1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: LSDynaMetaData.cxx
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 #include "LSDynaMetaData.h"
16
17 //------------------------------------------------------------------------------
LSDynaMetaData()18 LSDynaMetaData::LSDynaMetaData()
19 {
20 this->FileIsValid = 0;
21 this->Dimensionality = 0;
22 this->NumberOfNodes = 0;
23 this->FileSizeFactor = 7;
24 this->MaxFileLength = this->FileSizeFactor * 512 * 512 * 8;
25
26 this->Title[0] = '\0';
27 this->ReleaseNumber[0] = '\0';
28 this->CodeVersion = 0.0;
29 this->PreStateSize = 0;
30 this->StateSize = 0;
31 this->CurrentState = 0;
32 this->ElementDeletionOffset = 0;
33 this->SPHStateOffset = 0;
34
35 std::vector<std::string> blankNames;
36 std::vector<int> blankNumbers;
37 for (int cellType = 0; cellType < LSDynaMetaData::NUM_CELL_TYPES; ++cellType)
38 {
39 this->NumberOfCells[cellType] = 0;
40 this->CellArrayNames[cellType] = blankNames;
41 this->CellArrayComponents[cellType] = blankNumbers;
42 this->CellArrayStatus[cellType] = blankNumbers;
43 }
44 }
45
46 //------------------------------------------------------------------------------
AddPointArray(const std::string & name,int numComponents,int status)47 bool LSDynaMetaData::AddPointArray(const std::string& name, int numComponents, int status)
48 {
49 for (unsigned i = 0; i < this->PointArrayNames.size(); ++i)
50 {
51 if (this->PointArrayNames[i] == name)
52 {
53 return false;
54 }
55 }
56 this->PointArrayNames.push_back(name);
57 this->PointArrayComponents.push_back(numComponents);
58 this->PointArrayStatus.push_back(status);
59
60 return true;
61 }
62
63 //------------------------------------------------------------------------------
AddCellArray(int cellType,const std::string & name,int numComponents,int status)64 bool LSDynaMetaData::AddCellArray(
65 int cellType, const std::string& name, int numComponents, int status)
66 {
67 for (unsigned i = 0; i < this->CellArrayNames[cellType].size(); ++i)
68 {
69 if (this->CellArrayNames[cellType][i] == name)
70 {
71 return false;
72 }
73 }
74 this->CellArrayNames[cellType].push_back(name);
75 this->CellArrayComponents[cellType].push_back(numComponents);
76 this->CellArrayStatus[cellType].push_back(status);
77
78 return true;
79 }
80
81 //------------------------------------------------------------------------------
GetTotalMaterialCount()82 vtkIdType LSDynaMetaData::GetTotalMaterialCount()
83 {
84 return this->Dict["NUMMAT8"] + this->Dict["NUMMATT"] + this->Dict["NUMMAT4"] +
85 this->Dict["NUMMAT2"] + this->Dict["NGPSPH"] + this->Dict["NSURF"];
86 // Dict["NUMMAT"] is the subset of Dict["NUMMAT4"] materials that are rigid body materials
87 // FIXME: Should NSURF be in here at all? I don't have any datasets w/ NSURF > 0, so I can't test.
88 }
89
90 //------------------------------------------------------------------------------
Reset()91 void LSDynaMetaData::Reset()
92 {
93 this->FileIsValid = 0;
94 this->FileSizeFactor = 7;
95 this->MaxFileLength = this->FileSizeFactor * 512 * 512 * 8;
96
97 this->Title[0] = '\0';
98 this->ReleaseNumber[0] = '\0';
99 this->CodeVersion = 0.0;
100 this->PreStateSize = 0;
101 this->StateSize = 0;
102 this->CurrentState = 0;
103
104 this->Dict.clear();
105 this->Fam.Reset();
106
107 this->PointArrayNames.clear();
108 this->PointArrayComponents.clear();
109 this->PointArrayStatus.clear();
110
111 for (int cellType = 0; cellType < LSDynaMetaData::NUM_CELL_TYPES; ++cellType)
112 {
113 this->CellArrayNames[cellType].clear();
114 this->CellArrayComponents[cellType].clear();
115 this->CellArrayStatus[cellType].clear();
116 }
117
118 this->PartNames.clear();
119 this->PartIds.clear();
120 this->PartMaterials.clear();
121 this->PartStatus.clear();
122
123 this->MaterialsOrdered.clear();
124 this->MaterialsUnordered.clear();
125 this->MaterialsLookup.clear();
126
127 this->RigidSurfaceSegmentSizes.clear();
128 this->TimeValues.clear();
129 }
130