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