[vtkusers] FW:

Johan Hakansson jhakansson at sti-hawaii.com
Thu May 27 15:02:18 EDT 2004


 

 

Johan Hakansson 

Software / Algorithm developer

STI medical

733 Bishop Street 

96813 Honolulu

 

-----Original Message-----
From: Johan Hakansson 
Sent: Monday, May 24, 2004 5:05 PM
To: 'vtkusers at vtk.org'
Subject: 

 

Hi, 

 

I have problems getting this code sequence to work. 

The purpose is to have it create a surface from a "cloud" of  3D points.


These are loaded from file in the beginning of the code. 

 

The problem for me is to link the points to the surface reconstruction
filter.

In the TCL example I found they use a  "ProgrammableSource"  but I am
not able to 

Transfer the sequence to C++. In the example they use the
"ProgrammableSource"  

to read in the points but I may not need that as I read in mine
separately.

 

The error message I get is :

 

ERROR: In
C:\martink\vtk42\VTK\Imaging\vtkSurfaceReconstructionFilter.cxx, line
149

vtkSurfaceReconstructionFilter (0x01343F28): No points to reconstruct

 

Any tips will be appreciated.   

 

Aloha

/Johan

                        

            vtkProgrammableSource*            p_pointSource   =
vtkProgrammableSource::New();           

            vtkPoints*                                  p_points
= vtkPoints::New();

            

            CDataFile
File("C://3D_output.txt");  

            

            ReadStoreStream& stre = File.getReadStream(); 

 

            p_pointSource->GetPolyDataOutput()->SetPoints( p_points); 

 

            string sz;

 

            static double px; 

            static double py;

            static double pz;   

 

            do{

 

                        stre >> sz;

                        px = atof( sz.c_str());

 

                        stre >> sz;

                        py = atof( sz.c_str());

                        

                        stre >> sz;

                        pz = atof( sz.c_str());

 

                        p_points->InsertNextPoint( px, py, pz); 

 

            }while(sz.length());

 

            int l = p_points->GetNumberOfPoints();

 

//          Construct the surface and create isosurface.

 

            vtkSurfaceReconstructionFilter* p_surf =
vtkSurfaceReconstructionFilter::New(); 

                        p_surf->SetInput(
p_pointSource->GetPolyDataOutput());  // [pointSource GetPolyDataOutput]

 

            vtkContourFilter*
p_cf = vtkContourFilter::New();

 

            p_cf->SetInput( (vtkDataSet*) p_surf->GetOutput()); 

            p_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*                      p_reverse =
vtkReverseSense::New(); 

  

            p_reverse->SetInput(p_cf->GetOutput()); 

            p_reverse->ReverseCellsOn(); 

            p_reverse->ReverseNormalsOn(); 

 

            vtkPolyDataMapper*                   p_map =
vtkPolyDataMapper::New(); 

            

            p_map->SetInput( (vtkPolyData*) p_surf->GetOutput());

            p_map->ScalarVisibilityOff();

            

            vtkActor*
p_surfaceActor = vtkActor::New(); 

            p_surfaceActor->SetMapper( p_map); 

 

            p_surfaceActor->GetProperty()->SetDiffuseColor(  1.0000,
0.3882, 0.2784); 

            p_surfaceActor->GetProperty()->SetSpecularColor( 1, 1, 1); 

            p_surfaceActor->GetProperty()->SetSpecular(
0.4); 

            p_surfaceActor->GetProperty()->SetSpecularPower( 50); 

 

//          Create the RenderWindow, Renderer and both Actors

 

            vtkRenderer*                  p_ren1   = vtkRenderer::New();


            vtkRenderWindow*         p_renWin = vtkRenderWindow::New(); 

   

            p_renWin->AddRenderer( p_ren1); 

            

            vtkRenderWindowInteractor* p_iren =
vtkRenderWindowInteractor::New(); 

            p_iren->SetRenderWindow( p_renWin); 

 

//  Add the actors to the renderer, set the background and size

 

            p_ren1->AddActor( p_surfaceActor); 

            p_ren1->SetBackground( 1, 1, 1); 

            p_renWin->SetSize( 400, 400); 

            

            p_ren1->GetActiveCamera()->SetFocalPoint( 0, 0, 0); 

            p_ren1->GetActiveCamera()->SetPosition(           1, 0, 0); 

            p_ren1->GetActiveCamera()->SetViewUp( 0, 0, 1); 

            

            p_ren1->ResetCamera(); 

            

            p_ren1->GetActiveCamera()->Azimuth( 20); 

            p_ren1->GetActiveCamera()->Elevation( 30); 

            p_ren1->GetActiveCamera()->Dolly( 1.2); 

            p_ren1->ResetCameraClippingRange(); 

 

//          Render the image

 

            p_renWin->Render();

            p_iren->Start(); 

 

            return 0;            

 

Johan Hakansson 

Software / Algorithm developer

STI medical

733 Bishop Street 

96813 Honolulu

 

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


More information about the vtkusers mailing list