35 #ifndef __PolygonMesh_h 36 #define __PolygonMesh_h 72 #ifndef __gVirtualXRayConfig_h 97 #ifndef __PhotonCrossSection_h 265 bool anAutoComputeNormalFlag,
266 bool aPrintDebugInfoFlag,
269 int aBufferUsageHing);
307 bool useVBO(
int aBufferUsageHing,
int aTypeOfPrimitive);
310 void setHU(
short HU);
316 void setMixture(
const std::map<int, double>& aMixture);
317 void setMixture(
const std::map<std::string, double>& aMixture);
483 void splitFaces(
bool aPrintDebugInfoFlag =
false);
515 int getIndex(
unsigned int anIndex)
const;
525 void setIndex(
unsigned int anIndex,
unsigned int aValue);
571 const void* aVertexArray,
572 unsigned int aNumberOfVertices,
574 const void* anIndexArray,
575 unsigned int aNumberOfIndices,
596 const std::vector<float>* aVertexArray,
616 const std::vector<double>* aVertexArray,
637 const std::vector<float>* aVertexArray,
638 const std::vector<unsigned int>* anIndexArray,
659 const std::vector<double>* aVertexArray,
660 const std::vector<unsigned int>* anIndexArray,
681 const std::vector<float>* aVertexArray,
682 const std::vector<unsigned short>* anIndexArray,
703 const std::vector<double>* aVertexArray,
704 const std::vector<unsigned short>* anIndexArray,
725 const std::vector<float>* aVertexArray,
726 const std::vector<unsigned char>* anIndexArray,
747 const std::vector<double>* aVertexArray,
748 const std::vector<unsigned char>* anIndexArray,
773 const void* aVertexArray,
774 unsigned int aNumberOfVertices,
775 unsigned int aVertexVBO,
776 unsigned int aNormalVBO,
777 unsigned int aTextureVBO,
778 unsigned int anIndexVBO,
779 unsigned int aNumberOfIndices,
781 const void* aIndexArray = NULL,
782 const void* aNormalArray = NULL
809 const void* aVertexArray,
810 unsigned int aNumberOfVertices,
812 const void* anIndexArray,
813 unsigned int aNumberOfIndices,
835 const std::vector<float>* aVertexArray,
836 const std::vector<float>* aNormalArray,
856 const std::vector<float>* aVertexArray,
877 const std::vector<double>* aVertexArray,
878 const std::vector<double>* aNormalArray,
898 const std::vector<double>* aVertexArray,
919 const std::vector<float>* aVertexArray,
920 const std::vector<unsigned int>* anIndexArray,
926 const std::vector<float>* aVertexArray,
927 const std::vector<float>* aNormalArray,
928 const std::vector<unsigned int>* anIndexArray,
949 const std::vector<double>* aVertexArray,
950 const std::vector<unsigned int>* anIndexArray,
972 const std::vector<double>* aVertexArray,
973 const std::vector<float>* aNormalArray,
974 const std::vector<unsigned int>* anIndexArray,
995 const std::vector<float>* aVertexArray,
996 const std::vector<unsigned short>* anIndexArray,
1018 const std::vector<float>* aVertexArray,
1019 const std::vector<float>* aNormalArray,
1020 const std::vector<unsigned short>* anIndexArray,
1021 bool aCreateVBOFlag,
1040 const std::vector<double>* aVertexArray,
1041 const std::vector<unsigned short>* anIndexArray,
1042 bool aCreateVBOFlag,
1063 const std::vector<double>* aVertexArray,
1064 const std::vector<float>* aNormalArray,
1065 const std::vector<unsigned short>* anIndexArray,
1066 bool aCreateVBOFlag,
1086 const std::vector<float>* aVertexArray,
1087 const std::vector<unsigned char>* anIndexArray,
1088 bool aCreateVBOFlag,
1109 const std::vector<float>* aVertexArray,
1110 const std::vector<float>* aNormalArray,
1111 const std::vector<unsigned char>* anIndexArray,
1112 bool aCreateVBOFlag,
1132 const std::vector<double>* aVertexArray,
1133 const std::vector<unsigned char>* anIndexArray,
1134 bool aCreateVBOFlag,
1155 const std::vector<double>* aVertexArray,
1156 const std::vector<float>* aNormalArray,
1157 const std::vector<unsigned char>* anIndexArray,
1158 bool aCreateVBOFlag,
1179 const std::vector<double>* aVertexArray,
1180 const std::vector<double>* aNormalArray,
1181 const std::vector<unsigned char>* anIndexArray,
1182 bool aCreateVBOFlag,
1203 const std::vector<double>* aVertexArray,
1204 const std::vector<double>* aNormalArray,
1205 const std::vector<unsigned short>* anIndexArray,
1206 bool aCreateVBOFlag,
1227 const std::vector<double>* aVertexArray,
1228 const std::vector<double>* aNormalArray,
1229 const std::vector<unsigned int>* anIndexArray,
1230 bool aCreateVBOFlag,
1274 virtual void updateVBO(
int aTypeOfVBO,
int aTypeOfPrimitive);
1286 virtual void updateVBOs(
unsigned int aVertexVBO,
1287 unsigned int aNormalVBO,
1288 unsigned int aTextureVBO,
1289 unsigned int anIndexVBO);
1410 const VEC3& aRayOrigin,
1411 const VEC3& aRayDirection,
1412 const MATRIX4& aTransformationMatrix)
const;
1456 void removeIndex(
bool aPrintDebugInfoFlag =
false);
1489 bool anAutoComputeNormalFlag,
1490 bool aPrintDebugInfoFlag,
1491 bool aCreateVBOFlag,
1493 int aBufferUsageHing);
1514 bool anAutoComputeNormalFlag,
1515 bool aPrintDebugInfoFlag,
1516 bool aCreateVBOFlag,
1518 int aBufferUsageHing);
1540 bool aMoveToCentreFlag,
1541 bool anAutoComputeNormalFlag,
1542 bool aPrintDebugInfoFlag,
1543 bool aCreateVBOFlag,
1545 int aBufferUsageHing);
1557 #if __cplusplus < 199711L 1645 #endif // __PolygonMesh_h void * m_p_vertex_set
Array containing the vertices.
void applyTransform(const MATRIX4 &aTransformationMatrix)
void copyVertexSet(const void *apVertexSet)
Copy a vertex set.
bool hasNormalVectorsInverted() const
Check if the normal vectors have been inverted.
virtual void updateVBO(int aTypeOfVBO, int aTypeOfPrimitive)
Update the VBO.
void copyIndexSet(const void *apIndexSet)
Copy an index set.
void setLinearAttenuationCoefficient(double aCoefficient)
void loadASCIISTLFile(bool aMoveToCentreFlag, bool anAutoComputeNormalFlag, bool aPrintDebugInfoFlag, bool aCreateVBOFlag, RATIONAL_NUMBER aScale, int aBufferUsageHing)
Set the name of the file that contains the polygon mesh.
VEC3 getVertex(unsigned int anIndex) const
Accessor on a given vertex.
void applyScaling(RATIONAL_NUMBER x, RATIONAL_NUMBER y, RATIONAL_NUMBER z)
void getTriangleVertices(VEC3 &v0, VEC3 &v1, VEC3 &v2, unsigned int anIndex) const
const std::string & getFilename() const
Accessor on the name of the file that contains the polygon mesh.
void loadBinarySTLFile(bool aMoveToCentreFlag, bool anAutoComputeNormalFlag, bool aPrintDebugInfoFlag, bool aCreateVBOFlag, RATIONAL_NUMBER aScale, int aBufferUsageHing)
Set the name of the file that contains the polygon mesh.
const PhotonCrossSection & getPhotonCrossSection() const
void setMassAttenuationCoefficient(double aCoefficient)
void display()
Display the triangular mesh using OpenGL.
virtual void updateVBOs(unsigned int aVertexVBO, unsigned int aNormalVBO, unsigned int aTextureVBO, unsigned int anIndexVBO)
Update the VBOs with VBO already created.
VEC3 m_local_max_corner
Upper corner of the bounding box.
unsigned int m_number_of_indices
Number of indices.
const Material & getMaterial() const
Accessor on the material of the polygon mesh.
void displayFaceNormal(RATIONAL_NUMBER aNormalSize=0.5 *cm)
Display the face normal vectors.
virtual PolygonMesh operator-(const PolygonMesh &aPolygonMesh) const
operator-.
void setVertex(unsigned int anIndex, const VEC3 &aVertex)
Change the value of a given vertex.
Class to handle vertex buffer objects (VBOs).
void setDisplayFlag(bool display)
Set if the mesh is displayed or not.
std::auto_ptr< PolygonMesh > m_p_face_normal_vbo
unsigned int m_number_of_vertices
Number of vertices.
void loadSTLDataFromBinaryStream(const char *apInputData, bool aMoveToCentreFlag, bool anAutoComputeNormalFlag, bool aPrintDebugInfoFlag, bool aCreateVBOFlag, RATIONAL_NUMBER aScale, int aBufferUsageHing)
Set the name of the file that contains the polygon mesh.
const VEC3 & getLocalMaxCorner() const
Accessor on the bounding box upper corner.
void computeNormalVectors()
Compute the normal vectors using the cross product method.
void setElement(unsigned short Z)
void setFileName(const char *aFilename)
Set the name of the file that contains the polygon mesh.
unsigned int getIndexNumber() const
Accessor on the number of indices.
virtual PolygonMesh operator+(const PolygonMesh &aPolygonMesh) const
operator+.
void * m_p_index_set
Array containing the index.
void setExternalData(int aTypeOfPrimitive, const void *aVertexArray, unsigned int aNumberOfVertices, int aVertexDataType, const void *anIndexArray, unsigned int aNumberOfIndices, int anIndexDataType, bool aCreateVBOFlag, int aTypeOfVBO)
void reset()
Reset the data.
const std::string & getMaterialLabel() const
virtual void copyFrom(const PolygonMesh &aPolygonMesh)
Copy.
virtual PolygonMesh & operator+=(const PolygonMesh &aPolygonMesh)
operator+=.
void moveToCenter()
Move the polygon to the center.
PolygonMesh()
Default constructor.
bool useVBO(int aBufferUsageHing, int aTypeOfPrimitive)
Use a vertex buffer object if possible.
virtual PolygonMesh & operator-=(const PolygonMesh &aPolygonMesh)
operator-=.
virtual PolygonMesh & operator=(const PolygonMesh &aPolygonMesh)
Copy operator.
int m_polygon_type
Polygon type; valid values are GL_TRIANGLES.
PolygonMesh is a class to handle polygon (triangles) meshes.
VEC3 getVertexNormal(unsigned int anIndex) const
Accessor on a given vertex normal.
void moveToCentre()
Move the polygon to the centre.
void setHounsfieldValue(short HU)
float RATIONAL_NUMBER
Type of data used to store real numbers.
void setIndex(unsigned int anIndex, unsigned int aValue)
Set the value of a given index.
void setDensity(double aDensity)
bool m_has_inverted_normal_vectors
A flag set to true if the normal vectors are inverted.
Class to manage photon cross sections of elements, compounds and mixtures.
PhotonCrossSection is a class to manage photon cross sections of elements, compounds and mixtures...
bool m_external_data_flag
VEC3 getFaceNormal(unsigned int anIndex) const
Accessor on a given face normal.
unsigned int getVertexNormalNumber() const
Accessor on the number of vertex normal vectors.
void applyTranslation(const VEC3 &aTranslationVector)
void destroyIndexData()
Release the memory held by the index data if needed.
void setVertexNormal(unsigned int anIndex, const VEC3 &aNormalVector)
unsigned int getVertexNumber() const
Accessor on the number of vertices.
Material m_material
Material of the object.
void setHounsfieldUnit(short HU)
const double cm
centimeter
const VEC3 & getLocalMinCorner() const
Accessor on the bounding box lower corner.
void applyRotation(const VEC3 &aRotationAxis, RATIONAL_NUMBER aRotationAngleInDegrees)
PhotonCrossSection m_photon_cross_section
Material properties, with respect to X-ray.
void setVBOData(const void *aVertexArray, unsigned int aNumberOfVertices, unsigned int aVertexVBO, unsigned int aNormalVBO, unsigned int aTextureVBO, unsigned int anIndexVBO, unsigned int aNumberOfIndices, int anIndexDataType, const void *aIndexArray=NULL, const void *aNormalArray=NULL)
std::auto_ptr< VBO > m_p_vbo
Vertex buffer object.
Units, such as meters, etc.
void writeSTLFile()
Write the STL file.
void displayWireFrame()
Display the triangular mesh in wireframe using OpenGL.
Material is a class to handle materials.
void mergeVertices(bool aPrintDebugInfoFlag=false)
void computeBoundingBox()
Update the bounding box.
std::vector< RATIONAL_NUMBER > m_p_vertex_normal_set
Array containing the normal vectors (one per triangle)
int getIndex(unsigned int anIndex) const
Accessor on a given index.
unsigned int getFaceNormalNumber() const
Accessor on the number of face normal vectors.
void destroyVertexData()
Release the memory held by the vertex data if needed.
~PolygonMesh()
Destructor.
std::string m_filename
Name of the file that contains the polygon mesh.
std::vector< double > getMixtureWeightSet() const
Accessor on the element weight set of the mixture of the polygon mesh.
void loadSTLFile(bool aMoveToCentreFlag, bool anAutoComputeNormalFlag, bool aPrintDebugInfoFlag, bool aCreateVBOFlag, RATIONAL_NUMBER aScale, int aBufferUsageHing)
Set the name of the file that contains the polygon mesh.
Mixture is a class to manage a mixture (e.g. Ti90Al6V4).
std::string getCompound() const
Accessor on the compound description of the polygon mesh.
void setInternalData(int aTypeOfPrimitive, const void *aVertexArray, unsigned int aNumberOfVertices, int aVertexDataType, const void *anIndexArray, unsigned int aNumberOfIndices, int anIndexDataType, bool aCreateVBOFlag, int aTypeOfVBO)
bool getDisplayFlag() const
Accessor on the display flag of the polygon mesh.
RATIONAL_NUMBER m_file_scale
Unit of length of the file that contains the polygon mesh (if negative, then unknown) ...
std::auto_ptr< PolygonMesh > m_p_vertex_normal_vbo
void applyScale(const RATIONAL_NUMBER &aScale)
void setMixture(const Mixture &aMixture)
void setCompound(const std::string &aName)
Class to handle polygon (triangles) meshes.
void displayVertexNormal(RATIONAL_NUMBER aNormalSize=0.5 *cm)
Display the vertex normal vectors.
void setFaceNormal(unsigned int anIndex, const VEC3 &aNormalVector)
unsigned int getFaceNumber() const
Accessor on the number of faces.
std::vector< int > getMixtureElementSet() const
Accessor on the element Z number set of the mixture of the polygon mesh.
void setFilename(const char *aFilename)
Set the name of the file that contains the polygon mesh.
void invertNormalVectors()
Inverse the normal vectors.
void normaliseNormals()
Normalise the normal vectors.
VEC3 m_local_min_corner
Lower corner of the bounding box.
unsigned int getTriangleNumber() const
Accessor on the number of triangles.
const RATIONAL_NUMBER & getUnitOfLength() const
Accessor on the unit of length of the mesh.
Class to handle a material.
void splitFaces(bool aPrintDebugInfoFlag=false)
Split each face into four faces.
std::map< RATIONAL_NUMBER, VEC3 > rayIntersect(const VEC3 &aRayOrigin, const VEC3 &aRayDirection, const MATRIX4 &aTransformationMatrix) const
void removeIndex(bool aPrintDebugInfoFlag=false)
Remove the index.