Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkGreedyTerrainDecimation.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGreedyTerrainDecimation.h,v $
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 =========================================================================*/
00069 #ifndef __vtkGreedyTerrainDecimation_h
00070 #define __vtkGreedyTerrainDecimation_h
00071 
00072 #include "vtkPolyDataAlgorithm.h"
00073 
00074 class vtkPriorityQueue;
00075 class vtkDataArray;
00076 class vtkPointData;
00077 class vtkIdList;
00078 class vtkDoubleArray;
00079 class vtkFloatArray;
00080 
00081 //PIMPL Encapsulation for STL containers
00082 class vtkGreedyTerrainDecimationTerrainInfoType;
00083 class vtkGreedyTerrainDecimationPointInfoType;
00084 
00085 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
00086 #define VTK_ERROR_SPECIFIED_REDUCTION 1
00087 #define VTK_ERROR_ABSOLUTE            2
00088 #define VTK_ERROR_RELATIVE            3
00089 
00090 class VTK_HYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
00091 {
00092 public:
00093   vtkTypeRevisionMacro(vtkGreedyTerrainDecimation,vtkPolyDataAlgorithm);
00094   void PrintSelf(ostream& os, vtkIndent indent);
00095 
00097   static vtkGreedyTerrainDecimation* New();
00098 
00100 
00105   vtkSetClampMacro(ErrorMeasure,int,VTK_ERROR_NUMBER_OF_TRIANGLES,VTK_ERROR_RELATIVE);
00106   vtkGetMacro(ErrorMeasure,int);
00107   void SetErrorMeasureToNumberOfTriangles() 
00108     {this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);}
00109   void SetErrorMeasureToSpecifiedReduction() 
00110     {this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);}
00111   void SetErrorMeasureToAbsoluteError() 
00112     {this->SetErrorMeasure(VTK_ERROR_ABSOLUTE);}
00113   void SetErrorMeasureToRelativeError() 
00114     {this->SetErrorMeasure(VTK_ERROR_RELATIVE);}
00116 
00118 
00122   vtkSetClampMacro(NumberOfTriangles,vtkIdType,2,VTK_LARGE_ID);
00123   vtkGetMacro(NumberOfTriangles,vtkIdType);
00125 
00127 
00130   vtkSetClampMacro(Reduction,double,0.0,1.0);
00131   vtkGetMacro(Reduction,double);
00133 
00135 
00139   vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
00140   vtkGetMacro(AbsoluteError,double);
00142 
00144 
00148   vtkSetClampMacro(RelativeError,double,0.0,VTK_DOUBLE_MAX);
00149   vtkGetMacro(RelativeError,double);
00151 
00153 
00155   vtkSetMacro(BoundaryVertexDeletion,int);
00156   vtkGetMacro(BoundaryVertexDeletion,int);
00157   vtkBooleanMacro(BoundaryVertexDeletion,int);
00159 
00161 
00162   vtkSetMacro(ComputeNormals, int);
00163   vtkGetMacro(ComputeNormals, int);
00164   vtkBooleanMacro(ComputeNormals, int);
00166 
00167 protected:
00168   vtkGreedyTerrainDecimation();
00169   ~vtkGreedyTerrainDecimation();
00170 
00171   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00172   virtual int FillInputPortInformation(int port, vtkInformation *info);
00173 
00174   int ComputeNormals;
00175   vtkFloatArray* Normals;
00176   void ComputePointNormal(int i, int j, float n[3]);
00177 
00178   //ivars that the API addresses
00179   int       ErrorMeasure;
00180   vtkIdType NumberOfTriangles;
00181   double    Reduction;
00182   double    AbsoluteError;
00183   double    RelativeError;
00184   int       BoundaryVertexDeletion; //Can we delete boundary vertices?
00185 
00186   //Used for convenience
00187   vtkPolyData    *Mesh;
00188   vtkPointData   *InputPD;
00189   vtkPointData   *OutputPD;
00190   vtkDoubleArray *Points;
00191   vtkDataArray   *Heights;
00192   vtkIdType      CurrentPointId;
00193   double         Tolerance;
00194   vtkIdList      *Neighbors;
00195   int            Dimensions[3];
00196   double         Origin[3];
00197   double         Spacing[3];
00198   vtkIdType      MaximumNumberOfTriangles;
00199   double         Length;
00200 
00201   //Bookeeping arrays
00202   vtkPriorityQueue                          *TerrainError; //errors for each pt in height field
00203   vtkGreedyTerrainDecimationTerrainInfoType *TerrainInfo;  //owning triangle for each pt
00204   vtkGreedyTerrainDecimationPointInfoType   *PointInfo;    //map mesh pt id to input pt id
00205   
00206   //Make a guess at initial allocation
00207   void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris);
00208   
00209   //Returns non-zero if the error measure is satisfied.
00210   virtual int SatisfiesErrorMeasure(double error);
00211 
00212   //Insert all the boundary vertices into the TIN
00213   void InsertBoundaryVertices();
00214     
00215   //Insert a point into the triangulation; get a point from the triangulation
00216   vtkIdType AddPointToTriangulation(vtkIdType inputPtId);
00217   vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
00218   double *GetPoint(vtkIdType id);
00219   void GetPoint(vtkIdType id, double x[3]);
00220 
00221   //Helper functions
00222   void GetTerrainPoint(int i, int j, double x[3]);
00223   void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
00224   int InCircle (double x[3], double x1[3], double x2[3], double x3[3]);
00225   vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri,
00226                          double tol, vtkIdType nei[3], vtkIdList *neighbors, int& status);
00227   void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2,
00228                  vtkIdType tri, int depth);
00229 
00230   void UpdateTriangles(vtkIdType meshPtId); //update all points connected to this point
00231   void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3);
00232   void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
00233 
00234   int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3],
00235                            int* &min, int* &max, int* &midL, int* &midR,
00236                            int* &mid, int mid2[2], double h[3], double &hMin, double &hMax, 
00237                            double &hL, double &hR);
00238 
00239 private:
00240   vtkGreedyTerrainDecimation(const vtkGreedyTerrainDecimation&);  // Not implemented.
00241   void operator=(const vtkGreedyTerrainDecimation&);  // Not implemented.
00242 
00243 };
00244 
00245 #endif

Generated on Mon Jan 21 23:07:27 2008 for VTK by  doxygen 1.4.3-20050530