00001 #include "manualContourModelRotationTool.h" 00002 00003 // ---------------------------------------------------------------------------- 00004 // ---------------------------------------------------------------------------- 00005 // ---------------------------------------------------------------------------- 00006 00007 manualContourModelRotationTool::manualContourModelRotationTool() 00008 { 00009 } 00010 00011 //---------------------------------------------------------------- 00012 00013 manualContourModelRotationTool::~manualContourModelRotationTool() 00014 { 00015 } 00016 00017 00018 // ---------------------------------------------------------------------------- 00019 manualContourModelRotationTool * manualContourModelRotationTool :: Clone() // virtual 00020 { 00021 manualContourModelRotationTool * clone = new manualContourModelRotationTool(); 00022 CopyAttributesTo(clone); 00023 return clone; 00024 } 00025 00026 // --------------------------------------------------------------------------- 00027 void manualContourModelRotationTool::CopyAttributesTo( manualContourModelRotationTool * cloneObject) 00028 { 00029 // Fathers object 00030 manualContourModelRotationTool::CopyAttributesTo(cloneObject); 00031 } 00032 00033 //---------------------------------------------------------------- 00034 int manualContourModelRotationTool::GetTypeModel() //virtual 00035 { 00036 return 8; 00037 } 00038 00039 //---------------------------------------------------------------- 00040 void manualContourModelRotationTool::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal 00041 { 00042 int nps = GetNumberOfPointsSpline(); 00043 //Spline points of the circle 00044 if(i<nps-2) 00045 { 00046 double angle = _deltaAngle*i; 00047 *x = _radio*cos(angle) + _centerX; 00048 *y = _radio*sin(angle) + _centerY; 00049 *z = _centerZ; 00050 } 00051 //Spline points of the reference line 00052 if(i==nps-2) 00053 { 00054 *x = _centerX; 00055 *y = _centerY; 00056 *z = _centerZ; 00057 } 00058 //Spline points of the movable line 00059 if(i==nps-1) 00060 { 00061 manualPoint *mpA= GetManualPoint(2); 00062 *x = mpA->GetX(); 00063 *y = mpA->GetY(); 00064 *z = _centerZ; 00065 } 00066 00067 } 00068 00069 // --------------------------------------------------------------------------- 00070 void manualContourModelRotationTool:: UpdateSpline() 00071 { 00072 manualPoint *mpA,*mpB,*mpC; 00073 double difX,difY; 00074 double x, y; 00075 int np = GetSizeLstPoints( ); 00076 int nps = GetNumberOfPointsSpline(); 00077 _deltaAngle=(3.14159265*2)/(nps-1-2); 00078 00079 if (np==3) 00080 { 00081 mpA = GetManualPoint(0); 00082 mpB = GetManualPoint(1); 00083 mpC = GetManualPoint(2); 00084 difX = mpA->GetX() - mpB->GetX(); 00085 difY = mpA->GetY() - mpB->GetY(); 00086 _radio = sqrt( difX*difX + difY*difY ); 00087 _centerX = mpA->GetX(); 00088 _centerY = mpA->GetY(); 00089 _centerZ = mpA->GetZ(); 00090 00091 x= mpC->GetX() - mpA->GetX(); 00092 y= mpC->GetY() - mpA->GetY(); 00093 _angle= atan(y/x)*180/(3.14159265); 00094 cout << "Scale" <<_radio <<endl; 00095 cout << "Angle" <<_angle <<endl; 00096 cout<< "Center"<<_centerX<<","<<_centerY<<endl; 00097 } 00098 else 00099 { 00100 _radio = -1; 00101 _centerX = -1; 00102 _centerY = -1; 00103 _centerZ = -1; 00104 _angle = -1; 00105 } 00106 } 00107 00108 //---------------------------------------------------------------- 00109 double manualContourModelRotationTool::getRadio() 00110 { 00111 return _radio; 00112 } 00113 00114 //---------------------------------------------------------------- 00115 double manualContourModelRotationTool::getAngle() 00116 { 00117 return _angle; 00118 } 00119 00120 00121 std::vector<double> manualContourModelRotationTool::getCenter() 00122 { 00123 manualPoint *mpCenter = GetManualPoint(0); 00124 std::vector<double> centro(2,0); 00125 centro[0]=mpCenter->GetX(); 00126 centro[1]=mpCenter->GetY(); 00127 return centro; 00128 00129 }