OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / SGI / util / SGI / include / graphics / vtkPolyDataConnectivityFilter.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkPolyDataConnectivityFilter.h,v $
5   Language:  C++
6   Date:      $Date: 2002/02/01 06:30:47 $
7   Version:   $Revision: 1.1.1.1 $
8
9
10 Copyright (c) 1993-1998 Ken Martin, Will Schroeder, Bill Lorensen.
11
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
17
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
27
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
38
39
40 =========================================================================*/
41 // .NAME vtkPolyDataConnectivityFilter - extract polygonal data based on geometric connectivity
42 // .SECTION Description
43 // vtkPolyDataConnectivityFilter is a filter that extracts cells that share common 
44 // points. The filter works in one of four ways: 1) extract the largest
45 // connected region in the dataset; 2) extract specified region numbers;
46 // 3) extract all regions sharing specified point ids; or 4) extract
47 // all regions sharing specified cell ids.
48 //
49 // This filter is specialized for polygonal data. This means it runs a bit 
50 // faster and is easier to construct visualization networks that process
51 // polygonal data.
52 //
53 // The behavior of vtkPolyDataConnectivityFilter can be modified by turning on the 
54 // boolean ivar ScalarConnectivity. If this flag is on, the connectivity
55 // algorithm is modified so that cells are considered connected only if 1) they 
56 // are geometrically connected (share a vertex) and 2) the scalar values of one
57 // of the cell's points falls in the scalar range specified. This use of
58 // ScalarConnectivity is particularly useful for volume datasets: it can be used
59 // as a simple "connected segmentation" algorithm. For example, by using a seed
60 // voxel (i.e., cell) on a known anatomical structure, connectivity will pull
61 // out all voxels "containing" the anatomical structure. These voxels can then
62 // be contoured or processed by other visualization filters.
63
64 // .SECTION See Also
65 // vtkConnectivityFilter
66
67 #ifndef __vtkPolyDataConnectivityFilter_h
68 #define __vtkPolyDataConnectivityFilter_h
69
70 #include "vtkPolyDataToPolyDataFilter.h"
71
72 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
73 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
74 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
75 #define VTK_EXTRACT_LARGEST_REGION 4
76 #define VTK_EXTRACT_ALL_REGIONS 5
77
78 class VTK_EXPORT vtkPolyDataConnectivityFilter : public vtkPolyDataToPolyDataFilter
79 {
80 public:
81   vtkPolyDataConnectivityFilter();
82   ~vtkPolyDataConnectivityFilter();
83   static vtkPolyDataConnectivityFilter *New() {return new vtkPolyDataConnectivityFilter;};
84   const char *GetClassName() {return "vtkPolyDataConnectivityFilter";};
85   void PrintSelf(ostream& os, vtkIndent indent);
86
87   // Description:
88   // Turn on/off connectivity based on scalar value. If on, cells are connected
89   // only if they share points AND one of the cells scalar values falls in the
90   // scalar range specified.
91   vtkSetMacro(ScalarConnectivity,int);
92   vtkGetMacro(ScalarConnectivity,int);
93   vtkBooleanMacro(ScalarConnectivity,int);
94
95   // Description:
96   // Set the scalar range to use to extract cells based on scalar connectivity.
97   vtkSetVectorMacro(ScalarRange,float,2);
98   vtkGetVectorMacro(ScalarRange,float,2);
99
100   // Description:
101   // Control the extraction of connected surfaces.
102   vtkSetClampMacro(ExtractionMode,int,
103                   VTK_EXTRACT_POINT_SEEDED_REGIONS,VTK_EXTRACT_ALL_REGIONS);
104   vtkGetMacro(ExtractionMode,int);
105   void SetExtractionModeToPointSeededRegions()
106     {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
107   void SetExtractionModeToCellSeededRegions()
108     {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
109   void SetExtractionModeToLargestRegion()
110     {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
111   void SetExtractionModeToSpecifiedRegions()
112     {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
113   void SetExtractionModeToAllRegions()
114     {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
115   char *GetExtractionModeAsString();
116
117   // Use with point or cell seeded extraction methods
118   void InitializeSeedList();
119   void AddSeed(int id);
120   void DeleteSeed(int id);
121
122   // Use with extract specified regions 
123   void InitializeSpecifiedRegionList();
124   void AddSpecifiedRegion(int id);
125   void DeleteSpecifiedRegion(int id);
126
127   int GetNumberOfExtractedRegions();
128
129   // Description:
130   // The connectivity extraction algorithm works recursively. In some systems 
131   // the stack depth is limited. This methods specifies the maximum recursion 
132   // depth.
133   vtkSetClampMacro(MaxRecursionDepth,int,10,VTK_LARGE_INTEGER);
134   vtkGetMacro(MaxRecursionDepth,int);
135
136   // Description:
137   // Turn on/off the coloring of connected regions.
138   vtkSetMacro(ColorRegions,int);
139   vtkGetMacro(ColorRegions,int);
140   vtkBooleanMacro(ColorRegions,int);
141
142 protected:
143   // Usual data generation method
144   void Execute();
145
146   int ColorRegions; //boolean turns on/off scalar gen for separate regions
147   int ExtractionMode; //how to extract regions
148   vtkIdList Seeds; //id's of points or cells used to seed regions
149   int MaxRecursionDepth; //prevent excessive recursion
150   vtkIdList SpecifiedRegionIds; //regions specified for extraction
151   vtkIntArray *RegionSizes; //size (in cells) of each region extracted
152
153   int ScalarConnectivity;
154   float ScalarRange[2];
155
156   void TraverseAndMark(int cellId);
157
158 private:
159   vtkScalars *CellScalars;
160   vtkIdList *NeighborCellPointIds;
161
162 };
163
164 // Description:
165 // Return the method of extraction as a string.
166 inline char *vtkPolyDataConnectivityFilter::GetExtractionModeAsString(void)
167 {
168   if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS ) 
169     {
170     return "ExtractPointSeededRegions";
171     }
172   else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS ) 
173     {
174     return "ExtractCellSeededRegions";
175     }
176   else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS ) 
177     {
178     return "ExtractSpecifiedRegions";
179     }
180   else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS ) 
181     {
182     return "ExtractAllRegions";
183     }
184   else 
185     {
186     return "ExtractLargestRegion";
187     }
188 }
189
190
191 #endif
192
193