[vtkusers] Solid 2D shapes

Jan-Jaap van der Heijden Jan-Jaap.vanderHeijden at phoenixbv.com
Wed May 26 04:35:40 EDT 2004


Hello all,

Say I want to draw a solid, 2D box in a window.
A wireframe goes like this:


  // define coordinates, and scalar values at these coordinates
  vtkPoints *pts = vtkPoints::New();
  pts->GetData()->SetName(arrayname);
  pts->InsertPoint(0, 0.2,0.2,0);
  pts->InsertPoint(1, 0.8,0.2,0);
  pts->InsertPoint(2, 0.8,0.6,0);
  pts->InsertPoint(3, 0.2,0.6,0);

  vtkDoubleArray *scalars = vtkDoubleArray::New();
  scalars->SetNumberOfTuples(4);
  scalars->InsertValue(0,0);
  scalars->InsertValue(1,1);
  scalars->InsertValue(2,2);
  scalars->InsertValue(3,1);

  // define connectivity
  vtkCellArray *rect = vtkCellArray::New();
  rect->InsertNextCell(5);
  rect->InsertCellPoint(0);
  rect->InsertCellPoint(1);
  rect->InsertCellPoint(2);
  rect->InsertCellPoint(3);
  rect->InsertCellPoint(0);

  // Create the dataset
  vtkCoordinate *coords = vtkCoordinate::New();
  coords->SetCoordinateSystemToNormalizedViewport();

  vtkPolyData *polydata = vtkPolyData::New();
  polydata->SetPoints(pts);
  polydata->SetLines(rect);
  polydata->GetPointData()->SetScalars(scalars);

  vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New();
  mapper->SetInput(polydata);
  mapper->SetScalarRange(0,2);
  mapper->SetLookupTable(lut);

  // Create an actor.
  vtkActor2D *actor = vtkActor2D::New();
  actor->SetMapper(mapper);
  ren->AddActor2D(actor);


This gives a wireframe box.
How do I make it solid? There's no equivalent of vtkProperty::SetRepresentationToSurface() in vtkProperty2D

Thanks in advance,
Jan-Jaap



More information about the vtkusers mailing list