[vtkusers] (no subject)

Binnur Yetim binnuryetim at gmail.com
Thu Jun 5 07:02:02 EDT 2014


Hi
 I work on a project .I want to virtulization data what I have in the
.vtk extension file .My file is attached.I want to read and virtulization
 this data with vtk in the c++ but I can't do .Project was compiled and we
can read number of points but object was not virtulized. What is the
problem? Can you help me please.My code is

// Program: Visualization Toolkit
// First include the required header files for the VTK classes we are using.
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataReader.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkCleanPolyData.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkAutoInit.h"

#include "vtkContourFilter.h"
#include <vtkVersion.h>
#include "vtkStructuredGrid.h"
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include <string>
#include "vtkRenderWindowInteractor.h"
#include <vtkPoints.h>
#include <vtkTransform.h>
#include <vtkVertexGlyphFilter.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkIterativeClosestPointTransform.h>
#include <vtkTransformPolyDataFilter.h>
#include <vtkLandmarkTransform.h>
#include <vtkMath.h>
#include <vtkMatrix4x4.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkProperty.h>
#include "vtkGenericDataObjectReader.h"
VTK_MODULE_INIT(vtkRenderingOpenGL);
VTK_MODULE_INIT(vtkInteractionStyle);
int main()
{
//vtk dosyasını okutan kod

/*vtkDataReader *reader=vtkPolyDataReader::New();
reader->SetFileName("C:/Users/Binnur Yetim/Desktop/bitirme
tezi/poster/sample1.vtk");
reader->Update();*/

  // simply set filename here (oh static joy)
  std::string inputFilename = "C:/Users/Binnur Yetim/Desktop/bitirme
tezi/poster/bitirme.vtk";

  // Get all data from the file
  vtkSmartPointer<vtkGenericDataObjectReader> reader =
      vtkSmartPointer<vtkGenericDataObjectReader>::New();
  reader->SetFileName(inputFilename.c_str());
  reader->Update();

  // All of the standard data types can be checked and obtained like this:
  if(reader->IsFilePolyData())
    {
    std::cout << "output is a polydata" << std::endl;
    vtkPolyData* output = reader->GetPolyDataOutput();
    std::cout << "output has " << output->GetNumberOfPoints() << " points."
<< std::endl;
    }


vtkContourFilter *cont = vtkContourFilter::New();
cont->SetInputConnection(reader->GetOutputPort());
cont->SetNumberOfContours(1);
cont->SetValue(0, 200);

// between the source and the mapper.)
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cont->GetOutputPort() );
//
// Create an actor
//
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
coneActor->GetProperty()->SetColor(0,0.5,0.5);

// Create the Renderer
//
vtkRenderer *ren1= vtkRenderer::New();
ren1->AddActor( coneActor );
ren1->SetBackground( 0, 1, 1 );
//
// Finally we create the render window which will show up on the screen.

vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer( ren1 );
renWin->SetSize( 500, 500);
//
// The vtkRenderWindowInteractor class watches for events (e.g., keypress,
// mouse) in the vtkRenderWindow.
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
//
// By default the vtkRenderWindowInteractor instantiates an instance
// of vtkInteractorStyle.
vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();
iren->SetInteractorStyle(style);
//
// Unlike the previous scripts where we performed some operations and then
// exited, here we leave an event loop running.
//
iren->Initialize();
iren->Start();

// Free up any objects we created. All instances in VTK are deleted by
// using the Delete() method.
//
reader->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
style->Delete();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140605/68bf5fff/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample1.vtk
Type: application/octet-stream
Size: 36467 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140605/68bf5fff/attachment.obj>


More information about the vtkusers mailing list