VTK
dox/Filtering/vtkKdNode.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkKdNode.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*----------------------------------------------------------------------------
00016  Copyright (c) Sandia Corporation
00017  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00018 ----------------------------------------------------------------------------*/
00019 
00035 #ifndef __vtkKdNode_h
00036 #define __vtkKdNode_h
00037 
00038 #include "vtkObject.h"
00039 
00040 class vtkCell;
00041 class vtkPlanesIntersection;
00042 
00043 class VTK_FILTERING_EXPORT vtkKdNode : public vtkObject
00044 {
00045 public:
00046   vtkTypeMacro(vtkKdNode, vtkObject);
00047   void PrintSelf(ostream& os, vtkIndent indent);
00048 
00049   static vtkKdNode *New();
00050 
00052 
00054   vtkSetMacro(Dim, int);
00055   vtkGetMacro(Dim, int);
00057 
00061   virtual double GetDivisionPosition();
00062 
00064 
00065   vtkSetMacro(NumberOfPoints, int);
00066   vtkGetMacro(NumberOfPoints, int);
00068 
00070 
00072   void SetBounds(double x1,double x2,double y1,double y2,double z1,double z2);
00073   void SetBounds(double b[6])
00074     {
00075     this->SetBounds(b[0], b[1], b[2], b[3], b[4], b[5]);
00076     }
00077   void GetBounds(double *b) const;
00079 
00081 
00084   void SetDataBounds(double x1,double x2,double y1,double y2,double z1,double z2);
00085   void GetDataBounds(double *b) const;
00087 
00090   void SetDataBounds(float *v);
00091 
00093 
00095   double *GetMinBounds() {return this->Min;}
00096   double *GetMaxBounds() {return this->Max;}
00098 
00100   void SetMinBounds(double *mb);
00101 
00103   void SetMaxBounds(double *mb);
00104 
00106 
00108   double *GetMinDataBounds() {return this->MinVal;}
00109   double *GetMaxDataBounds() {return this->MaxVal;}
00111 
00114   void SetMinDataBounds(double *mb);
00115 
00118   void SetMaxDataBounds(double *mb);
00119 
00121 
00123   vtkSetMacro(ID, int);
00124   vtkGetMacro(ID, int);
00126 
00128 
00133   vtkGetMacro(MinID, int);
00134   vtkGetMacro(MaxID, int);
00135   vtkSetMacro(MinID, int);
00136   vtkSetMacro(MaxID, int);
00138 
00140   void AddChildNodes(vtkKdNode *left, vtkKdNode *right);
00141 
00143   void DeleteChildNodes();
00144 
00146 
00147   vtkGetObjectMacro(Left, vtkKdNode);
00148   void SetLeft(vtkKdNode* left);
00150 
00152 
00153   vtkGetObjectMacro(Right, vtkKdNode);
00154   void SetRight(vtkKdNode *right);
00156 
00158 
00159   vtkGetObjectMacro(Up, vtkKdNode);
00160   void SetUp(vtkKdNode* up);
00162 
00164 
00167   int IntersectsBox(double x1,double x2,double y1,double y2,double z1,double z2,
00168                     int useDataBounds);
00170 
00172 
00175   int IntersectsSphere2(double x, double y, double z, double rSquared,
00176                         int useDataBounds);
00178 
00185   int IntersectsRegion(vtkPlanesIntersection *pi, int useDataBounds);
00186 
00188 
00195   int IntersectsCell(vtkCell *cell, int useDataBounds, 
00196                      int cellRegion=-1, double *cellBounds=NULL);
00198   
00200 
00203   int ContainsBox(double x1,double x2,double y1,double y2,double z1,double z2,
00204                   int useDataBounds);
00206 
00210   int ContainsPoint(double x, double y, double z, int useDataBounds);
00211 
00215   double GetDistance2ToBoundary(double x, double y, double z, int useDataBounds);
00216 
00218 
00222   double GetDistance2ToBoundary(double x, double y, double z, double *boundaryPt,
00223                                 int useDataBounds);
00225 
00230   double GetDistance2ToInnerBoundary(double x, double y, double z);
00231 
00233 
00234   void PrintNode(int depth);
00235   void PrintVerboseNode(int depth);
00237 
00238 protected:
00239 
00240   vtkKdNode();
00241   ~vtkKdNode();
00242 
00243 private:
00244 
00245   double _GetDistance2ToBoundary(
00246     double x, double y, double z, double *boundaryPt,
00247     int innerBoundaryOnly, int useDataBounds);
00248 
00249   double Min[3];       // spatial bounds of node
00250   double Max[3];       // spatial bounds of node
00251   double MinVal[3];    // spatial bounds of data within node
00252   double MaxVal[3];    // spatial bounds of data within node
00253   int NumberOfPoints;
00254   
00255   vtkKdNode *Up;
00256 
00257   vtkKdNode *Left;
00258   vtkKdNode *Right;
00259 
00260   int Dim;
00261 
00262   int ID;        // region id
00263 
00264   int MinID;
00265   int MaxID;
00266 
00267   vtkKdNode(const vtkKdNode&); // Not implemented
00268   void operator=(const vtkKdNode&); // Not implemented
00269 };
00270 
00271 #endif