[vtkusers] Help! Using implicit function to draw Sphere and using boolean operations.

John Biddiscombe john.biddiscombe at mirada-solutions.com
Tue Sep 2 05:38:20 EDT 2003


#include "vtkImageData.h"

> -----Original Message-----
> From: Rahul Goela [mailto:rahulgoela at yahoo.com]
> Sent: 02 September 2003 09:39
> To: vtkusers at vtk.org
> Subject: [vtkusers] Help! Using implicit function to draw Sphere and
> using boolean operations.
> 
> 
> Hi,
> 
> I am new to VTK. I need to create two spheres using
> implicit functions and try boolien operations, such as
> Union on them. 
> 
> For the starters, I tried writting a code to create a
> sphere using q quadratic equation, and draw the image.
> 
> 
> I get the following error -
> --------------------------------------------------------
> error C2664: 'SetInput' : cannot convert parameter 1
> from 'class vtkImageData *' to 'class vtkDataSet *'
>         Types pointed to are unrelated; conversion
> requires reinterpret_cast, C-style cast or
> function-style cast
> : error C2664: 'SetInput' : cannot convert parameter 1
> from 'class vtkImageData *' to 'class vtkDataSet *'
>         Types pointed to are unrelated; conversion
> requires reinterpret_cast, C-style cast or
> function-style cast
> Error executing cl.exe.
> --------------------------------------------------------
> 
> My source Code is as follows -
> 
> -------------------------------------------------------
> #include "vtkSphereSource.h"
> #include "vtkQuadric.h"
> #include "vtkSampleFunction.h"
> #include "vtkContourFilter.h"
> #include "vtkOutlineFilter.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkProperty.h"
> 
> void main ()
> {
>  	
>   // -- create the quadric function object --
>   // create the quadric function definition
>   //F(x,y,z) = x^2 + y^2 + z^2 + R^2.
> 	
>   vtkQuadric *quadric = vtkQuadric::New();
>   quadric->SetCoefficients(1,1,1,0,0,0,0,0,0,1);
> 
>   // sample the quadric function
>   vtkSampleFunction *sample =
> vtkSampleFunction::New();
>   sample->SetSampleDimensions(60,60,60);
>   sample->SetImplicitFunction(quadric);
> 
>   // Create five surfaces F(x,y,z) = constant between
> range specified
>   vtkContourFilter *sphereSurface =
> vtkContourFilter::New();
>   sphereSurface->SetInput(sample->GetOutput());
>   sphereSurface->SetValue(0, 0.0);
> 
>   // map the contours to graphical primitives
>   vtkPolyDataMapper *contMapper =
> vtkPolyDataMapper::New();
>   contMapper->SetInput(sphereSurface->GetOutput());
>   //contMapper->SetScalarRange(0.0, 1.2);
> 
>   // create an actor for the contours
>   vtkActor *contActor = vtkActor::New();
>   contActor->SetMapper(contMapper);
> 
>   // -- create a box around the function to indicate
> the sampling volume --
> 
>   // create outline
>   vtkOutlineFilter *outline = vtkOutlineFilter::New();
>   outline->SetInput(sample->GetOutput());
> 
>   // map it to graphics primitives
>   vtkPolyDataMapper *outlineMapper =
> vtkPolyDataMapper::New();
>   outlineMapper->SetInput(outline->GetOutput());
> 
>   // create an actor for it
>   vtkActor *outlineActor = vtkActor::New();
>   outlineActor->SetMapper(outlineMapper);
>   //outlineActor->GetProperty()->SetColor(0,0,0);
> 
>   // -- render both of the objects --
> 
>   // a renderer and render window
>   vtkRenderer *ren1 = vtkRenderer::New();
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>   renWin->AddRenderer(ren1);
> 
>   // an interactor
>   vtkRenderWindowInteractor *iren =
> vtkRenderWindowInteractor::New();
>   iren->SetRenderWindow(renWin);
> 
>   // add the actors to the scene
>   ren1->AddActor(contActor);
>   ren1->AddActor(outlineActor);
>   ren1->SetBackground(1,1,1); // Background color
> white
> 
>   // render an image (lights and cameras are created
> automatically)
>   renWin->Render();
> 
>   // begin mouse interaction
>   iren->Start();
> }
> ---------------------------------------------------------
> 
> Kindly help me out as to how to solve this error. Also
> if there is a web-site with some examples referring to
> use of boolean Implicit function, kindly let me know.
> 
> Thanks in advance
> 
> Rahul
> 
> 
> 
> ______________________________________________________________
> __________
> Yahoo! India Promos: Win TVs, Bikes, DVD players & more!
> Go to http://in.promos.yahoo.com
> _______________________________________________
> 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