Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Common/vtkCellTypes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002   Program:   Visualization Toolkit
00003   Module:    $RCSfile: vtkCellTypes.h,v $
00004   Language:  C++
00005 
00006 
00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00008 All rights reserved.
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013  * Redistributions of source code must retain the above copyright notice,
00014    this list of conditions and the following disclaimer.
00015 
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019 
00020  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00021    of any contributors may be used to endorse or promote products derived
00022    from this software without specific prior written permission.
00023 
00024  * Modified source versions must be plainly marked as such, and must not be
00025    misrepresented as being the original software.
00026 
00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00028 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00033 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00034 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00035 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 
00038 =========================================================================*/
00065 #ifndef __vtkCellTypes_h
00066 #define __vtkCellTypes_h
00067 
00068 #include "vtkObject.h"
00069 #include "vtkCellType.h"
00070 #include "vtkIntArray.h"
00071 #include "vtkUnsignedCharArray.h"
00072 
00073 
00074 class VTK_COMMON_EXPORT vtkCellTypes : public vtkObject 
00075 {
00076 public:
00077   static vtkCellTypes *New();
00078   vtkTypeMacro(vtkCellTypes,vtkObject);
00079 
00081   int Allocate(int sz=512, int ext=1000);
00082 
00084   void InsertCell(int id, unsigned char type, int loc);
00085   
00087   int InsertNextCell(unsigned char type, int loc);
00088 
00090   void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
00091 
00093   int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
00094 
00096   void DeleteCell(int cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
00097 
00099   int GetNumberOfTypes() { return (this->MaxId + 1);};
00100 
00102   int IsType(unsigned char type);
00103 
00106   int InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
00107   
00109   unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
00110 
00112   void Squeeze();
00113 
00115   void Reset();
00116 
00123   unsigned long GetActualMemorySize();
00124 
00127   void DeepCopy(vtkCellTypes *src);
00128 
00129 protected:
00130   vtkCellTypes();
00131   ~vtkCellTypes();
00132 
00133   vtkUnsignedCharArray *TypeArray; // pointer to types array
00134   vtkIntArray *LocationArray;   // pointer to array of offsets
00135   int Size;            // allocated size of data
00136   int MaxId;           // maximum index inserted thus far
00137   int Extend;          // grow array by this point
00138 private:
00139   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00140   void operator=(const vtkCellTypes&);    // Not implemented.
00141 };
00142 
00143 
00144 
00145 inline int vtkCellTypes::IsType(unsigned char type)
00146 {
00147   int numTypes=this->GetNumberOfTypes();
00148 
00149   for (int i=0; i<numTypes; i++)
00150     {
00151     if ( type == this->GetCellType(i))
00152       {
00153       return 1;
00154       }
00155     }
00156   return 0;
00157 }
00158 
00159 
00160 #endif

Generated on Thu Mar 28 14:19:14 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001