-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle nested holes in convex decomposition (#8442)
Fixes #8379
- Loading branch information
Showing
6 changed files
with
764 additions
and
8 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Convex_decomposition_3/test/Convex_decomposition_3/cd_nested_holes_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> | ||
#include <CGAL/Polyhedron_3.h> | ||
#include <CGAL/Nef_polyhedron_3.h> | ||
#include <CGAL/IO/Nef_polyhedron_iostream_3.h> | ||
#include <CGAL/Nef_3/SNC_indexed_items.h> | ||
#include <CGAL/convex_decomposition_3.h> | ||
#include <list> | ||
|
||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; | ||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3; | ||
typedef CGAL::Nef_polyhedron_3<Kernel, CGAL::SNC_indexed_items> Nef_polyhedron_3; | ||
typedef Nef_polyhedron_3::Volume_const_iterator Volume_const_iterator; | ||
|
||
std::size_t run(std::string path) | ||
{ | ||
Polyhedron_3 input; | ||
std::ifstream(path) >> input; | ||
|
||
Nef_polyhedron_3 N(input); | ||
|
||
CGAL::convex_decomposition_3(N); | ||
std::list<Polyhedron_3> convex_parts; | ||
|
||
Volume_const_iterator ci = ++N.volumes_begin(); | ||
for( ; ci != N.volumes_end(); ++ci) { | ||
if(ci->mark()) { | ||
Polyhedron_3 P; | ||
N.convert_inner_shell_to_polyhedron(ci->shells_begin(), P); | ||
convex_parts.push_back(P); | ||
} | ||
} | ||
|
||
// int i=0; | ||
for (const Polyhedron_3& P : convex_parts) | ||
{ | ||
// std::ofstream("out_"+std::to_string(i++)+".off") << std::setprecision(17) << P; | ||
assert(P.size_of_vertices()!=0); | ||
} | ||
|
||
return convex_parts.size(); | ||
} | ||
|
||
int main() | ||
{ | ||
std::size_t val = run("data/in1.off"); | ||
assert(val==9); | ||
val = run("data/in2.off"); | ||
assert(val==10); | ||
val = run("data/in3.off"); | ||
assert(val==13); | ||
val = run("data/in4.off"); | ||
assert(val==17); | ||
} |
117 changes: 117 additions & 0 deletions
117
Convex_decomposition_3/test/Convex_decomposition_3/data/in1.off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
OFF 40 76 0 | ||
5 -5 4 | ||
5 -5 2 | ||
5 5 2 | ||
5 5 4 | ||
5 -5 -2 | ||
5 -5 -4 | ||
5 5 -4 | ||
5 5 -2 | ||
-5 5 4 | ||
-5 -5 4 | ||
-4 -4 4 | ||
-4 4 4 | ||
4 4 4 | ||
4 -4 4 | ||
-5 -5 -4 | ||
-5 5 -4 | ||
-4 4 -4 | ||
-4 -4 -4 | ||
4 -4 -4 | ||
4 4 -4 | ||
-5 5 2 | ||
-5 -5 2 | ||
-5 -5 -2 | ||
-5 5 -2 | ||
4 4 2 | ||
4 -4 2 | ||
4 -4 -2 | ||
4 4 -2 | ||
-4 4 2 | ||
-4 -4 2 | ||
-4 4 -2 | ||
-4 -4 -2 | ||
6 -6 2 | ||
6 -6 -2 | ||
6 6 -2 | ||
6 6 2 | ||
-6 6 2 | ||
-6 -6 2 | ||
-6 -6 -2 | ||
-6 6 -2 | ||
3 0 2 3 | ||
3 2 0 1 | ||
3 4 6 7 | ||
3 6 4 5 | ||
3 3 12 0 | ||
3 3 11 12 | ||
3 11 8 10 | ||
3 8 11 3 | ||
3 13 0 12 | ||
3 10 0 13 | ||
3 10 9 0 | ||
3 9 10 8 | ||
3 5 18 6 | ||
3 5 17 18 | ||
3 17 14 16 | ||
3 14 17 5 | ||
3 19 6 18 | ||
3 16 6 19 | ||
3 16 15 6 | ||
3 15 16 14 | ||
3 21 8 20 | ||
3 8 21 9 | ||
3 14 23 15 | ||
3 23 14 22 | ||
3 2 8 3 | ||
3 8 2 20 | ||
3 6 23 7 | ||
3 23 6 15 | ||
3 21 0 9 | ||
3 0 21 1 | ||
3 14 4 22 | ||
3 4 14 5 | ||
3 25 12 24 | ||
3 12 25 13 | ||
3 18 27 19 | ||
3 27 18 26 | ||
3 10 28 11 | ||
3 28 10 29 | ||
3 31 16 30 | ||
3 16 31 17 | ||
3 28 12 11 | ||
3 12 28 24 | ||
3 16 27 30 | ||
3 27 16 19 | ||
3 25 10 13 | ||
3 10 25 29 | ||
3 18 31 26 | ||
3 31 18 17 | ||
3 32 34 35 | ||
3 34 32 33 | ||
3 35 2 32 | ||
3 35 20 2 | ||
3 20 36 21 | ||
3 36 20 35 | ||
3 1 32 2 | ||
3 21 32 1 | ||
3 21 37 32 | ||
3 37 21 36 | ||
3 28 25 24 | ||
3 25 28 29 | ||
3 33 4 34 | ||
3 33 22 4 | ||
3 22 38 23 | ||
3 38 22 33 | ||
3 7 34 4 | ||
3 23 34 7 | ||
3 23 39 34 | ||
3 39 23 38 | ||
3 31 27 26 | ||
3 27 31 30 | ||
3 38 36 39 | ||
3 36 38 37 | ||
3 34 36 35 | ||
3 36 34 39 | ||
3 38 32 37 | ||
3 32 38 33 |
144 changes: 144 additions & 0 deletions
144
Convex_decomposition_3/test/Convex_decomposition_3/data/in2.off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
OFF | ||
48 92 0 | ||
|
||
2 2 2 | ||
2 -2 2 | ||
-2 2 2 | ||
-2 -2 2 | ||
-2 2 4 | ||
2 2 4 | ||
-2 -2 4 | ||
2 -2 4 | ||
5 -5 4 | ||
-4 4 4 | ||
5 5 4 | ||
4 -4 4 | ||
-5 -5 4 | ||
-4 -4 -4 | ||
5 -5 -4 | ||
4 4 -4 | ||
-5 5 -4 | ||
-5 5 4 | ||
5 5 -4 | ||
-5 -5 -4 | ||
4 4 4 | ||
4 -4 -2 | ||
-4 -4 4 | ||
-4 4 -2 | ||
-4 4 -4 | ||
4 4 -2 | ||
4 -4 -4 | ||
6 -6 2 | ||
5 5 2 | ||
-5 5 2 | ||
6 6 2 | ||
5 -5 2 | ||
-5 -5 2 | ||
-6 -6 2 | ||
5 -5 -2 | ||
-5 -5 -2 | ||
6 -6 -2 | ||
5 5 -2 | ||
-5 5 -2 | ||
-6 6 -2 | ||
-4 -4 -2 | ||
-6 6 2 | ||
6 6 -2 | ||
-6 -6 -2 | ||
-4 -4 2 | ||
-4 4 2 | ||
4 4 2 | ||
4 -4 2 | ||
3 2 4 5 | ||
3 7 6 3 | ||
3 5 7 1 | ||
3 6 7 5 | ||
3 3 6 4 | ||
3 5 0 2 | ||
3 3 1 7 | ||
3 1 0 5 | ||
3 5 4 6 | ||
3 4 2 3 | ||
3 8 28 10 | ||
3 28 8 31 | ||
3 34 18 37 | ||
3 18 34 14 | ||
3 10 20 8 | ||
3 10 9 20 | ||
3 9 17 22 | ||
3 17 9 10 | ||
3 11 8 20 | ||
3 22 8 11 | ||
3 22 12 8 | ||
3 12 22 17 | ||
3 14 26 18 | ||
3 14 13 26 | ||
3 13 19 24 | ||
3 19 13 14 | ||
3 15 18 26 | ||
3 24 18 15 | ||
3 24 16 18 | ||
3 16 24 19 | ||
3 32 17 29 | ||
3 17 32 12 | ||
3 19 38 16 | ||
3 38 19 35 | ||
3 28 17 10 | ||
3 17 28 29 | ||
3 18 38 37 | ||
3 38 18 16 | ||
3 32 8 12 | ||
3 8 32 31 | ||
3 19 34 35 | ||
3 34 19 14 | ||
3 47 20 46 | ||
3 20 47 11 | ||
3 26 25 15 | ||
3 25 26 21 | ||
3 22 45 9 | ||
3 45 22 44 | ||
3 40 24 23 | ||
3 24 40 13 | ||
3 45 20 9 | ||
3 20 45 46 | ||
3 24 25 23 | ||
3 25 24 15 | ||
3 47 22 11 | ||
3 22 47 44 | ||
3 26 40 21 | ||
3 40 26 13 | ||
3 27 42 30 | ||
3 42 27 36 | ||
3 30 28 27 | ||
3 30 29 28 | ||
3 29 41 32 | ||
3 41 29 30 | ||
3 31 27 28 | ||
3 32 27 31 | ||
3 32 33 27 | ||
3 33 32 41 | ||
3 2 0 45 | ||
3 1 44 47 | ||
3 36 34 42 | ||
3 36 35 34 | ||
3 35 43 38 | ||
3 43 35 36 | ||
3 37 42 34 | ||
3 38 42 37 | ||
3 38 39 42 | ||
3 39 38 43 | ||
3 40 25 21 | ||
3 25 40 23 | ||
3 43 41 39 | ||
3 41 43 33 | ||
3 42 41 30 | ||
3 41 42 39 | ||
3 43 27 33 | ||
3 27 43 36 | ||
3 44 1 3 | ||
3 44 3 45 | ||
3 45 3 2 | ||
3 46 45 0 | ||
3 46 0 47 | ||
3 47 0 1 | ||
|
Oops, something went wrong.