Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Inconsistent nef polyhedron topological properties

Subject: CGAL users discussion list

List archive

[cgal-discuss] Inconsistent nef polyhedron topological properties


Chronological Thread 
  • From: Nicholas Mario Wardhana <>
  • To:
  • Subject: [cgal-discuss] Inconsistent nef polyhedron topological properties
  • Date: Tue, 24 Jan 2017 19:28:39 +0000
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:kdIovhFycxFxQqSjQvpGxZ1GYnF86YWxBRYc798ds5kLTJ76rs2wAkXT6L1XgUPTWs2DsrQf2raQ7vmrADZdqdbZ6TZZL8wKD0dEwewt3CUeQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2a3IyL0LW59JTXJglJnzGgeqhaLROsrAyXuNNFr5FlL/MXyxDJpX9BYKxzzHlpIhqslgzw5s629dY39i1KuvVn6MdaXaXzea0QQrlRDTBgOGcwsp64/SLfRBeCsyNPGl4dlQBFVlDI

Hello,

I am creating a cube as a nef polyhedron by defining it as the intersections of the negative sides of the 6 bounding planes, based on the following example:
http://doc.cgal.org/latest/Nef_3/index.html#title6
It then checks the properties, saves the cube to a nef3 file, loads it again, and checks the property again

I would expect that the cube has the following properties.
  • 2-manifold (is_simple() == true)
  • The number of volumes = 2 (inside and outside the cube)
  • The number of shells = 2 (the inside and outside boundaries)
  • The number of facets = 6
  • The number of half-facets = 12
  • The number of edges = 12
  • The number of half-edges = 24
  • The number of vertices = 8
My code prints the followings.
CreateACube()
nefCube.is_simple() == true
nefCube.number_of_volumes(), expected 2, result = 3
GetNumberOfShells(nefCube), expected 2, result = 4
nefCube.number_of_facets(), expected 6, result = 12
nefCube.number_of_halffacets(), expected 12, result = 24
nefCube.number_of_edges(), expected 12, result = 24
nefCube.number_of_halfedges(), expected 24, result = 48
nefCube.number_of_vertices(), expected 8, result = 16
 
 
LoadACube()
nefCube.is_simple() == true
nefCube.number_of_volumes(), expected 2, result = 3
GetNumberOfShells(nefCube), expected 2, result = 4
nefCube.number_of_facets(), expected 6, result = 12
nefCube.number_of_halffacets(), expected 12, result = 24
nefCube.number_of_edges(), expected 12, result = 24
nefCube.number_of_halfedges(), expected 24, result = 48
nefCube.number_of_vertices(), expected 8, result = 16

I did not get many of the expected properties.

However, the nef3 file does state:
vertices   8
halfedges  24
facets     12
volumes    2
shalfedges 48
shalfloops 0
sfaces     16

and when I cross-checked the result by loading the nef3 file to the polyhedron_3 demo (http://www.cgal.org/demo/4.9/polyhedron_3.zip), it correctly prints the followings.

Test_ByEquation (mode: flat+edges, color: #6464ff)
Nef_3 polyhedron

Number of vertices: 8
Number of edges: 12
Number of facets: 6
number of volumes: 2

Bounding box: min (0,0,0), max (2,2,2)

File: <path omitted>/CGAL/output/Test_ByEquation.nef3


The minimum working code and the resulting nef3 file are attached. Could anyone please point out my mistakes? Thank you.

Best regards,
Nicholas Mario Wardhana

Attachment: Test_ByEquation.nef3
Description: Binary data

#include <CGAL/Exact_integer.h>
#include <CGAL/Extended_homogeneous.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>

#include <fstream>
#include <iostream>

typedef CGAL::Extended_homogeneous<int> Kernel;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Nef_polyhedron::Plane_3 Plane_3;
typedef Nef_polyhedron::Point_3 Point_3;
typedef Nef_polyhedron::Volume_const_iterator Volume_const_iterator;
typedef Nef_polyhedron::Shell_entry_const_iterator Shell_entry_const_iterator;

Nef_polyhedron MakeCubeByPlaneEquation(const Point_3& minPoint, const Point_3& maxPoint)
{
    Nef_polyhedron N0(Plane_3(1, 0, 0, -CGAL::to_double(maxPoint.x())));
    Nef_polyhedron N1(Plane_3(-1, 0, 0, CGAL::to_double(minPoint.x())));
    Nef_polyhedron N2(Plane_3(0, 1, 0, -CGAL::to_double(maxPoint.y())));
    Nef_polyhedron N3(Plane_3(0, -1, 0, CGAL::to_double(minPoint.y())));
    Nef_polyhedron N4(Plane_3(0, 0, 1, -CGAL::to_double(maxPoint.z())));
    Nef_polyhedron N5(Plane_3(0, 0, -1, CGAL::to_double(minPoint.z())));
    Nef_polyhedron nefCube = N0*N1*N2*N3*N4*N5;

    return nefCube;
}

int GetNumberOfShells(const Nef_polyhedron& nefPolyhedron)
{
    int numberOfShells = 0;
    Volume_const_iterator c;
    CGAL_forall_volumes(c, nefPolyhedron) {
        int is = 0;
        Shell_entry_const_iterator it;
        CGAL_forall_shells_of(it, c) {
            ++numberOfShells;
        }
    }

    return numberOfShells;
}

void PrintTopologicalProperties(const Nef_polyhedron& nefCube)
{
    if(nefCube.is_simple())
        std::cout << "nefCube.is_simple() == true" << std::endl;
    else
        std::cout << "nefCube.is_simple() == false" << std::endl;
    
    std::cout << "nefCube.number_of_volumes(), expected 2, result = " << nefCube.number_of_volumes() << std::endl;
    std::cout << "GetNumberOfShells(nefCube), expected 2, result = " << GetNumberOfShells(nefCube) << std::endl;
    std::cout << "nefCube.number_of_facets(), expected 6, result = " << nefCube.number_of_facets() << std::endl;
    std::cout << "nefCube.number_of_halffacets(), expected 12, result = " << nefCube.number_of_halffacets() << std::endl;
    std::cout << "nefCube.number_of_edges(), expected 12, result = " << nefCube.number_of_edges() << std::endl;
    std::cout << "nefCube.number_of_halfedges(), expected 24, result = " << nefCube.number_of_halfedges() << std::endl;
    std::cout << "nefCube.number_of_vertices(), expected 8, result = " << nefCube.number_of_vertices() << std::endl;
}

void CreateACube()
{
    Nef_polyhedron nefCube = MakeCubeByPlaneEquation(Point_3(0, 0, 0), Point_3(2, 2, 2));
    std::cout << "CreateACube()" << std::endl;
    PrintTopologicalProperties(nefCube);    
    std::ofstream out("CGAL//output//Test_ByEquation.nef3"); out << nefCube;
    std::cout << std::endl;
}

void LoadACube()
{
    Nef_polyhedron nefCube;
    std::ifstream in("CGAL//output//Test_ByEquation.nef3"); in >> nefCube;
    std::cout << "LoadACube()" << std::endl;
    PrintTopologicalProperties(nefCube);
}

int main(int argc, char **argv) {
    CreateACube();
    LoadACube();
    return 0;
}



Archive powered by MHonArc 2.6.18.

Top of Page