- UID
- 739618
- 积分
- 526
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2014-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 革天明 于 2020-10-24 17:22 编辑
//Cpp文件中定义静态变量
static double ComparePoint3d_Tol;
 - //定义比较函数
- static bool IsEqual(double a, double b, double tol = 1.0E-7)
- {
- return (fabs(a - b) < tol);
- }
- static bool lessPt(const AcGePoint3d& pt1,const AcGePoint3d& pt2)
- {
- if(IsEqual(pt1.x,pt2.x,ComparePoint3d_Tol))
- {
- if(IsEqual(pt1.y,pt2.y,ComparePoint3d_Tol))
- {
- return pt1.z < pt2.z;
- }
- return pt1.y < pt2.y;
- }
- return pt1.x < pt2.x;
- }
- static bool equalPt(const AcGePoint3d& pt1,const AcGePoint3d& pt2)
- {
- AcGeTol geTol;
- geTol.setEqualPoint(ComparePoint3d_Tol);
- return pt1.isEqualTo(pt2,geTol);
- }
//函数主体
 - //去除重复的点
- // ----- ads_delsamept symbol (do not rename)
- static int ads_delsamept(void)
- {
- //----- Remove the following line if you do not expect any argument for this ADS function
- struct resbuf *rb =acedGetArgs();
- ComparePoint3d_Tol = 0.001;
- std::vector<AcGePoint3d> pts;
- if (rb== NULL)
- {
- return acedRetNil();
- }
- else
- {
- if(rb->restype!=RTLB)
- {
- return acedRetNil();
- }
- else
- {
- rb = rb->rbnext;
- while(true)
- {
- if (rb->restype == RTPOINT)
- {
- pts.push_back(AcGePoint3d(rb->resval.rpoint[0],rb->resval.rpoint[1],0));
- rb = rb->rbnext;
- }
- else if (rb->restype == RT3DPOINT)
- {
- pts.push_back(AcGePoint3d(rb->resval.rpoint[0],rb->resval.rpoint[1],rb->resval.rpoint[2]));
- rb = rb->rbnext;
- }
- else if (rb->restype == 10)
- {
- pts.push_back(AcGePoint3d(rb->resval.rpoint[0],rb->resval.rpoint[1],rb->resval.rpoint[2]));
- rb = rb->rbnext;
- }
- else if(rb->restype==RTLE)
- {
- break;
- }
- else
- {
- return acedRetNil();
- }
- }
- if (rb->rbnext == NULL)
- {
- return acedRetNil();
- }
- rb = rb->rbnext;
- if (rb->restype == RTSHORT)
- {
- ComparePoint3d_Tol = rb->resval.rint;
- }
- else if (rb->restype == RTREAL)
- {
- ComparePoint3d_Tol = rb->resval.rreal;
- }
- else if (rb->restype == RTLONG)
- {
- ComparePoint3d_Tol = rb->resval.rlong;
- }
- if (rb->rbnext != NULL)
- {
- return acedRetNil();
- }
- }
-
- }
- std::sort(pts.begin(),pts.end(),lessPt);
- pts.erase(std::unique(pts.begin(),pts.end(),equalPt),pts.end());
- struct resbuf *bufList=NULL;
- for (int i = 0 ;i < pts.size(); i++)
- {
- if (bufList == NULL)
- bufList=acutBuildList(RT3DPOINT,pts.at(i),RTNONE);
- else
- bufList=acutBuildList(RTRESBUF,bufList,RT3DPOINT,pts.at(i),RTNONE);
- }
- return acedRetList(bufList);
- }
(delsamept (list (list 0 0) (list 10 10) (list 0 10)) 0.001)
(delsamept (list (list 0 0) (list 10 10) (list 0 10)) 0.11)
(delsamept (list (list 0 0) (list 0 0.002) (list 0 10)) 0.11)
(delsamept (list (list 0 0) (list 0 10) (list 0 0.002)) 0.11)
(delsamept (list (list 0 0) (list 0 10) T ) 0.11)
(delsamept (list (list 0 0 0 0) (list 0 10) (list 0 0.002)) 0.11)
(delsamept (list (list 0 0 0) (list 0 10 0) (list 0 0.002 0)) 0.11)
((0.0 0.0 0.0) (10.0 10.0 0.0) (0.0 10.0 0.0))
((0.0 0.0 0.0) (10.0 10.0 0.0) (0.0 10.0 0.0))
((0.0 0.002 0.0) (0.0 10.0 0.0))
((0.0 0.002 0.0) (0.0 10.0 0.0))
nil
nil
((0.0 0.002 0.0) (0.0 10.0 0.0))
((0.0 0.002 0.0) (0.0 10.0 0.0))
_$
|
评分
-
查看全部评分
|