[osg-users] osgUtil::Delaunay* question (where is the triangulation of the constraints?)

Robert Osfield robert.osfield at gmail.com
Sat Nov 12 01:38:15 PST 2016


Hi Nick,

The original author of DelaunayTriangulator hasn't been an active
member of the OSG for decade so it's unfortunately a case of reading
the code to work out what is happening.

I'm afraid it doesn't make much sense for me to go read your code,
read the DelaunayTriangulator code and work out what is going on, then
try to communicate my findings to you, it's just way more efficient to
dive into the code yourself.

Robert.

On 11 November 2016 at 18:18, Trajce Nikolov NICK
<trajce.nikolov.nick at gmail.com> wrote:
> Hi Community,
>
> I hope you will help this time too. Struggling again :-).
>
> I am trying to add cultural features to terrain models, nothing fancy (yet!
> :-) ) it is simple. Code will describe it more how I am doing it but it is
> the very basic, elevations array to be triangulated with some constraints.
> And it works nicely. However when I want to cut the triangulated constraint
> from the terrain, and add this cut triangles as separate primitive set,
> constraint->getTriangles() is empty. Based on the doxygen in the header I am
> expecting to have these triangles there:
>
> /** Get the filling primitive. One:
>      * triangulate must have bneen called and
>      * two:  triangle list is filled when
>      * DelaunayTriangulator::removeInternalTriangles is called.
>      * These return the triangles removed from the delaunay triangulation by
>      * DelaunayTriangulator::removeInternalTriangles. */
>     inline const osg::DrawElementsUInt *getTriangles() const { return
> prim_tris_.get(); }
>
> No triangles when calling this and this is the snippet:
>
> osg::ref_ptr<osgUtil::DelaunayTriangulator> triangulator = new
> osgUtil::DelaunayTriangulator;
>
> osg::ref_ptr<osg::Vec3Array> polyline = getPolylineVertices(line);
> osg::ref_ptr<osg::Vec3Array> polylineEdges = getEdges(polyline);
>
> constraint->setVertexArray(polylineEdges);
> constraint->addPrimitiveSet(new osg::DrawArrays(GL_LINE_LOOP, 0,
> polylineEdges->size()));
>
> triangulator->addInputConstraint(constraint);
> triangulator->setInputPointArray(_points);
> triangulator->triangulate();
> triangulator->removeInternalTriangles(constraint);
>
> osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
> geometry->setVertexArray(_points);
> geometry->addPrimitiveSet(triangulator->getTriangles()); // triangles with
> constraint cut
> geometry->addPrimitiveSet(constraint->getTriangles()); // no triangles
>
> Thanks a bunch as always!
>
> Nick
>
> --
> trajce nikolov nick
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list