BRepOffsetAPI_MakeOffset功能案例

2023-10-27 21:12

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

void ViewWindow::OnGen2dCurve()
{// Clear All_ctrlUi->listView->Clear();try{//构造一个线段GC_MakeSegment  Segment1(gp_Pnt(20, 0, 0), gp_Pnt(30, 0, 0));//根据线段构造一个边BRepBuilderAPI_MakeEdge anEdge(Segment1.Value());BRepBuilderAPI_MakeEdge anEdge2(gp_Pnt(30, 0, 0), gp_Pnt(30, 20, 0));BRepBuilderAPI_MakeEdge anEdge3(gp_Pnt(30, 20, 0), gp_Pnt(20, 0, 0));//aWire.Add(anEdge3.Edge());GC_MakeArcOfCircle arc4(gp_Pnt(30, 20, 0), gp_Pnt(34.651, 31.229, 0), gp_Pnt(45.88, 35.88, 0));BRepBuilderAPI_MakeEdge anEdge4(arc4.Value());构造一个圆double dr5 = 49.4178;double dAngelS5 = 98.82;double dAngelE5 = 94.4815;double dCenterX5 = 41.2769;double dCenterY5 = -12.4703;double dx5 = dr5 * cos(((dAngelE5 - dAngelS5) / 2 + dAngelS5) * M_PI / 180) + dCenterX5;double dy5 = dr5 * sin(((dAngelE5 - dAngelS5) / 2 + dAngelS5) * M_PI / 180) + dCenterY5;double dxs5 = dr5 * cos(dAngelS5 * M_PI / 180) + dCenterX5;double dys5 = dr5 * sin(dAngelS5 * M_PI / 180) + dCenterY5;double dxe5 = dr5 * cos(dAngelE5 * M_PI / 180) + dCenterX5;double dye5 = dr5 * sin(dAngelE5 * M_PI / 180) + dCenterY5;//GC_MakeArcOfCircle arc5(gp_Pnt(33.7, 36.363, 0), gp_Pnt(35.554, 36.615, 0),gp_Pnt(37.416, 36.796, 0));GC_MakeArcOfCircle arc5(gp_Pnt(dxs5, dys5, 0), gp_Pnt(dx5, dy5, 0), gp_Pnt(dxe5, dye5, 0));BRepBuilderAPI_MakeEdge anEdge5(arc5.Value());//      gp_Circ circle55(gp_Ax2(gp_Pnt(41.277, -12.470, 0), gp_Dir(0, 0, 1)), 49.418);//      //构造一个圆弧边//      GC_MakeArcOfCircle arc55(circle55, 94.481*M_PI/180, 98.82 * M_PI / 180,Standard_True);//   const Handle(Geom_TrimmedCurve) TrimmedCurve5 = arc55.Value();//      //求中间点位置//      Standard_Real first5 = TrimmedCurve5->FirstParameter();//      Standard_Real Last5 = TrimmedCurve5->LastParameter();//      Standard_Real mid5 = (Last5 - first5) / 2+ first5;//GC_MakeArcOfCircle arc5(TrimmedCurve5->Value(first5),//          TrimmedCurve5->Value(mid5),//          TrimmedCurve5->Value(Last5));//BRepBuilderAPI_MakeEdge anEdge5(arc5.Value());Standard_Real fBegin5 = 0, fEnd5 = 0;Handle(Geom_Curve) hCurveEdge5 = BRep_Tool::Curve(anEdge5, fBegin5, fEnd5);Handle(Geom_Circle) circle5 = Handle_Geom_Circle::DownCast(hCurveEdge5);// 在这里处理圆对象qDebug() << "Circle5";//读取圆弧起点和终点坐标qDebug() << "start5:[" << circle5->Value(fBegin5).X() << "," << circle5->Value(fBegin5).Y() << ","<< circle5->Value(fBegin5).Z() << "]";qDebug() << "end5:[" << circle5->Value(fEnd5).X() << "," << circle5->Value(fEnd5).Y() << ","<< circle5->Value(fEnd5).Z() << "]";qDebug() << "mid5:[" << circle5->Value((fEnd5- fBegin5)/2+ fBegin5).X() << "," << circle5->Value((fEnd5 - fBegin5) / 2 + fBegin5).Y() << ","<< circle5->Value((fEnd5 - fBegin5) / 2 + fBegin5).Z() << "]";qDebug() << "R5:" << circle5->Radius();const gp_Circ& circ5 = circle5->Circ();const gp_Pnt& center5 = circ5.Location();// 获取圆心坐标qDebug() << "Center5:[" << center5.X() << "," << center5.Y() << ","<< center5.Z() << "]";//gp_Circ circle66(gp_Ax2(gp_Pnt(41.329, -13.129, 0), gp_Dir(0, 0, 1)), 50.078);构造一个圆弧边//GC_MakeArcOfCircle arc66(circle66, 90.199 * M_PI / 180,94.481 * M_PI / 180, Standard_True);//const Handle(Geom_TrimmedCurve) TrimmedCurve6 = arc66.Value();求中间点位置//Standard_Real first6 = TrimmedCurve6->FirstParameter();//Standard_Real Last6 = TrimmedCurve6->LastParameter();//Standard_Real mid6 = (Last6 - first6) / 2 + first6;//GC_MakeArcOfCircle arc6(TrimmedCurve6->Value(first6),//	TrimmedCurve6->Value(mid6),//	TrimmedCurve6->Value(Last6));double dr6 = 50.0781;double dAngelS6 = 94.4815 ;double dAngelE6 = 90.1993;double dCenterX6 = 41.3285;double dCenterY6 = -13.1286;double dx6 = dr6 * cos(((dAngelE6 - dAngelS6) / 2 + dAngelS6) * M_PI / 180) + dCenterX6;double dy6 = dr6 * sin(((dAngelE6 - dAngelS6) / 2 + dAngelS6) * M_PI / 180) + dCenterY6;double dxs6 = dr6 * cos(dAngelS6 * M_PI / 180) + dCenterX6;double dys6 = dr6 * sin(dAngelS6 * M_PI / 180) + dCenterY6;double dxe6 = dr6 * cos(dAngelE6 * M_PI / 180) + dCenterX6;double dye6 = dr6 * sin(dAngelE6 * M_PI / 180) + dCenterY6;//GC_MakeArcOfCircle arc6(gp_Pnt(37.416, 36.796, 0), gp_Pnt(39.283, 36.908, 0), gp_Pnt(41.154, 36.949, 0));GC_MakeArcOfCircle arc6(gp_Pnt(dxe5, dye5, 0), gp_Pnt(dx6, dy6, 0), gp_Pnt(dxe6, dye6, 0));BRepBuilderAPI_MakeEdge anEdge6(arc6.Value());Standard_Real fBegin6 = 0, fEnd6 = 0;Handle(Geom_Curve) hCurveEdge6 = BRep_Tool::Curve(anEdge6, fBegin6, fEnd6);Handle(Geom_Circle) circle6 = Handle_Geom_Circle::DownCast(hCurveEdge6);// 在这里处理圆对象qDebug() << "Circle6";//读取圆弧起点和终点坐标qDebug() << "start6:[" << circle6->Value(fBegin6).X() << "," << circle6->Value(fBegin6).Y() << ","<< circle6->Value(fBegin6).Z() << "]";qDebug() << "end6:[" << circle6->Value(fEnd6).X() << "," << circle6->Value(fEnd6).Y() << ","<< circle6->Value(fEnd6).Z() << "]";qDebug() << "R6:" << circle6->Radius();const gp_Circ& circ6 = circle6->Circ();const gp_Pnt& center6 = circ6.Location();// 获取圆心坐标qDebug() << "Center6:[" << center6.X() << "," << center6.Y() << ","<< center6.Z() << "]";Handle(Geom2d_Circle) circle = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(center6.X(), center6.Y()) , gp_Dir2d(1, 0)), dr6);Handle(Geom2d_TrimmedCurve) trimmedCurve61 = new Geom2d_TrimmedCurve(circle, dAngelS6*M_PI/180, dAngelE6 * M_PI / 180);Geom2d_OffsetCurve OffsetCurve61(trimmedCurve61, -0.2);// 获取起始点和结束点gp_Pnt2d startPoint66 = OffsetCurve61.Value(OffsetCurve61.FirstParameter());gp_Pnt2d endPoint66 = OffsetCurve61.Value(OffsetCurve61.LastParameter());qDebug() << "startPoint66:(" << startPoint66.X() << "," << startPoint66.Y() << ")";qDebug() << "endPoint66:(" << endPoint66.X() << "," << endPoint66.Y() << ")";GC_MakeSegment  Segment7(gp_Pnt(dxe6, dye6, 0), gp_Pnt(41.901, 37.697, 0));BRepBuilderAPI_MakeEdge anEdge7(Segment7.Value());gp_Pnt2d piont71(dxe6, dye6);gp_Pnt2d piont72(41.901, 37.697);GCE2d_MakeSegment seg71(piont71, piont72);Geom2d_OffsetCurve OffsetCurve71(seg71.Value(), 0.2);// 获取起始点和结束点gp_Pnt2d startPoint77 = OffsetCurve71.Value(OffsetCurve71.FirstParameter());gp_Pnt2d endPoint77 = OffsetCurve71.Value(OffsetCurve71.LastParameter());qDebug() << "startPoint77:(" << startPoint77.X() << "," << startPoint77.Y() << ")";qDebug() << "endPoint77:(" << endPoint77.X() << "," << endPoint77.Y() << ")";//GC_MakeSegment  Segment8(gp_Pnt(41.901, 37.697, 0), gp_Pnt(41.901, 40.162, 0));GC_MakeSegment  Segment8(Segment7.Value()->EndPoint(), gp_Pnt(Segment7.Value()->EndPoint().X(), Segment7.Value()->EndPoint().Y()+10, 0));BRepBuilderAPI_MakeEdge anEdge8(Segment8.Value());GC_MakeSegment  Segment9(Segment8.Value()->EndPoint(), gp_Pnt(dxs5, Segment8.Value()->EndPoint().Y(), 0));BRepBuilderAPI_MakeEdge anEdge9(Segment9.Value());GC_MakeSegment  Segment10(gp_Pnt(dxs5, Segment8.Value()->EndPoint().Y(), 0), gp_Pnt(dxs5, dys5, 0));BRepBuilderAPI_MakeEdge anEdge10(Segment10.Value());// TopTools_ListOfShape listEdge;listEdge.Append(anEdge5.Edge());listEdge.Append(anEdge6.Edge());listEdge.Append(anEdge7.Edge());listEdge.Append(anEdge8.Edge());listEdge.Append(anEdge9.Edge());listEdge.Append(anEdge10.Edge());//根据一个边构造一个线框BRepBuilderAPI_MakeWire aWire;//aWire.Add(anEdge.Edge());//aWire.Add(anEdge2.Edge());//添加到线框中//aWire.Add(anEdge4.Edge());aWire.Add(listEdge);// aWire.Build();if (!aWire.IsDone()){if (aWire.Error()== BRepBuilderAPI_WireError::BRepBuilderAPI_EmptyWire){qDebug() << "Wire failed-EmptyWire!\n";}else if (aWire.Error() == BRepBuilderAPI_WireError::BRepBuilderAPI_DisconnectedWire){qDebug() << "Wire failed-DisconnectedWire!\n";} else if (aWire.Error() == BRepBuilderAPI_WireError::BRepBuilderAPI_NonManifoldWire){qDebug() << "Wire failed-NonManifoldWire!\n";}else{qDebug() << "Wire failed!\n";}//return;}// 创建 ShapeFix_Wireframe 对象并传入线框//      Handle(ShapeFix_Wireframe) aFixWire = new ShapeFix_Wireframe(aWire.Shape());aFixWire->SetPrecision(thePrec);//aFixWire->SetMaxTolerance(0.01);//      aFixWire->FixWireGaps();Handle(AIS_Shape) wire_shape = new AIS_Shape(aWire.Shape());_ctrlUi->listView->RecordModel(wire_shape, QString("wire shape"));wire_shape->SetColor(Quantity_NOC_YELLOW);//offset shape//线框做偏置距离BRepOffsetAPI_MakeOffset mk_offset;mk_offset.AddWire(aWire.Wire());//mk_offset.SetApprox(true);mk_offset.Init(GeomAbs_Arc, Standard_False);Standard_Real offset = _ctrlUi->doubleSpinBox_offsetDist->value();mk_offset.Perform(offset);if (!mk_offset.IsDone()){qDebug() << "Offset failed!\n";}else{const TopoDS_Shape& offsetShape = mk_offset.Shape();if (offsetShape.IsNull()){qDebug() << "offsetShape is null!\n";return;}Handle(AIS_Shape) offset_shape = new AIS_Shape(offsetShape);_ctrlUi->listView->RecordModel(offset_shape, QString("offset shape"));offset_shape->SetColor(Quantity_NOC_RED);//将拓扑数据转为几何数据TopTools_IndexedMapOfShape aEdgeMap;TopExp::MapShapes(offsetShape, TopAbs_EDGE, aEdgeMap);qDebug() << "edge count is " << aEdgeMap.Extent();//遍历结果for (int i = 1; i <= aEdgeMap.Extent(); ++i){const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeMap(i));const TopoDS_Vertex& aFirstVertex = TopExp::FirstVertex(aEdge);const TopoDS_Vertex& aLastVertex = TopExp::LastVertex(aEdge);Standard_Real fBegin = 0, fEnd = 0;Handle(Geom_Curve) hCurve = BRep_Tool::Curve(aEdge, fBegin, fEnd);if (!hCurve.IsNull()){if (hCurve->IsKind(STANDARD_TYPE(Geom_Line))) {// 是直线Handle(Geom_Line) line = Handle_Geom_Line::DownCast(hCurve);// 在这里处理直线对象qDebug() << "Line";//读取直线起点和终点坐标qDebug() << "start:[" << line->Value(fBegin).X() << "," << line->Value(fBegin).Y() << ","<< line->Value(fBegin).Z() << "]";qDebug() << "end:[" << line->Value(fEnd).X() << "," << line->Value(fEnd).Y() << ","<< line->Value(fEnd).Z() << "]";}else if (hCurve->IsKind(STANDARD_TYPE(Geom_Circle))) {// 是圆Handle(Geom_Circle) circle = Handle_Geom_Circle::DownCast(hCurve);// 在这里处理圆对象qDebug() << "Circle";//读取圆弧起点和终点坐标qDebug() << "start:[" << circle->Value(fBegin).X() << "," << circle->Value(fBegin).Y() << ","<< circle->Value(fBegin).Z() << "]";qDebug() << "end:[" << circle->Value(fEnd).X() << "," << circle->Value(fEnd).Y() << ","<< circle->Value(fEnd).Z() << "]";qDebug() << "R:" << circle->Radius();const gp_Circ& circ = circle->Circ();const gp_Pnt& center = circ.Location();// 获取圆心坐标qDebug() << "Center:[" << center.X() << "," << center.Y() << ","<< center.Z() << "]";}else if (hCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {// 是贝塞尔曲线Handle(Geom_BezierCurve) bezierCurve = Handle_Geom_BezierCurve::DownCast(hCurve);// 在这里处理贝塞尔曲线对象qDebug() << "BezierCurve";}else if (hCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {// 是B样条曲线Handle(Geom_BSplineCurve) bsplineCurve = Handle_Geom_BSplineCurve::DownCast(hCurve);// 在这里处理B样条曲线对象qDebug() << "SplineCurve";}else {// 其他类型的曲线// 在这里处理其他类型的曲线对象qDebug() << "OtherCurve";}}}}_view->fitAll();//_context->Activate(ViewHelper::SM_FACE);//_context->Activate(ViewHelper::SM_WIRE);}catch (Standard_Failure const& theFailure){qDebug() << "info: " << theFailure.GetMessageString() << "\n";}
}

这篇关于BRepOffsetAPI_MakeOffset功能案例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

MySQL中实现多表查询的操作方法(配sql+实操图+案例巩固 通俗易懂版)

《MySQL中实现多表查询的操作方法(配sql+实操图+案例巩固通俗易懂版)》本文主要讲解了MySQL中的多表查询,包括子查询、笛卡尔积、自连接、多表查询的实现方法以及多列子查询等,通过实际例子和操... 目录复合查询1. 回顾查询基本操作group by 分组having1. 显示部门号为10的部门名,员

Java使用Mail构建邮件功能的完整指南

《Java使用Mail构建邮件功能的完整指南》JavaMailAPI是一个功能强大的工具,它可以帮助开发者轻松实现邮件的发送与接收功能,本文将介绍如何使用JavaMail发送和接收邮件,希望对大家有所... 目录1、简述2、主要特点3、发送样例3.1 发送纯文本邮件3.2 发送 html 邮件3.3 发送带

Java实现数据库图片上传功能详解

《Java实现数据库图片上传功能详解》这篇文章主要为大家详细介绍了如何使用Java实现数据库图片上传功能,包含从数据库拿图片传递前端渲染,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1、前言2、数据库搭建&nbsChina编程p; 3、后端实现将图片存储进数据库4、后端实现从数据库取出图片给前端5、前端拿到

Python使用DeepSeek进行联网搜索功能详解

《Python使用DeepSeek进行联网搜索功能详解》Python作为一种非常流行的编程语言,结合DeepSeek这一高性能的深度学习工具包,可以方便地处理各种深度学习任务,本文将介绍一下如何使用P... 目录一、环境准备与依赖安装二、DeepSeek简介三、联网搜索与数据集准备四、实践示例:图像分类1.

如何关闭 Mac 触发角功能或设置修饰键? mac电脑防止误触设置技巧

《如何关闭Mac触发角功能或设置修饰键?mac电脑防止误触设置技巧》从Windows换到iOS大半年来,触发角是我觉得值得吹爆的MacBook效率神器,成为一大说服理由,下面我们就来看看mac电... MAC 的「触发角」功能虽然提高了效率,但过于灵敏也让不少用户感到头疼。特别是在关键时刻,一不小心就可能触

MobaXterm远程登录工具功能与应用小结

《MobaXterm远程登录工具功能与应用小结》MobaXterm是一款功能强大的远程终端软件,主要支持SSH登录,拥有多种远程协议,实现跨平台访问,它包括多会话管理、本地命令行执行、图形化界面集成和... 目录1. 远程终端软件概述1.1 远程终端软件的定义与用途1.2 远程终端软件的关键特性2. 支持的

Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)

《Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)》本文介绍了如何使用Python和Selenium结合ddddocr库实现图片验证码的识别和点击功能,感兴趣的朋友一起看... 目录1.获取图片2.目标识别3.背景坐标识别3.1 ddddocr3.2 打码平台4.坐标点击5.图

Java中实现订单超时自动取消功能(最新推荐)

《Java中实现订单超时自动取消功能(最新推荐)》本文介绍了Java中实现订单超时自动取消功能的几种方法,包括定时任务、JDK延迟队列、Redis过期监听、Redisson分布式延迟队列、Rocket... 目录1、定时任务2、JDK延迟队列 DelayQueue(1)定义实现Delayed接口的实体类 (

使用Navicat工具比对两个数据库所有表结构的差异案例详解

《使用Navicat工具比对两个数据库所有表结构的差异案例详解》:本文主要介绍如何使用Navicat工具对比两个数据库test_old和test_new,并生成相应的DDLSQL语句,以便将te... 目录概要案例一、如图两个数据库test_old和test_new进行比较:二、开始比较总结概要公司存在多

SpringBoot整合DeepSeek实现AI对话功能

《SpringBoot整合DeepSeek实现AI对话功能》本文介绍了如何在SpringBoot项目中整合DeepSeekAPI和本地私有化部署DeepSeekR1模型,通过SpringAI框架简化了... 目录Spring AI版本依赖整合DeepSeek API key整合本地化部署的DeepSeek