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