风树 发表于 2014-1-8 16:04:00

代码生来就是为人们服务的,它喜欢干的事就由它去干(部分整理)

2014.1.18
      年前整理到此,中途耽搁了些时间,提前先祝大家新年好。
      一种编程语言无难易之分,如果只需实现一些常用的功能,每个人都是能做到的。
      对于我们无专业要求的一般爱好者来说,开始入门时,最大的难点可能是需要很费劲地查找网上零散的资料,因为我们刚开始时是比较难单从“ObjectARX中文版.chh"这本资料里找到自己的答案。
      或许我们需要的是一个较为集中的例子。
      以下代码是我在乐筑天下一年多来,所有学习的小结,属基础类。代码以完整工程的形式提供给大家,希望能节约有心想学习的同学的学习时间;同时也献给乐筑天下,还是再次说一下,自己是莫名地喜欢“乐筑天下”这两个字的,不是奉承的话,只是因为它的含义,希望我们大家能了解它的含义。
      其实我并不需要写那些代码,只是出于爱好,想了解得更多一些,不知不觉地就成了现在这个样子。实话,确实付出了不少的时间,这份文档也应该到此为止了。
      对于它,其实就像自己的小孩一样,从无到有,长大了,它喜欢干的事就由它去干吧,它生来就是要为人们服务的,无需将人类太多的思想加在它的身上。
      为了让它,能更好的走出第一步,减少争议。
      首先我需要告诉它自己关于arx部分的身世,然后再简单的告诉它自己各部分是长成什么样子的:
      
    (以下将以“你”来表称代码)
      1、首先,你的出生其实只是单纯地为了好玩(),想实现mapgis造区中的一个类似功能,前生来自于网上的一个c类,但最后还是决定将你回炉一次,因为你需要你的个性,但还是带有它的影子。
      2、你的AcGeCurveToAcDbCurve ,AcDbCurveToAcGeCurve 来自于上的的帖子,区别主要在于Acad::ErrorStatus AcGeCurveToAcDbCurve(AcDbCurve * &pDb,const AcGeCircArc3d * pGe)部分。
      3、三角网(Jonathan Richard Shewchuk):核心来自于Jonathan Richard Shewchuk美国加州大学伯克利分校,约1万6千行彪悍的c代码(TriangleDll文件),首先见于
,改编者为 。在核心代码上新增Tin接口文件。在此感谢所构建的框架。
      对于核心部分,为了让你在某一个接口处长的象c++,便更改了核心代码中的一个位置,否则你会有概率地出现错误(注:改编者的代码不会出现这个问题);对于Tin接口文件部分,基本上是根据自己的想法重构,并增加其余文档。
      4、克里格插值gstl :直接来自于gstl,对地质统计分析了解的同学,因该了解gstl在该专业上的分量,在此不多说了,所以说你在这方面体制很好。(请注意xtcow_gstl.h的使用,想了解gstl 的,需直接下载其源码,看看它的使用说明)。
      5、几何类继承于MathGeoLib,来自于下载链接:
改变在于:1)将原float 精度调整为double精度,含因精度调整后对计算会造成影响的位置(也许有遗漏的地方)。
                  2)原代码中,多边形类顺逆时针方向的判定方法只针对凸多边形,调整为对凹凸多边形均适用的算法(,没有使用基于计算多边形面积的行列式算法)
                  3)其余文件均为自作接口文件,但未做精简整理。
      6、平面排布矩形(非最优化):同样来自,工程中没有使用,有兴趣的可以了解一下。
      7、在坐标标注、cad捕获显示、cad简单标签栏及空间栅格的文件夹中的内容,其框架来自于arx帮助文档,按需改动。
--------------------------------------------------------------------------------------------------------------------------------------------------------
通用文件夹下的内容:
   1)cad_entity_boundary.h (c++模版形式)
   内含实现一个cad_entity_boundary类,两个接口 :      
   //提取能代表AcDbEntity_对象范围的曲线(clone()的形式),将其加入到fanhui容器中
   static void pick_up_AcDbEntity_Boundary(AcDbEntity*AcDbEntity_,std::vector& fanhui);
    //point_set已经排序
    static bool _4_points_of_min_area_rectangle(std::vector & point_set,std::vector & MinimumAreaRectangle);
    其中调用了的:MinimumAreaRectangle函数。
   2)其余函数在类外定义,从通用函数中提取过来,为了能放在一起,以模版形式实现,在其它地方有引用。
      1: template//未使用      
      bool get_points_from_AcDbCurve(std::vector &store,AcDbCurve *pt,double dis,bool add_to_store);
      2:template//如果曲线长度以知则输入该长度AcDbCurve_length,否则不管      bool get_points_from_AcDbCurve(AcGePoint3dArray &ampoint3dArray,T *pt,double dis,bool add_to_store=0,double AcDbCurve_length=0);
      说明:和上面函数的主要区别只在于一个以vector容器一个以AcGePoint3dArray容器返回点集
      3:template//用template只是为了让该函数能放到这里
      double get_points_from_AcDbCurve_special(AcGePoint3dArray &store,T *pt,double shang_ci_sheng_duo_shao,double dis)
      说明:假设输入1、2、3条相联的曲线(圆弧、多段线、椭圆弧段、样条曲线等),但她们并不严格的首尾相连(点相连、方向相反),需要根据一个方向生成一组点集,相邻的两个点在原曲线路径上的路径长度一样
      该函数只是针对当时特定目标而写,专门给AcDbPolyline * Cad_Topo::connected_line(AcDbCurve* one ,std::vector &input_object_pt,double dis)循环调用,历史遗留问题,就不动它了
       4:得到文本边界,offset为边界便宜文本的距离      //4----3
      //1----2
      //其它地方有引用,接口形式就不改
      template
      bool text_boundary_point(AcDbEntity *import_Text_,T &point_1,T &point_2,T &point_3,T &point_4,double offset=0);
      5:template
      bool text_boundary_point(AcDbEntity *import_Text,std::vector&point_set,double offset=0,bool add_to_point_set=0);
         说明:直接用函数5
       6、template//用template只是为了让该函数能放到这里T只能为AcDbExtents      Acad::ErrorStatus AABB_AcDbBlockReference(T& exts,AcDbBlockReference* pRef);
      说明:就是一个递归式,只为解一下cad AcDbBlockTableRecordPointer、AcDbBlockTableRecordIterator、AcDbObjectPointer的使用模式,首见于,原文地址,
-------------------------------------------------------------------------------------------------------------------------------------------------------
function_for_cad_1.h 文件夹下:(注意和空间上原来的内容并不完全一样,原来部分内容存在内存泄露)
      void cad_zoom();
      void cad_zoom_win();
      void cad_zoom(AcGePoint2d CenterPt,double Height,double Width);
      void SendCmdToAcad(std::wstring &Cmd);
      void change_cad_title(std::wstring title);
      std::wstring get_active_database_tile_name(void);
      std::wstring get_database_tile_name(AcDbDatabase* input_database);
      AcApDocument*get_database_AcApDocument(AcDbDatabase* input_database);
      std::wstring get_cad_file_path_and_name(void);
      //std::wstring printf_sys_time(std::wstring text,std::wstring text_=_T(""));
      bool is_showed(AcDbEntity *pEnt);//
      //添加cad的支持路径
      //bool AddSupportPath(std::vector &arPath);
      //遍历指定AcDbBlockReference对象,获得该对象所有可见元素的拷贝
      //不清空store原有内容,累加//递归调用,使用时m_输入为空
      template
      bool recursive_procedure_for_copy(AcDbBlockReference *Ent,std::vector& store,AcGeMatrix3d m_) ;
      //如果存在该层,可以对AcDbDatabase* pDb输入NULL
      bool has_the_same_lay(std::wstring inputLyName,AcDbDatabase* pDb);
      bool creat_new_layer(std::wstring inputLyName,AcDbDatabase* pDb);
      //在cad图上以可读或可写的方式获得指定AcDbDatabase资源的AcDbBlockTableRecord
      AcDbObjectId get_AcDbBlockTableRecord(AcDbBlockTableRecord *&pSpaceRecord ,std::wstring block_name=ACDB_MODEL_SPACE,AcDb::OpenMode mode=AcDb::kForWrite, AcDbDatabase* pDb= acdbHostApplicationServices()->workingDatabase());
      //加入模型空间
      template
      AcDbObjectId AddToModelSpace(T *pEnt);
      template
      AcDbObjectIdArrayAddToModelSpace(containor &pEnt);
      template
      void AddToModelSpace(std::vector&Id ,containor &pEnt);
      //和块相关
      bool has_the_same_block(std::wstring BlockName, AcDbDatabase *i_pDb= acdbHostApplicationServices()->workingDatabase());
      std::wstring get_a_different_block_name_if_input_name_had_exited(std::wstring BlockName,AcDbDatabase *i_pDb= acdbHostApplicationServices()->workingDatabase());
      //功能:通过id打开资源
      template
      Acad::ErrorStatuschange_AcDbObjectId_to_AcDbEntity(std::vector &fanhui_object_pt_vector,const AcDbObjectIdArray &object_id,bool add=0,bool write=1);
      template
      Acad::ErrorStatuschange_AcDbObjectId_to_AcDbEntity(std::set &fanhui_object_pt_vector,const AcDbObjectIdArray &object_id,bool add=0,bool write=1);
      template
      Acad::ErrorStatuschange_AcDbObjectId_to_AcDbEntity(T*&fanhui_object, AcDbObjectId &object_id,bool write=1);
      //功能:通过资源,获取id,但只限定已经加入模型空间的资源,原来资源将会释放,返回过程中不能转换的个数
      template
      int change_AcDbEntity_to_AcDbObjectId(AcDbObjectIdArray &object_id, std::vector &fanhui_object_pt_vector);
      template
      int change_AcDbEntity_to_AcDbObjectId(AcDbObjectIdArray &object_id, std::set &fanhui_object_pt_vector);
      //将cad资源设置为可读形式
      template
      inline Acad::ErrorStatusmake_entity_ForRead(T *import_enty);
      template
      Acad::ErrorStatusmake_entity_ForRead(std::set & import_enty);
      template
      Acad::ErrorStatusmake_entity_ForRead(std::vector & import_enty);
      Acad::ErrorStatusmake_entity_ForRead(AcDbVoidPtrArray& curveSegments);
      template
      Acad::ErrorStatusmake_entity_ForWrite(std::vector & import_enty);
      //将cad资源设置为可写形式
      template
      inline Acad::ErrorStatusmake_entity_ForWrite(T *import_enty);
      template
      Acad::ErrorStatusmake_entity_ForWrite(std::set & import_enty);
      Acad::ErrorStatusmake_entity_ForWrite(AcDbVoidPtrArray& curveSegments);
      //在cad图上获得一个指定的属于T类型的资源(cad命令行中有提示)
      //更改cad中某一类的颜色
      template
      void change_entity_colour(std::vector&input,Adesk::UInt16 color);
      template
      void change_entity_colour(std::set&input,Adesk::UInt16 color);
      //克隆
      template
      Acad::ErrorStatusclone_cad_entity( std::vector & export_enty,const std::vector & import_enty);
      template
      Acad::ErrorStatusclone_cad_entity( std::set & export_enty,const std::vector & import_enty);
      template
      Acad::ErrorStatusclone_cad_entity( std::set & export_enty,const std::set & import_enty);
      template
      Acad::ErrorStatusclone_cad_entity( std::vector & export_enty,const std::vector & import);
      Acad::ErrorStatusclone_cad_entity( AcDbEntity *&export_enty,const AcDbObjectId import);
      //功能:根据idcopy指定类型的对象组,以可写的形式获得资源
      template
      Acad::ErrorStatusclone_cad_entity( std::vector & export_enty,const AcDbObjectIdArray & import);
      //删除
      template
      void erase_cad_entity(std::vector &shuru);
      template
      void erase_cad_entity(std::set &shuru);
      //释放资源
      template
      void close_entity(std::vector &shuru);
      template
      void close_entity(std::set &shuru);
      void close_entity(AcGeVoidPointerArray &shuru);
------------------------------------------------------------------------------------------------------------------------------------------------------------
function_for_cad_2.h文件夹下: (被文字查找对话框调用,只供练习使用)
      void trans(int x); //十进制整数转2进制数组
       inline size_t get_string_length(const wchar_t* pwszStr);
      std::wstring strToLower(const std::wstring &str);// wstring转小写
      bool replace_match_case( std::wstring &m_src,std::wstring &m_find,std::wstring &m_replace);
      bool replace_not_match_case( std::wstring &m_src,std::wstring &m_find,std::wstring &m_replace);
      bool insert_match_case( std::wstring &m_src,std::wstring &m_find,std::wstring &m_insert_nei_rong);
      bool insert_not_match_case( std::wstring &m_src,std::wstring &m_find,std::wstring &m_insert_nei_rong);
      bool find_match_case( const std::wstring &m_src,std::wstring &m_find);
      bool find_not_match_case( const std::wstring &m_src,std::wstring &m_find);
----------------------------------------------------------------------------------------------------------------------------------------------------------
function_for_cad_3.h文件夹下:
      //未使用
      void rebuild_curveSegments_for_AcGeCompositeCurve3d(AcGeVoidPointerArray& curveSegments);
      //曾经使用,后未使用
      void remove_max_area_or_bad_region(std::vector &fanhui,AcDbVoidPtrArray & import_enty);
      //曾经使用,后未使用
      void get_max_area_region(AcDbRegion* &fanhui,AcDbVoidPtrArray & regions);
      //由find_intessect_point调用,找AcDbCurve的自相交点
      Acad::ErrorStatusfind_self_intessect_point(std::vector &return_point,AcDbCurve *line1);
      //找出悬挂线的端点//可以不用这样实现,历史问题,不做修改
      Acad::ErrorStatus find_fly_point(std::vector &fly_point,
                                                                              const std::vector &object_pt_vector);
      //找出悬挂线的端点//可以不用这样实现,历史问题,不做修改
      Acad::ErrorStatus find_fly_point(std::vector &fly_point,
                                                                              const std::vector >&object_pt_vector);
      //让各线端点在一定程度上咬合//位于各点重心处//topo造区时使用,但设定不当,会造成错误
      void snap(std::set&enty,double eps_for_topo_=eps_for_topo);
      void snap(std::vector&enty,double eps_for_topo_=eps_for_topo);
      //在曲线param_1和param_2间找一个param,满足param对应的点离equal_point点距离最小
      //topo打断时调用,非必须
      double find_params_between_two_params_for_cad(AcDbCurve* Curve,double 洀开1,double 洀开2,AcGePoint3d &equal_point,int &iterations);
      //主要是topo造区时使用
      int delete_short_line__(std::vector &import_enty,double length_delete_line=eps);//删除短线
      int delete_short_line__(std::set &import_enty,double length_delete_line=eps);
      int delete_short_line__(std::list &import_enty,double length_delete_line=eps);//删除短线
      //会产生一个未加入模型空间的面域实体
      bool build_Region_from_text(AcDbRegion* 椀漀渀猀,AcDbEntity* Text);
      bool regions_intersect(AcDbRegion* regions,AcDbRegion* region_two);
      
      //1表示region包含region_two
      //2表示region_two包含region
      //为cad而设
      int regions_contain_relation(AcDbRegion* region,AcDbRegion* region_two);//相交
      //主要cad_entity_boundary调用
      AcDb2dPolyline * text_AcDb2dPolyline_boundary(AcDbEntity* Text);
      //判断指定点是否在指定线上
      bool points_on_curve(const AcDbCurve *compare_curve,const AcGePoint3dArray &Array,const AcGeTol &Tol);
      bool points_on_curve(const AcGeCurve3d *compare_curve,const AcGePoint3dArray &Array,const AcGeTol &Tol);
      
      //get_entity_copy_in_cur_workdatabase_by_rectang调用
      bool curve_is_outsize_the_rectang(AcDbExtents &extent,AcDbCurve *Curve_entity,int point_number);
      
      double curve_length(const AcDbCurve *Curve);
      //某种情况下curve_length(AcGeCurve3d * pGe)不能获得正确长度
      double curve_length(AcGeCurve3d * pGe);
      bool getSplineSamplePoints(AcGePoint3dArray &pnts,AcDbSpline *&spline, double lenght=0.1);
      //初见于地址
      void RemovePointBetweenLine(AcGePoint3dArray &pnts,double dMinAngle=M_PI-M_PI/180.0);
      //原型参考://www.cadgj.com/?p=163
      void SameHatchColor(AcDbHatch* pTargetHatch,AcDbHatch* pSourceHatch) ;
      //未使用
      void split_AcGeCurve3d_by_length(AcGeCurve3d * pGe,std::vector& piece,double &length);
      
      //RTree临时接口
      template
      void RTree_get_date_from_cad(HRTREEROOT RTREEROOT_,const std::set &pt_entity_vertor,double kuo_da_zhi=0);
      //RTree临时接口
      template
      void RTree_get_date_from_cad(HRTREEROOT RTREEROOT_,const std::vector &pt_entity_vertor,double kuo_da_zhi=0);
-------------------------------------------------------------------------------------------------------------------------------------------------------
原图中function_for_cad_4.h文件夹下内容未经检验及使用,删除
-------------------------------------------------------------------------------------------------------------------------------------------------------
format_change.h 文件:
      //随手写的,历史遗留问题,就放在这里,不改动被调用的位置了
      #define AcGePoint3d_TO_Point(Point3d,point) {point=Point3d.x;point=Point3d.y;point=Point3d.z;}
      inline AcGePoint3d Point_TO_AcGePoint3d(double point[]) ;
      inline AcGePoint2d Point_TO_AcGePoint2d(double point[]) ;
      //功能:BKDRHash//了解就行
      inline unsigned long BKDRHash(const wchar_t *str);
      inline std::wstring int_to_wstring(int a);
      inline std::wstring int_to_wstring(long int a);
      inline std::wstring double_to_wstring(double a,int pred);
      //参考网上c码中的内容修改
      class CharAndWchar
      {
                public:
                CharAndWchar();
                virtual~ CharAndWchar();
                char* WcharToChar(wchar_t* wc);//宽字节转单字节
                wchar_t* CharToWchar(char* c); //单字节转宽字节
                void Release();//释放资源
                private:
                char* m_char;
                wchar_t* m_wchar;
      };
       //找find_字符在pt串中第idex次出现的位置,以pt指针形式返回结果
       bool find_nth_from_wchart_s(wchar_t *pt,wchar_t find_,int &idex);//read_points_for_cass_elevation_points_file1调用
      // 功能:将一个字符串转换为浮点数
      float StrToFloatW(const wchar_t* pstrfloat_) ;//read_points_for_cass_elevation_points_file1调用
//勇敢兄,这是你的,稍作修改,未使用
/*
公路桩号:
      沿着道路前进方向,起点处的桩号是k0.000,每隔一定距离(如100米)做1桩号标记,并在相应有需要的地方进行标记,但应以设计图纸上标明的为准。
      施工前,对设计基础桩进行统一编号,以利于施工,号码不重复,且唯一。
      例如:起点桩号K200.500,终点桩号K350.800 (K200.500~K350.800)
      意为:公路200公里处再过500米为开始处,直到350公里再过800米处的这段路。(K为千米/公里)
      计算路长:350.800 - 200.500=150.300km
      还有k0.000-100之类的情况,这种有负的情况,说明路是按两个方向分的,有一个是正方向,另一个则是反方向,类似坐标轴。
      例如:规定k0.000为中桩编号,东面为正西面为负,东面一百米表示为k0.000+100,西面一百米则表示为k0.000-100。
*/
          class xZh
          {
          public:
                  double StringToZh(wchar_t* p);//字符串转成桩号数值
                  wchar_t* ZhToString(double p,wchar_t* ret,bool all);//桩号数值转成字符串
                  bool IsZh(wchar_t*);         //这符串能不能转换成桩号数值。能的话,就初始化私有成员
          private:
                  wchar_t qian;         //桩号的千分位
                  wchar_t ge;         //桩号的个分位
                  wchar_t xiaoshu;//桩号的小数位
          };
------------------------------------------------------------------------------------------------------------------------------------------------------
dim_change.h 中:      (主要在dim_xyz1中使用)
      //功能描述:返回Matrix,即wcs_to_usc的变换矩阵
         bool get_AcGeMatrix3d_from_wcs_to_usc (AcGeMatrix3d &Matrix);
         bool get_AcGeMatrix3d_from_usc_to_wcs (AcGeMatrix3d &Matrix);
         bool is_wcs(void);
         //
         bool change_Entity_from_wcs_to_usc(AcDbEntity *Entity );
         //change_Entity_from_usc_to_wcs一般没用,cadAcDbEntity读出来的都是世界坐标
         bool change_Entity_from_usc_to_wcs(AcDbEntity *Entity );
------------------------------------------------------------------------------------------------------------------------------------------------------
attribute_change.h 文件中:
            //SameEntityBasicAttr原型见于
            //认为是该单独提取一类该功能的函数
            
            template
            void SameEntityBasicAttr(entity_1* pTargetEnt,const entity_2* pSourceEnt) ;//将pTargetEnt设置为和pSourceEnt设置为一样的属性
         
         //以下根据自己的想法修改、扩展
          template
          bool is_same_entity_basic_attr(entity_1* pTargetEnt,const entity_2* pSourceEnt) ;
          template//按需还可以将该部分内容再扩展
          void SameEntityAttr(entity_1* pTargetEnt,const entity_2* pSourceEnt);
-----------------------------------------------------------------------------------------------------------------------------------------------------
Select.h文件中:(该部分内容和空间上并不完全一致)
         template
      class Select
      {
      public:
                //
                static bool read_real_from_cad(double &nReturn,std::wstring tishi_show);
                static bool read_int_from_cad(int &nReturn,std::wstring tishi_show);
                static bool get_point_from_cad(AcGePoint3d &point,std::wstring tishi_show);
                //这是某位达人的
                static bool arx_ssget(std::vector&fanhui,AcApDocument* pActivatedDoc=curDoc());
                //提示的形式获得一个实体id
                static AcDbObjectId get_entity(void);
                static bool get_entity(ELEMTYPE *&fanhui,std::wstring tishi_show,bool ForWrite=1);
               
                //在用鼠标点取的多个对象中,提取指定类型的对象
                static bool get_simple_entity(std::vector &fanhui,std::wstring tishi_show=_T(""),bool ForWrite=0,bool add_to_fanhui=0);
                static bool get_simple_entity(std::set &fanhui,std::wstring tishi_show=_T(""),bool ForWrite=0,bool add_to_fanhui=0);
                static bool get_simple_entity(AcDbObjectIdArray &fanhui,std::wstring tishi_show=_T(""),bool ForWrite=0,bool add_to_fanhui=0);
                //提取图上所有指定类型的实体id//acedSSGet(_T("A"),NULL,NULL,NULL,ssname)
                static bool get_simple_entity_in_cur_workdatabase(AcDbObjectIdArray &fanhui,bool ForWrite=0,std::wstring tishi_show=_T(""),bool add_to_fanhui=0);
                //返回选择集内所有ELEMTYPE类的实体拷贝,参照不返回,只返回在块内的ELEMTYPE类的拷贝
                //acedSSGet(NULL,NULL,NULL,NULL,ssname);////使用者建立选择集 ssname
                static bool get_entity_copy_in_cur_workdatabase(std::vector &all_,std::wstring tishi_show,bool ForWrite,bool add_to_fanhui=0);
                //返回选择集内所有ELEMTYPE类的实体指针(cad命令行中有提示),AcDbBlockReference不返回,
                //返回参照中指定ELEMTYPE类的对象指针保存到in_AcDbBlockReference中
                //如果指定的ELEMTYPE为AcDbBlockReference类,会自动退出
                //acedSSGet(NULL,NULL,NULL,NULL,ssname);////使用者建立选择集 ssname
                static bool get_entity_in_cur_workdatabase_specially(std::vector&fanhui,std::vector &AcDbBlockReference,std::wstring tishi_show,bool ForWrite,bool add_to_fanhui=0);
                //按提示从图上框选指定类型的实体
                //不会裁剪
                //Select::get_simple_entity(fanhui_IdArray,one,two,ForWrite);
                static bool get_simple_entity_in_cur_workdatabase_by_rectang(std::vector &fanhui,AcGePoint3d &minpoint_wcs,AcGePoint3d &maxpoint_wcs,bool ForWrite=1);
                //提取指定范围内的指定实体的拷贝(含参照内,对框选范围外的进行裁剪)
                //get_entity_copy_in_cur_workdatabase_by_rectang中提示在界面上点取两点获得范围,返回为minpoint、maxpoint点世界坐标系下的坐标
                static bool get_entity_copy_in_cur_workdatabase_by_rectang(std::vector &fanhui,AcGePoint3d &minpoint_wcs,AcGePoint3d &maxpoint_wcs);      
                //从selected中提取对应id的ELEMTYPE指针,该指针在原来容器中仍然保留
                static ELEMTYPE* get_specified_id_entity_from_the_container(AcDbObjectId one,std::vector &in_container);
                //从容器内提取指定类型的对象指针
                //container为std容器,含cad entity pt
                //提取的对象会删除在in_container中的记录
                static void get_specified_type_entity_from_the_container( std::vector &new_ ,std::vector &in_container);
                //从容器内提取指定类型的对象指针
                //container为std容器,含cad entity pt
                //提取的对象会删除在in_container中的记录
                static void get_specified_type_entity_from_the_container(std::set &new_ ,std::set &in_container);
               
                //似乎没有使用
                static void remove_specified_entity_from_the_container(ELEMTYPE *one,std::vector &in_container);
                static void remove_specified_entity_from_the_container(ELEMTYPE *one,std::set &in_container);
               
                //以前试验用的
                static bool get_entity_from_region(std::vector &selected);
                //未调试
                static Acad::ErrorStatus select_entity_by_lay(AcDbObjectIdArray &selected,std::wstring nLayerName,bool ForWrite=1);//在指定层选择T类实体//改好
                //从cad图上提示用户选择一条闭合多段线,作为选择cad图上实体的范围线,提取范围内的T类实体
                static void get_circle_that_less_then_specified_radius(std::vector &Fanhui_DbEntity, std::vector &Shuru_DbEntity,double radius);
                static void get_specified_radius_circle(std::vector &Fanhui_DbEntity,std::vector &Shuru_DbEntity,double r);
      private:
                //根据AcGePoint3d &minpoint,AcGePoint3d &maxpoint获得图上范围内的cad对象,要求输入的是USC坐标,
                //bool input_point_is_usc 默认为1,如果不是函数内自动转换
                //为内部调用//不会遍历块内实体
                static bool get_simple_entity(AcDbObjectIdArray &fanhui,AcGePoint3d &minpoint,AcGePoint3d &maxpoint,bool ForWrite=1,bool input_point_is_usc=1);
      };
--------------------------------------------------------------------------------------------------------------------------------------------------------
原布局裁剪夹中的内容,网上资料,未使用未检验,删除。
--------------------------------------------------------------------------------------------------------------------------------------------------------
Cad_Line_Gon文件中的内容:      (前半部分是我刚开始学习时最需要看的,可了解arx是怎么画图的)
      class Cad_Line_Gon
      {
      public:
                Cad_Line_Gon(void){};
                ~Cad_Line_Gon(void){};
                //网上零散资料
                static void find_cad_install_path(std::wstring &AcadInstallPath,std::wstring AcadRegiditPath=_T("SOFTWARE\\Autodesk\\\\R18.2\\ACAD-A001:804"));
                //网上零散资料
                static bool get_linetype_IdFromString(const std::wstring &str, AcDbObjectId& id);
                //网上零散资料
                static AcDb:ineWeight get_line_width(float iWidth);
                //文字类
                static AcDbObjectId create_text_style(std::wstring textstyle_name,float textsize,std::wstring FontName_T=(_T("宋体")),
                                                                        bool shx=0,std::wstring BigFontName=_T("gbcbig.shx"));
                //建立单行文字
                static AcDbObjectId create_simple_text(AcGePoint3d pt,std::wstring text,text_parameter &simple_text_parameter_);
                static void create_simple_text(std::vector &container,std::vector >&input_container,text_parameter &simple_text_parameter_);
                static void create_simple_text(std::vector &container,std::vector&input_container,text_parameter &simple_text_parameter_);
                //建立多行文字
                static AcDbObjectId create_muti_text(const std::wstring &Text,AcDbObjectId TextStyle,const AcGePoint3d &BasePoint,
                                                                        double texthight,double width,double angle=0,int color=0,
                                                                        const std::wstring &layerName=_T("0"));
                static void create_muti_text_(std::vector &container,std::vector   &input_container,AcDbObjectId &TextStyle,
                                                      double texthight,double width,double angle=0,int color=0,
                                                      const std::wstring &layerName=_T("0"));
                static void create_muti_text_(std::vector > PointID_to_Point3d,AcDbObjectId &TextStyle,
                                                                        double texthight,double width,double angle,int color,
                                                                        const std::wstring &layerName);//container返回对象指针
                //忘记了,似乎是针对什么地方写的
                static void create_muti_text_check(std::vector > > &ampointID_to_Point3d);
                static void create_muti_text_check(std::vector>&ampointID_to_Point3d );
                static void create_muti_text_check(std::list>&ampointID_to_Point3d );
                //以下内容留意build和draw的区别就行。
                //draw的部分通过网上零散资料汇总、修改或扩展而得,在此表示对无私网友们的感谢,是入门时的第一手资料
                //build类只是根据某些特殊情况下写的。
                //直线类
                static AcDbObjectId draw_line( double x1,double y1,double z1,// 起点坐标
                                                               double x2,double y2,double z2// 终点坐标
                                                               ,int color=0);
                static Acad::ErrorStatus draw_line(AcDbObjectId &lineId,AcGePoint3d startPt,AcGePoint3d endPt,int color,std::wstring Layer,std::wstring linetype);
                static bool draw_line(std::vector&point3,std::vector &ObjectId,Adesk::UInt16 newColor=-1,std::wstring layer=_T(""));
                static AcDb2dPolyline* build_AcDb2dPolyline( AcGePoint3dArray &ptArr,bool IsClose=0);
                //多段线类
                static AcDb3dPolyline *build_3d_Triangle(AcGePoint3d &p1,AcGePoint3d &p2,AcGePoint3d &p3);
                static Acad::ErrorStatus draw_2dpolyline(AcDbObjectId& polylineId, AcGePoint3dArray &ptArr,
                                                                              int Color=1, double Width=0,bool IsClose=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));//画单条多段线
                static Acad::ErrorStatus build_2dPolyline(AcDb2dPolyline* &polyline, AcGePoint3dArray &ptArr,
                                                                              int Color=1, double Width=0,bool IsClose=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));//画单条多段线
               
                static Acad::ErrorStatus build_3d_Polyline__(AcDb3dPolyline*& new_AcDb3dPolyline_,std::vector &point_set);
                static Acad::ErrorStatus build_3d_Polyline__(AcDb3dPolyline *& new_AcDb3dPolyline_,AcGePoint3dArray &ptArr);
                static Acad::ErrorStatus build_3d_Polyline_(AcDb3dPolyline *& new_AcDb3dPolyline_, std::vector &point_set);
                static Acad::ErrorStatus build_3d_Polyline_(AcDb3dPolyline *& new_AcDb3dPolyline_,AcGePoint3dArray &ptArr,
                                                                              int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));
                static Acad::ErrorStatus draw_3d_polyline(AcDbObjectId& polylineId, AcGePoint3dArray &ptArr,
                                                                              int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));
                static Acad::ErrorStatus draw_3d_polyline(AcDbObjectId& polylineId, std::vector &point_set,
                                                                              int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));
                static Acad::ErrorStatus draw_3d_polyline(AcDbObjectId& polylineId, std::vector >&point_set,
                                                                              int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));
                static Acad::ErrorStatus draw_square(AcDbObjectIdArray& Id,std::vector&x,std::vector&y,
                                                                                                      int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));//画方形
               
                static Acad::ErrorStatus draw_square(AcDbObjectIdArray& Id,std::vector&point,//左上角点
                                                                                                                std::vector&breadth,
                                                                                                                std::vector&high,
                                                                                                                int Color=1, double Width=0,std::wstring Layer=_T("0"),std::wstring linetype=_T(""));//画方形
               
                //样条曲线类
                static Acad::ErrorStatus draw_spline_polyline(AcDbObjectId& polylineId, AcGePoint3dArray ptArr,
                                                                                                               int Color, double Width,bool IsClose,std::wstring Layer,std::wstring linetype=_T(""));
                //建立面域
                static AcDbRegion* build_one_regions(AcDbVoidPtrArray& curveSegments);
                static AcDb3dPolyline* build_rectang(std::vector &point_set);
                static AcDb3dPolyline* build_rectang(AcDbExtents &extent);
                //临时所写,临时用的
                static AcDb3dPolyline* build_rectang_boundary_by_usc(AcDbExtents &extent);
                //填充类
                static AcDbObjectId draw_hatch(
                                                                                                AcDbObjectId dbOId,
                                                                                                wchar_t cLayer[]=_T("0"),
                                                                                                wchar_t cPattern[] =_T("SOLID"),
                                                                                                int nColor =256,
                                                                                                double dAngle =0.0,
                                                                                                double dScale =1.0,
                                                                                                AcDbDatabase * pDbDatab = acdbHostApplicationServices()->workingDatabase());
                //dbOId为圆、椭圆、矩形、面域、闭合多段线等闭合、封闭的实体集
                static Acad::ErrorStatus draw_hatch(
                                                                                                AcDbObjectIdArray &FanHuiId,
                                                                                                AcDbObjectIdArray &dbOId,
                                                                                                std::vector&cLayer ,
                                                                                                std::vector   &cPattern,
                                                                                                std::vector&nColor,
                                                                                                std::vector&dAngle,
                                                                                                std::vector&dScale,
                                                                                                AcDbDatabase * pDbDatab= acdbHostApplicationServices()->workingDatabase());
                //镜象
                static Acad::ErrorStatus draw_mirror_entity( AcDbObjectId &Fanhui_Id,AcDbObjectId &Shuru_Id,
                                                                                                                AcGePoint3d ptMirAxisStart,
                                                                                                                AcGePoint3d ptMirAxisEnd,AcDbDatabase *Database= acdbHostApplicationServices()->workingDatabase());//单个id镜象
      
                static Acad::ErrorStatus draw_mirror_entity( AcDbObjectIdArray &Fanhui_Id,AcDbObjectIdArray &Shuru_Id,
                                                                                                                AcGePoint3d ptMirAxisStart,
                                                                                                                AcGePoint3d ptMirAxisEnd,AcDbDatabase *Database= acdbHostApplicationServices()->workingDatabase());
                //该函数原型见于
                static bool pick_up_hatch_boundary(std::vector &curveSegments,AcDbHatch* pHatch);
               
                //下面根据需要自行扩展
                //通过屏幕点选Hatch,获得指针
                static bool get_hatch(std::vector &store,bool ForWrite);
                //复制形式获得指定Hatch的边界线
                static bool pick_up_hatch_boundary(std::vector &curveSegments,AcDbHatch* pHatch);
                static bool pick_up_hatch_boundary(std::vector &fanhui_regions,AcDbHatch* input);
                //根据所选择线改变填充图案形状// //一个分为多个
                //AcDbHatch* &input_Hatch将在函数内
                //一个分为多个
                //特点:将input_Hatch边界线和curveSegments拓扑造区,建立面域,面域生产填充图案
                //同时将新建的hatch加入了模型空间,并删除并释放原来输入的input_Hatch,将input_Hatch指针置零
                static std::vectorchange_hatch_boundary(AcDbHatch* &input_Hatch,std::vector &curveSegments);
                //AcDbRegion_Id为圆、椭圆、矩形、面域、闭合多段线等闭合、封闭的实体
                static AcDbHatch* rebuild_hatch_boundary_for_AcDbHatch( const AcDbHatch* old_Hatch,std::vector &dbObjIds);
               
                //在屏幕按提示提取外环//这个只是试验时用的
                static void pick_up_hatch_boundary(void);
};
----------------------------------------------------------------------------------------------------------------------------------------------------------
Cad_Block.h 文件内:
         class Cad_Block
      {      
      public:
                Cad_Block(void);
                ~Cad_Block(void);
      public:
                //将input容器内的AcDbEntity对象做成一个块,AcDbEntity需没有被加入过模型空间的实体
                //BlockName为自设的块名,存在同名则跳出
                //返回生成对象的id
                staticAcDbObjectId make_a_simple_block( std::vector &input ,AcGePoint3d &origin_of_coordinate,std::wstring BlockName);
               
                //原文地址
                staticAcDbText* AcDbAttributeToAcDbText(AcDbAttribute* pAttr);//应该移到通用函数里//未使用
               
                //将文件加载为块:1:文件名为块名 2:在pDb中定义为块 3、根据文件名自动构造块名,同文件名时自动改块名后序,不会重复
                static bool import_block_from_dwg(std::wstring path,AcDbDatabase* pDb= acdbHostApplicationServices()->workingDatabase());
               
                //将源文件strSourceDwgFile_path中指定块名strBlockName的块加载到指定文件pDb中
                static Acad::ErrorStatus
                        import_block_from_dwg(std::wstring strSourceDwgFile_path,std::wstring strBlockName,AcDbDatabase* pDb= acdbHostApplicationServices()->workingDatabase());
                //判断在pDb中是否存在BlockName块名的块
                static bool has_the_same_block(std::wstring BlockName, AcDbDatabase *pDb= acdbHostApplicationServices()->workingDatabase());
               
                //按提示操作,将选择的对象转换为块
                static void make_block_with_BlockReference(std::wstring block_name);
                //按提示操作,
                static bool make_block_with_BlockReference(std::wstring block_name,std::vector &Tag);
               
                //经过import_block_from_dwg->BindXref2后,可以通过set_AcDbBlockReference_to_the_same_lay将数据库中指定blockname中的所有东西更改为同一个图层
                staticAcad::ErrorStatus
                        set_AcDbBlockReference_to_the_same_lay(std::wstring blockname,std::wstring layname,AcDbDatabase *pdb= acdbHostApplicationServices()->workingDatabase());
                static Acad::ErrorStatus delect_bock(std::wstring blockname );
                //插入块//主要针对某些特定用途的,不通用//Draw_PointBlock调用,用途见Draw_PointBlock函数定义上的说明
                //ObjectId用来接受生成对象的返回id
                static Acad::ErrorStatus
                insert_block(AcDbBlockReference *&pBlkRef,AcDbObjectId &ObjectId,AcGePoint3d &pt,std::wstring blockname ,std::wstring layname,int ColorIndex,
                                                std::map &changevent,bool change=0,bool display=1,AcGeScale3d Scale=1, double Rotation=0,AcDbDatabase *pdb= acdbHostApplicationServices()->workingDatabase());
      
      private:
                AcGeScale3d Scale;
               
                //以下部分内容为初期形成,接口形式不好,内部调用,不作修改
                //AcDbBlockReference类表示在AutoCAD中INSERT实体。
                static bool is_BlockReference_object(AcDbEntity *pEnt);
                //判断输入的实体是否常规cad对象
                static bool is_cad_Common_object(AcDbEntity *pEnt);
                static Acad::ErrorStatus recursive_procedure_for_every_to_change_lay_name(AcDbEntity *Ent,std::wstring layname) ;
                //在指定层建立含属性的图块(块的内容和属性在代码里做,不含外部块);块名重复则跳出
                //作为例子,但有被其它地方调用
                static bool make_a_simple_block_with_attribute_definition_for_example(std::wstring BlockName,std::wstring layName,AcDbDatabase* pDb=acdbHostApplicationServices()->workingDatabase());
                //将特定属性(代码内)绑定到相应entityId名的块中并加入到AcDbBlockTableRecord
                static void make_AcDbAttributeDefinition_for_AcDbBlockTableRecord(AcDbAttributeDefinition_parameter &AcDbAttributeDefinition_parameter_,AcDbDatabase* pDb= acdbHostApplicationServices()->workingDatabase() );
                ////由insert调用
                static Acad::ErrorStatus
                        make_AcDbBlockReference_based_on_the_block_id( AcDbBlockReference* blkRef,const AcDbObjectId& blockRecordId,bool change,
                                                                        std::map &changevent);
                //以下内容来自于网络,被调用
                //绑定pDb文档的外部参照,默认绑定当前文档
                voidBindXref2(AcDbDatabase *pDb=acdbHostApplicationServices()->workingDatabase());
                //对在AcDbDatabase *pDb中的到的外部参照进行数据库绑定
                voidDo_BindXref2(AcDbDatabase *pDb, AcDbObjectIdArray& objIdArr);
      
               
      };
---------------------------------------------------------------------------------------------------------------------------------------------------------
XTCOW_Cad_point.h 文件内:      
      class XTCOW_Cad_point//画点仅供参考,最前期试写
      {
      private:
                staticdouble text_size;//文字大小默认值
      public:
                //网上资料
                //一次加一个点//变量名:ObjectId   变量说明:传入的空的id变量
                static Acad::ErrorStatusDraw_Point(AcDbObjectId &ObjectId, AcGePoint3d& nPt,std::wstring Layer,int Color=1);
                static Acad::ErrorStatusDraw_Circle(AcDbObjectId& circleId,AcGePoint3d 攀爀,float r);//画圆,输入空的circleId对象;
                static Acad::ErrorStatusDraw_Circle(AcDbObjectIdArray& fanhui_circleId,std::vector攀爀,float r,int Color=1,
                                                                                          std::wstring Layer=_T("0"),AcDbDatabase *Database= acdbHostApplicationServices()->workingDatabase());//画圆,输入空的circleId对象
      public://以下为扩展部分
                //非通用,在xtcowcad813中调用
                //按cad命令行提示,指定轴方向,选择编号方式进行编号
                static Acad::ErrorStatusbuild_serial_number_for_points(void);
                //static Acad::ErrorStatusbuild_serial_number_for_line_points(void);//给线上点编号(可指定方向,可以指定跳号)//未写
            
                //暂时只被build_serial_number_for_points调用,为build_serial_number_for_points而写
                static Acad::ErrorStatusDraw_Point(std::vector pt_entity_vertor, \
                     std::map &point_date,\
                     std::wstring Layer,AcCmColor Color,\
                     AcDbDatabase* pt_datebase=acdbHostApplicationServices()->workingDatabase());
         
                //见Draw_PointBlock函数定义上的调试例子
                static Acad::ErrorStatusDraw_PointBlock(std::vector & pt_entity_vertor, \
                        std::map &point_date,\
                        std::wstring Layer,AcCmColor Color,std::wstring BlockName,\
                        std::map &changevent,\
                        bool change=0,bool display=1,AcGeScale3d Scale=1, double Rotation=0,\
                        std::wstring xdate=_T("XTCOW_PointBlock"),\//不同的扩展数据名用来表示不同的AcDbBlockReference,在检索时好辨别是什么
                        AcDbDatabase* pt_datebase=acdbHostApplicationServices()->workingDatabase());
      private:
                     static Acad::ErrorStatusAdd_PointObject_point(std::wstring &Layer,AcCmColor Color);//试验
      };
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Tin.h文件内:      
       template
      class CTriangleMesh
      {
      protected:
                //进行三角形相邻关系分析的类//因某些原因,没有使用核心代码中提供的对应功能
                Triangle_topoTriangle_topo_;
                //Triangle_topo_整理后的生成对象
                std::vector > Triangle_struct_list_;//将CTriangleMesh模型生成的原始数据转换成Triangle_struct模型
               
                //记录Triangle_struct_list_中哪些三角形被删除(或排除在统计之外),int记录的是Triangle_struct对象的特有标识符
                std::set deleted_tris;
                //记录Triangle_struct_list_中所有三角形对应的角点被删除(或排除在统计之外),int记录的是每个点对象的特有标识符
                std::set deleted_point_about_deleted_tris;
                //用来记录经过程序插值形成的点,用来保存输出//
                std::vector Triangle_Interpolation_points;
                //指针,记录Triangle_struct_list_中三角形空间分布的数据库
                //指向kd_tree和kd_tree_for_split中的一个//非实体
                HRTREEROOT kd_tree_for_xy;
                //记录每个Vorout顶点对应的坐标//如索引号为j的Vorout顶点对应的坐标为ptsVorout_not_split
                std::vector ptsVorout_not_split;
                std::vector edgsVorout_not_split;
                std::vector edgsVorout_split;
                std::vector ptsVorout_split;
      protected:
                //对应tris_not_split的x_y空间检索库//如果kd_tree_for_split最终生成,它将马上销毁
                HRTREEROOT kd_tree;
                //对应tris_split的x_y空间检索库//如果不存在tris_split,它的指针为空
                HRTREEROOT kd_tree_for_split;
      protected:
                //指向输入点集的指针,用来初始化Triangle_struct_list_
                std::vector *input_date;
      public:      
                CTriangleMesh();
                ~CTriangleMesh();
      protected:
                void initialize(void);
                //被initialize调用
                void clear_TriangleMesh_memorypool();
      public:      
                //用途:1、生成凸包形式的非约束三角网
                //指令:1、zevn 2、Dzevn(可指定生成三角形的内角最小角度)3、qzevn(可指定生成的三角形最小面积)
                bool build_TriangleMesh(wchar_t *triswitches , std::vector &pts);
               
                //指定内外边界、地貌线约束三角化
                //用途精确输入内外边界、地貌线,一次性生成三角网
                //目前用途:1、生成边界约束三角网
                //pts:输入点坐标数组,包括边界点和内部点。
                //Segs_:内外边界线、边界点数组,外边界只能是一条,在数组中第一行,其它为内边界数组。通过get_out_boundary_points_from_input_points_by_pline命令获取
                //Segs__:地貌线边界数组
                bool build_TriangleMesh(wchar_t *triswitches, std::vector& pts,std::vector>&Segs_,std::vector>&Segs__);
      public:      
                //从Triangle_topo生成的三角形网络中提取网络边界
                //或从由三个顶点的闭合三维多段线组成的三角网中提取网络边界
                //对修改后的网络提取内外边界线
                //见命令行提示
                static bool pick_up_Tin_boundary(void);
      public:      
                //检查输入点是否在TriangleMesh范围内
                //如果在,返回所在点位于对应三角形的索引号,不在返回the_point_not_relation_TriangleMesh
                intsearch_Triangle_id_for_point(ELEMTYPE &inter_point);
                //以下需要在build_TriangleMesh调用后使用
                //指定插值算法计算某一个点的高程//同时自身也被build_TriangleMesh调用
                double compute_elevation_by_interpolation_point(ELEMTYPE &inter_point,bool kring=0);
                //计算volume and compute_surface_area_and_volume_of_Tin//
                bool compute_surface_area_and_volume_of_Tin_3d(void);
                //删除Triangle_struct_list_内指定的三角形
                void kill_Triangle_by_boundary(std::vector &deleted_tris__);
                //删除Triangle_struct_list_内和Triangle_struct相交的三角形
                void kill_Triangle_by_boundary(std::vector > &deleted_tris__ );
               
                //画三角网
            bool draw_Tin(void);
                //画Voronoi
                bool draw_Voronoi(void);
                //画dem//cad
                bool draw_dem(double cell_size);
                //将形成的插值点加入文件
                intput_out_Interpolation_point_to_file(void);
      protected:
                //初始化rtree
                void get_ready_rtree();
                void build_kd_tree(bool tris_not_split=1);
                //检查输入点是否在TriangleMesh范围内
                //如果在,返回所在点位于对应三角形的索引号,不在返回the_point_not_relation_TriangleMesh
                //Internal_call_in_Triangle and compute_elevation_by_interpolation_point
                int                search_Triangle_id_for_point(ELEMTYPE &inter_point,bool Internal_call=0);
                void      compute_z_for_split_point_in_Triangle(void);//内部调用
                doublecompute_z_for_split_point_in_Triangle( std::vector &tris,std::vector &ptsTris,int index,ELEMTYPE &inter_point,bool kring=0);
               
                void      get_split_points(std::vector&split_points );
                //build_TriangleMesh调用
                void      execute_Triangle_topo(void);
      protected:
                //以下部分未好,不打算做
                //手工加密三角网,并且改动原图//暂时不考虑提供给重新生成三角网使用
                ////#define use_Triangle_to_AcDbObjectId //动态删除三角形时用到
                //保存最后一次用draw_Tin生成的三角形索引号三角形id的 映射
                //如果Triangle_split存在则记录在Triangle_split_to_AcDbObjectId中,
                //否则记录在Triangle_to_AcDbObjectId
                std::map Triangle_to_AcDbObjectId;
                std::map Triangle_split_to_AcDbObjectId;
                bool add_point_to_TriangleMesh(ELEMTYPE &inter_point);
                bool add_Triangle_for_split(std::vector &tris,std::vector &ptsTris,std::vector&split_point,int index);
                //手工加密三角网,并且改动原图
                bool delete_Triangle( std::vector &tris,std::vector &ptsTris, std::map &Triangle_to_AcDbObjectId,int index);
      protected:
                //保存过程中段的分析结果
                std::vector                                                tris_not_split;
                std::vector                                        ptsTris_not_split;
                std::vector                                                tris_split;
                std::vector                                                ptsTris_split;
      protected:
                static int                                                                        count___;//调试检测用的
                unsigned long                                                                *vector_;//空间数据库查找使用
                ELEMTYPE                                                                point_set;//转换数据
                double                                                                        boundsMin;//转换数据
                double                                                                        boundsMax;//转换数据
                Triangle_struct                                        linshi_Triangle_;//转换数据
protected:
                //获取数据
                void GetData(void);
                char   cstrTriswitches;
                triangulateio in;                //输入结构
                triangulateio out;                //输出结构
                triangulateio vorout;      //输出Voronoi图结构
                //三角剖分
                bool DoTriangulate()
                {
                        try
                        {
                              triangulate(cstrTriswitches, &in, &out, &vorout);
                              GetData();//获取三角剖分结果      
                        }
                        catch (...)
                        {   
                              initialize();
                              return 0;
                        }               
                        return 1;
                }
      };
------------------------------------------------------------------------------------------------------------------------------------------------------------
被CTriangleMesh类调用的类:
      template
      class Triangle_topo
      {
      private:
                //记录外面传过来的Triangle的xy索引库
                HRTREEROOTpt_rtree_of_xy_for_Triangle;
                //内部自建、Triangle在z方向上的索引库
                HRTREEROOTrtree_of_z_for_Triangle;
                HRTREEROOTrtree_of_Triangle_points_about_Triangle_struct_list;
                //保存结果的容器指针,外面传过来的
                std::vector > *Triangle_struct_list;
                std::set * deleted_tris;
                std::set * deleted_point_about_deleted_tris;
               
      public:
                Triangle_topo();
                ~Triangle_topo();
                //处理数据用的类
                Triangle_behavior Triangle_behavior_;
                void clear();
                //获得需要的处理数据
                //Triangle_struct_list保存处理好的三角形信息//在函数内Triangle_struct_list先会被先清空
                //其余变量均为CTriangleMesh类内部容器
                bool build_topo_for_Triangle(std::vector > &Triangle_struct_list,\
                              std::vector &tris_,std::vector &ptsTris_,\
                              HRTREEROOTkd_tree_of_xy_for_Triangle,std::set * deleted_tris_,\
                              std::set *deleted_point_about_deleted_tris_);
                //通过已经建立的三角网数据结构,在图上画出未经加密及圆滑的等高线
                //gaocheng_保存需要生存的等高线的高程值
                //biao_gao_fen_duan_min,int biao_gao_fen_duan_max为gaocheng_中高程值的区间,可是放大一点,检索使用
                //不要一次把所有高程值都放到gaocheng_容器中,分批放将会提高效率
                //仅供学习参考
                //仅尝试过少量数据检测,因为这属于非数据挖掘部分,绘图我会选择专业软件实现该功能
                void build_Contour(std::vector &gaocheng_,int biao_gao_fen_duan_min,int biao_gao_fen_duan_max);
               
                //在build_topo_for_Triangle后使用
                //输出的dem__对象提供给 mesh.h 类使用
                bool Triangles_to_dem(dem &dem__,double cell_size);
      private:
                //内部数据初始化
                bool compute();
                bool get_Triangle_by_z_range(std::vector &fanhui_Triangle,double min_z,double max_z);
               
                //以下由build_Contour调用
                int get_next_edge_for_Triangle( int now_Triangle,int index_not_include_the_edge,double &gaocheng);
               
                int get_special_edge_for_Triangle(int now_Triangle,edges_struct & find_the_edge,double &gaocheng);
               
                //返回值为找到该点所在边的索引号//并将该点加入到容器
                int find_one_point_in_Triangle_for_Contour(int Triangle,double &gaocheng,std::vector &points_set,int index_not_include_the_edge=-1);
               
                /*和edge_begin_to_search相邻的下一个三角形的index*/
                int find_next_Triangle_for_Contour(int now_Triangle,int edge_begin_to_search);
               
                void find_points_by_search_Triangles_for_Contour(int begin_Triangle,int not_find_edge,double &gaocheng,std::vector &points_set,bool*biaoji_Triangle_finish);
      
      private:
                //临时变量
                unsigned long * vector_;
                Triangle_structTriangle;
                AABB_2D Extent;
                double boundsMin;
                double boundsMax;
               
    };
----------------------------------------------------------------------------------------------------------------------------------------------------
被Triangle_topo类调用的类:
      template
      class Triangle_behavior
      {
      private:      
                //自用临时变量
                unsigned long *vector_;
                std::set * deleted_tris;
                std::set *deleted_point_about_deleted_tris;
                //记录传递过来的数据指针
                std::vector > *Triangle_struct_list;
                //记录传递过来的数据指针
                HRTREEROOTpt_kd_tree_of_xy_for_Triangle;
                //HRTREEROOTkd_tree_of_Triangle_points_about_Triangle_struct_list;
      public:
                //记录外边界上的三角形
                std::set *> outsize_Triangle_list;
                std::set point_about_outsize;
                //记录所有输入的三角形在xy面上的范围值
                AABB_2D Extent_Triangle_struct_list;      
      public:
                Triangle_behavior();
                ~Triangle_behavior();
                //清理内部变量
                void clear();
                //初步建立各三角形的相邻关系
                bool topo(std::vector > *Triangle_struct_list_,HRTREEROOTpt_kd_tree_of_xy_for_Triangle_,HRTREEROOT kd_tree_of_Triangle_points_about_Triangle_struct_list_,std::set *deleted_tris_,      std::set *deleted_point_about_deleted_tris_);
               
                //标志该三角形已被删除
                void delete_Triangle(Triangle_struct &Triangle_);
                //标志该三角形三个点已被删除               
                bool delete_relation_point_about_Triangle(Triangle_struct &Triangle_);
      private:
                //被topo调用
                bool compute(void);
                //被compute调用
                void initrial_outsize_Triangle_and_point_list(void);
}
----------------------------------------------------------------------------------------------------------------------------------------------------------
input_help.h 文件夹内:(辅助CTriangleMesh)
       template//读取cass格式的高程点文件数据,返回于ptsTris中
      int read_points_for_cass_elevation_points_file1(std::vector &ptsTris);
      template//读取cass格式的高程点文件数据,返回于ptsTris中
      int read_points_for_cass_elevation_points_file(std::vector &ptsTris);
      //按屏幕提示为Tin.h在图上框选高程点,提取数据返回于Point_容器中
      bool get_points_set_from_cad(std::vector > &ampoint_);
      //按屏幕提示,从图上提取外边界、内边界、及地质界线,为Tin.h类生成数据
      //ptsTris_not_split为输入的离散点
      //Point_boundary为根据提示操作后取得的边界点集
      template
      boolget_boundary_points_from_input_points_by_pline(std::vector &ptsTris_not_split,std::vector > &ampoint_boundary,bool is_di_mao_xian=0);
-------------------------------------------------------------------------------------------------------------------------------------------------------
-
















版主先不要删帖

未整理

未整理

未整理

未整理

未整理

未整理














**** Hidden Message *****

20060510412 发表于 2018-11-16 08:42:00

谢谢楼主分享经验,虽然我看不懂......

liuxingyang 发表于 2018-4-23 12:05:00

这些东西费了不少心血,给你点赞

cadmap 发表于 2018-11-21 10:01:00

都是一些比较实用的例子,感谢

风树 发表于 2014-1-8 18:28:00


原附件无法更改权限。
2014.1.17
现提供部分整理后的下载文件,内容和说明的一致:
部分将rtree 写成了kd_tree





















风树 发表于 2014-1-8 18:29:00

2222222222

风树 发表于 2014-1-8 18:31:00


下面的几本书挺好的,值得一看
可直接上网上搜索书名下载。

gzxl 发表于 2014-1-8 18:45:00


先顶,再下来看看是什么
抱歉,只有特定用户可以下载本站附件,神秘呀

风树 发表于 2014-1-8 18:58:00


你好 还没编辑好呢,会有详细说明里面的内容

gzxl 发表于 2014-1-8 19:17:00


哦,那能不能发一份给我学习下
gzxl90@126.com
页: [1] 2
查看完整版本: 代码生来就是为人们服务的,它喜欢干的事就由它去干(部分整理)