]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3VContour.cpp
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualView3VContour.cpp
1 #include "manualView3VContour.h"
2
3
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 // ----------------------------------------------------------------------------
7
8 manualView3VContour::manualView3VContour(int type)
9 {
10         _type=type;
11 // JSTG 25-02-08 ------------------------------
12         //_manContModel= new manualContourModel();
13 //---------------------------------------------
14 }
15 // ----------------------------------------------------------------------------
16 manualView3VContour::~manualView3VContour()
17 {
18 }
19
20
21
22 // ----------------------------------------------------------------------------
23 manualView3VContour * manualView3VContour :: Clone()
24 {
25         manualView3VContour * clone = new manualView3VContour( GetType() );
26         CopyAttributesTo(clone);
27         return clone;
28 }
29
30 // ---------------------------------------------------------------------------
31
32 void manualView3VContour::CopyAttributesTo( manualView3VContour * cloneObject)
33 {
34         // Fathers object
35         manualViewContour::CopyAttributesTo(cloneObject);
36 }
37
38 int manualView3VContour::GetType()
39 {
40         return _type;
41 }
42
43 // ----------------------------------------------------------------------------
44 void manualView3VContour::FilterCordinateXYZ(double &x,double &y,double &z)
45 {
46         if (_type==0)
47         {
48                 x=-1000;
49         }
50         if (_type==1)
51         {
52                 y=500;
53         }
54         if (_type==2)
55         {
56                 z=-1000;
57         }
58 }
59 // ----------------------------------------------------------------------------
60
61 void manualView3VContour::RefreshContour()  // virtula
62 {
63         manualViewContour::RefreshContour();
64         int i;
65         double pp[3];
66 // JSTG 25-02-08 ----------------------------------------
67         //int nps = GetNumberOfPointsSpline();
68         int nps = _manContModel->GetNumberOfPointsSpline();
69 //-------------------------------------------------------
70         for( i = 0; i < nps; i++ )
71         {
72                 _pts->GetPoint( i, pp );
73                 FilterCordinateXYZ(pp[0],pp[1],pp[2]);
74
75 //EED 27 sep 2006
76                 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] );
77         }
78
79 }
80
81 // ----------------------------------------------------------------------------
82
83 void manualView3VContour::UpdateViewPoint(int id){  // virtual
84         double x,y,z;
85         manualPoint             *mp             = _manContModel->GetManualPoint(id);
86         x=mp->GetX();
87         y=mp->GetY();
88         z=mp->GetZ();
89
90         FilterCordinateXYZ(x,y,z);
91         _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
92 }
93
94 // ----------------------------------------------------------------------------
95
96 int     manualView3VContour::GetIdPoint(int x, int y, int z) // virtual
97 {
98         int ii=-1;
99         if (_manContModel!=NULL){
100                 double xx=x;
101                 double yy=y;
102                 double zz=z;
103                 TransfromeCoordViewWorld(xx,yy,zz,-1);
104                 ii=_manContModel->GetIdPoint(xx,yy,zz,GetRange(),_type);
105         }
106         return ii;
107 }
108
109 // ----------------------------------------------------------------------------
110 bool manualView3VContour::ifTouchContour(int x,int y,int z){ // virtual
111         bool result=false;
112         double xx=x;
113         double yy=y;
114         double zz=z;
115         double ppA[3];
116         double ppB[3];
117         double d1,d2,d3;
118         TransfromeCoordViewWorld(xx,yy,zz,-1);
119
120 //EED 27 sep 2006
121         xx = xx * _spc[0];
122         yy = yy * _spc[1];
123         zz = zz * _spc[2];
124
125     unsigned int i, nps,nps_t;
126     nps   = _sizePointsContour;
127         if (this->_manContModel->IfCloseContour()==true)
128         {
129                 nps_t = nps;
130         } else {
131                 nps_t = nps-1;
132         }
133         FilterCordinateXYZ(xx,yy,zz);
134
135     for( i = 0; i < nps_t; i++ ) {
136                 _pts->GetPoint(i%nps, ppA);
137                 _pts->GetPoint((i+1)%nps, ppB);
138                 FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]);
139                 FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]);
140                 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
141                 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
142                 d3= sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2]));
143                 if (  ((d1+d2)>=d3) &&  ((d1+d2)<=d3*1.3) ) {
144                         result=true;
145                         i=nps;
146                 }
147         }
148         return result;
149 }