CGAL/cgal

Logical error in triangle mesh validation condition

Closed this issue · 0 comments

I've identified a logical error in the triangle mesh validation condition. The current implementation incorrectly validates input meshes due to improper condition checking.

The problematic code:

if(!CGAL::IO::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))

This condition will:

  1. Accept non-triangle meshes when reading succeeds (because the second condition evaluates to false)
  2. Reject valid triangle meshes when reading succeeds (because the second condition evaluates to true)

The correct condition should be:

if(!CGAL::IO::read_polygon_mesh(fname, tmesh) || !CGAL::is_triangle_mesh(tmesh))

Environment

  • Operating system: Windows 10/11 64-bit
  • Compiler: Microsoft Visual Studio 2022
  • Release or debug mode: Both
  • Specific flags used: Default CGAL compilation flags
  • CGAL version: [Please specify your CGAL version here]
  • Boost version: [Please specify your Boost version here]
  • Other libraries: None