pythoncdt 2.0.2__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/CMakeLists.txt +1 -1
  2. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/conanfile.py +1 -1
  3. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/CDTUtils.h +12 -13
  4. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/Triangulation.h +44 -0
  5. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/Triangulation.hpp +73 -16
  6. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/src/CDT.cpp +29 -0
  7. pythoncdt-2.1.0/CDT/visualizer/data/issue-235.txt +17 -0
  8. pythoncdt-2.1.0/CDT/visualizer/data/issue-237.txt +17 -0
  9. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/main.cpp +25 -4
  10. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/PKG-INFO +1 -1
  11. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/src/cdt_bindings.cpp +9 -2
  12. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/src/pythoncdt/_core.pyi +6 -0
  13. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/tests/stubtest-allowlist.txt +1 -0
  14. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/tests/test_bindings.py +3 -2
  15. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.clang-format +0 -0
  16. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.github/dependabot.yml +0 -0
  17. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.github/release-drafter.yml +0 -0
  18. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.github/workflows/ci.yml +0 -0
  19. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.github/workflows/release-drafter.yml +0 -0
  20. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.github/workflows/wheels.yml +0 -0
  21. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.gitignore +0 -0
  22. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.gitmodules +0 -0
  23. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/.pre-commit-config.yaml +0 -0
  24. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.clang-format +0 -0
  25. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.github/workflows/ci_builds.yml +0 -0
  26. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.github/workflows/documentation.yml +0 -0
  27. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.gitignore +0 -0
  28. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.gitmodules +0 -0
  29. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/.mailmap +0 -0
  30. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/LICENSE +0 -0
  31. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/LICENSE-LLVM.txt +0 -0
  32. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/LICENSE-predicates.txt +0 -0
  33. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/conan_basic_setup.cmake +0 -0
  34. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/extras/VerifyTopology.h +0 -0
  35. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/CDT.h +0 -0
  36. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/CDT.hpp +0 -0
  37. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/CDTUtils.hpp +0 -0
  38. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/KDTree.h +0 -0
  39. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/LocatorKDTree.h +0 -0
  40. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/portable_nth_element.hpp +0 -0
  41. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/predicates.h +0 -0
  42. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/CDT/include/remove_at.hpp +0 -0
  43. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/LICENSE +0 -0
  44. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/CMakeLists.txt +0 -0
  45. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/LICENSE +0 -0
  46. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Capital A.txt +0 -0
  47. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Constrained Sweden.txt +0 -0
  48. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Hanging.txt +0 -0
  49. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Hanging2.txt +0 -0
  50. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/HangingIntersection.txt +0 -0
  51. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/LakeSuperior.txt +0 -0
  52. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Letter u.txt +0 -0
  53. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/OnEdge.txt +0 -0
  54. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/OnEdge2.txt +0 -0
  55. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Orange County.txt +0 -0
  56. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/ProblematicCase1.txt +0 -0
  57. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Sweden with constraints.txt +0 -0
  58. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Sweden with duplicate points.txt +0 -0
  59. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/Sweden.txt +0 -0
  60. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/cdt.txt +0 -0
  61. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/cdt_duplicates.txt +0 -0
  62. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/corner cases.txt +0 -0
  63. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/crossing-edges.txt +0 -0
  64. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/ditch.txt +0 -0
  65. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/duplicates.txt +0 -0
  66. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/gh_issue.txt +0 -0
  67. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/guitar no box.txt +0 -0
  68. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/guitar.txt +0 -0
  69. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/island.txt +0 -0
  70. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-230.txt +0 -0
  71. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-42-full-boundary-overlap-2.txt +0 -0
  72. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-42-full-boundary-overlap.txt +0 -0
  73. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-42-hole-overlaps-bondary.txt +0 -0
  74. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-42-multiple-boundary-overlaps-conform-to-edge.txt +0 -0
  75. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-42-multiple-boundary-overlaps.txt +0 -0
  76. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/issue-65-wrong-edges.txt +0 -0
  77. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/kidney.txt +0 -0
  78. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/overlapping constraints.txt +0 -0
  79. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/overlapping constraints2.txt +0 -0
  80. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/points_on_constraint_edge.txt +0 -0
  81. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/regression_issue_38_wrong_hull.txt +0 -0
  82. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/regression_issue_38_wrong_hull_small.txt +0 -0
  83. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/square with crack.txt +0 -0
  84. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CDT/visualizer/data/unit square.txt +0 -0
  85. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/CMakeLists.txt +0 -0
  86. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/LICENSE +0 -0
  87. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/README.md +0 -0
  88. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/benchmark_gil_release.py +0 -0
  89. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/benchmark_list_vs_array_access.py +0 -0
  90. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/pyproject.toml +0 -0
  91. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/src/pythoncdt/__init__.py +0 -0
  92. {pythoncdt-2.0.2 → pythoncdt-2.1.0}/src/pythoncdt/py.typed +0 -0
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4...4.0)
2
2
 
3
3
  project(
4
4
  "CDT"
5
- VERSION 2.0.1
5
+ VERSION 2.1.0
6
6
  DESCRIPTION
7
7
  "C++ library for constrained Delaunay triangulation"
8
8
  HOMEPAGE_URL "https://github.com/artem-ogre/CDT"
@@ -10,7 +10,7 @@ from conan.tools.env import Environment
10
10
 
11
11
  class CDTConan(ConanFile):
12
12
  name = "cdt"
13
- version = "2.0.1"
13
+ version = "2.1.0"
14
14
  license = "MPL-2.0 AND BSD-3-Clause AND Apache-2.0 WITH LLVM-exception"
15
15
  url = "https://github.com/artem-ogre/CDT"
16
16
  description = "Numerically robust C++ implementation of constrained Delaunay triangulation (CDT)"
@@ -97,6 +97,7 @@ using std::unordered_set;
97
97
  #include <boost/functional/hash.hpp>
98
98
  #include <boost/lexical_cast.hpp>
99
99
  #include <boost/tuple/tuple.hpp>
100
+ #include <boost/tuple/tuple_comparison.hpp>
100
101
  #include <boost/unordered_map.hpp>
101
102
  #include <boost/unordered_set.hpp>
102
103
  namespace CDT
@@ -117,22 +118,20 @@ std::string to_string(const T& value)
117
118
  } // namespace CDT
118
119
  #endif
119
120
 
120
- /// Ensure precise floating-point math without contraction to fused multiply-add operations.
121
+ /// Ensure precise floating-point math without contraction to fused multiply-add
122
+ /// operations.
121
123
  #ifdef _MSC_VER
122
- #define CDT_ENSURE_PRECISE_MATH \
123
- __pragma(float_control(push)) \
124
- __pragma(float_control(precise, on)) \
125
- __pragma(fp_contract(off))
124
+ #define CDT_ENSURE_PRECISE_MATH \
125
+ __pragma(float_control(push)) __pragma(float_control(precise, on)) \
126
+ __pragma(fp_contract(off))
126
127
  #elif defined(__clang__)
127
- #define CDT_ENSURE_PRECISE_MATH \
128
- _Pragma("float_control(push)") \
129
- _Pragma("float_control(precise, on)") \
130
- _Pragma("clang fp contract(off)")
128
+ #define CDT_ENSURE_PRECISE_MATH \
129
+ _Pragma("float_control(push)") _Pragma("float_control(precise, on)") \
130
+ _Pragma("clang fp contract(off)")
131
131
  #elif defined(__GNUC__)
132
- #define CDT_ENSURE_PRECISE_MATH \
133
- _Pragma("GCC push_options") \
134
- _Pragma("GCC optimize(\"no-fast-math\")") \
135
- _Pragma("GCC optimize(\"fp-contract=off\")")
132
+ #define CDT_ENSURE_PRECISE_MATH \
133
+ _Pragma("GCC push_options") _Pragma("GCC optimize(\"no-fast-math\")") \
134
+ _Pragma("GCC optimize(\"fp-contract=off\")")
136
135
  #else
137
136
  #define CDT_ENSURE_PRECISE_MATH _Pragma("STDC FP_CONTRACT OFF")
138
137
  #endif
@@ -91,6 +91,32 @@ struct CDT_EXPORT RefinementCriterion
91
91
  };
92
92
  };
93
93
 
94
+ /**
95
+ * Enum of bad triangles refinement orders
96
+ */
97
+ struct CDT_EXPORT RefinementOrder
98
+ {
99
+ /**
100
+ * The Enum itself
101
+ * @note needed to pre c++11 compilers that don't support 'class enum'
102
+ */
103
+ enum Enum
104
+ {
105
+ FIFO, ///< in the order found
106
+ WorstFirst, ///< worst first
107
+ };
108
+ };
109
+
110
+ /// FIFO queue with `top()` like `std::priority_queue`
111
+ template <typename T>
112
+ struct FifoQueue : std::queue<T>
113
+ {
114
+ const T& top() const
115
+ {
116
+ return this->front();
117
+ }
118
+ };
119
+
94
120
  /**
95
121
  * Counts of the refinements that Triangulation::refineTriangles was not able
96
122
  * to perform
@@ -764,9 +790,24 @@ public:
764
790
  * @param minEdgeLength don't split edges/triangles already this short:
765
791
  * acute corners and close fixed edges can otherwise force ever-shrinking
766
792
  * splits. 0 never gives up.
793
+ * @param refinementOrder bad triangles refinement order
767
794
  * @return refinements that could not be performed
768
795
  * @throw FinalizedError if triangulation was already finalized
769
796
  */
797
+ Unrefined refineTriangles(
798
+ VertInd maxVerticesToInsert,
799
+ RefinementCriterion::Enum refinementCriterion =
800
+ RefinementCriterion::SmallestAngle,
801
+ T refinementThreshold = degToRad(T(20)),
802
+ TriIndUSet* toEraseOrNull = NULL,
803
+ T minEdgeLength = T(1e-6),
804
+ RefinementOrder::Enum refinementOrder = RefinementOrder::FIFO);
805
+ /**
806
+ * #refineTriangles with a custom queue of bad triangles
807
+ * @tparam TQueue FifoQueue or `std::priority_queue` of
808
+ * `tuple<T, TriInd, VerticesArr3>`: badness, triangle, its vertices
809
+ */
810
+ template <typename TQueue>
770
811
  Unrefined refineTriangles(
771
812
  VertInd maxVerticesToInsert,
772
813
  RefinementCriterion::Enum refinementCriterion =
@@ -1056,6 +1097,9 @@ private:
1056
1097
  const Triangle& tri,
1057
1098
  RefinementCriterion::Enum refinementCriterion,
1058
1099
  T refinementThreshold) const;
1100
+ T triangleBadness(
1101
+ const Triangle& tri,
1102
+ RefinementCriterion::Enum refinementCriterion) const;
1059
1103
  /// Check if the triangle's smallest angle is enclosed by two fixed edges:
1060
1104
  /// such an angle comes from the input and can not be made any larger
1061
1105
  bool isSmallestAngleFixed(const Triangle& tri) const;
@@ -1490,6 +1490,19 @@ bool Triangulation<T, TNearPointLocator>::isRefinementNeeded(
1490
1490
  return false;
1491
1491
  }
1492
1492
 
1493
+ template <typename T, typename TNearPointLocator>
1494
+ T Triangulation<T, TNearPointLocator>::triangleBadness(
1495
+ const Triangle& tri,
1496
+ const RefinementCriterion::Enum refinementCriterion) const
1497
+ {
1498
+ const V2d<T>& a = vertices[tri.vertices[0]];
1499
+ const V2d<T>& b = vertices[tri.vertices[1]];
1500
+ const V2d<T>& c = vertices[tri.vertices[2]];
1501
+ return refinementCriterion == RefinementCriterion::SmallestAngle
1502
+ ? -smallestAngle(a, b, c)
1503
+ : area(a, b, c);
1504
+ }
1505
+
1493
1506
  template <typename T, typename TNearPointLocator>
1494
1507
  bool Triangulation<T, TNearPointLocator>::isSmallestAngleFixed(
1495
1508
  const Triangle& tri) const
@@ -1681,9 +1694,7 @@ TriIndVec Triangulation<T, TNearPointLocator>::resolveEncroachedEdges(
1681
1694
  const Edge triEdge(t.vertices[i], t.vertices[cw(i)]);
1682
1695
  if(fixedEdges.find(triEdge) == fixedEdges.end())
1683
1696
  continue;
1684
- if(isEdgeEncroached(triEdge) ||
1685
- (circumcenterOrNull &&
1686
- isEdgeEncroachedBy(triEdge, *circumcenterOrNull)))
1697
+ if(isEdgeEncroached(triEdge))
1687
1698
  {
1688
1699
  encroachedEdges.push(triEdge);
1689
1700
  }
@@ -2647,6 +2658,38 @@ void Triangulation<T, TNearPointLocator>::tryInitNearestPointLocator()
2647
2658
  }
2648
2659
 
2649
2660
  template <typename T, typename TNearPointLocator>
2661
+ Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2662
+ const VertInd maxVerticesToInsert,
2663
+ const RefinementCriterion::Enum refinementCriterion,
2664
+ const T refinementThreshold,
2665
+ TriIndUSet* const toEraseOrNull,
2666
+ const T minEdgeLength,
2667
+ const RefinementOrder::Enum refinementOrder)
2668
+ {
2669
+ switch(refinementOrder)
2670
+ {
2671
+ case RefinementOrder::FIFO:
2672
+ return refineTriangles<FifoQueue<tuple<T, TriInd, VerticesArr3> > >(
2673
+ maxVerticesToInsert,
2674
+ refinementCriterion,
2675
+ refinementThreshold,
2676
+ toEraseOrNull,
2677
+ minEdgeLength);
2678
+ case RefinementOrder::WorstFirst:
2679
+ return refineTriangles<
2680
+ std::priority_queue<tuple<T, TriInd, VerticesArr3> > >(
2681
+ maxVerticesToInsert,
2682
+ refinementCriterion,
2683
+ refinementThreshold,
2684
+ toEraseOrNull,
2685
+ minEdgeLength);
2686
+ }
2687
+ assert(false); // unreachable code
2688
+ return Unrefined();
2689
+ }
2690
+
2691
+ template <typename T, typename TNearPointLocator>
2692
+ template <typename TQueue>
2650
2693
  Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2651
2694
  const VertInd maxVerticesToInsert,
2652
2695
  const RefinementCriterion::Enum refinementCriterion,
@@ -2676,7 +2719,8 @@ Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2676
2719
  unrefined);
2677
2720
 
2678
2721
  // refine triangulation by inserting bad-quality triangles' circumcenters
2679
- TriIndQueue badTriangles;
2722
+ // keep vertices to detect triangles modified after enqueueing
2723
+ TQueue badTriangles;
2680
2724
  for(TriInd iT(0), n(triangles.size()); iT < n; ++iT)
2681
2725
  {
2682
2726
  const Triangle& t = triangles[iT];
@@ -2684,29 +2728,32 @@ Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2684
2728
  !(toEraseOrNull && toEraseOrNull->count(iT)) &&
2685
2729
  isRefinementNeeded(t, refinementCriterion, refinementThreshold))
2686
2730
  {
2687
- badTriangles.push(iT);
2731
+ badTriangles.push(make_tuple(
2732
+ triangleBadness(t, refinementCriterion), iT, t.vertices));
2688
2733
  }
2689
2734
  }
2690
2735
 
2691
2736
  while(!badTriangles.empty() && remainingVertexBudget > 0)
2692
2737
  {
2693
- const TriInd iT = badTriangles.front();
2738
+ const TriInd iT = get<1>(badTriangles.top());
2739
+ const VerticesArr3 vv = get<2>(badTriangles.top());
2740
+ const Triangle& t = triangles[iT];
2694
2741
  badTriangles.pop();
2695
2742
  if(toEraseOrNull && toEraseOrNull->count(iT))
2696
2743
  continue;
2697
- if(!isRefinementNeeded(
2698
- triangles[iT], refinementCriterion, refinementThreshold) ||
2744
+ if(vv != t.vertices)
2745
+ continue; // skip triangle that got modified since put in queue
2746
+ if(!isRefinementNeeded(t, refinementCriterion, refinementThreshold) ||
2699
2747
  (refinementCriterion == RefinementCriterion::SmallestAngle &&
2700
- isSmallestAngleFixed(triangles[iT])))
2748
+ isSmallestAngleFixed(t)))
2701
2749
  {
2702
2750
  // fixed-edge sharp angle is impossible to refine
2703
2751
  continue;
2704
2752
  }
2705
2753
  // copy: resolveEncroachedEdges below can re-allocate 'triangles'
2706
- const VerticesArr3 badTVerts = triangles[iT].vertices;
2707
- const V2d<T>& v0 = vertices[badTVerts[0]];
2708
- const V2d<T>& v1 = vertices[badTVerts[1]];
2709
- const V2d<T>& v2 = vertices[badTVerts[2]];
2754
+ const V2d<T>& v0 = vertices[vv[0]];
2755
+ const V2d<T>& v1 = vertices[vv[1]];
2756
+ const V2d<T>& v2 = vertices[vv[2]];
2710
2757
  const T shortestEdge = std::min(
2711
2758
  distance(v0, v1), std::min(distance(v1, v2), distance(v2, v0)));
2712
2759
  if(shortestEdge <= minEdgeLength)
@@ -2749,9 +2796,16 @@ Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2749
2796
  typedef TriIndVec::const_iterator It;
2750
2797
  for(It it = badTris.begin(); it != badTris.end(); ++it)
2751
2798
  {
2752
- badTriangles.push(*it);
2799
+ const Triangle& bad = triangles[*it];
2800
+ badTriangles.push(make_tuple(
2801
+ triangleBadness(bad, refinementCriterion),
2802
+ *it,
2803
+ bad.vertices));
2753
2804
  }
2754
- badTriangles.push(iT);
2805
+ badTriangles.push(make_tuple(
2806
+ triangleBadness(triangles[iT], refinementCriterion),
2807
+ iT,
2808
+ triangles[iT].vertices));
2755
2809
  continue;
2756
2810
  }
2757
2811
  // splitting was given up on: inserting would encroach anyway
@@ -2810,7 +2864,10 @@ Unrefined Triangulation<T, TNearPointLocator>::refineTriangles(
2810
2864
  !touchesSuperTriangle(t) &&
2811
2865
  isRefinementNeeded(t, refinementCriterion, refinementThreshold))
2812
2866
  {
2813
- badTriangles.push(currTri);
2867
+ badTriangles.push(make_tuple(
2868
+ triangleBadness(t, refinementCriterion),
2869
+ currTri,
2870
+ t.vertices));
2814
2871
  }
2815
2872
  currTri = t.next(iVert).first;
2816
2873
  } while(currTri != start);
@@ -30,6 +30,35 @@ template struct CDT_EXPORT Box2d<double>;
30
30
  template class CDT_EXPORT Triangulation<float>;
31
31
  template class CDT_EXPORT Triangulation<double>;
32
32
 
33
+ template CDT_EXPORT Unrefined Triangulation<float>::refineTriangles<
34
+ FifoQueue<tuple<float, TriInd, VerticesArr3> > >(
35
+ VertInd,
36
+ RefinementCriterion::Enum,
37
+ float,
38
+ TriIndUSet*,
39
+ float);
40
+ template CDT_EXPORT Unrefined Triangulation<double>::refineTriangles<
41
+ FifoQueue<tuple<double, TriInd, VerticesArr3> > >(
42
+ VertInd,
43
+ RefinementCriterion::Enum,
44
+ double,
45
+ TriIndUSet*,
46
+ double);
47
+ template CDT_EXPORT Unrefined Triangulation<float>::refineTriangles<
48
+ std::priority_queue<tuple<float, TriInd, VerticesArr3> > >(
49
+ VertInd,
50
+ RefinementCriterion::Enum,
51
+ float,
52
+ TriIndUSet*,
53
+ float);
54
+ template CDT_EXPORT Unrefined Triangulation<double>::refineTriangles<
55
+ std::priority_queue<tuple<double, TriInd, VerticesArr3> > >(
56
+ VertInd,
57
+ RefinementCriterion::Enum,
58
+ double,
59
+ TriIndUSet*,
60
+ double);
61
+
33
62
  template CDT_EXPORT DuplicatesInfo
34
63
  RemoveDuplicates<float>(std::vector<V2d<float> >&);
35
64
  template CDT_EXPORT DuplicatesInfo
@@ -0,0 +1,17 @@
1
+ 8 8
2
+ 0 0
3
+ 10 0
4
+ 10 10
5
+ 0 10
6
+ 4 4
7
+ 6 4
8
+ 6 6
9
+ 4 6
10
+ 0 1
11
+ 1 2
12
+ 2 3
13
+ 3 0
14
+ 4 5
15
+ 5 6
16
+ 6 7
17
+ 7 4
@@ -0,0 +1,17 @@
1
+ 8 8
2
+ -1 -3
3
+ 10 0
4
+ 10 13
5
+ 0 10
6
+ 4 4
7
+ 6 4
8
+ 6 6
9
+ 4 6
10
+ 0 1
11
+ 1 2
12
+ 2 3
13
+ 3 0
14
+ 4 7
15
+ 7 6
16
+ 6 5
17
+ 5 4
@@ -157,6 +157,7 @@ public:
157
157
  , m_minRefinementEdgeLength(1e-6)
158
158
  , m_refinementCriterion(CDT::RefinementCriterion::SmallestAngle)
159
159
  , m_refinementThreshold(20.0)
160
+ , m_refinementOrder(CDT::RefinementOrder::FIFO)
160
161
  , m_vertexInsertionOrder(CDT::VertexInsertionOrder::Auto)
161
162
  , m_intersectingEdgesStrategy(
162
163
  CDT::IntersectingConstraintEdges::TryResolve)
@@ -281,6 +282,13 @@ public slots:
281
282
  updateCDT();
282
283
  }
283
284
 
285
+ void setRefinementOrder(int index)
286
+ {
287
+ m_refinementOrder = index == 0 ? CDT::RefinementOrder::FIFO
288
+ : CDT::RefinementOrder::WorstFirst;
289
+ updateCDT();
290
+ }
291
+
284
292
  void hidePoints(int isHidePoints)
285
293
  {
286
294
  m_isHidePoints = (isHidePoints != 0);
@@ -535,7 +543,8 @@ private:
535
543
  m_refinementCriterion,
536
544
  threshold,
537
545
  &toErase,
538
- m_minRefinementEdgeLength);
546
+ m_minRefinementEdgeLength,
547
+ m_refinementOrder);
539
548
  // store positions: finalizing invalidates the indices
540
549
  storeUnrefined(m_cdt.findEncroachedFixedEdges());
541
550
  }
@@ -877,6 +886,7 @@ private:
877
886
  CoordType m_minRefinementEdgeLength;
878
887
  CDT::RefinementCriterion::Enum m_refinementCriterion;
879
888
  CoordType m_refinementThreshold; // degrees if SmallestAngle, else raw area
889
+ CDT::RefinementOrder::Enum m_refinementOrder;
880
890
  CDT::VertexInsertionOrder::Enum m_vertexInsertionOrder;
881
891
  CDT::IntersectingConstraintEdges::Enum m_intersectingEdgesStrategy;
882
892
  CoordType m_minDistToConstraintEdge;
@@ -983,9 +993,9 @@ public:
983
993
  new QLabel("intersectingEdgesStrategy"), isecStrategy);
984
994
  triangulationConfig->addRow(
985
995
  new QLabel("minDistToConstraintEdge"), distTolerance);
986
- triangulationConfig->addRow(triType);
987
- triangulationConfig->addRow(finalizeWith);
988
- triangulationConfig->addRow(fixDupes);
996
+ triangulationConfig->addRow(new QLabel("triangulation"), triType);
997
+ triangulationConfig->addRow(new QLabel("finalize"), finalizeWith);
998
+ triangulationConfig->addRow(new QLabel("duplicates"), fixDupes);
989
999
  QGroupBox* triOptGroup = new QGroupBox("Triangulation");
990
1000
  triOptGroup->setLayout(triangulationConfig);
991
1001
 
@@ -1025,6 +1035,15 @@ public:
1025
1035
  m_cdtWidget,
1026
1036
  SLOT(setRefinementCriterion(int)));
1027
1037
 
1038
+ QComboBox* refinementOrder = new QComboBox;
1039
+ refinementOrder->addItem("FIFO");
1040
+ refinementOrder->addItem("worst first");
1041
+ connect(
1042
+ refinementOrder,
1043
+ SIGNAL(currentIndexChanged(int)),
1044
+ m_cdtWidget,
1045
+ SLOT(setRefinementOrder(int)));
1046
+
1028
1047
  QDoubleSpinBox* refinementThreshold = new QDoubleSpinBox;
1029
1048
  refinementThreshold->setDecimals(6);
1030
1049
  refinementThreshold->setRange(0.0, 1000000.0);
@@ -1063,6 +1082,8 @@ public:
1063
1082
  new QLabel(tr("Refinement points")), refinementSpinbox);
1064
1083
  limitsLayout->addRow(
1065
1084
  new QLabel(tr("Refinement criterion")), refinementCriterion);
1085
+ limitsLayout->addRow(
1086
+ new QLabel(tr("Refinement order")), refinementOrder);
1066
1087
  limitsLayout->addRow(
1067
1088
  new QLabel(tr("Refinement threshold")), refinementThreshold);
1068
1089
  limitsLayout->addRow(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythoncdt
3
- Version: 2.0.2
3
+ Version: 2.1.0
4
4
  Summary: Python bindings for CDT: constrained Delaunay triangulation
5
5
  Keywords: cdt,computational-geometry,conforming,constrained,constrained-delaunay-triangulation,delaunay,delaunay-triangulation,fast,refinement,robust,triangle,triangulation
6
6
  Author: Artem Amirkhanov
@@ -214,6 +214,10 @@ PYBIND11_MODULE(_core, m, py::mod_gil_not_used())
214
214
  .value("SMALLEST_ANGLE", CDT::RefinementCriterion::SmallestAngle)
215
215
  .value("LARGEST_AREA", CDT::RefinementCriterion::LargestArea);
216
216
 
217
+ py::enum_<CDT::RefinementOrder::Enum>(m, "RefinementOrder")
218
+ .value("FIFO", CDT::RefinementOrder::FIFO)
219
+ .value("WORST_FIRST", CDT::RefinementOrder::WorstFirst);
220
+
217
221
  py::class_<CDT::Unrefined>(m, "Unrefined")
218
222
  .def_readonly(
219
223
  "short_edge_triangles", &CDT::Unrefined::shortEdgeTriangles)
@@ -440,7 +444,8 @@ PYBIND11_MODULE(_core, m, py::mod_gil_not_used())
440
444
  CDT::RefinementCriterion::Enum refinement_criterion,
441
445
  coord_t refinement_threshold,
442
446
  py::object to_erase,
443
- coord_t min_edge_length) {
447
+ coord_t min_edge_length,
448
+ CDT::RefinementOrder::Enum refinement_order) {
444
449
  const bool has_to_erase = !to_erase.is_none();
445
450
  if (has_to_erase && !py::isinstance<py::set>(to_erase))
446
451
  throw py::type_error("to_erase must be a set or None!");
@@ -455,7 +460,8 @@ PYBIND11_MODULE(_core, m, py::mod_gil_not_used())
455
460
  refinement_criterion,
456
461
  refinement_threshold,
457
462
  has_to_erase ? &triangles_to_erase : NULL,
458
- min_edge_length);
463
+ min_edge_length,
464
+ refinement_order);
459
465
  }
460
466
  if (has_to_erase)
461
467
  {
@@ -472,6 +478,7 @@ PYBIND11_MODULE(_core, m, py::mod_gil_not_used())
472
478
  py::arg("refinement_threshold") = CDT::degToRad(coord_t(20)),
473
479
  py::arg("to_erase") = py::none(),
474
480
  py::arg("min_edge_length") = coord_t(1e-6),
481
+ py::arg("refinement_order") = CDT::RefinementOrder::FIFO,
475
482
  "Triangles from `to_erase` are not refined; the triangles that "
476
483
  "replace them are added to it in place.")
477
484
  .def("find_encroached_fixed_edges", [](Triangulation& t) {
@@ -36,6 +36,11 @@ class RefinementCriterion(_Enum):
36
36
  LARGEST_AREA: ClassVar[RefinementCriterion]
37
37
  __members__: ClassVar[dict[str, RefinementCriterion]]
38
38
 
39
+ class RefinementOrder(_Enum):
40
+ FIFO: ClassVar[RefinementOrder]
41
+ WORST_FIRST: ClassVar[RefinementOrder]
42
+ __members__: ClassVar[dict[str, RefinementOrder]]
43
+
39
44
  class Unrefined:
40
45
  @property
41
46
  def short_edge_triangles(self) -> int: ...
@@ -131,6 +136,7 @@ class Triangulation:
131
136
  refinement_threshold: float = ...,
132
137
  to_erase: set[int] | None = None,
133
138
  min_edge_length: float = ...,
139
+ refinement_order: RefinementOrder = ...,
134
140
  ) -> Unrefined: ...
135
141
  def find_unrefined_triangles(
136
142
  self,
@@ -2,6 +2,7 @@
2
2
  pythoncdt._core.Edge
3
3
  pythoncdt._core.IntersectingConstraintEdges
4
4
  pythoncdt._core.RefinementCriterion
5
+ pythoncdt._core.RefinementOrder
5
6
  pythoncdt._core.Triangle
6
7
  pythoncdt._core.Triangulation
7
8
  pythoncdt._core.Unrefined
@@ -211,7 +211,8 @@ def triangulation_with_sharp_input_corner() -> cdt.Triangulation:
211
211
  (cdt.RefinementCriterion.LARGEST_AREA, 2.0, lambda t, threshold: max(triangle_areas(t)) <= threshold),
212
212
  ],
213
213
  )
214
- def test_refine_triangles_fulfills_criterion(criterion, threshold, is_criterion_fulfilled) -> None:
214
+ @pytest.mark.parametrize("order", [cdt.RefinementOrder.FIFO, cdt.RefinementOrder.WORST_FIRST])
215
+ def test_refine_triangles_fulfills_criterion(criterion, threshold, is_criterion_fulfilled, order) -> None:
215
216
  vv, ee = read_input_file(DATA_DIR / "Capital A.txt")
216
217
  t = cdt.Triangulation(cdt.VertexInsertionOrder.AS_PROVIDED, cdt.IntersectingConstraintEdges.NOT_ALLOWED, 0.0)
217
218
  t.insert_vertices(vv)
@@ -219,7 +220,7 @@ def test_refine_triangles_fulfills_criterion(criterion, threshold, is_criterion_
219
220
 
220
221
  to_erase = t.collect_outer_triangles_and_holes()
221
222
  assert to_erase == t.collect_outer_triangles_and_holes(), "Collecting triangles must not change the triangulation"
222
- unrefined = t.refine_triangles(1000, criterion, threshold, to_erase)
223
+ unrefined = t.refine_triangles(1000, criterion, threshold, to_erase, refinement_order=order)
223
224
  gave_up = [
224
225
  unrefined.short_edge_triangles,
225
226
  unrefined.circumcenter_outside,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes