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