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 "PlaneDirectionManager.h"
29 /********************************************************************************************
30 ** Start of data viewmanagerData
31 *********************************************************************************************/
33 PlaneDirectionManager::PlaneDirectionManager(int radio, double colour[3] , int opacity){
40 PlaneDirectionManager::~PlaneDirectionManager(){
41 RemoveAllActorsFromIndex();
44 void PlaneDirectionManager::SetRenderer(vtkRenderer* render){
47 void PlaneDirectionManager::SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz){
49 _lstPointsx = lstPointsx;
50 _lstPointsy = lstPointsy;
51 _lstPointsz = lstPointsz;
54 void PlaneDirectionManager::UpdateDirections() throw (std::exception){
61 void PlaneDirectionManager::AddActors(){
63 for(i = 0; i < (int)_vectdata.size();i++){
64 _render->AddViewProp (_vectdata[i]->GetActor());
68 void PlaneDirectionManager::RemoveAllActorsFromIndex(int n)throw (std::exception){
69 /*due to incompleate set of points to create the plane
72 throw std::exception();
74 for(int i = _vectdata.size()-1; i >= n;i--){
75 _render->RemoveViewProp(_vectdata[i]->GetActor());
80 void PlaneDirectionManager::UpdateVectors()throw (std::exception){
81 PlaneDirectionManagerData* temp;
82 bool deletelast = false;
85 for(i = 0; i < (int)_lstPointsx.size();i++){
87 if((int)_vectdata.size()>currentdata){
88 temp = _vectdata[currentdata];
90 temp = new PlaneDirectionManagerData(_radio, _colour, _opacity);
91 _vectdata.push_back(temp);
93 temp->setPoint0(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
96 temp->setPoint1(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
98 temp->setPoint2(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
103 RemoveAllActorsFromIndex(currentdata);
106 void PlaneDirectionManager::UpdateActors()
109 for(i = 0; i < (int)_vectdata.size();i++)
111 _vectdata[i]->UpdateActor();
115 void PlaneDirectionManager::addRemoveActor(int index, bool addremove)
117 if(index < (int)_vectdata.size()){
119 _render->AddViewProp (_vectdata[index]->GetActor());
121 _render->RemoveViewProp (_vectdata[index]->GetActor());
126 void PlaneDirectionManager::changeColor(int index,double r,double g,double b)
128 GetPlaneDirectionManagerData(index)->ChangeColour(r,g,b);
131 PlaneDirectionManagerData* PlaneDirectionManager::GetPlaneDirectionManagerData(int id)
133 return _vectdata[id];
136 void PlaneDirectionManager::WriteInformation(std::string filename, double* spc){
138 ff = fopen( filename.c_str() , "w+" );
148 for(i = 0; i < (int)_vectdata.size();i++){
150 double* p0 = _vectdata[i]->getPoint0();
151 double* p1 = _vectdata[i]->getPoint1();
152 double* p2 = _vectdata[i]->getPoint2();
153 double* dir = _vectdata[i]->GetDirection();
155 double p0x = p0[0]/spc[0];
156 double p0y = p0[1]/spc[1];
157 double p0z = p0[2]/spc[2];
159 double p1x = p1[0]/spc[0];
160 double p1y = p1[1]/spc[1];
161 double p1z = p1[2]/spc[2];
163 double p2x = p2[0]/spc[0];
164 double p2y = p2[1]/spc[1];
165 double p2z = p2[2]/spc[2];
167 double dirx = dir[0]/spc[0];
168 double diry = dir[1]/spc[1];
169 double dirz = dir[2]/spc[2];
171 fprintf(ff,"Dir%d\n",i);
172 fprintf(ff,"\tP0[%f, %f, %f]\tP1[%f, %f, %f]\tP2[%f, %f, %f]\tDir[%f, %f, %f] \n",
173 p0x,p0y,p0z, p1x,p1y,p1z, p2x,p2y,p2z, dirx,diry,dirz);
177 printf("PlaneDirectionManager::WriteInformation ...Error... creating file");
181 void PlaneDirectionManager::SetArrowSize(int arrowsize){