X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMesh.cxx;h=5a5be2fae825c43daefd5464baf1f7f739346de9;hb=61d57d331b0459560f6714c0c6bb8298868a662e;hp=4ca03ccab200f9b816686f73877ce88f8c55cde4;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/vv/vvMesh.cxx b/vv/vvMesh.cxx index 4ca03cc..5a5be2f 100644 --- a/vv/vvMesh.cxx +++ b/vv/vvMesh.cxx @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include #include +#include #include #include "clitkCommon.h" #include "vvMesh.h" @@ -37,6 +38,7 @@ along with this program. If not, see . #include #include #include +#include #include @@ -54,11 +56,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 +230,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);