OpenCascade使用___三角面片细分与重组(转)
GeomConvert------- BSpline曲线、曲面拆分,Handle(Geom_Curve)转BSpline曲线
BRepExtrema_DistShapeShape------求两个TopoDS_Shape(TopoDS_Face、TopoDS_Vertex、TopoDS_Edge、TopoDS_Wire...)的最近距离,得到这个距离所对应的点【在TopoDS_Shape1上的和TopoDS_Shape2上的都可以得到】、最近距离的值、最近距离点的个数
GeomAPI_IntCS----求Geom_Curve和Geom_Surface的交点、交点,得到交点的个数和对应的交点、曲线段的条数、对应的曲线(Geom_Curve)
GeomAPI_IntSS----求Geom_Surface和Geom_Surface的交线,得到交线的条数和对应的交线
BRepAlgoAPI_Section---求TopoDS_Shape和TopoDS_Shape、Geom_Surface和TopoDS_Shape、TopoDS_Shape和gp_Pln相交后的数据,得到TopoDS_Shape【包含相交部分的数据,BRepAlgoAPI_Section继承于BRepBuilderAPI_MakeShape】
BRep_Tool---TopoDS_Face转Geom_Surface、TopoDS_Edge转Geom_Curve(转完后可以得到曲线U值范围)、TopoDS_Vertex转gp_Pnt
StlTransfer---TopoDS_Shape转StlMesh_Mesh
StlMesh_MeshExplorer---StlMesh_Mesh的遍历器、获得三角面片的三个顶点的x、y、z值
遍历示例:
TopoDS_Shape TrimNurbsToSTL( const TopoDS_Face& aTrimTopFace,Standard_Real precision ) { TopoDS_Face TopoFace = BRepBuilderAPI_MakeFace(aTrimTopFace).Face(); Handle_StlMesh_Mesh aSTLMesh = new StlMesh_Mesh(); StlTransfer::BuildIncrementalMesh(TopoFace, precision, Standard_False, aSTLMesh); Standard_Integer NumberDomains = aSTLMesh->NbDomains(); Standard_Integer iND; gp_XYZ p1, p2, p3; TopoDS_Vertex Vertex1, Vertex2, Vertex3; TopoDS_Face AktFace; TopoDS_Wire AktWire; BRepBuilderAPI_Sewing aSewingTool; Standard_Real x1, y1, z1; Standard_Real x2, y2, z2; Standard_Real x3, y3, z3; aSewingTool.Init(CAD_NURBS_STL_TOLERANCE,Standard_True); TopoDS_Compound aComp; BRep_Builder BuildTool; BuildTool.MakeCompound( aComp ); StlMesh_MeshExplorer aMExp (aSTLMesh); for (iND=1;iND<=NumberDomains;iND++) { for (aMExp.InitTriangle (iND); aMExp.MoreTriangle (); aMExp.NextTriangle ()) { aMExp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3); p1.SetCoord(x1,y1,z1); p2.SetCoord(x2,y2,z2); p3.SetCoord(x3,y3,z3); if ((!(p1.IsEqual(p2,0.0))) && (!(p1.IsEqual(p3,0.0)))) { Vertex1 = BRepBuilderAPI_MakeVertex(p1); Vertex2 = BRepBuilderAPI_MakeVertex(p2); Vertex3 = BRepBuilderAPI_MakeVertex(p3); AktWire = BRepBuilderAPI_MakePolygon( Vertex1, Vertex2, Vertex3, Standard_True); if( !AktWire.IsNull()) { AktFace = BRepBuilderAPI_MakeFace( AktWire); if(!AktFace.IsNull()) BuildTool.Add( aComp, AktFace ); } } } } aSTLMesh->Clear(); aSewingTool.Load( aComp ); aSewingTool.Perform(); TopoDS_Shape aShape = aSewingTool.SewedShape(); if ( aShape.IsNull() ) aShape = aComp; return aShape; }
StlMesh_Mesh---获得网格片数、网格面片中的三角面片个数
TopoDS_Shape---存储数据的拓扑结构
TopExp_Explorer---TopoDS_Shape的遍历器
遍历示例;
void example() { TopoDS_Shape aShape; TopoDS_Face aFace; TopoDS_Wire aWire; TopoDS_Edge aEdge; TopoDS_Vertex aVertex; TopExp_Explorer Exp_Edge; TopExp_Explorer Exp_Wire; TopExp_Explorer Exp_Face; TopExp_Explorer Exp_Vertex; for (Exp_Face.Init(aShape,TopAbs_FACE);Exp_Face.More();Exp_Face.Next()) { aFace = TopoDS::Face(Exp_Face.Current()); for (Exp_Wire.Init(aFace,TopAbs_WIRE);Exp_Wire.More();Exp_Wire.Next()) { aWire = TopoDS::Wire(Exp_Wire.Current()); for (Exp_Edge.Init(aWire,TopAbs_EDGE);Exp_Edge.More();Exp_Edge.Next()) { aEdge = TopoDS::Edge(Exp_Edge.Current()); for (Exp_Vertex.Init(aEdge,TopAbs_VERTEX);Exp_Vertex.More();Exp_Vertex.Next()) { aVertex = TopoDS::Vertex(Exp_Vertex.Current()); gp_Pnt Pnt = BRep_Tool::Pnt(aVertex); } } } } for (Exp_Vertex.Init(aShape,TopAbs_VERTEX);Exp_Vertex.More();Exp_Vertex.Next()) { aVertex = TopoDS::Vertex(Exp_Vertex.Current()); gp_Pnt Pnt = BRep_Tool::Pnt(aVertex); } for (Exp_Edge.Init(aShape,TopAbs_EDGE);Exp_Edge.More();Exp_Edge.Next()) { aEdge = TopoDS::Edge(Exp_Edge.Current()); Standard_Real First,Last; Handle(Geom_Curve) Pnt = BRep_Tool::Curve(aEdge,First,Last); } for (Exp_Wire.Init(aShape,TopAbs_WIRE);Exp_Wire.More();Exp_Wire.Next()) { aWire = TopoDS::Wire(Exp_Wire.Current()); } for (Exp_Face.Init(aShape,TopAbs_WIRE);Exp_Face.More();Exp_Face.Next()) { aFace = TopoDS::Face(Exp_Face.Current()); Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace); } }
拓扑创建:
BRepBuilderAPI_MakeVertex = TopoDS_Vertex BRepBuilderAPI_MakeEdge = TopoDS_Edge BRepBuilderAPI_MakeWire = TopoDS_Wire BRepBuilderAPI_MakeFace = TopoDS_Face BRepBuilderAPI_MakePolygon = TopoDS_Wire //直线框
几何容器:数组队列
TColGeom_xxxxxxxxxxxxxxxxxx
TColgp_xxxxxxxxxxxxxxxxxxxxxx
TColStd_xxxxxxxxxxxxxxxxxxxxx
TDataStd_xxxxxxxxxxxxxxxxxxx
————————————————
版权声明:本文为CSDN博主「少莫千华」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chenlu5201314/article/details/8687364