gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
PolygonMesh.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2016, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
65 //******************************************************************************
66 // Include
67 //******************************************************************************
68 #ifndef __OutOfBoundsException_h
70 #endif
71 
72 #ifndef __Utilities_h
73 #include "gVirtualXRay/Utilities.h"
74 #endif
75 
76 
77 //******************************************************************************
78 // namespace
79 //******************************************************************************
80 namespace gVirtualXRay {
81 
82 
83 //--------------------------------
85 //--------------------------------
86 {
87  // Make sure the VBO and the dynamically allocated memory are released
88  reset();
89 }
90 //--------------------------------------------------------------------------
91 inline void PolygonMesh::setDisplayFlag(bool display)
92 //--------------------------------------------------------------------------
93 {
94  //Change the value of the display flag
96 }
97 
98 //--------------------------------------------------------------------------
99 inline bool PolygonMesh::getDisplayFlag() const
100 //--------------------------------------------------------------------------
101 {
102  // Return the display flag value
103  return m_display_flag;
104 }
105 
106 //---------------------------------------------------------
107 inline void PolygonMesh::setFilename(const char* aFilename)
108 //---------------------------------------------------------
109 {
110  // Store the name of the file that contains the polygon mesh
111  m_filename = aFilename;
112 }
113 
114 
115 //----------------------------------------------------------------
116 inline void PolygonMesh::setFilename(const std::string& aFilename)
117 //----------------------------------------------------------------
118 {
119  // Store the name of the file that contains the polygon mesh
120  m_filename = aFilename;
121 }
122 
123 
124 //---------------------------------------------------------
125 inline void PolygonMesh::setFileName(const char* aFilename)
126 //---------------------------------------------------------
127 {
128  // Store the name of the file that contains the polygon mesh
129  m_filename = aFilename;
130 }
131 
132 
133 //----------------------------------------------------------------
134 inline void PolygonMesh::setFileName(const std::string& aFilename)
135 //----------------------------------------------------------------
136 {
137  // Store the name of the file that contains the polygon mesh
138  m_filename = aFilename;
139 }
140 
141 
142 //--------------------------------------------------------
143 inline const std::string& PolygonMesh::getFilename() const
144 //--------------------------------------------------------
145 {
146  // Return the name of the file that contains the polygon mesh
147  return (m_filename);
148 }
149 
150 
151 //----------------------------------------------------------------
153 //----------------------------------------------------------------
154 {
155  return m_file_scale;
156 }
157 
158 
159 //-------------------------------------
161 //-------------------------------------
162 {
163  moveToCentre();
164 }
165 
166 
167 //-------------------------------------------------------------------
168 inline bool PolygonMesh::useVBO(int aTypeOfVBO, int aTypeOfPrimitive)
169 //-------------------------------------------------------------------
170 {
171  // Create the VBO if needed
172  if (!m_p_vbo.get())
173  {
174  m_p_vbo.reset(createVBO());
175  }
176 
177  // There is no data to store in a VBO
180  {
181  // Create a VBO if possible
182  updateVBO(aTypeOfVBO, aTypeOfPrimitive);
183  }
184 
185  return (m_p_vbo->isReady());
186 }
187 
188 
189 inline void PolygonMesh::setHU(short HU)
190 {
192 }
193 
194 
195 inline void PolygonMesh::setHounsfieldUnit(short HU)
196 {
197  setHU(HU);
198 }
199 
200 
201 inline void PolygonMesh::setHounsfieldValue(short HU)
202 {
203  setHU(HU);
204 }
205 
206 
207 inline void PolygonMesh::setElement(unsigned short Z)
208 {
210 }
211 
212 
213 inline void PolygonMesh::setElement(const std::string& aName)
214 {
216 }
217 
218 
219 inline void PolygonMesh::setMixture(const Mixture& aMixture)
220 {
222 }
223 
224 
225 inline void PolygonMesh::setMixture(const std::map<int, double>& aMixture)
226 {
228 }
229 
230 
231 inline void PolygonMesh::setMixture(const std::map<std::string, double>& aMixture)
232 {
234 }
235 
236 
237 inline void PolygonMesh::setMixture(const std::string& aName)
238 {
240 }
241 
242 
243 inline void PolygonMesh::setCompound(const std::string& aName)
244 {
246 }
247 
248 
249 inline void PolygonMesh::setMassAttenuationCoefficient(double aCoefficient)
250 {
252 }
253 
254 
255 inline void PolygonMesh::setLinearAttenuationCoefficient(double aCoefficient)
256 {
258 }
259 
260 
261 inline void PolygonMesh::setDensity(double aDensity)
262 {
264 }
265 
266 
268 {
269  return (m_photon_cross_section);
270 }
271 
272 
273 //-------------------------------------
274 inline double PolygonMesh::getDensity()
275 //-------------------------------------
276 {
278 }
279 
280 
281 //-------------------------------------------------------------
282 inline const std::string& PolygonMesh::getMaterialLabel() const
283 //-------------------------------------------------------------
284 {
285  return (m_photon_cross_section.getLabel());
286 }
287 
288 
289 //-------------------------------------------------
290 inline std::string PolygonMesh::getCompound() const
291 //-------------------------------------------------
292 {
294 }
295 
296 
297 //---------------------------------------------------------------
298 inline std::vector<int> PolygonMesh::getMixtureElementSet() const
299 //---------------------------------------------------------------
300 {
302 }
303 
304 
305 //-----------------------------------------------------------------
306 inline std::vector<double> PolygonMesh::getMixtureWeightSet() const
307 //-----------------------------------------------------------------
308 {
310 }
311 
312 
313 //-------------------------------------------------------
315 //-------------------------------------------------------
316 {
318 }
319 
320 
321 //-------------------------------------------------------
323 //-------------------------------------------------------
324 {
325  // Return the bounding box lower corner
326  return (m_local_min_corner);
327 }
328 
329 
330 //-------------------------------------------------------
332 //-------------------------------------------------------
333 {
334  // Return the bounding box upper corner
335  return (m_local_max_corner);
336 }
337 
338 
339 //----------------------------------------------------------
340 inline unsigned int PolygonMesh::getFaceNormalNumber() const
341 //----------------------------------------------------------
342 {
343  // Return the number of normal vectors
344  // There are 3 GLfloat values per normal
345  //return (m_p_face_normal_set.size() / 3);
346  return 0;
347 }
348 
349 
350 //------------------------------------------------------------
351 inline unsigned int PolygonMesh::getVertexNormalNumber() const
352 //------------------------------------------------------------
353 {
354  // Return the number of normal vectors
355  // There are 3 GLfloat values per normal
356  return (m_p_vertex_normal_set.size() / 3);
357 }
358 
359 
360 //------------------------------------------------------
361 inline unsigned int PolygonMesh::getVertexNumber() const
362 //------------------------------------------------------
363 {
364  return (m_number_of_vertices);
365 }
366 
367 
368 //-----------------------------------------------------
369 inline unsigned int PolygonMesh::getIndexNumber() const
370 //-----------------------------------------------------
371 {
372  return (m_number_of_indices);
373 }
374 
375 
376 //----------------------------------------------------------------
377 inline VEC3 PolygonMesh::getFaceNormal(unsigned int anIndex) const
378 //----------------------------------------------------------------
379 {
380  if (anIndex >= getFaceNumber())
381  {
382  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
383  }
384 
385  if (m_number_of_indices)
386  {
387  VEC3 temp = (getVertexNormal(getIndex(anIndex * 3 + 0)) +
388  getVertexNormal(getIndex(anIndex * 3 + 1)) +
389  getVertexNormal(getIndex(anIndex * 3 + 2))) / 3.0;
390 
391  VEC3 normal((getVertex(getIndex(anIndex * 3 + 2)) - getVertex(getIndex(anIndex * 3 + 0)))^(getVertex(getIndex(anIndex * 3 + 2)) - getVertex(getIndex(anIndex * 3 + 1))));
392  normal.normalize();
393 
394  if (sgn(normal.dotProduct(temp)) > 0)
395  {
396  return (normal);
397  }
398  else
399  {
400  return (-normal);
401  }
402  }
403  else
404  {
405  VEC3 normal((getVertex(anIndex * 3 + 2) - getVertex(anIndex * 3 + 0)) ^ (getVertex(anIndex * 3 + 2) - getVertex(3 + 1)));
406  normal.normalize();
407 
408 /* if (sgn(normal.dotProduct(temp)) > 0)
409  {
410  return (normal);
411  }
412  else
413  {
414  return (-normal);
415  }
416 */
417 
418  return (-normal);
419  }
420 }
421 
422 
423 //------------------------------------------------------------------
424 inline VEC3 PolygonMesh::getVertexNormal(unsigned int anIndex) const
425 //------------------------------------------------------------------
426 {
427  if (getVertexNormalNumber() <= anIndex)
428  {
429  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
430  }
431 
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]));
435 }
436 
437 
438 //-------------------------------------------
440 //-------------------------------------------
441 {
442  // There are vertices
444  {
447 
448  for (unsigned int i(1); i < m_number_of_vertices; ++i)
449  {
450  VEC3 vertex(getVertex(i));
451 
452  if (m_local_min_corner.getX() > vertex.getX())
453  m_local_min_corner.setX(vertex.getX());
454 
455  if (m_local_max_corner.getX() < vertex.getX())
456  m_local_max_corner.setX(vertex.getX());
457 
458  if (m_local_min_corner.getY() > vertex.getY())
459  m_local_min_corner.setY(vertex.getY());
460 
461  if (m_local_max_corner.getY() < vertex.getY())
462  m_local_max_corner.setY(vertex.getY());
463 
464  if (m_local_min_corner.getZ() > vertex.getZ())
465  m_local_min_corner.setZ(vertex.getZ());
466 
467  if (m_local_max_corner.getZ() < vertex.getZ())
468  m_local_max_corner.setZ(vertex.getZ());
469  }
470  }
471 }
472 
473 
474 //----------------------------------------------------------------
475 inline void PolygonMesh::applyScale(const RATIONAL_NUMBER& aScale)
476 //----------------------------------------------------------------
477 {
478  applyScale(aScale, aScale, aScale);
479 }
480 
481 
482 //-----------------------------------------------------------------------
483 inline void PolygonMesh::applyTranslation(const VEC3& aTranslationVector)
484 //-----------------------------------------------------------------------
485 {
487  {
488  for (unsigned int i(0); i < m_number_of_vertices; i++)
489  {
490  VEC3 vertex(getVertex(i) + aTranslationVector);
491  setVertex(i, vertex);
492  }
493 
494  m_local_min_corner += aTranslationVector;
495  m_local_max_corner += aTranslationVector;
496 
497  // The VBO exists
498  if (m_p_vbo.get())
499  {
500  // Update the VBO
501  if (m_p_vbo->isReady())
502  {
503  updateVBO(m_p_vbo->getBufferUsageHint(), m_p_vbo->getPrimitiveType());
504  }
505  // Reset the VBO to be on the safe side
506  else
507  {
508  m_p_vbo.reset(nullptr);
509  }
510  }
511  }
512 }
513 
514 
515 //------------------------------------------------------
517  RATIONAL_NUMBER y,
518  RATIONAL_NUMBER z)
519 //------------------------------------------------------
520 {
522  {
523  VEC3 scaling_factors(x, y, z);
524  for (unsigned int i(0); i < m_number_of_vertices; i++)
525  {
526  VEC3 vertex(getVertex(i).elementWiseProduct(scaling_factors));
527  setVertex(i, vertex);
528  }
529 
532 
533  // The VBO exists
534  if (m_p_vbo.get())
535  {
536  // Update the VBO
537  if (m_p_vbo->isReady())
538  {
539  updateVBO(m_p_vbo->getBufferUsageHint(), m_p_vbo->getPrimitiveType());
540  }
541  // Reset the VBO to be on the safe side
542  else
543  {
544  m_p_vbo.reset(nullptr);
545  }
546  }
547  }
548 }
549 
550 
551 //----------------------------------------------------------
552 inline void PolygonMesh::setFaceNormal(unsigned int anIndex,
553  const VEC3& aVertex)
554 //----------------------------------------------------------
555 {
556  throw Exception(__FILE__, __FUNCTION__, __LINE__, "Do Not Use Face Normal");
557 /*
558  if (getFaceNormalNumber() <= anIndex && m_p_face_normal_set.size())
559  {
560  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
561  }
562 
563  m_p_face_normal_set[anIndex * 3 + 0] = aVertex.getX();
564  m_p_face_normal_set[anIndex * 3 + 1] = aVertex.getY();
565  m_p_face_normal_set[anIndex * 3 + 2] = aVertex.getZ();*/
566 }
567 
568 
569 //------------------------------------------------------------
570 inline void PolygonMesh::setVertexNormal(unsigned int anIndex,
571  const VEC3& aVertex)
572 //------------------------------------------------------------
573 {
574  if (getVertexNormalNumber() <= anIndex && m_p_vertex_normal_set.size())
575  {
576  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
577  }
578 
579  m_p_vertex_normal_set[anIndex * 3 + 0] = aVertex.getX();
580  m_p_vertex_normal_set[anIndex * 3 + 1] = aVertex.getY();
581  m_p_vertex_normal_set[anIndex * 3 + 2] = aVertex.getZ();
582 }
583 
584 
585 //-----------------------------------------------------------------------------
586 inline void PolygonMesh::applyRotation(const VEC3& aRotationAxis,
587  RATIONAL_NUMBER aRotationAngleInDegrees)
588 //-----------------------------------------------------------------------------
589 {
591  {
592  MATRIX4 rotation_matrix(MATRIX4::buildRotationMatrix(
593  aRotationAngleInDegrees,
594  aRotationAxis));
595 
596  for (unsigned int i(0); i < m_number_of_vertices; i++)
597  {
598  VEC3 vertex(rotation_matrix * getVertex(i));
599  setVertex(i, vertex);
600  }
601 
602  for (unsigned int i(0); i < getFaceNormalNumber(); i++)
603  {
604  VEC3 normal_vector(rotation_matrix * getFaceNormal(i));
605  setFaceNormal(i, normal_vector);
606  }
607 
608  for (unsigned int i(0); i < getVertexNormalNumber(); i++)
609  {
610  VEC3 normal_vector(rotation_matrix * getVertexNormal(i));
611  setVertexNormal(i, normal_vector);
612  }
613 
614  // Update the bounding box
616 
617  // The VBO exists
618  if (m_p_vbo.get())
619  {
620  // Update the VBO
621  if (m_p_vbo->isReady())
622  {
623  updateVBO(m_p_vbo->getBufferUsageHint(), m_p_vbo->getPrimitiveType());
624  }
625  // Reset the VBO to be on the safe side
626  else
627  {
628  m_p_vbo.reset(nullptr);
629  }
630  }
631  }
632 }
633 
634 
635 //---------------------------------------------------------------------------
636 inline void PolygonMesh::applyTransform(const MATRIX4& aTransformationMatrix)
637 //---------------------------------------------------------------------------
638 {
640  {
641  for (unsigned int i(0); i < m_number_of_vertices; i++)
642  {
643  VEC3 vertex(aTransformationMatrix * getVertex(i));
644  setVertex(i, vertex);
645  }
646 
647  for (unsigned int i(0); i < getFaceNormalNumber(); i++)
648  {
649  VEC3 normal_vector(aTransformationMatrix * getFaceNormal(i));
650  normal_vector.normalize();
651  setFaceNormal(i, normal_vector);
652  }
653 
654  for (unsigned int i(0); i < getVertexNormalNumber(); i++)
655  {
656  VEC3 normal_vector(aTransformationMatrix * getVertexNormal(i));
657  normal_vector.normalize();
658  setVertexNormal(i, normal_vector);
659  }
660 
661  // Update the bounding box
663 
664  // The VBO exists
665  if (m_p_vbo.get())
666  {
667  // Update the VBO
668  if (m_p_vbo->isReady())
669  {
670  updateVBO(m_p_vbo->getBufferUsageHint(), m_p_vbo->getPrimitiveType());
671  }
672  // Reset the VBO to be on the safe side
673  else
674  {
675  m_p_vbo.reset(nullptr);
676  }
677  }
678  }
679 }
680 
681 
682 //-------------------------------------
684 //-------------------------------------
685 {
686  VEC3 translation_vector(m_local_min_corner + (m_local_max_corner - m_local_min_corner) / 2.0);
687  translation_vector *= -1.0;
688 
689  applyTranslation(translation_vector);
690 }
691 
692 
693 //--------------------------------------------
695 //--------------------------------------------
696 {
698 
699  // Re-order the vertex normals
700  for (std::vector<RATIONAL_NUMBER>::iterator ite(
701  m_p_vertex_normal_set.begin());
702  ite != m_p_vertex_normal_set.end();
703  ++ite)
704  {
705  *ite = -(*ite);
706  }
707 
708  // // Re-order the face normals
709  // for (std::vector<RATIONAL_NUMBER>::iterator ite(
710  // m_p_face_normal_set.begin());
711  // ite != m_p_face_normal_set.end();
712  // ++ite)
713  // {
714  // *ite = -(*ite);
715  // }
716 
717  // We are working with a triangle mesh
718  if (m_polygon_type == GL_TRIANGLES)
719  {
720  // An index is used
722  {
723  // Re-order the index
724  for (int i = 0; i < m_number_of_indices; i += 3)
725  {
726  // Swap two indices
727  unsigned int idx2 = getIndex(i + 1);
728  unsigned int idx3 = getIndex(i + 2);
729 
730  setIndex(i + 1, idx3);
731  setIndex(i + 2, idx2);
732  }
733  }
734  // An index is not used
736  {
737  // Re-order the vertices
738  for (int i = 0; i < m_number_of_vertices; i += 3)
739  {
740  // Swap two vertices
741  VEC3 vec2 = getVertex(i + 1);
742  VEC3 vec3 = getVertex(i + 2);
743 
744  setVertex(i + 1, vec3);
745  setVertex(i + 2, vec2);
746  }
747  }
748  }
749 
750  // Update the VBO
751  if (m_p_vbo.get())
752  {
753  if (m_p_vbo->isReady())
754  {
755  updateVBO(m_p_vbo->getBufferUsageHint(), m_p_vbo->getPrimitiveType());
756  }
757  }
758 }
759 
760 
761 //-----------------------------------------------------
762 inline const Material& PolygonMesh::getMaterial() const
763 //-----------------------------------------------------
764 {
765  return (m_material);
766 }
767 
768 
769 //-----------------------------------------
771 //-----------------------------------------
772 {
773  return (m_material);
774 }
775 
776 
777 } // namespace gVirtualXRay
void setY(const T &aValue)
Set the position along the y-axis.
Definition: Vec3.inl:99
void * m_p_vertex_set
Array containing the vertices.
Definition: PolygonMesh.h:1589
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.
Definition: PolygonMesh.h:1577
unsigned int m_number_of_indices
Number of indices.
Definition: PolygonMesh.h:1597
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.
Definition: PolygonMesh.inl:91
unsigned int m_number_of_vertices
Number of vertices.
Definition: PolygonMesh.h:1601
std::string getCompound() const
Accessor on the compound description of the polygon mesh.
T getX() const
Accessor on the position along the x-axis.
Definition: Vec3.inl:115
const VEC3 & getLocalMaxCorner() const
Accessor on the bounding box upper corner.
T getZ() const
Accessor on the position along the z-axis.
Definition: Vec3.inl:131
Exception is a class to handle exceptions.
Definition: Exception.h:109
Vec3< T > elementWiseProduct(const Vec3 &aVector) const
Element-wise product.
Definition: Vec3.inl:201
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.
Definition: Vec3.inl:91
void * m_p_index_set
Array containing the index.
Definition: PolygonMesh.h:1593
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.
Definition: Vec3.inl:123
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.
Definition: Matrix4x4.inl:307
int m_polygon_type
Polygon type; valid values are GL_TRIANGLES.
Definition: PolygonMesh.h:1615
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.
Definition: Types.h:107
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.
Definition: Types.h:115
void setDensity(double aDensity)
bool m_has_inverted_normal_vectors
A flag set to true if the normal vectors are inverted.
Definition: PolygonMesh.h:1634
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.
Definition: Vec3.inl:155
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.
Definition: PolygonMesh.h:1630
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.
Definition: PolygonMesh.h:1569
std::auto_ptr< VBO > m_p_vbo
Vertex buffer object.
Definition: PolygonMesh.h:1558
Material is a class to handle materials.
Definition: Material.h:86
void computeBoundingBox()
Update the bounding box.
std::vector< RATIONAL_NUMBER > m_p_vertex_normal_set
Array containing the normal vectors (one per triangle)
Definition: PolygonMesh.h:1585
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.
Definition: PolygonMesh.inl:84
std::string m_filename
Name of the file that contains the polygon mesh.
Definition: PolygonMesh.h:1549
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).
Definition: Mixture.h:101
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.
Definition: PolygonMesh.inl:99
RATIONAL_NUMBER m_file_scale
Unit of length of the file that contains the polygon mesh (if negative, then unknown) ...
Definition: PolygonMesh.h:1553
int sgn(const T &aValue)
Definition: Utilities.inl:419
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.
Definition: Vec3.inl:174
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.
Definition: PolygonMesh.h:1573
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.
Definition: Vec3.inl:107