[vtkusers] [vtk-developers] WG: Problems cutting polygons, bug? -> YES DEFINITELLY A BUG
Lodron, Gerald
Gerald.Lodron at joanneum.at
Wed Nov 24 06:18:00 EST 2010
Also the 3D rendering of a normal polygon seems to be strange, is there an error in the triangulation (compare surface mode (button s) and wireframe mode (button w)), here my example polygons
Without spikes:
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 7 float
0 0 0 100 0 0 100 50 0
150 50 0 90 60 0 100 100 0
0 100 0
POLYGONS 1 8
7 0 1 2 3 4 5 6
CELL_DATA 1
SCALARS scalars double 3
LOOKUP_TABLE default
1 0 0
With spikes:
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 7 float
0 0 0 100 0 0 100 50 0
150 50 0 90 50 0 100 100 0
0 100 0
POLYGONS 1 8
7 0 1 2 3 4 5 6
CELL_DATA 1
SCALARS scalars double 3
LOOKUP_TABLE default
1 0 0
Take
oPlane->SetOrigin(50, 50, 0);
oPlane->SetNormal(1,0,0);
as cutting plane for my example program
best regards
Ok
i figured out in which case the cutter does not work, and i think it is a bug:
Working Polygon:
(0 0 0)
(10 0 0)
(10 10 0)
(0 10 0)
This Polygon is cut correct. And this is not cut correct:
(0 0 0)
(10 0 0)
(10 5 0)
(15 5 0)
(10 5 0)
(10 10 0)
(0 10 0)
You can see that in my second case the boundary has an infinite small spike. This results in an empty cutting result. In my opinion this is a valid polygon so the cutting should be calculated...
Can anyone make a bug report? I do not know why i cannot go the bug report system today (or is it offline?)
________________________________
Von: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org] Im Auftrag von Lodron, Gerald
Gesendet: Mittwoch, 24. November 2010 09:30
An: 'vtk-developers at vtk.org'
Betreff: [vtk-developers] WG: Problems cutting polygons, bug?
and here the single polygon extracted which cannot be cutted
________________________________
Von: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org] Im Auftrag von Lodron, Gerald
Gesendet: Mittwoch, 24. November 2010 08:32
An: 'vtk-developers at vtk.org'; 'vtkusers at vtk.org'
Betreff: [vtk-developers] WG: Problems cutting polygons, bug?
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/5d79a5e4/attachment.htm>
More information about the vtkusers
mailing list