[vtkusers] How can I use vtkPolyData as a Implicit function of vtkClipPolyData?
Seungbum Koo
koosb at stanford.edu
Tue Feb 19 13:15:12 EST 2002
Dear vtk Users,
I'm using vtk3.2 and I have read manuals and vtkusers Archives over and
over but
I couldn't figure out how to convert my vtkPolyData into
vtkImplicitFunction to use
it in vtkClipPolyData.
What I want to do is clipping between a vtkPolyData and a vtkPolyData.
Some people made classes likes vtkImplicitPolyData but I want to do this
using only
vtk if possible, so I tried some test cases.
First, I made one vtkSphereSource as a vtkPolyData source, and one
vtkSphere as a vtkImplicitFunction
for vtkClipPolyData. It worked fine.
Second, I made one vtkSphereSource as a vtkPolyData source, and another
vtkSphereSource and
filtered is using vtkImplicitDataSet to use it as a vtkImplicitFunction. It
didnt' work and I received a
messages "can't evaluate function".
I looked into the function EvaluateFunction in vtkImplicitDataSet and it
couldn't evaluate
vtkSphereSource beacuse it didn't have scalar value. (I'm very confused
what the scalar
value should be in sphere.), So, I made some scalar values for the
vtkSphereSource.
But next, FindAndGetCell() in EvaluateFunction couldn't find any cell
around a point.
Does anyone know how to do vtkClipPolyData between two vtkPolyData's like
this case?
Seungbum
koosb at stanford.edu
----------------------------------------------------------------
Source for First case:
vtkSphereSource *pSphere1 = vtkSphereSource::New();
pSphere1->SetRadius(50);
pSphere1->SetCenter(0,0,0);
vtkSphere *pSphere2 = vtkSphere::New();
pSphere2->SetRadius(50);
pSphere2->SetCenter(0,0,50);
vtkClipPolyData *pClip = vtkClipPolyData::New();
pClip->SetInput(pSphere1->GetOutput());
pClip->SetClipFunction(pSphere2);
pClip->GenerateClipScalarsOn();
pClip->GenerateClippedOutputOn();
Source for Second case:
vtkSphereSource *pSphere1 = vtkSphereSource::New();
pSphere1->SetRadius(50);
pSphere1->SetCenter(0,0,0);
vtkSphereSource *pSphere2 = vtkSphereSource::New();
pSphere2->SetRadius(50);
pSphere2->SetCenter(0,0,50);
vtkImplicitDataSet *pIdata = vtkImplicitDataSet::New();
pIdata->SetDataSet(pSphere2->GetOutput());
vtkClipPolyData *pClip = vtkClipPolyData::New();
pClip->SetInput(pSphere1->GetOutput());
pClip->SetClipFunction(pIdata);
pClip->GenerateClipScalarsOn();
pClip->GenerateClippedOutputOn();
vtkScalars pScalars = vtkScalars::New();
for(int i=0; i<pSphere2->GetOutput()->GetNumberOfPoints(); i++)
pScalars->InsertNextScalar(1.0);
pSphere2->GetOutput()->GetPointData()->SetScalars(pScalars);
More information about the vtkusers
mailing list