VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkLSDynaPartCollection.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 00015 #ifndef __vtkLSDynaPartCollection_h 00016 #define __vtkLSDynaPartCollection_h 00017 00018 #include "vtkIOLSDynaModule.h" // For export macro 00019 #include "LSDynaMetaData.h" //needed for LSDynaMetaData::LSDYNA_TYPES enum 00020 #include "vtkObject.h" 00021 00022 class vtkDataArray; 00023 class vtkUnstructuredGrid; 00024 class vtkPoints; 00025 class vtkUnsignedCharArray; 00026 class vtkLSDynaPart; 00027 00028 class VTKIOLSDYNA_EXPORT vtkLSDynaPartCollection: public vtkObject 00029 { 00030 public: 00031 class LSDynaPart; 00032 static vtkLSDynaPartCollection *New(); 00033 00034 vtkTypeMacro(vtkLSDynaPartCollection,vtkObject); 00035 virtual void PrintSelf(ostream &os, vtkIndent indent); 00036 00037 //Description: 00038 //Pass in the metadata to setup this collection. 00039 //The optional min and max cell Id are used when in parallel to load balance the nodes. 00040 //Meaning the collection will only store subsections of parts that fall within 00041 //the range of the min and max 00042 //Note: min is included, and max is excluded from the valid range of cells. 00043 void InitCollection(LSDynaMetaData *metaData, 00044 vtkIdType* mins=NULL, vtkIdType* maxs=NULL); 00045 00046 00047 //Description: 00048 //For a given part type returns the number of cells to read and the number 00049 //of cells to skip first to not read 00050 void GetPartReadInfo(const int& partType, vtkIdType& numberOfCells, 00051 vtkIdType& numCellsToSkip,vtkIdType& numCellsToSkipEnd) const; 00052 00053 //Description: 00054 //Finalizes the cell topology by mapping the cells point indexes 00055 //to a relative number based on the cells this collection is storing 00056 void FinalizeTopology(); 00057 00058 00059 //Description: Register a cell of a given type and material index to the 00060 //correct part 00061 //NOTE: the cellIndex is relative to the collection. So in parallel 00062 //the cellIndex will be from 0 to MaxId-MinId 00063 void RegisterCellIndexToPart(const int& partType,const vtkIdType& matIdx, 00064 const vtkIdType& cellIndex,const vtkIdType& npts); 00065 00066 void InitCellInsertion(); 00067 00068 void AllocateParts(); 00069 00070 //Description: Insert a cell of a given type and material index to the 00071 //collection. 00072 //NOTE: the cellIndex is relative to the collection. So in parallel 00073 //the cellIndex will be from 0 to MaxId-MinId 00074 void InsertCell(const int& partType,const vtkIdType& matIdx, 00075 const int& cellType,const vtkIdType& npts, vtkIdType conn[8]); 00076 00077 //Description: 00078 //Set for each part type what cells are deleted/dead 00079 void SetCellDeadFlags(const int& partType, vtkUnsignedCharArray *death, 00080 const int& deadCellsAsGhostArray); 00081 00082 bool IsActivePart(const int& id) const; 00083 00084 //Description: 00085 //Given a part will return the unstructured grid for the part. 00086 //Note: You must call finalize before using this method 00087 vtkUnstructuredGrid* GetGridForPart(const int& index) const; 00088 00089 int GetNumberOfParts() const; 00090 00091 void DisbleDeadCells(); 00092 00093 //Description: 00094 void ReadPointUserIds(const vtkIdType& numTuples,const char* name); 00095 00096 //Description: 00097 void ReadPointProperty( 00098 const vtkIdType& numTuples, 00099 const vtkIdType& numComps, 00100 const char* name, 00101 const bool &isProperty=true, 00102 const bool& isGeometryPoints=false, 00103 const bool& isRoadPoints=false); 00104 00105 00106 00107 //Description: 00108 //Adds a property for all parts of a certain type 00109 void AddProperty(const LSDynaMetaData::LSDYNA_TYPES& type, const char* name, 00110 const int& offset, const int& numComps); 00111 void FillCellProperties(float *buffer,const LSDynaMetaData::LSDYNA_TYPES& type, 00112 const vtkIdType& startId, const vtkIdType& numCells, 00113 const int& numPropertiesInCell); 00114 void FillCellProperties(double *buffer,const LSDynaMetaData::LSDYNA_TYPES& type, 00115 const vtkIdType& startId, const vtkIdType& numCells, 00116 const int& numPropertiesInCell); 00117 00118 //Description: 00119 //Adds User Ids for all parts of a certain type 00120 void ReadCellUserIds( 00121 const LSDynaMetaData::LSDYNA_TYPES& type, const int& status); 00122 00123 template<typename T> 00124 void FillCellUserId(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type, 00125 const vtkIdType& startId, const vtkIdType& numCells) 00126 { 00127 this->FillCellUserIdArray(buffer,type,startId,numCells); 00128 } 00129 00130 protected: 00131 vtkLSDynaPartCollection(); 00132 ~vtkLSDynaPartCollection(); 00133 00134 vtkIdType* MinIds; 00135 vtkIdType* MaxIds; 00136 00137 //Builds up the basic meta information needed for topology storage 00138 void BuildPartInfo(); 00139 00140 //Description: 00141 //Breaks down the buffer of cell properties to the cell properties we 00142 //are interested in. This will remove all properties that aren't active or 00143 //for parts we are not loading 00144 template<typename T> 00145 void FillCellArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type, 00146 const vtkIdType& startId, vtkIdType numCells, const int& numTuples); 00147 00148 template<typename T> 00149 void FillCellUserIdArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type, 00150 const vtkIdType& startId, vtkIdType numCells); 00151 00152 //Description: 00153 //Methods for adding points to the collection 00154 void SetupPointPropertyForReading( 00155 const vtkIdType& numTuples, 00156 const vtkIdType& numComps, 00157 const char* name, 00158 const bool& isIdType, 00159 const bool& isProperty, 00160 const bool& isGeometryPoints, 00161 const bool& isRoadPoints); 00162 template<typename T> 00163 void FillPointProperty(const vtkIdType& numTuples, 00164 const vtkIdType& numComps, 00165 vtkLSDynaPart** parts, const vtkIdType numParts); 00166 00167 private: 00168 vtkLSDynaPartCollection( const vtkLSDynaPartCollection& ); // Not implemented. 00169 void operator = ( const vtkLSDynaPartCollection& ); // Not implemented. 00170 00171 LSDynaMetaData *MetaData; 00172 00173 class LSDynaPartStorage; 00174 LSDynaPartStorage* Storage; 00175 }; 00176 00177 00178 00179 #endif // LSDYNAPARTS_H