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