vtkContourFilter on 2D Cells (vtkPolygon)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkContourFilter on 2D Cells (vtkPolygon)

Frederic DANESI
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
 



_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkContourFilter on 2D Cells (vtkPolygon)

Frederic DANESI
Dear,

There is an error in the code I enclosed in my previous email:
It is not
  flt->SetInput((vtkDataSet *) output);
but
  flt->SetInput((vtkDataSet *) polygonPolyData);
 
The result is obviously the same ...
  //+ mapping and rendering  ==> vtkContourFilter (09981DD8): Created: 0
points, 0 verts, 0 lines, 0 triangles ... empty ...

Thanks for help,
Fred.

--
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
 




_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkContourFilter on 2D Cells (vtkPolygon)

Randall Hand
In reply to this post by Frederic DANESI
You're setting the value of all 4 points to "1", and then taking a contour of 1.  It doesn't intersect anywhere, so I think it's working just right.

Change the scalars to:
  for (int i =0; i <4; i++) scalars->InsertNextValue(i);

And then you'll have 4 different values.

On 2/1/06, Frederic DANESI <[hidden email]> wrote:
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




_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Randall Hand
Visualization Scientist,
ERDC-MSRC Vicksburg, MS
Homepage: http://www.yeraze.com
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

RE: vtkContourFilter on 2D Cells (vtkPolygon)

Frederic DANESI

Dear,

Thanks for this helpful remark… it works now but finally that’s not at all what I am looking for …

In fact, I would like to find the contour of several polygons … just like a boolean operation of  “union”, so all points of all polygons have the same scalar value. I was hoping that vtkContour would assume something like this ….

Have you any idea to do this ? …

Thanks,

Fred.

 

You're setting the value of all 4 points to "1", and then taking a contour of 1.  It doesn't intersect anywhere, so I think it's working just right.

Change the scalars to:
  for (int i =0; i <4; i++) scalars->InsertNextValue(i);

And then you'll have 4 different values.

On 2/1/06, Frederic DANESI <[hidden email]> wrote:

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




_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




--
Randall Hand
Visualization Scientist,
ERDC-MSRC Vicksburg, MS
Homepage: http://www.yeraze.com


_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkContourFilter on 2D Cells (vtkPolygon)

Randall Hand
Do you want edges of all the polys?  Or just an outer outline of the entire construct? 

If the outer outline is what you want, have you tried the vtkFeatureEdges filter?

I tried this just now in Paraview (it's great for experimenting with this kind of stuff, as it's based on VTK).  I loaded an Unstructured Grid with  all 2D cells.  I had to use an "Extract Surface" (vtkDataSetSurfaceFilter) to get it into a vtkPolyData format, but then I could use the "Feature Edges" (vtkFeatureEdges) filter.  Turn off all options except "Boundary Edges", and voila. 

On 2/1/06, Frederic DANESI <[hidden email]> wrote:

Dear,

Thanks for this helpful remark… it works now but finally that's not at all what I am looking for …

In fact, I would like to find the contour of several polygons … just like a boolean operation of  "union", so all points of all polygons have the same scalar value. I was hoping that vtkContour would assume something like this ….

Have you any idea to do this ? …

Thanks,

Fred.

 

You're setting the value of all 4 points to "1", and then taking a contour of 1.  It doesn't intersect anywhere, so I think it's working just right.

Change the scalars to:
  for (int i =0; i <4; i++) scalars->InsertNextValue(i);

And then you'll have 4 different values.

On 2/1/06, Frederic DANESI <[hidden email]> wrote:

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




_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/mailman/listinfo/vtkusers




--
Randall Hand
Visualization Scientist,
ERDC-MSRC Vicksburg, MS
Homepage: <a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yeraze.com




--
Randall Hand
Visualization Scientist,
ERDC-MSRC Vicksburg, MS
Homepage: http://www.yeraze.com
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers