GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Private Attributes | Static Private Attributes | List of all members
GLC_ExtrudedMesh Class Reference

GLC_ExtrudedMesh : An Extruded mesh defined by a list of points, *a direction and a distance. More...

#include <glc_extrudedmesh.h>

+ Inheritance diagram for GLC_ExtrudedMesh:

Public Member Functions

Constructor / Destructor
 GLC_ExtrudedMesh (const QList< GLC_Point3d > &points, const GLC_Vector3d &dir, double lenght)
 Default constructor.
 
 GLC_ExtrudedMesh (const GLC_ExtrudedMesh &other)
 Copy constructor.
 
virtual ~GLC_ExtrudedMesh ()
 Destructor.
 
Set Functions
GLC_ExtrudedMeshoperator= (const GLC_ExtrudedMesh &other)
 Assignement operator overload.
 
void setGeometry (const QList< GLC_Point3d > &points, const GLC_Vector3d &extrudedVector, double lenght)
 Set the mesh from the given points, vector and lenght.
 
void setPoints (const QList< GLC_Point3d > &points)
 Set the mesh points list.
 
void setExtrudedVector (const GLC_Vector3d &extrudedVector)
 Set the mesh extruded vector.
 
void setExtrudedLenght (double lenght)
 Set the mesh extruded lenght.
 
- Public Member Functions inherited from GLC_Mesh
 GLC_Mesh ()
 Default constructor.
 
 GLC_Mesh (const GLC_Mesh &)
 Copy constructor.
 
GLC_Meshoperator= (const GLC_Mesh &)
 Overload "=" operator.
 
virtual ~GLC_Mesh ()
 Destructor.
 
virtual void clear ()
 Clear the content of the mesh and super class and makes them empty.
 
void clearMeshWireAndBoundingBox ()
 Clear only the content off the mesh and makes it empty.
 
void addVertice (const GLfloatVector &vertices)
 Add vertices coordinate.
 
void addNormals (const GLfloatVector &normals)
 Add Normals.
 
void addTexels (const GLfloatVector &texels)
 Add texel.
 
void addColors (const GLfloatVector &colors)
 Add Colors.
 
GLC_uint addTriangles (GLC_Material *, const IndexList &, const int lod=0, double accuracy=0.0)
 Add triangles.
 
GLC_uint addTrianglesStrip (GLC_Material *, const IndexList &, const int lod=0, double accuracy=0.0)
 Add triangles Strip and return his id.
 
GLC_uint addTrianglesFan (GLC_Material *, const IndexList &, const int lod=0, double accuracy=0.0)
 Add triangles Fan and return his id.
 
void reverseNormals ()
 Reverse mesh normal.
 
void setColorPearVertex (bool flag)
 Set color per vertex flag to use indexed color.
 
void finish ()
 Copy vertex list in a vector list for Vertex Array Use.
 
virtual void setCurrentLod (const int)
 Set the lod Index.
 
virtual void replaceMasterMaterial (GLC_Material *)
 Replace the Master material.
 
void replaceMaterial (const GLC_uint, GLC_Material *)
 Replace the material specified by id with another one.
 
void setNextPrimitiveLocalId (GLC_uint id)
 Set the mesh next primitive local id.
 
void setWireColor (const QColor &color)
 Set the mesh wire color.
 
virtual void copyVboToClientSide ()
 Copy VBO to the Client Side.
 
virtual void releaseVboClientSide (bool update)
 Release client VBO.
 
virtual void setVboUsage (bool usage)
 Set VBO usage.
 
void loadFromDataStream (QDataStream &, const MaterialHash &, const QHash< GLC_uint, GLC_uint > &)
 Load the mesh from binary data stream.
 
void saveToDataStream (QDataStream &) const
 Save the mesh to binary data stream.
 
virtual unsigned int faceCount (int lod) const
 Get number of faces.
 
virtual unsigned int VertexCount () const
 Get number of vertex.
 
unsigned int numberOfNormals () const
 Get number of normals.
 
bool ColorPearVertexIsAcivated () const
 Return true if color pear vertex is activated.
 
int lodCount () const
 Return the number of lod.
 
GLfloatVector positionVector () const
 Return the Position Vector.
 
GLfloatVector normalVector () const
 Return the normal Vector.
 
GLfloatVector texelVector () const
 Return the texel Vector.
 
bool containsTriangles (int lod, GLC_uint materialId) const
 Return true if the mesh contains triangles in the specified LOD.
 
QVector< GLuint > getTrianglesIndex (int lod, GLC_uint materialId) const
 Return the triangle index.
 
IndexList getEquivalentTrianglesStripsFansIndex (int lod, GLC_uint materialId)
 Return the equivalent triangle index of (triangle, strip and fan)
 
int numberOfTriangles (int lod, GLC_uint materialId) const
 Return the number of triangles in the specified LOD.
 
bool containsStrips (int lod, GLC_uint materialId) const
 Return true if the mesh contains trips in the specified LOD with the specified material id.
 
QList< QVector< GLuint > > getStripsIndex (int lod, GLC_uint materialId) const
 Return the strips index.
 
int numberOfStrips (int lod, GLC_uint materialId) const
 Return the number of strips in the specified LOD with the specified material id.
 
bool containsFans (int lod, GLC_uint materialId) const
 Return true if the mesh contains fans in the specified LOD with the specified material id.
 
QList< QVector< GLuint > > getFansIndex (int lod, GLC_uint materialId) const
 Return the fans index.
 
int numberOfFans (int lod, GLC_uint materialId) const
 Return the number of fans in the specified LOD with the specified material id.
 
bool containsLod (int lod) const
 Return true if the mesh contains the specified LOD.
 
bool lodContainsMaterial (int lod, GLC_uint materialId) const
 Return true if the specified LOD contains the specified material.
 
double getLodAccuracy (int lod) const
 Return the specified LOD accuracy.
 
GLC_uint nextPrimitiveLocalId () const
 Return the next primitive local id.
 
GLC_MaterialMaterialOfPrimitiveId (GLC_uint id, int lod=0) const
 Return the GLC_Material applyed on the given primitive id of the given lod.
 
QSet< GLC_uintsetOfPrimitiveId () const
 Return the set of primitives id.
 
bool isEmpty () const
 Return true if the mesh position data is empty.
 
QColor wireColor () const
 Return the mesh wire color.
 
GLC_MeshcreateMeshOfGivenLod (int lodIndex)
 Create a mesh of the given LOD index.
 
GLC_MeshcreateMeshFromGivenLod (int lodIndex)
 Create a mesh from the given LOD index.
 
GLC_MeshtransformVertice (const GLC_Matrix4x4 &matrix)
 Transform mesh vertice by the given matrix.
 
virtual double volume ()
 Return the volume of this mesh.
 
- Public Member Functions inherited from GLC_Geometry
 GLC_Geometry (const QString &name, const bool type)
 Default constructor.
 
 GLC_Geometry (const GLC_Geometry &sourceGeom)
 Copy constructor.
 
GLC_Geometryoperator= (const GLC_Geometry &sourceGeom)
 Overload "=" operator.
 
virtual ~GLC_Geometry ()
 Destructor.
 
GLC_uint id () const
 Get Object ID.
 
QString name () const
 Get Object Name.
 
bool isValid (void) const
 Return true if the geometry is valid.
 
bool hasMaterial () const
 Return true if the geometry has material.
 
GLC_MaterialfirstMaterial (void) const
 Return first material of geometry.
 
int materialCount () const
 Return the number of materials.
 
GLC_Materialmaterial (const GLC_uint key) const
 Return the specified mesh sub material.
 
QSet< GLC_Material * > materialSet () const
 Get materials Set.
 
QList< GLC_uintmaterialIds () const
 Get materials ID List.
 
bool containsMaterial (const GLC_uint key) const
 Return true if Material key is in the mesh.
 
bool boundingBoxIsValid () const
 Return true if the bounding box is valid.
 
bool isTransparent () const
 Get the geometry transparency.
 
bool hasTransparentMaterials () const
 Return true if the geometry contains transparent materials.
 
bool usedColorPerVertex () const
 Return true if color per vertex is used.
 
bool typeIsWire () const
 Return true if the geometry type is wireframe.
 
GLfloat lineWidth () const
 Return the line width.
 
QColor wireColor () const
 Return this geometry wire color.
 
bool wireDataIsEmpty () const
 Return true if wire data is empty.
 
GLfloatVector wirePositionVector () const
 Return the wire position vector.
 
int wirePolylineCount () const
 Return the number of wire polylines.
 
GLuint wirePolylineOffset (int index) const
 Return the polyline offset from the given index.
 
GLsizei wirePolylineSize (int index) const
 Return the polyline size from the given index.
 
bool vboIsUsed () const
 Return true if this geometry will try to use VBO.
 
void addMaterial (GLC_Material *)
 Add material to the geometry.
 
void colorPerVertex (const bool colorPerVertex)
 Set the color per vertex usage.
 
void updateTransparentMaterialNumber ()
 Update the transparent material number.
 
void setId (const GLC_uint id)
 Set Geometry Id.
 
void setName (const QString name)
 Set geometry name.
 
GLC_uint addVerticeGroup (const GLfloatVector &vector)
 Add a vertice group to the geometry and returns its id.
 
void setLineWidth (GLfloat lineWidth)
 Set Line width.
 
void setWireColor (const QColor &color)
 Set this geometry wire color.
 
virtual void glLoadTexture (void)
 Load each textures of materials.
 
virtual void render (const GLC_RenderProperties &)
 Virtual interface for OpenGL execution.
 

Protected Member Functions

OpenGL Functions
virtual void glDraw (const GLC_RenderProperties &renderProperties)
 Virtual interface for OpenGL Geometry set up.
 
OpenGL Functions
- Protected Member Functions inherited from GLC_Geometry
void removeMaterial (GLC_uint)
 Remove the specified material from the geometry.
 
void clearWireAndBoundingBox ()
 Clear the wire data and the bounding box of this geometry.
 
virtual void glPropGeom (const GLC_RenderProperties &)
 Virtual interface for OpenGL Geometry properties.
 

Private Member Functions

Private services Functions
void createMeshAndWire ()
 Create the extruded mesh mesh and wire.
 
void createMesh ()
 Create the extruded mesh mesh.
 
void createWire ()
 Create the extruded mesh wire.
 
void computeGivenFaceNormal ()
 compute the given face normal
 
bool pointsLieOnAPlane () const
 Return true if the list of points lie on a plane.
 
GLfloatVector baseOutlineNormals () const
 Return base outline normmals.
 
GLfloatVector createdOutlineNormals () const
 Return created outline normmals.
 
GLfloatVector baseFaceVertices () const
 Return base face vertices.
 
GLfloatVector baseFaceTexels () const
 Return base face texel.
 
GLfloatVector baseOutlineFacesVertices () const
 Return base outline faces vertices.
 
GLfloatVector basedOutlineFacesTexels () const
 Return base outline faces texels.
 
GLfloatVector baseFaceNormals () const
 Return the base face normals.
 
QList< GLC_Point3dcreatedFacePoints () const
 Return the list of points of the created face.
 
GLfloatVector createdFaceNormals () const
 Return the created face normals.
 
GLfloatVector createdFaceVertices () const
 Return created face vertices.
 
GLfloatVector createdFaceTexels () const
 Return created face texels.
 
GLfloatVector createdOutlineFacesVertices () const
 Return created outline faces vertices.
 
GLfloatVector createdOutlineFacesTexels () const
 Return created outline faces texels.
 

Private Attributes

QList< GLC_Point3dm_Points
 The list of point which define the face to extrude.
 
GLC_Vector3d m_ExtrusionVector
 The direction of extrusion.
 
double m_ExtrusionLenght
 The extrusion lenght.
 
GLC_Vector3d m_GivenFaceNormal
 The normal of the given face.
 

Static Private Attributes

static quint32 m_ChunkId = 0xA712
 Class chunk id.
 

Get Functions

QList< GLC_Point3dfacePoints () const
 Return the list of points which defined the face to extrude.
 
GLC_Vector3d extrusionVector () const
 Return the extrusion vector.
 
double extrusionLenght () const
 Return the extrusion lenght.
 
virtual GLC_Geometryclone () const
 Return a copy of the extruded mesh.
 
virtual const GLC_BoundingBoxboundingBox (void)
 Return the extruded mesh bounding box.
 
static quint32 chunckID ()
 Return the class Chunk ID.
 

Additional Inherited Members

- Public Types inherited from GLC_Mesh
typedef QHash< GLC_uint,
GLC_PrimitiveGroup * > 
LodPrimitiveGroups
 
typedef QHash< const int,
LodPrimitiveGroups * > 
PrimitiveGroupsHash
 
- Static Public Member Functions inherited from GLC_Mesh
static quint32 chunckID ()
 Return the class Chunk ID.
 
- Protected Attributes inherited from GLC_Geometry
bool m_GeometryIsValid
 Geometry validity.
 
GLC_BoundingBoxm_pBoundingBox
 Bounding box.
 
MaterialHash m_MaterialHash
 Material Hash table.
 
bool m_UseColorPerVertex
 Color per vertex usage.
 
bool m_IsSelected
 Selection state.
 
GLC_WireData m_WireData
 Wire Data.
 
QColor m_WireColor
 The wire color.
 
GLfloat m_LineWidth
 The line width.
 

Detailed Description

GLC_ExtrudedMesh : An Extruded mesh defined by a list of points, *a direction and a distance.

Definition at line 40 of file glc_extrudedmesh.h.

Constructor & Destructor Documentation

GLC_ExtrudedMesh::GLC_ExtrudedMesh ( const QList< GLC_Point3d > &  points,
const GLC_Vector3d dir,
double  lenght 
)

Default constructor.

The points list must be in counterclockwise order

Definition at line 34 of file glc_extrudedmesh.cpp.

References glc::compare(), computeGivenFaceNormal(), createMeshAndWire(), glc::EPSILON, m_Points, and pointsLieOnAPlane().

Referenced by clone().

GLC_ExtrudedMesh::GLC_ExtrudedMesh ( const GLC_ExtrudedMesh other)

Copy constructor.

Definition at line 49 of file glc_extrudedmesh.cpp.

References createMeshAndWire(), and GLC_Mesh::isEmpty().

GLC_ExtrudedMesh::~GLC_ExtrudedMesh ( )
virtual

Destructor.

Definition at line 62 of file glc_extrudedmesh.cpp.

Member Function Documentation

GLfloatVector GLC_ExtrudedMesh::basedOutlineFacesTexels ( ) const
private

Return base outline faces texels.

Definition at line 381 of file glc_extrudedmesh.cpp.

References m_Points, glc::normalyzePolygon(), glc::polygonIn2d(), GLC_Vector2d::x(), and GLC_Vector2d::y().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::baseFaceNormals ( ) const
private

Return the base face normals.

Definition at line 403 of file glc_extrudedmesh.cpp.

References m_GivenFaceNormal, m_Points, GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::baseFaceTexels ( ) const
private

Return base face texel.

Definition at line 343 of file glc_extrudedmesh.cpp.

References m_Points, glc::normalyzePolygon(), glc::polygonIn2d(), GLC_Vector2d::x(), and GLC_Vector2d::y().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::baseFaceVertices ( ) const
private

Return base face vertices.

Definition at line 328 of file glc_extrudedmesh.cpp.

References m_Points, GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh(), and createWire().

GLfloatVector GLC_ExtrudedMesh::baseOutlineFacesVertices ( ) const
private

Return base outline faces vertices.

Definition at line 361 of file glc_extrudedmesh.cpp.

References m_Points, GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::baseOutlineNormals ( ) const
private

Return base outline normmals.

Definition at line 280 of file glc_extrudedmesh.cpp.

References m_ExtrusionVector, m_Points, and GLC_Vector3d::normalize().

Referenced by createMesh().

const GLC_BoundingBox & GLC_ExtrudedMesh::boundingBox ( void  )
virtual

Return the extruded mesh bounding box.

Reimplemented from GLC_Mesh.

Definition at line 77 of file glc_extrudedmesh.cpp.

References GLC_Mesh::boundingBox(), createMeshAndWire(), and GLC_Mesh::isEmpty().

quint32 GLC_ExtrudedMesh::chunckID ( )
static

Return the class Chunk ID.

Definition at line 67 of file glc_extrudedmesh.cpp.

References m_ChunkId.

GLC_Geometry * GLC_ExtrudedMesh::clone ( ) const
virtual

Return a copy of the extruded mesh.

Reimplemented from GLC_Mesh.

Definition at line 72 of file glc_extrudedmesh.cpp.

References GLC_ExtrudedMesh().

void GLC_ExtrudedMesh::computeGivenFaceNormal ( )
private

compute the given face normal

Definition at line 249 of file glc_extrudedmesh.cpp.

References m_GivenFaceNormal, m_Points, and normalize().

Referenced by GLC_ExtrudedMesh().

GLfloatVector GLC_ExtrudedMesh::createdFaceNormals ( ) const
private

Return the created face normals.

Definition at line 431 of file glc_extrudedmesh.cpp.

References GLC_Vector3d::inverted(), m_GivenFaceNormal, m_Points, GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh().

QList< GLC_Point3d > GLC_ExtrudedMesh::createdFacePoints ( ) const
private

Return the list of points of the created face.

Definition at line 417 of file glc_extrudedmesh.cpp.

References m_ExtrusionLenght, m_ExtrusionVector, and m_Points.

Referenced by createdFaceTexels(), createdFaceVertices(), createdOutlineFacesTexels(), and createdOutlineFacesVertices().

GLfloatVector GLC_ExtrudedMesh::createdFaceTexels ( ) const
private

Return created face texels.

Definition at line 464 of file glc_extrudedmesh.cpp.

References createdFacePoints(), m_Points, glc::normalyzePolygon(), glc::polygonIn2d(), GLC_Vector2d::x(), and GLC_Vector2d::y().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::createdFaceVertices ( ) const
private

Return created face vertices.

Definition at line 447 of file glc_extrudedmesh.cpp.

References createdFacePoints(), GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh(), and createWire().

GLfloatVector GLC_ExtrudedMesh::createdOutlineFacesTexels ( ) const
private

Return created outline faces texels.

Definition at line 505 of file glc_extrudedmesh.cpp.

References createdFacePoints(), m_Points, glc::normalyzePolygon(), glc::polygonIn2d(), GLC_Vector2d::x(), and GLC_Vector2d::y().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::createdOutlineFacesVertices ( ) const
private

Return created outline faces vertices.

Definition at line 483 of file glc_extrudedmesh.cpp.

References createdFacePoints(), GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().

Referenced by createMesh().

GLfloatVector GLC_ExtrudedMesh::createdOutlineNormals ( ) const
private

Return created outline normmals.

Definition at line 303 of file glc_extrudedmesh.cpp.

References m_ExtrusionVector, m_Points, and GLC_Vector3d::normalize().

Referenced by createMesh().

void GLC_ExtrudedMesh::createMesh ( )
private
void GLC_ExtrudedMesh::createMeshAndWire ( )
private
void GLC_ExtrudedMesh::createWire ( )
private

Create the extruded mesh wire.

Definition at line 222 of file glc_extrudedmesh.cpp.

References GLC_Geometry::addVerticeGroup(), baseFaceVertices(), createdFaceVertices(), and m_Points.

Referenced by createMeshAndWire().

double GLC_ExtrudedMesh::extrusionLenght ( ) const
inline

Return the extrusion lenght.

Definition at line 77 of file glc_extrudedmesh.h.

GLC_Vector3d GLC_ExtrudedMesh::extrusionVector ( ) const
inline

Return the extrusion vector.

Definition at line 73 of file glc_extrudedmesh.h.

QList<GLC_Point3d> GLC_ExtrudedMesh::facePoints ( ) const
inline

Return the list of points which defined the face to extrude.

Definition at line 69 of file glc_extrudedmesh.h.

void GLC_ExtrudedMesh::glDraw ( const GLC_RenderProperties renderProperties)
protectedvirtual

Virtual interface for OpenGL Geometry set up.

This Virtual function have to be implemented in concrete class.

Reimplemented from GLC_Mesh.

Definition at line 527 of file glc_extrudedmesh.cpp.

References createMeshAndWire(), GLC_Mesh::glDraw(), and GLC_Mesh::isEmpty().

GLC_ExtrudedMesh & GLC_ExtrudedMesh::operator= ( const GLC_ExtrudedMesh other)

Assignement operator overload.

Definition at line 86 of file glc_extrudedmesh.cpp.

References m_ExtrusionLenght, m_ExtrusionVector, m_GivenFaceNormal, m_Points, and GLC_Mesh::operator=().

bool GLC_ExtrudedMesh::pointsLieOnAPlane ( ) const
private

Return true if the list of points lie on a plane.

Definition at line 259 of file glc_extrudedmesh.cpp.

References GLC_Plane::lieOnThisPlane(), and m_Points.

Referenced by GLC_ExtrudedMesh().

void GLC_ExtrudedMesh::setExtrudedLenght ( double  lenght)

Set the mesh extruded lenght.

Definition at line 126 of file glc_extrudedmesh.cpp.

References GLC_Mesh::clearMeshWireAndBoundingBox(), createMeshAndWire(), and m_ExtrusionLenght.

void GLC_ExtrudedMesh::setExtrudedVector ( const GLC_Vector3d extrudedVector)

Set the mesh extruded vector.

Definition at line 118 of file glc_extrudedmesh.cpp.

References GLC_Mesh::clearMeshWireAndBoundingBox(), createMeshAndWire(), and m_ExtrusionVector.

void GLC_ExtrudedMesh::setGeometry ( const QList< GLC_Point3d > &  points,
const GLC_Vector3d extrudedVector,
double  lenght 
)

Set the mesh from the given points, vector and lenght.

Definition at line 100 of file glc_extrudedmesh.cpp.

References GLC_Mesh::clearMeshWireAndBoundingBox(), createMeshAndWire(), m_ExtrusionLenght, m_ExtrusionVector, and m_Points.

void GLC_ExtrudedMesh::setPoints ( const QList< GLC_Point3d > &  points)

Set the mesh points list.

Definition at line 110 of file glc_extrudedmesh.cpp.

References GLC_Mesh::clearMeshWireAndBoundingBox(), createMeshAndWire(), and m_Points.

Member Data Documentation

quint32 GLC_ExtrudedMesh::m_ChunkId = 0xA712
staticprivate

Class chunk id.

Definition at line 200 of file glc_extrudedmesh.h.

Referenced by chunckID().

double GLC_ExtrudedMesh::m_ExtrusionLenght
private

The extrusion lenght.

Definition at line 194 of file glc_extrudedmesh.h.

Referenced by createdFacePoints(), operator=(), setExtrudedLenght(), and setGeometry().

GLC_Vector3d GLC_ExtrudedMesh::m_ExtrusionVector
private

The direction of extrusion.

Definition at line 191 of file glc_extrudedmesh.h.

Referenced by baseOutlineNormals(), createdFacePoints(), createdOutlineNormals(), operator=(), setExtrudedVector(), and setGeometry().

GLC_Vector3d GLC_ExtrudedMesh::m_GivenFaceNormal
private

The normal of the given face.

Definition at line 197 of file glc_extrudedmesh.h.

Referenced by baseFaceNormals(), computeGivenFaceNormal(), createdFaceNormals(), and operator=().

QList<GLC_Point3d> GLC_ExtrudedMesh::m_Points
private

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

©2005-2013 Laurent Ribon