[vtkusers] Extracting 3d points from within an Implicit Function.
Rahul Goela
rahulgoela at yahoo.com
Sat Feb 7 05:15:07 EST 2004
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
More information about the vtkusers
mailing list