[vtkusers] cloud of points into surfaces
João Figueiredo
joao_ct at msn.com
Mon Jan 1 13:08:38 EST 2007
hello my name is João,
i'm trying to tranform a cloud of points into a surface...
my program reads coordinates from a *.txt file.
then i´m using the delaney2d and delaney3d to transform this cloud of points
into surface...
but unfortunately, it is not working...
could anyone help me please...maybe another Vtk classe??
my source code:
#include <stdio.h>
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkUnstructuredGrid.h"
#include "vtkFloatArray.h"
#include "vtkPoints.h"
#include "vtkPointData.h"
#include "vtkDataSetMapper.h"
#include "vtkProperty.h"
#include "vtkPolyDataMapper.h"
#include "vtkGaussianSplatter.h"
#include "vtkContourFilter.h"
#include "vtkPlaneWidget.h"
#include "vtkCellArray.h"
#include "vtkDelaunay2D.h"
#include "vtkPolyDataWriter.h"
#include "vtkShrinkFilter.h"
int main()
{
float f1, f2, f3;
FILE * pFile;
pFile = fopen ("tunel_5cm.txt","r");
rewind (pFile);
int i=0;
int numpontos=0;
vtkPoints *pontos = vtkPoints::New();
vtkCellArray *Vertices = vtkCellArray::New();
while (fscanf (pFile, "%f,%f,%f\n", &f1, &f2, &f3)!=EOF)
{
/*if ((i%5)==0)
{*/
pontos->InsertNextPoint(f1, f2, f3);
Vertices->InsertNextCell(1);
Vertices->InsertCellPoint(numpontos);
numpontos++;
/*}
i++;*/
}
fclose (pFile);
vtkPolyData *polydata= vtkPolyData::New();
polydata->SetPoints(pontos);
polydata->SetVerts(Vertices);
//delaunay
vtkDelaunay2D *del2D = vtkDelaunay2D::New();
del2D = vtkDelaunay2D::New();
del2D->SetInput(polydata);
del2D->SetTolerance(0.002);
del2D->BoundingTriangulationOff();
del2D->SetAlpha(2);
//del2D->Update();
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
mapper->SetInput(del2D->GetOutput());
vtkActor *actor= vtkActor::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(1,0,0);
actor->GetProperty()->SetOpacity(0.9);
actor->GetProperty()->SetAmbient(0.5);
actor->GetProperty()->SetDiffuse(0.3);
actor->GetProperty()->SetSpecular(0.2);
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderer->SetBackground(1,1,1);
renWin->SetSize(300,300);
iren->Initialize();
renWin->Render();
iren->Start();
return 0;
}
_________________________________________________________________
MSN Messenger: converse com os seus amigos online.
http://messenger.msn.com.br
More information about the vtkusers
mailing list