File size: 2,490 Bytes
5a600cf | 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 | transformer transforms;
{
List<Tuple2<wordRe, label>> simpleTransformations;
List<Tuple3<word, string, label>> transformations;
dictArgList
(
{transformationString, 0},
simpleTransformations,
transformations
);
forAll(transformations, i)
{
if (transformations[i].first() == "translate")
{
const vector v(IStringStream(transformations[i].second())());
transforms = transformer::translation(v) & transforms;
}
else if (transformations[i].first() == "rotate")
{
Pair<vector> n1n2(IStringStream(transformations[i].second())());
n1n2[0] /= mag(n1n2[0]);
n1n2[1] /= mag(n1n2[1]);
transforms =
transformer::rotation(rotationTensor(n1n2[0], n1n2[1]))
& transforms;
}
else if (transformations[i].first() == "Rx")
{
const scalar a
(
readScalar(IStringStream(transformations[i].second())())
);
transforms = transformer::rotation(Rx(degToRad(a))) & transforms;
}
else if (transformations[i].first() == "Ry")
{
const scalar a
(
readScalar(IStringStream(transformations[i].second())())
);
transforms = transformer::rotation(Ry(degToRad(a))) & transforms;
}
else if (transformations[i].first() == "Rz")
{
const scalar a
(
readScalar(IStringStream(transformations[i].second())())
);
transforms = transformer::rotation(Rz(degToRad(a))) & transforms;
}
else if (transformations[i].first() == "Ra")
{
IStringStream istr(transformations[i].second());
const vector v(istr);
const scalar a(readScalar(istr));
transforms = transformer::rotation(Ra(v, degToRad(a))) & transforms;
}
else if (transformations[i].first() == "scale")
{
const vector v(IStringStream(transformations[i].second())());
transforms =
transformer::scaling(diagTensor(v.x(), v.y(), v.z()))
& transforms;
}
else
{
args.printUsage();
FatalErrorInFunction
<< "Unknown transformation " << transformations[i].first()
<< exit(FatalError);
}
}
}
|