wordpress 自动图片页面优化的方法
OCC的基础知识可能还是要系统学习一下,部分导入的模型面类型是很多面都是GeomAbs_BSplineSurface,最终获取参数都要拟合一下,拟合后的生成的面对象没有大小,比如平面只有矢量(大小没有思路) 圆柱拟合面没有高度(圆柱最后我用的投影的方法获取高度)。
本章,拾取的面按步距生成点云,因为没有大小或者没办法通过UV控制,所以尝试通过点云类直接操作
1、通过点云生成TopoDS_Shape
可以尝试BRepLib_PointCloudShape
2、通过TopoDS_Shape 直接生成点云。
BRepLib_PointCloudShape 这个类可以实现。
参考连接:Open Cascade 7.7.0 新功能:模拟三维扫描点云-BRepLib_PointCloudShape - unicornsir - 博客园
代码如下:
a.类继承和虚函数的实现:
class PointCloudPntFiller : public BRepLib_PointCloudShape
{
public:
PointCloudPntFiller(Standard_Real theTol) : BRepLib_PointCloudShape(TopoDS_Shape(), theTol) {}
void SetPointArray(const Handle(Graphic3d_ArrayOfPoints)& thePoints) { myPoints = thePoints; }
protected:
virtual void addPoint(const gp_Pnt& thePoint,
const gp_Vec& theNorm,
const gp_Pnt2d& theUV,
const TopoDS_Shape&) Standard_OVERRIDE
{
const Standard_Integer aPntIndex = myPoints->AddVertex(thePoint, theUV);
if (theNorm.SquareMagnitude() > gp::Resolution())
{
myPoints->SetVertexNormal(aPntIndex, theNorm);
}
if (myPoints->HasVertexColors())
{
Quantity_Color aColor(360.0 * Standard_Real(aPntIndex) / Standard_Real(myPoints->VertexNumberAllocated()),
1.0, 0.5, Quantity_TOC_HLS);
myPoints->SetVertexColor(aPntIndex, aColor);
}
}
private:
Handle(Graphic3d_ArrayOfPoints) myPoints;
};
b,.类的调用
Handle(Graphic3d_ArrayOfPoints)thePoints=new Graphic3d_ArrayOfPoints(10000, false, true);;
PointCloudPntFiller thePointCloudPntFiller( Precision::Confusion());
thePointCloudPntFiller.SetShape(aFace);
thePointCloudPntFiller.SetDistance(uStep);
thePointCloudPntFiller.SetPointArray(thePoints);
thePointCloudPntFiller.GeneratePointsByDensity();
总结:
1、这个方法应该也可以根据密度生成网格小平面可以在和其他系统交互中把TopoDS_Shape 转换为数据
2、步距只能一个参数,不存UV 经纬这种操作。
我的遗留问题:为什么部分GeomAbs_BSplineSurface类型面通过BRepTools::UVBounds没办法获取大小。
double umin, umax, vmin, vmax;
BRepTools::UVBounds(aFace, umin, umax, vmin, vmax);