1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| void Fastener::readName(std::string line){
// Remove eventual spaces in fastener name
for (size_t n = 0; n < line.size(); n++){
if(line[n] == ' '){
line.erase(n,1);
}
}
// Extraction of "Name" attributes
vector<string> infoName;
int curs1=0, curs2=0, lp=line.size()+1;
string sep("//"); // Select the separator in fastener name
while (curs2+ sep.size() != lp ){
curs2=line.find(sep, curs1);
if(curs2!=-1){
infoName.push_back(line.substr(curs1,curs2-curs1));
curs1 = curs2 + sep.size();
curs2 = curs1;
}
else {
infoName.push_back(line.substr(curs1));
curs2=lp;
}
}
if (infoName.size()==7){ // The name format is groupName_type_dF_standardBolt_standardNut_th1_th2
double currentdF = atof(infoName[2].c_str()); // atof function converts a string to a double
double currentth1 = atof(infoName[5].c_str());
double currentth2 = atof(infoName[6].c_str());
groupName = infoName[0];
type = infoName[1];
dF = currentdF;
standardBolt = infoName[3];
standardNut = infoName[4];
th1 = currentth1;
th2 = currentth2;
}
if (infoName.size()==9){ // The name format is groupName_type_dF_standardBolt_standardNut_th1_mat1_th2_mat2
double currentdF = atof(infoName[2].c_str());
double currentth1 = atof(infoName[5].c_str());
double currentth2 = atof(infoName[7].c_str());
groupName = infoName[0];
type = infoName[1];
dF = currentdF;
standardBolt = infoName[3];
standardNut = infoName[4];
th1 = currentth1;
mat1 = infoName[6];
th2 = currentth2;
mat2 = infoName[8];
}
if (infoName.size()==10)
{
double currentdF = atof(infoName[2].c_str()); // atof function converts a string to a double
double currentth1 = atof(infoName[5].c_str());
double currentth2 = atof(infoName[7].c_str());
groupName = infoName[0];
type = infoName[1];
dF= currentdF;
standardBolt = infoName[3];
standardNut = infoName[4];
th1= currentth1;
mat1 = infoName[6];
th2= currentth2;
mat2 = infoName[8];
if (infoName[9] == "Unsupported" || infoName[9] == "Supported")
{
SupportedOrUnsupported = infoName[9];
}
else
{
rivet= infoName[9];
SupportedOrUnsupported = "Unsupported";
}
}
if (infoName.size() == 11)
{
double currentdF = atof(infoName[2].c_str()); // atof function converts a string to a double
double currentth1 = atof(infoName[5].c_str());
double currentth2 = atof(infoName[7].c_str());
groupName = infoName[0];
type = infoName[1];
dF= currentdF;
standardBolt = infoName[3];
standardNut = infoName[4];
th1= currentth1;
mat1 = infoName[6];
th2= currentth2;
mat2 = infoName[8];
rivet= infoName[9];
SupportedOrUnsupported = infoName[10];
}
if ((infoName.size() != 7) && (infoName.size() != 9)&& (infoName.size() != 10)&& (infoName.size() != 11)) {
groupName = infoName[0]; // Extract groupName attribute if format name is incorrect (or whole name if there is no separator)
}
} |