manualView3DContour.cpp
Go to the documentation of this file.00001 #include "manualView3DContour.h"
00002
00003
00004
00005
00006 manualView3DContour::manualView3DContour()
00007 {
00008 }
00009
00010 manualView3DContour::~manualView3DContour()
00011 {
00012 }
00013
00014
00015 manualView3DContour * manualView3DContour :: Clone()
00016 {
00017 manualView3DContour * clone = new manualView3DContour();
00018 CopyAttributesTo(clone);
00019 return clone;
00020 }
00021
00022
00023 void manualView3DContour::CopyAttributesTo( manualView3DContour * cloneObject)
00024 {
00025
00026 manualViewContour::CopyAttributesTo(cloneObject);
00027
00028 cloneObject->SetDimensions ( _w , _h , _d );
00029 }
00030
00031 void manualView3DContour::SetDimensions(int w, int h, int d)
00032 {
00033 _w = w;
00034 _h = h;
00035 _d = d;
00036 }
00037
00038 void manualView3DContour::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)
00039 {
00040 X = _vtkmprbasedata->GetX();
00041 Y = _vtkmprbasedata->GetY();
00042 Z = _vtkmprbasedata->GetZ();
00043 }
00044
00045 void manualView3DContour::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
00046 {
00047 _vtkmprbasedata = vtkmprbasedata;
00048 }
00049
00050 int manualView3DContour::GetIdPoint2(int x, int y)
00051 {
00052 int id = -1;
00053 double p[3],pA[3],pB[3];
00054
00055 double pickPoint[ 3 ], cameraPos[ 3 ];
00056 vtkPointPicker* picker = vtkPointPicker::New( );
00057 vtkRenderer *pRenderer = this->GetWxVtkBaseView()->GetRenderer();
00058 picker->Pick( x, y, 0.0, pRenderer );
00059 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
00060 picker->GetPickPosition( pickPoint );
00061 picker->Delete( );
00062
00063 UtilVtk3DGeometriSelection utilVtk3Dgeometriselection;
00064 utilVtk3Dgeometriselection.SetDimentions(_w,_h,_d);
00065
00066 if( utilVtk3Dgeometriselection.FindCubePointsFromPoints( pA, pB, pickPoint, cameraPos ) )
00067 {
00068 double dist,distMin=999999999;
00069 int i,size=this->_manContModel->GetSizeLstPoints();
00070 for (i=0;i<size;i++)
00071 {
00072 manualPoint *mp = this->_manContModel->GetManualPoint(i);
00073 p[0] = mp->GetX();
00074 p[1] = mp->GetY();
00075 p[2] = mp->GetZ();
00076 dist=utilVtk3Dgeometriselection.DistanceMinPointToLine(p,pA,pB);
00077 if ( (dist<=2*GetRange()) && (dist<distMin) )
00078 {
00079 distMin = dist;
00080 id = i;
00081 }
00082 }
00083 }
00084 return id;
00085 }
00086
00087 int manualView3DContour::SelectPosiblePoint ( int x, int y, int z )
00088 {
00089 SelectAllPossibleSelected(false);
00090 int id=GetIdPoint2(x,y);
00091 if (id!=-1)
00092 {
00093 SetPointPosibleSelected(id,true);
00094 }
00095 return id;
00096 }
00097