Structure defining a surface composed of vertices and triangles. More...
#include <Mesh.hpp>
Public Types | |
| typedef sal3d_mesh_triangle | Triangle |
| A triangle belonging to a Mesh. | |
| typedef sal3d_mesh_vertex | Vertex |
| A vertex of a Mesh. | |
| typedef Array1D< Triangle > | Triangles |
| An array of Triangles in a Mesh. | |
| typedef Array1D< Vertex > | Vertices |
| An array of Vertices in a Mesh. | |
Public Member Functions | |
| Mesh (int numVertices=0, int numTriangles=0) | |
| Default constructor. Creates an empty Mesh, with the given number of vertices and triangles. | |
| Mesh (const sal3d::COP &cop) | |
| Constructor from COP. Creates a Mesh with the COP surface. | |
| Mesh (const Mesh &mesh) | |
| Copy constructor. | |
| Mesh (sal3d_mesh mesh) | |
| Constructor from a C sal3d_mesh. Creates a new C++ object that holds it. | |
| Mesh (const Mesh &mesh, const Movement3D &movement) | |
| Constructor from a moved Mesh. | |
| ~Mesh () | |
| Destructor. | |
| void | clear () |
| Clear the Mesh. | |
| bool | isEmpty () |
| Checks if the Mesh is empty. | |
| void | mergeMesh (const Mesh &mesh) |
| Merge the passed Mesh to the current one. | |
| int | getNumTriangles () const |
| Get the number of Triangles of the Mesh. | |
| int | getNumVertices () const |
| Get the number of Vertices of the Mesh. | |
| void | addTriangles (const std::vector< Vertex > &vertices, const std::vector< Triangle > &triangles) |
| Add the list of Vertices and Triangles to the Mesh. | |
| void | addTriangles (const Vertices &vertices, const Triangles &triangles) |
| Add the list of Vertices and Triangles to the Mesh. | |
| const Triangles | getTriangles () const |
| Get the array of Triangles that define the Mesh. | |
| Triangles | getTriangles () |
| Get the array of Triangles that define the Mesh. | |
| const Vertices | getVertices () const |
| Get the array of Vertices that comprise the Mesh. | |
| Vertices | getVertices () |
| Get the array of Vertices that comprise the Mesh. | |
| void | exportToBinaryPLY (const std::string &filename) const |
| Export the Mesh to a PLY binary file. | |
| void | exportToASCIIPLY (const std::string &filename) const |
| Export the Mesh to a PLY ASCII file. | |
| void | exportToBinarySTL (const std::string &filename, const std::string &header=std::string("")) const |
| Export the Mesh to a STL binary file. | |
| void | exportToASCIISTL (const std::string &filename) const |
| Export the Mesh to a STL ASCII file. | |
| Mesh & | operator= (const Mesh &aMesh) |
| Assignment operator. | |
| sal3d_mesh | c_mesh () const |
| Returns the pointer to the internal C mesh. | |
| void | glPaintPoints () const |
| Issue gl instructions to paint the Mesh as points. | |
| void | glPaintRandomPoints (int num_points) const |
| Paints numberPoints random points of the Mesh. | |
| void | glPaintPolygons () const |
| Issue gl instructions to paint the Mesh as polygons. | |
| Mesh | copy () const |
| Get a deep copy of the Mesh. | |
| void | cropGL (const Projection2D &projection, const Polygon2D &polygon2d, bool keepInsidePoints=true) |
| Crop the Mesh as defined by a Polygon2D. | |
| void | cropGL (const std::vector< Projection2D > &projections, const std::vector< Polygon2D > &polygons, bool keepInsidePoints=true) |
| Crop the Mesh as defined by a set of Polygon2D objects. | |
Static Public Member Functions | |
| static Mesh | MeshFromPLY (const std::string &filename) |
| Creates a Mesh from a PLY file. | |
| static Mesh | MeshFromSTL (const std::string &filename) |
| Creates a Mesh from a STL file. | |
Structure defining a surface composed of vertices and triangles.
This class requires linking with core3d.lib (import library for core3d.dll).
A Mesh is a structure that defines a surface composed of a series of points and triangles.
In sal3d, a Mesh is the result of using the Integrator tool. This objects can then be exported to both PLY and STL file formats, to be read in many of the common programs that deal with 3D structures.
It is also possible to get the Vertices and Triangles of a Mesh through the appropriate methods, and to add more Vertices and Triangles with the use of addTriangles.
| sal3d::Mesh::Mesh | ( | int | numVertices = 0, |
| int | numTriangles = 0 |
||
| ) | [inline] |
Default constructor. Creates an empty Mesh, with the given number of vertices and triangles.
| sal3d::Error | On error |
Referenced by copy(), MeshFromPLY(), and MeshFromSTL().
| sal3d::Mesh::Mesh | ( | const sal3d::COP & | cop | ) | [inline] |
Constructor from COP. Creates a Mesh with the COP surface.
| sal3d::Error | On error |
References sal3d::COP::c_cop().
| sal3d::Mesh::Mesh | ( | const Mesh & | mesh | ) | [inline] |
Copy constructor.
| sal3d::Error | On error |
| sal3d::Mesh::Mesh | ( | sal3d_mesh | mesh | ) | [inline, explicit] |
Constructor from a C sal3d_mesh. Creates a new C++ object that holds it.
mesh. That means that you should not call sal3d_mesh_release() on this mesh, otherwise it would be called twice.| [in] | mesh | The C sal3d_mesh used to create this object. |
| sal3d::Error | On error |
| sal3d::Mesh::Mesh | ( | const Mesh & | mesh, |
| const Movement3D & | movement | ||
| ) | [inline] |
Constructor from a moved Mesh.
| [in] | mesh | The original Mesh to be moved. |
| [in] | movement | The Movement3D matrix that specifies the transformation to be applied to the mesh. |
| sal3d::Error | On error |
References c_mesh(), and sal3d::Movement3D::c_movement_3d().
| sal3d::Mesh::~Mesh | ( | ) | [inline] |
Destructor.
If the reference counter reaches zero, the object is destroyed and its memory released.
| void sal3d::Mesh::addTriangles | ( | const std::vector< Vertex > & | vertices, |
| const std::vector< Triangle > & | triangles | ||
| ) | [inline] |
Add the list of Vertices and Triangles to the Mesh.
| [in] | vertices | The vector of vertices to add to the Mesh. |
| [in] | triangles | The vector of triangles to add to the Mesh. |
| sal3d::Error | On error |
Referenced by mergeMesh().
| void sal3d::Mesh::addTriangles | ( | const Vertices & | vertices, |
| const Triangles & | triangles | ||
| ) | [inline] |
Add the list of Vertices and Triangles to the Mesh.
| [in] | vertices | The list of vertices to add to the Mesh. |
| [in] | triangles | The list of triangles to add to the Mesh. |
| sal3d::Error | On error |
References sal3d::Array1D< T >::length().
| sal3d_mesh sal3d::Mesh::c_mesh | ( | ) | const [inline] |
| void sal3d::Mesh::clear | ( | ) | [inline] |
| Mesh sal3d::Mesh::copy | ( | ) | const [inline] |
Get a deep copy of the Mesh.
This means that the object and its memory is duplicated. More information about this can be fount at Memory management: reference counting.
| sal3d::Error | On error |
References Mesh().
| void sal3d::Mesh::cropGL | ( | const Projection2D & | projection, |
| const Polygon2D & | polygon2d, | ||
| bool | keepInsidePoints = true |
||
| ) | [inline] |
Crop the Mesh as defined by a Polygon2D.
This function is mainly targeted for use with 2D viewports, the usual case being a GL 2D viewport, with the polygon defined in pixel units. The Mesh is projected to the viewport and what falls outside (when keepInsidePoints is true) the polygon is removed, and vice versa.
| [in] | projection | The projection matrix used to project the Mesh to 2D. |
| [in] | polygon2d | The polygon to define the desired region. |
| [in] | keepInsidePoints | If true (default), the points that fall outside the polygon are removed, if false they are the ones that are kept. |
| sal3d::Error | On error |
| void sal3d::Mesh::cropGL | ( | const std::vector< Projection2D > & | projections, |
| const std::vector< Polygon2D > & | polygons, | ||
| bool | keepInsidePoints = true |
||
| ) | [inline] |
Crop the Mesh as defined by a set of Polygon2D objects.
This function is mainly targeted for use with 2D viewports, the usual case being a GL 2D viewport, with the polygons defined in pixel units. The Mesh is projected to the viewport and what falls outside (when keepInsidePoints is true) the polygons is removed, and vice versa.
| [in] | projections | The vector of projection matrices used to project the Mesh to 2D. |
| [in] | polygons | The polygons to define the desired region. |
| [in] | keepInsidePoints | If true (default), the points that fall outside the polygons are removed, if false they are the ones that are kept. |
| sal3d::Error | On error |
| void sal3d::Mesh::exportToASCIIPLY | ( | const std::string & | filename | ) | const [inline] |
Export the Mesh to a PLY ASCII file.
| [in] | filename | The file name to save the Mesh. |
| sal3d::Error | On error |
| void sal3d::Mesh::exportToASCIISTL | ( | const std::string & | filename | ) | const [inline] |
Export the Mesh to a STL ASCII file.
| [in] | filename | The file name to save the Mesh. |
| sal3d::Error | On error |
| void sal3d::Mesh::exportToBinaryPLY | ( | const std::string & | filename | ) | const [inline] |
Export the Mesh to a PLY binary file.
| [in] | filename | The file name to save the Mesh. |
| sal3d::Error | On error |
| void sal3d::Mesh::exportToBinarySTL | ( | const std::string & | filename, |
| const std::string & | header = std::string("") |
||
| ) | const [inline] |
Export the Mesh to a STL binary file.
| [in] | filename | The file name to save the Mesh. |
| [in] | header | A text that will be written as the header of the STL |
| sal3d::Error | On error |
| int sal3d::Mesh::getNumTriangles | ( | ) | const [inline] |
Get the number of Triangles of the Mesh.
| sal3d::Error | On error |
Referenced by getTriangles(), and isEmpty().
| int sal3d::Mesh::getNumVertices | ( | ) | const [inline] |
Get the number of Vertices of the Mesh.
| sal3d::Error | On error |
Referenced by getVertices(), and isEmpty().
| const Triangles sal3d::Mesh::getTriangles | ( | ) | const [inline] |
Get the array of Triangles that define the Mesh.
| sal3d::Error | On error |
References getNumTriangles().
Referenced by getTriangles(), and mergeMesh().
| Triangles sal3d::Mesh::getTriangles | ( | ) | [inline] |
Get the array of Triangles that define the Mesh.
| sal3d::Error | On error |
References getTriangles().
| const Vertices sal3d::Mesh::getVertices | ( | ) | const [inline] |
Get the array of Vertices that comprise the Mesh.
| sal3d::Error | On error |
References getNumVertices().
Referenced by getVertices(), and mergeMesh().
| Vertices sal3d::Mesh::getVertices | ( | ) | [inline] |
Get the array of Vertices that comprise the Mesh.
| sal3d::Error | On error |
References getVertices().
| void sal3d::Mesh::glPaintPoints | ( | ) | const [inline] |
Issue gl instructions to paint the Mesh as points.
| sal3d::Error | On error |
| void sal3d::Mesh::glPaintPolygons | ( | ) | const [inline] |
Issue gl instructions to paint the Mesh as polygons.
| sal3d::Error | On error |
| void sal3d::Mesh::glPaintRandomPoints | ( | int | num_points | ) | const [inline] |
Paints numberPoints random points of the Mesh.
Useful in an sceneario where you wish to paint quick simplified version of the Mesh. In fast painting while moving it by the mouse, for example.
| sal3d::Error | On error |
| bool sal3d::Mesh::isEmpty | ( | ) | [inline] |
Checks if the Mesh is empty.
References getNumTriangles(), and getNumVertices().
| void sal3d::Mesh::mergeMesh | ( | const Mesh & | mesh | ) | [inline] |
Merge the passed Mesh to the current one.
All the Vertices and Triangles of the Mesh passed to the method are added to the Mesh.
References addTriangles(), getTriangles(), and getVertices().
Assignment operator.
| [in] | aMesh | The Mesh to copy to this object. |
by
1.7.6.1