// SPDX-License-Identifier: LGPL-2.1-or-later /*************************************************************************** * Copyright (c) 2017 Lorenz Lechner * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef MESHFLATTENING #define MESHFLATTENING // idea: // - unwrap any meshed shells and output a 2d face (meshing is done externally) // - unwrap faces which are nurbs and return nurbs (no cuts, meshing internally) // - TODO: map any curves from origin to flattened faces #include #include #include #include "MeshFlatteningNurbs.h" // clang-format off using Vector3 = Eigen::Vector3d; using Vector2 = Eigen::Vector2d; template using ColMat = Eigen::Matrix; template using RowMat = Eigen::Matrix; using trip = Eigen::Triplet; using spMat = Eigen::SparseMatrix; std::vector> getBoundaries(ColMat vertices, ColMat tris); class FaceUnwrapper{ nurbs::NurbsBase2D nu; public: FaceUnwrapper() = default; FaceUnwrapper(const TopoDS_Face & face); FaceUnwrapper(ColMat xyz_nodes, ColMat tris); void findFlatNodes(int steps, double val); ColMat interpolateFlatFace(const TopoDS_Face& face); std::vector> getFlatBoundaryNodes(); bool use_nurbs = true; // the mesh ColMat tris; // input ColMat fixed_nodes; // input ColMat xyz_nodes; // compute from uv_mesh (xyz = A * poles) ColMat uv_nodes; // input ColMat ze_nodes; // compute // nurbs ColMat ze_poles; // compute spMat A; // mapping between nurbs(poles) and mesh(vertices) computed with nurbs-basis-functions and uv_mesh }; // clang-format on #endif // MESHFLATTENING