<HTML>
<HEAD>
<TITLE>Re: [vtkusers] Surfaces from unorganized point - vtkSurfaceReconstructionFilter</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>I think the signature of your function should be defined as follows:<BR>
<BR>
</SPAN></FONT><FONT FACE="Times New Roman"><SPAN STYLE='font-size:12pt'><B>void </B>readPoints(<B>void*</B>)<BR>
{<BR>
...<BR>
}<BR>
</SPAN></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
I haven’t tried it but from looking at the docs I think the callback function should return void and takes a void pointer as an argument.<BR>
<BR>
Gerrick<BR>
On 6/22/09 7:56 AM, "Michele Natrella" <<a href="michele.cetma@yahoo.it">michele.cetma@yahoo.it</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Times New Roman"><SPAN STYLE='font-size:12pt'>Hi,<BR>
I am trying to represent a surface as a three-dimensional unorganized points. These pointsets come from a scan. To do this I am using <B>vtkSurfaceReconstructionFilter</B> which is a class specifically designed for this purpose. However there is an error that is driving me mad, it is caused by the method <B>SetExecuteMethod</B> belonging to the class <B>vtkProgrammableSource</B>. It appears as follows:<BR>
<BR>
error C2660: "vtkProgrammableSource::SetExecuteMethod": function does not take 1 parameters<BR>
<BR>
As following the code I wrote. I've put in bold the line which the error refers to, besides at the end of the message I reported the definition of the function <B>readPoints</B> used in the first lines of the main.<BR>
<BR>
<BR>
<B> MAIN<BR>
</B><BR>
#include "vtkSurfaceReconstructionFilter.h"<BR>
#include "vtkProgrammableSource.h"<BR>
#include "vtkContourFilter.h"<BR>
#include "vtkReverseSense.h"<BR>
#include "vtkPolyDataMapper.h"<BR>
#include "vtkProperty.h"<BR>
#include "vtkCamera.h"<BR>
#include "vtkRenderer.h"<BR>
#include "vtkRenderWindow.h"<BR>
#include "vtkRenderWindowInteractor.h"<BR>
#include "readPoints.h"<BR>
<BR>
int main()<BR>
{<BR>
<BR>
// Read some points. Use a programmable filter to read them.<BR>
vtkProgrammableSource* pointSource = vtkProgrammableSource::New();<BR>
<BR>
readPoints(); <BR>
<BR>
<B>pointSource->SetExecuteMethod(readPoints());</B> // ERROR !!<BR>
<BR>
<BR>
// Construct the surface and create isosurface.<BR>
vtkSurfaceReconstructionFilter* surf = vtkSurfaceReconstructionFilter::New();<BR>
surf->SetInputConnection(pointSource->GetOutputPort());<BR>
<BR>
vtkContourFilter* cf = vtkContourFilter::New();<BR>
cf->SetInputConnection(surf->GetOutputPort());<BR>
cf->SetValue(0, 0.0);<BR>
<BR>
// Sometimes the contouring algorithm can create a volume whose gradient<BR>
// vector and ordering of polygon (using the right hand rule) are<BR>
// inconsistent. vtkReverseSense cures this problem.<BR>
vtkReverseSense* reverse = vtkReverseSense::New();<BR>
reverse->SetInputConnection(cf->GetOutputPort());<BR>
reverse->ReverseCellsOn();<BR>
reverse->ReverseNormalsOn();<BR>
<BR>
vtkPolyDataMapper* map = vtkPolyDataMapper::New();<BR>
map->SetInputConnection(reverse->GetOutputPort());<BR>
map->ScalarVisibilityOff();<BR>
<BR>
vtkActor* surfaceActor = vtkActor::New();<BR>
surfaceActor->SetMapper(map);<BR>
surfaceActor->GetProperty()->SetDiffuseColor(1.0000, 0.3882, 0.2784);<BR>
surfaceActor->GetProperty()->SetSpecularColor(1, 1, 1);<BR>
surfaceActor->GetProperty()->SetSpecular(.4);<BR>
surfaceActor->GetProperty()->SetSpecularPower(50);<BR>
<BR>
// Create the RenderWindow, Renderer and both Actors<BR>
vtkRenderer* ren = vtkRenderer::New();<BR>
vtkRenderWindow* renWin = vtkRenderWindow::New();<BR>
renWin->AddRenderer(ren);<BR>
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<BR>
iren->SetRenderWindow(renWin);<BR>
<BR>
// Add the actors to the renderer, set the background and size<BR>
ren->AddActor(surfaceActor);<BR>
ren->SetBackground(1, 1, 1);<BR>
renWin->SetSize(400, 400);<BR>
ren->GetActiveCamera()->SetFocalPoint(0, 0, 0);<BR>
ren->GetActiveCamera()->SetPosition(1, 0, 0);<BR>
ren->GetActiveCamera()->SetViewUp(0, 0, 1);<BR>
ren->ResetCamera();<BR>
ren->GetActiveCamera()->Azimuth(20);<BR>
ren->GetActiveCamera()->Elevation(30);<BR>
ren->GetActiveCamera()->Dolly(1.2);<BR>
ren->ResetCameraClippingRange();<BR>
<BR>
iren->Initialize();<BR>
renWin->Render();<BR>
iren->Start();<BR>
<BR>
return 0;<BR>
<BR>
}<BR>
<BR>
<BR>
<B> FUNCTION readPoints<BR>
</B><BR>
#include "vtkProgrammableSource.h"<BR>
#include "vtkReverseSense.h"<BR>
#include <fstream><BR>
#include <string><BR>
#include <iostream><BR>
#include <vector><BR>
#include <sstream><BR>
#include <cstdlib><BR>
<BR>
using namespace std;<BR>
<BR>
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);<BR>
std::vector<std::string> split(const std::string &s, char delim);<BR>
<BR>
int readPoints(void)<BR>
{<BR>
vtkProgrammableSource* pointSource = vtkProgrammableSource::New();<BR>
vtkPolyData* output = vtkPolyData::New();<BR>
output = pointSource->GetPolyDataOutput();<BR>
vtkPoints* points = vtkPoints::New();<BR>
output->SetPoints(points);<BR>
<BR>
// -1- Apertura file in lettura<BR>
ifstream fileStream("file_three-dimensional unorganized points.txt");<BR>
<BR>
// -2- Controllo sulla correttezza dell'apertura del file<BR>
if( !fileStream )<BR>
{<BR>
cout << "Impossibile aprire il file " << endl;<BR>
return 1;<BR>
}<BR>
<BR>
// -3- Recupero linea per linea e assegnamento valori <BR>
string line;<BR>
vector<string> data;<BR>
float x, y, z; //Punti da inserire <BR>
while(getline(fileStream, line)) //Prende una nuova linea<BR>
{<BR>
if(!line.empty()) // se la linea non è vuota<BR>
{<BR>
data=split(line, ' '); //il carattere di separazione lo spazio<BR>
<BR>
//Conversione da std::string a float (se si vuole convertire in double sostituire atof con atod)<BR>
x=(float)atof(data[0].c_str());<BR>
y=(float)atof(data[1].c_str());<BR>
z=(float)atof(data[2].c_str());<BR>
<BR>
points->InsertNextPoint(x, y, z);<BR>
////points.InsertNextPoint(x, y, z) // in Python<BR>
}<BR>
}<BR>
<BR>
return 0;<BR>
}<BR>
<BR>
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {<BR>
std::stringstream ss(s);<BR>
std::string item;<BR>
while(std::getline(ss, item, delim)) {<BR>
elems.push_back(item);<BR>
}<BR>
return elems;<BR>
}<BR>
<BR>
std::vector<std::string> split(const std::string &s, char delim) {<BR>
std::vector<std::string> elems;<BR>
return split(s, delim, elems);<BR>
}<BR>
<BR>
<BR>
<BR>
</SPAN></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'>_______________________________________________<BR>
Powered by www.kitware.com<BR>
<BR>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
<BR>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><BR>
<BR>
Follow this link to subscribe/unsubscribe:<BR>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE>
</BODY>
</HTML>