[vtkusers] Surfaces from unorganized point - vtkSurfaceReconstructionFilter

Gerrick Bivins gbivins at objectreservoir.com
Mon Jun 22 10:41:27 EDT 2009


I think the signature of your function should be defined as follows:

void readPoints(void*)
{
...
}

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.

Gerrick
On 6/22/09 7:56 AM, "Michele Natrella" <michele.cetma at yahoo.it> wrote:

> Hi,
> 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
> vtkSurfaceReconstructionFilter 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 SetExecuteMethod belonging to the class vtkProgrammableSource. It
> appears as follows:
> 
>     error C2660: "vtkProgrammableSource::SetExecuteMethod": function does not
> take 1 parameters
> 
> 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 readPoints used in the first lines of the main.
> 
> 
>                                                     MAIN
> 
> #include "vtkSurfaceReconstructionFilter.h"
> #include "vtkProgrammableSource.h"
> #include "vtkContourFilter.h"
> #include "vtkReverseSense.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkProperty.h"
> #include "vtkCamera.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "readPoints.h"
> 
> int main()
> {
> 
>     // Read some points. Use a programmable filter to read them.
>     vtkProgrammableSource* pointSource = vtkProgrammableSource::New();
> 
>     readPoints();
> 
>     pointSource->SetExecuteMethod(readPoints());    // ERROR !!
> 
> 
>     // Construct the surface and create isosurface.
>     vtkSurfaceReconstructionFilter* surf =
> vtkSurfaceReconstructionFilter::New();
>     surf->SetInputConnection(pointSource->GetOutputPort());
> 
>     vtkContourFilter* cf = vtkContourFilter::New();
>     cf->SetInputConnection(surf->GetOutputPort());
>     cf->SetValue(0, 0.0);
>     
>     // Sometimes the contouring algorithm can create a volume whose gradient
>     // vector and ordering of polygon (using the right hand rule) are
>     // inconsistent. vtkReverseSense cures this problem.
>     vtkReverseSense* reverse = vtkReverseSense::New();
>     reverse->SetInputConnection(cf->GetOutputPort());
>     reverse->ReverseCellsOn();
>     reverse->ReverseNormalsOn();
> 
>     vtkPolyDataMapper* map = vtkPolyDataMapper::New();
>     map->SetInputConnection(reverse->GetOutputPort());
>     map->ScalarVisibilityOff();
> 
>     vtkActor* surfaceActor = vtkActor::New();
>     surfaceActor->SetMapper(map);
>     surfaceActor->GetProperty()->SetDiffuseColor(1.0000, 0.3882, 0.2784);
>     surfaceActor->GetProperty()->SetSpecularColor(1, 1, 1);
>     surfaceActor->GetProperty()->SetSpecular(.4);
>     surfaceActor->GetProperty()->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;
> 
> }
> 
> 
>                                             FUNCTION readPoints
> 
> #include "vtkProgrammableSource.h"
> #include "vtkReverseSense.h"
> #include <fstream>
> #include <string>
> #include <iostream>
> #include <vector>
> #include <sstream>
> #include <cstdlib>
> 
> using namespace std;
> 
> std::vector<std::string> &split(const std::string &s, char delim,
> std::vector<std::string> &elems);
> std::vector<std::string> split(const std::string &s, char delim);
> 
> int readPoints(void)
> {
>     vtkProgrammableSource* pointSource = vtkProgrammableSource::New();
>     vtkPolyData* output = vtkPolyData::New();
>     output = pointSource->GetPolyDataOutput();
>     vtkPoints* points = vtkPoints::New();
>     output->SetPoints(points);
> 
> // -1- Apertura file in lettura
>     ifstream fileStream("file_three-dimensional unorganized points.txt");
> 
>     // -2- Controllo sulla correttezza dell'apertura del file
>     if( !fileStream )
>     {
>         cout << "Impossibile aprire il file " << endl;
>         return 1;
>     }
> 
> // -3- Recupero linea per linea e assegnamento valori
>     string line;
>     vector<string> data;
>     float x, y, z; //Punti da inserire
>     while(getline(fileStream, line)) //Prende una nuova linea
>     {
>         if(!line.empty()) // se la linea non è vuota
>         {
>         data=split(line, ' '); //il carattere di separazione  lo spazio
>         
>         //Conversione da std::string a float (se si vuole convertire in double
> sostituire atof con atod)
>         x=(float)atof(data[0].c_str());
>         y=(float)atof(data[1].c_str());
>         z=(float)atof(data[2].c_str());
>         
>         points->InsertNextPoint(x, y, z);
>         ////points.InsertNextPoint(x, y, z) // in Python
>         }
>     }
> 
> return 0;
> }
> 
> std::vector<std::string> &split(const std::string &s, char delim,
> std::vector<std::string> &elems) {
>     std::stringstream ss(s);
>     std::string item;
>     while(std::getline(ss, item, delim)) {
>         elems.push_back(item);
>     }
>     return elems;
> }
> 
> std::vector<std::string> split(const std::string &s, char delim) {
>     std::vector<std::string> elems;
>     return split(s, delim, elems);
> }
> 
> 
> 
> 
>  
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090622/efe22324/attachment.htm>


More information about the vtkusers mailing list