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 );
42 //EED 2017-01-01 Migration VTK7
43 #if VTK_MAJOR_VERSION <= 5
44 _arrowMapper->SetInput( _vtkarrow->GetOutput() );
46 _arrowMapper->SetInputData( _vtkarrow->GetOutput() );
49 _arrowActor->SetMapper(_arrowMapper);
74 PlaneDirectionManagerData::~PlaneDirectionManagerData(){
77 _arrowMapper->Delete();
78 _arrowActor->Delete();
85 vtkProp3D* PlaneDirectionManagerData::GetActor(){
89 void PlaneDirectionManagerData::UpdateActor(){
91 _arrowActor->GetProperty()->SetColor( _colour[0] , _colour[1] , _colour[2] );
92 _arrowActor->GetProperty()->SetOpacity( _opacity );
95 double* vect1= getNormal(makeVector(p0, p1));
96 double* vect2= getNormal(makeVector(p0, p2));
97 _dir = getNormal(getCrossProduct(vect1, vect2));
98 double *newvectnorm = getNormal(getCrossProduct(_dir, vect2));
99 double *midp = GetMidPoint();
101 vtkMatrix4x4* _matrix = vtkMatrix4x4::New();
103 _matrix->SetElement(0,0,_dir[0]*_radio);
104 _matrix->SetElement(1,0,_dir[1]*_radio);
105 _matrix->SetElement(2,0,_dir[2]*_radio);
106 _matrix->SetElement(0,1,vect2[0]*_radio);
107 _matrix->SetElement(1,1,vect2[1]*_radio);
108 _matrix->SetElement(2,1,vect2[2]*_radio);
109 _matrix->SetElement(0,2,newvectnorm[0]*_radio);
110 _matrix->SetElement(1,2,newvectnorm[1]*_radio);
111 _matrix->SetElement(2,2,newvectnorm[2]*_radio);
112 _matrix->SetElement(0,3,midp[0]);
113 _matrix->SetElement(1,3,midp[1]);
114 _matrix->SetElement(2,3,midp[2]);
115 _arrowActor->SetUserMatrix(_matrix);
119 void PlaneDirectionManagerData::ChangeColour(double r,double g,double b){
123 if(_arrowActor!=NULL){
124 _arrowActor->GetProperty()->SetColor( r,g,b );
128 double* PlaneDirectionManagerData::GetMidPoint(){
129 if(p0 != NULL && p1 != NULL && p2 != NULL){
130 double* ret = new double[3];
131 ret[0] = (p0[0] + p1[0] +p2[0])/3;
132 ret[1] = (p0[1] + p1[1] +p2[1])/3;
133 ret[2] = (p0[2] + p1[2] +p2[2])/3;