diff --git a/src/Mod/MeshPart/App/MeshFlattening.cpp b/src/Mod/MeshPart/App/MeshFlattening.cpp index 9d1290373d..1139bcb1de 100644 --- a/src/Mod/MeshPart/App/MeshFlattening.cpp +++ b/src/Mod/MeshPart/App/MeshFlattening.cpp @@ -22,17 +22,17 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include #endif #include "MeshFlattening.h" @@ -50,30 +50,30 @@ std::vector> getBoundaries(ColMat vertices, ColMat< std::vector> edge_vector; - for (long i=0; i hash {v1, v2}; hash_list.push_back(hash); - if (v1 < v2) - hash_map[hash] = std::vector{v1, v2, 0}; - else - hash_map[hash] = std::vector{v2, v1, 0}; + if (v1 < v2) { + hash_map[hash] = std::vector {v1, v2, 0}; + } + else { + hash_map[hash] = std::vector {v2, v1, 0}; + } } } - for (auto & hash: hash_list) + for (auto& hash : hash_list) { hash_map[hash][2] += 1; + } - for (auto &hash: hash_map) - { - if (hash.second[2] == 1) - { + for (auto& hash : hash_map) { + if (hash.second[2] == 1) { long v0 = hash.second[0]; long v1 = hash.second[1]; @@ -83,8 +83,7 @@ std::vector> getBoundaries(ColMat vertices, ColMat< } - while (neighbour_map.size() != 0) - { + while (neighbour_map.size() != 0) { long start_index = neighbour_map.begin()->first; long close_index = start_index; long next_index = neighbour_map[start_index][1]; @@ -94,33 +93,27 @@ std::vector> getBoundaries(ColMat vertices, ColMat< edge_vector_0.push_back(start_index); neighbour_map.erase(start_index); edge_vector_0.push_back(next_index); - while (next_index != close_index) - { + while (next_index != close_index) { temporary_next = neighbour_map[next_index][0]; - if (temporary_next != start_index) - { + if (temporary_next != start_index) { start_index = next_index; next_index = temporary_next; } - else - { + else { start_index = next_index; next_index = neighbour_map[start_index][1]; } neighbour_map.erase(start_index); edge_vector_0.push_back(next_index); - } edge_vector.push_back(edge_vector_0); } std::vector> edges; - for (auto &edge: edge_vector) - { + for (auto& edge : edge_vector) { ColMat edge_vertices; edge_vertices.resize(edge.size(), 3); int i = 0; - for (auto index: edge) - { + for (auto index : edge) { edge_vertices.row(i) = vertices.row(index); i++; } @@ -132,35 +125,33 @@ std::vector> getBoundaries(ColMat vertices, ColMat< FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face) { long i = 0; -// transform to nurbs: + // transform to nurbs: TopLoc_Location location; -// triangulate: - const Handle(Poly_Triangulation) &triangulation = BRep_Tool::Triangulation(face, location); + // triangulate: + const Handle(Poly_Triangulation)& triangulation = BRep_Tool::Triangulation(face, location); - if (triangulation.IsNull()) + if (triangulation.IsNull()) { throw std::runtime_error("null triangulation in face construction"); + } Standard_Integer numNodes = triangulation->NbNodes(); Standard_Integer numTriangles = triangulation->NbTriangles(); -// compute uv coordinates - if (triangulation->HasUVNodes()) - { + // compute uv coordinates + if (triangulation->HasUVNodes()) { this->uv_nodes.resize(numNodes, 2); i = 0; - for (Standard_Integer index = 1; index <= numNodes; ++index) - { + for (Standard_Integer index = 1; index <= numNodes; ++index) { const gp_Pnt2d& _uv_node = triangulation->UVNode(index); this->uv_nodes.row(i) << _uv_node.X(), _uv_node.Y(); i++; } } -// + // this->xyz_nodes.resize(numNodes, 3); i = 0; - for (Standard_Integer index = 1; index <= numNodes; ++index) - { + for (Standard_Integer index = 1; index <= numNodes; ++index) { gp_Pnt _node = triangulation->Node(index); this->xyz_nodes.row(i) << _node.X(), _node.Y(), _node.Z(); i++; @@ -168,45 +159,47 @@ FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face) this->tris.resize(numTriangles, 3); i = 0; - for (Standard_Integer index = 1; index <= numTriangles; ++index) - { + for (Standard_Integer index = 1; index <= numTriangles; ++index) { int n1, n2, n3; const Poly_Triangle& _tri = triangulation->Triangle(index); _tri.Get(n1, n2, n3); - this->tris.row(i) << n1-1, n2-1, n3-1; + this->tris.row(i) << n1 - 1, n2 - 1, n3 - 1; i++; } } void FaceUnwrapper::findFlatNodes(int steps, double val) { - std::vector fixed_pins; //TODO: INPUT - lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(), this->tris.transpose(), fixed_pins); + std::vector fixed_pins;// TODO: INPUT + lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(), + this->tris.transpose(), + fixed_pins); mesh_flattener.lscm(); - for (int j=0; jze_nodes = mesh_flattener.flat_vertices.transpose(); } ColMat FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face) { - if (this->uv_nodes.size() == 0) - throw(std::runtime_error("no uv-coordinates found, interpolating with nurbs is only possible if the Flattener was constructed with a nurbs.")); + if (this->uv_nodes.size() == 0) { + throw(std::runtime_error("no uv-coordinates found, interpolating with nurbs is only " + "possible if the Flattener was constructed with a nurbs.")); + } // extract xyz poles, knots, weights, degree - const Handle(Geom_Surface) &_surface = BRep_Tool::Surface(face); - const Handle(Geom_BSplineSurface) &_bspline = Handle(Geom_BSplineSurface)::DownCast(_surface); + const Handle(Geom_Surface)& _surface = BRep_Tool::Surface(face); + const Handle(Geom_BSplineSurface)& _bspline = Handle(Geom_BSplineSurface)::DownCast(_surface); - const TColStd_Array1OfReal &_uknots = _bspline->UKnotSequence(); - const TColStd_Array1OfReal &_vknots = _bspline->VKnotSequence(); + const TColStd_Array1OfReal& _uknots = _bspline->UKnotSequence(); + const TColStd_Array1OfReal& _vknots = _bspline->VKnotSequence(); Eigen::VectorXd weights; weights.resize(_bspline->NbUPoles() * _bspline->NbVPoles()); long i = 0; - for (long u=1; u <= _bspline->NbUPoles(); u++) - { - for (long v=1; v <= _bspline->NbVPoles(); v++) - { + for (long u = 1; u <= _bspline->NbUPoles(); u++) { + for (long v = 1; v <= _bspline->NbVPoles(); v++) { weights[i] = _bspline->Weight(u, v); i++; } @@ -216,12 +209,10 @@ ColMat FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face) Eigen::VectorXd v_knots; u_knots.resize(_uknots.Length()); v_knots.resize(_vknots.Length()); - for (long u=1; u <= _uknots.Length(); u++) - { + for (long u = 1; u <= _uknots.Length(); u++) { u_knots[u - 1] = _uknots.Value(u); } - for (long v=1; v <= _vknots.Length(); v++) - { + for (long v = 1; v <= _vknots.Length(); v++) { v_knots[v - 1] = _vknots.Value(v); } @@ -229,7 +220,7 @@ ColMat FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face) nu = nurbs::NurbsBase2D(u_knots, v_knots, weights, _bspline->UDegree(), _bspline->VDegree()); A = nu.getInfluenceMatrix(this->uv_nodes); - Eigen::LeastSquaresConjugateGradient solver; + Eigen::LeastSquaresConjugateGradient solver; solver.compute(A); ColMat ze_poles; ColMat flat_poles; @@ -243,17 +234,17 @@ ColMat FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face) } -FaceUnwrapper::FaceUnwrapper(ColMat< double, int(3) > xyz_nodes, ColMat< long int, int(3) > tris) +FaceUnwrapper::FaceUnwrapper(ColMat xyz_nodes, ColMat tris) { this->tris = tris; this->xyz_nodes = xyz_nodes; - } std::vector> FaceUnwrapper::getFlatBoundaryNodes() { - if (this->ze_nodes.size() == 0) + if (this->ze_nodes.size() == 0) { throw(std::runtime_error("flat vertices not xet computed")); + } ColMat flat_vertices; flat_vertices.resize(this->ze_nodes.rows(), 3); diff --git a/src/Mod/MeshPart/Gui/Resources/MeshPart.qrc b/src/Mod/MeshPart/Gui/Resources/MeshPart.qrc index 6c58ee8b3a..8ad53a9b91 100644 --- a/src/Mod/MeshPart/Gui/Resources/MeshPart.qrc +++ b/src/Mod/MeshPart/Gui/Resources/MeshPart.qrc @@ -6,4 +6,3 @@ icons/MeshPart_CreateFlatMesh.svg - diff --git a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_hu.ts b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_hu.ts index 8b94d2dd92..a1dad2ef64 100644 --- a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_hu.ts +++ b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_hu.ts @@ -340,7 +340,7 @@ felületeltérés szorozva az aktuális hálószakasz hosszával (él) A hálószegmensek az objektum felületek színe szerint lesznek csoportosítva. -Ezek a csoportok a hálókimeneti formátumokhoz lesznek exportálva, amelyek +Ezek a csoportok a hálókimeneti formátumokhoz lesznek exportálva, amelyek támogatják ezt a tulajdonságot (pl. OBJ formátum). diff --git a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_ka.ts b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_ka.ts index 84375d8bf1..84d0f3cf08 100644 --- a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_ka.ts +++ b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_ka.ts @@ -340,7 +340,7 @@ Surface deviation multiplied by the length of the current mesh segment (edge) ქსელის სეგმენტები დაჯგუფდება ობიექტის ზედაპირის ფერის მიხედვით. -ეს ჯგუფები გატანილი იქნება ბადის გამომავალი ფორმატებისთვის, +ეს ჯგუფები გატანილი იქნება ბადის გამომავალი ფორმატებისთვის, რომლებსაც აქვთ ამ თვისების მხარდაჭერა(მაგ. ფორმატი OBJ). diff --git a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_tr.ts b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_tr.ts index 61bea86f0d..6fb8698c72 100644 --- a/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_tr.ts +++ b/src/Mod/MeshPart/Gui/Resources/translations/MeshPart_tr.ts @@ -35,7 +35,7 @@ Creates an approximated curve on top of a mesh. This command only works with a 'mesh' object. - Bir metal örgünün üstünde yaklaşık bir eğri oluşturur. + Bir metal örgünün üstünde yaklaşık bir eğri oluşturur. Bu komut yalnızca bir 'metal örgü' nesnesiyle çalışır. @@ -220,7 +220,7 @@ Bu komut yalnızca bir 'metal örgü' nesnesiyle çalışır. Press 'Start', then pick points on the mesh; when enough points have been set, right-click and choose 'Create'. Repeat this process to create more splines. Close this task panel to complete the operation. This command only works with a 'mesh' object, not a regular face or surface. To convert an object to a mesh use the tools of the Mesh Workbench. - "Başlat"a basın, ardından metal örgü üzerindeki noktaları seçin; Yeterli nokta ayarlandığında, sağ tıklayın ve 'Oluştur'u seçin. Daha fazla spline oluşturmak için bu işlemi tekrarlayın. İşlemi tamamlamak için bu görev panelini kapatın. + "Başlat"a basın, ardından metal örgü üzerindeki noktaları seçin; Yeterli nokta ayarlandığında, sağ tıklayın ve 'Oluştur'u seçin. Daha fazla spline oluşturmak için bu işlemi tekrarlayın. İşlemi tamamlamak için bu görev panelini kapatın. Bu komut, normal bir yüz veya yüzeyle değil, yalnızca 'metal örgü' nesnesiyle çalışır. Bir nesneyi metal örgüye dönüştürmek için Metal Örgü Çalışma Tezgahının araçlarını kullanın. @@ -338,7 +338,7 @@ Surface deviation multiplied by the length of the current mesh segment (edge)Mesh segments will be grouped according to the color of the object faces. These groups will be exported for mesh output formats supporting this feature (e.g. the format OBJ). - Metal örgü bölümleri, nesne yüzlerinin rengine göre gruplandırılacaktır. + Metal örgü bölümleri, nesne yüzlerinin rengine göre gruplandırılacaktır. Bu gruplar, bu özelliği destekleyen metal örgü çıktı biçimleri için dışa aktarılacaktır (ör. OBJ biçimi). @@ -427,7 +427,7 @@ En küçük değer 0'dır. If this parameter is smaller, the mesh becomes finer. A value in the range of 0.1-1. - Bu parametre daha küçükse, metal örgü daha ince hale gelir. + Bu parametre daha küçükse, metal örgü daha ince hale gelir. 0.1-1 aralığında bir değer. diff --git a/src/Mod/MeshPart/meshpart.dox b/src/Mod/MeshPart/meshpart.dox index 37340f3950..78f968f938 100644 --- a/src/Mod/MeshPart/meshpart.dox +++ b/src/Mod/MeshPart/meshpart.dox @@ -2,4 +2,3 @@ * \ingroup CWORKBENCHES * \brief Part to Mesh (and vice-versa) conversion tools */ -