#include "reducedmodel.hpp" ReducedModel::ReducedModel() : PatternGeometry({1, 0, 0, 2, 1, 2, 1}, {{0, 3}}) { interfaceNodeIndex = 3; label = "ReducedModel"; // constexpr double initialHexSize = 0.3; // CoordType movableVertex_barycentric(1 - initialHexSize, initialHexSize / 2, initialHexSize / 2); // const vcg::Triangle3 &baseTriangle = getBaseTriangle(); // vert[0].P() = baseTriangle.cP(0) * movableVertex_barycentric[0] // + baseTriangle.cP(1) * movableVertex_barycentric[1] // + baseTriangle.cP(2) * movableVertex_barycentric[2]; } void ReducedModel::updateBaseTriangleGeometry_theta(const double &newTheta_deg) { const CoordType baseTriangleHexagonVertexPosition = vert[0].cP(); const CoordType thetaRotatedHexagonBaseTriangleVertexPosition = vcg::RotationMatrix(PatternGeometry::DefaultNormal, vcg::math::ToRad(newTheta_deg)) * baseTriangleHexagonVertexPosition; vert[0].P() = thetaRotatedHexagonBaseTriangleVertexPosition; // constexpr int fanSize = 6; // for (int rotationCounter = 0; rotationCounter < /*ReducedModelOptimizer::*/ fanSize; // rotationCounter++) { // vert[2 * rotationCounter].P() = vcg::RotationMatrix(PatternGeometry::DefaultNormal, // vcg::math::ToRad(60.0 * rotationCounter)) // * thetaRotatedHexagonBaseTriangleVertexPosition; // } updateEigenEdgeAndVertices(); } void ReducedModel::updateBaseTriangleGeometry_R(const double &newR) { const CoordType barycentricCoordinates_hexagonBaseTriangleVertex(1 - newR, newR / 2, newR / 2); const vcg::Triangle3 &baseTriangle = getBaseTriangle(); const CoordType hexagonBaseTriangleVertexPosition = baseTriangle.cP(0) * barycentricCoordinates_hexagonBaseTriangleVertex[0] + baseTriangle.cP(1) * barycentricCoordinates_hexagonBaseTriangleVertex[1] + baseTriangle.cP(2) * barycentricCoordinates_hexagonBaseTriangleVertex[2]; vert[0].P() = hexagonBaseTriangleVertexPosition; // constexpr int fanSize = 6; // for (int rotationCounter = 0; rotationCounter < /*ReducedModelOptimizer::*/ fanSize; // rotationCounter++) { // vert[2 * rotationCounter].P() = vcg::RotationMatrix(PatternGeometry::DefaultNormal, // vcg::math::ToRad(60.0 * rotationCounter)) // * hexagonBaseTriangleVertexPosition; // // std::cout << vert[2 * rotationCounter].P()[0] << " " << vert[2 * rotationCounter].P()[1] // // << " " << vert[2 * rotationCounter].P()[2] << std::endl; // } updateEigenEdgeAndVertices(); } void ReducedModel::updateBaseTriangleGeometry_theta( const double &newTheta_deg, std::shared_ptr &pReducedModel_edgeMesh) { std::dynamic_pointer_cast(pReducedModel_edgeMesh) ->updateBaseTriangleGeometry_theta(newTheta_deg); } void ReducedModel::updateBaseTriangleGeometry_R(const double &newR, std::shared_ptr &pReducedModel_edgeMesh) { std::dynamic_pointer_cast(pReducedModel_edgeMesh) ->updateBaseTriangleGeometry_R(newR); } void ReducedModel::createFan(const size_t &fanSize) { deleteDanglingVertices(); PatternGeometry rotatedPattern; vcg::tri::Append::MeshCopy(rotatedPattern, *this); for (int rotationCounter = 1; rotationCounter < fanSize; rotationCounter++) { vcg::Matrix44d R; auto rotationAxis = PatternGeometry::DefaultNormal; R.SetRotateDeg(360.0 / fanSize, rotationAxis); vcg::tri::UpdatePosition::Matrix(rotatedPattern, R); vcg::tri::Append::Mesh(*this, rotatedPattern); //For the reduced model we also need to connect to neighbouring base triangles of the fan if (rotationCounter == fanSize - 1) { vcg::tri::Allocator::AddEdge(*this, 0, this->VN() - rotatedPattern.VN()); } vcg::tri::Allocator::AddEdge(*this, this->VN() - 2 * rotatedPattern.VN(), this->VN() - rotatedPattern.VN()); removeDuplicateVertices(); updateEigenEdgeAndVertices(); } }