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 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: CutModelSaveBinInfo.cxx,v $
31 Date: $Date: 2012/11/15 14:15:48 $
32 Version: $Revision: 1.3 $
34 Copyright: (c) 2002, 2003
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notice for more information.
41 =========================================================================*/
42 #include "CutModelSaveBinInfo.h"
45 ** Start of the manager class
47 CutModelSaveBinInfo::CutModelSaveBinInfo(int id, int currentaction, UNDOTYPE actiontype, std::string path){
52 sprintf(c,"/infounrd_%d_fig_%d.info",currentaction,id);
56 _stdFilename+=".poly";
58 _matrixFilename = path;
60 _actiontype = actiontype;
64 CutModelSaveBinInfo::~CutModelSaveBinInfo(){
67 void CutModelSaveBinInfo::savePolyData(vtkPolyData* polydata){
68 vtkPolyDataWriter * writer = vtkPolyDataWriter ::New();
69 writer->SetFileName(_stdFilename.c_str());
71 //EED 2017-01-01 Migration VTK7
72 #if VTK_MAJOR_VERSION <= 5
73 writer->SetInput(polydata);
75 writer->SetInputData(polydata);
78 writer->SetFileTypeToBinary();
83 vtkTransform* CutModelSaveBinInfo::getPolyDataTransform()throw( CutModelException){
84 vtkPolyDataReader* reader = vtkPolyDataReader::New();
85 //std::cout<<"filename vtkTransform* CutModelSaveBinInfo::getPolyDataTransform()"<<this->getSTDFileName()<<std::endl;
86 reader->SetFileName(this->getSTDFileName().c_str());
87 vtkPolyData* poly = reader->GetOutput();
89 vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
90 //EED 2017-01-01 Migration VTK7
91 #if VTK_MAJOR_VERSION <= 5
92 mapper->SetInput(poly);
94 mapper->SetInputData(poly);
96 vtkActor* actor = vtkActor::New();
97 actor->SetMapper(mapper);
98 vtkMatrix4x4* actmatrix = actor->GetMatrix();
100 std::cout<<"tkTransform* CutModelSaveBinInfo::getPolyDataTransform() Actor "<<actor<<std::endl;
101 std::cout<<"tkTransform* CutModelSaveBinInfo::getPolyDataTransform() Actor Matrix "<<actmatrix<<std::endl;
105 vtkTransform* transform = vtkTransform::New();
107 transform->Identity();
109 transform->GetMatrix()->SetElement(0,0,actmatrix->GetElement(0,0));
110 transform->GetMatrix()->SetElement(1,0,actmatrix->GetElement(1,0));
111 transform->GetMatrix()->SetElement(2,0,actmatrix->GetElement(2,0));
112 transform->GetMatrix()->SetElement(0,1,actmatrix->GetElement(0,1));
113 transform->GetMatrix()->SetElement(1,1,actmatrix->GetElement(1,1));
114 transform->GetMatrix()->SetElement(2,1,actmatrix->GetElement(2,1));
115 transform->GetMatrix()->SetElement(0,2,actmatrix->GetElement(0,2));
116 transform->GetMatrix()->SetElement(1,2,actmatrix->GetElement(1,2));
117 transform->GetMatrix()->SetElement(2,2,actmatrix->GetElement(2,2));
118 transform->GetMatrix()->SetElement(0,3,actmatrix->GetElement(0,3));
119 transform->GetMatrix()->SetElement(1,3,actmatrix->GetElement(1,3));
120 transform->GetMatrix()->SetElement(2,3,actmatrix->GetElement(2,3));
133 void CutModelSaveBinInfo::saveMatrix4x4(vtkMatrix4x4* matrix){
134 fstream binary_file(_matrixFilename.c_str(),ios::out|ios::binary);
135 binary_file.write(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
138 vtkTransform* CutModelSaveBinInfo::getTransformFromMatrixFile()throw( CutModelException){
139 vtkMatrix4x4* matrix = vtkMatrix4x4::New();
140 fstream binary_file(_matrixFilename.c_str(),ios::binary|ios::in);
141 binary_file.read(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
144 vtkTransform* transform = vtkTransform::New();
145 transform->SetMatrix(matrix);