Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Running out of memory when compiling 3D mesh generation code with extended polyhedral surface information

Subject: CGAL users discussion list

List archive

[cgal-discuss] Running out of memory when compiling 3D mesh generation code with extended polyhedral surface information


Chronological Thread 
  • From: Nicholas Mario Wardhana <>
  • To:
  • Subject: [cgal-discuss] Running out of memory when compiling 3D mesh generation code with extended polyhedral surface information
  • Date: Tue, 7 Jun 2011 00:00:22 +0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=qyG9Qvl3Rc8uSPRKyNCJcAUyx1zWg6u2Rl1uhuWuxBFe95OMYo4KGpaMYTmPeHLIkk YL+SqSsZbNhII78guCaUUrX4MZXCTLAEommHl9jBK9tBasL6kru5E4XV4Ao6cLQ2kDg5 Aeneu0znl+u+QHNIvGGMC5ocbxnjw3uf+wDq4=

Hi all,

I am using CGAL's 3D mesh generation module (
http://www.cgal.org/Manual/3.5/doc_html/cgal_manual/Mesh_3/Chapter_main
).to generate a 3D mesh from an extended polyhedral surface, and I was
having a problem with the overwhelming memory consumption during the
compilation. I tried to (independently) compile my code using Visual
Studio 2008 on 2 machines:

1) laptop with Intel Core 2 Duo P8600 @ 2.40 GHz processor, 4 GB of
memory (1 GB is shared for graphics), running Windows Vista, and

2) workstation with.Intel Xeon E5520 @ 2.27 GHz quad core processor, 4
GB of memory, running Windows 7.

Please see the attachment for a rather stripped off, albeit not
minimal code. This code can compile well on both machines, although
with high memory consumption. However, for the real code that we are
developing, the second machine can only compile the code under Release
configuration, whereas the compiler always crashes on the first
machine. I also attach a screen capture of the Windows task manager
during the compilation on the first machine. It shows that the
compilation process consumed almost 2 GB of memory.

My questions are as follow.

1) Is it normal for the compiler to consume that much memory? Is there
any way to reduce the memory consumption?

2) What is the fastest kernel that the tetrahedral mesh generation can
use? I only want a fast program without exact computation. Originally
I went with CGAL::Simple_cartesian<float>, but I found an "cannot
convert from 'const CGAL::Lazy_exact_nt<ET_>' to 'float'" error, so I
resort to CGAL::Simple_cartesian<double> .

Please let me know if I need to give more information.

Thank you!

Best regards,
Nicholas Mario Wardhana

Attachment: cgal.jpg
Description: JPEG image

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Mesh_3/Robust_intersection_traits_3.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Triangle_accessor_3.h>
#include <CGAL/Polyhedral_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>

typedef CGAL::Simple_cartesian<double> Kernel;

template <class Kernel, class Refs, class Point>
struct CGALPolyhedronVertex : public CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point>
{
    CGALPolyhedronVertex()
        : CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point> ()
        , datum(0.0f)
    {

    }

    CGALPolyhedronVertex(const CGALPolyhedronVertex& v)
        : CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point>(v.point())
        , datum(v.datum)
    {

    }

    CGALPolyhedronVertex(const Point& p)
        : CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point> (p)
        , datum(0.0f)
    {

    }

    float datum;
};

template <class Kernel, class Refs, class Plane>
struct CGALPolyhedronFacet : public CGAL::HalfedgeDS_face_base<Refs, CGAL::Tag_true, Plane>
{
    CGALPolyhedronFacet()
        : CGAL::HalfedgeDS_face_base<Refs, CGAL::Tag_true, Plane> ()
        , datum(0.0f)
    {

    }

    CGALPolyhedronFacet(const CGALPolyhedronFacet& v)
        : CGAL::HalfedgeDS_face_base<Refs, CGAL::Tag_true, Plane>(v.plane())
        , datum(0.0f)
    {

    }

    CGALPolyhedronFacet(const Plane& p)
        : CGAL::HalfedgeDS_face_base<Refs, CGAL::Tag_true, Plane> (p)
        , datum(0.0f)
    {

    }

    float datum;
};

class CGALPolyhedronItems : public CGAL::Polyhedron_items_3 
{
public:
    template < class Refs, class Traits>
    struct Vertex_wrapper {
        typedef typename Traits::Point_3 Point;
        typedef CGALPolyhedronVertex<Kernel, Refs, Point> Vertex;
    };
    template < class Refs, class Traits>
    struct Halfedge_wrapper {
        typedef CGAL::HalfedgeDS_halfedge_base< Refs> Halfedge;
    };
    template < class Refs, class Traits>
    struct Face_wrapper {
        typedef typename Traits::Plane_3 Plane;
        typedef CGALPolyhedronFacet<Kernel, Refs, Plane>   Face;
    };
};

typedef CGAL::Polyhedron_3<Kernel, CGALPolyhedronItems> Polyhedron;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron2;
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, Kernel> MeshDomain;

// Triangulation
typedef CGAL::Mesh_triangulation_3<MeshDomain>::type MeshTriangulation;
typedef CGAL::Mesh_complex_3_in_triangulation_3<MeshTriangulation> MeshComplex3;

// Mesh Criteria
typedef CGAL::Mesh_criteria_3<MeshTriangulation> MeshCriteria;
typedef MeshCriteria::Facet_criteria FacetCriteria;
typedef MeshCriteria::Cell_criteria CellCriteria;

int main()
{
    Polyhedron p;
    MeshDomain domain(p);
    FacetCriteria facetCriteria(25, 0.15f, 0.008f); // angle, size, approximation
    CellCriteria cellCriteria(4, 0.2f); // radius-edge ratio, size
    MeshCriteria criteria(facetCriteria, cellCriteria);
    MeshComplex3 meshComplex3 = CGAL::make_mesh_3<MeshComplex3>(domain, criteria);

    return 0;
}



Archive powered by MHonArc 2.6.16.

Top of Page