[vtkusers] WG: Problems cutting polygons, bug?

Lodron, Gerald Gerald.Lodron at joanneum.at
Wed Nov 24 02:32:24 EST 2010


ok, there is the vtk polydata file, i hope that i come through the filter otherwise noone will read thsi :-)



________________________________
Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag von Lodron, Gerald
Gesendet: Mittwoch, 24. November 2010 08:23
An: 'vtkusers at vtk.org'
Betreff: [vtkusers] Problems cutting polygons, bug?


Hi

I wrote an application where a user can paint 2d polygons in 3D space. Then the user can define a cutting plane and i display the resulting lines.
The problem is that SOMETIMES the cutting does not work, so if anyone replys i will send him the Test1.vtk file which contains 4 Polygons whereby only three are cutted. (Yes the cutting plane defenetly cuts all polygons and there are 4 Polygons in the input file, see first visualization).

here my code:


vtkSmartPointer<vtkPolyDataReader> oReader = vtkPolyDataReader::New();

oReader->SetFileName("C:\\Test1.vtk");

oReader->Update();

vtkSmartPointer<vtkPolyData> oPolyData = oReader->GetOutput();

//Display input data, not important

{

vtkSmartPointer<vtkPolyDataMapper> oMapper = vtkPolyDataMapper::New();

oMapper->SetInputConnection(oReader->GetOutputPort());

vtkSmartPointer<vtkActor> oActor = vtkActor::New();

oActor->SetMapper( oMapper );

vtkSmartPointer<vtkRenderer> oRenderer = vtkRenderer::New();

vtkSmartPointer<vtkRenderWindow> oRenderWindow = vtkRenderWindow::New();

oRenderWindow->AddRenderer(oRenderer);

vtkSmartPointer<vtkRenderWindowInteractor> oIRen = vtkRenderWindowInteractor::New();

oIRen->SetRenderWindow(oRenderWindow);

oRenderer->AddActor(oActor);

// Render and interact

oRenderWindow->Render();

oIRen->Initialize();

oIRen->Start();

}

oPolyData->Print(std::cout); //containing 4 polygons

//Cut 2D polygons in 3D space with a plane

vtkSmartPointer<vtkPlane> oPlane = vtkPlane::New();

vtkSmartPointer<vtkCutter> oCutter = vtkCutter::New();

oCutter->SetCutFunction(oPlane);

oCutter->GenerateValues(1,0,1); //i am not sure why i do that

oPlane->SetOrigin(8.5, -72, -1177.0);

oPlane->SetNormal(1,0,0);

oCutter->SetInput(oPolyData);

oCutter->Update();

vtkSmartPointer<vtkPolyData> oCuttedPolyData = oCutter->GetOutput();

//Display cutting data, not important

{

vtkSmartPointer<vtkPolyDataMapper> oMapper = vtkPolyDataMapper::New();

oMapper->SetInputConnection(oCutter->GetOutputPort());

vtkSmartPointer<vtkActor> oActor = vtkActor::New();

oActor->SetMapper( oMapper );

vtkSmartPointer<vtkRenderer> oRenderer = vtkRenderer::New();

vtkSmartPointer<vtkRenderWindow> oRenderWindow = vtkRenderWindow::New();

oRenderWindow->AddRenderer(oRenderer);

vtkSmartPointer<vtkRenderWindowInteractor> oIRen = vtkRenderWindowInteractor::New();

oIRen->SetRenderWindow(oRenderWindow);

oRenderer->AddActor(oActor);

// Render and interact

oRenderWindow->Render();

oIRen->Initialize();

oIRen->Start();

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101124/f33dc8b5/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001.txt
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101124/f33dc8b5/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Test1.vtk.txt
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101124/f33dc8b5/attachment-0001.txt>


More information about the vtkusers mailing list