OGG几何内核-BRepBuilderAPI_MakeEdge学习

OGG几何内核fork自OCCT 7.7.0,

BRepBuilderAPI_MakeEdge是几何内核的一个重要和基础的功能,也十分复杂,因为要支持line、circle、ellipse,parabola,hyperbola,circle,beziercurve,bsplinecurve。需要支持多种参数情况:

1、曲线。

2、曲线+始终长度。

3、曲线+始终角度。

4、曲线+两点。

5、曲线+面。

代码注释如下:

Provides methods to build edges.

The   methods have  the  following   syntax, where TheCurve is one of Lin, Circ, ...

Create(C : TheCurve)

Makes an edge on  the whole curve.  Add vertices on finite curves.

Create(C : TheCurve; p1,p2 : Real)

Make an edge  on the curve between parameters p1 and p2. if p2 < p1 the edge will be REVERSED. If p1  or p2 is infinite the  curve will be open in that  direction. Vertices are created for finite values of p1 and p2.

Create(C : TheCurve; P1, P2 : Pnt from gp)

Make an edge on the curve  between the points P1 and P2. The  points are projected on   the curve and the   previous method is  used. An  error is raised if the points are not on the curve.

Create(C : TheCurve; V1, V2 : Vertex from TopoDS)

Make an edge  on the curve  between the vertices V1 and V2. Same as the  previous but no vertices are created. If a vertex is  Null the curve will be open in this direction.

class BRepBuilderAPI_MakeEdge  : public BRepBuilderAPI_MakeShape
{
public:DEFINE_STANDARD_ALLOCStandard_EXPORT BRepBuilderAPI_MakeEdge();Standard_EXPORT BRepBuilderAPI_MakeEdge(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);//! The general method to directly create an edge is to give//! -      a 3D curve C as the support (geometric domain) of the edge,//! -      two vertices V1 and V2 to limit the curve (definition of the restriction of//! the edge), and//! -      two real values p1 and p2 which are the parameters for the vertices V1 and V2//! on the curve.//! The curve may be defined as a 2d curve in the parametric space of a surface: a//! pcurve. The surface on which the edge is built is then kept at the level of the edge.//! The default tolerance will be associated with this edge.//! Rules applied to the arguments://! For the curve://! -      The curve must not be a 'null handle'.//! -      If the curve is a trimmed curve the basis curve is used.//! For the vertices://! -      Vertices may be null shapes. When V1 or V2 is null the edge is open in the//! corresponding direction and the parameter value p1 or p2 must be infinite//! (remember that Precision::Infinite() defines an infinite value).//! -      The two vertices must be identical if they have the same 3D location.//! Identical vertices are used in particular when the curve is closed.//! For the parameters://! -      The parameters must be in the parametric range of the curve (or the basis//! curve if the curve is trimmed). If this condition is not satisfied the edge is not//! built, and the Error function will return BRepAPI_ParameterOutOfRange.//! -      Parameter values must not be equal. If this condition is not satisfied (i.e.//! if | p1 - p2 | ) the edge is not built, and the Error function will return//! BRepAPI_LineThroughIdenticPoints.//! Parameter values are expected to be given in increasing order://! C->FirstParameter()//! - If the parameter values are given in decreasing order the vertices are switched,//! i.e. the "first vertex" is on the point of parameter p2 and the "second vertex" is//! on the point of parameter p1. In such a case, to keep the original intent of the//! construction, the edge will be oriented "reversed".//! - On a periodic curve the parameter values p1 and p2 are adjusted by adding or//! subtracting the period to obtain p1 in the parametric range of the curve, and p2]//! such that [ p1 , where Period is the period of the curve.//! - A parameter value may be infinite. The edge is open in the corresponding//! direction. However the corresponding vertex must be a null shape. If this condition//! is not satisfied the edge is not built, and the Error function will return//! BRepAPI_PointWithInfiniteParameter.//! - The distance between the vertex and the point evaluated on the curve with the//! parameter, must be lower than the precision of the vertex. If this condition is not//! satisfied the edge is not built, and the Error function will return//! BRepAPI_DifferentsPointAndParameter.//! Other edge constructions//! - The parameter values can be omitted, they will be computed by projecting the//! vertices on the curve. Note that projection is the only way to evaluate the//! parameter values of the vertices on the curve: vertices must be given on the curve,//! i.e. the distance from a vertex to the curve must be less than or equal to the//! precision of the vertex. If this condition is not satisfied the edge is not built,//! and the Error function will return BRepAPI_PointProjectionFailed.//! -      3D points can be given in place of vertices. Vertices will be created from the//! points (with the default topological precision Precision::Confusion()).//! Note://! -      Giving vertices is useful when creating a connected edge.//! -      If the parameter values correspond to the extremities of a closed curve,//! points must be identical, or at least coincident. If this condition is not//! satisfied the edge is not built, and the Error function will return//! BRepAPI_DifferentPointsOnClosedCurve.//! -      The vertices or points can be omitted if the parameter values are given. The//! points will be computed from the parameters on the curve.//! The vertices or points and the parameter values can be omitted. The first and last//! parameters of the curve will then be used.//!//! Auxiliary methodsStandard_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);Standard_EXPORT void Init (const Handle(Geom_Curve)& C);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);//! Defines or redefines the arguments for the construction of an edge.//! This function is currently used after the empty constructor BRepAPI_MakeEdge().Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);protected:private:BRepLib_MakeEdge myMakeEdge;};

从最后几行代码,结合可以发现,BRepBuilderAPI_MakeEdge是BRepLib_MakeEdge的包装,实际功能由BRepLib_MakeEdge实现。

为了能更深入理解BRepBuilderAPI_MakeEdge,可以研究分析一下测试命令mkedge的代码。

static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const char** a)
{if (n < 3) return 1;Handle(Geom_Curve)   C   = DrawTrSurf::GetCurve(a[2]);Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);if (C.IsNull() && C2d.IsNull()) {//std::cout << a[2] << " is not a curve" << std::endl;di << a[2] << " is not a curve\n";return 1;}TopoDS_Edge edge;if (n == 3) {if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C);else               edge = BRepBuilderAPI_MakeEdge2d(C2d);}else {Handle(Geom_Surface) S;Standard_Integer i = 0;if (!C2d.IsNull()) {S = DrawTrSurf::GetSurface(a[3]);if (!S.IsNull()) i = 1;}TopoDS_Shape aLocalShape(DBRep::Get(a[3+i],TopAbs_VERTEX));TopoDS_Vertex V1 = TopoDS::Vertex(aLocalShape);
//    TopoDS_Vertex V1 = TopoDS::Vertex(DBRep::Get(a[3+i],TopAbs_VERTEX));if (n == 5+i) {if (V1.IsNull()) {if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,Draw::Atof(a[3]),Draw::Atof(a[4]));else if (S.IsNull())              edge = BRepBuilderAPI_MakeEdge2d(C2d,Draw::Atof(a[3]),Draw::Atof(a[4]));elseedge = BRepBuilderAPI_MakeEdge(C2d,S,Draw::Atof(a[4]),Draw::Atof(a[5]));}else {aLocalShape = DBRep::Get(a[4+i],TopAbs_VERTEX);TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape);
//  TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[4+i],TopAbs_VERTEX));if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,V1,V2);else if (S.IsNull())              edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2);elseedge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2);}}  else if (n == 7+i) {aLocalShape = DBRep::Get(a[5+i],TopAbs_VERTEX);TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape);
//      TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[5+i],TopAbs_VERTEX));if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));else if (S.IsNull())         edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));else              edge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2,Draw::Atof(a[5]),Draw::Atof(a[7]));}elsereturn 1;}DBRep::Set(a[1],edge);return 0;
}

以下是各种曲线生成及参数测试:

vertex a 0 0 0
vertex b 6 0 0
vertex c 6 1 0
vertex d 6 0 0
edge l a b
mkcurve curve1 l
mkedge l1 curve1 1 2
mkedge l2 curve1 a b
mkedge l3 curve1 a c
mkedge l4 curve1 a dcircle c 0 0 0 10
mkedge c1 c 0 pi/4
mkedge c1 c 0 pi/2
mkedge c1 c 0 pi
mkedge c1 c 0 2*pi
mkedge c1 c 0 2pi
mkedge c1 c -pi pi
mkedge c1 c -pi/2 0mkedge e1 a bparabola w1 0 0 0 1 0 0 0 0 1 50
mkedge p1 w1 -100 100beziercurve w2 5 0 0 0 20 0 0 20 5 0 25 10 0 10 20 0
mkedge b1 w2 
mkedge b1 w2 0 0.5
mkedge b1 w2 0 0.9
mkedge b1 w2 0 1
mkedge b1 w2 0 2bsplinecurve w3 3 2  -1.0 4   1.0 4  0 0 0 1  2 10 0 1  4 6 0 1  10 0 0 1
mkedge b2 w3
mkedge b2 w3  0 0.5

通过这些测试命令,可以观察看到线的方向,以及OCCT对不同类型的线生成的edge的处理方式不同。

抛物线和双曲线:

beziercurve和bsplinecurve

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/13709.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

springboot常用的注解

启动注解(Spring Boot 应用的入口注解)@SpringBootApplication @SpringBootApplication 是一个注解,它是 Spring Boot 应用的入口注解,用于表示一个应用程序的主类。这个注解通常被放置在包含 main() 方法的类上。@SpringBootApplication 是一个组合注解,整合了以下三个注…

亚马逊测评还能做吗?

只能说测评不是唯一的手段&#xff0c;但是推销量的一把好手。首先测评能让listing快速成长&#xff0c;短期内有望成为爆款&#xff0c;速度快&#xff0c;利润高&#xff0c;回款快。相对其他推广&#xff0c;测评无疑是有效&#xff0c;省培养listing的方法。其次新品前期太…

设计模式六大原则

开闭原则&#xff1a;对修改封闭&#xff0c;对拓展开放。 单一职责原则&#xff1a;类的功能要专一。 里氏代换原则&#xff1a;子类继承父类的时候&#xff0c;除添加新的方法完成新增功能外&#xff0c;尽量不要重写父类方法。 依赖倒转原则&#xff1a;类要依赖接口&…

Hsql每日一题 | day01

前言 就一直向前走吧&#xff0c;沿途的花终将绽放~ 题目&#xff1a;找出连续活跃3天及以上的用户 create table t_useractive(uid string,dt string );insert into t_useractive values(A,2023-10-01),(A,2023-10-02),(A,2023-10-03),(A,2023-10-04),(B,2023-10-01),(B…

代码随想录打卡第38天:动态规划解决编辑距离和回文串

1.72编辑距离 1.问题描述 找到其中需要进行操作的最少次数。 2.问题转换 大体思路可以参照前面的两个字符串的删除操作。添加操作可以将其看做是一个另类的删除操作&#xff0c;所以最后全部都可以看做是一个删除操作 3.解题思路 每一个位置的word1[i]和word2[j]都有两种…

RTOS原理和应用总结

RTOS的作用 RTOS一般应用在中低端处理器当中&#xff0c;这里举一个笔者日常开发遇到的案例来说明RTOS的作用。 假设你有一个设备&#xff0c;这个设备的外围硬件很多&#xff0c;假设有LED、一个网口、若干RS232等等。 在没有RTOS的时候&#xff0c;我们用裸机编程来写&…

HTML5 多媒体应用技术

目录 多媒体元素 audio元素video元素多媒体事件与JavaScript交互音频和视频轨道(Track)媒体API MediaElement APIMediaSource Extensions (MSE)Encrypted Media Extensions (EME)Web Audio API

数据库同步软件,天不生PanguSync万古如长夜

在信息时代的海洋中&#xff0c;数据是那永不熄灭的灯塔&#xff0c;照亮了科技发展的航道。然而&#xff0c;随着数据的膨胀和应用场景的多样化&#xff0c;如何确保这些宝贵资源在不同平台、不同设备间实时更新、保持一致性&#xff0c;便成了一道亟待解决的难题。于是&#…

Android File Transfer for mac(强大的安卓文件传输工具) 直装版

Android File Transfer是一款专门为Mac用户设计的软件&#xff0c;它用于在Android设备与Mac之间传输文件。这款软件提供了简单直观的操作界面&#xff0c;使用户能够轻松地在Android设备和Mac之间传输和管理文件。 下载地址&#xff1a;https://www.macz.com/mac/7099.html?i…

使用python实现socket进行消息传输-demo

Socket 是什么 Socket 是一种在计算机网络中用于实现进程间通信的一种机制。它是网络编程中的重要概念&#xff0c;通过它可以在不同的计算机之间进行数据传输和通信。Socket 可以用于实现各种网络应用&#xff0c;包括客户端-服务器模型、P2P 应用等。基本上&#xff0c;Sock…

自动驾驶决策规划算法——二次规划

自动驾驶决策规划算法第二章第二节(中) 参考线算法_哔哩哔哩_bilibili 动态规划开辟的凸空间如下&#xff0c;两条橙色线之间&#xff1a; 黄色的点就意味着L的上下界&#xff0c;物理意义是当轨迹ss1时&#xff0c;L的范围应该是(Lmin1,Lmax1)之间&#xff0c;这个范围就是开辟…

学习日记.1

今天就是配置了droidbot的环境。主要的知识来源是GitHub - xieincz/droidbot: A lightweight test input generator for Android. Similar to Monkey, but with more intelligence and cool features! 看readme&#xff0c;注意只需要platform就好&#xff0c;sdk太大不用下载…

《Ai企业知识库》-模型实践-rasa开源学习框架-基础理论-02

rasa官网 Conversational AI Platform | Superior Customer Experiences Start Here rasa简介&#xff1a; Rasa是一个开源的机器学习框架&#xff0c;专门用于构建自动化的文本和语音对话系统&#xff0c;即聊天机器人。它允许开发者和企业创建定制化的对话体验&#xff0c…

ubuntu设置root开机登录,允许root用户ssh远程登录

ubuntu与centos系统不同&#xff0c;默认root开机不能登录。 1、输入一下命令创建root密码&#xff0c;根据提示输入新密码 sudo passwd root 2、打开gdm-autologin文件&#xff0c;将auth required pam_succeed_if.so user ! root quiet_success这行注释掉&#xff0c;这行就…

el-upload 上传多个视频

<el-form-item label"视频" prop"video_url"><el-uploadclass"upload-demo"ref"uploadRef":multiple"true":on-change"handleChange":before-remove"beforeRemove":before-upload"before…

Flutter 中的 EditableText 小部件:全面指南

Flutter 中的 EditableText 小部件&#xff1a;全面指南 在Flutter中&#xff0c;EditableText是一个低级别的文本编辑组件&#xff0c;它提供了构建自定义文本编辑界面的能力。与TextField和TextFormField不同&#xff0c;EditableText提供了更多的灵活性&#xff0c;允许开发…

【LinuxC语言】链接文件

文章目录 前言一、inode索引节点inode的作用为什么inode重要 二、文件链接的定义文件链接是什么硬链接&#xff08;Hard Link&#xff09;软链接&#xff08;符号链接&#xff0c;Symbolic Link&#xff09;硬链接图示&#xff1a;软链接图示&#xff1a; 硬链接应用场景限制和…

五步定位性能瓶颈

一、着手测试前的准备&#xff1a;优化数据流向与系统架构分析 在进行性能测试或系统优化之前&#xff0c;明确数据流向和系统架构的细节是至关重要的步骤。这不仅能够帮助识别潜在的瓶颈&#xff0c;还能确保测试用例设计的全面性与针对性。以下是关键步骤和方法&#xff1a;…

实现本地访问云主机,以及在云主机搭建FTP站点

前言 云计算是一种基于互联网的计算模式&#xff0c;通过网络提供按需访问的计算资源和服务。核心概念是把计算能力视作一种公共资源&#xff0c;用户可以根据自身需求动态分配和管理这些资源。 云主机 ECS (Elastic Compute Server)是一种按需获取的云端服务器&#xff0c;提…

142.栈和队列:用栈实现队列(力扣)

题目描述 代码解决 class MyQueue { public:stack<int> stIn; // 输入栈&#xff0c;用于push操作stack<int> stOut; // 输出栈&#xff0c;用于pop和peek操作MyQueue() {}void push(int x) {stIn.push(x); // 将元素压入输入栈}int pop() {// 如果输出栈为空&…