[vtkusers] designing a probe filter

Dean Inglis dean.inglis at camris.ca
Thu Mar 4 11:07:26 EST 2004


Hi,

I have a filter that I implemented (naively) some time ago
that takes vtkImageData and a set of vtkPoints as
input.  The input vtkPoints are typically obtained from a
vtkSplineWidget manipulated on a visulaized slice
of image data.  The filter converts point xyz coords
to discrete ijk indices to probe the vtkImagedata.
It calculates mean, min, max, std dev, n points, etc. and ensures
that the calculated ijk discrete points are non-repeating
in a local sense (e.g., criss-crossed paths are allowed).
The filter maintains an internal vtkPoints consisting of
a subset of the input points that can be uniquely
discretized to ijk indices.  I want to implement this filter
correctly since I am running into some memory access pb's.
Any ideas on which VTK class to sub-class from would be helpful.

thanks,
Dean

the current naive implementaton:

#include <vtkstd/vector>

class vtkImageData;
class vtkPoints;

class VTK_LOCAL_IMAGING_EXPORT vtkVoxelProfile : public vtkObject
{
public:
  // Description:
  // Instantiate the object.
  static vtkVoxelProfile *New();
  vtkTypeRevisionMacro(vtkVoxelProfile,vtkObject);

  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Set the image data to lookup into.
  void SetImageData(vtkImageData* data);

  // Description:
  // Set the points to lookup into the image with.
  void SetInputPoints(vtkPoints* points);

  vtkPoints* GetOutputPoints(){return this->OutputPoints;}

  // Description:
  // Get basic image stats.
  vtkGetMacro(MinValue, double);
  vtkGetMacro(MaxValue, double);
  vtkGetMacro(StdDev, double);
  vtkGetMacro(Variance, double);
  vtkGetMacro(Mean, double);
  vtkGetMacro(Sum, double);
  vtkGetMacro(NumValues, unsigned int);
  vtkGetMacro(NumPoints, unsigned int);
  vtkGetMacro(Median, double);

  // Description:
  // Traverse the list of points.
  void Traverse();

  // Description:
  // Calculate basic stats.
  void CalculateData();

  // Description:
  // Clear the list of found unique points and initialize image stat values.
  void Reset();

  // Description:
  // Flag to prevent clearing the list of unique points.
  vtkSetMacro(Append,int);
  vtkGetMacro(Append,int);
  vtkBooleanMacro(Append,int);

protected:
  vtkVoxelProfile();
  ~vtkVoxelProfile();

  vtkImageData* ImageData;
  vtkPoints*    InputPoints;
  vtkPoints*    OutputPoints;

  int Append;

//BTX
  std::vector<double> Vector;
//ETX

  double    MinValue;
  double    MaxValue;
  double    StdDev;
  double    Variance;   // sigma squared
  double    Mean;       // average
  double    Median;
  double    Sum;
  unsigned int NumValues; // number of unique non-repeated points
  unsigned int NumPoints;  // number of input points

private:
  vtkVoxelProfile(const vtkVoxelProfile&);  //Not implemented
  void operator=(const vtkVoxelProfile&);  //Not implemented
};

#endif





More information about the vtkusers mailing list