[vtkusers] Problem with drawing a concave polygonal cell
itkvtk123 at gmx.net
itkvtk123 at gmx.net
Mon Nov 2 18:31:26 EST 2009
I'm having exactly the same problem here.
The display of concave polygonal spatial objects is really messed up.
(it looks strange and flickers as you zoom / rotate / etc. sometimes it does even disappear)
The vtkTriangleFilter-trick works for the flickering issue, but I don't like the solution since it is only a workaround.
In addition to that, you see the difference in wireframe-mode (the spatial which went through the filter has many subdivisions).
Is there another solution for this problem? Or is it a bug?
(sorry for the double-post)
###########################################################
It seems that one finds the solution right after posting the problem.
I just realized that I can solve my problem by running the concave
polygonal cell through the vtkTriangleFilter. Please ignore my
last post.
Paul
############################################################
I am having a problem with drawing a 5 sided, concave
polygonal cell, as illustrated by the attached picture
and sample code. The points of the polygon are:
Index x-y-z coordinates
0 (1, 0, 0)
1 (1, 1, 0)
2 (0, 1, 0)
3 (.8, .8, 0)
4 (0, 0, 0)
so the polygon looks like (connect 0 through 4)
2 1
3
4 0
However, vtk draws a polygon with an extra black
region (see attached gif picture) that flickers on
and off when the polygon is rotated.
According to the man pages, "The polygons cannot have
any internal holes, and cannot self-intersect." These
criteria seem to be satisfied by the above example.
I am probably missing something obvious, but would
appreciate it if someone would point me in the right
direction on how to properly draw a concave polygon.
Thanks.
Paul
(See attached file: poly.gif)
// ====== sample code ======
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyData.h"
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
void main()
{
// Set up the rendering stuff
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renderer->SetBackground(1, 1, 1);
// Create the poly data set
vtkPolyData *pd = vtkPolyData::New();
vtkPoints *pts = vtkPoints::New();
pts->InsertNextPoint(1, 0, 0);
pts->InsertNextPoint(1, 1, 0);
pts->InsertNextPoint(0, 1, 0);
pts->InsertNextPoint(0.8, 0.8, 0);
pts->InsertNextPoint(0, 0, 0);
pd->SetPoints(pts);
pts->Delete();
vtkCellArray *cellArray = vtkCellArray::New();
int pp[5] = {0, 1, 2, 3, 4};
cellArray->InsertNextCell(5, pp);
pd->SetPolys(cellArray);
cellArray->Delete();
// Create mapper and actor
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
mapper->SetInput(pd);
vtkActor *actor = vtkActor::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
actor->GetProperty()->SetColor(1, 0, 0);
renWin->Render();
iren->Start();
// Clean up
renderer->Delete();
renWin->Delete();
iren->Delete();
pd->Delete();
mapper->Delete();
actor->Delete();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: poly.gif
Type: image/gif
Size: 3781 bytes
Desc: Compuserve GIF
Url : http://public.kitware.com/pipermail/vtkusers/attachments/20000629/0a19d5ee/poly-0001.gif
--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser
More information about the vtkusers
mailing list