/*=========================================================================
+ 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 <http://www.gnu.org/licenses/>.
-
-=========================================================================*/
+ 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 <sstream>
#include <cassert>
#include <vector>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
+#include <vtkOBJReader.h>
#include <vtkImageData.h>
#include "clitkCommon.h"
#include "vvMesh.h"
#include <vtkLinearExtrusionFilter.h>
#include <vtkPolyDataToImageStencil.h>
#include <vtkMarchingCubes.h>
+#include <itksys/SystemTools.hxx>
#include <vtkMetaImageWriter.h>
void vvMesh::ReadFromVTK(const char * filename)
{
- assert(GetNumberOfMeshes() == 0); ///We assume the object is empty
- vtkSmartPointer<vtkPolyDataReader> r=vtkSmartPointer<vtkPolyDataReader>::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<vtkPolyDataReader> r=vtkSmartPointer<vtkPolyDataReader>::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<vtkOBJReader> r=vtkSmartPointer<vtkOBJReader>::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;
}
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);