[vtkusers] How can i generate a surface from a set of points?

Vetria Byrd byrdv at cis.uab.edu
Wed Mar 24 14:15:34 EST 2004


I am trying to convert reconstructSurface.tcl to .cxx code.
I have been unable to resolve 3 errors.

Thanks to anyone who can shed some light on this.

Sincerely,
Vetria

Here's the error listing (source code to follow):

Compiling...
reconstructSurface.cxx
\Examples\reconstructSurface\reconstructSurface.cxx(57) : error C2660:
'SetExecuteMethod' : function does not take 1 parameters

\Examples\reconstructSurface\reconstructSurface.cxx(122) : error C2440: '='
: cannot convert from 'class vtkPolyData *' to 'class vtkProgrammableSource
*'
        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast

\Examples\reconstructSurface\reconstructSurface.cxx(125) : error C2039:
'SetPoints' : is not a member of 'vtkProgrammableSource'
        C:\Program Files\vtk42\Graphics\vtkProgrammableSource.h(49) : see
declaration of 'vtkProgrammableSource'
Error executing cl.exe.

ALL_BUILD - 3 error(s), 0 warning(s)

----------------------
Here's the code:  

const char *filename = "C:/data/cactus.3334m.pts";

// Global variables

int i;

// Read some points in.  Use a programmable filter to read them.
vtkProgrammableSource *pointSource = vtkProgrammableSource::New();
vtkProgrammableSource *output = vtkProgrammableSource::New();


void readPoints();


int main()
{
	// Read some points in.  Use a programmable filter to read them.
	vtkProgrammableSource *pointSource = vtkProgrammableSource::New();
	
	
	pointSource->SetExecuteMethod(readPoints());

	//Construct the surface and create isosurface
	vtkSurfaceReconstructionFilter *surf =
vtkSurfaceReconstructionFilter::New();
	surf->SetInput(pointSource->GetPolyDataOutput());

	vtkContourFilter *cf = vtkContourFilter::New();
	cf->SetInput( (vtkDataSet *) surf->GetOutput() );

      cf->SetValue(0, 0.0);

	// deal with inconsistent polygons
	vtkReverseSense *reverse = vtkReverseSense::New();
	reverse->SetInput(cf->GetOutput());
	reverse->ReverseCellsOn();
	reverse->ReverseNormalsOn();

	vtkPolyDataMapper *map = vtkPolyDataMapper::New();
	map->SetInput(reverse->GetOutput());
	map->ScalarVisibilityOff();

	vtkActor *surfaceActor = vtkActor::New();
	surfaceActor->SetMapper(map);

	vtkProperty *isoProp = vtkProperty::New();
	isoProp = surfaceActor->GetProperty();
	isoProp->SetDiffuseColor(1.0000, 0.3882, 0.2784);
	isoProp->SetSpecularColor(1, 1, 1);
	isoProp->SetSpecular(.4);
	isoProp->SetSpecularPower(50);

	// Create the RenderWindow, Renderer and both Actors
	vtkRenderer *ren = vtkRenderer::New();
	vtkRenderWindow *renWin = vtkRenderWindow::New();
	renWin->AddRenderer(ren);
	vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(renWin);

	// Add the actors to the renderer, set the background and size
	ren->AddActor(surfaceActor);
	ren->SetBackground(1, 1, 1);
	renWin->SetSize(400, 400);
	ren->GetActiveCamera()->SetFocalPoint(0, 0, 0);
	ren->GetActiveCamera()->SetPosition(1, 0, 0);
	ren->GetActiveCamera()->SetViewUp(0, 0, 1);
	ren->ResetCamera();
	ren->GetActiveCamera()->Azimuth(20);
	ren->GetActiveCamera()->Elevation(30);
	ren->GetActiveCamera()->Dolly(1.2);
	ren->ResetCameraClippingRange();

	iren->Initialize();
	renWin->Render();
	iren->Start();

	return 0;

}

void readPoints()
{
//the data file was modified so that I can just read in the data points
//without checking for "p" and without splitting the line.

float x, y, z;

	output = pointSource->GetPolyDataOutput();

	vtkPoints *points = vtkPoints::New();
	output->SetPoints(points);

	ifstream datafile (filename, ios::in);	// open file for reading
    if (! datafile.is_open())
	{ cout << "Error opening file"; exit (1); }

	 for(i=0; i<3337; i++)
	  {
		
		fscanf(stdin,"%f %f %^f",x,y,z);
		points->InsertNextPoint(x,y,z);
	  }
  
	
}



-----Original Message-----
From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf Of
Mathieu Malaterre
Sent: Tuesday, March 23, 2004 3:50 PM
To: Alexander Trum
Cc: vtkusers
Subject: Re: [vtkusers] How can i generate a surface from a set of points?

Alexander,

	Reading the raw file should be pretty easy inside a for loop (if you

know how many points you have). The most difficult part is that you 
don't have the cell connectivity.

	You should have a look at:

Imaging/Testing/Tcl/reconstructSurface.tcl

	Please note that this file is almost just like yours:

VTKData/Data/cactus.3337.pts

HTH
Mathieu

Alexander Trum wrote:
> Hello
> 
> I have a ASCII file with XYZ coordinates from a three dimensional scan 
> (a room in a factory was scanned).
> Here a small example from such a file:
> 123.232 234.1234 1234.1234
> 46.456 46.34 68.68
> 35.345 345.345 35.89
> 
> What i want to do is to read in these coordinates and generate a 
> polygonal surface from these points.
> 
> Is these possible with VTK and if: How can I do it?
> 
> 
> Thanks in advance,
>   Alex
> 



_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list