mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
fix build errors, use MDAL 0.0.2 (int API)
This commit is contained in:
parent
50422a1165
commit
1efdbc5c20
20
external/mdal/api/mdal.h
vendored
20
external/mdal/api/mdal.h
vendored
@ -36,10 +36,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Statuses */
|
||||
enum Status
|
||||
enum MDAL_Status
|
||||
{
|
||||
None,
|
||||
// Errors
|
||||
@ -57,14 +55,14 @@ enum Status
|
||||
Warn_NodeNotUnique
|
||||
};
|
||||
|
||||
/* Mesh */
|
||||
//! Mesh
|
||||
typedef void *MeshH;
|
||||
|
||||
//! Return MDAL version
|
||||
MDAL_EXPORT const char *MDAL_Version();
|
||||
|
||||
//! Return last status message
|
||||
MDAL_EXPORT Status MDAL_LastStatus();
|
||||
MDAL_EXPORT MDAL_Status MDAL_LastStatus();
|
||||
|
||||
//! Load mesh file. On error see MDAL_LastStatus for error type This effectively loads whole mesh in-memory
|
||||
MDAL_EXPORT MeshH MDAL_LoadMesh( const char *meshFile );
|
||||
@ -72,17 +70,17 @@ MDAL_EXPORT MeshH MDAL_LoadMesh( const char *meshFile );
|
||||
MDAL_EXPORT void MDAL_CloseMesh( MeshH mesh );
|
||||
|
||||
//! Return vertex count for the mesh
|
||||
MDAL_EXPORT size_t MDAL_M_vertexCount( MeshH mesh );
|
||||
MDAL_EXPORT int MDAL_M_vertexCount( MeshH mesh );
|
||||
//! Return vertex X coord for the mesh
|
||||
MDAL_EXPORT double MDAL_M_vertexXCoordinatesAt( MeshH mesh, size_t index );
|
||||
MDAL_EXPORT double MDAL_M_vertexXCoordinatesAt( MeshH mesh, int index );
|
||||
//! Return vertex Y coord for the mesh
|
||||
MDAL_EXPORT double MDAL_M_vertexYCoordinatesAt( MeshH mesh, size_t index );
|
||||
MDAL_EXPORT double MDAL_M_vertexYCoordinatesAt( MeshH mesh, int index );
|
||||
//! Return face count for the mesh
|
||||
MDAL_EXPORT size_t MDAL_M_faceCount( MeshH mesh );
|
||||
MDAL_EXPORT int MDAL_M_faceCount( MeshH mesh );
|
||||
//! Return number of vertices face consist of, e.g. 3 for triangle
|
||||
MDAL_EXPORT size_t MDAL_M_faceVerticesCountAt( MeshH mesh, size_t index );
|
||||
MDAL_EXPORT int MDAL_M_faceVerticesCountAt( MeshH mesh, int index );
|
||||
//! Return vertex index for face
|
||||
MDAL_EXPORT size_t MDAL_M_faceVerticesIndexAt( MeshH mesh, size_t face_index, size_t vertex_index );
|
||||
MDAL_EXPORT int MDAL_M_faceVerticesIndexAt( MeshH mesh, int face_index, int vertex_index );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
20
external/mdal/frmts/mdal_2dm.cpp
vendored
20
external/mdal/frmts/mdal_2dm.cpp
vendored
@ -22,13 +22,13 @@ MDAL::Loader2dm::Loader2dm( const std::string &meshFile ):
|
||||
{
|
||||
}
|
||||
|
||||
MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
MDAL::Mesh *MDAL::Loader2dm::load( MDAL_Status *status )
|
||||
{
|
||||
if ( status ) *status = Status::None;
|
||||
if ( status ) *status = MDAL_Status::None;
|
||||
|
||||
if ( !MDAL::fileExists( mMeshFile ) )
|
||||
{
|
||||
if ( status ) *status = Status::Err_FileNotFound;
|
||||
if ( status ) *status = MDAL_Status::Err_FileNotFound;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
std::string line;
|
||||
if ( !std::getline( in, line ) || !startsWith( line, "MESH2D" ) )
|
||||
{
|
||||
if ( status ) *status = Status::Err_UnknownFormat;
|
||||
if ( status ) *status = MDAL_Status::Err_UnknownFormat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
startsWith( line, "E8Q" ) ||
|
||||
startsWith( line, "E9Q" ) )
|
||||
{
|
||||
if ( status ) *status = Status::Warn_UnsupportedElement;
|
||||
if ( status ) *status = MDAL_Status::Warn_UnsupportedElement;
|
||||
elemCount += 1; // We still count them as elements
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
std::map<size_t, size_t>::iterator search = elemIDtoIndex.find( elemID );
|
||||
if ( search != elemIDtoIndex.end() )
|
||||
{
|
||||
if ( status ) *status = Status::Warn_ElementNotUnique;
|
||||
if ( status ) *status = MDAL_Status::Warn_ElementNotUnique;
|
||||
continue;
|
||||
}
|
||||
elemIDtoIndex[elemID] = elemIndex;
|
||||
@ -114,7 +114,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
std::map<size_t, size_t>::iterator search = elemIDtoIndex.find( elemID );
|
||||
if ( search != elemIDtoIndex.end() )
|
||||
{
|
||||
if ( status ) *status = Status::Warn_ElementNotUnique;
|
||||
if ( status ) *status = MDAL_Status::Warn_ElementNotUnique;
|
||||
continue;
|
||||
}
|
||||
elemIDtoIndex[elemID] = elemIndex;
|
||||
@ -143,7 +143,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
std::map<size_t, size_t>::iterator search = elemIDtoIndex.find( elemID );
|
||||
if ( search != elemIDtoIndex.end() )
|
||||
{
|
||||
if ( status ) *status = Status::Warn_ElementNotUnique;
|
||||
if ( status ) *status = MDAL_Status::Warn_ElementNotUnique;
|
||||
continue;
|
||||
}
|
||||
elemIDtoIndex[elemID] = elemIndex;
|
||||
@ -159,7 +159,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
std::map<size_t, size_t>::iterator search = nodeIDtoIndex.find( nodeID );
|
||||
if ( search != nodeIDtoIndex.end() )
|
||||
{
|
||||
if ( status ) *status = Status::Warn_NodeNotUnique;
|
||||
if ( status ) *status = MDAL_Status::Warn_NodeNotUnique;
|
||||
continue;
|
||||
}
|
||||
nodeIDtoIndex[nodeID] = nodeIndex;
|
||||
@ -188,7 +188,7 @@ MDAL::Mesh *MDAL::Loader2dm::load( Status *status )
|
||||
{
|
||||
assert( false ); //TODO mark element as unusable
|
||||
|
||||
if ( status ) *status = Status::Warn_ElementWithInvalidNode;
|
||||
if ( status ) *status = MDAL_Status::Warn_ElementWithInvalidNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
external/mdal/frmts/mdal_2dm.hpp
vendored
2
external/mdal/frmts/mdal_2dm.hpp
vendored
@ -18,7 +18,7 @@ namespace MDAL
|
||||
{
|
||||
public:
|
||||
Loader2dm( const std::string &meshFile );
|
||||
Mesh *load( Status *status );
|
||||
Mesh *load( MDAL_Status *status );
|
||||
|
||||
private:
|
||||
std::string mMeshFile;
|
||||
|
54
external/mdal/mdal.cpp
vendored
54
external/mdal/mdal.cpp
vendored
@ -6,14 +6,14 @@
|
||||
#include "mdal_loader.hpp"
|
||||
#include "mdal_defines.hpp"
|
||||
|
||||
static Status sLastStatus;
|
||||
static MDAL_Status sLastStatus;
|
||||
|
||||
const char *MDAL_Version()
|
||||
{
|
||||
return "0.0.1";
|
||||
return "0.0.2";
|
||||
}
|
||||
|
||||
Status MDAL_LastStatus()
|
||||
MDAL_Status MDAL_LastStatus()
|
||||
{
|
||||
return sLastStatus;
|
||||
}
|
||||
@ -38,49 +38,63 @@ void MDAL_CloseMesh( MeshH mesh )
|
||||
}
|
||||
|
||||
|
||||
size_t MDAL_M_vertexCount( MeshH mesh )
|
||||
int MDAL_M_vertexCount( MeshH mesh )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
return m->vertices.size();
|
||||
int len = static_cast<int>( m->vertices.size() );
|
||||
return len;
|
||||
}
|
||||
|
||||
double MDAL_M_vertexXCoordinatesAt( MeshH mesh, size_t index )
|
||||
double MDAL_M_vertexXCoordinatesAt( MeshH mesh, int index )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
assert( m->vertices.size() > index );
|
||||
return m->vertices[index].x;
|
||||
assert( index > -1 );
|
||||
size_t i = static_cast<size_t>( index );
|
||||
assert( m->vertices.size() > i );
|
||||
return m->vertices[i].x;
|
||||
}
|
||||
|
||||
double MDAL_M_vertexYCoordinatesAt( MeshH mesh, size_t index )
|
||||
double MDAL_M_vertexYCoordinatesAt( MeshH mesh, int index )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
assert( m->vertices.size() > index );
|
||||
return m->vertices[index].y;
|
||||
assert( index > -1 );
|
||||
size_t i = static_cast<size_t>( index );
|
||||
assert( m->vertices.size() > i );
|
||||
return m->vertices[i].y;
|
||||
}
|
||||
|
||||
size_t MDAL_M_faceCount( MeshH mesh )
|
||||
int MDAL_M_faceCount( MeshH mesh )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
return m->faces.size();
|
||||
int len = static_cast<int>( m->faces.size() );
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t MDAL_M_faceVerticesCountAt( MeshH mesh, size_t index )
|
||||
int MDAL_M_faceVerticesCountAt( MeshH mesh, int index )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
assert( m->faces.size() > index );
|
||||
return m->faces[index].size();
|
||||
assert( index > -1 );
|
||||
size_t i = static_cast<size_t>( index );
|
||||
assert( m->faces.size() > i );
|
||||
int len = static_cast<int>( m->faces[i].size() );
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t MDAL_M_faceVerticesIndexAt( MeshH mesh, size_t face_index, size_t vertex_index )
|
||||
int MDAL_M_faceVerticesIndexAt( MeshH mesh, int face_index, int vertex_index )
|
||||
{
|
||||
assert( mesh );
|
||||
MDAL::Mesh *m = ( MDAL::Mesh * ) mesh;
|
||||
assert( m->faces.size() > face_index );
|
||||
assert( m->faces[face_index].size() > vertex_index );
|
||||
return m->faces[face_index][vertex_index];
|
||||
assert( face_index > -1 );
|
||||
size_t fi = static_cast<size_t>( face_index );
|
||||
assert( m->faces.size() > fi );
|
||||
assert( vertex_index > -1 );
|
||||
size_t vi = static_cast<size_t>( vertex_index );
|
||||
assert( m->faces[fi].size() > vi );
|
||||
int len = static_cast<int>( m->faces[fi][vi] );
|
||||
return len;
|
||||
}
|
||||
|
2
external/mdal/mdal_loader.cpp
vendored
2
external/mdal/mdal_loader.cpp
vendored
@ -6,7 +6,7 @@
|
||||
#include "mdal_loader.hpp"
|
||||
#include "frmts/mdal_2dm.hpp"
|
||||
|
||||
MDAL::Mesh *MDAL::Loader::load( const std::string &meshFile, Status *status )
|
||||
MDAL::Mesh *MDAL::Loader::load( const std::string &meshFile, MDAL_Status *status )
|
||||
{
|
||||
MDAL::Loader2dm loader( meshFile );
|
||||
return loader.load( status );
|
||||
|
2
external/mdal/mdal_loader.hpp
vendored
2
external/mdal/mdal_loader.hpp
vendored
@ -17,7 +17,7 @@ namespace MDAL
|
||||
class Loader
|
||||
{
|
||||
public:
|
||||
static Mesh *load( const std::string &meshFile, Status *status );
|
||||
static Mesh *load( const std::string &meshFile, MDAL_Status *status );
|
||||
};
|
||||
|
||||
} // namespace MDAL
|
||||
|
78
images/themes/default/mIconMeshLayer.svg
Normal file
78
images/themes/default/mIconMeshLayer.svg
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="16"
|
||||
width="16"
|
||||
version="1.1"
|
||||
id="svg10"
|
||||
sodipodi:docname="mIconMeshLayer.svg"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
|
||||
<metadata
|
||||
id="metadata16">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs14" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1680"
|
||||
inkscape:window-height="1021"
|
||||
id="namedview12"
|
||||
showgrid="false"
|
||||
inkscape:zoom="14.75"
|
||||
inkscape:cx="8"
|
||||
inkscape:cy="8"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g8" />
|
||||
<g
|
||||
transform="translate(0.06779661,-15.457627)"
|
||||
id="g8"
|
||||
style="fill:#eeeeec;fill-rule:evenodd;stroke:#888a85;stroke-linecap:round;stroke-linejoin:round">
|
||||
<rect
|
||||
id="rect30"
|
||||
width="5.9661016"
|
||||
height="4.7457619"
|
||||
x="1.6949153"
|
||||
y="18.508474" />
|
||||
<rect
|
||||
id="rect32"
|
||||
width="5.762712"
|
||||
height="5.0847459"
|
||||
x="1.7627119"
|
||||
y="23.254236" />
|
||||
<rect
|
||||
id="rect34"
|
||||
width="5.6949148"
|
||||
height="4.7457619"
|
||||
x="7.525424"
|
||||
y="18.508474" />
|
||||
<rect
|
||||
id="rect36"
|
||||
width="5.5593219"
|
||||
height="5.0847468"
|
||||
x="7.6610169"
|
||||
y="23.254236" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
@ -10,9 +10,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
typedef QgsPoint QgsMeshVertex; //xyz coords of vertex
|
||||
typedef QVector<size_t> QgsMeshFace; //list of vertex indexes
|
||||
typedef QVector<int> QgsMeshFace; //list of vertex indexes
|
||||
|
||||
class QgsMeshSource /Abstract/
|
||||
{
|
||||
@ -33,28 +32,28 @@ read on demand
|
||||
public:
|
||||
virtual ~QgsMeshSource();
|
||||
|
||||
virtual size_t vertexCount() const = 0;
|
||||
virtual int vertexCount() const = 0;
|
||||
%Docstring
|
||||
Return number of vertexes in the native mesh
|
||||
Return number of vertices in the native mesh
|
||||
|
||||
:return: Number of vertexes in the mesh
|
||||
:return: Number of vertices in the mesh
|
||||
%End
|
||||
|
||||
virtual size_t faceCount() const = 0;
|
||||
virtual int faceCount() const = 0;
|
||||
%Docstring
|
||||
Return number of faces in the native mesh
|
||||
|
||||
:return: Number of faces in the mesh
|
||||
%End
|
||||
|
||||
virtual QgsMeshVertex vertex( size_t index ) const = 0;
|
||||
virtual QgsMeshVertex vertex( int index ) const = 0;
|
||||
%Docstring
|
||||
Factory for mesh vertex with index
|
||||
|
||||
:return: new mesh vertex on index
|
||||
%End
|
||||
|
||||
virtual QgsMeshFace face( size_t index ) const = 0;
|
||||
virtual QgsMeshFace face( int index ) const = 0;
|
||||
%Docstring
|
||||
Factory for mesh face with index
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsMeshLayer : QgsMapLayer
|
||||
{
|
||||
%Docstring
|
||||
@ -90,29 +88,17 @@ parameters used by the data provider as url query items.
|
||||
virtual QgsMeshDataProvider *dataProvider();
|
||||
|
||||
%Docstring
|
||||
Return data provider
|
||||
QgsMeshLayer cannot be copied.
|
||||
%End
|
||||
|
||||
|
||||
virtual QgsMeshLayer *clone() const /Factory/;
|
||||
|
||||
%Docstring
|
||||
Returns a new instance equivalent to this one. A new provider is
|
||||
created for the same data source and renderers are cloned too.
|
||||
|
||||
:return: a new layer instance
|
||||
%End
|
||||
|
||||
virtual QgsRectangle extent() const;
|
||||
|
||||
%Docstring
|
||||
Returns the extent of the layer.
|
||||
%End
|
||||
|
||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
|
||||
%Docstring
|
||||
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context
|
||||
%End
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context );
|
||||
|
||||
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
||||
QString providerType() const;
|
||||
%Docstring
|
||||
@ -138,30 +124,7 @@ Returns a line symbol used for rendering of triangular (derived) mesh.
|
||||
Toggle rendering of triangular (derived) mesh. Off by default
|
||||
%End
|
||||
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context );
|
||||
%Docstring
|
||||
Read the symbology for the current layer from the Dom node supplied.
|
||||
|
||||
:param node: node that will contain the symbology definition for this layer.
|
||||
:param errorMessage: reference to string that will be updated with any error messages
|
||||
:param context: reading context (used for transform from relative to absolute paths)
|
||||
|
||||
:return: true in case of success.
|
||||
%End
|
||||
|
||||
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const;
|
||||
%Docstring
|
||||
Write the symbology for the layer into the docment provided.
|
||||
|
||||
:param node: the node that will have the style element added to it.
|
||||
:param doc: the document that will have the QDomNode added.
|
||||
:param errorMessage: reference to string that will be updated with any error messages
|
||||
:param context: writing context (used for transform from absolute to relative paths)
|
||||
|
||||
:return: true in case of success.
|
||||
%End
|
||||
|
||||
private: // Private methods
|
||||
private: // Private methods
|
||||
QgsMeshLayer( const QgsMeshLayer &rhs );
|
||||
};
|
||||
|
||||
|
@ -472,6 +472,9 @@ Returns the icon name of the given ``layerType``
|
||||
static QIcon iconRaster();
|
||||
static QIcon iconDefault();
|
||||
static QIcon iconMesh();
|
||||
%Docstring
|
||||
Return icon for mesh layer type
|
||||
%End
|
||||
|
||||
virtual QString layerName() const;
|
||||
%Docstring
|
||||
|
@ -27,7 +27,7 @@ QgsRectangle QgsMeshDataProvider::extent() const
|
||||
{
|
||||
QgsRectangle rec;
|
||||
rec.setMinimal();
|
||||
for ( size_t i = 0; i < vertexCount(); ++i )
|
||||
for ( int i = 0; i < vertexCount(); ++i )
|
||||
{
|
||||
QgsMeshVertex v = vertex( i );
|
||||
rec.setXMinimum( std::min( rec.xMinimum(), v.x() ) );
|
||||
|
@ -18,22 +18,16 @@
|
||||
#ifndef QGSMESHDATAPROVIDER_H
|
||||
#define QGSMESHDATAPROVIDER_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgis.h"
|
||||
#include "qgspoint.h"
|
||||
#include "qgsrectangle.h"
|
||||
#include "qgsdataprovider.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
typedef QgsPoint QgsMeshVertex; //xyz coords of vertex
|
||||
typedef QVector<size_t> QgsMeshFace; //list of vertex indexes
|
||||
typedef QVector<int> QgsMeshFace; //list of vertex indexes
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
@ -53,28 +47,28 @@ class CORE_EXPORT QgsMeshSource SIP_ABSTRACT
|
||||
virtual ~QgsMeshSource() = default;
|
||||
|
||||
/**
|
||||
* \brief Return number of vertexes in the native mesh
|
||||
* \returns Number of vertexes in the mesh
|
||||
* \brief Return number of vertices in the native mesh
|
||||
* \returns Number of vertices in the mesh
|
||||
*/
|
||||
virtual size_t vertexCount() const = 0;
|
||||
virtual int vertexCount() const = 0;
|
||||
|
||||
/**
|
||||
* \brief Return number of faces in the native mesh
|
||||
* \returns Number of faces in the mesh
|
||||
*/
|
||||
virtual size_t faceCount() const = 0;
|
||||
virtual int faceCount() const = 0;
|
||||
|
||||
/**
|
||||
* \brief Factory for mesh vertex with index
|
||||
* \returns new mesh vertex on index
|
||||
*/
|
||||
virtual QgsMeshVertex vertex( size_t index ) const = 0;
|
||||
virtual QgsMeshVertex vertex( int index ) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Factory for mesh face with index
|
||||
* \returns new mesh face on index
|
||||
*/
|
||||
virtual QgsMeshFace face( size_t index ) const = 0;
|
||||
virtual QgsMeshFace face( int index ) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -14,19 +14,18 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgis.h"
|
||||
#include "qgsmaplayerrenderer.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsmeshlayerrenderer.h"
|
||||
#include "qgstriangularmesh.h"
|
||||
#include "qgssinglesymbolrenderer.h"
|
||||
#include "qgsmeshmemorydataprovider.h"
|
||||
#include "qgsfillsymbollayer.h"
|
||||
#include "qgsproviderregistry.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgsmeshlayerrenderer.h"
|
||||
#include "qgsproviderregistry.h"
|
||||
#include "qgstriangularmesh.h"
|
||||
|
||||
QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
|
||||
const QString &baseName,
|
||||
@ -96,6 +95,14 @@ QString QgsMeshLayer::providerType() const
|
||||
return mProviderKey;
|
||||
}
|
||||
|
||||
QgsMesh *QgsMeshLayer::nativeMesh() SIP_SKIP {return mNativeMesh;}
|
||||
|
||||
QgsTriangularMesh *QgsMeshLayer::triangularMesh() SIP_SKIP {return mTriangularMesh;}
|
||||
|
||||
QgsSymbol *QgsMeshLayer::nativeMeshSymbol() {return mNativeMeshSymbol;}
|
||||
|
||||
QgsSymbol *QgsMeshLayer::triangularMeshSymbol() {return mTriangularMeshSymbol;}
|
||||
|
||||
void QgsMeshLayer::toggleTriangularMeshRendering( bool toggle )
|
||||
{
|
||||
if ( toggle && mTriangularMeshSymbol )
|
||||
@ -127,13 +134,13 @@ void QgsMeshLayer::fillNativeMesh()
|
||||
return;
|
||||
|
||||
mNativeMesh->vertices.resize( dataProvider()->vertexCount() );
|
||||
for ( size_t i = 0; i < dataProvider()->vertexCount(); ++i )
|
||||
for ( int i = 0; i < dataProvider()->vertexCount(); ++i )
|
||||
{
|
||||
mNativeMesh->vertices[i] = dataProvider()->vertex( i );
|
||||
}
|
||||
|
||||
mNativeMesh->faces.resize( dataProvider()->faceCount() );
|
||||
for ( size_t i = 0; i < dataProvider()->faceCount(); ++i )
|
||||
for ( int i = 0; i < dataProvider()->faceCount(); ++i )
|
||||
{
|
||||
mNativeMesh->faces[i] = dataProvider()->face( i );
|
||||
}
|
||||
|
@ -19,24 +19,12 @@
|
||||
#define QGSMESHLAYER_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QFont>
|
||||
#include <QMutex>
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgsrendercontext.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
|
||||
class QgsMapLayerRenderer;
|
||||
class QgsSymbol;
|
||||
|
||||
class QgsMeshDataProvider;
|
||||
class QgsNativeMesh;
|
||||
class QgsTriangularMesh;
|
||||
struct QgsMesh;
|
||||
|
||||
@ -110,7 +98,6 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
|
||||
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
|
||||
*/
|
||||
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
|
||||
//! Dtor
|
||||
~QgsMeshLayer() override;
|
||||
|
||||
//! QgsMeshLayer cannot be copied.
|
||||
@ -118,68 +105,36 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
|
||||
//! QgsMeshLayer cannot be copied.
|
||||
QgsMeshLayer &operator=( QgsMeshLayer const &rhs ) = delete;
|
||||
|
||||
//! Return data provider
|
||||
QgsMeshDataProvider *dataProvider() override;
|
||||
|
||||
//! Return const data provider
|
||||
const QgsMeshDataProvider *dataProvider() const override SIP_SKIP;
|
||||
|
||||
/**
|
||||
* Returns a new instance equivalent to this one. A new provider is
|
||||
* created for the same data source and renderers are cloned too.
|
||||
* \returns a new layer instance
|
||||
*/
|
||||
QgsMeshLayer *clone() const override SIP_FACTORY;
|
||||
|
||||
//! Returns the extent of the layer.
|
||||
QgsRectangle extent() const override;
|
||||
|
||||
/**
|
||||
* Return new instance of QgsMapLayerRenderer that will be used for rendering of given context
|
||||
*/
|
||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) SIP_FACTORY;
|
||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context ) override;
|
||||
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const override;
|
||||
|
||||
//! Return the provider type for this layer
|
||||
QString providerType() const;
|
||||
|
||||
//! return native mesh (nullprt before rendering)
|
||||
QgsMesh *nativeMesh() SIP_SKIP {return mNativeMesh;}
|
||||
QgsMesh *nativeMesh() SIP_SKIP;
|
||||
|
||||
//! return triangular mesh (nullprt before rendering)
|
||||
QgsTriangularMesh *triangularMesh() SIP_SKIP {return mTriangularMesh;}
|
||||
QgsTriangularMesh *triangularMesh() SIP_SKIP;
|
||||
|
||||
//! Returns a line symbol used for rendering native mesh.
|
||||
QgsSymbol *nativeMeshSymbol() {return mNativeMeshSymbol;}
|
||||
QgsSymbol *nativeMeshSymbol();
|
||||
|
||||
/**
|
||||
* Returns a line symbol used for rendering of triangular (derived) mesh.
|
||||
* \see toggleTriangularMeshRendering
|
||||
*/
|
||||
QgsSymbol *triangularMeshSymbol() {return mTriangularMeshSymbol;}
|
||||
QgsSymbol *triangularMeshSymbol();
|
||||
|
||||
//! Toggle rendering of triangular (derived) mesh. Off by default
|
||||
void toggleTriangularMeshRendering( bool toggle );
|
||||
|
||||
/**
|
||||
* Read the symbology for the current layer from the Dom node supplied.
|
||||
* \param node node that will contain the symbology definition for this layer.
|
||||
* \param errorMessage reference to string that will be updated with any error messages
|
||||
* \param context reading context (used for transform from relative to absolute paths)
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context );
|
||||
|
||||
/**
|
||||
* Write the symbology for the layer into the docment provided.
|
||||
* \param node the node that will have the style element added to it.
|
||||
* \param doc the document that will have the QDomNode added.
|
||||
* \param errorMessage reference to string that will be updated with any error messages
|
||||
* \param context writing context (used for transform from absolute to relative paths)
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const;
|
||||
|
||||
private: // Private methods
|
||||
private: // Private methods
|
||||
|
||||
/**
|
||||
* Returns true if the provider is in read-only mode
|
||||
|
@ -17,18 +17,14 @@
|
||||
|
||||
#include "qgsmeshlayerrenderer.h"
|
||||
|
||||
#include "qgsrenderer.h"
|
||||
#include "qgsrendercontext.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgsexception.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgssinglesymbolrenderer.h"
|
||||
#include "qgsfield.h"
|
||||
#include "qgstriangularmesh.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgspointxy.h"
|
||||
#include "qgsrenderer.h"
|
||||
#include "qgssinglesymbolrenderer.h"
|
||||
#include "qgssymbol.h"
|
||||
|
||||
#include <QPicture>
|
||||
|
||||
|
||||
QgsMeshLayerRenderer::QgsMeshLayerRenderer( QgsMeshLayer *layer, QgsRenderContext &context )
|
||||
|
@ -18,23 +18,15 @@
|
||||
#ifndef QGSMESHLAYERRENDERER_H
|
||||
#define QGSMESHLAYERRENDERER_H
|
||||
|
||||
class QgsRenderContext;
|
||||
class QgsMeshLayer;
|
||||
class QgsMeshVectorFieldRenderer;
|
||||
class QgsSingleSymbolRenderer;
|
||||
class QgsTriangularMesh;
|
||||
class QgsSymbol;
|
||||
|
||||
#define SIP_NO_FILE
|
||||
|
||||
#include <QList>
|
||||
#include <QPainter>
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgsfeedback.h"
|
||||
|
||||
#include "qgsmaplayerrenderer.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsrendercontext.h"
|
||||
#include "qgstriangularmesh.h"
|
||||
|
||||
/**
|
||||
@ -47,9 +39,10 @@ class QgsSymbol;
|
||||
class QgsMeshLayerRenderer : public QgsMapLayerRenderer
|
||||
{
|
||||
public:
|
||||
//! Ctor
|
||||
QgsMeshLayerRenderer( QgsMeshLayer *layer, QgsRenderContext &context );
|
||||
~QgsMeshLayerRenderer() override;
|
||||
|
||||
~QgsMeshLayerRenderer() override;
|
||||
bool render() override;
|
||||
|
||||
private:
|
||||
|
@ -14,11 +14,7 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmeshmemorydataprovider.h"
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <limits>
|
||||
|
||||
static const QString TEXT_PROVIDER_KEY = QStringLiteral( "mesh_memory" );
|
||||
static const QString TEXT_PROVIDER_DESCRIPTION = QStringLiteral( "Mesh memory provider" );
|
||||
@ -127,12 +123,18 @@ bool QgsMeshMemoryDataProvider::addFaces( const QString &def )
|
||||
for ( int j = 0; j < vertices.size(); ++j )
|
||||
{
|
||||
int vertex_id = vertices[j].toInt();
|
||||
face.push_back( vertex_id );
|
||||
if ( face[j] >= mVertices.size() )
|
||||
if ( vertex_id < 0 )
|
||||
{
|
||||
setError( QgsError( QStringLiteral( "Invalid mesh definition, vertex index must be positive value" ), QStringLiteral( "Mesh Memory Provider" ) ) );
|
||||
return false;
|
||||
}
|
||||
if ( mVertices.size() < vertex_id )
|
||||
{
|
||||
setError( QgsError( QStringLiteral( "Invalid mesh definition, missing vertex id defined in face" ), QStringLiteral( "Mesh Memory Provider" ) ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
face.push_back( vertex_id );
|
||||
}
|
||||
faces.push_back( face );
|
||||
}
|
||||
@ -141,23 +143,23 @@ bool QgsMeshMemoryDataProvider::addFaces( const QString &def )
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t QgsMeshMemoryDataProvider::vertexCount() const
|
||||
int QgsMeshMemoryDataProvider::vertexCount() const
|
||||
{
|
||||
return mVertices.size();
|
||||
}
|
||||
|
||||
size_t QgsMeshMemoryDataProvider::faceCount() const
|
||||
int QgsMeshMemoryDataProvider::faceCount() const
|
||||
{
|
||||
return mFaces.size();
|
||||
}
|
||||
|
||||
QgsMeshVertex QgsMeshMemoryDataProvider::vertex( size_t index ) const
|
||||
QgsMeshVertex QgsMeshMemoryDataProvider::vertex( int index ) const
|
||||
{
|
||||
Q_ASSERT( vertexCount() > index );
|
||||
return mVertices[index];
|
||||
}
|
||||
|
||||
QgsMeshFace QgsMeshMemoryDataProvider::face( size_t index ) const
|
||||
QgsMeshFace QgsMeshMemoryDataProvider::face( int index ) const
|
||||
{
|
||||
Q_ASSERT( faceCount() > index );
|
||||
return mFaces[index];
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
///@cond PRIVATE
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "qgis_core.h"
|
||||
@ -72,10 +70,10 @@ class QgsMeshMemoryDataProvider: public QgsMeshDataProvider
|
||||
QString description() const override;
|
||||
QgsCoordinateReferenceSystem crs() const override;
|
||||
|
||||
size_t vertexCount() const override;
|
||||
size_t faceCount() const override;
|
||||
QgsMeshVertex vertex( size_t index ) const override;
|
||||
QgsMeshFace face( size_t index ) const override;
|
||||
int vertexCount() const override;
|
||||
int faceCount() const override;
|
||||
QgsMeshVertex vertex( int index ) const override;
|
||||
QgsMeshFace face( int index ) const override;
|
||||
|
||||
//! Returns the memory provider key
|
||||
static QString providerKey();
|
||||
|
@ -16,12 +16,8 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgstriangularmesh.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsrendercontext.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
|
||||
|
||||
QgsTriangularMesh::QgsTriangularMesh( )
|
||||
{
|
||||
|
@ -21,14 +21,10 @@
|
||||
|
||||
#define SIP_NO_FILE
|
||||
|
||||
#include <QList>
|
||||
#include <QPainter>
|
||||
#include <QVector>
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgis_core.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
class QgsRenderContext;
|
||||
|
||||
|
@ -76,7 +76,6 @@ QIcon QgsLayerItem::iconRaster()
|
||||
|
||||
QIcon QgsLayerItem::iconMesh()
|
||||
{
|
||||
// TODO new icon!
|
||||
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) );
|
||||
}
|
||||
|
||||
|
@ -499,6 +499,7 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
|
||||
static QIcon iconTable();
|
||||
static QIcon iconRaster();
|
||||
static QIcon iconDefault();
|
||||
//! Return icon for mesh layer type
|
||||
static QIcon iconMesh();
|
||||
|
||||
//! \returns the layer name
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "qgsdataitem.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QgsMdalLayerItem : public QgsLayerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -16,10 +16,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmdalprovider.h"
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <limits>
|
||||
#include "mdal.h"
|
||||
|
||||
static const QString TEXT_PROVIDER_KEY = QStringLiteral( "mdal" );
|
||||
static const QString TEXT_PROVIDER_DESCRIPTION = QStringLiteral( "MDAL provider" );
|
||||
@ -57,23 +53,23 @@ QgsMdalProvider::~QgsMdalProvider()
|
||||
MDAL_CloseMesh( mMeshH );
|
||||
}
|
||||
|
||||
size_t QgsMdalProvider::vertexCount() const
|
||||
int QgsMdalProvider::vertexCount() const
|
||||
{
|
||||
if ( mMeshH )
|
||||
return MDAL_M_vertexCount( mMeshH );
|
||||
else
|
||||
return ( size_t ) 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t QgsMdalProvider::faceCount() const
|
||||
int QgsMdalProvider::faceCount() const
|
||||
{
|
||||
if ( mMeshH )
|
||||
return MDAL_M_faceCount( mMeshH );
|
||||
else
|
||||
return ( size_t ) 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QgsMeshVertex QgsMdalProvider::vertex( size_t index ) const
|
||||
QgsMeshVertex QgsMdalProvider::vertex( int index ) const
|
||||
{
|
||||
Q_ASSERT( index < vertexCount() );
|
||||
double x = MDAL_M_vertexXCoordinatesAt( mMeshH, index );
|
||||
@ -82,12 +78,12 @@ QgsMeshVertex QgsMdalProvider::vertex( size_t index ) const
|
||||
return vertex;
|
||||
}
|
||||
|
||||
QgsMeshFace QgsMdalProvider::face( size_t index ) const
|
||||
QgsMeshFace QgsMdalProvider::face( int index ) const
|
||||
{
|
||||
Q_ASSERT( index < faceCount() );
|
||||
QgsMeshFace face;
|
||||
int n_face_vertices = MDAL_M_faceVerticesCountAt( mMeshH, index );
|
||||
for ( size_t j = 0; j < n_face_vertices; ++j )
|
||||
for ( int j = 0; j < n_face_vertices; ++j )
|
||||
{
|
||||
int vertex_index = MDAL_M_faceVerticesIndexAt( mMeshH, index, j );
|
||||
face.push_back( vertex_index );
|
||||
|
@ -16,21 +16,13 @@
|
||||
#ifndef QGSMDALPROVIDER_H
|
||||
#define QGSGDALPROVIDER_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsdataitem.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsrectangle.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDomElement>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
|
||||
#include <mdal.h>
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsmeshdataprovider.h"
|
||||
|
||||
class QMutex;
|
||||
class QgsCoordinateTransform;
|
||||
|
||||
@ -58,10 +50,10 @@ class QgsMdalProvider : public QgsMeshDataProvider
|
||||
QString description() const override;
|
||||
QgsCoordinateReferenceSystem crs() const override;
|
||||
|
||||
size_t vertexCount() const override;
|
||||
size_t faceCount() const override;
|
||||
QgsMeshVertex vertex( size_t index ) const override;
|
||||
QgsMeshFace face( size_t index ) const override;
|
||||
int vertexCount() const override;
|
||||
int faceCount() const override;
|
||||
QgsMeshVertex vertex( int index ) const override;
|
||||
QgsMeshFace face( int index ) const override;
|
||||
|
||||
private:
|
||||
MeshH mMeshH;
|
||||
|
@ -230,7 +230,7 @@ bool QgsGeoPackageCollectionItem::handleDrop( const QMimeData *data, Qt::DropAct
|
||||
}
|
||||
else if ( dropUri.layerType == QStringLiteral( "mesh" ) )
|
||||
{
|
||||
// unsuported
|
||||
// unsupported
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -18,12 +18,6 @@
|
||||
#include "qgstest.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QLabel>
|
||||
#include <QStringList>
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
|
||||
//qgis includes...
|
||||
#include "qgsmaplayer.h"
|
||||
@ -31,8 +25,6 @@
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsproviderregistry.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsmaprenderersequentialjob.h"
|
||||
#include "qgsmeshmemorydataprovider.h"
|
||||
|
||||
/**
|
||||
* \ingroup UnitTests
|
||||
@ -104,14 +96,14 @@ void TestQgsMeshLayer::test_data_provider()
|
||||
QVERIFY( dp->isValid() );
|
||||
QCOMPARE( expectedExtent, dp->extent() );
|
||||
|
||||
QCOMPARE( ( size_t ) 5, dp->vertexCount() );
|
||||
QCOMPARE( 5, dp->vertexCount() );
|
||||
QCOMPARE( QgsMeshVertex( 1000.0, 2000.0 ), dp->vertex( 0 ) );
|
||||
QCOMPARE( QgsMeshVertex( 2000.0, 2000.0 ), dp->vertex( 1 ) );
|
||||
QCOMPARE( QgsMeshVertex( 3000.0, 2000.0 ), dp->vertex( 2 ) );
|
||||
QCOMPARE( QgsMeshVertex( 2000.0, 3000.0 ), dp->vertex( 3 ) );
|
||||
QCOMPARE( QgsMeshVertex( 1000.0, 3000.0 ), dp->vertex( 4 ) );
|
||||
|
||||
QCOMPARE( ( size_t ) 2, dp->faceCount() );
|
||||
QCOMPARE( 2, dp->faceCount() );
|
||||
QgsMeshFace f1;
|
||||
f1 << 0 << 1 << 3 << 4;
|
||||
QCOMPARE( f1, dp->face( 0 ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user