X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMesh.cxx;h=4890f199c214e3f04f20eeb07f030881c443db23;hb=ff7bc7bab634e15b2e7d8ac18cd19285710626c6;hp=4ca03ccab200f9b816686f73877ce88f8c55cde4;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/vv/vvMesh.cxx b/vv/vvMesh.cxx index 4ca03cc..4890f19 100644 --- a/vv/vvMesh.cxx +++ b/vv/vvMesh.cxx @@ -1,27 +1,20 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Program: vv - Language: C++ - Author : Joel Schaerer (joel.schaerer@insa-lyon.fr) + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr -Copyright (C) 2008 -Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr -CREATIS-LRMN http://www.creatis.insa-lyon.fr + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -=========================================================================*/ + It is distributed under dual licence + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ #include #include #include @@ -30,6 +23,7 @@ along with this program. If not, see . #include #include #include +#include #include #include "clitkCommon.h" #include "vvMesh.h" @@ -37,6 +31,7 @@ along with this program. If not, see . #include #include #include +#include #include @@ -54,11 +49,30 @@ void vvMesh::AddMesh(vtkPolyData* p) void vvMesh::ReadFromVTK(const char * filename) { - assert(GetNumberOfMeshes() == 0); ///We assume the object is empty - vtkSmartPointer r=vtkSmartPointer::New(); - r->SetFileName(filename); - r->Update(); - AddMesh(r->GetOutput()); + DD("hello!"); + std::string extension=itksys::SystemTools::GetFilenameLastExtension(std::string(filename)); + if (extension == ".vtk" || extension== ".VTK") + { + assert(GetNumberOfMeshes() == 0); ///We assume the object is empty + vtkSmartPointer r=vtkSmartPointer::New(); + r->SetFileName(filename); + r->Update(); + assert(r->GetOutput()); + AddMesh(r->GetOutput()); + } + else if (extension == ".obj" || extension== ".OBJ") + { + assert(GetNumberOfMeshes() == 0); ///We assume the object is empty + vtkSmartPointer r=vtkSmartPointer::New(); + r->SetFileName(filename); + r->Update(); + assert(r->GetOutput()); + AddMesh(r->GetOutput()); + } + else + assert (false) ; //shouldn't happen + + assert(GetNumberOfMeshes() != 0); ///We assume the object is empty structure_name=filename; } @@ -209,9 +223,9 @@ void vvMesh::propagateContour(vvImage::Pointer vf) int iy=(old[1]-Oy)/Sy; int iz=(old[2]-Oz)/Sz; float* vector=vector_data+(ix+iy*vf->GetSize()[0]+iz*vf->GetSize()[0]*vf->GetSize()[1])*3; - if (ix>=0 and ix < dims[0] - and iy>=0 and iy < dims[1] - and iz>=0 and iz < dims[2]) + if (ix>=0 && ix < dims[0] + && iy>=0 && iy < dims[1] + && iz>=0 && iz < dims[2]) new_mesh->GetPoints()->SetPoint(j,old[0]+vector[0],old[1]+vector[1],old[2]+vector[2]); } this->AddMesh(new_mesh);