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();
99 // JSTG 25-02-08 ----------------------------------------
100 //int nps = GetNumberOfPointsSpline();
101 int nps = _manContModel->GetNumberOfPointsSpline();
102 //-------------------------------------------------------
103 for( i = 0; i < nps; i++ )
105 _pts->GetPoint( i, pp );
106 FilterCordinateXYZ(pp[0],pp[1],pp[2]);
108 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] );
111 if (pp[0] < _minX) { _minX = pp[0]; }
112 if (pp[1] < _minY) { _minY = pp[1]; }
113 if (pp[2] < _minZ) { _minZ = pp[2]; }
114 if (pp[0] > _maxX) { _maxX = pp[0]; }
115 if (pp[1] > _maxY) { _maxY = pp[1]; }
116 if (pp[2] > _maxZ) { _maxY = pp[2]; }
125 // ----------------------------------------------------------------------------
127 void manualView3VContour::UpdateViewPoint(int id){ // virtual
129 manualPoint *mp = _manContModel->GetManualPoint(id);
134 FilterCordinateXYZ(x,y,z);
135 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
138 // ----------------------------------------------------------------------------
140 int manualView3VContour::GetIdPoint(int x, int y, int z) // virtual
143 if (_manContModel!=NULL){
147 TransfromCoordViewWorld(xx,yy,zz,-1);
148 ii=_manContModel->GetIdPoint(xx,yy,zz,GetRange(),_type);
153 // ----------------------------------------------------------------------------
154 bool manualView3VContour::ifTouchContour(int x,int y,int z){ // virtual
162 TransfromCoordViewWorld(xx,yy,zz,-1);
169 if ( (xx>=_minX) && (yy>=_minY) && (xx<=_maxX) && (yy<=_maxY)) { // boundaring box
170 unsigned int i, nps,nps_t;
171 nps = _sizePointsContour;
172 if (this->_manContModel->IfCloseContour()==true)
178 FilterCordinateXYZ(xx,yy,zz);
180 for( i = 0; i < nps_t; i++ ) {
181 _pts->GetPoint(i%nps, ppA);
182 _pts->GetPoint((i+1)%nps, ppB);
183 FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]);
184 FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]);
185 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
186 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
187 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]));
188 if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) {