vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SnapObject.h
Go to the documentation of this file.
1 #ifndef SNAPOBJECT_H
2 #define SNAPOBJECT_H
3 
5 #include "functions.h"
6 
7 
8 
9 class SnapObject
10 {
11 public:
12  SnapObject();
13  SnapObject(int id);
15  ~SnapObject();
16 
17 private:
18  unsigned long ID;
20 
21 
23  //temporary variables for computing
24 
25  bool graph_dirty; //if there is need to update graph set this value to true
26  vector<map<int, int>> * graph; //graph of object - edges
27 
28  bool simpleGraph_dirty;
29  vector<set<int>> * simpleGraph; //simple graph without count of edges
30 
31 
32  bool maxDistance_dirty; //if there is need to compute this distance
33  float maxDistance; //max geodesic distance targetMaxDistance from boundary loop
34 
35  bool snappingRegion_dirty;
36  vector<int> snappingRegion; //snaping region
37  vector<float> * snappingRegionValues; //distance of aech point in snapping region to the boundary loop
38 
39  bool boundaryLoop_dirty;
40  vector<vector<int>> * boundaryLoop; //closest point to boundary loop
41  vector<osg::Vec3> boundaryLoopCentroids;
42  unsigned long choosenBoundaryLoop;
43 
44  bool closestPoint_dirty;
45  vector<int> closestPoint; //closest point to boundary loop
46 
47 public:
48  void setId(unsigned long ID);
49  unsigned long getId();
50 
53 
54  void setDirtyGraph(bool dirty);
55  bool getDirtyGraph();
56 
57  void setDirtyMaxDistance(bool dirty);
58  bool getDirtyMaxDistance();
59 
60  void setDirtySnappingRegion(bool dirty);
62 
63  void setDirtyBoundaryLoop(bool dirty);
64  bool getDirtyBoundaryLoop();
65 
66  void setDirtyClosestPoint(bool dirty);
67  bool getDirtyClosestPoint();
68 
69  void setDirtyAll(bool dirty);
70 
71  void setChoosenBoundaryLoop(unsigned long position);
72  unsigned long getChoosenBoundaryLoop();
73 
74 
75 
77 //FUNCTIONS
78 public:
79  //get geode of node graf
80  osg::Geode* getGeode();
81  osg::Geode* getGeodeOf(osg::Node *eo);
82 
83  //get geometry of node graf
84  osg::Geometry* getGeometry();
85 
86  //get vertices
87  osg::Vec3Array* getVertices();
88 
89  //get colors
90  osg::Vec4Array* getColors();
91 
92  //get normals
93  osg::Vec3Array* getNormals();
94 
95  //get faces
96  osg::DrawElementsUShort* getFaces();
97 
98  //get primitive set - store count of point and definition
99  osg::PrimitiveSet* getPrimitiveSet();
100 
101 
102  //get boundary loop of object
103  vector<vector<int>> * getBoundaryLoops();
104  vector<vector<int>> * findBoundaryLoops();
105  vector<int> getBoundaryLoop();
106  vector<osg::Vec3> getBoundaryLoopCentroids();
107  bool chooseBoundaryLoop(SnapObject *object); //choose chich loop of each object we will use
108 
109 
110  //getGraph
111  vector<map<int, int>> * getGraph();
112  vector<map<int, int>> * createGraph();
113 
114  vector<set<int>> * getSimpleGraph();
115  vector<set<int>> * createSimpleGraph();
116 
117  vector<int> getSnapRegion();
118 
119  vector<int> getClosestPoint(SnapObject *object);
120  vector<int> findClosestPoint(SnapObject *object);
121 
122  vector<int> getClosestSnappingRegionPoints(SnapObject *object);
123  vector<int> findClosestSnappingRegionPoints(SnapObject *object);
124 
125 
126  //getSnappingRegion
127  //optimalization - combine findMaxDistance and getSnappingRegion
128  vector<int> getSnappingRegion();
129  vector<float> * getSnappingRegionValues();
130  float getMaxDistance();
131  vector<int> getSnapRegionWithDistanceSet();
132 
133 
134  //shortest path
135  vector<int> findShortestPath(int pointA, int pointB);
136 
137  void updateDisplayList();
138  void deleteFromScene();
139  void recomputeNormal();
140 
141  bool erasePoints(vector<int> &boundaryLoopToErase, vector<int> &eraseLoop);
142  bool erasePointsAndAllFaces(vector<int> &boundaryLoopToErase, vector<int> &eraseLoop);
143  bool mergeObject(SnapObject *object);
144 
145  int findClosestPoint(osg::Vec3 point);
146 
147  //get part of object - we have seed and boundary loop
148  set<int> getPartOfObject(int seed, set<int> cuttingLoopSet);
149 
150  //return true if object is suitable for processing
151  bool SnapObject::isSuitable();
152 
153 
154  void optimalizeLoop(vector<int> &loop);
155 
156 };
157 
158 #endif // SNAPOBJECT_H
159