VTK  9.3.1
vtkLSDynaPart.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkLSDynaPart_h
5 #define vtkLSDynaPart_h
6 
7 #include "LSDynaMetaData.h" //needed for lsdyna types
8 #include "vtkIOLSDynaModule.h" // For export macro
9 #include "vtkObject.h"
10 #include "vtkStdString.h" //needed for string
11 
12 VTK_ABI_NAMESPACE_BEGIN
14 class vtkPoints;
15 
16 class VTKIOLSDYNA_EXPORT vtkLSDynaPart : public vtkObject
17 {
18 public:
19  static vtkLSDynaPart* New();
20 
21  vtkTypeMacro(vtkLSDynaPart, vtkObject);
22  void PrintSelf(ostream& os, vtkIndent indent) override;
23 
24  // Description: Set the type of the part
25  void SetPartType(int type);
26 
27  // Description: Returns the type of the part
29 
30  // Description: Returns if the type of the part is considered valid
31  bool hasValidType() const;
32 
33  vtkIdType GetUserMaterialId() const { return UserMaterialId; }
34  vtkIdType GetPartId() const { return PartId; }
35  bool HasCells() const;
36 
37  // Setup the part with some basic information about what it holds
38  void InitPart(vtkStdString name, const vtkIdType& partId, const vtkIdType& userMaterialId,
39  const vtkIdType& numGlobalPoints, const int& sizeOfWord);
40 
41  // Reserves the needed space in memory for this part
42  // that way we never over allocate memory
43  void AllocateCellMemory(const vtkIdType& numCells, const vtkIdType& cellLen);
44 
45  // Add a cell to the part
46  void AddCell(const int& cellType, const vtkIdType& npts, vtkIdType conn[8]);
47 
48  // Description:
49  // Setups the part cell topology so that we can cache information
50  // between timesteps.
51  void BuildToplogy();
52 
53  // Description:
54  // Returns if the toplogy for this part has been constructed
55  bool IsTopologyBuilt() const { return TopologyBuilt; }
56 
57  // Description:
58  // Constructs the grid for this part and returns it.
59  vtkUnstructuredGrid* GenerateGrid();
60 
61  // Description:
62  // allows the part to store dead cells
63  void EnableDeadCells(const int& deadCellsAsGhostArray);
64 
65  // Description:
66  // removes the dead cells array if it exists from the grid
67  void DisableDeadCells();
68 
69  // Description:
70  // We set cells as dead to make them not show up during rendering
71  void SetCellsDeadState(unsigned char* dead, const vtkIdType& size);
72 
73  // Description:
74  // allows the part to store user cell ids
75  void EnableCellUserIds();
76 
77  // Description:
78  // Set the user ids for the cells of this grid
79  void SetNextCellUserIds(const vtkIdType& value);
80 
81  // Description:
82  // Called to init point filling for a property
83  // is also able to set the point position of the grid too as that
84  // is stored as a point property
85  void AddPointProperty(const char* name, const vtkIdType& numComps, const bool& isIdTypeProperty,
86  const bool& isProperty, const bool& isGeometryPoints);
87 
88  // Description:
89  // Given a chunk of point property memory copy it to the correct
90  // property on the part
91  void ReadPointBasedProperty(float* data, const vtkIdType& numTuples, const vtkIdType& numComps,
92  const vtkIdType& currentGlobalPointIndex);
93 
94  void ReadPointBasedProperty(double* data, const vtkIdType& numTuples, const vtkIdType& numComps,
95  const vtkIdType& currentGlobalPointIndex);
96 
97  // Description:
98  // Adds a property to the part
99  void AddCellProperty(const char* name, const int& offset, const int& numComps);
100 
101  // Description:
102  // Given the raw data converts it to be the properties for this part
103  // The cell properties are woven together as a block for each cell
104  void ReadCellProperties(
105  float* cellProperties, const vtkIdType& numCells, const vtkIdType& numPropertiesInCell);
106  void ReadCellProperties(
107  double* cellsProperties, const vtkIdType& numCells, const vtkIdType& numPropertiesInCell);
108 
109  // Description:
110  // Get the id of the lowest global point this part needs
111  // Note: Presumes topology has been built already
112  vtkIdType GetMinGlobalPointId() const;
113 
114  // Description:
115  // Get the id of the largest global point this part needs
116  // Note: Presumes topology has been built already
117  vtkIdType GetMaxGlobalPointId() const;
118 
119 protected:
120  vtkLSDynaPart();
121  ~vtkLSDynaPart() override;
122 
123  vtkUnstructuredGrid* RemoveDeletedCells();
124 
125  void BuildUniquePoints();
126  void BuildCells();
127 
128  void GetPropertyData(const char* name, const vtkIdType& numComps, const bool& isIdTypeArray,
129  const bool& isProperty, const bool& isGeometry);
130 
131  template <typename T>
132  void AddPointInformation(T* buffer, T* pointData, const vtkIdType& numTuples,
133  const vtkIdType& numComps, const vtkIdType& currentGlobalPointIndex);
134 
135  // basic info about the part
140 
144 
147 
150 
153 
155 
156  class InternalCells;
157  InternalCells* Cells;
158 
159  class InternalCellProperties;
160  InternalCellProperties* CellProperties;
161 
162  class InternalPointsUsed;
163  class DensePointsUsed;
164  class SparsePointsUsed;
165  InternalPointsUsed* GlobalPointsUsed;
166 
167  // used when reading properties
168  class InternalCurrentPointInfo;
169  InternalCurrentPointInfo* CurrentPointPropInfo;
170 
171 private:
172  vtkLSDynaPart(const vtkLSDynaPart&) = delete;
173  void operator=(const vtkLSDynaPart&) = delete;
174 };
175 
176 VTK_ABI_NAMESPACE_END
177 #endif // vtkLSDynaPart_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:33
vtkIdType NumberOfPoints
int vtkIdType
Definition: vtkType.h:315
InternalCells * Cells
a simple class to control print indentation
Definition: vtkIndent.h:28
InternalCellProperties * CellProperties
bool DeadCellsAsGhostArray
dataset represents arbitrary combinations of all possible cell types
vtkUnstructuredGrid * Grid
LSDynaMetaData::LSDYNA_TYPES PartType() const
Definition: vtkLSDynaPart.h:28
InternalPointsUsed * GlobalPointsUsed
bool IsTopologyBuilt() const
Definition: vtkLSDynaPart.h:55
vtkIdType NumberOfCells
LSDYNA_TYPES
LS-Dyna cell types.
LSDynaMetaData::LSDYNA_TYPES Type
vtkIdType GetPartId() const
Definition: vtkLSDynaPart.h:34
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:28