Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Rectangular tube is capped on the surface when converting Nef_Polyhedron_3 to Polyhedron_3

Subject: CGAL users discussion list

List archive

[cgal-discuss] Rectangular tube is capped on the surface when converting Nef_Polyhedron_3 to Polyhedron_3


Chronological Thread 
  • From: sdobashi <>
  • To:
  • Subject: [cgal-discuss] Rectangular tube is capped on the surface when converting Nef_Polyhedron_3 to Polyhedron_3
  • Date: Tue, 7 Nov 2017 13:51:00 -0700 (MST)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
  • Ironport-phdr: 9a23:iP8ADRDds1aTjitgk7rgUyQJP3N1i/DPJgcQr6AfoPdwSP38osbcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kubtmBDX0ynfUoufry0ScbuiJG82Om2vpHSeA5VnyGVYLVoLRzwox+CmNMRhN55JqE7wwDJozMcd+NczHhoJEmOkAvm+++/+Zdi92JbvPd3pJ0IarnzY6ltFO8QNz8hKW1gv5WzuA==

Hi everyone,

I created a rectangular tube shaped Nef_polyhedron_3 object by subtracting
'box2' from 'box1' (fig1, 2).
The resultant nef polyhedron looks like what I expected (fig2).

However, when I converted this to Polyhedron_3 using
"CGAL::convert_nef_polyhedron_to_polygon_mesh" or "convert_to_polygon"
method,
The top and bottom of the rectangular tube were capped (fig3).

I attached the relevant code to the end of this message.
The output "diff12.off" has a rectilinear hole inside a box but the hole was
capped on the surface.
I want to preserve the shape like fig3
even after converting the Nef polyhedron to an ordinary Polyhedron.

Is there a way to prevent the covering on the surface
when converting Nef polygon to an ordinary polygon?

Thanks,
S Dobashi

Fig1
<http://cgal-discuss.949826.n4.nabble.com/file/t375861/fig1_box1_and_box2.png>


Fig2
<http://cgal-discuss.949826.n4.nabble.com/file/t375861/fig2_box1_minus_box2_as_Nef.png>


Fig3
<http://cgal-discuss.949826.n4.nabble.com/file/t375861/fig3_box1_minus_box2_as_Polyhedron.png>


#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h>

#include <sstream>
#include <fstream>

typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_kernel;
typedef CGAL::Polyhedron_3<Exact_kernel> Polyhedron;
typedef CGAL::Surface_mesh<Exact_kernel::Point_3> Surface_mesh;
typedef CGAL::Nef_polyhedron_3<Exact_kernel> Nef_polyhedron;

void set_box1(Polyhedron& P)
{
std::stringstream ss;
ss << "OFF\n"
<< "8 6 0\n"
<< "0 0 0\n"
<< "1 0 0\n"
<< "1 1 0\n"
<< "0 1 0\n"
<< "0 0 1\n"
<< "1 0 1\n"
<< "1 1 1\n"
<< "0 1 1\n"
<< "4 0 3 2 1\n"
<< "4 0 1 5 4\n"
<< "4 1 2 6 5\n"
<< "4 2 3 7 6\n"
<< "4 3 0 4 7\n"
<< "4 4 5 6 7\n";
ss >> P;
}

void set_box2(Polyhedron& P)
{
std::stringstream ss;
ss << "OFF\n"
<< "8 6 0\n"
<< "0.25 0.25 -0.25\n"
<< "0.75 0.25 -0.25\n"
<< "0.75 0.75 -0.25\n"
<< "0.25 0.75 -0.25\n"
<< "0.25 0.25 1.25\n"
<< "0.75 0.25 1.25\n"
<< "0.75 0.75 1.25\n"
<< "0.25 0.75 1.25\n"
<< "4 0 3 2 1\n"
<< "4 0 1 5 4\n"
<< "4 1 2 6 5\n"
<< "4 2 3 7 6\n"
<< "4 3 0 4 7\n"
<< "4 4 5 6 7\n";
ss >> P;
}

int main()
{
Polyhedron box1, box2;
set_box1(box1);
set_box2(box2);

std::ofstream out;
out.open("box1.off");
out << box1;
out.close();

out.open("box2.off");
out << box2;
out.close();

Nef_polyhedron nef1(box1);
Nef_polyhedron nef2(box2);
Nef_polyhedron nef_diff12 = nef1 - nef2;

Surface_mesh output;
CGAL::convert_nef_polyhedron_to_polygon_mesh(nef_diff12, output);

out.open("diff12.off");
out << output;
out.close();
}




--
Sent from: http://cgal-discuss.949826.n4.nabble.com/



Archive powered by MHonArc 2.6.18.

Top of Page