VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkLSDynaPart.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 __vtkLSDynaPart_h 00016 #define __vtkLSDynaPart_h 00017 00018 #include "vtkIOLSDynaModule.h" // For export macro 00019 #include "vtkObject.h" 00020 #include "LSDynaMetaData.h" //needed for lsdyna types 00021 #include "vtkStdString.h" //needed for string 00022 00023 class vtkUnstructuredGrid; 00024 class vtkPoints; 00025 00026 class VTKIOLSDYNA_EXPORT vtkLSDynaPart: public vtkObject 00027 { 00028 public: 00029 static vtkLSDynaPart *New(); 00030 00031 vtkTypeMacro(vtkLSDynaPart,vtkObject); 00032 virtual void PrintSelf(ostream &os, vtkIndent indent); 00033 00034 //Description: Set the type of the part 00035 void SetPartType(int type); 00036 00037 //Description: Returns the type of the part 00038 LSDynaMetaData::LSDYNA_TYPES PartType() const { return Type; } 00039 00040 //Description: Returns if the type of the part is considered valid 00041 bool hasValidType() const; 00042 00043 vtkIdType GetUserMaterialId() const { return UserMaterialId; } 00044 vtkIdType GetPartId() const { return PartId; } 00045 bool HasCells() const; 00046 00047 //Setup the part with some basic information about what it holds 00048 void InitPart(vtkStdString name, 00049 const vtkIdType& partId, 00050 const vtkIdType& userMaterialId, 00051 const vtkIdType& numGlobalPoints, 00052 const int& sizeOfWord); 00053 00054 //Reserves the needed space in memory for this part 00055 //that way we never over allocate memory 00056 void AllocateCellMemory(const vtkIdType& numCells, const vtkIdType& cellLen); 00057 00058 //Add a cell to the part 00059 void AddCell(const int& cellType, const vtkIdType& npts, vtkIdType conn[8]); 00060 00061 //Description: 00062 //Setups the part cell topology so that we can cache information 00063 //between timesteps. 00064 void BuildToplogy(); 00065 00066 //Description: 00067 //Returns if the toplogy for this part has been constructed 00068 bool IsTopologyBuilt() const { return TopologyBuilt; } 00069 00070 //Description: 00071 //Constructs the grid for this part and returns it. 00072 vtkUnstructuredGrid* GenerateGrid(); 00073 00074 //Description: 00075 //allows the part to store dead cells 00076 void EnableDeadCells(const int& deadCellsAsGhostArray); 00077 00078 //Description: 00079 //removes the dead cells array if it exists from the grid 00080 void DisableDeadCells(); 00081 00082 //Description: 00083 //We set cells as dead to make them not show up during rendering 00084 void SetCellsDeadState(unsigned char *dead, const vtkIdType &size); 00085 00086 //Description: 00087 //allows the part to store user cell ids 00088 void EnableCellUserIds(); 00089 00090 //Description: 00091 //Set the user ids for the cells of this grid 00092 void SetNextCellUserIds(const vtkIdType& value); 00093 00094 00095 //Description: 00096 //Called to init point filling for a property 00097 //is also able to set the point position of the grid too as that 00098 //is stored as a point property 00099 void AddPointProperty(const char* name, const vtkIdType& numComps, 00100 const bool& isIdTypeProperty, const bool &isProperty, 00101 const bool& isGeometryPoints); 00102 00103 //Description: 00104 //Given a chunk of point property memory copy it to the correct 00105 //property on the part 00106 void ReadPointBasedProperty(float *data, 00107 const vtkIdType& numTuples, 00108 const vtkIdType& numComps, 00109 const vtkIdType& currentGlobalPointIndex); 00110 00111 void ReadPointBasedProperty(double *data, 00112 const vtkIdType& numTuples, 00113 const vtkIdType& numComps, 00114 const vtkIdType& currentGlobalPointIndex); 00115 00116 //Description: 00117 //Adds a property to the part 00118 void AddCellProperty(const char* name, const int& offset, const int& numComps); 00119 00120 //Description: 00121 //Given the raw data converts it to be the properties for this part 00122 //The cell properties are woven together as a block for each cell 00123 void ReadCellProperties(float *cellProperties, const vtkIdType& numCells, 00124 const vtkIdType &numPropertiesInCell); 00125 void ReadCellProperties(double *cellsProperties, const vtkIdType& numCells, 00126 const vtkIdType &numPropertiesInCell); 00127 00128 //Description: 00129 //Get the id of the lowest global point this part needs 00130 //Note: Presumes topology has been built already 00131 vtkIdType GetMinGlobalPointId() const; 00132 00133 //Description: 00134 //Get the id of the largest global point this part needs 00135 //Note: Presumes topology has been built already 00136 vtkIdType GetMaxGlobalPointId() const; 00137 00138 protected: 00139 vtkLSDynaPart(); 00140 ~vtkLSDynaPart(); 00141 00142 vtkUnstructuredGrid* RemoveDeletedCells(); 00143 00144 void BuildUniquePoints(); 00145 void BuildCells(); 00146 00147 void GetPropertyData(const char* name, const vtkIdType &numComps, 00148 const bool &isIdTypeArray, const bool& isProperty, const bool& isGeometry); 00149 00150 template<typename T> 00151 void AddPointInformation(T *buffer,T *pointData, 00152 const vtkIdType& numTuples, 00153 const vtkIdType& numComps, 00154 const vtkIdType& currentGlobalPointIndex); 00155 00156 //basic info about the part 00157 LSDynaMetaData::LSDYNA_TYPES Type; 00158 vtkStdString Name; 00159 vtkIdType UserMaterialId; 00160 vtkIdType PartId; 00161 00162 vtkIdType NumberOfCells; 00163 vtkIdType NumberOfPoints; 00164 vtkIdType NumberOfGlobalPoints; 00165 00166 bool DeadCellsAsGhostArray; 00167 bool HasDeadCells; 00168 00169 bool TopologyBuilt; 00170 bool DoubleBased; 00171 00172 vtkUnstructuredGrid* Grid; 00173 vtkUnstructuredGrid* ThresholdGrid; 00174 00175 vtkPoints* Points; 00176 00177 class InternalCells; 00178 InternalCells *Cells; 00179 00180 class InternalCellProperties; 00181 InternalCellProperties *CellProperties; 00182 00183 class InternalPointsUsed; 00184 class DensePointsUsed; 00185 class SparsePointsUsed; 00186 InternalPointsUsed *GlobalPointsUsed; 00187 00188 //used when reading properties 00189 class InternalCurrentPointInfo; 00190 InternalCurrentPointInfo *CurrentPointPropInfo; 00191 00192 private: 00193 vtkLSDynaPart( const vtkLSDynaPart& ); // Not implemented. 00194 void operator = ( const vtkLSDynaPart& ); // Not implemented. 00195 }; 00196 00197 #endif // VTKLSDYNAPART