VTK
dox/Common/DataModel/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 "vtkCommonDataModelModule.h" // For export macro
00039 #include "vtkObject.h"
00040 
00041 class vtkCell;
00042 class vtkPlanesIntersection;
00043 
00044 class VTKCOMMONDATAMODEL_EXPORT vtkKdNode : public vtkObject
00045 {
00046 public:
00047   vtkTypeMacro(vtkKdNode, vtkObject);
00048   void PrintSelf(ostream& os, vtkIndent indent);
00049 
00050   static vtkKdNode *New();
00051 
00053 
00055   vtkSetMacro(Dim, int);
00056   vtkGetMacro(Dim, int);
00058 
00062   virtual double GetDivisionPosition();
00063 
00065 
00066   vtkSetMacro(NumberOfPoints, int);
00067   vtkGetMacro(NumberOfPoints, int);
00069 
00071 
00073   void SetBounds(double x1,double x2,double y1,double y2,double z1,double z2);
00074   void SetBounds(double b[6])
00075     {
00076     this->SetBounds(b[0], b[1], b[2], b[3], b[4], b[5]);
00077     }
00078   void GetBounds(double *b) const;
00080 
00082 
00085   void SetDataBounds(double x1,double x2,double y1,double y2,double z1,double z2);
00086   void GetDataBounds(double *b) const;
00088 
00091   void SetDataBounds(float *v);
00092 
00094 
00096   double *GetMinBounds() {return this->Min;}
00097   double *GetMaxBounds() {return this->Max;}
00099 
00101   void SetMinBounds(double *mb);
00102 
00104   void SetMaxBounds(double *mb);
00105 
00107 
00109   double *GetMinDataBounds() {return this->MinVal;}
00110   double *GetMaxDataBounds() {return this->MaxVal;}
00112 
00115   void SetMinDataBounds(double *mb);
00116 
00119   void SetMaxDataBounds(double *mb);
00120 
00122 
00124   vtkSetMacro(ID, int);
00125   vtkGetMacro(ID, int);
00127 
00129 
00134   vtkGetMacro(MinID, int);
00135   vtkGetMacro(MaxID, int);
00136   vtkSetMacro(MinID, int);
00137   vtkSetMacro(MaxID, int);
00139 
00141   void AddChildNodes(vtkKdNode *left, vtkKdNode *right);
00142 
00144   void DeleteChildNodes();
00145 
00147 
00148   vtkGetObjectMacro(Left, vtkKdNode);
00149   void SetLeft(vtkKdNode* left);
00151 
00153 
00154   vtkGetObjectMacro(Right, vtkKdNode);
00155   void SetRight(vtkKdNode *right);
00157 
00159 
00160   vtkGetObjectMacro(Up, vtkKdNode);
00161   void SetUp(vtkKdNode* up);
00163 
00165 
00168   int IntersectsBox(double x1,double x2,double y1,double y2,double z1,double z2,
00169                     int useDataBounds);
00171 
00173 
00176   int IntersectsSphere2(double x, double y, double z, double rSquared,
00177                         int useDataBounds);
00179 
00186   int IntersectsRegion(vtkPlanesIntersection *pi, int useDataBounds);
00187 
00189 
00196   int IntersectsCell(vtkCell *cell, int useDataBounds,
00197                      int cellRegion=-1, double *cellBounds=NULL);
00199 
00201 
00204   int ContainsBox(double x1,double x2,double y1,double y2,double z1,double z2,
00205                   int useDataBounds);
00207 
00211   int ContainsPoint(double x, double y, double z, int useDataBounds);
00212 
00216   double GetDistance2ToBoundary(double x, double y, double z, int useDataBounds);
00217 
00219 
00223   double GetDistance2ToBoundary(double x, double y, double z, double *boundaryPt,
00224                                 int useDataBounds);
00226 
00231   double GetDistance2ToInnerBoundary(double x, double y, double z);
00232 
00234 
00235   void PrintNode(int depth);
00236   void PrintVerboseNode(int depth);
00238 
00239 protected:
00240 
00241   vtkKdNode();
00242   ~vtkKdNode();
00243 
00244 private:
00245 
00246   double _GetDistance2ToBoundary(
00247     double x, double y, double z, double *boundaryPt,
00248     int innerBoundaryOnly, int useDataBounds);
00249 
00250   double Min[3];       // spatial bounds of node
00251   double Max[3];       // spatial bounds of node
00252   double MinVal[3];    // spatial bounds of data within node
00253   double MaxVal[3];    // spatial bounds of data within node
00254   int NumberOfPoints;
00255 
00256   vtkKdNode *Up;
00257 
00258   vtkKdNode *Left;
00259   vtkKdNode *Right;
00260 
00261   int Dim;
00262 
00263   int ID;        // region id
00264 
00265   int MinID;
00266   int MaxID;
00267 
00268   vtkKdNode(const vtkKdNode&); // Not implemented
00269   void operator=(const vtkKdNode&); // Not implemented
00270 };
00271 
00272 #endif