View Full Version : Qt3D: QPolygonMeshWithHole geometry

11th December 2019, 15:42
Hi there,

does anybody have a mesh implementation for a polygon mesh (ideally with hole) ready or does anybody know about a project using such a mesh?

If there's nothing like that available, I would create such a mesh myself - in such case I'd appreciate feedback/suggestions on the API. Currently I would favour something like:

// polygons defined 2D plane, n > 2
// with vectors of first and last segment must not be parallel
// inner polygon must not intersect with outer polygon, but may have a joined
// point, but no joined segments
QPolygonF outerPolygon = ...;
QPolygonF innerPolygon = ...;

QPolygonMesh * mesh = new QPolygonMesh();

Polygon would be created in x-z plane such, that p0 is the origin (0,0,0) (translating all polygon points accordingly).

What do you think?

11th December 2019, 19:42
Are these polygons actually circles or ellipses? You could use QPainterPath to create the ellipse, then use QPainterPath::toFillPolygon() to extract the QPolygonF from it.

Of course, QPolygonF is 2D only...

13th December 2019, 11:05

actually, the result needs to be a *mesh* encapsulated in a class that implements Qt3DRender::QGeometryRenderer interface and provides the required properties. These will be a set of vertices, and faces that represent a triangulated surface.

So, I'm looking for a class that implements the process of taking the outer (and optionally inner) polygon and performing a triangulation (see for example http://www.cs.cmu.edu/~quake/triangle.html) and generating the data structures to implement Qt3DRender::QGeometryRenderer just like Qt3DExtras::QConeMesh.

I'm afraid the QPainterPath::toFillPolygon() algorithm won't help here :-(


13th December 2019, 17:29
I'm afraid the QPainterPath::toFillPolygon() algorithm won't help here :-(

Well, you -did- ask for polygons in your original post. I have never looked into 3D triangulation, only 2D. As you note with your link to the Triangle page, there are many excellent implementations triangulating planar surfaces.

Can't you adapt Triangle's output for your purposes?