I haven't looked at the cutter code, but it is likely that changing the parameters to the cutting plane doesn't cause a Modified event to be made to the cutter code. Try calling cutter->Modified to force the cutter to be stale before calling cutter->Update().<div>
<br></div><div>- Wes<br><br><div class="gmail_quote">On Wed, Nov 3, 2010 at 8:35 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Inside the loop you must disconnect the input to append from the<br>
output of cutter. One way to do that is to use DeepCopy as you<br>
discovered.<br>
<br>
Another is to create the cutter inside the loop and Delete it after<br>
adding its output to append If you use SmartPointer's you need not<br>
delete). This should be faster than the DeepCopy, depending on the<br>
size of the models.<br>
<br>
If you do not disconnect the input to append, then all of the inputs<br>
will be the same (should be the last cutter output).<br>
<div><div></div><div class="h5"><br>
<br>
On Wed, Nov 3, 2010 at 5:00 AM, nsarrasin <<a href="mailto:nsarrasin@phenix-systems.com">nsarrasin@phenix-systems.com</a>> wrote:<br>
><br>
> Thanks for your reply,<br>
><br>
> I followed your advice and used GetOutputPort() but the result stays the<br>
> same.<br>
><br>
> I post a (light, simple and commented) code which illustrates the problem,<br>
> maybe i'm doing something wrong .<br>
><br>
> Thanks a lot for helping me.<br>
><br>
> //slicing of a sphere by a plane. the plane is iteratively rotated all<br>
> around the sphere<br>
><br>
> #include <vtkSmartPointer.h><br>
> #include <vtkPolyData.h><br>
> #include <vtkTransform.h><br>
> #include <vtkPlane.h><br>
> #include <vtkCutter.h><br>
> #include <vtkMath.h><br>
> #include <vtkAppendPolyData.h><br>
> #include <vtkPolyDataMapper.h><br>
> #include <vtkActor.h><br>
> #include <vtkProperty.h><br>
> #include <vtkRenderer.h><br>
> #include <vtkRenderWindow.h><br>
> #include <vtkRenderWindowInteractor.h><br>
> #include <vtkSphereSource.h><br>
> #include <vtkInteractorStyleTrackballCamera.h><br>
> #include <vector><br>
><br>
> int main (int argc, char *argv[])<br>
> {<br>
> //the object to cut<br>
> vtkSphereSource* sph = vtkSphereSource::New();<br>
> sph->SetRadius(25.);<br>
> sph->SetPhiResolution(50.);<br>
> sph->SetThetaResolution(50.);<br>
><br>
> vtkPolyData *polydata = sph->GetOutput();<br>
><br>
> //init the cutting plane<br>
> double bounds[6], center[3];<br>
> polydata->GetBounds(bounds);<br>
> polydata->GetCenter(center);<br>
><br>
> vtkPlane* plane = vtkPlane::New();<br>
> plane->SetOrigin(center);<br>
> plane->SetNormal(bounds[0]-center[0], bounds[2]-center[1], 0.);<br>
><br>
> int nbsections = 10;<br>
> double angle = 360./(double)nbsections;<br>
> double normal[3]={0,0,1};<br>
><br>
> //init the transformation<br>
> vtkTransform* transf = vtkTransform::New();<br>
> transf->RotateWXYZ(angle, normal[0], normal[1], normal[2]);<br>
><br>
> vtkMatrix4x4* mat = vtkMatrix4x4::New();<br>
> transf->GetMatrix(mat);<br>
><br>
> vtkAppendPolyData* appdata = vtkAppendPolyData::New();<br>
> vtkCutter* cutter = vtkCutter::New();<br>
> cutter->SetInput(polydata);<br>
> cutter->SetCutFunction(plane);<br>
><br>
> double new_normal[4];<br>
><br>
> for(int step=0; step<nbsections; step++)<br>
> {<br>
> //// Code works but need Update + DeppCopy<br>
> cutter->Update();<br>
> vtkPolyData* tmp_result=vtkPolyData::New();<br>
> tmp_result->DeepCopy( cutter->GetOutput());<br>
> appdata->AddInput(tmp_result);<br>
><br>
> //// Code doesn't update though GetOutputPort()<br>
> //appdata->AddInputConnection(cutter->GetOutputPort());<br>
><br>
> //rotation of the cutting plane around normal<br>
> mat->MultiplyPoint(plane->GetNormal(), new_normal);<br>
> plane->SetNormal(new_normal);<br>
> plane->SetOrigin(center);<br>
> }<br>
><br>
> //visualisation<br>
> //1. All slices<br>
> vtkSmartPointer<vtkPolyDataMapper> appmapper =<br>
> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
> appmapper->SetInput(appdata->GetOutput());<br>
><br>
> vtkSmartPointer<vtkActor> appactor = vtkSmartPointer<vtkActor>::New();<br>
> appactor->SetMapper(appmapper);<br>
> appactor->GetProperty()->SetColor(1,0,0);<br>
><br>
> //2. polydata<br>
> vtkSmartPointer<vtkPolyDataMapper> teethmapper =<br>
> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
> teethmapper->SetInput(polydata);<br>
><br>
> vtkSmartPointer<vtkActor> teethactor = vtkSmartPointer<vtkActor>::New();<br>
> teethactor->SetMapper(teethmapper);<br>
> teethactor->GetProperty()->SetColor(0.8,0.8,0.8);<br>
><br>
> // The usual renderer, render window and interactor<br>
> vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();<br>
> vtkSmartPointer<vtkRenderWindow> renWin =<br>
> vtkSmartPointer<vtkRenderWindow>::New();<br>
> vtkSmartPointer<vtkRenderWindowInteractor> iren =<br>
> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
><br>
> ren1->SetBackground(.1, .2, .3);<br>
> renWin->AddRenderer(ren1);<br>
> iren->SetRenderWindow(renWin);<br>
><br>
> ren1->AddActor(appactor);<br>
> ren1->AddActor(teethactor);<br>
><br>
> renWin->Render();<br>
> iren->Start();<br>
> }<br>
><br>
> --<br>
> View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkCutter-Update-doesn-t-update-the-vtkCutter-GetOutput-tp3246712p3248103.html" target="_blank">http://vtk.1045678.n5.nabble.com/vtkCutter-Update-doesn-t-update-the-vtkCutter-GetOutput-tp3246712p3248103.html</a><br>
> Sent from the VTK - Users mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>
</div>