VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkConnectivityFilter.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 =========================================================================*/ 00055 #ifndef vtkConnectivityFilter_h 00056 #define vtkConnectivityFilter_h 00057 00058 #include "vtkFiltersCoreModule.h" // For export macro 00059 #include "vtkUnstructuredGridAlgorithm.h" 00060 00061 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1 00062 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2 00063 #define VTK_EXTRACT_SPECIFIED_REGIONS 3 00064 #define VTK_EXTRACT_LARGEST_REGION 4 00065 #define VTK_EXTRACT_ALL_REGIONS 5 00066 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6 00067 00068 class vtkDataArray; 00069 class vtkFloatArray; 00070 class vtkIdList; 00071 class vtkIdTypeArray; 00072 class vtkIntArray; 00073 00074 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkUnstructuredGridAlgorithm 00075 { 00076 public: 00077 vtkTypeMacro(vtkConnectivityFilter,vtkUnstructuredGridAlgorithm); 00078 void PrintSelf(ostream& os, vtkIndent indent); 00079 00081 static vtkConnectivityFilter *New(); 00082 00084 00087 vtkSetMacro(ScalarConnectivity,int); 00088 vtkGetMacro(ScalarConnectivity,int); 00089 vtkBooleanMacro(ScalarConnectivity,int); 00091 00093 00095 vtkSetVector2Macro(ScalarRange,double); 00096 vtkGetVector2Macro(ScalarRange,double); 00098 00100 00101 vtkSetClampMacro(ExtractionMode,int, 00102 VTK_EXTRACT_POINT_SEEDED_REGIONS,VTK_EXTRACT_CLOSEST_POINT_REGION); 00103 vtkGetMacro(ExtractionMode,int); 00104 void SetExtractionModeToPointSeededRegions() 00105 {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);}; 00106 void SetExtractionModeToCellSeededRegions() 00107 {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);}; 00108 void SetExtractionModeToLargestRegion() 00109 {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);}; 00110 void SetExtractionModeToSpecifiedRegions() 00111 {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);}; 00112 void SetExtractionModeToClosestPointRegion() 00113 {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);}; 00114 void SetExtractionModeToAllRegions() 00115 {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);}; 00116 const char *GetExtractionModeAsString(); 00118 00120 void InitializeSeedList(); 00121 00123 void AddSeed(vtkIdType id); 00124 00126 void DeleteSeed(vtkIdType id); 00127 00129 void InitializeSpecifiedRegionList(); 00130 00132 void AddSpecifiedRegion(int id); 00133 00135 void DeleteSpecifiedRegion(int id); 00136 00138 00140 vtkSetVector3Macro(ClosestPoint,double); 00141 vtkGetVectorMacro(ClosestPoint,double,3); 00143 00145 int GetNumberOfExtractedRegions(); 00146 00148 00149 vtkSetMacro(ColorRegions,int); 00150 vtkGetMacro(ColorRegions,int); 00151 vtkBooleanMacro(ColorRegions,int); 00153 00155 00158 vtkSetMacro(OutputPointsPrecision,int); 00159 vtkGetMacro(OutputPointsPrecision,int); 00161 00162 protected: 00163 vtkConnectivityFilter(); 00164 ~vtkConnectivityFilter(); 00165 00166 // Usual data generation method 00167 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00168 virtual int FillInputPortInformation(int port, vtkInformation *info); 00169 00170 int ColorRegions; //boolean turns on/off scalar gen for separate regions 00171 int ExtractionMode; //how to extract regions 00172 int OutputPointsPrecision; 00173 vtkIdList *Seeds; //id's of points or cells used to seed regions 00174 vtkIdList *SpecifiedRegionIds; //regions specified for extraction 00175 vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted 00176 00177 double ClosestPoint[3]; 00178 00179 int ScalarConnectivity; 00180 double ScalarRange[2]; 00181 00182 void TraverseAndMark(vtkDataSet *input); 00183 00184 private: 00185 // used to support algorithm execution 00186 vtkFloatArray *CellScalars; 00187 vtkIdList *NeighborCellPointIds; 00188 vtkIdType *Visited; 00189 vtkIdType *PointMap; 00190 vtkIdTypeArray *NewScalars; 00191 vtkIdTypeArray *NewCellScalars; 00192 vtkIdType RegionNumber; 00193 vtkIdType PointNumber; 00194 vtkIdType NumCellsInRegion; 00195 vtkDataArray *InScalars; 00196 vtkIdList *Wave; 00197 vtkIdList *Wave2; 00198 vtkIdList *PointIds; 00199 vtkIdList *CellIds; 00200 private: 00201 vtkConnectivityFilter(const vtkConnectivityFilter&); // Not implemented. 00202 void operator=(const vtkConnectivityFilter&); // Not implemented. 00203 }; 00204 00206 00207 inline const char *vtkConnectivityFilter::GetExtractionModeAsString(void) 00208 { 00209 if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS ) 00210 { 00211 return "ExtractPointSeededRegions"; 00212 } 00213 else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS ) 00214 { 00215 return "ExtractCellSeededRegions"; 00216 } 00217 else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS ) 00218 { 00219 return "ExtractSpecifiedRegions"; 00220 } 00221 else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS ) 00222 { 00223 return "ExtractAllRegions"; 00224 } 00225 else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION ) 00226 { 00227 return "ExtractClosestPointRegion"; 00228 } 00229 else 00230 { 00231 return "ExtractLargestRegion"; 00232 } 00233 } 00235 00236 #endif 00237 00238