回复
先创建一个类,譬如CPoint3d
-
- #pragma once
- #include "c:\objectarx 2012\inc\gepnt3d.h" //--->根据你的目录来定
- class CPoint3d : public AcGePoint3d
- {
- private:
- double fuzz;
- public:
- CPoint3d(void):fuzz(0.0){}
- ~CPoint3d(void){}
- void SetFuzz(double tol)
- {
- fuzz = tol;
- }
- void copy(c**t AcGePoint3d & pt)
- {
- this->x=pt.x;
- this->y=pt.y;
- this->z=pt.z;
- }
- bool isEqualTo(double x1,double x2) c**t
- {
- double delta = x1 - x2;
- return (delta = (-fuzz));
- }
- bool operator x,pt.x))
- if (isEqualTo(this->y,pt.y))
- return (this->z y x
- #include
- using namespace std;
- 以下为测试:
- 在你的函数中这样添加:[code]
- //过滤选择CAD的点(PointArray)对象
- resbuf filter;
- filter.restype=0;
- filter.resval.rstring=_T("POINT");
- filter.rbnext = NULL;
- ads_name sel;
- int ret=acedSSGet(NULL,NULL,NULL,&filter,sel);
- if( ret!=RTNORM)
- {
- acedSSFree(sel);
- return;
- }
- long len;
- ads_name ent;
- AcDbObjectId ObjId;
- AcDbPoint *pEnt;
- acedSSLength(sel,&len);
- AcGePoint3dArray ptset;
- for (long i = 0;iposition());
- pEnt->close();
- }
- acedSSFree(sel);
- len = ptset.length();
- //这样得到了AcGePoint3dArray,然后运用set,排除重复点:
- set pts;
- CPoint3d tempPt;
- tempPt.SetFuzz(1e-4);
- for (int i = 0; i ::iterator pItr;
- int i = 0;
- for (pItr = pts.begin();pItr!=pts.end();pItr++)
- {
- acutPrintf(_T("\nPoint [%d] is : %f,%f,%f"),i,(*pItr).x,(*pItr).y,(*pItr).z);
- Pt3d.x=(*pItr).x;
- Pt3d.y=(*pItr).y;
- Pt3d.z=(*pItr).z;
- ptset[ i ] = Pt3d;
- i++;
- }
|