Help Needed: [vtkusers] Extracting points from within an Implicit Function.

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Mon Feb 9 14:41:40 EST 2004


Rahul,
   what if you add the points to a vtkPolyData and use vtkClipPolyData ?
theoretically it should work
    Dave P


                                                                                                               
                      Rahul Goela                                                                              
                      <rahulgoela at yahoo        To:       vtkusers at vtk.org                                      
                      .com>                    cc:                                                             
                      Sent by:                 Subject:  Help Needed: [vtkusers] Extracting points from within 
                      vtkusers-admin at vt         an Implicit Function.                                          
                      k.org                                                                                    
                                                                                                               
                                                                                                               
                      09/02/2004 14:20                                                                         
                                                                                                               
                                                                                                               




Hello Vtk Users:

I am currently imvolved in developing a visualization
tool for analysis of 3d data (point form).

I was facing a very unique problem, for which I have
not been able to find the solution. It is regarding
the vtkImplicitFunctions.

Problem:

Say there are two spheres and I Union them using
vtkImplicitFunction, I will get a shape of 'dumbell'.
Now say I have a point cloud, drawn from 30 random 3D
points. This 'dumbell' shape say encloses 5 of these
points in the 3d Space. Is there any way, using VTK
that I get these 5 points ?

I have tried using a method using 'vtkClipDataSet',
but it doesn't give the result. My source code has
been provided below.

I would be extremely grateful if I could any help
regarding this issue.

Thanks alot,

Best regards,

Rahul
--------------------SOURCE CODE-----------------------

PLOTTING OF POINTS-:

- Three arrays xcon,ycon and zcon have the x,y,z
co-ordinates of these points.

  //Data to be visualized
  vtkPoints *newPts = vtkPoints::New();
  numPts=30;
  for(i=0; i<numPts; i++)
  {
    xyz[0] = xcon[i]; // put the x,y,z coords into a
                         temp point holder
    xyz[1] = ycon[i];
    xyz[2] = zcon[i];
    newPts->InsertPoint(i, xyz);
  }
  aVertex = vtkVertex::New();
  for( int m = 0; m < NumPoints; m++ )
  {
    aVertex->GetPointIds()->InsertNextId(m);
  }
  dataSet = vtkUnstructuredGrid::New();

dataSet->InsertNextCell(aVertex->GetCellType(),aVertex->GetPointIds());
  dataSet->SetPoints(newPts);

  dataSetMapper = vtkDataSetMapper::New();
  dataSetMapper->SetInput(dataSet);

  dataSetActor = vtkActor::New();
  dataSetActor->SetMapper(dataSetMapper);
  dataSetActor->GetProperty()->SetColor(0,0,0);

METHOD FOR EXTRACTING POINTS:

vtkPointDataToCellData
*p2c=vtkPointDataToCellData::New();

p2c->SetInput(dataSet);//dataset is the set of points
which are being visualized on the screen

p2c->PassPointDataOn();

vtkClipDataSet *clipedData = vtkClipDataSet::New();
clipedData->SetClipFunction(ib1); //ib1 is the
implicit function from which the pts have to be
extracted.

//Now add the following code to the clipdataset
clipedData->SetInput(p2c->GetUnstructuredGridOutput());

//clipDataSet->GenerateClippedOutputOn();//This is if
u require the points outside the implict boolean
function

vtkDataSetMapper *dsmapper = vtkDataSetMapper::New();
dsmapper->SetInput(clipedData->GetOutput());

vtkActor *dsActor = vtkActor::New();
 dsActor->SetMapper(dsmapper);
 dsActor->GetProperty()->SetColor(0,1,0);

//The dsActor is empty as it doesn't show any points.

------------------------------------------------------


________________________________________________________________________
Yahoo! India Education Special: Study in the UK now.
Go to http://in.specials.yahoo.com/index1.html
_______________________________________________
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