QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
56 addVerticesFromFeature( feat, valueAttribute, transform, feedback );
84 addVerticesFromFeature( feat, valueAttribute, transform, feedback );
88 addBreakLinesFromFeature( feat, valueAttribute, transform, feedback );
100 return mTriangulation->addPoint( vertex );
105 return mTriangulation->triangulationToMesh( feedback );
118 geom.
transform( transform, Qgis::TransformDirection::Forward,
true );
130 if ( valueAttribute >= 0 )
131 value = feature.
attribute( valueAttribute ).toDouble();
137 if ( valueAttribute < 0 )
138 mTriangulation->addPoint( *vit );
149 double valueOnVertex = 0;
150 if ( valueAttribute >= 0 )
151 valueOnVertex = feature.
attribute( valueAttribute ).toDouble();
154 std::vector<const QgsCurve *> curves;
158 geom.
transform( transform, Qgis::TransformDirection::Forward,
true );
169 std::vector< const QgsCurvePolygon * > polygons;
175 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( ms->
geometryN( i ) ) );
180 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( geom.
constGet() ) );
190 if ( polygon->exteriorRing() )
191 curves.emplace_back( polygon->exteriorRing() );
193 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
197 curves.emplace_back( polygon->interiorRing( i ) );
210 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( mc->
geometryN( i ) ) );
215 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( geom.
constGet() ) );
219 for (
const QgsCurve *curve : curves )
228 curve->points( linePoints );
229 bool hasZ = curve->is3D();
230 if ( valueAttribute >= 0 )
231 for (
int i = 0; i < linePoints.count(); ++i )
236 linePoints[i].setZ( valueOnVertex );
239 const QgsPoint &point = linePoints.at( i );
240 linePoints[i] =
QgsPoint( point.
x(), point.
y(), valueOnVertex );
251 mDataset = std::make_unique< QgsMeshZValueDataset >( mesh );
261 if ( datasetIndex != 0 )
264 return mDataset->metadata();
274 return mDataset.get();
281 return QDomElement();
288 if ( vertex.
z() < mZMinimum )
289 mZMinimum = vertex.
z();
290 if ( vertex.
z() > mZMaximum )
291 mZMaximum = vertex.
z();
297 if ( valueIndex < 0 || valueIndex >= mMesh.
vertexCount() )
307 QVector<double> zValues( count );
308 for (
int i = valueIndex; i < valueIndex + count; ++i )
309 zValues[i - valueIndex] = mMesh.
vertex( i ).
z();
316 Q_UNUSED( faceIndex );
325 return ( faceIndex > 0 && faceIndex < mMesh.
faceCount() );
342 return QObject::tr(
"Delaunay triangulation" );
348 QList<int> vertexIndextoTriangulate;
350 QList<int> removedVerticesFromTriangulation;
355 vertexIndextoTriangulate.append( vertexIndex );
357 removedVerticesFromTriangulation.append( vertexIndex );
360 bool triangulationReady =
false;
364 while ( !triangulationReady )
368 QVector<int> triangulationVertexToMeshVertex( vertexIndextoTriangulate.count() );
371 for (
int i = 0; i < vertexIndextoTriangulate.count(); ++i )
373 triangulationVertexToMeshVertex[i] = vertexIndextoTriangulate.at( i );
374 triangulation.
addVertex( destinationMesh->
vertices.at( vertexIndextoTriangulate.at( i ) ) );
380 QVector<QgsMeshFace> rawDestinationFaces = resultingTriangulation.
faces;
382 for (
QgsMeshFace &destinationFace : rawDestinationFaces )
384 for (
int &vertexIndex : destinationFace )
385 vertexIndex = triangulationVertexToMeshVertex[vertexIndex];
389 QVector<QgsMeshFace> destinationFaces;
390 for (
const QgsMeshFace &face : rawDestinationFaces )
393 destinationFaces.append( face );
396 bool facesReady =
false;
398 while ( !facesReady && !giveUp )
410 triangulationReady =
true;
426 removedVerticesFromTriangulation.append( error.
elementIndex );
427 vertexIndextoTriangulate.removeOne( error.
elementIndex );
438 if ( !removedVerticesFromTriangulation.isEmpty() )
439 mMessage = QObject::tr(
"%n vertices have not been included in the triangulation",
nullptr, removedVerticesFromTriangulation.count() );
443 if ( triangulationReady && !giveUp )
Abstract base class for curved geometry type.
void setProgress(double progress)
Sets the current progress for the feedback object.
QgsMeshDatasetMetadata datasetMetadata(int datasetIndex) const override
Returns the metadata of the dataset with index datasetIndex.
bool isVertexFree(int vertexIndex) const
Returns whether the vertex with index vertexIndex is a free vertex.
Class that contains independent faces an topological information about this faces.
QString text() const override
Returns a short text string describing what this advanced edit does. Default implementation return a ...
The class is used as a container of context for various read/write operations on other objects.
@ ScalarDouble
Scalar double values.
~QgsMeshTriangulation()
Destructor.
@ FlatFace
A flat face is present.
Class that contains topological differences between two states of a topological mesh,...
Point geometry type, with support for z-dimension and m-values.
#define QgsDebugMsgLevel(str, level)
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
const QgsCoordinateReferenceSystem & crs
Curve polygon geometry type.
QgsMeshDatasetValue represents single dataset value.
QgsMeshDataBlock areFacesActive(int faceIndex, int count) const override
Returns whether faces are active.
int valuesCount() const override
Returns the values count.
Abstract class that represents a dataset.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
QgsMeshDatasetValue datasetValue(int valueIndex) const override
Returns the value with index valueIndex.
Mesh - vertices, edges and faces.
QgsMeshTriangulation()
Constructor.
Multi surface geometry collection.
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
Class that makes edit operation on a mesh.
Custom exception class for Coordinate Reference System related exceptions.
int faceCount() const
Returns number of faces.
QgsMeshDataBlock datasetValues(bool isScalar, int valueIndex, int count) const override
Returns count values from valueIndex.
int vertexCount() const
Returns number of vertices.
bool isActive(int faceIndex) const override
Returns whether the face is active.
Multi curve geometry collection.
QVector< QgsMeshFace > faces
Base class for feedback objects to be used for cancellation of something running in a worker thread.
int datasetCount() const override
Returns the count of datasets in the group.
Class that represents an error during mesh editing.
@ InvalidFace
An error occurs due to an invalid face (for example, vertex indexes are unordered)
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
bool addBreakLines(QgsFeatureIterator &lineFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transformContext, QgsFeedback *feedback=nullptr, long featureCount=1)
Adds break lines from a vector layer, return true if successful.
@ InvalidVertex
An error occurs due to an invalid vertex (for example, vertex index is out of range the available ver...
QgsMesh triangulatedMesh(QgsFeedback *feedback=nullptr) const
Returns the triangulated mesh.
Class that handles mesh creation with Delaunay constrained triangulation.
QVector< int > QgsMeshFace
List of vertex indexes.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsMeshEditingError checkConsistency() const
Checks the consistency of the topological mesh and return false if there is a consistency issue.
This class represents a coordinate reference system (CRS).
void setValid(bool valid)
Sets block validity.
Abstract class that represents a dataset group.
bool addVertices(QgsFeatureIterator &vertexFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback=nullptr, long featureCount=1)
Adds vertices to the triangulation from a feature iterator, return true if successful.
QList< int > mInputVertices
void calculateStatistic() const
Calculates the statistics (minimum and maximum)
@ SourceBreakLines
Break lines.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const override
Write dataset group information in a DOM element.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
The vertex_iterator class provides STL-style iterator for vertices.
bool nextFeature(QgsFeature &f)
QVector< QgsPoint > QgsPointSequence
A geometry is the spatial representation of a feature.
@ ActiveFlagInteger
Integer boolean flag whether face is active.
@ ManifoldFace
ManifoldFace.
void setValues(const QVector< double > &vals)
Sets values.
QgsMeshZValueDatasetGroup(const QString &datasetGroupName, const QgsMesh &mesh)
Constructor.
QVector< QgsMeshVertex > vertices
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the coordinate reference system used for the triangulation.
QgsMeshZValueDataset(const QgsMesh &mesh)
Constructor with the mesh.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Changes addFaces(const TopologicalFaces &topologicFaces)
Adds faces topologicFaces to the topologic mesh.
QgsMeshEditingDelaunayTriangulation()
Constructor.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
bool isVertexOnBoundary(int vertexIndex) const
Returns whether the vertex with index vertexIndex is on a boundary.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Qgis::MeshEditingErrorType errorType
@ TooManyVerticesInFace
A face has more vertices than the maximum number supported per face.
QgsMeshDataset * dataset(int index) const override
Returns the dataset with index.
static TopologicalFaces createNewTopologicalFaces(const QVector< QgsMeshFace > &faces, bool uniqueSharedVertexAllowed, QgsMeshEditingError &error)
Creates new topological faces that are not yet included in the mesh.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsWkbTypes::GeometryType type
QgsMesh * mesh() const
Returns a pointer to the wrapped mesh.
QgsMeshVertex vertex(int index) const
Returns a vertex at the index.
Wrapper for iterator of features from vector data provider or vector layer.
bool isFaceGeometricallyCompatible(const QgsMeshFace &face)
Returns true if the face does not intersect or contains any other elements (faces or vertices) The to...
QgsMeshDatasetMetadata metadata() const override
Returns the metadata of the dataset.
QgsTopologicalMesh & topologicalMesh()
Returns a reference to the topological mesh.
void initialize() override
Initialize the dataset group.
QgsMeshEditingError facesCanBeAdded(const TopologicalFaces &topologicalFaces) const
Returns whether the faces can be added to the mesh.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
int addVertex(const QgsPoint &vertex)
Adds a new vertex in the triangulation and returns the index of the new vertex.
@ UniqueSharedVertex
A least two faces share only one vertices.
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...