2 #include "PlaneDirectionManagerData.h"
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
8 PlaneDirectionManagerData::PlaneDirectionManagerData(int radio, double colour[3], int opacity)
10 _vtkarrow = vtkArrowSource::New();
11 _arrowMapper = vtkPolyDataMapper::New();
12 _arrowActor = vtkActor::New();
14 _vtkarrow->SetTipResolution(30);
15 _vtkarrow->SetShaftResolution( 30 );
16 _arrowMapper->SetInput( _vtkarrow->GetOutput() );
17 _arrowActor->SetMapper(_arrowMapper);
42 PlaneDirectionManagerData::~PlaneDirectionManagerData(){
45 _arrowMapper->Delete();
46 _arrowActor->Delete();
53 vtkProp3D* PlaneDirectionManagerData::GetActor(){
57 void PlaneDirectionManagerData::UpdateActor(){
59 _arrowActor->GetProperty()->SetColor( _colour[0] , _colour[1] , _colour[2] );
60 _arrowActor->GetProperty()->SetOpacity( _opacity );
63 double* vect1= getNormal(makeVector(p0, p1));
64 double* vect2= getNormal(makeVector(p0, p2));
65 _dir = getNormal(getCrossProduct(vect1, vect2));
66 double *newvectnorm = getNormal(getCrossProduct(_dir, vect2));
67 double *midp = GetMidPoint();
69 vtkMatrix4x4* _matrix = vtkMatrix4x4::New();
71 _matrix->SetElement(0,0,_dir[0]*_radio);
72 _matrix->SetElement(1,0,_dir[1]*_radio);
73 _matrix->SetElement(2,0,_dir[2]*_radio);
74 _matrix->SetElement(0,1,vect2[0]*_radio);
75 _matrix->SetElement(1,1,vect2[1]*_radio);
76 _matrix->SetElement(2,1,vect2[2]*_radio);
77 _matrix->SetElement(0,2,newvectnorm[0]*_radio);
78 _matrix->SetElement(1,2,newvectnorm[1]*_radio);
79 _matrix->SetElement(2,2,newvectnorm[2]*_radio);
80 _matrix->SetElement(0,3,midp[0]);
81 _matrix->SetElement(1,3,midp[1]);
82 _matrix->SetElement(2,3,midp[2]);
83 _arrowActor->SetUserMatrix(_matrix);
87 void PlaneDirectionManagerData::ChangeColour(double r,double g,double b){
91 if(_arrowActor!=NULL){
92 _arrowActor->GetProperty()->SetColor( r,g,b );
96 double* PlaneDirectionManagerData::GetMidPoint(){
97 if(p0 != NULL && p1 != NULL && p2 != NULL){
98 double* ret = new double[3];
99 ret[0] = (p0[0] + p1[0] +p2[0])/3;
100 ret[1] = (p0[1] + p1[1] +p2[1])/3;
101 ret[2] = (p0[2] + p1[2] +p2[2])/3;