Skip to content

Commit

Permalink
fix doc and more cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and nyalldawson committed Jul 30, 2020
1 parent eb24446 commit 0348ab0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/analysis/interpolation/NormVecDecorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/analysis/interpolation/TriDecorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions src/analysis/interpolation/qgsdualedgetriangulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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 );
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 5 additions & 7 deletions src/analysis/interpolation/qgsdualedgetriangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgstininterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/interpolation/qgstriangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 0348ab0

Please sign in to comment.