VTK
vtkLSDynaPart.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLSDynaPart.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 =========================================================================*/
14 
15 #ifndef vtkLSDynaPart_h
16 #define vtkLSDynaPart_h
17 #ifndef __VTK_WRAP__
18 
19 #include "vtkIOLSDynaModule.h" // For export macro
20 #include "vtkObject.h"
21 #include "LSDynaMetaData.h" //needed for lsdyna types
22 #include "vtkStdString.h" //needed for string
23 
25 class vtkPoints;
26 
27 class VTKIOLSDYNA_EXPORT vtkLSDynaPart: public vtkObject
28 {
29 public:
30  static vtkLSDynaPart *New();
31 
32  vtkTypeMacro(vtkLSDynaPart,vtkObject);
33  void PrintSelf(ostream &os, vtkIndent indent) override;
34 
35  //Description: Set the type of the part
36  void SetPartType(int type);
37 
38  //Description: Returns the type of the part
39  LSDynaMetaData::LSDYNA_TYPES PartType() const { return Type; }
40 
41  //Description: Returns if the type of the part is considered valid
42  bool hasValidType() const;
43 
44  vtkIdType GetUserMaterialId() const { return UserMaterialId; }
45  vtkIdType GetPartId() const { return PartId; }
46  bool HasCells() const;
47 
48  //Setup the part with some basic information about what it holds
49  void InitPart(vtkStdString name,
50  const vtkIdType& partId,
51  const vtkIdType& userMaterialId,
52  const vtkIdType& numGlobalPoints,
53  const int& sizeOfWord);
54 
55  //Reserves the needed space in memory for this part
56  //that way we never over allocate memory
57  void AllocateCellMemory(const vtkIdType& numCells, const vtkIdType& cellLen);
58 
59  //Add a cell to the part
60  void AddCell(const int& cellType, const vtkIdType& npts, vtkIdType conn[8]);
61 
62  //Description:
63  //Setups the part cell topology so that we can cache information
64  //between timesteps.
65  void BuildToplogy();
66 
67  //Description:
68  //Returns if the toplogy for this part has been constructed
69  bool IsTopologyBuilt() const { return TopologyBuilt; }
70 
71  //Description:
72  //Constructs the grid for this part and returns it.
73  vtkUnstructuredGrid* GenerateGrid();
74 
75  //Description:
76  //allows the part to store dead cells
77  void EnableDeadCells(const int& deadCellsAsGhostArray);
78 
79  //Description:
80  //removes the dead cells array if it exists from the grid
81  void DisableDeadCells();
82 
83  //Description:
84  //We set cells as dead to make them not show up during rendering
85  void SetCellsDeadState(unsigned char *dead, const vtkIdType &size);
86 
87  //Description:
88  //allows the part to store user cell ids
89  void EnableCellUserIds();
90 
91  //Description:
92  //Set the user ids for the cells of this grid
93  void SetNextCellUserIds(const vtkIdType& value);
94 
95 
96  //Description:
97  //Called to init point filling for a property
98  //is also able to set the point position of the grid too as that
99  //is stored as a point property
100  void AddPointProperty(const char* name, const vtkIdType& numComps,
101  const bool& isIdTypeProperty, const bool &isProperty,
102  const bool& isGeometryPoints);
103 
104  //Description:
105  //Given a chunk of point property memory copy it to the correct
106  //property on the part
107  void ReadPointBasedProperty(float *data,
108  const vtkIdType& numTuples,
109  const vtkIdType& numComps,
110  const vtkIdType& currentGlobalPointIndex);
111 
112  void ReadPointBasedProperty(double *data,
113  const vtkIdType& numTuples,
114  const vtkIdType& numComps,
115  const vtkIdType& currentGlobalPointIndex);
116 
117  //Description:
118  //Adds a property to the part
119  void AddCellProperty(const char* name, const int& offset, const int& numComps);
120 
121  //Description:
122  //Given the raw data converts it to be the properties for this part
123  //The cell properties are woven together as a block for each cell
124  void ReadCellProperties(float *cellProperties, const vtkIdType& numCells,
125  const vtkIdType &numPropertiesInCell);
126  void ReadCellProperties(double *cellsProperties, const vtkIdType& numCells,
127  const vtkIdType &numPropertiesInCell);
128 
129  //Description:
130  //Get the id of the lowest global point this part needs
131  //Note: Presumes topology has been built already
132  vtkIdType GetMinGlobalPointId() const;
133 
134  //Description:
135  //Get the id of the largest global point this part needs
136  //Note: Presumes topology has been built already
137  vtkIdType GetMaxGlobalPointId() const;
138 
139 protected:
140  vtkLSDynaPart();
141  ~vtkLSDynaPart() override;
142 
143  vtkUnstructuredGrid* RemoveDeletedCells();
144 
145  void BuildUniquePoints();
146  void BuildCells();
147 
148  void GetPropertyData(const char* name, const vtkIdType &numComps,
149  const bool &isIdTypeArray, const bool& isProperty, const bool& isGeometry);
150 
151  template<typename T>
152  void AddPointInformation(T *buffer,T *pointData,
153  const vtkIdType& numTuples,
154  const vtkIdType& numComps,
155  const vtkIdType& currentGlobalPointIndex);
156 
157  //basic info about the part
162 
166 
169 
172 
175 
177 
178  class InternalCells;
179  InternalCells *Cells;
180 
181  class InternalCellProperties;
182  InternalCellProperties *CellProperties;
183 
184  class InternalPointsUsed;
185  class DensePointsUsed;
186  class SparsePointsUsed;
187  InternalPointsUsed *GlobalPointsUsed;
188 
189  //used when reading properties
190  class InternalCurrentPointInfo;
191  InternalCurrentPointInfo *CurrentPointPropInfo;
192 
193 private:
194  vtkLSDynaPart( const vtkLSDynaPart& ) = delete;
195  void operator = ( const vtkLSDynaPart& ) = delete;
196 };
197 
198 #endif
199 #endif // VTKLSDYNAPART
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkStdString Name
vtkIdType GetUserMaterialId() const
Definition: vtkLSDynaPart.h:44
vtkIdType NumberOfPoints
int vtkIdType
Definition: vtkType.h:347
InternalCells * Cells
a simple class to control print indentation
Definition: vtkIndent.h:39
InternalCellProperties * CellProperties
bool DeadCellsAsGhostArray
dataset represents arbitrary combinations of all possible cell types
vtkUnstructuredGrid * Grid
LSDynaMetaData::LSDYNA_TYPES PartType() const
Definition: vtkLSDynaPart.h:39
InternalPointsUsed * GlobalPointsUsed
bool IsTopologyBuilt() const
Definition: vtkLSDynaPart.h:69
vtkIdType NumberOfCells
LSDYNA_TYPES
LS-Dyna cell types.
LSDynaMetaData::LSDYNA_TYPES Type
vtkIdType GetPartId() const
Definition: vtkLSDynaPart.h:45
vtkIdType PartId
InternalCurrentPointInfo * CurrentPointPropInfo
vtkIdType NumberOfGlobalPoints
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkPoints * Points
vtkIdType UserMaterialId
vtkUnstructuredGrid * ThresholdGrid
represent and manipulate 3D points
Definition: vtkPoints.h:39