[vtkusers] Concaved Polygon edge shown straight
ALIZIER Julien AUSY
julien.alizier-ausy at irsn.fr
Wed Feb 4 09:12:42 EST 2004
Hi John,
Just a guess, but in OpenGL specifications, the behaviour is undefined when
drawing concave polygons. OpenGL says that all polygons must be convex and
if you want to draw concave shapes, you must tessellate youself.
But I don't know how this is handled in VTK.
Hope it helps,
-- Julien
-----Message d'origine-----
De : John Platt [mailto:jcplatt at lineone.net]
Envoyé : mercredi 4 février 2004 15:00
À : vtkusers at vtk.org
Objet : [vtkusers] Concaved Polygon edge shown straight
Hi users,
I have a single, plane, curvilinear quadrilateral with 2 straight sides, 1
concaved side and 1 convexed side. This is defined using 6 points and
VTK_POLYGON. This is the only cell in vtkUnstructuredGrid which is input to
vtkDataSetMapper.
The concaved edge is displayed straight while all other edges are shown
correctly. If the polygon is rotated, evidence of the correct shape can be
seen at certain orientations.
What am I missing? I have attached the cpp file used with vtk 4.5.0.
Many thanks.
John Platt
#include "stdafx.h"
#include "vtkPoints.h"
#include "vtkIdList.h"
#include "vtkCellType.h"
#include "vtkUnstructuredGrid.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Define points.
vtkPoints* globalCoords = vtkPoints::New();
globalCoords->Initialize();
globalCoords->InsertNextPoint( 0, 0, 0 );
globalCoords->InsertNextPoint( 1, 0.5, 0 ); // concave
globalCoords->InsertNextPoint( 2, 0, 0 );
globalCoords->InsertNextPoint( 2, 2, 0 );
globalCoords->InsertNextPoint( 1, 2.5, 0 ); // convexed
globalCoords->InsertNextPoint( 0, 2, 0 );
// Define the polygon topology.
vtkIdList* topology = vtkIdList::New();
for ( int nPts = 0; nPts < 6; nPts++ )
topology->InsertNextId( nPts );
// Add the points and the single cell to an unstructired grid.
vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New();
UGrid->SetPoints( globalCoords );
UGrid->InsertNextCell( VTK_POLYGON, topology );
// Convert the cell to graphic primitives.
vtkDataSetMapper* faceMapper = vtkDataSetMapper::New();
faceMapper->SetInput( UGrid );
faceMapper->ScalarVisibilityOff();
// Create an actor to represent the cell faces.
vtkActor* faceActor = vtkActor::New();
faceActor->SetMapper( faceMapper );
faceActor->GetProperty()->SetColor( 1, 0, 0 );
// Create the Renderer, RenderWindow, and RenderWindowInteractor.
vtkRenderer* renderer = vtkRenderer::New();
renderer->AddActor( faceActor );
vtkRenderWindow* renderWin = vtkRenderWindow::New();
renderWin->AddRenderer( renderer );
vtkRenderWindowInteractor* interactor = vtkRenderWindowInteractor::New();
interactor->SetRenderWindow( renderWin );
interactor->Initialize();
renderWin->Render();
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040204/97881cbd/attachment.htm>
More information about the vtkusers
mailing list