Open CASCADE学习|扫掠

2024-02-11 17:12
文章标签 学习 open cascade 扫掠

本文主要是介绍Open CASCADE学习|扫掠,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

1、BRepPrimAPI_MakePrism

Draw Test Harness:

C++:

2、BRepPrimAPI_MakeRevol

Draw Test Harness:

C++:

3、BRepOffsetAPI_MakePipeShell

Draw Test Harness:

C++:

Draw Test Harness:

C++:

Draw Test Harness:

C++:​

锥度弯曲管

参考文献:


1、BRepPrimAPI_MakePrism

生成线性扫掠

Draw Test Harness:

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0prism r p 0 0 1vdisplay p r

C++:

#include <BRepBuilderAPI_MakePolygon.hxx>#include <BRepPrimAPI_MakePrism.hxx>#include"Viewer.h"int main(int argc, char* argv[]){    BRepBuilderAPI_MakePolygon p;    p.Add(gp_Pnt(0,0, 0));    p.Add(gp_Pnt(1, 0, 0));    p.Add(gp_Pnt(1, 2, 0));    p.Add(gp_Pnt(0, 1, 0));    p.Add(gp_Pnt(0, 0, 0));    TopoDS_Shape r=BRepPrimAPI_MakePrism(p,gp_Vec(0,0,1));    Viewer vout(50, 50, 500, 500);    vout << r;    vout.StartMessageLoop();    return 0;}

2、BRepPrimAPI_MakeRevol

生成旋转扫掠

Draw Test Harness:

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0revol r p 3 0 0 0 1 0 280vdisplay p r

C++:

#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepPrimAPI_MakeRevol.hxx>
​
#include"Viewer.h"
​
int main(int argc, char* argv[])
{BRepBuilderAPI_MakePolygon p;p.Add(gp_Pnt(0,0, 0));p.Add(gp_Pnt(1, 0, 0));p.Add(gp_Pnt(1, 2, 0));p.Add(gp_Pnt(0, 1, 0));p.Add(gp_Pnt(0, 0, 0));TopoDS_Shape r= BRepPrimAPI_MakeRevol(p, gp_Ax1(gp_Pnt(3,0,0), gp_Dir(0,1,0)),280*M_PI/180);Viewer vout(50, 50, 500, 500);vout << r;vout.StartMessageLoop();return 0;
​
}
​

3、BRepOffsetAPI_MakePipeShell

生成通用的扫掠。该类提供了一个框架,沿着脊柱的导线构建一个shell或者solid。构造solid,初始线框必须闭合的。

在Draw Test Harness中使用如下命令:

mksweep

addsweep

deletesweep

sestsweep

sestsweep有以下选项

-FR选项:切矢和法向由Frenet标架确定;

-CF选项:切矢由Frenet标架指定,法向通过计算最小扭转来确定;

-DT选项:切矢和法向由Darboux标架确定;

-CN选项:副法向由指定的dx, dy, dz确定;

-FT:切矢和法向是固定的;

buildsweep

buildsweep有指定不连续的处理方式及是否生成实体。其中

-C:将路径Path中不连续的地方通过延长和相交进行处理;

-R:将路径Path中不连续的地方通过相交和填充进行处理;

Draw Test Harness:

polyline p  0 0 0 1 0 0 1 2 0 0 1 0circle c 0 0 0 1 0 0 0.2mkedge e cwire w emksweep paddsweep wsetsweep -FX 1 0 0buildsweep r -Cvdisplay p w r

C++:

#include <BRepBuilderAPI_MakePolygon.hxx>
#include <Geom_Circle.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <TopoDS.hxx>
​
#include"Viewer.h"
​
int main(int argc, char* argv[])
{BRepBuilderAPI_MakePolygon p;p.Add(gp_Pnt(0,0, 0));p.Add(gp_Pnt(1, 0, 0));p.Add(gp_Pnt(1, 2, 0));p.Add(gp_Pnt(0, 1, 0));p.Add(gp_Pnt(0, 0, 0));Handle(Geom_Circle) c = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 0.2);TopoDS_Edge e = BRepBuilderAPI_MakeEdge(c);BRepBuilderAPI_MakeWire w;w.Add(e);BRepOffsetAPI_MakePipeShell* Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(p));gp_Dir D(1, 0, 0);gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);Sweep->SetMode(Axe);BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;Transition = BRepBuilderAPI_RightCorner;Sweep->SetTransitionMode(Transition);Sweep->Add(w, Standard_False, Standard_False);Sweep->Build();TopoDS_Shape r = Sweep->Shape();Viewer vout(50, 50, 500, 500);vout << p;vout << w;vout << r;vout.StartMessageLoop();return 0;
​
}
​

Draw Test Harness:

mksweep paddsweep wsetsweep -FRbuildsweep r -Cvdisplay p w r

C++:

#include <BRepBuilderAPI_MakePolygon.hxx>
#include <Geom_Circle.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <TopoDS.hxx>
​
#include"Viewer.h"
​
int main(int argc, char* argv[])
{BRepBuilderAPI_MakePolygon p;p.Add(gp_Pnt(0,0, 0));p.Add(gp_Pnt(1, 0, 0));p.Add(gp_Pnt(1, 2, 0));p.Add(gp_Pnt(0, 1, 0));p.Add(gp_Pnt(0, 0, 0));Handle(Geom_Circle) c = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 0.2);TopoDS_Edge e = BRepBuilderAPI_MakeEdge(c);BRepBuilderAPI_MakeWire w;w.Add(e);BRepOffsetAPI_MakePipeShell* Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(p));Sweep->SetMode(Standard_True);BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;Transition = BRepBuilderAPI_RightCorner;Sweep->SetTransitionMode(Transition);Sweep->Add(w, Standard_False, Standard_False);Sweep->Build();TopoDS_Shape r = Sweep->Shape();Viewer vout(50, 50, 500, 500);vout << p;vout << w;vout << r;vout.StartMessageLoop();return 0;
​
}
​

Draw Test Harness:

polyline p  0 0 0 1 0 0 1 2 0 0 1 0 0 0 0circle c 0 0 0 1 0 0 0.2mkedge e cwire w emksweep paddsweep wbuildsweep r -Rvdisplay p w r

C++:

#include <BRepBuilderAPI_MakePolygon.hxx>
#include <Geom_Circle.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <TopoDS.hxx>
​
#include"Viewer.h"
​
int main(int argc, char* argv[])
{BRepBuilderAPI_MakePolygon p;p.Add(gp_Pnt(0,0, 0));p.Add(gp_Pnt(1, 0, 0));p.Add(gp_Pnt(1, 2, 0));p.Add(gp_Pnt(0, 1, 0));p.Add(gp_Pnt(0, 0, 0));Handle(Geom_Circle) c = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 0.2);TopoDS_Edge e = BRepBuilderAPI_MakeEdge(c);BRepBuilderAPI_MakeWire w;w.Add(e);BRepOffsetAPI_MakePipeShell* Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(p));Sweep->Add(w, Standard_False, Standard_False);Sweep->SetMode(Standard_True);BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;Transition = BRepBuilderAPI_RoundCorner;Sweep->SetTransitionMode(Transition);Sweep->Build();TopoDS_Shape r = Sweep->Shape();Viewer vout(50, 50, 500, 500);vout << p;vout << w;vout << r;vout.StartMessageLoop();return 0;
​
}
​

锥度弯曲管

#include <Geom_BezierCurve.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <Law_Linear.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom2d_TrimmedCurve.hxx>
​
#include <GCE2d_MakeSegment.hxx>
​
#include <GeomAPI_PointsToBSpline.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <GC_MakeCircle.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
​
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
​
#include"Viewer.h"
​
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
​
int main(int argc, char* argv[])
{//Creation of points for the spineTColgp_Array1OfPnt array = TColgp_Array1OfPnt(1, 5);array.SetValue(1, gp_Pnt(1, 4, 0));array.SetValue(2, gp_Pnt(2, 2, 0));array.SetValue(3, gp_Pnt(3, 3, 0));array.SetValue(4, gp_Pnt(4, 3, 0));array.SetValue(5, gp_Pnt(5, 5, 0));
​//Creation of a Bezier Curve as the spine #创建贝塞尔曲线作为主干Geom_BezierCurve* bz_curv = new Geom_BezierCurve(array);TopoDS_Edge bz_curv_edge = BRepBuilderAPI_MakeEdge(bz_curv);TopoDS_Wire bz_curv_wire = BRepBuilderAPI_MakeWire(bz_curv_edge);
​//Creation of profile to sweep along the spine #创建沿脊柱扫描的轮廓gp_Circ circle = gp_Circ(gp::ZOX(), 1);circle.SetLocation(array[1]);TopoDS_Edge circle_edge = BRepBuilderAPI_MakeEdge(circle);TopoDS_Wire circle_wire = BRepBuilderAPI_MakeWire(circle_edge);//Creation of the law to dictate the evolution of the profile#规定轮廓的演变BRepOffsetAPI_MakePipeShell* brep1 = new BRepOffsetAPI_MakePipeShell(bz_curv_wire);Handle(Law_Linear) law_f =new Law_Linear();law_f->Set(0, 0.5, 1, 1);brep1->SetLaw(circle_wire, law_f, Standard_False,Standard_True);Viewer vout(50, 50, 500, 500);vout << bz_curv_wire;vout << brep1->Shape();vout.StartMessageLoop();return 0;
​
}
​


参考文献:

1、https://dev.opencascade.org/doc/occt-7.0.0/refman/html/class_b_rep_offset_a_p_i___make_pipe_shell.html#details

2、https://www.cnblogs.com/opencascade/p/OpenCASCADE_Sweep_Algorithm.html

3、https://blog.csdn.net/ydk001001/article/details/121210419

这篇关于Open CASCADE学习|扫掠的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/700367

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss

【学习笔记】 陈强-机器学习-Python-Ch15 人工神经网络(1)sklearn

系列文章目录 监督学习:参数方法 【学习笔记】 陈强-机器学习-Python-Ch4 线性回归 【学习笔记】 陈强-机器学习-Python-Ch5 逻辑回归 【课后题练习】 陈强-机器学习-Python-Ch5 逻辑回归(SAheart.csv) 【学习笔记】 陈强-机器学习-Python-Ch6 多项逻辑回归 【学习笔记 及 课后题练习】 陈强-机器学习-Python-Ch7 判别分析 【学

系统架构师考试学习笔记第三篇——架构设计高级知识(20)通信系统架构设计理论与实践

本章知识考点:         第20课时主要学习通信系统架构设计的理论和工作中的实践。根据新版考试大纲,本课时知识点会涉及案例分析题(25分),而在历年考试中,案例题对该部分内容的考查并不多,虽在综合知识选择题目中经常考查,但分值也不高。本课时内容侧重于对知识点的记忆和理解,按照以往的出题规律,通信系统架构设计基础知识点多来源于教材内的基础网络设备、网络架构和教材外最新时事热点技术。本课时知识

线性代数|机器学习-P36在图中找聚类

文章目录 1. 常见图结构2. 谱聚类 感觉后面几节课的内容跨越太大,需要补充太多的知识点,教授讲得内容跨越较大,一般一节课的内容是书本上的一章节内容,所以看视频比较吃力,需要先预习课本内容后才能够很好的理解教授讲解的知识点。 1. 常见图结构 假设我们有如下图结构: Adjacency Matrix:行和列表示的是节点的位置,A[i,j]表示的第 i 个节点和第 j 个

Node.js学习记录(二)

目录 一、express 1、初识express 2、安装express 3、创建并启动web服务器 4、监听 GET&POST 请求、响应内容给客户端 5、获取URL中携带的查询参数 6、获取URL中动态参数 7、静态资源托管 二、工具nodemon 三、express路由 1、express中路由 2、路由的匹配 3、路由模块化 4、路由模块添加前缀 四、中间件