Skip to content
Permalink
Browse files

Handle curved geometries (line/polygon 3d symbol) and repeated vertices

  • Loading branch information
wonder-sk committed Aug 10, 2017
1 parent b234fc5 commit 81c591c17256ff0f0d839dd69d48f947e538a82e
Showing with 32 additions and 12 deletions.
  1. +7 −1 src/3d/lineentity.cpp
  2. +7 −1 src/3d/polygonentity.cpp
  3. +18 −10 src/3d/tessellator.cpp
@@ -93,7 +93,13 @@ Qt3DRender::QGeometryRenderer *LineEntityNode::renderer( const Map3D &map, const
if ( f.geometry().isNull() )
continue;

QgsAbstractGeometry *g = f.geometry().geometry();
QgsGeometry geom = f.geometry();

// segmentize curved geometries if necessary
if ( QgsWkbTypes::isCurvedType( geom.geometry()->wkbType() ) )
geom = QgsGeometry( geom.geometry()->segmentize() );

QgsAbstractGeometry *g = geom.geometry();

QgsGeos engine( g );
QgsAbstractGeometry *buffered = engine.buffer( symbol.width / 2., nSegments, endCapStyle, joinStyle, mitreLimit ); // factory
@@ -96,7 +96,13 @@ Qt3DRender::QGeometryRenderer *PolygonEntityNode::renderer( const Map3D &map, co
if ( f.geometry().isNull() )
continue;

QgsAbstractGeometry *g = f.geometry().geometry();
QgsGeometry geom = f.geometry();

// segmentize curved geometries if necessary
if ( QgsWkbTypes::isCurvedType( geom.geometry()->wkbType() ) )
geom = QgsGeometry( geom.geometry()->segmentize() );

QgsAbstractGeometry *g = geom.geometry();

if ( QgsWkbTypes::flatType( g->wkbType() ) == QgsWkbTypes::Polygon )
{
@@ -105,15 +105,19 @@ void Tessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHeight
polyline.reserve( exterior->numPoints() );

QgsVertexId::VertexType vt;
QgsPoint pt;
QgsPoint pt, ptPrev;

for ( int i = 0; i < exterior->numPoints() - 1; ++i )
{
exterior->pointAt( i, pt, vt );
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
polyline.push_back( pt2 );
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
z[pt2] = zPt;
if ( i == 0 || pt != ptPrev )
{
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
polyline.push_back( pt2 );
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
z[pt2] = zPt;
}
ptPrev = pt;
}
polylinesToDelete << polyline;

@@ -128,16 +132,20 @@ void Tessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHeight
for ( int j = 0; j < hole->numPoints() - 1; ++j )
{
hole->pointAt( j, pt, vt );
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
holePolyline.push_back( pt2 );
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
z[pt2] = zPt;
if ( j == 0 || pt != ptPrev )
{
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
holePolyline.push_back( pt2 );
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
z[pt2] = zPt;
}
ptPrev = pt;
}
cdt->AddHole( holePolyline );
polylinesToDelete << holePolyline;
}

// TODO: robustness (no duplicate / nearly duplicate points, ...)
// TODO: robustness (no nearly duplicate points, invalid geometries ...)

cdt->Triangulate();

0 comments on commit 81c591c

Please sign in to comment.
You can’t perform that action at this time.