Imagine++
|
A mesh representing a 3D object. More...
#include "Imagine/Graphics.h"
Public Member Functions | |
Mesh () | |
Empty constructor. More... | |
Mesh (const FloatPoint3 *vertices, int nvertices, const Triangle *triangles=0, int ntriangles=0, const Quad *quads=0, int nquads=0, MeshColorMode colorMode=CONSTANT_COLOR, MeshShadingMode shadingMode=SMOOTH_SHADING, const FloatVector3 *normals=0) | |
Constructor (float). More... | |
Mesh (const DoublePoint3 *vertices, int nvertices, const Triangle *triangles=0, int ntriangles=0, const Quad *quads=0, int nquads=0, MeshColorMode colorMode=CONSTANT_COLOR, MeshShadingMode shadingMode=SMOOTH_SHADING, const DoubleVector3 *normals=0) | |
Constructor (double). More... | |
Mesh (const std::vector< FloatPoint3 > &vertices, const std::vector< Triangle > &triangles=std::vector< Triangle >(), const std::vector< Quad > &quads=std::vector< Quad >(), MeshColorMode colorMode=CONSTANT_COLOR, MeshShadingMode shadingMode=SMOOTH_SHADING, const std::vector< FloatVector3 > &normals=std::vector< FloatVector3 >()) | |
Constructor (float vectors). More... | |
Mesh (const Mesh &) | |
Copy constructor. More... | |
~Mesh () | |
Destructor. | |
float | getOpacity () const |
Get opacity (from 0=transparent to 1=opaque). | |
bool | operator!= (const Mesh &mesh) const |
Comparison operator. More... | |
Mesh & | operator= (const Mesh &) |
Assignment operator. More... | |
bool | operator== (const Mesh &mesh) const |
Comparison operator. More... | |
void | setColor (Color col) |
Set color. More... | |
void | setColors (MeshData data, const Color *col) |
Set colors. More... | |
void | setDefaultLookupTable () |
Default LUT. More... | |
void | setGeometry (const FloatPoint3 *vertices, int nvertices, const Triangle *triangles=0, int ntriangles=0, const Quad *quads=0, int nquads=0, const FloatVector3 *normals=0) |
Set geometry (float). More... | |
void | setGeometry (const DoublePoint3 *vertices, int nvertices, const Triangle *triangles=0, int ntriangles=0, const Quad *quads=0, int nquads=0, const DoubleVector3 *normals=0) |
Set geometry (double). More... | |
void | setLookupTable (Color col0, Color col1) |
Set LUT. More... | |
void | setOpacity (float opacity) |
Set opacity. More... | |
void | setRange (float v0, float v1) |
Default LUT. More... | |
void | setValues (MeshData data, const float *val) |
Set values. More... | |
void | setVertices (const FloatPoint3 *vertices, const FloatVector3 *normals=0) |
Set points (float). More... | |
void | setVertices (const DoublePoint3 *vertices, const DoubleVector3 *normals=0) |
Set points (double). More... | |
const std::vector< FloatPoint3 > & | vertices () const |
Get points. | |
Static Public Member Functions | |
static Mesh | Arrow (const DoublePoint3 &base, const DoubleVector3 &shaft, double r, int resolution=32) |
Arrow. More... | |
static Mesh | Cone (const DoublePoint3 &base, const DoubleVector3 &axis, double r, int resolution=32) |
Cone. More... | |
static Mesh | Cube (const DoublePoint3 ¢er, const DoubleVector3 &axis1, const DoubleVector3 &axis2, const DoubleVector3 &axis3) |
Parallelepiped. More... | |
static Mesh | Cylinder (const DoublePoint3 ¢er, const DoubleVector3 &axis, double r, int res=32) |
Cylinder. More... | |
static Mesh | Plane (const DoublePoint3 ¢er, const DoubleVector3 &axis1, const DoubleVector3 &axis2) |
Parallelogram. More... | |
static Mesh | PointCloud (const DoublePoint3 *points, int n) |
PointCloud. More... | |
static Mesh | PolyLine (DoublePoint3 *points, int n, bool closed) |
PolyLine. More... | |
static Mesh | Sphere (const DoublePoint3 ¢er, double r, int res=24) |
Sphere. More... | |
Friends | |
void | hideMesh (const Mesh &M, bool reinitCam) |
Hide mesh. More... | |
bool | readMeshFromObjFile (Mesh &mesh, const std::string &fileName) |
Read mesh from Wavefront OBJ file. More... | |
void | showMesh (const Mesh &M, bool reinitCam) |
Show mesh. More... | |
This can be a point cloud or a set of triangles or quadrilaterals. This class is only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h
Imagine::Mesh::Mesh | ( | ) |
Use setVertices or setGeometry to fill it later.
Imagine::Mesh::Mesh | ( | const FloatPoint3 * | vertices, |
int | nvertices, | ||
const Triangle * | triangles = 0 , |
||
int | ntriangles = 0 , |
||
const Quad * | quads = 0 , |
||
int | nquads = 0 , |
||
MeshColorMode | colorMode = CONSTANT_COLOR , |
||
MeshShadingMode | shadingMode = SMOOTH_SHADING , |
||
const FloatVector3 * | normals = 0 |
||
) |
Constructs a mesh (float). Note: arrays are copied into the data structure, so they could be deleted after mesh creation.
vertices | array of points |
nvertices | number of points |
triangles | array of triangles (indices to point array, from 0 to nvertices-1) |
ntriangles | number of triangles |
quads | array of quadrilaterals (indices to point array, from 0 to nvertices-1) |
nquads | number of quadrilaterals |
colorMode | color mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards |
shadingMode | shading mode (default=FLAT_SHADING) NB: cannot be changed afterwards |
normals | array of nvertices normals (computed if =0) |
Imagine::Mesh::Mesh | ( | const DoublePoint3 * | vertices, |
int | nvertices, | ||
const Triangle * | triangles = 0 , |
||
int | ntriangles = 0 , |
||
const Quad * | quads = 0 , |
||
int | nquads = 0 , |
||
MeshColorMode | colorMode = CONSTANT_COLOR , |
||
MeshShadingMode | shadingMode = SMOOTH_SHADING , |
||
const DoubleVector3 * | normals = 0 |
||
) |
Constructs a mesh (double). Note: arrays are copied into the data structure, so they could be deleted after mesh creation.
vertices | array of points |
nvertices | number of points |
triangles | array of triangles (indices to point array, from 0 to nvertices-1) |
ntriangles | number of triangles |
quads | array of quadrilaterals (indices to point array, from 0 to nvertices-1) |
nquads | number of quadrilaterals |
colorMode | color mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards |
shadingMode | shading mode (default=FLAT_SHADING) NB: cannot be changed afterwards |
normals | array of nvertices normals (computed if =0) |
Imagine::Mesh::Mesh | ( | const std::vector< FloatPoint3 > & | vertices, |
const std::vector< Triangle > & | triangles = std::vector< Triangle >() , |
||
const std::vector< Quad > & | quads = std::vector< Quad >() , |
||
MeshColorMode | colorMode = CONSTANT_COLOR , |
||
MeshShadingMode | shadingMode = SMOOTH_SHADING , |
||
const std::vector< FloatVector3 > & | normals = std::vector< FloatVector3 >() |
||
) |
Constructs a mesh.
vertices | array of points |
triangles | array of triangles (indices to point array, from 0 to vertices.size()-1) |
quads | array of quadrilaterals (indices to point array, from 0 to vertices.size()-1) |
colorMode | color mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards |
shadingMode | shading mode (default=FLAT_SHADING) NB: cannot be changed afterwards |
normals | array of vertices.size() normals (computed if =0) |
Imagine::Mesh::Mesh | ( | const Mesh & | ) |
Shallow copy, shares data with original mesh: if you modify one, the other will also be affected.
|
static |
Constructs an arrow. Act as a CONSTANT_COLOR mesh.
base | starting point |
shaft | direction (arrow goes from base to base+shaft) |
r | shaft radius |
resolution | adjusts number of facets (default=32) |
|
static |
Constructs a cone . Act as a CONSTANT_COLOR mesh.
base | starting point |
axis | axis |
r | radius |
resolution | adjusts number of facets (default=32) |
|
static |
Constructs a parallelepiped. Act as a CONSTANT_COLOR mesh.
center | center |
axis1,axis2,axis3 | cube axes |
|
static |
Constructs a cylinder. Act as a CONSTANT_COLOR mesh.
center | center |
axis | axis |
r | radius |
res | resolution: adjusts number of facets (default=32) |
|
inline |
Two meshes sharing the same data (through copy constructor or assignment operator) are considered equal.
Shallow copy, shares data with original mesh: if you modify one, the other will also be affected.
|
inline |
Two meshes sharing the same data (through copy constructor or assignment operator) are considered equal.
|
static |
Constructs a parallelogram. Act as a CONSTANT_COLOR mesh.
center | center |
axis1,axis2 | directions |
|
static |
Constructs a point cloud. Act as a CONSTANT_COLOR mesh.
points | array of points |
n | number of points |
|
static |
Constructs a line through points. Act as a CONSTANT_COLOR mesh.
points | array of points |
n | number of points |
closed | is the line closed |
void Imagine::Mesh::setColor | ( | Color | col | ) |
Sets color. Mesh should be of CONSTANT_COLOR mode
col | color |
Sets colors. Mesh should be of VERTEX_COLOR or FACE_COLOR mode
data | type of data to hold colors. |
col | colors for each triangle or vertex |
void Imagine::Mesh::setDefaultLookupTable | ( | ) |
Restore default 'rainbow' scale (VERTEX_VALUE or FACE_VALUE modes)
void Imagine::Mesh::setGeometry | ( | const FloatPoint3 * | vertices, |
int | nvertices, | ||
const Triangle * | triangles = 0 , |
||
int | ntriangles = 0 , |
||
const Quad * | quads = 0 , |
||
int | nquads = 0 , |
||
const FloatVector3 * | normals = 0 |
||
) |
Changes vertices and topology.
vertices | new vertices |
nvertices | new number of vertices |
triangles | new triangles |
ntriangles | new number of triangles |
quads | new quadrilaterals |
nquads | new number of quadrilaterals |
normals | new normals |
void Imagine::Mesh::setGeometry | ( | const DoublePoint3 * | vertices, |
int | nvertices, | ||
const Triangle * | triangles = 0 , |
||
int | ntriangles = 0 , |
||
const Quad * | quads = 0 , |
||
int | nquads = 0 , |
||
const DoubleVector3 * | normals = 0 |
||
) |
Changes vertices and topology.
vertices | new vertices |
nvertices | new number of vertices |
triangles | new triangles |
ntriangles | new number of triangles |
quads | new quadrilaterals |
nquads | new number of quadrilaterals |
normals | new normals |
Replaces default 'rainbow' scale by a new one (in VERTEX_VALUE or FACE_VALUE modes)
col0 | initial color for interpolation for a value of min range |
col1 | final color for interpolation for a value of max range |
void Imagine::Mesh::setOpacity | ( | float | opacity | ) |
Change mesh opacity.
opacity | (from 0=transparent to 1=opaque) |
void Imagine::Mesh::setRange | ( | float | v0, |
float | v1 | ||
) |
Restore default 'rainbow' scale (VERTEX_VALUE or FACE_VALUE modes)
v0,v1 | min and max values (default 0 and 1) |
void Imagine::Mesh::setValues | ( | MeshData | data, |
const float * | val | ||
) |
Sets values. Mesh should be of VERTEX_VALUE or FACE_VALUE mode.
data | type of data to hold values. |
val | values for each triangle, quad or vertex |
void Imagine::Mesh::setVertices | ( | const FloatPoint3 * | vertices, |
const FloatVector3 * | normals = 0 |
||
) |
Changes vertices positions. Mesh topology remains constant.
vertices | new positions |
normals | new normals |
void Imagine::Mesh::setVertices | ( | const DoublePoint3 * | vertices, |
const DoubleVector3 * | normals = 0 |
||
) |
Changes vertices positions. Mesh topology remains constant.
vertices | new positions |
normals | new normals |
|
static |
Constructs a sphere. Act as a CONSTANT_COLOR mesh.
center | center |
r | radius |
res | resolution: adjusts number of facets (default=32) |
|
friend |
Removes a mesh from active window (must be a 3D window).
M | Mesh to hide |
reinitCam | Reset camera to fit all the meshes being viewed |
Function only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h
|
friend |
See http://en.wikipedia.org/wiki/Wavefront_.obj_file Function only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h
|
friend |
Shows a mesh in active window (must be a 3D window).
M | Mesh to show |
reinitCam | Reset camera to view all meshes (same as SHIFT-r) |
IMPORTANT NOTE:
Function only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h