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