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 "vtkUnstructuredGridAlgorithm.h" 00059 00060 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1 00061 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2 00062 #define VTK_EXTRACT_SPECIFIED_REGIONS 3 00063 #define VTK_EXTRACT_LARGEST_REGION 4 00064 #define VTK_EXTRACT_ALL_REGIONS 5 00065 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6 00066 00067 class vtkDataArray; 00068 class vtkFloatArray; 00069 class vtkIdList; 00070 class vtkIdTypeArray; 00071 class vtkIntArray; 00072 00073 class VTK_GRAPHICS_EXPORT vtkConnectivityFilter : public vtkUnstructuredGridAlgorithm 00074 { 00075 public: 00076 vtkTypeMacro(vtkConnectivityFilter,vtkUnstructuredGridAlgorithm); 00077 void PrintSelf(ostream& os, vtkIndent indent); 00078 00080 static vtkConnectivityFilter *New(); 00081 00083 00086 vtkSetMacro(ScalarConnectivity,int); 00087 vtkGetMacro(ScalarConnectivity,int); 00088 vtkBooleanMacro(ScalarConnectivity,int); 00090 00092 00094 vtkSetVector2Macro(ScalarRange,double); 00095 vtkGetVector2Macro(ScalarRange,double); 00097 00099 00100 vtkSetClampMacro(ExtractionMode,int, 00101 VTK_EXTRACT_POINT_SEEDED_REGIONS,VTK_EXTRACT_CLOSEST_POINT_REGION); 00102 vtkGetMacro(ExtractionMode,int); 00103 void SetExtractionModeToPointSeededRegions() 00104 {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);}; 00105 void SetExtractionModeToCellSeededRegions() 00106 {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);}; 00107 void SetExtractionModeToLargestRegion() 00108 {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);}; 00109 void SetExtractionModeToSpecifiedRegions() 00110 {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);}; 00111 void SetExtractionModeToClosestPointRegion() 00112 {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);}; 00113 void SetExtractionModeToAllRegions() 00114 {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);}; 00115 const char *GetExtractionModeAsString(); 00117 00119 void InitializeSeedList(); 00120 00122 void AddSeed(vtkIdType id); 00123 00125 void DeleteSeed(vtkIdType id); 00126 00128 void InitializeSpecifiedRegionList(); 00129 00131 void AddSpecifiedRegion(int id); 00132 00134 void DeleteSpecifiedRegion(int id); 00135 00137 00139 vtkSetVector3Macro(ClosestPoint,double); 00140 vtkGetVectorMacro(ClosestPoint,double,3); 00142 00144 int GetNumberOfExtractedRegions(); 00145 00147 00148 vtkSetMacro(ColorRegions,int); 00149 vtkGetMacro(ColorRegions,int); 00150 vtkBooleanMacro(ColorRegions,int); 00152 00153 protected: 00154 vtkConnectivityFilter(); 00155 ~vtkConnectivityFilter(); 00156 00157 // Usual data generation method 00158 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00159 virtual int FillInputPortInformation(int port, vtkInformation *info); 00160 00161 int ColorRegions; //boolean turns on/off scalar gen for separate regions 00162 int ExtractionMode; //how to extract regions 00163 vtkIdList *Seeds; //id's of points or cells used to seed regions 00164 vtkIdList *SpecifiedRegionIds; //regions specified for extraction 00165 vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted 00166 00167 double ClosestPoint[3]; 00168 00169 int ScalarConnectivity; 00170 double ScalarRange[2]; 00171 00172 void TraverseAndMark(vtkDataSet *input); 00173 00174 private: 00175 // used to support algorithm execution 00176 vtkFloatArray *CellScalars; 00177 vtkIdList *NeighborCellPointIds; 00178 vtkIdType *Visited; 00179 vtkIdType *PointMap; 00180 vtkIdTypeArray *NewScalars; 00181 vtkIdTypeArray *NewCellScalars; 00182 vtkIdType RegionNumber; 00183 vtkIdType PointNumber; 00184 vtkIdType NumCellsInRegion; 00185 vtkDataArray *InScalars; 00186 vtkIdList *Wave; 00187 vtkIdList *Wave2; 00188 vtkIdList *PointIds; 00189 vtkIdList *CellIds; 00190 private: 00191 vtkConnectivityFilter(const vtkConnectivityFilter&); // Not implemented. 00192 void operator=(const vtkConnectivityFilter&); // Not implemented. 00193 }; 00194 00196 00197 inline const char *vtkConnectivityFilter::GetExtractionModeAsString(void) 00198 { 00199 if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS ) 00200 { 00201 return "ExtractPointSeededRegions"; 00202 } 00203 else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS ) 00204 { 00205 return "ExtractCellSeededRegions"; 00206 } 00207 else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS ) 00208 { 00209 return "ExtractSpecifiedRegions"; 00210 } 00211 else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS ) 00212 { 00213 return "ExtractAllRegions"; 00214 } 00215 else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION ) 00216 { 00217 return "ExtractClosestPointRegion"; 00218 } 00219 else 00220 { 00221 return "ExtractLargestRegion"; 00222 } 00223 } 00225 00226 #endif 00227 00228