OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / ALPHALINUX5 / util / ALPHALINUX5 / include / vtk / vtkCellTypes.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkCellTypes.h,v $
5   Language:  C++
6   Date:      $Date: 2002/02/01 06:35:43 $
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 vtkCellTypes - object provides direct access to cells in vtkCellArray and type information
42 // .SECTION Description
43 // This class is a supplemental object to vtkCellArray to allow random
44 // access into cells as well as representing cell type information.  The
45 // "location" field is the location in the vtkCellArray list in terms of an
46 // integer offset.  An integer offset was used instead of a pointer for easy
47 // storage and inter-process communication. The type information is defined
48 // in the file vtkCellType.h.
49 // .SECTION Caveats 
50 // Sometimes this class is used to pass type information independent of the
51 // random access (i.e., location) information. For example, see
52 // vtkDataSet::GetCellTypes(). If you use the class in this way, you can use
53 // a location value of -1.
54 // .SECTION See Also 
55 // vtkCellArray vtkCellLinks
56
57 #ifndef __vtkCellTypes_h
58 #define __vtkCellTypes_h
59
60 #include "vtkReferenceCount.h"
61 #include "vtkCellType.h"
62
63 struct _vtkCell_s {
64     unsigned char type; //from CellType.h
65     int loc; //location in associated CellArray object
66 };
67
68 class VTK_EXPORT vtkCellTypes : public vtkReferenceCount 
69 {
70 public:
71   vtkCellTypes() : Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
72   vtkCellTypes(int sz, int ext);
73   ~vtkCellTypes();
74   static vtkCellTypes *New() {return new vtkCellTypes;};
75   int Allocate(int sz=512, int ext=1000);
76   const char *GetClassName() {return "vtkCellTypes";};
77
78   void InsertCell(int id, unsigned char type, int loc);
79   int InsertNextCell(unsigned char type, int loc);
80   void DeleteCell(int cellId);
81
82   //special operations to pass type information
83   int GetNumberOfTypes();
84   int IsType(unsigned char type);
85   int InsertNextType(unsigned char type);
86   unsigned char GetCellType(int id);
87
88   //special operations used for managing data location offsets
89   int GetCellLocation(int id);
90   _vtkCell_s &GetCell(int id);
91
92   void Squeeze();
93   void Reset();
94
95 private:
96   _vtkCell_s *Array;   // pointer to data
97   int Size;       // allocated size of data
98   int MaxId;     // maximum index inserted thus far
99   int Extend;     // grow array by this point
100   _vtkCell_s *Resize(int sz);  // function to resize data
101 };
102
103 // Description:
104 // Return a reference to a cell list structure.
105 inline _vtkCell_s &vtkCellTypes::GetCell(int id) 
106 {
107   return this->Array[id];
108 }
109
110 // Description:
111 // Return the type of cell.
112 inline unsigned char vtkCellTypes::GetCellType(int cellId) 
113 {
114   return this->Array[cellId].type;
115 }
116
117 // Description:
118 // Return the location of the cell in the associated vtkCellArray.
119 inline int vtkCellTypes::GetCellLocation(int cellId) 
120 {
121   return this->Array[cellId].loc;
122 }
123
124 // Description:
125 // Delete cell by setting to NULL cell type.
126 inline void vtkCellTypes::DeleteCell(int cellId)
127 {
128   this->Array[cellId].type = VTK_NULL_ELEMENT;
129 }
130
131 // Description:
132 // Return the number of types in the list.
133 inline int vtkCellTypes::GetNumberOfTypes() 
134 {
135   return (this->MaxId + 1);
136 }
137
138 // Description:
139 // Return 1 if type specified is contained in list; 0 otherwise.
140 inline int vtkCellTypes::IsType(unsigned char type)
141 {
142   int numTypes=this->GetNumberOfTypes();
143
144   for (int i=0; i<numTypes; i++) 
145     if ( type == this->GetCellType(i)) return 1;
146   return 0;
147 }
148
149 // Description:
150 // Add the type specified to the end of the list. Range checking is performed.
151 inline int vtkCellTypes::InsertNextType(unsigned char type) 
152 {
153   return this->InsertNextCell(type,-1);
154 }
155
156 #endif