[vtkusers] Concaved Polygon edge shown straight
Jeff Lee
jeff at cdnorthamerica.com
Wed Feb 4 09:09:21 EST 2004
opengl cannot display concave polys - you must tessellate. try triangle
filter, or there are some tesselate filters out there that will do the
trick.
-Jeff
John Platt wrote:
> 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;
>
> }
>
>
>
>
>
>
>
>
>
More information about the vtkusers
mailing list