Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nef_3: Add testcase #8646

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
24 changes: 24 additions & 0 deletions Nef_3/test/Nef_3/data/lshape1_dim3.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
OFF
12 8 0

1.5 3 1
1.5 -1.5 1
-3 -1.5 1
-3 -3 1
3 -3 1
3 3 1
1.5 3 -1
1.5 -1.5 -1
3 3 -1
3 -3 -1
-3 -3 -1
-3 -1.5 -1
6 0 1 2 3 4 5
4 1 0 6 7
4 6 0 5 8
4 8 5 4 9
4 9 4 3 10
4 10 3 2 11
4 11 2 1 7
6 11 7 6 8 9 10

30 changes: 30 additions & 0 deletions Nef_3/test/Nef_3/data/ushape1_dim3.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
OFF
16 10 0

-3 -3 -1
-3 -1.5 -1
-3 -1.5 1
-3 -3 1
3 -3 -1
3 3 -1
-3 3 -1
-3 1.5 -1
1.5 1.5 -1
1.5 -1.5 -1
3 -3 1
1.5 -1.5 1
1.5 1.5 1
-3 1.5 1
-3 3 1
3 3 1
4 0 1 2 3
8 1 0 4 5 6 7 8 9
4 4 0 3 10
8 10 3 2 11 12 13 14 15
4 11 2 1 9
4 11 9 8 12
4 12 8 7 13
4 13 7 6 14
4 14 6 5 15
4 15 5 4 10

62 changes: 62 additions & 0 deletions Nef_3/test/Nef_3/issue8644.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@


#include <CGAL/Extended_cartesian.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/Nef_polyhedron_3.h>

#define DATA_DIR std::string("./data/")+
sloriot marked this conversation as resolved.
Show resolved Hide resolved

///////////////////////////////////////////////////////////////////////////////
using AFT=CGAL::Exact_rational; //CGAL::Gmpzf; CGAL::Exact_rational CGAL::Exact_integer
using AExtended_kernel=CGAL::Extended_cartesian<AFT>; //CGAL::Exact_predicates_exact_constructions_kernel ; //CGAL::Filtered_extended_homogeneous<RT>;
using ANef_polyhedron_3=CGAL::Nef_polyhedron_3<AExtended_kernel>;//CGAL::Exact_predicates_exact_constructions_kernel>;
template<typename SM>
void compute_volume_kernel_surface_mesh(SM& sm,
ANef_polyhedron_3& res)
{
res=ANef_polyhedron_3(ANef_polyhedron_3::COMPLETE);
for(typename SM::Face_index fd : sm.faces())
{
auto n=CGAL::Polygon_mesh_processing::compute_face_normal(fd, sm);
auto p1=sm.point(sm.source(sm.halfedge(fd)));
typename ANef_polyhedron_3::Point_3 ep1(p1.x(), p1.y(), p1.z());
typename ANef_polyhedron_3::Vector_3 en(n.x(), n.y(), n.z());
typename ANef_polyhedron_3::Plane_3 eplane(ep1, en);
std::cout<<eplane<<std::endl;
res*=ANef_polyhedron_3(eplane);
}
}
////////////////////////////////////////////////////////////////////////////////
void test_sm(const std::string& filename, bool rev)
{
CGAL::Surface_mesh<CGAL::Exact_predicates_inexact_constructions_kernel::Point_3> sm;
if(!CGAL::IO::read_polygon_mesh(filename, sm))
{
std::cerr << "Invalid input file: " << filename << std::endl;
return;
}
if(rev)
{ CGAL::Polygon_mesh_processing::reverse_face_orientations(sm); }
ANef_polyhedron_3 res;
compute_volume_kernel_surface_mesh(sm, res);

if(res.is_empty())
{ std::cout<<"["<<filename<<"]: empty kernel."<<std::endl;}
else
{ std::cout<<"["<<filename<<"]: NON empty kernel."<<std::endl;}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int main(/* int argc, char** argv */)
{
test_sm(std::string(DATA_DIR"lshape1_dim3.off"), true);
test_sm(std::string(DATA_DIR"lshape1_dim3.off"), false);
test_sm(std::string(DATA_DIR"ushape1_dim3.off"), true);
test_sm(std::string(DATA_DIR"ushape1_dim3.off"), false);
return 0;
}

Loading