VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkHull.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 =========================================================================*/ 00043 #ifndef __vtkHull_h 00044 #define __vtkHull_h 00045 00046 #include "vtkPolyDataAlgorithm.h" 00047 00048 class vtkCellArray; 00049 class vtkPlanes; 00050 class vtkPoints; 00051 class vtkPolyData; 00052 00053 class VTK_GRAPHICS_EXPORT vtkHull : public vtkPolyDataAlgorithm 00054 { 00055 public: 00056 static vtkHull *New(); 00057 vtkTypeMacro(vtkHull,vtkPolyDataAlgorithm); 00058 void PrintSelf(ostream& os, vtkIndent indent); 00059 00061 void RemoveAllPlanes( void ); 00062 00064 00073 int AddPlane( double A, double B, double C ); 00074 int AddPlane( double plane[3] ); 00076 00078 00084 void SetPlane( int i, double A, double B, double C ); 00085 void SetPlane( int i, double plane[3] ); 00087 00089 00091 int AddPlane( double A, double B, double C, double D ); 00092 int AddPlane( double plane[3], double D ); 00093 void SetPlane( int i, double A, double B, double C, double D ); 00094 void SetPlane( int i, double plane[3], double D ); 00096 00099 void SetPlanes( vtkPlanes *planes ); 00100 00102 00103 vtkGetMacro( NumberOfPlanes, int ); 00105 00110 void AddCubeVertexPlanes(); 00111 00116 void AddCubeEdgePlanes(); 00117 00120 void AddCubeFacePlanes(); 00121 00129 void AddRecursiveSpherePlanes( int level ); 00130 00132 00140 void GenerateHull(vtkPolyData *pd, double *bounds); 00141 void GenerateHull(vtkPolyData *pd, double xmin, double xmax, 00142 double ymin, double ymax, double zmin, double zmax); 00144 00145 protected: 00146 vtkHull(); 00147 ~vtkHull(); 00148 00149 // The planes - 4 doubles per plane for A, B, C, D 00150 double *Planes; 00151 00152 // This indicates the current size (in planes - 4*sizeof(double)) of 00153 // the this->Planes array. Planes are allocated in chunks so that the 00154 // array does not need to be reallocated every time a new plane is added 00155 int PlanesStorageSize; 00156 00157 // The number of planes that have been added 00158 int NumberOfPlanes; 00159 00160 // Internal method used to find the position of each plane 00161 void ComputePlaneDistances(vtkPolyData *input); 00162 00163 // Internal method used to create the actual polygons from the set 00164 // of planes 00165 void ClipPolygonsFromPlanes( vtkPoints *points, vtkCellArray *polys, 00166 double *bounds ); 00167 00168 // Internal method used to create the initial "big" polygon from the 00169 // plane equation. This polygon is clipped by all other planes to form 00170 // the final polygon (or it may be clipped entirely) 00171 void CreateInitialPolygon( double *, int, double * ); 00172 00173 // The method that does it all... 00174 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00175 private: 00176 vtkHull(const vtkHull&); // Not implemented. 00177 void operator=(const vtkHull&); // Not implemented. 00178 }; 00179 00180 #endif