[vtkusers] modifications to vtkTensorGlyph

Alexandre Guimond guimond at bwh.harvard.edu
Fri Jun 29 13:34:55 EDT 2001


Hi.  It is sometimes convinient to scale glyphs in vtkTensorGlyph
according to the *square root* of the eigenvalues, for example, when
the tensors correspond to covariance matrices.  Would it be possible
to add this functionality to vtkTensorGlyph?  If so, here is a patch
file. thx.

Index: vtkTensorGlyph.cxx
===================================================================
RCS file: /vtk/cvsroot/vtk/graphics/vtkTensorGlyph.cxx,v
retrieving revision 1.42
diff -u -r1.42 vtkTensorGlyph.cxx
--- vtkTensorGlyph.cxx	2001/06/18 13:13:03	1.42
+++ vtkTensorGlyph.cxx	2001/06/29 17:31:06
@@ -73,6 +73,7 @@
   this->ColorGlyphs = 1;
   this->ClampScaling = 0;
   this->MaxScaleFactor = 100;
+  this->SqrtScaleFactors = 0;
 }
 
 vtkTensorGlyph::~vtkTensorGlyph()
@@ -251,6 +252,23 @@
       w[2] = vtkMath::Normalize(zv);
       }
 
+    // compute square root of scale factors if desired
+    if(this->SqrtScaleFactors)
+      {
+      if(w[0]!=0)
+	{
+	w[0]=sqrt(w[0]);
+	}
+      if(w[1]!=0)
+	{
+	w[1]=sqrt(w[1]);
+	}
+      if(w[2]!=0)
+	{
+	w[2]=sqrt(w[2]);
+	}
+      }
+    
     // compute scale factors
     w[0] *= this->ScaleFactor;
     w[1] *= this->ScaleFactor;
Index: vtkTensorGlyph.h
===================================================================
RCS file: /vtk/cvsroot/vtk/graphics/vtkTensorGlyph.h,v
retrieving revision 1.33
diff -u -r1.33 vtkTensorGlyph.h
--- vtkTensorGlyph.h	2000/12/10 20:08:55	1.33
+++ vtkTensorGlyph.h	2001/06/29 17:31:06
@@ -111,6 +111,12 @@
   vtkGetMacro(ExtractEigenvalues,int);
 
   // Description:
+  // Turn on/off scaling by square root of eigenvalues.
+  vtkSetMacro(SqrtScaleFactors,int);
+  vtkBooleanMacro(SqrtScaleFactors,int);
+  vtkGetMacro(SqrtScaleFactors,int);
+
+  // Description:
   // Turn on/off coloring of glyph with input scalar data. If false, or 
   // input scalar data not present, then the scalars from the source
   // object are passed through the filter.
@@ -148,6 +154,7 @@
   int ColorGlyphs; // Boolean controls coloring with input scalar data
   int ClampScaling; // Boolean controls whether scaling is clamped.
   float MaxScaleFactor; // Maximum scale factor (ScaleFactor*eigenvalue)
+  int SqrtScaleFactors; // Scale by Square Root of eigenvalues.
 };
 
 #endif

-- 
Alexandre Guimond, Ph.D. guimond at bwh.harvard.edu Phone:(617) 278-0800 
http://spl.bwh.harvard.edu:8000/~guimond/          Fax:(617) 264-5154
Brigham and Women's Hospital, Harvard Medical School
CNI, RF396, 221 Longwood Av, Boston, MA 02115




More information about the vtkusers mailing list