OCCT命令集1(速查笔记)
OCCT命令集1
- 一、生成點(diǎn)、線、面和 shell
- BRepBuilderAPI_MakeEdge 點(diǎn)生成邊命令
- BRepBuilderAPI_MakeWire 邊生成曲線命令
- 生成面
- 1、BRepBuilderAPI_MakeFace 根據(jù)閉合線生成面
- 2、BRepFill::Face() wire生成face的函數(shù)。
- 生成shell
- 1、BRepFill::Shell() wire生成shell的函數(shù)。
- 2、BRepBuilderAPI_Sewing 具體見下面
- 生成Compound和solid
- 二、創(chuàng)造模型
- BRepPrimAPI_MakeCylinder 生成圓柱體命令
- BRepPrimAPI_MakeBox 生成長(zhǎng)方體命令
- 三、格式轉(zhuǎn)換
- 四、變形命令
- 拉伸,掃描,回轉(zhuǎn)拉伸命令;
- 倒圓角
- 倒直角
- 構(gòu)建空心實(shí)體
- 組裝命令
- 拔模命令
- 五、布爾命令(并集,交集,差集)
- 六、移動(dòng)命令
- 七、數(shù)據(jù)交互,導(dǎo)入導(dǎo)出
- 八、輔助類 TopExp_Explorer
一、生成點(diǎn)、線、面和 shell
BRepBuilderAPI_MakeEdge 點(diǎn)生成邊命令
//方法1gp_Pnt pt1(0,0,0);//gp_Pnt類定義點(diǎn)包含double的xyz。gp_Pnt pt2(1,1,1); TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(pt1,pt2); //方法2//TColgp_Array1OfPnt類定義點(diǎn)的數(shù)組。NCollection_Array1類定義了一個(gè)ArrayTColgp_Array1OfPnt array(1, num);for (int i = 1; i <= num; ++i) {array.SetValue(i, list[i - 1]);}GeomAPI_PointsToBSpline Approx(array);//GeomAPI_PointsToBSpline類用一組點(diǎn)近似得到BSpline曲線。***展開相關(guān)類Handle_Geom_BSplineCurve K = Approx.Curve();//Geom_BSplineCurve類是B_spline 曲線的定義TopoDS_Edge shape = BRepBuilderAPI_MakeEdge(K);//提供構(gòu)建edge的方法。BRepBuilderAPI_MakeWire 邊生成曲線命令
TopoDS_Edge edge1,edge2,edge3,edge4; TopoDS_Wire wireSrc = BRepBuilderAPI_MakeWire(edge4);TopoDS_Wire four_wire = BRepBuilderAPI_MakeWire(edge1, edge2, edge3, edge4);TopoDS_Face four_face = BRepBuilderAPI_MakeFace(four_wire); TopoDS_Edge edge1,edge2,edge3,edge4; BRepBuilderAPI_MakeWire wire;//導(dǎo)線,由邊組成。wire.Add(edge1);wire.Add(edge2);wire.Add(edge3);wire.Add(edge4);if (!wire.IsDone())return false;wireRect = wire.Wire();生成面
1、BRepBuilderAPI_MakeFace 根據(jù)閉合線生成面
TopoDS_Face face1 = BRepBuilderAPI_MakeFace(wire1); BRepBuilderAPI_MakeFace mf;mf.Init(face);mf.Add(holeWire);if (!mf.IsDone())return false;TopoDS_Face face2 = mf.Face(); BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(0,0,1)));if (!builder.IsDone())return;TopoDS_Shape shape = builder.Shape();2、BRepFill::Face() wire生成face的函數(shù)。
TopoDS_Face face = BRepFill::Face(TopoDS::Edge(shape1), TopoDS::Edge(shape2));生成shell
1、BRepFill::Shell() wire生成shell的函數(shù)。
TopoDS_Shell shell = BRepFill::Shell(TopoDS::Wire(shape1), TopoDS::Wire(shape2));2、BRepBuilderAPI_Sewing 具體見下面
生成Compound和solid
//構(gòu)建 復(fù)合模型BRep_Builder builder;TopoDS_Compound comp;builder.MakeCompound(comp); BRepBuilderAPI_MakeSolid solid(*shell1);if (!solid.IsDone())return false;TopoDS_Shape coverSolid = solid.Solid();二、創(chuàng)造模型
BRepPrimAPI_MakeCylinder 生成圓柱體命令
gp_Ax2 ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 30));TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(ax2, radius, height).Shape();BRepPrimAPI_MakeBox 生成長(zhǎng)方體命令
TopoDS_Shape box = BRepPrimAPI_MakeBox(x, y, z);三、格式轉(zhuǎn)換
TopoDS::Face 相關(guān)。 TopoDS包 是用于定義拓?fù)湫畔ⅰ?/p> //類型轉(zhuǎn)換都類似,這里只是列舉2個(gè) TopoDS_Wire wire = TopoDS::Wire(shape);//類型轉(zhuǎn)換 TopoDS_Face face = TopoDS::Face(mk.Shape());
四、變形命令
拉伸,掃描,回轉(zhuǎn)拉伸命令;
注意: 掃描,拉伸,回轉(zhuǎn)拉伸本質(zhì)相同
拉伸命令
BRepPrimAPI_MakePrism類 。拓?fù)湫畔?shí)體化,支持最簡(jiǎn)單的方體,錐形,圓柱,球體,還有基礎(chǔ)形狀的掃略拉伸。
另外:dir給負(fù)數(shù)可以挖洞。
旋轉(zhuǎn)掃描命令
BRepPrimAPI_MakeRevol類 生成生成旋轉(zhuǎn)掃描拓?fù)洹?/p>
TopoDS_Shape shape= BRepPrimAPI_MakeRevol(wire, gp::OZ());
BRepPrimAPI_MakeRevol mkRevol(mkFace.Face(), gp_Ax1(gp_Pnt(0,0,0), gp_Dir(0,0,1)),Base::toRadians<double>(angle3), Standard_True);TopoDS_Shape shape = mkRevol.Shape();
倒圓角
BRepFilletAPI_MakeFillet 描述在殼或?qū)嶓w的斷裂邊上構(gòu)建圓角的函數(shù)
//edges為需要倒圓角的所有邊; //shapeSrc為需要倒圓角的源模型;BRepFilletAPI_MakeFillet fillet(shapeSrc);auto iter = edges.begin();while (iter != edges.end()){TopoDS_Edge& e = *iter;fillet.Add(radus, e);iter++;}TopoDS_Shape shapeRes = fillet.Shape();if (shapeRes.IsNull())return false;return true;倒直角
BRepFilletAPI_MakeChamfer 類 倒直角命令
構(gòu)建空心實(shí)體
BRepOffsetAPI_MakeThickSolid 用于構(gòu)建空心實(shí)體的函數(shù)。
//構(gòu)建空心實(shí)體(有厚度)BRepOffsetAPI_MakeThickSolid BodyMaker;TopoDS_Shape solidSrc;TopoDS_Shape shapeRes;try{//solidSrc是實(shí)體;facesToRemove是被刪除的面集;Thickness定義墻的厚度;//1.e-6定義了生成形狀中重合的公差標(biāo)準(zhǔn);BodyMaker.MakeThickSolidByJoin(solidSrc, facesToRemove, -3, 1.e-6);//,//BRepOffset_Skin, Standard_False, Standard_False, GeomAbs_Intersection);shapeRes= BodyMaker.Shape();}catch (Standard_Failure){return false;}組裝命令
BRepBuilderAPI_Sewing 類 組裝不同shape、face。離心機(jī)的離線裝配中用到了。
BRepBuilderAPI_Sewing sew; sew.Add(shape1); sew.Add(shape2); sew.Add(shape3); sew.Add(shape4); sew.Perform(); TopoDS_Shape shapeRes = sew.SewedShape();拔模命令
拔模: 鑄造件更好的脫離磨具,添加的角度。
BRepOffsetAPI_DraftAngle類 拔模命令,太高一個(gè)角度。
五、布爾命令(并集,交集,差集)
BRepAlgoAPI_Fuse 類為并集Fuse。
BRepAlgoAPI_Fuse mkFuse;TopTools_ListOfShape shapeArguments,shapeTools;const TopoDS_Shape& shape = s.front();if (shape.IsNull())throw Base::RuntimeError("Input shape is null");shapeArguments.Append(shape);for (std::vector<TopoDS_Shape>::iterator it = s.begin()+1; it != s.end(); ++it) {if (it->IsNull())throw Base::RuntimeError("Input shape is null");shapeTools.Append(*it);}mkFuse.SetArguments(shapeArguments);mkFuse.SetTools(shapeTools);mkFuse.Build();if (!mkFuse.IsDone())throw Base::RuntimeError("MultiFusion failed");TopoDS_Shape resShape = mkFuse.Shape(); BRepAlgoAPI_Common類為交集comm,BRepAlgoAPI_Cut類為差集Cut。 從一個(gè)體中裁剪去另一個(gè)體。剪切命令六、移動(dòng)命令
BRepBuilderAPI_Transform 平移旋轉(zhuǎn)縮放命令。gp_Ax1類、gp_Trsf類實(shí)現(xiàn)繞軸旋轉(zhuǎn)矩陣。
gp_Trsf 配合上面命令的平移旋轉(zhuǎn)縮放矩陣,gp_Ax1 類是定義任意軸;
七、數(shù)據(jù)交互,導(dǎo)入導(dǎo)出
STEPControl_Writer 類和 STEPControl_Reader 類。
IGESControl_Writer 類和 IGESControl_Reader 類。
八、輔助類 TopExp_Explorer
TopExp_Explorer 函數(shù)可以用來探索該實(shí)體的edge,返回的結(jié)果為子形狀(sub-shape);同時(shí)該函數(shù)的經(jīng)常會(huì)使用其子函數(shù)More,Current,Next 放進(jìn)循環(huán)中
//遍歷for (TopExp_Explorer exp(shapSrc, TopAbs_FACE); exp.More(); exp.Next()){TopoDS_Face face = TopoDS::Face(exp.Current());Handle(Geom_Surface) geomSurface = BRep_Tool::Surface(face);//BRep_Tool類用于獲取相關(guān)shape的幾何信息。...} TopTools_IndexedMapOfShape anIndices;TopExp::MapShapes(s, type, anIndices);// 用于探索拓?fù)鋽?shù)據(jù)結(jié)構(gòu)的工具。在地圖<M>中存儲(chǔ)<S>的所有子形狀,類型<T>。總結(jié)
以上是生活随笔為你收集整理的OCCT命令集1(速查笔记)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux的PS1美化
- 下一篇: 气象数据获取