68 #ifndef __OutOfBoundsException_h 380 if (anIndex >= getFaceNumber())
385 if (m_number_of_indices)
387 VEC3 temp = (getVertexNormal(getIndex(anIndex * 3 + 0)) +
388 getVertexNormal(getIndex(anIndex * 3 + 1)) +
389 getVertexNormal(getIndex(anIndex * 3 + 2))) / 3.0;
391 VEC3 normal((getVertex(getIndex(anIndex * 3 + 2)) - getVertex(getIndex(anIndex * 3 + 0)))^(getVertex(getIndex(anIndex * 3 + 2)) - getVertex(getIndex(anIndex * 3 + 1))));
405 VEC3 normal((getVertex(anIndex * 3 + 2) - getVertex(anIndex * 3 + 0)) ^ (getVertex(anIndex * 3 + 2) - getVertex(3 + 1)));
427 if (getVertexNormalNumber() <= anIndex)
432 return (
VEC3(m_p_vertex_normal_set[anIndex * 3 + 0],
433 m_p_vertex_normal_set[anIndex * 3 + 1],
434 m_p_vertex_normal_set[anIndex * 3 + 2]));
523 VEC3 scaling_factors(x, y, z);
526 VEC3 vertex(
getVertex(i).elementWiseProduct(scaling_factors));
556 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"Do Not Use Face Normal");
593 aRotationAngleInDegrees,
687 translation_vector *= -1.0;
700 for (std::vector<RATIONAL_NUMBER>::iterator ite(
727 unsigned int idx2 =
getIndex(i + 1);
728 unsigned int idx3 =
getIndex(i + 2);
void setY(const T &aValue)
Set the position along the y-axis.
void * m_p_vertex_set
Array containing the vertices.
void applyTransform(const MATRIX4 &aTransformationMatrix)
std::vector< int > getMixtureElementSet() const
Accessor on the element Z number set of the mixture of the polygon mesh.
bool hasNormalVectorsInverted() const
Check if the normal vectors have been inverted.
virtual void updateVBO(int aTypeOfVBO, int aTypeOfPrimitive)
Update the VBO.
void setLinearAttenuationCoefficient(double aCoefficient)
VEC3 getVertex(unsigned int anIndex) const
Accessor on a given vertex.
void applyScaling(RATIONAL_NUMBER x, RATIONAL_NUMBER y, RATIONAL_NUMBER z)
const std::string & getFilename() const
Accessor on the name of the file that contains the polygon mesh.
const PhotonCrossSection & getPhotonCrossSection() const
static std::map< int, double > getMixtureWeightSet(const std::string &aName)
void setMassAttenuationCoefficient(double aCoefficient)
void display()
Display the triangular mesh using OpenGL.
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 setVertex(unsigned int anIndex, const VEC3 &aVertex)
Change the value of a given vertex.
void useElement(unsigned short Z)
VBO * createVBO()
Create an OpenGL VBO suitable for the current OpenGL context.
void setDisplayFlag(bool display)
Set if the mesh is displayed or not.
unsigned int m_number_of_vertices
Number of vertices.
std::string getCompound() const
Accessor on the compound description of the polygon mesh.
T getX() const
Accessor on the position along the x-axis.
const VEC3 & getLocalMaxCorner() const
Accessor on the bounding box upper corner.
T getZ() const
Accessor on the position along the z-axis.
Exception is a class to handle exceptions.
Vec3< T > elementWiseProduct(const Vec3 &aVector) const
Element-wise product.
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.
void setX(const T &aValue)
Set the position along the x-axis.
void * m_p_index_set
Array containing the index.
void reset()
Reset the data.
void useLinearAttenuationCoefficient(double aCoefficient)
void useCompound(const std::string &aName)
const std::string & getMaterialLabel() const
T getY() const
Accessor on the position along the y-axis.
void moveToCenter()
Move the polygon to the center.
bool useVBO(int aBufferUsageHing, int aTypeOfPrimitive)
Use a vertex buffer object if possible.
static Matrix4x4 buildRotationMatrix(RATIONAL_NUMBER anAngle, RATIONAL_NUMBER x, RATIONAL_NUMBER y, RATIONAL_NUMBER z)
Build a rotation matrix.
int m_polygon_type
Polygon type; valid values are GL_TRIANGLES.
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.
Vec3< RATIONAL_NUMBER > VEC3
Type of data used to store 3D vectors.
void setDensity(double aDensity)
bool m_has_inverted_normal_vectors
A flag set to true if the normal vectors are inverted.
const std::string & getLabel() const
PhotonCrossSection is a class to manage photon cross sections of elements, compounds and mixtures...
VEC3 getFaceNormal(unsigned int anIndex) const
Accessor on a given face normal.
void normalize()
Normalize the current vector so that its length is 1.
Some utility functions that do not fit anywhere else.
unsigned int getVertexNormalNumber() const
Accessor on the number of vertex normal vectors.
void applyTranslation(const VEC3 &aTranslationVector)
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 VEC3 & getLocalMinCorner() const
Accessor on the bounding box lower corner.
void applyRotation(const VEC3 &aRotationAxis, RATIONAL_NUMBER aRotationAngleInDegrees)
void useMixture(const Mixture &aMixture)
PhotonCrossSection m_photon_cross_section
Material properties, with respect to X-ray.
std::auto_ptr< VBO > m_p_vbo
Vertex buffer object.
Material is a class to handle materials.
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.
~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.
Mixture is a class to manage a mixture (e.g. Ti90Al6V4).
std::string getCompound() const
Accessor on the compound description of the polygon mesh.
Class to handle exceptions when accessing an array cell that is not accessible, i.e. out of bounds memory access.
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) ...
double getDensity() const
void applyScale(const RATIONAL_NUMBER &aScale)
void setMixture(const Mixture &aMixture)
void setCompound(const std::string &aName)
void setFaceNormal(unsigned int anIndex, const VEC3 &aNormalVector)
std::vector< int > getMixtureElementSet() const
Accessor on the element Z number set of the mixture of the polygon mesh.
double dotProduct(const Vec3 &aVector) const
Get the dot product between the current vector and a given vector.
void setFilename(const char *aFilename)
Set the name of the file that contains the polygon mesh.
void invertNormalVectors()
Inverse the normal vectors.
void useMassAttenuationCoefficient(double aCoefficient)
VEC3 m_local_min_corner
Lower corner of the bounding box.
const RATIONAL_NUMBER & getUnitOfLength() const
Accessor on the unit of length of the mesh.
void setZ(const T &aValue)
Set the position along the z-axis.
void setDensity(double aDensity)