[vtkusers] some questions about cells, file formats, etc
nuno.jf
nunofernandes7 at gmail.com
Wed Jan 11 15:04:32 EST 2012
Sure, and thank you for your help!
Sorry for some confusion in my code:
(Btw, I noticed that When I set mc->ComputeNormalsOff() instead of
mc->ComputeNormalsOn() , I don't get this error)
// Includes for lots of things
//VTK
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include "vtkPolyDataReader.h"
#include "vtkStructuredPointsReader.h"
#include "vtkMarchingCubes.h"
#include "vtkImageMarchingCubes.h"
#include "vtkGaussianSplatter.h"
#include "vtkImageGaussianSmooth.h"
#include "vtkPolyDataConnectivityFilter.h"
#include "vtkContourFilter.h"
#include "vtkGaussianSplatter.h"
#include "vtkPolyDataWriter.h"
#include "vtkGeometryFilter.h"
#include "vtkStructuredPoints.h"
#include "vtkThreshold.h"
//renderização
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkImageSobel3D.h"
#include "vtkXMLPolyDataWriter.h"
// main function
int main( int argc, char *argv[] )
{
vtkStructuredPointsReader *imp1 = vtkStructuredPointsReader::New();
imp1 -> SetFileName( argv[1] );
imp1 -> Update();
vtkImageGaussianSmooth *smooth = vtkImageGaussianSmooth::New();
smooth->SetInput(imp1->GetOutput());
smooth->SetDimensionality(3);
smooth->SetStandardDeviations(1,1,1);
smooth->Update();
vtkSmartPointer<vtkImageMarchingCubes> mc =
vtkSmartPointer<vtkImageMarchingCubes>::New();
mc->SetInput(smooth->GetOutput());
mc->ComputeNormalsOn();
mc->ComputeScalars();
mc->ComputeGardientsOn();
mc->GenerateValues(1,atof(argv[2]),atof(argv[3]));
mc->Update();
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(.1, .2, .3);
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(mc->GetOutputPort()); //mc->GetOutputPort()
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderWindow->Render();
interactor->Start();
vtkPolyData * out = vtkPolyData::New();
out = mc->GetOutput();
out ->Update();
//Writer
vtkPolyDataWriter *writer =vtkPolyDataWriter::New();
writer ->SetInput(out);
writer->SetFileTypeToASCII();
writer ->SetFileName("output.vtk");
writer ->Update();
//XML Writer
vtkXMLPolyDataWriter * writer2 = vtkXMLPolyDataWriter::New();
writer2->SetInput(out);
writer2->SetDataModeToAscii();
writer2->SetFileName("outputXML.vtp");
writer2->Update();
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/some-questions-about-cells-file-formats-etc-tp5089451p5137877.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list