Skip to content
Permalink
Browse files

fix build errors, use MDAL 0.0.2 (int API)

  • Loading branch information
PeterPetrik committed Apr 19, 2018
1 parent 50422a1 commit 1efdbc5c20834d36d006d04833bd554deea35a4e
@@ -36,10 +36,8 @@
extern "C" {
#endif

#include <stddef.h>

/* Statuses */
enum Status
enum MDAL_Status
{
None,
// Errors
@@ -57,32 +55,32 @@ 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 );
//! Close mesh, free the memory
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
}
@@ -22,21 +22,21 @@ 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;
}

std::ifstream in( mMeshFile, std::ifstream::in );
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;
}
}

@@ -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;
@@ -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;
}
@@ -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 );
@@ -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
@@ -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>
@@ -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

0 comments on commit 1efdbc5

Please sign in to comment.
You can’t perform that action at this time.