VTK
vtkLSDynaPartCollection.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLSDynaPartCollection.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 vtkLSDynaPartCollection_h
16 #define vtkLSDynaPartCollection_h
17 
18 #include "vtkIOLSDynaModule.h" // For export macro
19 #include "LSDynaMetaData.h" //needed for LSDynaMetaData::LSDYNA_TYPES enum
20 #include "vtkObject.h"
21 
22 class vtkDataArray;
24 class vtkPoints;
26 class vtkLSDynaPart;
27 
29 {
30 public:
31  class LSDynaPart;
32  static vtkLSDynaPartCollection *New();
33 
35  virtual void PrintSelf(ostream &os, vtkIndent indent);
36 
37  //Description:
38  //Pass in the metadata to setup this collection.
39  //The optional min and max cell Id are used when in parallel to load balance the nodes.
40  //Meaning the collection will only store subsections of parts that fall within
41  //the range of the min and max
42  //Note: min is included, and max is excluded from the valid range of cells.
43  void InitCollection(LSDynaMetaData *metaData,
44  vtkIdType* mins=NULL, vtkIdType* maxs=NULL);
45 
46 
47  //Description:
48  //For a given part type returns the number of cells to read and the number
49  //of cells to skip first to not read
50  void GetPartReadInfo(const int& partType, vtkIdType& numberOfCells,
51  vtkIdType& numCellsToSkip,vtkIdType& numCellsToSkipEnd) const;
52 
53  //Description:
54  //Finalizes the cell topology by mapping the cells point indexes
55  //to a relative number based on the cells this collection is storing
56  void FinalizeTopology();
57 
58 
59  //Description: Register a cell of a given type and material index to the
60  //correct part
61  //NOTE: the cellIndex is relative to the collection. So in parallel
62  //the cellIndex will be from 0 to MaxId-MinId
63  void RegisterCellIndexToPart(const int& partType,const vtkIdType& matIdx,
64  const vtkIdType& cellIndex,const vtkIdType& npts);
65 
66  void InitCellInsertion();
67 
68  void AllocateParts();
69 
70  //Description: Insert a cell of a given type and material index to the
71  //collection.
72  //NOTE: the cellIndex is relative to the collection. So in parallel
73  //the cellIndex will be from 0 to MaxId-MinId
74  void InsertCell(const int& partType,const vtkIdType& matIdx,
75  const int& cellType,const vtkIdType& npts, vtkIdType conn[8]);
76 
77  //Description:
78  //Set for each part type what cells are deleted/dead
79  void SetCellDeadFlags(const int& partType, vtkUnsignedCharArray *death,
80  const int& deadCellsAsGhostArray);
81 
82  bool IsActivePart(const int& id) const;
83 
84  //Description:
85  //Given a part will return the unstructured grid for the part.
86  //Note: You must call finalize before using this method
87  vtkUnstructuredGrid* GetGridForPart(const int& index) const;
88 
89  int GetNumberOfParts() const;
90 
91  void DisbleDeadCells();
92 
93  //Description:
94  void ReadPointUserIds(const vtkIdType& numTuples,const char* name);
95 
96  //Description:
97  void ReadPointProperty(
98  const vtkIdType& numTuples,
99  const vtkIdType& numComps,
100  const char* name,
101  const bool &isProperty=true,
102  const bool& isGeometryPoints=false,
103  const bool& isRoadPoints=false);
104 
105 
106 
107  //Description:
108  //Adds a property for all parts of a certain type
109  void AddProperty(const LSDynaMetaData::LSDYNA_TYPES& type, const char* name,
110  const int& offset, const int& numComps);
111  void FillCellProperties(float *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
112  const vtkIdType& startId, const vtkIdType& numCells,
113  const int& numPropertiesInCell);
114  void FillCellProperties(double *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
115  const vtkIdType& startId, const vtkIdType& numCells,
116  const int& numPropertiesInCell);
117 
118  //Description:
119  //Adds User Ids for all parts of a certain type
120  void ReadCellUserIds(
121  const LSDynaMetaData::LSDYNA_TYPES& type, const int& status);
122 
123  template<typename T>
124  void FillCellUserId(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
125  const vtkIdType& startId, const vtkIdType& numCells)
126  {
127  this->FillCellUserIdArray(buffer,type,startId,numCells);
128  }
129 
130 protected:
133 
136 
137  //Builds up the basic meta information needed for topology storage
138  void BuildPartInfo();
139 
140  //Description:
141  //Breaks down the buffer of cell properties to the cell properties we
142  //are interested in. This will remove all properties that aren't active or
143  //for parts we are not loading
144  template<typename T>
145  void FillCellArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
146  const vtkIdType& startId, vtkIdType numCells, const int& numTuples);
147 
148  template<typename T>
149  void FillCellUserIdArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
150  const vtkIdType& startId, vtkIdType numCells);
151 
152  //Description:
153  //Methods for adding points to the collection
154  void SetupPointPropertyForReading(
155  const vtkIdType& numTuples,
156  const vtkIdType& numComps,
157  const char* name,
158  const bool& isIdType,
159  const bool& isProperty,
160  const bool& isGeometryPoints,
161  const bool& isRoadPoints);
162  template<typename T>
163  void FillPointProperty(const vtkIdType& numTuples,
164  const vtkIdType& numComps,
165  vtkLSDynaPart** parts, const vtkIdType numParts);
166 
167 private:
168  vtkLSDynaPartCollection( const vtkLSDynaPartCollection& ); // Not implemented.
169  void operator = ( const vtkLSDynaPartCollection& ); // Not implemented.
170 
171  LSDynaMetaData *MetaData;
172 
173  class LSDynaPartStorage;
174  LSDynaPartStorage* Storage;
175 };
176 
177 
178 
179 #endif // LSDYNAPARTS_H
abstract base class for most VTK objects
Definition: vtkObject.h:61
int vtkIdType
Definition: vtkType.h:275
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
dynamic, self-adjusting array of unsigned char
CellTypeInDataSet cellType(vtkDataSet *input)
#define VTKIOLSDYNA_EXPORT
void FillCellUserId(T *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, const vtkIdType &numCells)
static vtkObject * New()
represent and manipulate 3D points
Definition: vtkPoints.h:38