[vtkusers] How can I use vtkPolyData as a Implicit function of vtkClipPolyData?

David Pont david_pont at hotmail.com
Tue Feb 19 20:04:56 EST 2002


Seungbum,
  As far as I know vtkImplicitDataSet will not help you clip polydata with 
polydata, not directly anyway. I am also interested to hear if there is some 
way of clipping with polydata, using existing vtk classes.
I have developed a class named vtkImplicitPolydata, which I have passed on 
to some people that have asked this type of question, I can send it to you 
if you like. I would happily contribute the class to vtk, but it needs more 
work first... and I have no time at the moment...
If any of the people that have used vtkImplicitPolydata could report their 
experiences, this would help me decide if it just needs fine tuning, or a 
bullet.

  regards
    Dave Pont


>From: Seungbum Koo <koosb at stanford.edu>
>To: vtkusers at public.kitware.com
>Subject: [vtkusers] How can I use vtkPolyData as a Implicit function of 
>vtkClipPolyData?
>Date: Tue, 19 Feb 2002 10:15:12 -0800
>
>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);
>
>_______________________________________________
>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://public.kitware.com/mailman/listinfo/vtkusers




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




More information about the vtkusers mailing list