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 # ------------------------------------------------------------------------ */
27 #include "PlaneDirectionManagerData.h"
29 /********************************************************************************************
30 ** Start of data viewmanagerData
31 *********************************************************************************************/
33 PlaneDirectionManagerData::PlaneDirectionManagerData(int radio, double colour[3], int opacity)
35 _vtkarrow = vtkArrowSource::New();
36 _arrowMapper = vtkPolyDataMapper::New();
37 _arrowActor = vtkActor::New();
39 _vtkarrow->SetTipResolution(30);
40 _vtkarrow->SetShaftResolution( 30 );
41 _arrowMapper->SetInput( _vtkarrow->GetOutput() );
42 _arrowActor->SetMapper(_arrowMapper);
67 PlaneDirectionManagerData::~PlaneDirectionManagerData(){
70 _arrowMapper->Delete();
71 _arrowActor->Delete();
78 vtkProp3D* PlaneDirectionManagerData::GetActor(){
82 void PlaneDirectionManagerData::UpdateActor(){
84 _arrowActor->GetProperty()->SetColor( _colour[0] , _colour[1] , _colour[2] );
85 _arrowActor->GetProperty()->SetOpacity( _opacity );
88 double* vect1= getNormal(makeVector(p0, p1));
89 double* vect2= getNormal(makeVector(p0, p2));
90 _dir = getNormal(getCrossProduct(vect1, vect2));
91 double *newvectnorm = getNormal(getCrossProduct(_dir, vect2));
92 double *midp = GetMidPoint();
94 vtkMatrix4x4* _matrix = vtkMatrix4x4::New();
96 _matrix->SetElement(0,0,_dir[0]*_radio);
97 _matrix->SetElement(1,0,_dir[1]*_radio);
98 _matrix->SetElement(2,0,_dir[2]*_radio);
99 _matrix->SetElement(0,1,vect2[0]*_radio);
100 _matrix->SetElement(1,1,vect2[1]*_radio);
101 _matrix->SetElement(2,1,vect2[2]*_radio);
102 _matrix->SetElement(0,2,newvectnorm[0]*_radio);
103 _matrix->SetElement(1,2,newvectnorm[1]*_radio);
104 _matrix->SetElement(2,2,newvectnorm[2]*_radio);
105 _matrix->SetElement(0,3,midp[0]);
106 _matrix->SetElement(1,3,midp[1]);
107 _matrix->SetElement(2,3,midp[2]);
108 _arrowActor->SetUserMatrix(_matrix);
112 void PlaneDirectionManagerData::ChangeColour(double r,double g,double b){
116 if(_arrowActor!=NULL){
117 _arrowActor->GetProperty()->SetColor( r,g,b );
121 double* PlaneDirectionManagerData::GetMidPoint(){
122 if(p0 != NULL && p1 != NULL && p2 != NULL){
123 double* ret = new double[3];
124 ret[0] = (p0[0] + p1[0] +p2[0])/3;
125 ret[1] = (p0[1] + p1[1] +p2[1])/3;
126 ret[2] = (p0[2] + p1[2] +p2[2])/3;