[vtkusers] vtkContourFilter on 2D Cells (vtkPolygon)

Frederic DANESI fred.danesi at netcourrier.com
Wed Feb 1 04:22:34 EST 2006


Dear vtkusers,

I am trying something that I believe quite simple, but without any success.

I would like to build some vtkPolygons (2D) and then to use vtkContourFilter
to obtain an isoline (which I assume to match with the boundary of all
polygons together) ... 

Even with only one polygon, vtkContourFilter does not do anything
(vtkContourFilter (09981DD8): Created: 0 points, 0 verts, 0 lines, 0
triangles) ... 

I enclosed my code hereafter.

I will really appreciate any idea, tips on what I missed or what I'm doing
wrong, or any code example...

Thanks,
Fred.

----

vtkPolygon *polygon = vtkPolygon::New();

  polygon->GetPointIds()->SetNumberOfIds(4);
  polygon->GetPointIds()->SetId(0,0);
  polygon->GetPointIds()->SetId(1,1);
  polygon->GetPointIds()->SetId(2,2);
  polygon->GetPointIds()->SetId(3,3);

  polygon->GetPoints()->SetNumberOfPoints(4);
  polygon->GetPoints()->SetPoint(0, 0.0, 0.0, 0.0);
  polygon->GetPoints()->SetPoint(1, 10.0, 0.0, 0.0);
  polygon->GetPoints()->SetPoint(2, 10.0, 10.0, 0.0);
  polygon->GetPoints()->SetPoint(3, 0.0, 10.0, 0.0);

  vtkIntArray * scalars = vtkIntArray::New();
  scalars->Allocate(5000,10000);
  for (int i =0; i <4; i++) scalars->InsertNextValue(1);
  
  vtkPolyData * polygonPolyData = vtkPolyData::New();
  polygonPolyData->Allocate(1,1);
  polygonPolyData->InsertNextCell(polygon->GetCellType(),
polygon->GetPointIds());
  polygonPolyData->SetPoints(polygon->GetPoints());
  polygonPolyData->GetPointData()->SetScalars(scalars);

  // mapping and rendering "polygonPolyData" ==> OK ...

  vtkContourFilter * flt = vtkContourFilter ::New();
  flt->SetInput((vtkDataSet *)output);
  flt->DebugOn();
  flt->SetValue(0,1);
	  
  //+ mapping and rendering  ==> vtkContourFilter (09981DD8): Created: 0
points, 0 verts, 0 lines, 0 triangles ... empty ...

--
Responsable Département DINCCS
(Département Ingénierie Numérique Conception Collaborative et Simulation)
Pole de Haute Technologie
08000 Charleville-Mézières
Tél. 03.24.37.89.89
  






More information about the vtkusers mailing list