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 00154 protected: 00155 vtkConnectivityFilter(); 00156 ~vtkConnectivityFilter(); 00157 00158 // Usual data generation method 00159 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00160 virtual int FillInputPortInformation(int port, vtkInformation *info); 00161 00162 int ColorRegions; //boolean turns on/off scalar gen for separate regions 00163 int ExtractionMode; //how to extract regions 00164 vtkIdList *Seeds; //id's of points or cells used to seed regions 00165 vtkIdList *SpecifiedRegionIds; //regions specified for extraction 00166 vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted 00167 00168 double ClosestPoint[3]; 00169 00170 int ScalarConnectivity; 00171 double ScalarRange[2]; 00172 00173 void TraverseAndMark(vtkDataSet *input); 00174 00175 private: 00176 // used to support algorithm execution 00177 vtkFloatArray *CellScalars; 00178 vtkIdList *NeighborCellPointIds; 00179 vtkIdType *Visited; 00180 vtkIdType *PointMap; 00181 vtkIdTypeArray *NewScalars; 00182 vtkIdTypeArray *NewCellScalars; 00183 vtkIdType RegionNumber; 00184 vtkIdType PointNumber; 00185 vtkIdType NumCellsInRegion; 00186 vtkDataArray *InScalars; 00187 vtkIdList *Wave; 00188 vtkIdList *Wave2; 00189 vtkIdList *PointIds; 00190 vtkIdList *CellIds; 00191 private: 00192 vtkConnectivityFilter(const vtkConnectivityFilter&); // Not implemented. 00193 void operator=(const vtkConnectivityFilter&); // Not implemented. 00194 }; 00195 00197 00198 inline const char *vtkConnectivityFilter::GetExtractionModeAsString(void) 00199 { 00200 if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS ) 00201 { 00202 return "ExtractPointSeededRegions"; 00203 } 00204 else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS ) 00205 { 00206 return "ExtractCellSeededRegions"; 00207 } 00208 else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS ) 00209 { 00210 return "ExtractSpecifiedRegions"; 00211 } 00212 else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS ) 00213 { 00214 return "ExtractAllRegions"; 00215 } 00216 else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION ) 00217 { 00218 return "ExtractClosestPointRegion"; 00219 } 00220 else 00221 { 00222 return "ExtractLargestRegion"; 00223 } 00224 } 00226 00227 #endif 00228 00229