当前位置: 首页 > article >正文

Open CASCADE学习|2个TCL命令转C++

1、torus aTorus 10 2

该命令的实现代码为:

static Standard_Integer anasurface (Draw_Interpretor& ,
            Standard_Integer  n, 
            const char** a)
{
  if (n < 2) return 1;
  gp_Ax3 loc;
​
  Standard_Integer i;
​
  if (n < 5) {
    loc = gp_Ax3(gp_Pnt(0,0,0),gp_Dir(0,0,1),gp_Dir(1,0,0));
    i = 2;
  }
  else if (n < 8) {
    loc = gp_Ax3(gp_Pnt(Draw::Atof(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4])),
     gp_Dir(0,0,1),gp_Dir(1,0,0));
    i = 5;
  }
  else if (n < 11) {
    loc = gp_Ax3(gp_Pnt(Draw::Atof(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4])),
     gp_Dir(Draw::Atof(a[5]),Draw::Atof(a[6]),Draw::Atof(a[7])));
    i = 8;
  }
  else if (n < 14) {
    loc = gp_Ax3(gp_Pnt(Draw::Atof(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4])),
     gp_Dir(Draw::Atof(a[5]),Draw::Atof(a[6]),Draw::Atof(a[7])),
     gp_Dir(Draw::Atof(a[8]),Draw::Atof(a[9]),Draw::Atof(a[10])));
    i = 11;
  }
  else
    return 1;
​
  Handle(Geom_Geometry) result;
​
  if (!strcasecmp(a[0],"plane")) {
    Handle(Geom_Plane) C = new Geom_Plane(loc);
    result = C;
  }
  else {
    if (i >= n) return 1;
    Standard_Real par1 = Draw::Atof(a[i]);
    
    if (!strcasecmp(a[0],"cylinder")) {
      Handle(Geom_CylindricalSurface) C = 
  new Geom_CylindricalSurface(loc,par1);
      result = C;
    }
    
    else if (!strcasecmp(a[0],"sphere")) {
      Handle(Geom_SphericalSurface) C = 
  new Geom_SphericalSurface(loc,par1);
      result = C;
    }
    
    else {
      if (i+1 >= n) return 1;
      Standard_Real par2 = Draw::Atof(a[i+1]);
      
      if (!strcasecmp(a[0],"cone")) {
  par1 *= (M_PI / 180.0);
  Handle(Geom_ConicalSurface) C =
    new Geom_ConicalSurface(loc,par1,par2);
  result = C;
      }
    
      else if (!strcasecmp(a[0],"torus")) {
  Handle(Geom_ToroidalSurface) C =
    new Geom_ToroidalSurface(loc,par1,par2);
  result = C;
      }
    }    
  }
​
  DrawTrSurf::Set(a[1],result);
  return 0;
}

转化为C++代码:

gp_Ax3 loc = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0));Handle(Geom_ToroidalSurface) aTorus =new Geom_ToroidalSurface(loc, 10, 2);

2、mkedgecurve aHelixEdge 0.01

该命令的实现代码为:

static Standard_Integer mkedgecurve (Draw_Interpretor& ,Standard_Integer n,const char** a)
{
​
  if (n < 3) return 1;
  Standard_Real Tolerance = Draw::Atof(a[2]) ;
​
  TopoDS_Shape S = DBRep::Get(a[1]);
  
  if (S.IsNull()) return 1;
  
   BRepLib::BuildCurves3d(S,
        Tolerance) ;
   return 0 ;
}

转化为C++代码:

BRepLib::BuildCurves3d(aHelixEdge,0.01);


http://www.kler.cn/news/234312.html

相关文章:

  • 【Linux】make和Makefile
  • Tomcat之虚拟主机
  • 基于微信小程序的校园二手交易平台
  • ChatGPT高效提问—prompt常见用法(续篇九)
  • Nginx实战:2-日志配置
  • wireshark抓包问题及学习
  • Uniapp(uni-app)学习与快速上手教程
  • vue3初识
  • Qt PCL学习(三):点云滤波
  • 2024.2.10 DMS(数据库管理系统)初体验
  • 【知识整理】技术新人的培养计划
  • 关于创建vue项目报错command failed: npm install --loglevel error
  • 蓝桥杯刷题--python-4
  • 4核8G服务器配置性能怎么样?12M带宽配置服务器能干什么?
  • Git详细讲解
  • jsp教材管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目
  • .gitlab-ci.yml文件参数配置和使用
  • 电脑空间爆满解决方法
  • c++之说_11|自定义类型 enum(枚举)与enumclass (c11新枚举)
  • Apache网站部署
  • 应用层 HTTP协议(1)
  • 《动手学深度学习(PyTorch版)》笔记8.3
  • 【笔记】Helm-5 Chart模板指南-11 子chart和全局值
  • 学习之旅9------JavaScript面向对象编程(OOP)全面解析
  • 【数据分享】1929-2023年全球站点的逐日降水量数据(Shp\Excel\免费获取)
  • 13.Swift元组
  • C语言第二十二弹---指针(六)
  • LineageOS 线刷包 小米红米 Note 4 (Mido)
  • 从事机器视觉,笔记本电脑该如何选型
  • 基于JSP的网上购书系统