Imagine++
Public Member Functions | Static Public Member Functions | Friends | List of all members
Imagine::Mesh Class Reference

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...
 
Meshoperator= (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 &center, const DoubleVector3 &axis1, const DoubleVector3 &axis2, const DoubleVector3 &axis3)
 Parallelepiped. More...
 
static Mesh Cylinder (const DoublePoint3 &center, const DoubleVector3 &axis, double r, int res=32)
 Cylinder. More...
 
static Mesh Plane (const DoublePoint3 &center, 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 &center, 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...
 

Detailed Description

The simplest Mesh is a set of 3D points. Faces may be added as triangles or quadrangles (a quadrangle is supposed planar). They are coded as index of 3 or 4 vertices. A vertex can participate in several faces. After construction, you may change the position of vertices without changing the topology through setVertices.

Color. By default, a mesh has a constant color (CONSTANT_COLOR), specified by Mesh::setColor. If not, either one color per vertex (VERTEX_COLOR or VERTEX_VALUE) or per face (FACE_COLOR or FACE_VALUE) may be specified with Mesh::setColors. If values are used, colors are interpolated between the arguments of Mesh::setLookupTable. The range for interpolation is specified by setRange. Transparency can be tuned with Mesh::setOpacity, value 1 meaning opaque and 0 completely transparent.

Lighting. A default light along the viewer's direction is applied when displaying faces. This can be configured with setLight. Normals are used for composition. The mode FLAT_SHADING computes the normal of each face, whereas SMOOTH_SHADING gives a normal per vertex, which can be specified at construction or automatically computed, and the normal on each point of the facet is interpolated from the ones of vertices.

Some convenience functions provide predefined volumes. Notice that the only way to have a polyline or polygon is through the function Mesh::PolyLine, as the constructor of Mesh does not distinguish it from a point cloud.

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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

Constructor & Destructor Documentation

◆ Mesh() [1/5]

Imagine::Mesh::Mesh ( )

Use setVertices or setGeometry to fill it later.

◆ Mesh() [2/5]

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.

Parameters
verticesarray of points
nverticesnumber of points
trianglesarray of triangles (indices to point array, from 0 to nvertices-1)
ntrianglesnumber of triangles
quadsarray of quadrilaterals (indices to point array, from 0 to nvertices-1)
nquadsnumber of quadrilaterals
colorModecolor mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards
shadingModeshading mode (default=FLAT_SHADING) NB: cannot be changed afterwards
normalsarray of nvertices normals (computed if =0)
FloatPoint3 fP[8]={FloatPoint3(3,-1,-1),FloatPoint3(5,-1,-1),FloatPoint3(5,1,-1),FloatPoint3(3,1,-1), // constructor (float)
FloatPoint3(3,-1,1),FloatPoint3(5,-1,1),FloatPoint3(5,1,1),FloatPoint3(3,1,1)
};
Triangle fT[12]={Triangle(0,2,1),Triangle(2,0,3),Triangle(4,5,6),Triangle(6,7,4), // A cube
Triangle(0,1,5),Triangle(5,4,0),Triangle(1,2,6),Triangle(6,5,1),
Triangle(2,3,7),Triangle(7,6,2),Triangle(3,0,4),Triangle(4,7,3)
};
Mesh fM(fP,8,fT,12);
// ...

◆ Mesh() [3/5]

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.

Parameters
verticesarray of points
nverticesnumber of points
trianglesarray of triangles (indices to point array, from 0 to nvertices-1)
ntrianglesnumber of triangles
quadsarray of quadrilaterals (indices to point array, from 0 to nvertices-1)
nquadsnumber of quadrilaterals
colorModecolor mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards
shadingModeshading mode (default=FLAT_SHADING) NB: cannot be changed afterwards
normalsarray of nvertices normals (computed if =0)
DoublePoint3 dP[8]={DoublePoint3(-1,-1,-1),DoublePoint3(1,-1,-1),DoublePoint3(1,1,-1),DoublePoint3(-1,1,-1), // constructor (double)
DoublePoint3(-1,-1,1),DoublePoint3(1,-1,1),DoublePoint3(1,1,1),DoublePoint3(-1,1,1)
};
Triangle dT[12]={Triangle(0,2,1),Triangle(2,0,3),Triangle(4,5,6),Triangle(6,7,4), // A cube
Triangle(0,1,5),Triangle(5,4,0),Triangle(1,2,6),Triangle(6,5,1),
Triangle(2,3,7),Triangle(7,6,2),Triangle(3,0,4),Triangle(4,7,3)
};
Mesh dM(dP,8,dT,12); // ...

◆ Mesh() [4/5]

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.

Parameters
verticesarray of points
trianglesarray of triangles (indices to point array, from 0 to vertices.size()-1)
quadsarray of quadrilaterals (indices to point array, from 0 to vertices.size()-1)
colorModecolor mode (default=CONSTANT_COLOR) NB: cannot be changed afterwards
shadingModeshading mode (default=FLAT_SHADING) NB: cannot be changed afterwards
normalsarray of vertices.size() normals (computed if =0)

◆ Mesh() [5/5]

Imagine::Mesh::Mesh ( const Mesh )

Shallow copy, shares data with original mesh: if you modify one, the other will also be affected.

Member Function Documentation

◆ Arrow()

static Mesh Imagine::Mesh::Arrow ( const DoublePoint3 base,
const DoubleVector3 shaft,
double  r,
int  resolution = 32 
)
static

Constructs an arrow. Act as a CONSTANT_COLOR mesh.

Parameters
basestarting point
shaftdirection (arrow goes from base to base+shaft)
rshaft radius
resolutionadjusts number of facets (default=32)
Returns
contructed mesh
Mesh Ar=Mesh::Arrow(DoublePoint3(-2,0,0),DoubleVector3(0.5,0,0),0.1); // arrow

Examples:
Graphics/test/test.cpp.

◆ Cone()

static Mesh Imagine::Mesh::Cone ( const DoublePoint3 base,
const DoubleVector3 axis,
double  r,
int  resolution = 32 
)
static

Constructs a cone . Act as a CONSTANT_COLOR mesh.

Parameters
basestarting point
axisaxis
rradius
resolutionadjusts number of facets (default=32)
Returns
contructed mesh
Mesh Cn=Mesh::Cone(DoublePoint3(2,0,0),DoubleVector3(-0.5,0,0),0.3); // cone

Examples:
Graphics/test/test.cpp.

◆ Cube()

static Mesh Imagine::Mesh::Cube ( const DoublePoint3 center,
const DoubleVector3 axis1,
const DoubleVector3 axis2,
const DoubleVector3 axis3 
)
static

Constructs a parallelepiped. Act as a CONSTANT_COLOR mesh.

Parameters
centercenter
axis1,axis2,axis3cube axes
Returns
contructed mesh
Mesh Cb=Mesh::Cube(DoublePoint3(0,-2,0),DoubleVector3(.1,0,0),DoubleVector3(.1,.2,0),DoubleVector3(0,.1,.3)); // parallelepiped

Examples:
Graphics/test/test.cpp.

◆ Cylinder()

static Mesh Imagine::Mesh::Cylinder ( const DoublePoint3 center,
const DoubleVector3 axis,
double  r,
int  res = 32 
)
static

Constructs a cylinder. Act as a CONSTANT_COLOR mesh.

Parameters
centercenter
axisaxis
rradius
resresolution: adjusts number of facets (default=32)
Returns
contructed mesh
Mesh Cl=Mesh::Cylinder(DoublePoint3(-0.5,-0.5,1.5),DoubleVector3(0,1,0),0.2); // cylinder

Examples:
Graphics/test/test.cpp.

◆ operator!=()

bool Imagine::Mesh::operator!= ( const Mesh mesh) const
inline

Two meshes sharing the same data (through copy constructor or assignment operator) are considered equal.

◆ operator=()

Mesh& Imagine::Mesh::operator= ( const Mesh )

Shallow copy, shares data with original mesh: if you modify one, the other will also be affected.

◆ operator==()

bool Imagine::Mesh::operator== ( const Mesh mesh) const
inline

Two meshes sharing the same data (through copy constructor or assignment operator) are considered equal.

◆ Plane()

static Mesh Imagine::Mesh::Plane ( const DoublePoint3 center,
const DoubleVector3 axis1,
const DoubleVector3 axis2 
)
static

Constructs a parallelogram. Act as a CONSTANT_COLOR mesh.

Parameters
centercenter
axis1,axis2directions
Returns
contructed mesh
Mesh Pl=Mesh::Plane(DoublePoint3(0.5,0,1.5),DoubleVector3(.2,0,0),DoubleVector3(0,.3,0)); // plane

Examples:
Graphics/test/test.cpp.

◆ PointCloud()

static Mesh Imagine::Mesh::PointCloud ( const DoublePoint3 points,
int  n 
)
static

Constructs a point cloud. Act as a CONSTANT_COLOR mesh.

Parameters
pointsarray of points
nnumber of points
Returns
contructed mesh
Mesh Cp=Mesh::PointCloud(PTSCL,8); // pointcloud

Examples:
Graphics/test/test.cpp.

◆ PolyLine()

static Mesh Imagine::Mesh::PolyLine ( DoublePoint3 points,
int  n,
bool  closed 
)
static

Constructs a line through points. Act as a CONSTANT_COLOR mesh.

Parameters
pointsarray of points
nnumber of points
closedis the line closed
Returns
contructed mesh
Mesh Cpl=Mesh::PolyLine(PTSCL,8,true); // polyline

Examples:
Graphics/test/test.cpp.

◆ setColor()

void Imagine::Mesh::setColor ( Color  col)

Sets color. Mesh should be of CONSTANT_COLOR mode

Parameters
colcolor
dM.setColor(RED); // set color
fM.setColor(BLUE); // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ setColors()

void Imagine::Mesh::setColors ( MeshData  data,
const Color col 
)

Sets colors. Mesh should be of VERTEX_COLOR or FACE_COLOR mode

Parameters
datatype of data to hold colors.
colcolors for each triangle or vertex
Color *cols=new Color[2*(n-1)*(n-1)]; // set colors
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,FACE_COLOR,SMOOTH_SHADING);
for (int i=0;i<2*(n-1)*(n-1);i++)
cols[i]=Color(intRandom(0,255),intRandom(0,255),intRandom(0,255));
S.setColors(TRIANGLE,cols);
delete[] cols;
cout << "Random triangle colors" << endl;
showMesh(S, false);
hideMesh(S, false);
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,VERTEX_COLOR,SMOOTH_SHADING);
cols=new Color[n*n];
for (int i=0;i<n*n;i++)
cols[i]=Color(intRandom(0,255),intRandom(0,255),intRandom(0,255));
S.setColors(VERTEX, cols);
delete[] cols;
cout << "Random vertex colors" << endl;
showMesh(S, false); // ...

Examples:
Graphics/test/test.cpp.

◆ setDefaultLookupTable()

void Imagine::Mesh::setDefaultLookupTable ( )

Restore default 'rainbow' scale (VERTEX_VALUE or FACE_VALUE modes)

S.setDefaultLookupTable(); // default LUT
cout << "Vertex value coloring with default LUT" << endl;
showMesh(S, false); // ...

Examples:
Graphics/test/test.cpp.

◆ setGeometry() [1/2]

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.

Parameters
verticesnew vertices
nverticesnew number of vertices
trianglesnew triangles
ntrianglesnew number of triangles
quadsnew quadrilaterals
nquadsnew number of quadrilaterals
normalsnew normals
DoublePoint3 P4[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0),DoublePoint3(1,1,1)}; // set geometry
Triangle T4[]={Triangle(0,1,2),Triangle(1,3,2)};
S.setGeometry(P4,4,T4,2); // ...

Examples:
Graphics/test/test.cpp.

◆ setGeometry() [2/2]

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.

Parameters
verticesnew vertices
nverticesnew number of vertices
trianglesnew triangles
ntrianglesnew number of triangles
quadsnew quadrilaterals
nquadsnew number of quadrilaterals
normalsnew normals
DoublePoint3 P4[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0),DoublePoint3(1,1,1)}; // set geometry
Triangle T4[]={Triangle(0,1,2),Triangle(1,3,2)};
S.setGeometry(P4,4,T4,2); // ...

◆ setLookupTable()

void Imagine::Mesh::setLookupTable ( Color  col0,
Color  col1 
)

Replaces default 'rainbow' scale by a new one (in VERTEX_VALUE or FACE_VALUE modes)

Parameters
col0initial color for interpolation for a value of min range
col1final color for interpolation for a value of max range
Color LUT[3]={BLACK,BLUE,WHITE}; // change LUT
// S.setLookupTable(LUT,3);
S.setLookupTable(LUT[0],LUT[1]);
cout << "Vertex value coloring with custom LUT" << endl;
showMesh(S, false); // ...

Examples:
Graphics/test/test.cpp.

◆ setOpacity()

void Imagine::Mesh::setOpacity ( float  opacity)

Change mesh opacity.

Parameters
opacity(from 0=transparent to 1=opaque)
fM.setOpacity(.5f); // opacity

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ setRange()

void Imagine::Mesh::setRange ( float  v0,
float  v1 
)

Restore default 'rainbow' scale (VERTEX_VALUE or FACE_VALUE modes)

S.setDefaultLookupTable(); // default LUT
cout << "Vertex value coloring with default LUT" << endl;
showMesh(S, false); // ...
Set range. Sets range. Mesh should be of VERTEX_VALUE or FACE_VALUE mode. Values from v0 to v1 are represented by a rainbow.

Parameters
v0,v1min and max values (default 0 and 1)
float *vals=new float[2*(n-1)*(n-1)]; // set values
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,FACE_VALUE,SMOOTH_SHADING);
for (int i=0;i<2*(n-1)*(n-1);i++)
vals[i]=float(i)/(2*(n-1)*(n-1));
S.setRange(0.,1.);
S.setValues(TRIANGLE,vals);
delete[] vals;
cout << "Face value coloring" << endl;
showMesh(S, false);
hideMesh(S, false);
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,VERTEX_VALUE,SMOOTH_SHADING);
vals=new float[n*n];
for (int i=0;i<n*n;i++)
vals[i]=float(i)/(n*n);
S.setRange(0.,1.);
S.setValues(VERTEX,vals);
delete[] vals;
cout << "Vertex value coloring" << endl;
showMesh(S, false);
anyClick(); // ...

Examples:
Graphics/test/test.cpp.

◆ setValues()

void Imagine::Mesh::setValues ( MeshData  data,
const float *  val 
)

Sets values. Mesh should be of VERTEX_VALUE or FACE_VALUE mode.

Parameters
datatype of data to hold values.
valvalues for each triangle, quad or vertex
float *vals=new float[2*(n-1)*(n-1)]; // set values
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,FACE_VALUE,SMOOTH_SHADING);
for (int i=0;i<2*(n-1)*(n-1);i++)
vals[i]=float(i)/(2*(n-1)*(n-1));
S.setRange(0.,1.);
S.setValues(TRIANGLE,vals);
delete[] vals;
cout << "Face value coloring" << endl;
showMesh(S, false);
hideMesh(S, false);
S=Mesh(P,n*n,T,2*(n-1)*(n-1),0,0,VERTEX_VALUE,SMOOTH_SHADING);
vals=new float[n*n];
for (int i=0;i<n*n;i++)
vals[i]=float(i)/(n*n);
S.setRange(0.,1.);
S.setValues(VERTEX,vals);
delete[] vals;
cout << "Vertex value coloring" << endl;
showMesh(S, false);
anyClick(); // ...

Examples:
Graphics/test/test.cpp.

◆ setVertices() [1/2]

void Imagine::Mesh::setVertices ( const FloatPoint3 vertices,
const FloatVector3 normals = 0 
)

Changes vertices positions. Mesh topology remains constant.

Parameters
verticesnew positions
normalsnew normals
DoublePoint3 P3[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0)}; // set points
Triangle T3(0,1,2);
S=Mesh(P3,3,&T3,1,0,0,CONSTANT_COLOR);
cout << "Triangle" << endl;
DoublePoint3 Q3[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,2,0)};
S.setVertices(Q3);
cout << "Bigger triangle" << endl;
showMesh(S, false);
DoublePoint3 P4[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0),DoublePoint3(1,1,1)}; // set geometry
Triangle T4[]={Triangle(0,1,2),Triangle(1,3,2)};
S.setGeometry(P4,4,T4,2); // ...

Examples:
Graphics/test/test.cpp.

◆ setVertices() [2/2]

void Imagine::Mesh::setVertices ( const DoublePoint3 vertices,
const DoubleVector3 normals = 0 
)

Changes vertices positions. Mesh topology remains constant.

Parameters
verticesnew positions
normalsnew normals
DoublePoint3 P3[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0)}; // set points
Triangle T3(0,1,2);
S=Mesh(P3,3,&T3,1,0,0,CONSTANT_COLOR);
cout << "Triangle" << endl;
DoublePoint3 Q3[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,2,0)};
S.setVertices(Q3);
cout << "Bigger triangle" << endl;
showMesh(S, false);
DoublePoint3 P4[]={DoublePoint3(0,0,0),DoublePoint3(1,0,0),DoublePoint3(0,1,0),DoublePoint3(1,1,1)}; // set geometry
Triangle T4[]={Triangle(0,1,2),Triangle(1,3,2)};
S.setGeometry(P4,4,T4,2); // ...

◆ Sphere()

static Mesh Imagine::Mesh::Sphere ( const DoublePoint3 center,
double  r,
int  res = 24 
)
static

Constructs a sphere. Act as a CONSTANT_COLOR mesh.

Parameters
centercenter
rradius
resresolution: adjusts number of facets (default=32)
Returns
contructed mesh
Mesh Sp=Mesh::Sphere(DoublePoint3(0,2,0),0.5); // sphere

Examples:
Graphics/test/particles.cpp, and Graphics/test/test.cpp.

Friends And Related Function Documentation

◆ hideMesh

void hideMesh ( const Mesh M,
bool  reinitCam 
)
friend

Removes a mesh from active window (must be a 3D window).

Parameters
MMesh to hide
reinitCamReset camera to fit all the meshes being viewed
hideMesh(fM); // hide mesh

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

◆ readMeshFromObjFile

bool readMeshFromObjFile ( Mesh mesh,
const std::string &  fileName 
)
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

◆ showMesh

void showMesh ( const Mesh M,
bool  reinitCam 
)
friend

Shows a mesh in active window (must be a 3D window).

Parameters
MMesh to show
reinitCamReset camera to view all meshes (same as SHIFT-r)

IMPORTANT NOTE:

  • A mesh does not live in a window! It can be viewed in more than one window (showMesh/hideMesh functions).
  • Closing a window does not delete the meshes viewed in it
  • To hide the mesh later, you must keep the mesh variable.
    • For instance:
      showMesh(Mesh(...)); // Displayed, but cannot be hidden later
      This is the right thing to do:
      Mesh S(...);
    • Inside a function:
      Mesh f() {
      Mesh S(...);
      return S;
      }
      void g() {
      Mesh S=f();
      ... // We can hide it later with hideMesh(S);
      }
  • However, it is possible to hide all meshes in active window with clearWindow function

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


The documentation for this class was generated from the following file: