vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConnectEditor.h
Go to the documentation of this file.
1 #ifndef CONNECT_EDITOR_H
2 #define CONNECT_EDITOR_H
3 
4 #include <time.h>
5 #include "../EditorController/ControllableAbility.h"
6 #include "functions.h"
7 #include "SnapObject.h"
8 #include "normal.h"
9 
10 //#define TIME //print time of functions - for optimalization
11 
12 
13 
14 using namespace vrecko;
15 
16 namespace APConnectEditor {
17 
18 //class Snap;
19 
21 {
22 private:
23 
24  bool isOptimalized; // at first computation with snapping optimalize objects
25 
27  //variables used for XML paramaters
28  bool bApplyConnecting; //connecting
29  bool bApplySnapping; //snapping by icp algorithm
30  bool bNotApplyScaling; //use scaling in icp or not
31 
32  SnapObject *target, *source;
33 
34 
35 
36 
37 
38 
39 public:
40  ConnectEditor();
41  virtual ~ConnectEditor() { deactivate(); }
42  virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pParametersNode);
43 
44 
45 
46 protected:
47  virtual void fillDefaultInfo();
48  virtual bool activate();
49  virtual void deactivate();
50  virtual void processButtonRelease(vrecko::CABUTTONEVENT* eventData); //call method - snap || merge || ...
51  //virtual void menuItemClicked(const char* itemID); //zatim neni potreba snad pozdeji jestli bude potreba dynamickeho menu
52 
53 
54 
56 //My functions
57  bool init();
58  bool snap();
59 
60 
61 
63 //My functions
64 private:
65 
66  //function make one ICP iteration and transform object - use translation, scaling and rotation transformation
67  bool icp();//does not apply on object but only on matrix - smaller error to deform mesh
68 
69  //transformation - || 0-3 - quaternion of rotation || 4-6 - translation || 7 - scaling
70  void icp_iteration(osg::Vec3Array* targetPoints, osg::Vec3Array* sourcePoints, vector<int> targetSnappingRegion, vector<int> closestPoints, float transformation[8]);
71 
72  //start icp - compute only translation and scale
73  void icp_scale(osg::Vec3Array* targetPoints, osg::Vec3Array* sourcePoints, vector<int> targetSnappingRegion, vector<int> sourceSnappingRegion, float transformation[8]);
74  void icp_translate(osg::Vec3Array* targetPoints, osg::Vec3Array* sourcePoints, vector<int> targetSnappingRegion, vector<int> sourceSnappingRegion, float transformation[8]);
75 
76  //compute error for icp
77  float computeError(osg::Vec3Array* targetPoints, osg::Vec3Array* sourcePoints, vector<int> targetSnappingRegion, vector<int> closestPoints);
78 
79  //get snapping region - find informations and call getSnapRegion with this informations
80  vector<int> getSnappingRegion(SnapObject *browsingObject, SnapObject *colisionObject);
81 
82  bool morphObjects();
83  bool connectObjects();
84  void optimalizeEraseLoop(vector<int> &eraseLoop);
85 
86  bool testPreConditions();
87 
88 };
89 
90 
91 
92 
93 } //end APConnectEditor
94 
95 #endif //CONNECT_EDITOR_H
96 
97