LCOV - code coverage report
Current view: top level - analysis/interpolation - qgstriangulation.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 2 0.0 %
Date: 2021-04-10 08:29:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :                           Triangulation.h  -  description
       3                 :            :                              -------------------
       4                 :            :     copyright            : (C) 2004 by Marco Hugentobler
       5                 :            :     email                : mhugent@geo.unizh.ch
       6                 :            :  ***************************************************************************/
       7                 :            : 
       8                 :            : /***************************************************************************
       9                 :            :  *                                                                         *
      10                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      11                 :            :  *   it under the terms of the GNU General Public License as published by  *
      12                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      13                 :            :  *   (at your option) any later version.                                   *
      14                 :            :  *                                                                         *
      15                 :            :  ***************************************************************************/
      16                 :            : 
      17                 :            : #ifndef TRIANGULATION_H
      18                 :            : #define TRIANGULATION_H
      19                 :            : 
      20                 :            : #include <QList>
      21                 :            : #include "qgis_sip.h"
      22                 :            : #include <QPainter>
      23                 :            : #include "TriangleInterpolator.h"
      24                 :            : #include "qgis_analysis.h"
      25                 :            : #include "qgsinterpolator.h"
      26                 :            : #include "qgsmeshdataprovider.h"
      27                 :            : 
      28                 :            : class QgsFeatureSink;
      29                 :            : class QgsFields;
      30                 :            : class QgsFeedback;
      31                 :            : 
      32                 :            : #define SIP_NO_FILE
      33                 :            : 
      34                 :            : /**
      35                 :            :  * \ingroup analysis
      36                 :            :  * \brief Interface for Triangulation classes.
      37                 :            :  * \note Not available in Python bindings.
      38                 :            :  *
      39                 :            :  * \since QGIS 3.16
      40                 :            : */
      41                 :          0 : class ANALYSIS_EXPORT QgsTriangulation
      42                 :            : {
      43                 :            :   public:
      44                 :            :     //! Enumeration describing the behavior, if two forced lines cross.
      45                 :            :     enum ForcedCrossBehavior
      46                 :            :     {
      47                 :            :       SnappingTypeVertex, //!< The second inserted forced line is snapped to the closest vertice of the first inserted forced line.
      48                 :            :       DeleteFirst,        //!< 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)
      49                 :            :       InsertVertex
      50                 :            :     };
      51                 :          0 :     virtual ~QgsTriangulation() = default;
      52                 :            : 
      53                 :            :     /**
      54                 :            :      * Adds a line (e.g. a break-, structure- or an isoline) to the triangulation, by specifying
      55                 :            :      * a list of source \a points.
      56                 :            :      */
      57                 :            :     virtual void addLine( const QgsPointSequence &points, QgsInterpolator::SourceType lineType ) = 0;
      58                 :            : 
      59                 :            :     /**
      60                 :            :      * Adds a \a point to the triangulation.
      61                 :            :      *
      62                 :            :      * The point should have a z-value matching the value to interpolate.
      63                 :            :      */
      64                 :            :     virtual int addPoint( const QgsPoint &point ) = 0;
      65                 :            : 
      66                 :            :     /**
      67                 :            :      * Calculates the normal at a point on the surface and assigns it to 'result'.
      68                 :            :      * \returns TRUE in case of success and FALSE in case of failure
      69                 :            :      */
      70                 :            :     virtual bool calcNormal( double x, double y, QgsPoint &result SIP_OUT ) = 0;
      71                 :            : 
      72                 :            :     //! Performs a consistency check, remove this later
      73                 :            :     virtual void performConsistencyTest() = 0;
      74                 :            : 
      75                 :            :     /**
      76                 :            :      * Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
      77                 :            :      * Returns TRUE in case of success and FALSE in case of failure
      78                 :            :      */
      79                 :            :     virtual bool calcPoint( double x, double y, QgsPoint &result SIP_OUT ) = 0;
      80                 :            : 
      81                 :            :     //! Returns a pointer to the point with number i.
      82                 :            :     virtual QgsPoint *point( int i ) const = 0;
      83                 :            : 
      84                 :            :     /**
      85                 :            :      * Finds out in which triangle the point with coordinates x and y is and
      86                 :            :      * assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'
      87                 :            :      */
      88                 :            :     virtual bool triangleVertices( double x, double y, QgsPoint &p1 SIP_OUT, int &n1 SIP_OUT, QgsPoint &p2 SIP_OUT, int &n2 SIP_OUT, QgsPoint &p3 SIP_OUT, int &n3 SIP_OUT ) = 0;
      89                 :            : 
      90                 :            :     //! 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
      91                 :            :     virtual bool triangleVertices( double x, double y, QgsPoint &p1 SIP_OUT, QgsPoint &p2 SIP_OUT, QgsPoint &p3 SIP_OUT ) = 0;
      92                 :            : 
      93                 :            :     /**
      94                 :            :      * Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge).
      95                 :            :      *
      96                 :            :      * Returns -1 if point is a virtual point.
      97                 :            :      * Returns -10 if point crosses over edges.
      98                 :            :      */
      99                 :            :     virtual int oppositePoint( int p1, int p2 ) = 0;
     100                 :            : 
     101                 :            :     //! Returns the largest x-coordinate value of the bounding box
     102                 :            :     virtual double xMax() const = 0;
     103                 :            : 
     104                 :            :     //! Returns the smallest x-coordinate value of the bounding box
     105                 :            :     virtual double xMin() const = 0;
     106                 :            : 
     107                 :            :     //! Returns the largest y-coordinate value of the bounding box
     108                 :            :     virtual double yMax() const = 0;
     109                 :            : 
     110                 :            :     //! Returns the smallest x-coordinate value of the bounding box
     111                 :            :     virtual double yMin() const = 0;
     112                 :            : 
     113                 :            :     //! Returns the number of points
     114                 :            :     virtual int pointsCount() const = 0;
     115                 :            : 
     116                 :            :     /**
     117                 :            :      * Returns a value list with the information of the triangles surrounding (counterclockwise) a point.
     118                 :            :      * Four integer values describe a triangle, the first three are the number of the half edges of the triangle
     119                 :            :      * and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise.
     120                 :            :      * Any virtual point needs to have the number -1
     121                 :            :      */
     122                 :            :     virtual QList<int> surroundingTriangles( int pointno ) = 0;
     123                 :            : 
     124                 :            :     /**
     125                 :            :      * Returns a value list with the numbers of the four points, which would be affected by an edge swap.
     126                 :            :      * This function is e.g. needed by NormVecDecorator to know the points,
     127                 :            :      * for which the normals have to be recalculated.
     128                 :            :      * The list has to be deleted by the code which calls this method
     129                 :            :      */
     130                 :            :     virtual QList<int> pointsAroundEdge( double x, double y ) = 0;
     131                 :            : 
     132                 :            :     //! Draws the points, edges and the forced lines
     133                 :            :     //virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const=0;
     134                 :            : 
     135                 :            :     //! Sets the behavior of the triangulation in case of crossing forced lines
     136                 :            :     virtual void setForcedCrossBehavior( QgsTriangulation::ForcedCrossBehavior b ) = 0;
     137                 :            : 
     138                 :            :     //! Sets an interpolator object
     139                 :            :     virtual void setTriangleInterpolator( TriangleInterpolator *interpolator ) = 0;
     140                 :            : 
     141                 :            :     //! Eliminates the horizontal triangles by swapping
     142                 :            :     virtual void eliminateHorizontalTriangles() = 0;
     143                 :            : 
     144                 :            :     //! Adds points to make the triangles better shaped (algorithm of ruppert)
     145                 :            :     virtual void ruppertRefinement() = 0;
     146                 :            : 
     147                 :            :     //! Returns TRUE, if the point with coordinates x and y is inside the convex hull and FALSE otherwise
     148                 :            :     virtual bool pointInside( double x, double y ) = 0;
     149                 :            : 
     150                 :            :     //! Reads the content of a taff-file
     151                 :            :     //virtual bool readFromTAFF(QString fileName)=0;
     152                 :            : 
     153                 :            :     //! Saves the content to a taff file
     154                 :            :     //virtual bool saveToTAFF(QString fileName) const=0;
     155                 :            : 
     156                 :            :     //! Swaps the edge which is closest to the point with x and y coordinates (if this is possible)
     157                 :            :     virtual bool swapEdge( double x, double y ) = 0;
     158                 :            : 
     159                 :            :     /**
     160                 :            :      * Returns the fields output by features when calling
     161                 :            :      * saveTriangulation(). These fields should be used when creating
     162                 :            :      * a suitable feature sink for saveTriangulation()
     163                 :            :      * \see saveTriangulation()
     164                 :            :      * \since QGIS 3.0
     165                 :            :      */
     166                 :            :     static QgsFields triangulationFields();
     167                 :            : 
     168                 :            :     /**
     169                 :            :      * Saves the triangulation features to a feature \a sink.
     170                 :            :      *
     171                 :            :      * The sink must be setup to accept LineString features, with fields matching
     172                 :            :      * those returned by triangulationFields().
     173                 :            :      *
     174                 :            :      * \returns TRUE in case of success
     175                 :            :      *
     176                 :            :      * \see triangulationFields()
     177                 :            :      *  \since QGIS 3.0
     178                 :            :      */
     179                 :            :     virtual bool saveTriangulation( QgsFeatureSink *sink, QgsFeedback *feedback = nullptr ) const = 0;
     180                 :            : 
     181                 :            :     /**
     182                 :            :      * Returns a QgsMesh corresponding to the triangulation
     183                 :            :      *
     184                 :            :      * \since QGIS 3.16
     185                 :            :      */
     186                 :            :     virtual QgsMesh triangulationToMesh( QgsFeedback *feedback = nullptr ) const = 0;
     187                 :            : };
     188                 :            : 
     189                 :            : #endif

Generated by: LCOV version 1.14