Skip to content
Permalink
Browse files

fix doc and more cleaning

  • Loading branch information
vcloarec authored and nyalldawson committed Jul 30, 2020
1 parent eb24446 commit 0348ab0dd68f71347746c881f200744ac34be92e
@@ -39,6 +39,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
//! Enumeration for the state of a point. Normal means, that the point is not on a BreakLine, BreakLine means that the point is on a breakline (but not an end point of it) and EndPoint means, that it is an endpoint of a breakline.
enum PointState {Normal, BreakLine, EndPoint};
NormVecDecorator();
//! Constructor for TriDecorator with an existing triangulation
NormVecDecorator( QgsTriangulation *tin );
~NormVecDecorator() override;
int addPoint( const QgsPoint &p ) override;
@@ -33,6 +33,7 @@ class ANALYSIS_EXPORT TriDecorator : public QgsTriangulation
public:
//! Constructor for TriDecorator
TriDecorator() = default;
//! Constructor for TriDecorator with an existing triangulation
explicit TriDecorator( QgsTriangulation *t );
void addLine( const QVector< QgsPoint> &points, QgsInterpolator::SourceType lineType ) override;
int addPoint( const QgsPoint &p ) override;
@@ -74,7 +74,7 @@ void QgsDualEdgeTriangulation::addLine( const QVector<QgsPoint> &points, QgsInte
int i = 0;
for ( const QgsPoint &point : points )
{
actpoint = mDecorator->addPoint( point );
actpoint = addPoint( point );
i++;
if ( actpoint != -100 )
{
@@ -89,7 +89,7 @@ void QgsDualEdgeTriangulation::addLine( const QVector<QgsPoint> &points, QgsInte

for ( ; i < points.size(); ++i )
{
currentpoint = mDecorator->addPoint( points.at( i ) );
currentpoint = addPoint( points.at( i ) );
if ( currentpoint != -100 && actpoint != -100 && currentpoint != actpoint )//-100 is the return value if the point could not be not inserted
{
insertForcedSegment( actpoint, currentpoint, lineType );
@@ -2102,8 +2102,8 @@ void QgsDualEdgeTriangulation::ruppertRefinement()
/*******otherwise, try to add the circumcenter to the triangulation************************************************************************************************/

QgsPoint p( 0, 0, 0 );
mDecorator->calcPoint( circumcenter.x(), circumcenter.y(), p );
int pointno = mDecorator->addPoint( p );
calcPoint( circumcenter.x(), circumcenter.y(), p );
int pointno = addPoint( p );

if ( pointno == -100 || pointno == mTwiceInsPoint )
{
@@ -3022,7 +3022,6 @@ QgsMesh QgsDualEdgeTriangulation::triangulationToMesh() const
{
QVector<bool> alreadyVisitedEdges( mHalfEdge.count(), false );

//QSet<HalfEdge *> edgeToTreat = QSet<HalfEdge *>::fromList( mHalfEdge.toList() );
QVector< bool> edgeToTreat( mHalfEdge.count(), true );
QHash<HalfEdge *, int > edgesHash;
for ( int i = 0; i < mHalfEdge.count(); ++i )
@@ -3114,7 +3113,7 @@ int QgsDualEdgeTriangulation::splitHalfEdge( int edge, float position )

//calculate the z-value of the point to insert
QgsPoint zvaluepoint( 0, 0, 0 );
mDecorator->calcPoint( p->x(), p->y(), zvaluepoint );
calcPoint( p->x(), p->y(), zvaluepoint );
p->setZ( zvaluepoint.z() );

//insert p into mPointVector
@@ -3151,7 +3150,7 @@ int QgsDualEdgeTriangulation::splitHalfEdge( int edge, float position )
checkSwap( mHalfEdge[dualedge]->getNext(), 0 );
checkSwap( mHalfEdge[edge3]->getNext(), 0 );

mDecorator->addPoint( QgsPoint( p->x(), p->y(), 0 ) );//dirty hack to enforce update of decorators
addPoint( QgsPoint( p->x(), p->y(), 0 ) );//dirty hack to enforce update of decorators

return mPointVector.count() - 1;
}
@@ -43,14 +43,16 @@
* \ingroup analysis
* DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data structure.
* \note Not available in Python bindings.
*
* \since QGIS 3.16
*/
class ANALYSIS_EXPORT QgsDualEdgeTriangulation: public QgsTriangulation
{
public:
QgsDualEdgeTriangulation();
QgsDualEdgeTriangulation( int nop, QgsTriangulation *decorator );
//! Constructor with a number of points to reserve
QgsDualEdgeTriangulation( int nop );
~QgsDualEdgeTriangulation() override;
void setDecorator( QgsTriangulation *d ) {mDecorator = d;}
void addLine( const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType ) override;
int addPoint( const QgsPoint &p ) override;
//! Performs a consistency check, remove this later
@@ -116,8 +118,6 @@ class ANALYSIS_EXPORT QgsDualEdgeTriangulation: public QgsTriangulation
TriangleInterpolator *mTriangleInterpolator = nullptr;
//! Member to store the behavior in case of crossing forced segments
QgsTriangulation::ForcedCrossBehavior mForcedCrossBehavior = QgsTriangulation::DeleteFirst;
//! Pointer to the decorator using this triangulation. It it is used directly, mDecorator equals this
QgsTriangulation *mDecorator = nullptr;
//! Inserts an edge and makes sure, everything is OK with the storage of the edge. The number of the HalfEdge is returned
unsigned int insertEdge( int dual, int next, int point, bool mbreak, bool forced );
//! Inserts a forced segment between the points with the numbers p1 and p2 into the triangulation and returns the number of a HalfEdge belonging to this forced edge or -100 in case of failure
@@ -167,14 +167,12 @@ class ANALYSIS_EXPORT QgsDualEdgeTriangulation: public QgsTriangulation
#ifndef SIP_RUN

inline QgsDualEdgeTriangulation::QgsDualEdgeTriangulation()
: mDecorator( this )
{
mPointVector.reserve( DEFAULT_STORAGE_FOR_POINTS );
mHalfEdge.reserve( DEFAULT_STORAGE_FOR_HALF_EDGES );
}

inline QgsDualEdgeTriangulation::QgsDualEdgeTriangulation( int nop, QgsTriangulation *decorator )
: mDecorator( decorator ? decorator : this )
inline QgsDualEdgeTriangulation::QgsDualEdgeTriangulation( int nop )
{
mPointVector.reserve( nop );
mHalfEdge.reserve( nop );
@@ -79,7 +79,7 @@ void QgsTinInterpolator::setTriangulationSink( QgsFeatureSink *sink )

void QgsTinInterpolator::initialize()
{
QgsDualEdgeTriangulation *dualEdgeTriangulation = new QgsDualEdgeTriangulation( 100000, nullptr );
QgsDualEdgeTriangulation *dualEdgeTriangulation = new QgsDualEdgeTriangulation( 100000 );
if ( mInterpolation == CloughTocher )
{
NormVecDecorator *dec = new NormVecDecorator();
@@ -35,6 +35,8 @@ class QgsFeedback;
* \ingroup analysis
* Interface for Triangulation classes.
* \note Not available in Python bindings.
*
* \since QGIS 3.16
*/
class ANALYSIS_EXPORT QgsTriangulation
{

0 comments on commit 0348ab0

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