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

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Fri Nov 11 10:18:30 PST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161111/e83409ca/attachment-0002.htm>


More information about the osg-users mailing list