[vtkusers] vtkPolyPlane problem
Matteo
sendtomatteo at yahoo.it
Fri Apr 14 04:31:27 EDT 2017
Hi
I truly need to find a way to have a 'cut' along something not strictly
planar, if nobody can solve the problem related vtkPolyPlane (see below)
I will be very glad also if someone can suggest some other way to get a
similar result.
Thank You
Matteo
Il 05/04/2017 15:24, Matteo via vtkusers ha scritto:
> Hi
> Let me add my test code to my previous message:
>
>
> vtkSmartPointer<vtkStructuredGrid> structuredGrid =
> vtkSmartPointer<vtkStructuredGrid>::New();
>
> vtkSmartPointer<vtkPoints> points =
> vtkSmartPointer<vtkPoints>::New();
>
> const int Size=20;
>
> int i, j, k;
>
> for(k = 0; k < Size; k++)
> for(j = 0; j < Size; j++)
> for(i = 0; i < Size; i++)
> points->InsertNextPoint(i, j, k);
>
> // Specify the dimensions of the grid
> structuredGrid->SetDimensions(Size,Size,Size);
> structuredGrid->SetPoints(points);
>
> // Cutter
>
> #if 0
> vtkSmartPointer<vtkPlane> plane =
> vtkSmartPointer<vtkPlane>::New();
> plane->SetOrigin(Size/2,0,0);
> plane->SetNormal(1,0,0);
> #else
> const int N=3;
>
> const double Step10=(Size-1)/10.0;
>
> vtkPoints *cutPts = vtkPoints::New();
> cutPts->SetNumberOfPoints(N);
>
> {
> i=0;
> cutPts->SetPoint(i++, 1*Step10, 1*Step10, 0);
> cutPts->SetPoint(i++, 5*Step10, 5*Step10, 0);
> cutPts->SetPoint(i++, 5*Step10, 8*Step10, 0);
> ASSERT(i==N);
> }
>
> int* idCutPts = new int[N];
> for(i = 0; i < N; i++)
> idCutPts[i] = i;
>
> vtkSmartPointer<vtkPolyLine> PolyLine =
> vtkSmartPointer<vtkPolyLine>::New();
> PolyLine->Initialize(N, idCutPts, cutPts);
>
> vtkSmartPointer<vtkPolyPlane> plane =
> vtkSmartPointer<vtkPolyPlane>::New();
> plane->SetPolyLine(PolyLine);
>
> #endif
>
> vtkSmartPointer<vtkCutter> cutter =
> vtkSmartPointer<vtkCutter>::New();
> cutter->SetCutFunction(plane);
> cutter->SetInputData(structuredGrid);
> cutter->Update();
>
> vtkSmartPointer<vtkPolyDataMapper> cutterMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> cutterMapper->SetInputConnection( cutter->GetOutputPort());
>
> // Create plane actor
> vtkSmartPointer<vtkActor> planeActor =
> vtkSmartPointer<vtkActor>::New();
> planeActor->GetProperty()->SetColor(1.0,1.0,0);
> planeActor->GetProperty()->SetLineWidth(2);
> planeActor->SetMapper(cutterMapper);
>
> // Create a mapper and actor
> vtkSmartPointer<vtkDataSetMapper> mapper =
> vtkSmartPointer<vtkDataSetMapper>::New();
> #if VTK_MAJOR_VERSION <= 5
> mapper->SetInputConnection(structuredGrid->GetProducerPort());
> #else
> mapper->SetInputData(structuredGrid);
> #endif
>
> vtkSmartPointer<vtkActor> actor =
> vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
> actor->GetProperty()->SetRepresentationToWireframe();
>
> // Create a renderer, render window, and interactor
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> renderWindowInteractor->SetRenderWindow(renderWindow);
>
> // Add the actor to the scene
> renderer->AddActor(actor);
> renderer->AddActor(planeActor);
> renderer->SetBackground(.3, .6, .3); // Background color
>
> // Render and interact
> renderWindow->Render();
> renderWindowInteractor->Start();
>
>
>
>
> Il 05/04/2017 10:48, Matteo via vtkusers ha scritto:
>> Hi
>> I need to use vtkCutter to cut a vtkStructuredGrid, but not using a
>> simple vtkPlane: what I need is something more complex.
>> I need to use a polyline, and extrude it on Z direction, to specify a
>> surface more complex then a simple vtkPlane.
>> It looks that vtkPolyPlane is what I need, but when I use it I have a
>> problem: the cut is done quite correctly along the polyline
>> specified, but also appear some other piece of cut in some other
>> position.
>> The picture attached shows the problem.
>> I tried more grid sizes, and different polylines (different length or
>> shapes), but there is quite always this strange extra surfaces added.
>> I am not sure if it is a correct result of this filter.... or a bug.
>> Anyone can help?
>> Matteo
>>
>>
>>
>>
>>
>> _______________________________________________
>> Powered bywww.kitware.com
>>
>> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at:http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170414/89867937/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 24897 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170414/89867937/attachment.png>
More information about the vtkusers
mailing list