]> Creatis software - clitk.git/commitdiff
added functionality for OBJ meshes. Untested.
authorschaerer <schaerer>
Wed, 10 Mar 2010 15:36:26 +0000 (15:36 +0000)
committerschaerer <schaerer>
Wed, 10 Mar 2010 15:36:26 +0000 (15:36 +0000)
vv/qt_ui/vvMainWindow.ui
vv/vvMainWindow.cxx
vv/vvMesh.cxx
vv/vvMeshReader.cxx

index 40a599ab57479825d42b19d5de86172fb6482e9f..b5b4ac58d638b9444f0d4c37a595f1169671927c 100644 (file)
      <normaloff>:/new/prefix1/icons/open.png</normaloff>:/new/prefix1/icons/open.png</iconset>
    </property>
    <property name="text">
-    <string>Open VTK contour</string>
+    <string>Open VTK or OBJ contour</string>
    </property>
   </action>
   <action name="actionNavigation_Help">
index 871fb4b2a0785713144ffcbb25c40d3b62f3e2c0..1dbd8e4575fadbeeccfd645091ec3b147139c442 100644 (file)
@@ -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();
index 8f6e78cf02740f2e854272ffa56b46b8ed200796..5a5be2fae825c43daefd5464baf1f7f739346de9 100644 (file)
@@ -30,6 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <vtkPointData.h>
 #include <vtkPolyData.h>
 #include <vtkPolyDataReader.h>
+#include <vtkOBJReader.h>
 #include <vtkImageData.h>
 #include "clitkCommon.h"
 #include "vvMesh.h"
@@ -37,6 +38,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <vtkLinearExtrusionFilter.h>
 #include <vtkPolyDataToImageStencil.h>
 #include <vtkMarchingCubes.h>
+#include <itksys/SystemTools.hxx>
 
 #include <vtkMetaImageWriter.h>
 
@@ -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<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;
 }
 
index ead558a19d018d8b74166288e398aeb2be1ce816..e4eff21dad3873f1b85ca94055cb60357bc5979a 100644 (file)
@@ -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