MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadRigidBodyGeometryFile

Method ReadRigidBodyGeometryFile

IO/EnSight/core/EnSightDataSet.cxx:2987–3243  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2985
2986//------------------------------------------------------------------------------
2987bool EnSightDataSet::ReadRigidBodyGeometryFile()
2988{
2989 if (!this->RigidBodyFile.SetFileNamePattern(this->RigidBodyFileName, true))
2990 {
2991 vtkGenericWarningMacro("Rigid body file " << this->RigidBodyFileName << " could not be opened");
2992 return false;
2993 }
2994
2995 this->RigidBodyTransforms.clear();
2996 this->EulerTransformsMap.clear();
2997 this->UseEulerTimeSteps = false;
2998 this->EulerTimeSteps.clear();
2999
3000 auto result = this->RigidBodyFile.ReadNextLine();
3001 if (!result.first || result.second.find("EnSight Rigid Body") == std::string::npos)
3002 {
3003 vtkGenericWarningMacro("The first line " << result.second << " is not 'EnSight Rigid Body'.");
3004 return false;
3005 }
3006
3007 // read the version now
3008 result = this->RigidBodyFile.ReadNextLine();
3009 if (!result.first || result.second.find("version") == std::string::npos)
3010 {
3011 vtkGenericWarningMacro("The first line " << result.second << " is not 'EnSight Rigid Body'.");
3012 return false;
3013 }
3014
3015 float version;
3016 extractLinePart(GetNumRegEx(), result.second, version);
3017 if (version != 2.0)
3018 {
3019 vtkGenericWarningMacro("currently only version 2.0 of the rigid body format is supported.");
3020 return false;
3021 }
3022
3023 // read "names" or "numbers"
3024 result = this->RigidBodyFile.ReadNextLine();
3025 if (!result.first)
3026 {
3027 vtkGenericWarningMacro("There was an issue reading the names/numbers line");
3028 return false;
3029 }
3030 this->UsePartNamesRB = result.second.find("names") != std::string::npos;
3031
3032 int numParts;
3033 this->RigidBodyFile.ReadNumber(&numParts);
3034
3035 // read the number of following part names / part numbers
3036 result = this->RigidBodyFile.ReadNextLine(); // either a part name or number
3037 int idx = 0;
3038 while (result.first && idx < numParts)
3039 {
3040 // handle line which is either a part name or number
3041 int partId;
3042 std::string partName = result.second;
3043 sanitize(partName);
3044 if (!this->UsePartNamesRB)

Callers

nothing calls this directly

Calls 15

extractLinePartFunction · 0.85
SplitStringFunction · 0.85
extractFileNameFunction · 0.85
SetFileNamePatternMethod · 0.80
ReadNextLineMethod · 0.80
ReadNumberMethod · 0.80
backMethod · 0.80
RotateXMethod · 0.80
RotateYMethod · 0.80
RotateZMethod · 0.80

Tested by

no test coverage detected