Modeling Algorithms Fillets and Chamfers

造型算法——倒圆与倒角

eryar@163.com

一、倒圆Fillet Constructor

1. BRepFilletAPI_MakeFillet

使用类BRepFilletAPI_MakeFillet来为形状添加倒圆。倒圆是用光滑面来代替角边。使用方法如下:

l 首先,给定一个需要倒圆的形状;

l 然后,通过Add方法来添加描述倒圆的参数,倒圆所需的参数包括一个边edge和半径radius。当然,边edge必须由两个面face所共有。倒圆会将原来的边替换成光滑的圆面过渡。

l 最后,通过询问结果来执行倒圆操作。

注:添加一个倒圆两次并不会出错,因为只保留了最后一次添的倒圆。

Figure 1. Filleting two edges using radius r1 and r2

下面给出一个将创建一个倒圆的长方体,其尺寸分别为abc,倒圆半径r

Figure 2. Filleting a box

代码如下所示,创建上图所示的倒圆的长方体的参数分别为:

a = 100b = 60c = 80r = 10

#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <TopoDS_Solid.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <TopExp_Explorer.hxx> TopoDS_Shape FilletedBox(const Standard_Real a,
const Standard_Real b,
const Standard_Real c,
const Standard_Real r)
{
TopoDS_Solid Box = BRepPrimAPI_MakeBox(a,b,c);
BRepFilletAPI_MakeFillet MF(Box); // add all the edges to fillet
TopExp_Explorer ex(Box,TopAbs_EDGE); while (ex.More())
{
MF.Add(r,TopoDS::Edge(ex.Current()));
ex.Next();
}
return MF.Shape();
}

如下图所示为创建一个半径变化的倒圆操作:

Figure 3. Evolutive radius fillet

Figure 4. Evolutive radius fillet a box

程序代码如下所示:

  1:     TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 200, 200);
  2:     BRepFilletAPI_MakeFillet Rake(theBox);
  3:     ChFi3d_FilletShape FSH = ChFi3d_Rational;
  4:     Rake.SetFilletShape(FSH);
  5:
  6:     TColgp_Array1OfPnt2d parAndRad(1, 6);
  7:     parAndRad.SetValue(1, gp_Pnt2d(0, 10));
  8:     parAndRad.SetValue(2, gp_Pnt2d(50, 20));
  9:     parAndRad.SetValue(3, gp_Pnt2d(70, 20));
 10:     parAndRad.SetValue(4, gp_Pnt2d(130, 60));
 11:     parAndRad.SetValue(5, gp_Pnt2d(160, 30));
 12:     parAndRad.SetValue(6, gp_Pnt2d(200, 20));
 13:
 14:     TopExp_Explorer ex(theBox, TopAbs_EDGE);
 15:     Rake.Add(parAndRad, TopoDS::Edge(ex.Current()));
 16:     TopoDS_Shape evolvedBox = Rake.Shape();
 17: 

2. BRepFilletAPI_MakeFillet2d

BRepFilletAPI_MakeFillet2d is used to construct fillets and chamfers on planar faces.

我按照示例代码运行了一下程序,结果程序总是崩溃,其操作的效果不得而知,所以也得不到真实的效果图。将其程序代码列出如下所示:

  1: #include “BRepPrimAPI_MakeBox.hxx”
  2: #include “TopoDS_Shape.hxx”
  3: #include “TopExp_Explorer.hxx”
  4: #include “BRepFilletAPI_MakeFillet2d.hxx”
  5: #include “TopoDS.hxx”
  6: #include “TopoDS_Solid.hxx”
  7:
  8: TopoDS_Shape FilletFace(const Standard_Real a,
  9:     const Standard_Real b,
 10:     const Standard_Real c,
 11:     const Standard_Real r)
 12: {
 13:     TopoDS_Solid Box = BRepPrimAPI_MakeBox (a,b,c);
 14:     TopExp_Explorer ex1(Box,TopAbs_FACE);
 15:
 16:     const TopoDS_Face& F = TopoDS::Face(ex1.Current());
 17:     BRepFilletAPI_MakeFillet2d MF(F);
 18:     TopExp_Explorer ex2(F, TopAbs_VERTEX);
 19:
 20:     while (ex2.More())
 21:     {
 22:         MF.AddFillet(TopoDS::Vertex(ex2.Current()),r);
 23:         ex2.Next();
 24:     }
 25:
 26:     // while...
 27:     return MF.Shape();
 28: }
 29: 

二、倒角Chamfer Constructor

1BRepFilletAPI_MakeChamfer

BREpFilletAPI_MakeChamfer的使用方法与BRepFilletAPI_MakeFillet大致类似,但稍有不同:

a) The surfaces created are ruled and not smooth;

b) The Add syntax for selecting edges requires one or two distances, one edge and one face(contiguous to the edge);

Add(dist, E, F);

Add(d1, d2, E, F); with d1 on the face F.

Figure 5. Creating a chamfer

Figure 6. The box with chamfers

程序代码如下所示:

  1: TopoDS_Shape theBox = BRepPrimAPI_MakeBox(130,200,170);
  2: BRepFilletAPI_MakeChamfer MC(theBox);
  3: TopTools_IndexedDataMapOfShapeListOfShape M;
  4: TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M);
  5:
  6: for (Standar1d_Integer i;i<M.Extent();i++)
  7: {
  8:     TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
  9:     TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
 10:     MC.Add(15,15,E,F);
 11: }
 12:
 13: TopoDS_Shape ChanfrenedBox = MC.Shape();
 14: 

OpenCascade Modeling Algorithms Fillets and Chamfers的更多相关文章

  1. OpenCascade Modeling Algorithms Boolean Operations

    Modeling Algorithms Boolean Operations of Opencascade eryar@163.com 布尔操作(Boolean Operations)是通过两个形状( ...

  2. OpenCASCADE Hidden Line Removal

    OpenCASCADE Hidden Line Removal eryar@163.com Abstract. To provide the precision required in industr ...

  3. OpenCascade Sweep Algorithm

    OpenCascade Sweep Algorithm eryar@163.com Abstract. Sweeps are the objects you obtain by sweeping a ...

  4. Overview of OpenCascade Library

    Overview of OpenCascade Library eryar@163.com 摘要Abstract:对OpenCascade库的功能及其实现做简要介绍. 关键字Key Words:Ope ...

  5. OpenCascade简介

    OpenCascade简介   Overview of OpenCascade Library eryar@163.com 摘要Abstract:对OpenCascade库的功能及其实现做简要介绍. ...

  6. A Simple OpenCASCADE Qt Demo-occQt

    A Simple OpenCASCADE Qt Demo-occQt eryar@163.com Abstract. OpenCASCADE have provided the Qt samples ...

  7. Building OpenCascade on Windows with Visual Studio

    Building OpenCascade on Windows with Visual Studio eryar@163.com 摘要Abstract:详细说明OpenCascade的编译配置过程,希 ...

  8. The Installation and Compilation of OpenCASCADE

    OpenCASCADE的编译 The Installation and Compilation of OpenCASCADE eryar@163.com 一. 安装OpenCASCADE 可以从Ope ...

  9. OpenCascade Primitives BRep - Box

    OpenCascade Primitives BRep - Box eryar@163.com Abstract. BRep is short for Boundary Representation. ...

随机推荐

  1. BZOJ4170 极光(CDQ分治 或 树套树)

    传送门 BZOJ上的题目没有题面-- [样例输入] 3 5 2 4 3 Query 2 2 Modify 1 3 Query 2 2 Modify 1 2 Query 1 1 [样例输出] 2 3 3 ...

  2. RTS与CTS的含义

    ====================================我是分割线首先介绍下网上看到的================================================= ...

  3. CodeSoft随笔 批量连续打印,变量打印,codesoft条码

    调用codeSoft的模板,实现批量连续打印. Code: 制作标签1.lab. 添加两个变量var0,var1. using LabelManager2; string strFile = Syst ...

  4. Drupal资源

    以下是一些Drupal的常用资源. www.drupal.org:Drupal官网,拥有最全 www.acquia.com:Drupal奠基人Dries主导的专业网站,有著名的Aquia平台,功能类似 ...

  5. 在VS2010下编译和使用tesseract_ocr识别验证码

    对于自动识别验证码,使用trsseract是个不错的选择,有兴趣的的朋友可以试试. 编译tesseract 官网提供了vs2008的编译说明和工程,但在vs2010下的编译时基本相同的,因此我使用的方 ...

  6. react-router+webpack+gulp路由实例

    背景:新项目要开始了,有一种想要在新项目中使用react的冲动,应该也是一个单页面的应用,单页应用就涉及到一个路由的问题.于是最近在网上找了蛮多关于react-router的文章,也遇到了许多的坑,经 ...

  7. JavaScript 基础第九天(DOM第三天)

    一.引言 我们昨天介绍了很多的概念以及大部分我们可以在工作中用到的事件,那么今天我们将运用这些知识做一些效果! 二.导入 今天的内容以实例为主. 三.重点内容 祝愿墙的简单构建: 首先我将介绍出本次实 ...

  8. Ubuntu16.04使用阿里云镜像安装Mongodb

    一.概述 近日要在新的Ubuntu16.04系统上安装MongoDB,某度结果后直接从Mongo官网直接获得3.2版本的下载链接,结果在下载时发觉速度慢的可怜.迫于无奈,只能找国内的镜像下载.切换国内 ...

  9. 关于Mysql查询带单引号及插入带单引号字符串问题

    1.转为带参数查询 String sql=""select id from student where name='?'; Connection connect = DriverM ...

  10. cmd输出的日志里有中文乱码的解决办法

    在命令行使用adb logcat命令直接输出日志中文内容显示乱码,原因是中文系统中cmd命令行窗口默认的编码是GBK,而LogCat打印的日志是UTF-8编码,所以adb logcat命令输出的中文内 ...