22 SmartPointer<Mesh<T>> mesh =
nullptr;
24 hrleVectorType<double, 3> transformVector{};
26 double numericEps = 1e-6;
29 bool isValidVector() {
30 if (DotProduct(transformVector, transformVector) < numericEps) {
37 void translateMesh() {
39 if (!isValidVector()) {
42 for (
auto &node : mesh->nodes) {
43 for (
unsigned i = 0; i < 3; ++i) {
44 node[i] += transformVector[i];
52 if (!isValidVector()) {
55 if (std::abs(angle) < numericEps) {
58 const double norm = std::sqrt(transformVector[0] * transformVector[0] +
59 transformVector[1] * transformVector[1] +
60 transformVector[2] * transformVector[2]);
61 for (
unsigned i = 0; i < 3; ++i) {
62 transformVector[i] /= norm;
64 const auto axis = transformVector;
65 double sinAngle = std::sin(angle);
66 double cosAngle = std::cos(angle);
67 double uniMinusCosAngle = 1 - cosAngle;
68 for (
auto &node : mesh->nodes) {
70 double term1 = axis[0] * node[0] + axis[1] * node[1] + axis[2] * node[2];
71 for (
unsigned i = 0; i < 3; ++i) {
72 unsigned ip1 = (i + 1) % 3;
73 unsigned ip2 = (i + 2) % 3;
75 axis[i] * term1 * uniMinusCosAngle + oldNode[i] * cosAngle +
76 (axis[ip1] * oldNode[ip2] - axis[ip2] * oldNode[ip1]) * sinAngle;
82 if (!isValidVector()) {
84 .addWarning(
"TransformMesh: TransformVector is not valid!")
88 for (
auto &node : mesh->nodes) {
89 for (
unsigned i = 0; i < 3; ++i) {
90 node[i] *= transformVector[i];
98 std::array<double, 3> passedTransformVector = {},
99 double passedAngle = 0.0)
100 : mesh(passedMesh), transform(passedTransform),
101 transformVector(passedTransformVector), angle(passedAngle) {}
105 hrleVectorType<double, 3> passedTransformVector = {},
106 double passedAngle = 0.0)
107 : mesh(passedMesh), transform(passedTransform),
108 transformVector(passedTransformVector), angle(passedAngle) {}
111 if (mesh ==
nullptr) {
112 Logger::getInstance()
113 .addWarning(
"No mesh passed to TransformMesh. Not transforming!")
128 Logger::getInstance()
130 "Invalid transform passed to TransformMesh. Not transforming!")