Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix sip bindings for interpolation classes
Also missing members declared in interpolation headers
  • Loading branch information
nyalldawson committed Nov 10, 2015
1 parent bbf58fd commit a0542e5
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 70 deletions.
28 changes: 14 additions & 14 deletions python/analysis/analysis.sip
Expand Up @@ -14,20 +14,20 @@
%Include vector/qgstransectsample.sip
%Include vector/qgszonalstatistics.sip

// %Include interpolation/Bezier3D.sip
// %Include interpolation/CloughTocherInterpolator.sip
// %Include interpolation/DualEdgeTriangulation.sip
// %Include interpolation/HalfEdge.sip
// %Include interpolation/LinTriangleInterpolator.sip
// %Include interpolation/Line3D.sip
// %Include interpolation/Node.sip
// %Include interpolation/NormVecDecorator.sip
// %Include interpolation/ParametricLine.sip
// %Include interpolation/Point3D.sip
// %Include interpolation/TriangleInterpolator.sip
// %Include interpolation/Triangulation.sip
// %Include interpolation/TriDecorator.sip
// %Include interpolation/Vector3D.sip
%Include interpolation/Bezier3D.sip
%Include interpolation/CloughTocherInterpolator.sip
%Include interpolation/DualEdgeTriangulation.sip
%Include interpolation/HalfEdge.sip
%Include interpolation/LinTriangleInterpolator.sip
%Include interpolation/Line3D.sip
%Include interpolation/Node.sip
%Include interpolation/NormVecDecorator.sip
%Include interpolation/ParametricLine.sip
%Include interpolation/Point3D.sip
%Include interpolation/TriangleInterpolator.sip
%Include interpolation/Triangulation.sip
%Include interpolation/TriDecorator.sip
%Include interpolation/Vector3D.sip

%Include interpolation/qgsgridfilewriter.sip
%Include interpolation/qgsinterpolator.sip
Expand Down
9 changes: 3 additions & 6 deletions python/analysis/interpolation/Bezier3D.sip
Expand Up @@ -8,8 +8,7 @@ class Bezier3D : ParametricLine
/** Default constructor*/
Bezier3D();
/** Constructor, par is a pointer to the parent, controlpoly a controlpolygon*/
//! @note not available in python binding
// Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
/** Destructor*/
virtual ~Bezier3D();
/** Do not use this method, since a Bezier curve does not consist of other curves*/
Expand All @@ -30,16 +29,14 @@ class Bezier3D : ParametricLine
/** Returns a control point*/
virtual const Point3D* getControlPoint( int number ) const;
/** Returns a pointer to the control polygon*/
//! @note not available in python binding
// virtual const QVector<Point3D*>* getControlPoly() const;
virtual const QVector<Point3D*>* getControlPoly() const;
/** Returns the degree of the curve*/
virtual int getDegree() const;
/** Returns the parent*/
virtual ParametricLine* getParent() const;
/** Sets the parent*/
virtual void setParent( ParametricLine* par );
/** Sets the control polygon*/
//! @note not available in python binding
// virtual void setControlPoly( QVector<Point3D*>* cp );
virtual void setControlPoly( QVector<Point3D*>* cp );

};
11 changes: 3 additions & 8 deletions python/analysis/interpolation/DualEdgeTriangulation.sip
Expand Up @@ -25,10 +25,9 @@ class DualEdgeTriangulation: Triangulation
/** Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)*/
int getOppositePoint( int p1, int p2 );
/** Finds out, in which triangle the point with coordinates x and y is and assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'*/
//! @note not available in python bindings
// virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 );
bool getTriangle( double x, double y, Point3D* p1, int* n1 /Out/, Point3D* p2 /Out/, int* n2 /Out/, Point3D* p3 /Out/, int* n3 /Out/ );
/** Finds out, in which triangle the point with coordinates x and y is and assigns addresses to the points at the vertices to 'p1', 'p2' and 'p3*/
virtual bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 );
bool getTriangle( double x, double y, Point3D* p1 /Out/, Point3D* p2 /Out/, Point3D* p3 /Out/ );
/** Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method*/
QList<int>* getSurroundingTriangles( int pointno );
/** Returns the largest x-coordinate value of the bounding box*/
Expand All @@ -41,10 +40,6 @@ class DualEdgeTriangulation: Triangulation
virtual double getYMin() const;
/** Returns the number of points*/
virtual int getNumberOfPoints() const;
/** Removes the line with number i from the triangulation*/
void removeLine( int i );
/** Removes the point with the number i from the triangulation*/
void removePoint( int i );
/** Sets the behaviour of the triangulation in case of crossing forced lines*/
virtual void setForcedCrossBehaviour( Triangulation::forcedCrossBehaviour b );
/** Sets the color of the normal edges*/
Expand Down Expand Up @@ -81,7 +76,7 @@ class DualEdgeTriangulation: Triangulation
/** Threshold for the leftOfTest to handle numerical instabilities*/
//const static double leftOfTresh=0.00001;
/** Security to prevent endless loops in 'baseEdgeOfTriangle'. It there are more iteration then this number, the point will not be inserted*/
const static int nBaseOfRuns = 300000;
//const static int nBaseOfRuns;
/** Returns the number of an edge which points to the point with number 'point' or -1 if there is an error*/
int baseEdgeOfPoint( int point );
/** Returns the number of a HalfEdge from a triangle in which 'point' is in. If the number -10 is returned, this means, that 'point' is outside the convex hull. If -5 is returned, then numerical problems with the leftOfTest occured (and the value of the possible edge is stored in the variable 'mUnstableEdge'. -20 means, that the inserted point is exactly on an edge (the number is stored in the variable 'mEdgeWithPoint'). -25 means, that the point is already in the triangulation (the number of the point is stored in the member 'mTwiceInsPoint'. If -100 is returned, this means that something else went wrong*/
Expand Down
9 changes: 5 additions & 4 deletions python/analysis/interpolation/NormVecDecorator.sip
Expand Up @@ -27,10 +27,11 @@ class NormVecDecorator : TriDecorator
/** Returns a pointer to the normal vector for the point with the number n*/
Vector3D* getNormal( int n ) const;
/** Finds out, in which triangle a point with coordinates x and y is and assigns the triangle points to p1, p2, p3 and the estimated normals to v1, v2, v3. The vectors are normaly taken from 'mNormVec', exept if p1, p2 or p3 is a point on a breakline. In this case, the normal is calculated on-the-fly. Returns false, if something went wrong and true otherwise*/
bool getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 );
/** This function behaves similar to the one above. Additionally, the numbers of the points are returned (ptn1, ptn2, ptn3) as well as the pointStates of the triangle points (state1, state2, state3)*/
//! @note not available in python bindings
// bool getTriangle( double x, double y, Point3D* p1, int* ptn1, Vector3D* v1, pointState* state1, Point3D* p2, int* ptn2, Vector3D* v2, pointState* state2, Point3D* p3, int* ptn3, Vector3D* v3, pointState* state3 );
bool getTriangle( double x, double y, Point3D* p1 /Out/, Vector3D* v1 /Out/, Point3D* p2 /Out/, Vector3D* v2 /Out/, Point3D* p3 /Out/, Vector3D* v3 /Out/ );
/** This function behaves similar to the one above. Additionally, the numbers of the points are returned (ptn1, ptn2, ptn3) as well as the pointStates of the triangle points (state1, state2, state3)
* @note not available in Python bindings
*/
//bool getTriangle( double x, double y, Point3D* p1 /Out/, int* ptn1 /Out/, Vector3D* v1 /Out/, pointState* state1 /Out/, Point3D* p2 /Out/, int* ptn2 /Out/, Vector3D* v2 /Out/, pointState* state2 /Out/, Point3D* p3 /Out/, int* ptn3 /Out/, Vector3D* v3 /Out/, pointState* state3 /Out/);
/** Returns the state of the point with the number 'pointno'*/
pointState getState( int pointno ) const;
/** Sets an interpolator*/
Expand Down
10 changes: 4 additions & 6 deletions python/analysis/interpolation/ParametricLine.sip
Expand Up @@ -7,8 +7,8 @@ class ParametricLine
/** Default constructor*/
ParametricLine();
/** Constructor, par is a pointer to the parent object, controlpoly the controlpolygon
@note not available in python binding */
// ParametricLine( ParametricLine* par /Transfer/, QVector<Point3D*>* controlpoly );
*/
ParametricLine( ParametricLine* par /Transfer/, QVector<Point3D*>* controlpoly );
/** Destructor*/
virtual ~ParametricLine();
virtual void add( ParametricLine* pl ) = 0;
Expand All @@ -19,13 +19,11 @@ class ParametricLine
virtual void changeDirection() = 0;
//virtual void draw(QPainter* p);
virtual const Point3D* getControlPoint( int number ) const = 0;
//! @note not available in python binding
// virtual const QVector<Point3D*>* getControlPoly() const = 0;
virtual const QVector<Point3D*>* getControlPoly() const = 0;
virtual int getDegree() const = 0;
virtual ParametricLine* getParent() const = 0;
//virtual bool intersects(ParametricLine* pal);
virtual void remove( int i ) = 0;
//! @note not available in python binding
// virtual void setControlPoly( QVector<Point3D*>* cp ) = 0;
virtual void setControlPoly( QVector<Point3D*>* cp ) = 0;
virtual void setParent( ParametricLine* paral ) = 0;
};
9 changes: 4 additions & 5 deletions python/analysis/interpolation/TriDecorator.sip
Expand Up @@ -2,12 +2,12 @@
class TriDecorator : Triangulation
{
%TypeHeaderCode
#include "Triangulation.h"
#include <TriDecorator.h>
%End

public:
TriDecorator();
TriDecorator( Triangulation* t );
explicit TriDecorator( Triangulation* t );
virtual ~TriDecorator();
virtual void addLine( Line3D* line, bool breakline );
virtual int addPoint( Point3D* p );
Expand All @@ -19,9 +19,8 @@ class TriDecorator : Triangulation
virtual bool calcPoint( double x, double y, Point3D* result );
virtual Point3D* getPoint( unsigned int i ) const;
virtual int getNumberOfPoints() const;
//! @note not available in python bindings
// bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 );
bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 );
bool getTriangle( double x, double y, Point3D* p1, int* n1 /Out/, Point3D* p2 /Out/, int* n2 /Out/, Point3D* p3 /Out/, int* n3 /Out/ );
bool getTriangle( double x, double y, Point3D* p1 /Out/, Point3D* p2 /Out/, Point3D* p3 /Out/ );
virtual int getOppositePoint( int p1, int p2 );
virtual QList<int>* getSurroundingTriangles( int pointno );
virtual double getXMax() const;
Expand Down
72 changes: 60 additions & 12 deletions python/analysis/interpolation/Triangulation.sip
Expand Up @@ -5,42 +5,90 @@ class Triangulation
%End

public:
/** Enumeration describing the behaviour, if two forced lines cross. SnappingType_VERTICE means, that the second inserted forced line is snapped to the closest vertice of the first inserted forced line. DELETE_FIRST means, that the status of the first inserted forced line is reset to that of a normal edge (so that the second inserted forced line remain and the first not*/
enum forcedCrossBehaviour {SnappingType_VERTICE, DELETE_FIRST, INSERT_VERTICE};


//! Enumeration describing the behaviour, if two forced lines cross.
enum forcedCrossBehaviour
{
SnappingType_VERTICE, //!< the second inserted forced line is snapped to the closest vertice of the first inserted forced line.
DELETE_FIRST, //!< the status of the first inserted forced line is reset to that of a normal edge (so that the second inserted forced line remain and the first not)
INSERT_VERTICE
};

virtual ~Triangulation();
/** Adds a line (e.g. a break-, structure- or an isoline) to the triangulation. The class takes ownership of the line object and its points*/

/**
* Adds a line (e.g. a break-, structure- or an isoline) to the triangulation.
* The class takes ownership of the line object and its points
*/
virtual void addLine( Line3D* line /Transfer/, bool breakline ) = 0;
/** Adds a point to the triangulation*/

/**
* Adds a point to the triangulation
* Ownership is transferred to this class
*/
virtual int addPoint( Point3D* p ) = 0;
/** Calculates the normal at a point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/

/**
* Calculates the normal at a point on the surface and assigns it to 'result'.
* @return true in case of success and false in case of failure
*/
virtual bool calcNormal( double x, double y, Vector3D* result ) = 0;

/** Performs a consistency check, remove this later*/
virtual void performConsistencyTest() = 0;
/** Calculates x-, y and z-value of the point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/

/**
* Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
* Returns true in case of success and flase in case of failure
*/
virtual bool calcPoint( double x, double y, Point3D* result ) = 0;

/** Returns a pointer to the point with number i. Any virtual points must have the number -1*/
virtual Point3D* getPoint( unsigned int i ) const = 0;
/** Finds out, in which triangle the point with coordinates x and y is and assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'*/
//! @note not available in python binding
// virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) = 0;

/** Finds out in which triangle the point with coordinates x and y is and
* assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'
*/
virtual bool getTriangle( double x, double y, Point3D* p1, int* n1 /Out/, Point3D* p2 /Out/, int* n2 /Out/, Point3D* p3 /Out/, int* n3 /Out/ ) = 0;

/** Finds out, in which triangle the point with coordinates x and y is and assigns the points at the vertices to 'p1', 'p2' and 'p3*/
virtual bool getTriangle( double x, double y, Point3D* p1 /Out/, Point3D* p2 /Out/, Point3D* p3 /Out/ ) = 0;
virtual bool getTriangle( double x, double y, Point3D* p1 /Out/, Point3D* p2 /Out/, Point3D* p3 /Out/ ) = 0;

/** Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)*/
virtual int getOppositePoint( int p1, int p2 ) = 0;

/** Returns the largest x-coordinate value of the bounding box*/
virtual double getXMax() const = 0;

/** Returns the smallest x-coordinate value of the bounding box*/
virtual double getXMin() const = 0;

/** Returns the largest y-coordinate value of the bounding box*/
virtual double getYMax() const = 0;

/** Returns the smallest x-coordinate value of the bounding box*/
virtual double getYMin() const = 0;

/** Returns the number of points*/
virtual int getNumberOfPoints() const = 0;
/** Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method. Any virtual point needs to have the number -1*/

/**
* Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point.
* Four integer values describe a triangle, the first three are the number of the half edges of the triangle
* and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise.
* The value list has to be deleted by the code which called the method.
* Any virtual point needs to have the number -1
*/
virtual QList<int>* getSurroundingTriangles( int pointno ) = 0;
/** Returns a value list with the numbers of the four points, which would be affected by an edge swap. This function is e.g. needed by NormVecDecorator to know the points, for which the normals have to be recalculated. The list has to be deleted by the code which calls this method*/

/** Returns a value list with the numbers of the four points, which would be affected by an edge swap.
* This function is e.g. needed by NormVecDecorator to know the points,
* for which the normals have to be recalculated.
* The list has to be deleted by the code which calls this method
*/
virtual QList<int>* getPointsAroundEdge( double x, double y ) = 0;

/** Draws the points, edges and the forced lines*/
//virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const=0;
/** Sets the behaviour of the triangulation in case of crossing forced lines*/
Expand Down
3 changes: 0 additions & 3 deletions src/analysis/interpolation/Bezier3D.h
Expand Up @@ -31,7 +31,6 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine
/** Default constructor*/
Bezier3D();
/** Constructor, par is a pointer to the parent, controlpoly a controlpolygon*/
//! @note not available in python binding
Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
/** Destructor*/
virtual ~Bezier3D();
Expand All @@ -53,7 +52,6 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine
/** Returns a control point*/
virtual const Point3D* getControlPoint( int number ) const override;
/** Returns a pointer to the control polygon*/
//! @note not available in python binding
virtual const QVector<Point3D*>* getControlPoly() const override;
/** Returns the degree of the curve*/
virtual int getDegree() const override;
Expand All @@ -62,7 +60,6 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine
/** Sets the parent*/
virtual void setParent( ParametricLine* par ) override;
/** Sets the control polygon*/
//! @note not available in python binding
virtual void setControlPoly( QVector<Point3D*>* cp ) override;

};
Expand Down
4 changes: 0 additions & 4 deletions src/analysis/interpolation/DualEdgeTriangulation.h
Expand Up @@ -75,10 +75,6 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
virtual double getYMin() const override { return yMin; }
/** Returns the number of points*/
virtual int getNumberOfPoints() const override;
/** Removes the line with number i from the triangulation*/
void removeLine( int i );
/** Removes the point with the number i from the triangulation*/
void removePoint( int i );
/** Sets the behaviour of the triangulation in case of crossing forced lines*/
virtual void setForcedCrossBehaviour( Triangulation::forcedCrossBehaviour b ) override;
/** Sets the color of the normal edges*/
Expand Down
5 changes: 3 additions & 2 deletions src/analysis/interpolation/NormVecDecorator.h
Expand Up @@ -50,8 +50,9 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
Vector3D* getNormal( int n ) const;
/** Finds out, in which triangle a point with coordinates x and y is and assigns the triangle points to p1, p2, p3 and the estimated normals to v1, v2, v3. The vectors are normaly taken from 'mNormVec', exept if p1, p2 or p3 is a point on a breakline. In this case, the normal is calculated on-the-fly. Returns false, if something went wrong and true otherwise*/
bool getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 );
/** This function behaves similar to the one above. Additionally, the numbers of the points are returned (ptn1, ptn2, ptn3) as well as the pointStates of the triangle points (state1, state2, state3)*/
//! @note not available in python bindings
/** This function behaves similar to the one above. Additionally, the numbers of the points are returned (ptn1, ptn2, ptn3) as well as the pointStates of the triangle points (state1, state2, state3)
* @note not available in Python bindings
*/
bool getTriangle( double x, double y, Point3D* p1, int* ptn1, Vector3D* v1, pointState* state1, Point3D* p2, int* ptn2, Vector3D* v2, pointState* state2, Point3D* p3, int* ptn3, Vector3D* v3, pointState* state3 );
/** Returns the state of the point with the number 'pointno'*/
pointState getState( int pointno ) const;
Expand Down

0 comments on commit a0542e5

Please sign in to comment.