<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>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 <span style="font-weight: bold;">vtkSurfaceReconstructionFilter</span> 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 <span style="font-weight: bold;">SetExecuteMethod</span> belonging to the class <span style="font-weight: bold;">vtkProgrammableSource</span>. 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 <span
style="font-weight: bold;">readPoints</span> used in the first lines of the main.<br><br><br> <span style="font-weight: bold;"> MAIN</span><br><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> <span style="font-weight: bold;">pointSource->SetExecuteMethod(readPoints());</span> // 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> <span style="font-weight: bold;"> FUNCTION readPoints</span><br><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></div></div><br>
</body></html>