vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PS_Polyhedron.h
Go to the documentation of this file.
1 
8 #pragma once
9 
11 #include "PS_FacePlane.h"
12 #include "PS_Face.h"
13 #include "PS_Component.h"
14 #include "PS_Symmetry.h"
15 
16 namespace APDYNAMICART
17 {
18 
19 class PS_Polyhedron : public osg::Referenced
20 {
21 public:
22  PS_Polyhedron(const string& name);
23 
24  int initialize(std::string name, osg::ref_ptr<osg::MatrixTransform> layerNode);
25 
26  //load symmetries and face of polyhedron from XML files
27  int loadfromXML( std::string fileName );
28 
29  void createFacePlanes();
30  void setComponent( PS_ComponentPtr compo );
31 private:
32 
33  // pointer to parent scene graph node
34  osg::ref_ptr<osg::MatrixTransform> _layerNode;
35 
36  // pointer to face definition
37  PS_FacePtr _face;
38 
39  // pointer to component definition - probably not needed at all, just for convinient
40  PS_ComponentPtr _component;
41 
42  // list of all face planes
43  std::vector<PS_FacePlanePtr> _facePlanes;
44 
45  // structure holding all symmetries of polyhedron
46  PS_Symmetry* _poly_symmetry;
47 
48  // distance of face-planes from center of polyhedron
49  double _facePlaneDistance;
50 
51 
52 };
53 
54 typedef osg::ref_ptr<PS_Polyhedron> PS_PolyhedronPtr;
55 
56 
57 
58 
59 
60 
61 
62 
65 {
66 public:
67  static std::vector<std::string> getAvaiablePolyhedronNames()
68  {
69  std::vector<std::string> polyhedronNames;
70  polyhedronNames.push_back("Tetrahedron");
71  polyhedronNames.push_back("Hexahedron");
72  polyhedronNames.push_back("Dodecahedron");
73  return polyhedronNames;
74  }
75 
76  static PS_PolyhedronPtr getPolyhedron(const std::string& name)
77  {
78  dbgPS(__FUNCTION__);
79 
80  if (isValidName(name))
81  {
82  return new PS_Polyhedron(name);
83  }
84  else
85  {
86  err("Polyhedron: '" << name << " is not defined.");
87  return NULL;
88  }
89  }
90 
91  static bool isValidName(const std::string& name)
92  {
93  std::vector<std::string> names = getAvaiablePolyhedronNames();
94  for (u_int i = 0; i < names.size(); ++i)
95  {
96  if (names.at(i) == name)
97  {
98  return true;
99  }
100  }
101 
102  return false;
103  }
104 };
105 }