Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] What's the minimal requirement to use the Constructive Solid Geometry (CSG) module of CGAL?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] What's the minimal requirement to use the Constructive Solid Geometry (CSG) module of CGAL?


Chronological Thread 
  • From: Guillaume Damiand <>
  • To: "" <>
  • Subject: Re: [cgal-discuss] What's the minimal requirement to use the Constructive Solid Geometry (CSG) module of CGAL?
  • Date: Tue, 24 Jan 2012 07:09:53 +0100

The variables nVertices,Vertices,nTri,nTri are parameters of the constructor of your class.
Thus they are not defined in the operator(). You need to define variables in your class in order to store them.
Guillaume


Dear Dr. Loriot,

Thank you very much for your kindly reply. I am trying to study the example 'polyhedron_prog_incr_builder' and tried to modify the file 'polyhedron_prog_incr_builder.cpp' as follows:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_3.h>

// A modifier creating a triangle with the incremental builder.
template <class HDS>
class Build_triangle : public CGAL::Modifier_base<HDS> {
public:
    Build_triangle(int nVertices, double *Vertices, int nTri, int *Tri) {}
    void operator()( HDS& hds) {
        // Postcondition: `hds' is a valid polyhedral surface.
        CGAL::Polyhedro n_incremental_builder_3<HDS> B( hds, true);
        B.begin_surface( 3, 1, 6);
        typedef typename HDS::Vertex   Vertex;
        typedef typename Vertex::Point Point;
                double *v=Vertices;
                for (int i=0;i<nVertices;i++)
                    B.add_vertex( Point( *v++, *v++, *v++));
                for (int i=0;i<nTri;i++)
                {
                    B.begin_facet();
                     B.add_vertex_to_facet( *Tri++);
                    B.add_vertex_to_facet( *Tri++);
                    B.add_vertex_to_facet( *Tri++);
                    B.end_facet();
                }
        B.end_surface();
    }
};

typedef CGAL::Simple_cartesian<double>     Kernel;
typedef CGAL::Polyhedron_3<Kernel>         Polyhedron;
typedef Polyhedron::HalfedgeDS             HalfedgeDS;

int main() {
    ; Polyhedron P;
        int nVertices=3;
        double Vertices[]={0, 0, 0,1, 0, 0,0, 1, 0};
        int nTri=1;
        int Tri[]={0,1,2};
    Build_triangle<HalfedgeDS> triangle(nVertices,Vertices,nTri,Tri);
    P.delegate( triangle);
    //CGAL_assertion( P.is_triangle( P.halfedges_begin()));
    return 0;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


The following errors displayed:
1>------ Build started: Project: polyhedron_prog_incr_builder, Configuration: Debug Win32 ------
1>Build started 2012/1/24 11:50:26.
1>InitializeBuildStatus:
1>  Touching "polyhedron_prog_incr_builder.dir\Debug\polyhedron_prog_incr_builder .unsuccessfulbuild".
1>CustomBuild:
1>  All outputs are up-to-date.
1>ClCompile:
1>  polyhedron_prog_incr_builder.cpp
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(16): error C2065: 'Vertices' : undeclared identifier
1>          D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(10) : while compiling class template member function 'void Build_triangle<HDS>::operator ()(HDS &)'
1>          with
1>          [
1>              HDS=HalfedgeDS
1>          ]
1>          D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(41) : see reference to class template instantiation 'Build_triangle<HDS>' being compiled
1>          with
1>          [
1>              HDS=HalfedgeDS
1>          ]
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(17): error C2065: 'nVertices' : undeclared identifier
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(19): error C2065: 'nTri' : undeclared identifier
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(22): error C2065: 'Tri' : undeclared identifier
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\polyhedron_prog_incr_builder.cpp(23): error C2065: 'Tri' : undeclared identifier
1>D:\CGAL\CGAL3.9\CGAL-3.9\examples\Polyhedron\poly hedron_prog_incr_builder.cpp(24): error C2065: 'Tri' : undeclared identifier
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.53
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Could you please help me to check the problem?



Thanks



> Date: Wed, 18 Jan 2012 11:55:11 +0100
> From:
> To:
> Subject: Re: [cgal-discuss] What's the minimal requirement to use the Constructive Solid Geometry (CSG) module of CGAL?
>
> CGAL cannot handle directly cylinders but only discrete polyhedral models.
>
> See the documentation of Nef package for more details:
> http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html
>
> Sebastien.
>
> On 01/18/2012 10:41 AM, Zhanghong Tang wrote:
> > Dear Dr. Loriot,
> >
> > Thank you very much for your kindly reply.
> >
> > My requirement is as follows:
> > 1) read the geometries to do the operations;
> > for example, two cylinders with both radius 1 and length 10, the center
> > of top and bottom facet of two cylinders are:
> > cylinder 1:
> > top facet: (0,0,5)
> > bottom facet: (0,0,-5)
> > cylinder 2:
> > top facet (5,0,0)
> > bottom facet: (-5,0,0)
> >
> > 2) find the 3D Boolean operations of input objects and output the
> > presentation by OFF file format.
> > for example, find the unite of two crossed cylinders and output the
> > presentation by OFF file format.
> >
> >
> > How to implement this with mimimal code?
> >
> >
> > Thanks,
> > Zhanghong Tang
> >
> >
> > P.S.:
> > I notice that the mesher 'NetGen' takes the CSG format as its input
> > file, however, it can't handle the simplest example (it works when the
> > radius of two cylinders are not equal), I guess that the CGAL can handle
> > it easily.
> >
> >
> >
> > > Date: Wed, 18 Jan 2012 08:25:30 +0100
> > > From:
> > > To:
> > > Subject: Re: [cgal-discuss] What's the minimal requirement to use the
> > Constructive Solid Geometry (CSG) module of CGAL?
> > >
> > > Zhanghong Tang wrote:
> > > > Dear all,
> > > >
> > > > I would like use the CSG module of CGAL, what's the minimal
> > requirement
> > > > to use this module? I want to build it to a blockbox with CSG module
> > > > data input and another format data output (for example, piecewise
> > linear
> > > > complex format, Geomview's polyhedral file format (OFF)), which files
> > > > should I select to compile and is there any interface to use this
> > module?
> > > >
> > > > Thanks,
> > > > Zhanghong Tang
> > > >
> > > Your question is not clear to me. Could you explain what you are looking
> > > for exactly?
> > &g t;
> > > For 3D Boolean operations, you need to use Nef_3:
> > >
> > http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html
> > > For simple polyhedron manipulation, you can use Polyhedron_3:
> > >
> > http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Polyhedron/Chapter_main.html
> > >
> > > Sebastien.
> > > ;
> > > --
> > > You are currently subscribed to cgal-discuss.
> > > To unsubscribe or access the archives, go to
> > > https://lists-sop.inria.fr/wws/info/cgal-discuss
> > >
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>


-- 
===================================================================
Guillaume DAMIAND

CNRS, LIRIS  UMR 5205
Université Claude Bernard
Bâtiment Nautibus (710)
43 Boulevard du 11 Novembre 1918
69622 Villeurbanne Cedex (France)
-------------------------------------------------------------------
Phone: +33 (0)4.72.43.26.62               Fax: +33 (0)4.72.43.15.36
Mail: 
===================================================================



Archive powered by MHonArc 2.6.16.

Top of Page