manualView3VContour.cpp
Go to the documentation of this file.00001 #include "manualView3VContour.h"
00002
00003
00004
00005
00006
00007
00008 manualView3VContour::manualView3VContour(int type)
00009 {
00010 _type=type;
00011
00012
00013
00014 }
00015
00016 manualView3VContour::~manualView3VContour()
00017 {
00018 }
00019
00020
00021
00022
00023 manualView3VContour * manualView3VContour :: Clone()
00024 {
00025 manualView3VContour * clone = new manualView3VContour( GetType() );
00026 CopyAttributesTo(clone);
00027 return clone;
00028 }
00029
00030
00031
00032 void manualView3VContour::CopyAttributesTo( manualView3VContour * cloneObject)
00033 {
00034
00035 manualViewContour::CopyAttributesTo(cloneObject);
00036 }
00037
00038 int manualView3VContour::GetType()
00039 {
00040 return _type;
00041 }
00042
00043
00044 void manualView3VContour::FilterCordinateXYZ(double &x,double &y,double &z)
00045 {
00046 if (_type==0)
00047 {
00048 x=-1000;
00049 }
00050 if (_type==1)
00051 {
00052 y=500;
00053 }
00054 if (_type==2)
00055 {
00056 z=-1000;
00057 }
00058 }
00059
00060
00061 void manualView3VContour::RefreshContour()
00062 {
00063 manualViewContour::RefreshContour();
00064 int i;
00065 double pp[3];
00066
00067
00068 int nps = _manContModel->GetNumberOfPointsSpline();
00069
00070 for( i = 0; i < nps; i++ )
00071 {
00072 _pts->GetPoint( i, pp );
00073 FilterCordinateXYZ(pp[0],pp[1],pp[2]);
00074
00075
00076 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] );
00077 }
00078
00079 }
00080
00081
00082
00083 void manualView3VContour::UpdateViewPoint(int id){
00084 double x,y,z;
00085 manualPoint *mp = _manContModel->GetManualPoint(id);
00086 x=mp->GetX();
00087 y=mp->GetY();
00088 z=mp->GetZ();
00089
00090 FilterCordinateXYZ(x,y,z);
00091 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
00092 }
00093
00094
00095
00096 int manualView3VContour::GetIdPoint(int x, int y, int z)
00097 {
00098 int ii=-1;
00099 if (_manContModel!=NULL){
00100 double xx=x;
00101 double yy=y;
00102 double zz=z;
00103 TransfromCoordViewWorld(xx,yy,zz,-1);
00104 ii=_manContModel->GetIdPoint(xx,yy,zz,GetRange(),_type);
00105 }
00106 return ii;
00107 }
00108
00109
00110 bool manualView3VContour::ifTouchContour(int x,int y,int z){
00111 bool result=false;
00112 double xx=x;
00113 double yy=y;
00114 double zz=z;
00115 double ppA[3];
00116 double ppB[3];
00117 double d1,d2,d3;
00118 TransfromCoordViewWorld(xx,yy,zz,-1);
00119
00120
00121 xx = xx * _spc[0];
00122 yy = yy * _spc[1];
00123 zz = zz * _spc[2];
00124
00125 unsigned int i, nps,nps_t;
00126 nps = _sizePointsContour;
00127 if (this->_manContModel->IfCloseContour()==true)
00128 {
00129 nps_t = nps;
00130 } else {
00131 nps_t = nps-1;
00132 }
00133 FilterCordinateXYZ(xx,yy,zz);
00134
00135 for( i = 0; i < nps_t; i++ ) {
00136 _pts->GetPoint(i%nps, ppA);
00137 _pts->GetPoint((i+1)%nps, ppB);
00138 FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]);
00139 FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]);
00140 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
00141 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
00142 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]));
00143 if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) {
00144 result=true;
00145 i=nps;
00146 }
00147 }
00148 return result;
00149 }