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
{
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())
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();
#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;
}
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