VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPolyDataConnectivityFilter.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 =========================================================================*/ 00046 #ifndef __vtkPolyDataConnectivityFilter_h 00047 #define __vtkPolyDataConnectivityFilter_h 00048 00049 #include "vtkPolyDataAlgorithm.h" 00050 00051 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1 00052 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2 00053 #define VTK_EXTRACT_SPECIFIED_REGIONS 3 00054 #define VTK_EXTRACT_LARGEST_REGION 4 00055 #define VTK_EXTRACT_ALL_REGIONS 5 00056 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6 00057 00058 class vtkDataArray; 00059 class vtkIdList; 00060 class vtkIdTypeArray; 00061 00062 class VTK_GRAPHICS_EXPORT vtkPolyDataConnectivityFilter : public vtkPolyDataAlgorithm 00063 { 00064 public: 00065 vtkTypeMacro(vtkPolyDataConnectivityFilter,vtkPolyDataAlgorithm); 00066 void PrintSelf(ostream& os, vtkIndent indent); 00067 00069 static vtkPolyDataConnectivityFilter *New(); 00070 00072 00075 vtkSetMacro(ScalarConnectivity,int); 00076 vtkGetMacro(ScalarConnectivity,int); 00077 vtkBooleanMacro(ScalarConnectivity,int); 00079 00081 00083 vtkSetVector2Macro(ScalarRange,double); 00084 vtkGetVector2Macro(ScalarRange,double); 00086 00088 00089 vtkSetClampMacro(ExtractionMode,int, 00090 VTK_EXTRACT_POINT_SEEDED_REGIONS, 00091 VTK_EXTRACT_CLOSEST_POINT_REGION); 00092 vtkGetMacro(ExtractionMode,int); 00093 void SetExtractionModeToPointSeededRegions() 00094 {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);}; 00095 void SetExtractionModeToCellSeededRegions() 00096 {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);}; 00097 void SetExtractionModeToLargestRegion() 00098 {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);}; 00099 void SetExtractionModeToSpecifiedRegions() 00100 {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);}; 00101 void SetExtractionModeToClosestPointRegion() 00102 {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);}; 00103 void SetExtractionModeToAllRegions() 00104 {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);}; 00105 const char *GetExtractionModeAsString(); 00107 00109 void InitializeSeedList(); 00110 00112 void AddSeed(int id); 00113 00115 void DeleteSeed(int id); 00116 00118 void InitializeSpecifiedRegionList(); 00119 00121 void AddSpecifiedRegion(int id); 00122 00124 void DeleteSpecifiedRegion(int id); 00125 00127 00129 vtkSetVector3Macro(ClosestPoint,double); 00130 vtkGetVectorMacro(ClosestPoint,double,3); 00132 00134 int GetNumberOfExtractedRegions(); 00135 00137 00138 vtkSetMacro(ColorRegions,int); 00139 vtkGetMacro(ColorRegions,int); 00140 vtkBooleanMacro(ColorRegions,int); 00142 00143 protected: 00144 vtkPolyDataConnectivityFilter(); 00145 ~vtkPolyDataConnectivityFilter(); 00146 00147 // Usual data generation method 00148 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00149 00150 int ColorRegions; //boolean turns on/off scalar gen for separate regions 00151 int ExtractionMode; //how to extract regions 00152 vtkIdList *Seeds; //id's of points or cells used to seed regions 00153 vtkIdList *SpecifiedRegionIds; //regions specified for extraction 00154 vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted 00155 00156 double ClosestPoint[3]; 00157 00158 int ScalarConnectivity; 00159 double ScalarRange[2]; 00160 00161 void TraverseAndMark(); 00162 00163 // used to support algorithm execution 00164 vtkDataArray *CellScalars; 00165 vtkIdList *NeighborCellPointIds; 00166 vtkIdType *Visited; 00167 vtkIdType *PointMap; 00168 vtkDataArray *NewScalars; 00169 vtkIdType RegionNumber; 00170 vtkIdType PointNumber; 00171 vtkIdType NumCellsInRegion; 00172 vtkDataArray *InScalars; 00173 vtkPolyData *Mesh; 00174 vtkIdList *Wave; 00175 vtkIdList *Wave2; 00176 vtkIdList *PointIds; 00177 vtkIdList *CellIds; 00178 private: 00179 vtkPolyDataConnectivityFilter(const vtkPolyDataConnectivityFilter&); // Not implemented. 00180 void operator=(const vtkPolyDataConnectivityFilter&); // Not implemented. 00181 }; 00182 00184 00185 inline const char *vtkPolyDataConnectivityFilter::GetExtractionModeAsString(void) 00186 { 00187 if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS ) 00188 { 00189 return "ExtractPointSeededRegions"; 00190 } 00191 else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS ) 00192 { 00193 return "ExtractCellSeededRegions"; 00194 } 00195 else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS ) 00196 { 00197 return "ExtractSpecifiedRegions"; 00198 } 00199 else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS ) 00200 { 00201 return "ExtractAllRegions"; 00202 } 00203 else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION ) 00204 { 00205 return "ExtractClosestPointRegion"; 00206 } 00207 else 00208 { 00209 return "ExtractLargestRegion"; 00210 } 00211 } 00213 00214 00215 #endif