VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkCPExodusIIElementBlock.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 =========================================================================*/ 00026 #ifndef vtkCPExodusIIElementBlock_h 00027 #define vtkCPExodusIIElementBlock_h 00028 00029 #include "vtkObject.h" 00030 #include "vtkIOExodusModule.h" // For export macro 00031 00032 #include "vtkMappedUnstructuredGrid.h" // For mapped unstructured grid wrapper 00033 00034 #include <string> // For std::string 00035 00036 class vtkGenericCell; 00037 00038 class VTKIOEXODUS_EXPORT vtkCPExodusIIElementBlockImpl : public vtkObject 00039 { 00040 public: 00041 static vtkCPExodusIIElementBlockImpl *New(); 00042 virtual void PrintSelf(ostream &os, vtkIndent indent); 00043 vtkTypeMacro(vtkCPExodusIIElementBlockImpl, vtkObject) 00044 00045 //@{ 00052 bool SetExodusConnectivityArray(int *elements, const std::string &type, 00053 int numElements, int nodesPerElement); 00055 00056 // API for vtkMappedUnstructuredGrid's implementation. 00057 vtkIdType GetNumberOfCells(); 00058 int GetCellType(vtkIdType cellId); 00059 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds); 00060 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds); 00061 int GetMaxCellSize(); 00062 void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array); 00063 int IsHomogeneous(); 00064 00065 // This container is read only -- these methods do nothing but print a 00066 // warning. 00067 void Allocate(vtkIdType numCells, int extSize = 1000); 00068 vtkIdType InsertNextCell(int type, vtkIdList *ptIds); 00069 vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds); 00070 vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, 00071 vtkIdType nfaces, vtkIdType *faces); 00072 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts); 00073 00074 protected: 00075 vtkCPExodusIIElementBlockImpl(); 00076 ~vtkCPExodusIIElementBlockImpl(); 00077 00078 private: 00079 vtkCPExodusIIElementBlockImpl(const vtkCPExodusIIElementBlockImpl &); // Not implemented. 00080 void operator=(const vtkCPExodusIIElementBlockImpl &); // Not implemented. 00081 00082 // Convert between Exodus node ids and VTK point ids. 00083 static vtkIdType NodeToPoint(const int &id) 00084 { 00085 return static_cast<vtkIdType>(id - 1); 00086 } 00087 static int PointToNode(const vtkIdType &id) 00088 { 00089 return static_cast<int>(id + 1); 00090 } 00091 00092 // Convenience methods to get pointers into the element array. 00093 int* GetElementStart(vtkIdType cellId) const 00094 { 00095 return this->Elements + (cellId * this->CellSize); 00096 } 00097 int* GetElementEnd(vtkIdType cellId) const 00098 { 00099 return this->Elements + (cellId * this->CellSize) + this->CellSize; 00100 } 00101 int* GetStart() const { return this->Elements; } 00102 int* GetEnd() const 00103 { 00104 return this->Elements + (this->NumberOfCells * this->CellSize); 00105 } 00106 00107 int *Elements; 00108 int CellType; 00109 int CellSize; 00110 vtkIdType NumberOfCells; 00111 }; 00112 00113 vtkMakeExportedMappedUnstructuredGrid(vtkCPExodusIIElementBlock, 00114 vtkCPExodusIIElementBlockImpl, 00115 VTKIOEXODUS_EXPORT) 00116 00117 #endif //vtkCPExodusIIElementBlock_h