教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

Open CASCADE基础介绍(10)

来源:网络收集 时间:2026-08-23
导读: 绕一个轴旋转: gp_Trsf theTransformation; gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); theTransformation.SetRotation(axe,30*PI/180); 示例三: 缩放: gp_Trsf theTransformation; gp_Pnt theC

绕一个轴旋转:

gp_Trsf theTransformation;

gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); theTransformation.SetRotation(axe,30*PI/180);

示例三: 缩放:

gp_Trsf theTransformation;

gp_Pnt theCenterOfScale(200,60,60);

theTransformation.SetScale(theCenterOfScale,0.5);

示例四: 平移:

gp_Trsf theTransformation;

gp_Vec theVectorOfTranslation(-6,-6,6);

theTransformation.SetTranslation(theVectorOfTranslation);

示例五:

Displacement:

TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); gp_Trsf theTransformation;

gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1)); gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1)); theTransformation.SetDisplacement(ax3_1,ax3_2);

BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation); TopoDS_Shape TransformedShape = myBRepTransformation.Shape();

示例六: 变形

gp_GTrsf theTransformation;

gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5); theTransformation.SetVectorialPart(rot);

theTransformation.SetTranslationPart(gp_XYZ(5,5,5));

BRepBuilderAPI_GTransform myBRepTransformation(S,theTransformation); TopoDS_Shape S2 = myBRepTransformation.Shape();

BuilderAPI_MakeEdge类定义一生成一个边;此类有多个构造函数,现举

其中一个介绍如下:

Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L,const Handle(Geom_Surface)& S,const TopoDS_Vertex& V1,const TopoDS_Vertex& V2,const Standard_Real p1,const Standard_Real p2); 其参数含义是:

顶点V1和V2用来限制曲线(定义边的约束),值p1和p2为顶点的参数; 曲线可以定义成在一个表面的2D曲线,应用缺省的公差; 参数规则: 对于曲线来说: --句柄不能为空;

--如果曲线是一个trimmed曲线,使用基础曲线; 对于顶点来说:

--可以为空,表示此参数为无限大;静态方法 Precision::Infinite()用来定义一个无限大的数; --两个顶点如果位于同一位置,必须一样,当曲线是封闭时使用相同的顶点; 对于参数来说:

--参数为必须在曲线参数范围内,如果曲线是trimmed,使用基础曲线;如果边的条件不满足,返回BRepAPI_ParameterOutOfRange错误;

--参数值不能相等,如果条件不满足,边无法创建,返回BRepAPI_LineThroughIdenticPoints错误;

--参数值可以这样给出C->FirstParameter()

--如果参数值需要切换,比如第一个顶点的参数为P2,第二个顶点的参数为P1,边的方向可以“reversed”;

--对于一个周期曲线,值P1和P2可以通过加或减周期来得到;

--参数值可以无限大,在对应的方向上边是开放的。然而,对应的顶点必须是空图形,如果条件不满足,边无法创建,返回BRepAPI_PointWithInfiniteParameter错误; --参数值可以被忽略,将通过曲线上的投影进行计算; --可以给定空间三维点;

BRepFeat_MakePipe类基类为:BRepFeat_Form;

通过基本图形生成一个Pipe;

BRepFeat_MakeLinearForm 类

基类为:BRepFeat_RibSlot

在一个平面表面上建一个肋或开凹槽;

BRepFeat_Gluer类粘合两个实体为一个实体;

示例: (1):创建两个BOX,并找到要粘合的面; (2):创建要粘合的对象: BRepFeat_Gluer glue2(S4,S3); (3):用两个面粘合对象; glue2.Bind(F4,F3); (4):重新生成对象:

LocOpe_FindEdges CommonEdges(F4,F3);

for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next())

glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());

TopoDS_Shape res2 = glue2.Shape();

myAISContext->Erase(ais3,Standard_False,Standard_False);

ais4->Set(res2);

myAISContext->Redisplay(ais4,Standard_False);

Graphic2d_Polyline类

创建一个多边形. 常见方法:

--Length()得到线的点数;

--void Values(const Standard_Integer aRank,Quantity_Length& X,Quantity_Length& Y) const;得到序号为aRank的点;

--void DrawElement(const Handle(Graphic2d_Drawer)& aDrawer,const Standard_Integer anIndex) ;绘制多边形的一条边;

--void DrawVertex(const Handle(Graphic2d_Drawer)& aDrawer,const Standard_Integer anIndex) ;绘制多边形的一个顶点;

--Standard_Boolean Pick(const Standard_ShortReal X,const Standard_ShortReal Y,const Standard_ShortReal aPrecision,const Handle(Graphic2d_Drawer)& aDrawer) ;得到此多边形是否被拾取,注意:PickIndex()方法得到的是最后拾取的点,如果拾取点在线的内部,返回0;

Graphic2d_Line类是Polyline, Circle ... 等图元的基类;

常见方法:

--SetWidthIndex(const Standard_Integer anIndex) ;得到在width map中的宽度的索引;设定对应的线宽值;

--SetTypeIndex(const Standard_Integer anIndex) ;设置线型;

--SetInteriorColorIndex(const Standard_Integer anIndex) ;设置颜色;

--void SetDrawEdge(const Standard_Boolean aDraw) ;设置边是否绘出,注意,这种情况下,polygon的类型必须为:

Graphic2d_TOPF_FILLED 或者 Graphic2d_TOPF_PATTERNED;

--SetInteriorPattern(const Standard_Integer anIndex) ;定义封闭线的内部图案,polygon的填充类型必须是:Graphic2d_TOPF_PATTERNED;

--SetTypeOfPolygonFilling(const Graphic2d_TypeOfPolygonFilling aType) ;定义封闭线的图案,TypeOfPolygonFilling可选类型有:

- Graphic2d_TOPF_EMPTY - Graphic2d_TOPF_FILLED - Graphic2d_TOPF_PATTERNED ; --Standard_Integer InteriorColorIndex() const;得到颜色索引;

--Standard_Integer InteriorPattern() const;得到所使用的图案索引;

--Graphic2d_TypeOfPolygonFilling TypeOfPolygonFilling() const;得到多边形填充模式;

…… 此处隐藏:1877字,全部文档内容请下载后查看。喜欢就下载吧 ……
Open CASCADE基础介绍(10).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/591939.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)