VTK
dox/Filters/Core/vtkPolyDataConnectivityFilter.h
Go to the documentation of this file.
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 =========================================================================*/
00052 #ifndef __vtkPolyDataConnectivityFilter_h
00053 #define __vtkPolyDataConnectivityFilter_h
00054 
00055 #include "vtkFiltersCoreModule.h" // For export macro
00056 #include "vtkPolyDataAlgorithm.h"
00057 
00058 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
00059 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
00060 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
00061 #define VTK_EXTRACT_LARGEST_REGION 4
00062 #define VTK_EXTRACT_ALL_REGIONS 5
00063 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
00064 
00065 class vtkDataArray;
00066 class vtkIdList;
00067 class vtkIdTypeArray;
00068 
00069 class VTKFILTERSCORE_EXPORT vtkPolyDataConnectivityFilter : public vtkPolyDataAlgorithm
00070 {
00071 public:
00072   vtkTypeMacro(vtkPolyDataConnectivityFilter,vtkPolyDataAlgorithm);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00076 
00077   vtkGetObjectMacro(RegionSizes,vtkIdTypeArray);
00079 
00081   static vtkPolyDataConnectivityFilter *New();
00082 
00084 
00087   vtkSetMacro(ScalarConnectivity,int);
00088   vtkGetMacro(ScalarConnectivity,int);
00089   vtkBooleanMacro(ScalarConnectivity,int);
00091 
00093 
00100   vtkSetMacro(FullScalarConnectivity,int);
00101   vtkGetMacro(FullScalarConnectivity,int);
00102   vtkBooleanMacro(FullScalarConnectivity,int);
00104 
00106 
00108   vtkSetVector2Macro(ScalarRange,double);
00109   vtkGetVector2Macro(ScalarRange,double);
00111 
00113 
00114   vtkSetClampMacro(ExtractionMode,int,
00115                    VTK_EXTRACT_POINT_SEEDED_REGIONS,
00116                    VTK_EXTRACT_CLOSEST_POINT_REGION);
00117   vtkGetMacro(ExtractionMode,int);
00118   void SetExtractionModeToPointSeededRegions()
00119     {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
00120   void SetExtractionModeToCellSeededRegions()
00121     {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
00122   void SetExtractionModeToLargestRegion()
00123     {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
00124   void SetExtractionModeToSpecifiedRegions()
00125     {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
00126   void SetExtractionModeToClosestPointRegion()
00127     {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
00128   void SetExtractionModeToAllRegions()
00129     {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
00130   const char *GetExtractionModeAsString();
00132 
00134   void InitializeSeedList();
00135 
00137   void AddSeed(int id);
00138 
00140   void DeleteSeed(int id);
00141 
00143   void InitializeSpecifiedRegionList();
00144 
00146   void AddSpecifiedRegion(int id);
00147 
00149   void DeleteSpecifiedRegion(int id);
00150 
00152 
00154   vtkSetVector3Macro(ClosestPoint,double);
00155   vtkGetVectorMacro(ClosestPoint,double,3);
00157 
00159   int GetNumberOfExtractedRegions();
00160 
00162 
00163   vtkSetMacro(ColorRegions,int);
00164   vtkGetMacro(ColorRegions,int);
00165   vtkBooleanMacro(ColorRegions,int);
00167 
00169 
00171   vtkSetMacro( MarkVisitedPointIds, int );
00172   vtkGetMacro( MarkVisitedPointIds, int );
00173   vtkBooleanMacro( MarkVisitedPointIds, int );
00175 
00177 
00179   vtkGetObjectMacro( VisitedPointIds, vtkIdList );
00181 
00182 protected:
00183   vtkPolyDataConnectivityFilter();
00184   ~vtkPolyDataConnectivityFilter();
00185 
00186   // Usual data generation method
00187   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00188 
00189   int ColorRegions; //boolean turns on/off scalar gen for separate regions
00190   int ExtractionMode; //how to extract regions
00191   vtkIdList *Seeds; //id's of points or cells used to seed regions
00192   vtkIdList *SpecifiedRegionIds; //regions specified for extraction
00193   vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
00194 
00195   double ClosestPoint[3];
00196 
00197   int ScalarConnectivity;
00198   int FullScalarConnectivity;
00199 
00200   // Does this cell qualify as being scalar connected ?
00201   int IsScalarConnected( vtkIdType cellId );
00202 
00203   double ScalarRange[2];
00204 
00205   void TraverseAndMark();
00206 
00207   // used to support algorithm execution
00208   vtkDataArray *CellScalars;
00209   vtkIdList *NeighborCellPointIds;
00210   vtkIdType *Visited;
00211   vtkIdType *PointMap;
00212   vtkDataArray *NewScalars;
00213   vtkIdType RegionNumber;
00214   vtkIdType PointNumber;
00215   vtkIdType NumCellsInRegion;
00216   vtkDataArray *InScalars;
00217   vtkPolyData *Mesh;
00218   vtkIdList *Wave;
00219   vtkIdList *Wave2;
00220   vtkIdList *PointIds;
00221   vtkIdList *CellIds;
00222   vtkIdList *VisitedPointIds;
00223 
00224   int MarkVisitedPointIds;
00225 
00226 private:
00227   vtkPolyDataConnectivityFilter(const vtkPolyDataConnectivityFilter&);  // Not implemented.
00228   void operator=(const vtkPolyDataConnectivityFilter&);  // Not implemented.
00229 };
00230 
00232 
00233 inline const char *vtkPolyDataConnectivityFilter::GetExtractionModeAsString(void)
00234 {
00235   if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS )
00236     {
00237     return "ExtractPointSeededRegions";
00238     }
00239   else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS )
00240     {
00241     return "ExtractCellSeededRegions";
00242     }
00243   else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
00244     {
00245     return "ExtractSpecifiedRegions";
00246     }
00247   else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
00248     {
00249     return "ExtractAllRegions";
00250     }
00251   else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION )
00252     {
00253     return "ExtractClosestPointRegion";
00254     }
00255   else
00256     {
00257     return "ExtractLargestRegion";
00258     }
00259 }
00261 
00262 
00263 #endif