Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
FACTOR=$1
set -ex
cd Lab/demo
/usr/local/bin/cmake -S Lab -B build -DCGAL_DIR=$2
LIST_OF_PLUGINS=$(/usr/local/bin/cmake --build build -t help | egrep 'plugin$' |& cut -d\ -f2)
PLUGINS_ARRAY=(${LIST_OF_PLUGINS});
/usr/local/bin/cmake -S Lab -B build -DCGAL_DIR="$2"
mapfile -t PLUGINS_ARRAY <<< "$(/usr/local/bin/cmake --build build -t help | grep -E 'plugin$' |& cut -d\ -f2)"
NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]}
DEL=$(($NB_OF_PLUGINS / 4))
DEL=$(( NB_OF_PLUGINS / 4 + 1))
cd build
NUM_PROCS=$(nproc)
make -j${NUM_PROCS} ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))}
make "-j${NUM_PROCS}" "${PLUGINS_ARRAY[@]:$((FACTOR * DEL)):$DEL}"
16 changes: 16 additions & 0 deletions Data/data/meshes/non_manifold.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OFF
8 4 0

0 0 0
1 0 0
1 1 0
2 0 0
0 0 0
1 0 0
1 1 0
2 0 0

3 0 1 2
3 2 1 3
3 5 4 6
3 5 6 7
2 changes: 2 additions & 0 deletions STL_Extension/doc/STL_Extension/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - STL Extensions for CGAL"
INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/value_type_traits.h
INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/functional.h
INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Triangulation_simplex_base_with_time_stamp.h
INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/bisect_failures.h

1 change: 1 addition & 0 deletions STL_Extension/doc/STL_Extension/PackageDescription.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
- `CGAL::Creator_uniform_d<Arg, Result>`

\cgalCRPSection{Utilities}
- `CGAL::bisect_failures()`
- `CGAL::Twotuple<T>`
- `CGAL::Threetuple<T>`
- `CGAL::Fourtuple<T>`
Expand Down
1 change: 1 addition & 0 deletions STL_Extension/doc/STL_Extension/examples.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*!
\example STL_Extension/bisect_failures.cpp
\example STL_Extension/Default.cpp
\example STL_Extension/Dispatch_output_iterator.cpp
\example STL_Extension/in_place_list_prog.cpp
Expand Down
109 changes: 109 additions & 0 deletions STL_Extension/examples/STL_Extension/bisect_failures.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// CGAL::bisect_failures requires the code to be compiled with assertions
// enabled. That means NDEBUG and CGAL_NDEBUG should not be defined.
#if defined(NDEBUG)
# undef NDEBUG
#endif
#if defined(CGAL_NDEBUG)
# undef CGAL_NDEBUG
#endif
#include <CGAL/config.h>
#include <CGAL/bisect_failures.h>
#include <CGAL/boost/graph/Euler_operations.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/clip.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>

#include <cstdlib>
#include <iostream>
#include <string>

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Point = Kernel::Point_3;
using Mesh = CGAL::Surface_mesh<Point>;


int main(int argc, char* argv[]) {
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/non_manifold.off");

Mesh mesh_a;
if(!CGAL::IO::read_polygon_mesh(filename, mesh_a)) {
std::cerr << "Error: cannot read file " << filename << std::endl;
return EXIT_FAILURE;
}

std::cout << "Loaded mesh with " << mesh_a.number_of_vertices() << " vertices and "
<< mesh_a.number_of_faces() << " faces" << std::endl;

const std::string clip_name = (argc > 2) ? argv[2] : CGAL::data_file_path("meshes/cube.off");
Mesh mesh_b;
if(!CGAL::IO::read_polygon_mesh(clip_name, mesh_b)) {
std::cerr << "Error: cannot read file " << clip_name << std::endl;
return EXIT_FAILURE;
}

std::cout << "Loaded clipping mesh mesh with " << mesh_b.number_of_vertices() << " vertices and "
<< mesh_b.number_of_faces() << " faces" << std::endl;

//! [bisect_failures_snippet]
// Define the callbacks for bisect_failures

auto get_size = [](const Mesh& m) -> std::size_t {
return m.number_of_faces();
};

auto simplify = [](Mesh& m, int start, int end) -> bool {
for(auto i = end - 1; i >= start; --i) {
const auto f = m.faces().begin() + i;
CGAL::Euler::remove_face(halfedge(*f, m), m);
}

return m.is_valid();
};

auto run = [&mesh_b](Mesh& mesh) -> int {
return CGAL::Polygon_mesh_processing::clip(mesh, mesh_b) ? EXIT_SUCCESS : EXIT_FAILURE;
};

auto save = [](const Mesh& m, CGAL::Bisection_event event) {
std::string prefix;
switch(event) {
case CGAL::BAD_DATA:
prefix = "bad_data";
break;
case CGAL::FINAL_BAD_DATA:
prefix = "final_bad_data";
break;
case CGAL::ERROR_DATA:
prefix = "error_data";
break;
case CGAL::CURRENT_DATA:
prefix = "current_data";
break;
default:
CGAL_UNREACHABLE();
}
std::string out_filename = prefix + ".off";
if(!CGAL::IO::write_polygon_mesh(out_filename, m)) {
std::cerr << "Warning: Could not save mesh to " << out_filename << std::endl;
} else {
std::cout << "Saved mesh with " << m.number_of_faces()
<< " faces to " << out_filename << std::endl;
}
};

std::cout << "\n=== Starting bisection to find smaller failing case ===\n" << std::endl;

int result = CGAL::bisect_failures(mesh_a, get_size, simplify, run, save);
//! [bisect_failures_snippet]

if(result == EXIT_SUCCESS) {
std::cout << "\nNo failure detected during bisection." << std::endl;
} else {
std::cout << "\nFailure detected during bisection. Result code: " << result << std::endl;
}

return EXIT_SUCCESS;
}
Loading