明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1525|回复: 6

多边形叠加分析(交并差)

[复制链接]
发表于 2021-12-13 09:23 | 显示全部楼层 |阅读模式
本帖最后由 gzxl 于 2021-12-13 09:32 编辑

MFC 的多边形叠加分析(交并差)见原帖网址:
https://github.com/team79/Polygo ... ter/MFCApplication3

arx的多边形叠加分析(交并差)效果图:
http://bbs.mjtd.com/forum.php?mod=attachment&aid=MTE3MTYxfDY1YTljOTFkMmU1MDVlZTQwYmU0NDIxYzNjOTAzZGM5fDE3MTQ2Mzc3NzE%3D&request=yes&_f=.gif
arx 的不支持有弧段的多边形。

数学法计算交集与面域法计算交集的时间比较:
数学法用时: 0 毫秒

面域法用时: 2937毫秒

获取多段线顶点坐标,并加入点集合中
  1.     /// @brief 获取多段线顶点坐标,并加入点集合中
  2.     /// @param[In] polylineId : 多段线实体 ID
  3.     /// @param[Out] pointArray : 返回的顶点集合
  4.     /// @return : 成功返回 Acad::eOk,失败返回 Acad::eInvalidInput
  5.     static Acad::ErrorStatus GetPolylineVertPts(AcDbObjectId polylineId, AcGePoint3dArray& pointArray)
  6.     {
  7.         Acad::ErrorStatus es = Acad::eOk;
  8.         AcDbObject* pObject = NULL;
  9.         AcDbPolyline* pline = NULL;
  10.         if ((es = acdbOpenObject(pObject, polylineId, AcDb::kForRead)) != Acad::eOk)
  11.             return es;
  12.         if (!pObject->isKindOf(AcDbPolyline::desc()))
  13.         {
  14.             pObject->close();
  15.             return Acad::eInvalidInput;
  16.         }
  17.         pline = AcDbPolyline::cast(pObject);
  18.         int num = pline->numVerts();
  19.         for (int i = 0; i < num; i++)
  20.         {
  21.             AcGePoint3d temPt;
  22.             if ((es = pline->getPointAt(i, temPt)) == Acad::eOk)
  23.             {
  24.                 pointArray.append(temPt);
  25.             }
  26.         }

  27.         AcGePoint3d startPt;
  28.         es = pline->getPointAt(0, startPt);
  29.         pointArray.append(startPt);

  30.         pObject->close();
  31.         return es;
  32.     }
复制代码
多边形叠加分析(交集) 测试
  1. // 创建多段线过滤条件
  2. struct resbuf* filter = acutBuildList(RTDXF0, _T("LWPOLYLINE"), RTNONE);
  3. ads_name ss;
  4. // 提示用户选择二个多边形
  5. acutPrintf(_T("\n请选择二个多边形(闭合多段线):\n"));
  6. int res = acedSSGet(NULL, NULL, NULL, filter, ss);
  7. // 释放缓冲区链表
  8. acutRelRb(filter);

  9. // 计时开始
  10. DWORD start, end;
  11. start = GetTickCount();

  12. // 如果取消了选择或者选择条件不符合
  13. if (res != RTNORM)
  14. {
  15.     acutPrintf(_T("\n没有选择二个多边形(闭合多段线)!"));
  16.     return;
  17. }
  18. // 选择集个数
  19. Adesk::Int32 length;
  20. acedSSLength(ss, &length);
  21. if (length != 2)
  22. {
  23.     acutPrintf(_T("\n必须选择二个多边形(闭合多段线)!"));
  24.     // 释放选择集
  25.     acedSSFree(ss);
  26.     return;
  27. }
  28. // 第一、二个多边形顶点集合,交集顶点集合
  29. AcGePoint3dArray poly1Pts, poly2Pts, interPolyPts;
  30. // 错误状态码
  31. Acad::ErrorStatus es;
  32. // 图元名
  33. ads_name eame1, eame2;
  34. acedSSName(ss, 0, eame1);
  35. acedSSName(ss, 1, eame2);
  36. // 释放选择集
  37. acedSSFree(ss);
  38. // 图元名转换为实体ID
  39. AcDbObjectId obj1Id, obj2Id;
  40. es = acdbGetObjectId(obj1Id, eame1);
  41. es = acdbGetObjectId(obj2Id, eame2);
  42. // 获取多边形顶点,并加入集合
  43. es = GetPolylineVertPts(obj1Id, poly1Pts);
  44. es = GetPolylineVertPts(obj2Id, poly2Pts);

  45. MPolygon p1, p2;
  46. Edge temp;
  47. // 第一个多边形
  48. for (int i = 0; i < poly1Pts.length() - 1; i++)
  49. {
  50.     temp.LPoint.x = poly1Pts[i].x;
  51.     temp.LPoint.y = poly1Pts[i].y;
  52.     temp.RPoint.x = poly1Pts[i + 1].x;
  53.     temp.RPoint.y = poly1Pts[i + 1].y;
  54.     p1.external_circle.circle_edge.push_back(temp);
  55. }
  56. temp.LPoint.x = poly1Pts[0].x;
  57. temp.LPoint.y = poly1Pts[0].y;
  58. temp.RPoint.x = poly1Pts[poly1Pts.length() - 1].x;
  59. temp.RPoint.y = poly1Pts[poly1Pts.length() - 1].y;
  60. p1.external_circle.circle_edge.push_back(temp);
  61. p1.internal_circle.clear();

  62. // 第二个多边形
  63. for (int i = 0; i < poly2Pts.length() - 1; i++)
  64. {
  65.     temp.LPoint.x = poly2Pts[i].x;
  66.     temp.LPoint.y = poly2Pts[i].y;
  67.     temp.RPoint.x = poly2Pts[i + 1].x;
  68.     temp.RPoint.y = poly2Pts[i + 1].y;
  69.     p2.external_circle.circle_edge.push_back(temp);
  70. }
  71. temp.LPoint.x = poly2Pts[0].x;
  72. temp.LPoint.y = poly2Pts[0].y;
  73. temp.RPoint.x = poly2Pts[poly2Pts.length() - 1].x;
  74. temp.RPoint.y = poly2Pts[poly2Pts.length() - 1].y;
  75. p2.external_circle.circle_edge.push_back(temp);
  76. p2.internal_circle.clear();

  77. vector<AcGePoint2dArray> interPts;
  78. MPolygon::SolveAnd(p1, p2, interPts); // 交集
  79. if (interPts.size() > 0)
  80. {
  81.     for (int i = 0; i < (int)interPts.size(); i++)
  82.     {
  83.         AcGePoint2dArray pts = interPts[i];
  84.         if (pts.length() > 0)
  85.         {
  86.             int numVertices = pts.length();
  87.             AcDbPolyline* pPoly = new AcDbPolyline(numVertices);
  88.             for (int j = 0; j < numVertices; j++)
  89.             {
  90.                 AcGePoint2d pt2d = pts[j];
  91.                 pPoly->addVertexAt(j, pt2d, 0, 0, 0);
  92.             }
  93.             pPoly->setColorIndex(1);
  94.             pPoly->setClosed(TRUE);
  95.             pPoly->setConstantWidth(10);
  96.             AcDbBlockTable* pBlkTbl = NULL;
  97.             acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);
  98.             AcDbBlockTableRecord* pBlkTblRcd = NULL;
  99.             pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
  100.             pBlkTbl->close();
  101.             pBlkTblRcd->appendAcDbEntity(pPoly);
  102.             pBlkTblRcd->close();
  103.             pPoly->close();
  104.         }
  105.     }
  106. }
  107. // 结束计时
  108. end = GetTickCount() - start;
  109. acutPrintf(_T("\n数学法用时: %d 毫秒"), end);
复制代码
多边形叠加分析(并集) 测试
  1. // 创建多段线过滤条件
  2. struct resbuf* filter = acutBuildList(RTDXF0, _T("LWPOLYLINE"), RTNONE);
  3. ads_name ss;
  4. // 提示用户选择二个多边形
  5. acutPrintf(_T("\n请选择二个多边形(闭合多段线):\n"));
  6. int res = acedSSGet(NULL, NULL, NULL, filter, ss);
  7. // 释放缓冲区链表
  8. acutRelRb(filter);

  9. // 计时开始
  10. DWORD start, end;
  11. start = GetTickCount();

  12. // 如果取消了选择或者选择条件不符合
  13. if (res != RTNORM)
  14. {
  15.     acutPrintf(_T("\n没有选择二个多边形(闭合多段线)!"));
  16.     return;
  17. }
  18. // 选择集个数
  19. Adesk::Int32 length;
  20. acedSSLength(ss, &length);
  21. if (length != 2)
  22. {
  23.     acutPrintf(_T("\n必须选择二个多边形(闭合多段线)!"));
  24.     // 释放选择集
  25.     acedSSFree(ss);
  26.     return;
  27. }
  28. // 第一、二个多边形顶点集合,交集顶点集合
  29. AcGePoint3dArray poly1Pts, poly2Pts, interPolyPts;
  30. // 错误状态码
  31. Acad::ErrorStatus es;
  32. // 图元名
  33. ads_name eame1, eame2;
  34. acedSSName(ss, 0, eame1);
  35. acedSSName(ss, 1, eame2);
  36. // 释放选择集
  37. acedSSFree(ss);
  38. // 图元名转换为实体ID
  39. AcDbObjectId obj1Id, obj2Id;
  40. es = acdbGetObjectId(obj1Id, eame1);
  41. es = acdbGetObjectId(obj2Id, eame2);
  42. // 获取多边形顶点,并加入集合
  43. es = GetPolylineVertPts(obj1Id, poly1Pts);
  44. es = GetPolylineVertPts(obj2Id, poly2Pts);

  45. MPolygon p1, p2;
  46. Edge temp;
  47. // 第一个多边形
  48. for (int i = 0; i < poly1Pts.length() - 1; i++)
  49. {
  50.     temp.LPoint.x = poly1Pts[i].x;
  51.     temp.LPoint.y = poly1Pts[i].y;
  52.     temp.RPoint.x = poly1Pts[i + 1].x;
  53.     temp.RPoint.y = poly1Pts[i + 1].y;
  54.     p1.external_circle.circle_edge.push_back(temp);
  55. }
  56. temp.LPoint.x = poly1Pts[0].x;
  57. temp.LPoint.y = poly1Pts[0].y;
  58. temp.RPoint.x = poly1Pts[poly1Pts.length() - 1].x;
  59. temp.RPoint.y = poly1Pts[poly1Pts.length() - 1].y;
  60. p1.external_circle.circle_edge.push_back(temp);
  61. p1.internal_circle.clear();

  62. // 第二个多边形
  63. for (int i = 0; i < poly2Pts.length() - 1; i++)
  64. {
  65.     temp.LPoint.x = poly2Pts[i].x;
  66.     temp.LPoint.y = poly2Pts[i].y;
  67.     temp.RPoint.x = poly2Pts[i + 1].x;
  68.     temp.RPoint.y = poly2Pts[i + 1].y;
  69.     p2.external_circle.circle_edge.push_back(temp);
  70. }
  71. temp.LPoint.x = poly2Pts[0].x;
  72. temp.LPoint.y = poly2Pts[0].y;
  73. temp.RPoint.x = poly2Pts[poly2Pts.length() - 1].x;
  74. temp.RPoint.y = poly2Pts[poly2Pts.length() - 1].y;
  75. p2.external_circle.circle_edge.push_back(temp);
  76. p2.internal_circle.clear();

  77. vector<AcGePoint2dArray> interPts;
  78. MPolygon::SolveOr(p1, p2, interPts);  // 并集
  79. if (interPts.size() > 0)
  80. {
  81.     for (int i = 0; i < (int)interPts.size(); i++)
  82.     {
  83.         AcGePoint2dArray pts = interPts[i];
  84.         if (pts.length() > 0)
  85.         {
  86.             int numVertices = pts.length();
  87.             AcDbPolyline* pPoly = new AcDbPolyline(numVertices);
  88.             for (int j = 0; j < numVertices; j++)
  89.             {
  90.                 AcGePoint2d pt2d = pts[j];
  91.                 pPoly->addVertexAt(j, pt2d, 0, 0, 0);
  92.             }
  93.             pPoly->setColorIndex(1);
  94.             pPoly->setClosed(TRUE);
  95.             pPoly->setConstantWidth(10);
  96.             AcDbBlockTable* pBlkTbl = NULL;
  97.             acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);
  98.             AcDbBlockTableRecord* pBlkTblRcd = NULL;
  99.             pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
  100.             pBlkTbl->close();
  101.             pBlkTblRcd->appendAcDbEntity(pPoly);
  102.             pBlkTblRcd->close();
  103.             pPoly->close();
  104.         }
  105.     }
  106. }

  107. // 结束计时
  108. end = GetTickCount() - start;
  109. acutPrintf(_T("\n数学法用时: %d 毫秒"), end);
复制代码
多边形叠加分析(差集) 测试
  1. // 创建多段线过滤条件
  2. struct resbuf* filter = acutBuildList(RTDXF0, _T("LWPOLYLINE"), RTNONE);
  3. ads_name ss;
  4. // 提示用户选择二个多边形
  5. acutPrintf(_T("\n请选择二个多边形(闭合多段线):\n"));
  6. int res = acedSSGet(NULL, NULL, NULL, filter, ss);
  7. // 释放缓冲区链表
  8. acutRelRb(filter);

  9. // 计时开始
  10. DWORD start, end;
  11. start = GetTickCount();

  12. // 如果取消了选择或者选择条件不符合
  13. if (res != RTNORM)
  14. {
  15.     acutPrintf(_T("\n没有选择二个多边形(闭合多段线)!"));
  16.     return;
  17. }
  18. // 选择集个数
  19. Adesk::Int32 length;
  20. acedSSLength(ss, &length);
  21. if (length != 2)
  22. {
  23.     acutPrintf(_T("\n必须选择二个多边形(闭合多段线)!"));
  24.     // 释放选择集
  25.     acedSSFree(ss);
  26.     return;
  27. }
  28. // 第一、二个多边形顶点集合,交集顶点集合
  29. AcGePoint3dArray poly1Pts, poly2Pts, interPolyPts;
  30. // 错误状态码
  31. Acad::ErrorStatus es;
  32. // 图元名
  33. ads_name eame1, eame2;
  34. acedSSName(ss, 0, eame1);
  35. acedSSName(ss, 1, eame2);
  36. // 释放选择集
  37. acedSSFree(ss);
  38. // 图元名转换为实体ID
  39. AcDbObjectId obj1Id, obj2Id;
  40. es = acdbGetObjectId(obj1Id, eame1);
  41. es = acdbGetObjectId(obj2Id, eame2);
  42. // 获取多边形顶点,并加入集合
  43. es = GetPolylineVertPts(obj1Id, poly1Pts);
  44. es = GetPolylineVertPts(obj2Id, poly2Pts);

  45. MPolygon p1, p2;
  46. Edge temp;
  47. // 第一个多边形
  48. for (int i = 0; i < poly1Pts.length() - 1; i++)
  49. {
  50.     temp.LPoint.x = poly1Pts[i].x;
  51.     temp.LPoint.y = poly1Pts[i].y;
  52.     temp.RPoint.x = poly1Pts[i + 1].x;
  53.     temp.RPoint.y = poly1Pts[i + 1].y;
  54.     p1.external_circle.circle_edge.push_back(temp);
  55. }
  56. temp.LPoint.x = poly1Pts[0].x;
  57. temp.LPoint.y = poly1Pts[0].y;
  58. temp.RPoint.x = poly1Pts[poly1Pts.length() - 1].x;
  59. temp.RPoint.y = poly1Pts[poly1Pts.length() - 1].y;
  60. p1.external_circle.circle_edge.push_back(temp);
  61. p1.internal_circle.clear();

  62. // 第二个多边形
  63. for (int i = 0; i < poly2Pts.length() - 1; i++)
  64. {
  65.     temp.LPoint.x = poly2Pts[i].x;
  66.     temp.LPoint.y = poly2Pts[i].y;
  67.     temp.RPoint.x = poly2Pts[i + 1].x;
  68.     temp.RPoint.y = poly2Pts[i + 1].y;
  69.     p2.external_circle.circle_edge.push_back(temp);
  70. }
  71. temp.LPoint.x = poly2Pts[0].x;
  72. temp.LPoint.y = poly2Pts[0].y;
  73. temp.RPoint.x = poly2Pts[poly2Pts.length() - 1].x;
  74. temp.RPoint.y = poly2Pts[poly2Pts.length() - 1].y;
  75. p2.external_circle.circle_edge.push_back(temp);
  76. p2.internal_circle.clear();

  77. vector<AcGePoint2dArray> interPts;
  78. MPolygon::SolveSub(p1, p2, interPts);  // 差集
  79. if (interPts.size() > 0)
  80. {
  81.     for (int i = 0; i < (int)interPts.size(); i++)
  82.     {
  83.         AcGePoint2dArray pts = interPts[i];
  84.         if (pts.length() > 0)
  85.         {
  86.             int numVertices = pts.length();
  87.             AcDbPolyline* pPoly = new AcDbPolyline(numVertices);
  88.             for (int j = 0; j < numVertices; j++)
  89.             {
  90.                 AcGePoint2d pt2d = pts[j];
  91.                 pPoly->addVertexAt(j, pt2d, 0, 0, 0);
  92.             }
  93.             pPoly->setColorIndex(1);
  94.             pPoly->setClosed(TRUE);
  95.             pPoly->setConstantWidth(10);
  96.             AcDbBlockTable* pBlkTbl = NULL;
  97.             acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);
  98.             AcDbBlockTableRecord* pBlkTblRcd = NULL;
  99.             pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
  100.             pBlkTbl->close();
  101.             pBlkTblRcd->appendAcDbEntity(pPoly);
  102.             pBlkTblRcd->close();
  103.             pPoly->close();
  104.         }
  105.     }
  106. }

  107. // 结束计时
  108. end = GetTickCount() - start;
  109. acutPrintf(_T("\n数学法用时: %d 毫秒"), end);
交并差所需的类见以下附件PolygonOAUtil.h、PolygonOAUtil.cpp
PolygonOAUtil.h头文件

  1. /// @file 多边形叠加分析(交并差)
  2. /// @date 2021-12-08
  3. /// @version v1.0

  4. #pragma once
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <vector>
  8. using namespace std;

  9. /////////////////////////////////////////////////////////////////
  10. // Point 类 : 实现多边形点的存储,并记录点的性质。
  11. class Point
  12. {
  13. public:
  14.     // 存储多边形顶点的横坐标, 纵坐标
  15.     double x, y;

  16.     // 重构 Point 类的构造函数
  17.     Point(double x = 0, double y = 0) : x(x), y(y) {}

  18.     // 重构类的=运算
  19.     Point& operator=(const Point& b);

  20.     // 重构类的<运算
  21.     bool operator<(const Point& b);

  22.     // 重构类的!=运算
  23.     bool operator!=(const Point b);

  24.     // 重构类的==运算
  25.     bool operator==(const Point b);
  26. };

  27. /////////////////////////////////////////////////////////////////
  28. // Edge 类 : 实现多边形边的存储,并记录边的性质;
  29. class Edge
  30. {
  31. public:
  32.     // 存储简单多边形边的左顶点, 右顶点
  33.     Point LPoint, RPoint;

  34.     // 存储边的奇偶性   奇边 : 1 偶边 : 0
  35.     int odd;

  36.     // 存储变的内外性,即该边是在另一多边形的内部还是外部    内边 : 1 外边: 0 重边 :2
  37.     int inout;

  38.     // 初始化 Edge 类对象的各个成员变量,避免因未初始化而引起的不知名错误
  39.     void init();

  40.     // 重构 Edge 类的构造函数
  41.     Edge() {}

  42.     // 重构 Edge 类的构造函数
  43.     Edge(Point l, Point r) :LPoint(l), RPoint(r) {}

  44.     // 重构类的==运算
  45.     bool operator==(const Edge B);

  46.     // 重构类的!=运算
  47.     bool operator!=(const Edge B);

  48.     // 计算两线段交点
  49.     static double tCross(const Point& p1, const Point& p2);
  50.     static double Cross(const Point& p1, const Point& p2, const Point& p3, const Point& p4);
  51.     static double Area(const Point& p1, const Point& p2, const Point& p3);
  52.     static double fArea(const Point& p1, const Point& p2, const Point& p3);
  53.     static bool Meet(const Point& p1, const Point& p2, const Point& p3, const Point& p4);
  54.     static Point Inter(const Point& p1, const Point& p2, const Point& p3, const Point& p4);
  55.     static double Dot(Point A, Point B);

  56.     // 判断点是否在线段之上
  57.     static bool OnSegment(Point p, Point a1, Point a2);

  58.     // 求两线段交点
  59.     static Point GetCrossPoint(Edge a, Edge b);

  60.     // 实现边的控制台输出,该函数主要用与在最初开发系统时对程序的调试
  61.     void output();
  62. };

  63. /////////////////////////////////////////////////////////////////
  64. // TEdge 类 : 在进行多边形的交并差计算时实现多边形边的存储,起到过度的作用,同时记录边的性质;
  65. class TEdge : public Edge
  66. {
  67. public:
  68.     // 标记边是属于多边形 A、还是多边形 B
  69.     int pgn;

  70.     // 标记边是否已访问过, 初始值为false
  71.     bool visited;

  72.     // 记录边是否为重边
  73.     int repet;

  74.     // 指向连接左、右端点的本输入多边形的邻边的指针
  75.     int lpAdjEg, rpAdjEg;

  76.     // 指向连接左、右端点的另一输入多边形的两邻边的指针
  77.     int lpotherPgnAdjEg[2], rpotherPgnAdjEg[2];

  78.     // 重构TEdge类的构造函数
  79.     TEdge();

  80.     // 重构类的=运算
  81.     TEdge& operator=(const Edge& e);

  82.     // 重构类的==运算
  83.     bool operator==(const TEdge B);

  84.     // 重构类的!=运算
  85.     bool operator!=(const TEdge B);

  86.     // 重构类的==运算
  87.     bool operator==(const Edge B);

  88.     // 重构类的!=运算
  89.     bool operator!=(const Edge B);
  90. };

  91. /////////////////////////////////////////////////////////////////
  92. // Circle 类 : 实现多边形内环与外环的存储,并记录环的性质
  93. class Circle
  94. {
  95. public:
  96.     // 存储环的多条边
  97.     vector<Edge> circle_edge;

  98.     // 用来表示该环是内环还是外环
  99.     int type;  // 好像 type 无作用

  100.     // 重构 Circle 类的构造函数
  101.     Circle();

  102.     // 初始化 Circle 类对象的各个成员变量,避免因未初始化而引起的不知名错误
  103.     void init();

  104.     // 判断点是否在线段之上
  105.     static bool PointAboveSegment(Point p, Edge e);
  106. };

  107. /////////////////////////////////////////////////////////////////
  108. // MPolygon类:实现多边形的存储,并记录多边形的性质。
  109. class MPolygon
  110. {
  111. public:
  112.     // 存储多边形的外环
  113.     Circle external_circle;

  114.     // 存储多边形的内环
  115.     vector<Circle> internal_circle;

  116.     // 重构 MPolygon 类的构造函数
  117.     MPolygon();

  118.     // 初始化 MPolygon 类对象的各个成员变量,避免因未初始化而引起的不知名错误
  119.     void init();

  120.     // 计算位于点p下方的另一多边形边的条数
  121.     int calc(Point p, const MPolygon B);

  122.     // 判断另一多边形中是否有边e
  123.     bool finde(Edge e, const MPolygon B);

  124.     // 判断内边还是外边
  125.     void getinout(const MPolygon B);

  126.     // 判断奇边还是偶边
  127.     void getodd();

  128.     // 得到简单边,作用是当前多边形的边与第二个多边形的边存在的交点插入当前多边形中
  129.     // 并重构当前多边形的边
  130.     void getSimpleEdge(const MPolygon B);

  131.     // 计算两个多边形交集
  132.     static int SolveAnd(MPolygon p1, MPolygon p2, vector<AcGePoint2dArray>& interPts);

  133.     // 计算两个多边形并集
  134.     static int SolveOr(MPolygon p1, MPolygon p2, vector<AcGePoint2dArray>& interPts);

  135.     // 计算两个多边形差集
  136.     static int SolveSub(MPolygon p1, MPolygon p2, vector<AcGePoint2dArray>& interPts);
  137. };
http://bbs.mjtd.com/forum.php?mod=attachment&aid=MTE3MTY0fDRkNmY5YTQzZjg4MmJhMGUwOWQ2MTk3MGI0OWVlMTE0fDE3MTQ2Mzc3NzE%3D&request=yes&_f=.rar


本帖子中包含更多资源

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

x
发表于 2021-12-13 15:53 | 显示全部楼层
把每个多边形转为面域, 然后用面域的ARX的布尔函数求得也是可以的
发表于 2021-12-14 08:24 | 显示全部楼层
大佬和顾老师的ID很像啊
发表于 2021-12-14 10:12 | 显示全部楼层
来支持楼主一下,感谢分享c+源码
发表于 2022-2-12 22:58 | 显示全部楼层

来支持楼主一下,感谢分享c+源码
发表于 2022-12-2 11:44 | 显示全部楼层
g大,CAD用面域求差集好像有bug
发表于 2022-12-3 08:38 | 显示全部楼层
g大,测试了循环卡,CAD就崩了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 16:16 , Processed in 0.378425 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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