[vtkusers] Bug in vtkRIBExporter

Rainer Sabelka sabelka at iue.tuwien.ac.at
Sat Nov 11 18:34:32 EST 2000


Hi,

some time ago I posted a fix for a bug in vtkRIBExporter. Recently I
tried out the latest nightlies
and noticed that the bug is still there (cell data do not work
correctly).
I'll attach the fix to this mail. Can someone with CVS access please
incorporate it into the repository?

Thanks,
Rainer
-------------- next part --------------
--- vtkRIBExporter.h.orig	Sat Nov 11 22:28:10 2000
+++ vtkRIBExporter.h	Sun Nov 12 00:17:50 2000
@@ -148,8 +148,8 @@
   void WriteLight (vtkLight *aLight, int count);
   void WriteAmbientLight (int count);
   void WriteProperty (vtkProperty *aProperty, vtkTexture *aTexture);
-  void WritePolygons (vtkPolyData *pd, vtkScalars *colors, vtkProperty *aProperty);
-  void WriteStrips (vtkPolyData *pd, vtkScalars *colors, vtkProperty *aProperty);
+  void WritePolygons (vtkPolyData *pd, vtkScalars *colors, vtkProperty *aProperty, int useCellData);
+  void WriteStrips (vtkPolyData *pd, vtkScalars *colors, vtkProperty *aProperty, int useCellData);
 
   void WriteData();
   void WriteActor(vtkActor *anActor);
-------------- next part --------------
--- vtkRIBExporter.cxx.orig	Sat Nov 11 22:28:19 2000
+++ vtkRIBExporter.cxx	Sun Nov 12 00:17:19 2000
@@ -644,13 +644,17 @@
     polyData = (vtkPolyData *)aDataSet;
     }
 
+  int useCellData=0;
+  if(anActor->GetMapper()->GetScalarMode() == VTK_SCALAR_MODE_USE_CELL_DATA
+     || polyData->GetPointData()->GetScalars() == NULL) useCellData=1;
+
   if (polyData->GetNumberOfPolys ())
     {
-    this->WritePolygons (polyData, anActor->GetMapper()->GetColors (), anActor->GetProperty ());
+    this->WritePolygons (polyData, anActor->GetMapper()->GetColors (), anActor->GetProperty (), useCellData);
     }
   if (polyData->GetNumberOfStrips ())
     {
-    this->WriteStrips (polyData, anActor->GetMapper()->GetColors (), anActor->GetProperty ());
+    this->WriteStrips (polyData, anActor->GetMapper()->GetColors (), anActor->GetProperty (), useCellData);
     }
   fprintf (this->FilePtr, "TransformEnd\n");
   fprintf (this->FilePtr, "AttributeEnd\n");
@@ -661,7 +665,7 @@
   matrix->Delete();
 }
 
-void vtkRIBExporter::WritePolygons (vtkPolyData *polyData, vtkScalars *s, vtkProperty *aProperty)
+void vtkRIBExporter::WritePolygons (vtkPolyData *polyData, vtkScalars *s, vtkProperty *aProperty, int useCellData)
 {
   float vertexColors[512][3];
   RtFloat *TCoords;
@@ -719,7 +723,8 @@
     n = 0;
     }
 
-  for (polys->InitTraversal(); polys->GetNextCell(npts,pts); )
+  int cellNum=0;
+  for (polys->InitTraversal(); polys->GetNextCell(npts,pts); cellNum++)
     { 
     if (!n)
       {
@@ -731,7 +736,8 @@
       k = j;
       if (s) 
         {
-        colors = s->GetColor(pts[k]);
+        if(useCellData) colors=s->GetColor(cellNum);
+        else colors = s->GetColor(pts[k]);
         vertexColors[k][0] = colors[0] / 255.0;
         vertexColors[k][1] = colors[1] / 255.0;
         vertexColors[k][2] = colors[2] / 255.0;
@@ -805,7 +811,7 @@
   polygon->Delete();
 }
 
-void vtkRIBExporter::WriteStrips (vtkPolyData *polyData, vtkScalars *s, vtkProperty *aProperty)
+void vtkRIBExporter::WriteStrips (vtkPolyData *polyData, vtkScalars *s, vtkProperty *aProperty, int useCellData)
 {
   float vertexColors[512][3];
   RtFloat *TCoords;
@@ -867,7 +873,8 @@
 
 
   // each iteration returns a triangle strip
-  for (strips->InitTraversal(); strips->GetNextCell(npts,pts); )
+  int cellNum=0;
+  for (strips->InitTraversal(); strips->GetNextCell(npts,pts); cellNum++)
     { 
     // each triangle strip is converted into a bunch of triangles
     p1 = pts[0];
@@ -898,7 +905,8 @@
         {
         if (s) 
           {
-          colors = s->GetColor(idx[k]);
+          if(useCellData) colors=s->GetColor(cellNum);
+          else colors = s->GetColor(pts[k]);
           vertexColors[k][0] = colors[0] / 255.0;
           vertexColors[k][1] = colors[1] / 255.0;
           vertexColors[k][2] = colors[2] / 255.0;


More information about the vtkusers mailing list