@@ -129,7 +129,7 @@ static void build_arrangement_for_triangles(
129129
130130/* *
131131 * Extract triangular faces from the arrangement.
132- * Skips non-triangular faces and faces with vertices not in original point set .
132+ * Expects that all bounded faces are triangles and will throw if not .
133133 */
134134static std::vector<std::tuple<int , int , int >>
135135extract_triangular_faces (
@@ -150,14 +150,13 @@ extract_triangular_faces(
150150 Halfedge_const_handle start = e;
151151
152152 do {
153- if (deg > 3 ) break ; // Early out: not a triangle
153+ if (deg > 3 ) { throw std::runtime_error ( " Bound face is not triangular. " );} ; // Early out: not a triangle
154154
155155 const Point &pv = e->source ()->point ();
156156 auto it = idx_of.find (pv);
157157 if (it == idx_of.end ()) {
158158 // Vertex not in original points (likely intersection) - skip face
159- deg = 999 ;
160- break ;
159+ throw std::runtime_error (" Face vertex not found in original points list." );
161160 }
162161 if (deg < 3 ) idxs[deg] = it->second ;
163162 ++deg;
@@ -186,13 +185,11 @@ extract_triangular_faces(
186185 * convex hull. Otherwise, all edges should appear exactly twice. The indices
187186 * will be sorted in each triangle, and the list of triangles will also be
188187 * sorted.
188+ * Expects that all bounded faces are triangles and will throw if not.
189189 */
190190std::vector<std::tuple<int , int , int >>
191191compute_triangles (const std::vector<Point> &points,
192192 const std::vector<std::tuple<int , int >> &edges) {
193- std::cout << " Computing triangles from " << points.size () << " points and "
194- << edges.size () << " edges." << std::endl;
195-
196193 // Step 1: Build point-to-index mapping
197194 std::map<Point, int , LessPointXY> idx_of;
198195 for (int i = 0 ; i < static_cast <int >(points.size ()); ++i) {
@@ -208,11 +205,6 @@ compute_triangles(const std::vector<Point> &points,
208205 std::vector<std::tuple<int , int , int >> triangles =
209206 extract_triangular_faces (arrangement, idx_of);
210207
211- // Step 4: Deduplicate and sort
212- std::sort (triangles.begin (), triangles.end ());
213- triangles.erase (std::unique (triangles.begin (), triangles.end ()),
214- triangles.end ());
215-
216208 return triangles;
217209}
218210
0 commit comments