1.1.1 拓撲變換描述

1.1.2 BRepBuilderAPI_Transform
(1) 功能說明:拓撲變換
此對象與gp_Trsf相關聯進行變換
(2) 構造函數:
public OCBRepBuilderAPI_Transform(OCgp_Trsf T);
public OCBRepBuilderAPI_Transform(OCTopoDS_Shape S, OCgp_Trsf T, bool Copy);
(3) 參數說明:
T:要進行的變換
S:進行變換的拓撲圖形
Copy:是否用副本進行變換
(4) 備注:
Perform是該對象的一個方法。
OCBRepBuilderAPI_Transform(OCgp_Trsf T) 與public void Perform(OCTopoDS_Shape S, bool Copy)相等于OCBRepBuilderAPI_Transform(OCTopoDS_Shape S, OCgp_Trsf T, bool Copy)。
(5) 執行個體:
例1:點對稱
OCTopoDS_Shape S;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Pnt PntCenterOfTheTransformation = new OCgp_Pnt(110, 60, 60);
theTransformation.SetMirror(PntCenterOfTheTransformation);//鏡像
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例2:軸對稱
OCTopoDS_Shape S ;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Ax1 axe = new OCgp_Ax1(new OCgp_Pnt(110, 60, 60), new OCgp_Dir(0.0, 1.0, 0.0));
theTransformation.SetMirror(axe);//鏡像
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例3:面對稱
OCTopoDS_Shape S = new OCBRepPrimAPI_MakeWedge(60.0, 100.0, 80.0, 20.0).Shape();
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Ax2 axe2 = new OCgp_Ax2(new OCgp_Pnt(0, 0, 0), new OCgp_Dir(1, 0, 0));
theTransformation.SetMirror(axe2);//鏡像
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例4:旋轉變換
OCTopoDS_Shape S;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Ax1 axe = new OCgp_Ax1(new OCgp_Pnt(200, 60, 60), new OCgp_Dir(0.0, 1.0, 0.0));
theTransformation.SetRotation(axe, 30 * System.Math.PI / 180);
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例5:縮放變換
OCTopoDS_Shape S;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Pnt theCenterOfScale = new OCgp_Pnt(100, 60, 60);
theTransformation.SetScale(theCenterOfScale, 0.3);
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例6:平移變換
OCTopoDS_Shape S;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Vec theVectorOfTranslation = new OCgp_Vec(-6, -6, 6);
theTransformation.SetTranslation(theVectorOfTranslation);
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();
例7:移位(Displacement)變換
OCTopoDS_Shape S;
OCgp_Trsf theTransformation = new OCgp_Trsf();
OCgp_Ax3 ax3_1 = new OCgp_Ax3(new OCgp_Pnt(0, 0, 0), new OCgp_Dir(0, 0, 1));
OCgp_Ax3 ax3_2 = new OCgp_Ax3(new OCgp_Pnt(60, 60, 60), new OCgp_Dir(1, 1, 1));
theTransformation.SetDisplacement(ax3_1, ax3_2);
OCBRepBuilderAPI_Transform myBRepTransformation =
new OCBRepBuilderAPI_Transform(S, theTransformation, false);
OCTopoDS_Shape TransformedShape = myBRepTransformation.Shape();
1.1.3 BRepBuilderAPI_GTransform
(1) 功能說明:拓撲變換
此對象與gp_GTrsf相關聯進行變換
(2) 構造函數:
public OCBRepBuilderAPI_GTransform(OCgp_GTrsf T);
public OCBRepBuilderAPI_GTransform(OCTopoDS_Shape S, OCgp_GTrsf T, bool Copy);
(3) 參數說明:
T:要進行的變換
S:進行變換的拓撲圖形
Copy:是否用副本進行變換
(4) 執行個體:
例1:變形(deform)變換
OCTopoDS_Shape S;
OCgp_GTrsf theTransformation = new OCgp_GTrsf();
OCgp_Mat rot = new OCgp_Mat(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);
theTransformation.SetVectorialPart(rot);
// SetVectorialPart-----Replaces the vectorial part of this transformation by Matrix
theTransformation.SetTranslationPart(new OCgp_XYZ(5, 5, 5));
//SetTranslationPart-----
//Replaces the translation part of this transformation by the coordinates
OCBRepBuilderAPI_GTransform myBRepTransformation =
new OCBRepBuilderAPI_GTransform(S, theTransformation, false);
OCTopoDS_Shape S2 = myBRepTransformation.Shape();