找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1020|回复: 1

[每日一码] 求Line和Su**ce的交点

[复制链接]

已领礼包: 13个

财富等级: 恭喜发财

发表于 2016-8-26 19:08:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
下面是示例代码,求端点是(0 0 0) (0 0 1)的LINE和Su**ce的交点。

注意:include和lib文件在  ObjectARX SDK\\utils\brep 目录下。

  1. static AcGePoint3dArray Intersect(AcDbSu**ce* pSu**ce,AcGeLine3d line)
  2. {
  3.     AcGePoint3dArray returnPtArray;
  4.   AcDbBody* pBody = new AcDbBody();

  5.   // 2013
  6.   // Acad::ErrorStatus es = pBody->setASMBody(pSu**ce->ASMBodyCopy());
  7.   //before 20123
  8.    Acad::ErrorStatus es = pBody->setBody(pSu**ce->body());

  9.    //build AcBrBrep
  10.    AcBrBrep* pBrep = new AcBrBrep();
  11.    //
  12.   if(AcBr::eOk == pBrep->set(*pBody))
  13.   {
  14.     AcBrBrepFaceTraverser* pFaceTrav = new AcBrBrepFaceTraverser;
  15.     if(AcBr::eOk == pFaceTrav->setBrep(*pBrep))
  16.    {
  17.        for(pFaceTrav->restart();!pFaceTrav->done();pFaceTrav->next())
  18.        {
  19.         AcB**ce face;

  20.         if(AcBr::eOk == pFaceTrav->getFace(face))
  21.         {
  22.           double area = 0.0f;
  23.          face.getSu**ceArea(area);

  24.          acutPrintf(L"\nSu**ce Area: %f", area);

  25.         //*****whole su**ce of the Brep face******        
  26.         //AcGeNurbSu**ce nurbSu**ce;
  27.         //face.getSu**ceAsNurb(nurbSu**ce);
  28.         //AcGeCurveSurfInt curveSI;
  29.         ////input the curve and line
  30.         //curveSI.set(line,nurbSu**ce);
  31.         ////get the count of intersect points
  32.         //int count = curveSI.numIntPoints(err_1);
  33.         //    if(err_1 == AcGe::kXXOk && count >0 )
  34.         //    {      
  35.         //        AcGeIntersectError err_2;
  36.         //        for(int index = 0 ;index < count; index ++)
  37.         //        {
  38.         //           AcGePoint3d pt =
  39.         //             curveSI.intPoint(index,err_2);      
  40.         //            returnPtArray.append(pt);
  41.         //        }      
  42.         //      
  43.         //    }
  44.         //**********

  45.         //****real su**ce of the orignal AcDbSu**ce      
  46.           AcGeExternalBoundedSu**ce** nurbs = NULL;
  47.           Adesk::UInt32 numNurbs = 0;
  48.           face.getSu**ceAsTrimmedNurbs(numNurbs,nurbs);
  49.           //*****

  50.         for (Adesk::UInt32 i = 0; i < numNurbs; i++)
  51.         {
  52.             AcGeCurveSurfInt curveSI;
  53.             AcGeIntersectError  err_1 = AcGe::kXXOk;         
  54.              //input the curve and line
  55.             curveSI.set(line,*nurbs);

  56.             //get the count of intersect points
  57.             int count = curveSI.numIntPoints(err_1);
  58.             if(err_1 == AcGe::kXXOk && count >0 )
  59.             {
  60.                 AcGeIntersectError err_2;
  61.                 for(int index = 0 ;index < count; index ++)
  62.                 {
  63.                     AcGePoint3d pt =
  64.                         curveSI.intPoint(index,err_2);      
  65.                     returnPtArray.append(pt);
  66.                 }      
  67.             }
  68.             delete nurbs;
  69.         }
  70.         // your responsibility to delete the
  71.        // array of su**ces
  72.         delete[] nurbs;
  73.       }
  74.     }
  75.   }
  76.   delete pFaceTrav;
  77.   }
  78.   delete pBrep;


  79.   return returnPtArray;

  80. }

游客,如果您要查看本帖隐藏内容请回复


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2023-5-19 16:19:24 | 显示全部楼层
学习学习学习
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-29 10:37 , Processed in 0.279437 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表