Skip to content

Commit 0f86fa6

Browse files
committed
clean up in the cross product alternatives
1 parent c63c2a2 commit 0f86fa6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

Surface_mesh_simplification/include/CGAL/Cartesian/CrossProduct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace CGAL {
5252
return a*b - c*d;
5353
}
5454

55+
5556
} // namespace CGAL
5657

5758
#endif // CGAL_CARTESIAN_CROSSPRODUCT_H //

Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/internal/Lindstrom_Turk_core.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ private :
152152
}
153153
#endif
154154

155-
static Vector SL_cross_product(const Vector& a, const Vector& b)
155+
// balanced solution based on abusing the fact that here we expect u and v to have similar coordinates
156+
static Vector robust_cross_product(const Vector& a, const Vector& b)
156157
{
157158
const FT ax=a.x(), ay=a.y(), az=a.z();
158159
const FT bx=b.x(), by=b.y(), bz=b.z();
@@ -184,9 +185,10 @@ private :
184185
exv.exact();
185186
return to_approx(exv);
186187
}
187-
#endif
188188

189-
static Vector X_product(const Vector& u, const Vector& v)
189+
190+
191+
static Vector experimental_cross_product(const Vector& u, const Vector& v)
190192
{
191193
#if 0
192194
// this can create large errors and spiky meshes for kernels with inexact constructions
@@ -201,18 +203,18 @@ private :
201203
return { diff_of_products(u.y(), v.z(), u.z(), v.y()),
202204
diff_of_products(u.z(), v.x(), u.x(), v.z()),
203205
diff_of_products(u.x(), v.y(), u.y(), v.x()) };
204-
#elif 1
205-
// balanced solution based on abusing the fact that here we expect u and v to have similar coordinates
206-
return SL_cross_product(u, v);
207206
#elif 0
208207
// obviously too slow
209208
return exact_cross_product(u, v);
210209
#endif
211210
}
212211

212+
#endif
213+
214+
213215
static Vector point_cross_product(const Point& a, const Point& b)
214216
{
215-
return X_product(a-ORIGIN, b-ORIGIN);
217+
return robust_cross_product(a-ORIGIN, b-ORIGIN);
216218
}
217219

218220
// This is the (uX)(Xu) product described in the Lindstrom-Turk paper
@@ -334,7 +336,7 @@ extract_triangle_data()
334336
Vector v01 = p1 - p0;
335337
Vector v02 = p2 - p0;
336338

337-
Vector lNormalV = X_product(v01,v02);
339+
Vector lNormalV = robust_cross_product(v01,v02);
338340
FT lNormalL = point_cross_product(p0,p1) * (p2 - ORIGIN);
339341

340342
CGAL_SMS_LT_TRACE(1, " Extracting triangle v" << tri.v0 << "->v" << tri.v1 << "->v" << tri.v2
@@ -660,10 +662,10 @@ add_constraint_if_alpha_compatible(const Vector& Ai,
660662
FT l = CGAL_NTS sqrt(slai);
661663
CGAL_SMS_LT_TRACE(3, " l: " << n_to_string(l));
662664

663-
// Due to double number type, l may have a small value instead of zero (example sum of the face normals of a tetrahedron for volumic constraint)
665+
// Due to double number type, l may have a small value instead of zero (example sum of the face normals of a tetrahedron for volume constraint)
664666
// if bi is greater than maxBb, we consider that l is zero
665667
CGAL_SMS_LT_TRACE(3, " error consider: " << (CGAL::abs(bi) / maxBb));
666-
if(l > (std::abs(bi) / maxBb))
668+
if(l > (CGAL::abs(bi) / maxBb))
667669
{
668670
Vector Ain = Ai / l;
669671
FT bin = bi / l;

0 commit comments

Comments
 (0)