2 #include "PlaneDirectionManager.h"
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
8 PlaneDirectionManager::PlaneDirectionManager(int radio, double colour[3] , int opacity){
15 PlaneDirectionManager::~PlaneDirectionManager(){
16 RemoveAllActorsFromIndex();
19 void PlaneDirectionManager::SetRenderer(vtkRenderer* render){
22 void PlaneDirectionManager::SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz){
24 _lstPointsx = lstPointsx;
25 _lstPointsy = lstPointsy;
26 _lstPointsz = lstPointsz;
29 void PlaneDirectionManager::UpdateDirections() throw (std::exception){
36 void PlaneDirectionManager::AddActors(){
38 for(i = 0; i < (int)_vectdata.size();i++){
39 _render->AddViewProp (_vectdata[i]->GetActor());
43 void PlaneDirectionManager::RemoveAllActorsFromIndex(int n)throw (std::exception){
44 /*due to incompleate set of points to create the plane
47 throw std::exception();
49 for(int i = _vectdata.size()-1; i >= n;i--){
50 _render->RemoveViewProp(_vectdata[i]->GetActor());
55 void PlaneDirectionManager::UpdateVectors()throw (std::exception){
56 PlaneDirectionManagerData* temp;
57 bool deletelast = false;
60 for(i = 0; i < (int)_lstPointsx.size();i++){
62 if((int)_vectdata.size()>currentdata){
63 temp = _vectdata[currentdata];
65 temp = new PlaneDirectionManagerData(_radio, _colour, _opacity);
66 _vectdata.push_back(temp);
68 temp->setPoint0(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
71 temp->setPoint1(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
73 temp->setPoint2(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
78 RemoveAllActorsFromIndex(currentdata);
81 void PlaneDirectionManager::UpdateActors()
84 for(i = 0; i < (int)_vectdata.size();i++)
86 _vectdata[i]->UpdateActor();
90 void PlaneDirectionManager::addRemoveActor(int index, bool addremove)
92 if(index < (int)_vectdata.size()){
94 _render->AddViewProp (_vectdata[index]->GetActor());
96 _render->RemoveViewProp (_vectdata[index]->GetActor());
101 void PlaneDirectionManager::changeColor(int index,double r,double g,double b)
103 GetPlaneDirectionManagerData(index)->ChangeColour(r,g,b);
106 PlaneDirectionManagerData* PlaneDirectionManager::GetPlaneDirectionManagerData(int id)
108 return _vectdata[id];
111 void PlaneDirectionManager::WriteInformation(std::string filename, double* spc){
113 ff = fopen( filename.c_str() , "w+" );
123 for(i = 0; i < (int)_vectdata.size();i++){
125 double* p0 = _vectdata[i]->getPoint0();
126 double* p1 = _vectdata[i]->getPoint1();
127 double* p2 = _vectdata[i]->getPoint2();
128 double* dir = _vectdata[i]->GetDirection();
130 double p0x = p0[0]/spc[0];
131 double p0y = p0[1]/spc[1];
132 double p0z = p0[2]/spc[2];
134 double p1x = p1[0]/spc[0];
135 double p1y = p1[1]/spc[1];
136 double p1z = p1[2]/spc[2];
138 double p2x = p2[0]/spc[0];
139 double p2y = p2[1]/spc[1];
140 double p2z = p2[2]/spc[2];
142 double dirx = dir[0]/spc[0];
143 double diry = dir[1]/spc[1];
144 double dirz = dir[2]/spc[2];
146 fprintf(ff,"Dir%d\n",i);
147 fprintf(ff,"\tP0[%f, %f, %f]\tP1[%f, %f, %f]\tP2[%f, %f, %f]\tDir[%f, %f, %f] \n",
148 p0x,p0y,p0z, p1x,p1y,p1z, p2x,p2y,p2z, dirx,diry,dirz);
152 printf("PlaneDirectionManager::WriteInformation ...Error... creating file");
156 void PlaneDirectionManager::SetArrowSize(int arrowsize){