1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "manualView3VContour.h"
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 manualView3VContour::manualView3VContour(int type)
36 // JSTG 25-02-08 ------------------------------
37 //_manContModel= new manualContourModel();
38 //---------------------------------------------
40 // ----------------------------------------------------------------------------
41 manualView3VContour::~manualView3VContour()
47 // ----------------------------------------------------------------------------
48 manualView3VContour * manualView3VContour :: Clone()
50 manualView3VContour * clone = new manualView3VContour( GetType() );
51 CopyAttributesTo(clone);
55 // ---------------------------------------------------------------------------
57 void manualView3VContour::CopyAttributesTo( manualView3VContour * cloneObject)
60 manualViewContour::CopyAttributesTo(cloneObject);
63 int manualView3VContour::GetType()
68 // ----------------------------------------------------------------------------
69 void manualView3VContour::FilterCordinateXYZ(double &x,double &y,double &z)
84 // ----------------------------------------------------------------------------
86 void manualView3VContour::RefreshContour() // virtula
88 manualViewContour::RefreshContour();
102 // JSTG 25-02-08 ----------------------------------------
103 //int nps = GetNumberOfPointsSpline();
104 int nps = _manContModel->GetNumberOfPointsSpline();
105 //-------------------------------------------------------
106 for( i = 0; i < nps; i++ )
108 _pts->GetPoint( i, pp );
109 FilterCordinateXYZ(pp[0],pp[1],pp[2]);
112 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] );
117 if (pp[0] < _minX) { _minX = pp[0]; }
118 if (pp[1] < _minY) { _minY = pp[1]; }
119 if (pp[2] < _minZ) { _minZ = pp[2]; }
120 if (pp[0] > _maxX) { _maxX = pp[0]; }
121 if (pp[1] > _maxY) { _maxY = pp[1]; }
122 if (pp[2] > _maxZ) { _maxY = pp[2]; }
133 // ----------------------------------------------------------------------------
135 void manualView3VContour::UpdateViewPoint(int id){ // virtual
137 manualPoint *mp = _manContModel->GetManualPoint(id);
142 FilterCordinateXYZ(x,y,z);
143 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
146 // ----------------------------------------------------------------------------
148 int manualView3VContour::GetIdPoint(int x, int y, int z) // virtual
151 if (_manContModel!=NULL){
155 TransfromCoordViewWorld(xx,yy,zz,-1);
156 ii=_manContModel->GetIdPoint(xx,yy,zz,GetRange(),_type);
161 // ----------------------------------------------------------------------------
162 bool manualView3VContour::ifTouchContour(int x,int y,int z){ // virtual
170 TransfromCoordViewWorld(xx,yy,zz,-1);
177 if ( (xx>=_minX) && (yy>=_minY) && (xx<=_maxX) && (yy<=_maxY)) { // boundaring box
178 unsigned int i, nps,nps_t;
179 nps = _sizePointsContour;
180 if (this->_manContModel->IfCloseContour()==true)
186 FilterCordinateXYZ(xx,yy,zz);
188 for( i = 0; i < nps_t; i++ ) {
189 _pts->GetPoint(i%nps, ppA);
190 _pts->GetPoint((i+1)%nps, ppB);
191 FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]);
192 FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]);
193 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
194 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
195 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]));
196 if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) {