From 10ec7dc09aeea303fdc6a30449ec69de2f2ccd88 Mon Sep 17 00:00:00 2001 From: schaerer Date: Wed, 10 Mar 2010 15:36:26 +0000 Subject: [PATCH] added functionality for OBJ meshes. Untested. --- vv/qt_ui/vvMainWindow.ui | 2 +- vv/vvMainWindow.cxx | 7 ++++--- vv/vvMesh.cxx | 31 ++++++++++++++++++++++++++----- vv/vvMeshReader.cxx | 1 + 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/vv/qt_ui/vvMainWindow.ui b/vv/qt_ui/vvMainWindow.ui index 40a599a..b5b4ac5 100644 --- a/vv/qt_ui/vvMainWindow.ui +++ b/vv/qt_ui/vvMainWindow.ui @@ -1035,7 +1035,7 @@ :/new/prefix1/icons/open.png:/new/prefix1/icons/open.png - Open VTK contour + Open VTK or OBJ contour diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 871fb4b..1dbd8e4 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvMainWindow.cxx,v $ Language: C++ - Date: $Date: 2010/03/08 10:12:28 $ - Version: $Revision: 1.15 $ + Date: $Date: 2010/03/10 15:36:26 $ + Version: $Revision: 1.16 $ Author : Pierre Seroul (pierre.seroul@gmail.com) Copyright (C) 200COLUMN_IMAGE_NAME @@ -415,7 +415,7 @@ void vvMainWindow::OpenVTKContour() { if (mSlicerManagers.size() > 0) { - QString Extensions = "Images ( *.vtk)"; + QString Extensions = "Images ( *.vtk; *.obj)"; Extensions += ";;All Files (*)"; QString file = QFileDialog::getOpenFileName(this,tr("Open vtkPolyData"),mInputPathName,Extensions); if (file.isNull()) @@ -423,6 +423,7 @@ void vvMainWindow::OpenVTKContour() QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); vvMeshReader reader; + reader.SetImage(mSlicerManagers[index]->GetImage()); reader.SetModeToVTK(); reader.SetFilename(file.toStdString()); reader.Update(); diff --git a/vv/vvMesh.cxx b/vv/vvMesh.cxx index 8f6e78c..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; } diff --git a/vv/vvMeshReader.cxx b/vv/vvMeshReader.cxx index ead558a..e4eff21 100644 --- a/vv/vvMeshReader.cxx +++ b/vv/vvMeshReader.cxx @@ -68,6 +68,7 @@ void vvMeshReader::run() vvMesh::Pointer m=vvMesh::New(); m->ReadFromVTK(filename.c_str()); if (vf) m->propagateContour(vf); + m->ComputeMasks(image->GetVTKImages()[0],true); result.push_back(m); } else //Read a Dicom-struct file -- 2.47.1