Attached Files | 03_offset.patch [^] (10,977 bytes) 2008-07-07 08:12 [Show Content] [Hide Content]This patch permits to make different polygon offset for each mappers (by default VTK use statics members so the offset parameters are shared by all the mappers).
Index: Rendering/vtkMapper.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkMapper.cxx,v
retrieving revision 1.122
diff -u -r1.122 vtkMapper.cxx
--- Rendering/vtkMapper.cxx 23 Feb 2008 17:18:46 -0000 1.122
+++ Rendering/vtkMapper.cxx 17 Jun 2008 10:09:34 -0000
@@ -27,13 +27,6 @@
// Initialize static member that controls global immediate mode rendering
static int vtkMapperGlobalImmediateModeRendering = 0;
-// Initialize static member that controls global coincidence resolution
-static int vtkMapperGlobalResolveCoincidentTopology = VTK_RESOLVE_OFF;
-static double vtkMapperGlobalResolveCoincidentTopologyZShift = 0.01;
-static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor = 1.0;
-static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits = 1.0;
-static int vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFaces = 1;
-
// Construct with initial range (0,1).
vtkMapper::vtkMapper()
{
@@ -64,6 +57,12 @@
this->InterpolateScalarsBeforeMapping = 0;
this->ColorCoordinates = 0;
this->ColorTextureMap = 0;
+
+ this->ResolveCoincidentTopology = VTK_RESOLVE_OFF;
+ this->ResolveCoincidentTopologyZShift = 0.01;
+ this->ResolveCoincidentTopologyPolygonOffsetFactor = 1.0;
+ this->ResolveCoincidentTopologyPolygonOffsetUnits = 1.0;
+ this->ResolveCoincidentTopologyPolygonOffsetFaces = 1;
}
vtkMapper::~vtkMapper()
@@ -132,66 +131,28 @@
return vtkMapperGlobalImmediateModeRendering;
}
-void vtkMapper::SetResolveCoincidentTopology(int val)
-{
- if (val == vtkMapperGlobalResolveCoincidentTopology)
- {
- return;
- }
- vtkMapperGlobalResolveCoincidentTopology = val;
-}
-
-int vtkMapper::GetResolveCoincidentTopology()
-{
- return vtkMapperGlobalResolveCoincidentTopology;
-}
-
void vtkMapper::SetResolveCoincidentTopologyToDefault()
{
- vtkMapperGlobalResolveCoincidentTopology = VTK_RESOLVE_OFF;
-}
-
-void vtkMapper::SetResolveCoincidentTopologyZShift(double val)
-{
- if (val == vtkMapperGlobalResolveCoincidentTopologyZShift)
- {
- return;
- }
- vtkMapperGlobalResolveCoincidentTopologyZShift = val;
-}
-
-double vtkMapper::GetResolveCoincidentTopologyZShift()
-{
- return vtkMapperGlobalResolveCoincidentTopologyZShift;
+ this->ResolveCoincidentTopology = VTK_RESOLVE_OFF;
}
void vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(
double factor, double units)
{
- if (factor == vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor &&
- units == vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits )
+ if (factor == this->ResolveCoincidentTopologyPolygonOffsetFactor &&
+ units == this->ResolveCoincidentTopologyPolygonOffsetUnits )
{
return;
}
- vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor = factor;
- vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits = units;
+ this->ResolveCoincidentTopologyPolygonOffsetFactor = factor;
+ this->ResolveCoincidentTopologyPolygonOffsetUnits = units;
}
void vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(
double& factor, double& units)
{
- factor = vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor;
- units = vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits;
-}
-
-void vtkMapper::SetResolveCoincidentTopologyPolygonOffsetFaces(int faces)
-{
- vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFaces = faces;
-}
-
-int vtkMapper::GetResolveCoincidentTopologyPolygonOffsetFaces()
-{
- return vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFaces;
+ factor = this->ResolveCoincidentTopologyPolygonOffsetFactor;
+ units = this->ResolveCoincidentTopologyPolygonOffsetUnits;
}
// Overload standard modified time function. If lookup table is modified,
@@ -700,11 +661,11 @@
os << indent << "RenderTime: " << this->RenderTime << endl;
os << indent << "Resolve Coincident Topology: ";
- if ( vtkMapperGlobalResolveCoincidentTopology == VTK_RESOLVE_OFF )
+ if ( this->ResolveCoincidentTopology == VTK_RESOLVE_OFF )
{
os << "Off" << endl;
}
- else if ( vtkMapperGlobalResolveCoincidentTopology == VTK_RESOLVE_POLYGON_OFFSET )
+ else if ( this->ResolveCoincidentTopology == VTK_RESOLVE_POLYGON_OFFSET )
{
os << "Polygon Offset" << endl;
}
Index: Rendering/vtkMapper.h
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkMapper.h,v
retrieving revision 1.94
diff -u -r1.94 vtkMapper.h
--- Rendering/vtkMapper.h 27 Aug 2007 20:44:05 -0000 1.94
+++ Rendering/vtkMapper.h 17 Jun 2008 10:09:34 -0000
@@ -263,41 +263,26 @@
// approach, you may also want to set the ResolveCoincidentTopologyZShift
// value. (Note: not all mappers/graphics systems implement this
// functionality.)
- static void SetResolveCoincidentTopology(int val);
- static int GetResolveCoincidentTopology();
- static void SetResolveCoincidentTopologyToDefault();
- static void SetResolveCoincidentTopologyToOff()
+ /*void SetResolveCoincidentTopology(int val);
+ int GetResolveCoincidentTopology();*/
+ void SetResolveCoincidentTopologyToDefault();
+ void SetResolveCoincidentTopologyToOff()
{SetResolveCoincidentTopology(VTK_RESOLVE_OFF);}
- static void SetResolveCoincidentTopologyToPolygonOffset()
+ void SetResolveCoincidentTopologyToPolygonOffset()
{SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);}
- static void SetResolveCoincidentTopologyToShiftZBuffer()
+ void SetResolveCoincidentTopologyToShiftZBuffer()
{SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);}
// Description:
// Used to set the polygon offset scale factor and units.
// Used when ResolveCoincidentTopology is set to PolygonOffset.
// These are global variables.
- static void SetResolveCoincidentTopologyPolygonOffsetParameters(
+ void SetResolveCoincidentTopologyPolygonOffsetParameters(
double factor, double units);
- static void GetResolveCoincidentTopologyPolygonOffsetParameters(
+ void GetResolveCoincidentTopologyPolygonOffsetParameters(
double& factor, double& units);
// Description:
- // Used when ResolveCoincidentTopology is set to PolygonOffset. The polygon
- // offset can be applied either to the solid polygonal faces or the
- // lines/vertices. When set (default), the offset is applied to the faces
- // otherwise it is applied to lines and vertices.
- // This is a global variable.
- static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
- static int GetResolveCoincidentTopologyPolygonOffsetFaces();
-
- // Description:
- // Used to set the z-shift if ResolveCoincidentTopology is set to
- // ShiftZBuffer. This is a global variable.
- static void SetResolveCoincidentTopologyZShift(double val);
- static double GetResolveCoincidentTopologyZShift();
-
- // Description:
// Return bounding box (array of six doubles) of data expressed as
// (xmin,xmax, ymin,ymax, zmin,zmax).
virtual double *GetBounds();
@@ -347,6 +332,31 @@
void SetScalarMaterialModeToAmbientAndDiffuse()
{this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE);};
+ // controls coincidence resolution
+ vtkSetMacro(ResolveCoincidentTopology, int);
+ vtkGetMacro(ResolveCoincidentTopology, int);
+
+ // Description:
+ // Used to set the z-shift if ResolveCoincidentTopology is set to
+ // ShiftZBuffer. This is a global variable.
+ vtkSetMacro(ResolveCoincidentTopologyZShift, double);
+ vtkGetMacro(ResolveCoincidentTopologyZShift, double);
+
+ vtkSetMacro(ResolveCoincidentTopologyPolygonOffsetFactor, double);
+ vtkGetMacro(ResolveCoincidentTopologyPolygonOffsetFactor, double);
+
+ vtkSetMacro(ResolveCoincidentTopologyPolygonOffsetUnits, double);
+ vtkGetMacro(ResolveCoincidentTopologyPolygonOffsetUnits, double);
+
+ // Description:
+ // Used when ResolveCoincidentTopology is set to PolygonOffset. The polygon
+ // offset can be applied either to the solid polygonal faces or the
+ // lines/vertices. When set (default), the offset is applied to the faces
+ // otherwise it is applied to lines and vertices.
+ // This is a global variable.
+ vtkSetMacro(ResolveCoincidentTopologyPolygonOffsetFaces, int);
+ vtkGetMacro(ResolveCoincidentTopologyPolygonOffsetFaces, int);
+
// Description:
// Return the light-model color mode.
const char *GetScalarMaterialModeAsString();
@@ -375,6 +385,13 @@
int ScalarMode;
int ScalarMaterialMode;
+ // Controls coincidence resolution
+ int ResolveCoincidentTopology;
+ double ResolveCoincidentTopologyZShift;
+ double ResolveCoincidentTopologyPolygonOffsetFactor;
+ double ResolveCoincidentTopologyPolygonOffsetUnits;
+ int ResolveCoincidentTopologyPolygonOffsetFaces;
+
double RenderTime;
// for coloring by a component of a field data array
Index: Rendering/vtkOpenGLImageActor.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkOpenGLImageActor.cxx,v
retrieving revision 1.37
diff -u -r1.37 vtkOpenGLImageActor.cxx
--- Rendering/vtkOpenGLImageActor.cxx 5 Mar 2008 19:01:46 -0000 1.37
+++ Rendering/vtkOpenGLImageActor.cxx 17 Jun 2008 10:09:35 -0000
@@ -319,6 +319,11 @@
return res;
}
+#include <iostream>
+#include <cassert>
+
+using namespace std;
+
// Implement base class method.
void vtkOpenGLImageActor::Load(vtkRenderer *ren)
{
@@ -462,7 +467,9 @@
// draw the quad
- if ( vtkMapper::GetResolveCoincidentTopology() )
+ cerr << "You should rewrite the polygon offSet of vtkOpenGLImageActor !" << endl;
+ assert(0);
+ /*if ( vtkMapper::GetResolveCoincidentTopology() )
{
if ( vtkMapper::GetResolveCoincidentTopology() ==
VTK_RESOLVE_SHIFT_ZBUFFER )
@@ -477,7 +484,7 @@
glPolygonOffset(f,u);
#endif
}
- }
+ }*/
glDisable(GL_COLOR_MATERIAL);
glDisable (GL_CULL_FACE);
glDisable( GL_LIGHTING );
Index: Widgets/Testing/Cxx/TestOrientationMarkerWidget.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Widgets/Testing/Cxx/TestOrientationMarkerWidget.cxx,v
retrieving revision 1.2
diff -u -r1.2 TestOrientationMarkerWidget.cxx
--- Widgets/Testing/Cxx/TestOrientationMarkerWidget.cxx 7 Apr 2007 15:20:54 -0000 1.2
+++ Widgets/Testing/Cxx/TestOrientationMarkerWidget.cxx 17 Jun 2008 10:09:41 -0000
@@ -461,7 +461,7 @@
// this static function improves the appearance of the text edges
// since they are overlaid on a surface rendering of the cube's faces
//
- vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
+ //vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
// anatomic labelling
//
|