From 47ce19e02be5c39b8bbf02b88e29b6a575c3b783 Mon Sep 17 00:00:00 2001 From: mos Date: Tue, 21 May 2024 19:18:14 +0200 Subject: [PATCH] [MeshPart] clean removed old commented code. [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci revert comments [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/Mod/MeshPart/App/AppMeshPart.cpp | 1 - src/Mod/MeshPart/App/AppMeshPartPy.cpp | 1 - src/Mod/MeshPart/App/CurveProjector.cpp | 204 +----------------- src/Mod/MeshPart/App/MeshAlgos.cpp | 47 ---- src/Mod/MeshPart/App/MeshAlgos.h | 15 -- .../App/MeshFlatteningBoostPython.cpp | 4 - src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp | 4 - 7 files changed, 3 insertions(+), 273 deletions(-) diff --git a/src/Mod/MeshPart/App/AppMeshPart.cpp b/src/Mod/MeshPart/App/AppMeshPart.cpp index 1fb7b4d611..3d3b79d306 100644 --- a/src/Mod/MeshPart/App/AppMeshPart.cpp +++ b/src/Mod/MeshPart/App/AppMeshPart.cpp @@ -38,7 +38,6 @@ PyMOD_INIT_FUNC(MeshPart) // load dependent module try { Base::Interpreter().loadModule("Part"); - // Base::Interpreter().loadModule("Mesh"); } catch (const Base::Exception& e) { PyErr_SetString(PyExc_ImportError, e.what()); diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index 844058804d..c8d05b9d5a 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -183,7 +183,6 @@ private: float x=0.0f,y=0.0f,z=1.0f,size = 0.1f; if (!PyArg_ParseTuple(args.ptr(), "O!O(fff)f", &(Part::TopoShapePy::Type), &pcTopoObj,&pcListObj,&x,&y,&z,&size)) -// if (!PyArg_ParseTuple(args, "O!O!", &(App::TopoShapePy::Type), &pcTopoObj,&PyList_Type,&pcListObj,x,y,z,size)) throw Py::Exception(); pcObject = static_cast(pcTopoObj); diff --git a/src/Mod/MeshPart/App/CurveProjector.cpp b/src/Mod/MeshPart/App/CurveProjector.cpp index 46bb9f307c..ceab83bff4 100644 --- a/src/Mod/MeshPart/App/CurveProjector.cpp +++ b/src/Mod/MeshPart/App/CurveProjector.cpp @@ -103,8 +103,6 @@ void CurveProjectorShape::Do() TopExp_Explorer Ex; for (Ex.Init(_Shape, TopAbs_EDGE); Ex.More(); Ex.Next()) { const TopoDS_Edge& aEdge = TopoDS::Edge(Ex.Current()); - - // std::vector vSplitEdges; projectCurve(aEdge, mvEdgeSplitPoints[aEdge]); } } @@ -280,9 +278,6 @@ void CurveProjectorSimple::Do() for (Ex.Init(_Shape, TopAbs_EDGE); Ex.More(); Ex.Next()) { const TopoDS_Edge& aEdge = TopoDS::Edge(Ex.Current()); - // GetSampledCurves(aEdge,vEdgePolygon,2000); - - // std::vector vSplitEdges; projectCurve(aEdge, vEdgePolygon, mvEdgeSplitPoints[aEdge]); } } @@ -308,13 +303,11 @@ void CurveProjectorSimple::GetSampledCurves(const TopoDS_Edge& aEdge, // projectToNeighbours(Handle(Geom_Curve) hCurve,float pos void CurveProjectorSimple::projectCurve(const TopoDS_Edge& aEdge, - const std::vector& /*rclPoints*/, - std::vector& /*vSplitEdges*/) + const std::vector&, + std::vector&) { - Base::Vector3f /*cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal,*/ TempResultPoint; + Base::Vector3f TempResultPoint; bool bFirst = true; - // unsigned long auNeighboursIdx[3]; - // std::map >::iterator N1,N2,N3; Standard_Real fBegin, fEnd; Handle(Geom_Curve) hCurve = BRep_Tool::Curve(aEdge, fBegin, fEnd); @@ -361,189 +354,8 @@ void CurveProjectorSimple::projectCurve(const TopoDS_Edge& aEdge, Base::Console().Log("Projection map [%d facets with %d points]\n", FaceProjctMap.size(), PointCount); - - // estimate the first face - // gp_Pnt gpPt = hCurve->Value(fBegin); - // if( - // !findStartPoint(MeshK,Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()),cResultPoint,uCurFacetIdx) - // ) - // uCurFacetIdx = FaceProjctMap.begin()->first; - - /* - do{ - Base::Console().Log("Grow on %d %d left\n",uCurFacetIdx,FaceProjctMap.size()); - - if(FaceProjctMap[uCurFacetIdx].size() == 1) - { - Base::Console().Log("Single hit\n"); - }else{ - - - } - - FaceProjctMap.erase(uCurFacetIdx); - - // estimate next facet - MeshGeomFacet cCurFacet= MeshK.GetFacet(uCurFacetIdx); - MeshK.GetFacetNeighbours ( uCurFacetIdx, auNeighboursIdx[0], auNeighboursIdx[1], - auNeighboursIdx[2]); - - uCurFacetIdx = MeshCore::FACET_INDEX_MAX; - PointCount = 0; - - for(int i=0; i<3; i++) - { - N1 = FaceProjctMap.find(auNeighboursIdx[i]); - // if the i'th neighbour is valid - if ( N1 != FaceProjctMap.end() ) - { - unsigned long temp = N1->second.size(); - if(temp >= PointCount){ - PointCount = N1->second.size(); - uCurFacetIdx = auNeighboursIdx[i]; - } - } - } - - - }while(uCurFacetIdx != MeshCore::FACET_INDEX_MAX); - */ } -/* -void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, - const std::vector &rclPoints, - std::vector &vSplitEdges) -{ - const MeshKernel &MeshK = *(_Mesh.getKernel()); - - Standard_Real fFirst, fLast, fAct; - Handle(Geom_Curve) hCurve = BRep_Tool::Curve( aEdge,fFirst,fLast ); - - // getting start point - gp_Pnt gpPt = hCurve->Value(fFirst); - fAct = fFirst; - // projection of the first point - Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()); - Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal,TempResultPoint; - MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx; - MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as -FACET_INDEX_MAX MeshCore::FacetIndex auNeighboursIdx[3]; bool GoOn; - - // go through the whole Mesh, find the first projection - MeshFacetIterator It(MeshK); - GoOn = false; - for(It.Init();It.More();It.Next()) - { - // try to project (with angle) to the face - if(MeshFacetFunc::IntersectWithLine (*It, cStartPoint, It->GetNormal(), cResultPoint) ) - { - uCurFacetIdx = It.Position(); - GoOn = true; - break; - } - } - - if(!GoOn) - { - Base::Console().Log("Starting point not projectable\n"); - return; - } - { - float fStep = (fLast-fFirst)/20; - unsigned long HitCount,Sentinel = 0 ; - MeshGeomFacet cCurFacet= MeshK.GetFacet(uCurFacetIdx); - MeshK.GetFacetNeighbours ( uCurFacetIdx, auNeighboursIdx[0], auNeighboursIdx[1], -auNeighboursIdx[2]); - - do{ - // lower the step until you find a neigbourfacet to project... - fStep /= 2.0; - // still on the same facet? - gpPt = hCurve->Value(fAct+fStep); - if(MeshFacetFunc::IntersectWithLine (cCurFacet, Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()), -cCurFacet.GetNormal(), cResultPoint) ) - { - fAct += fStep; - fStep *= 2.0; - continue; - } - - HitCount = 0; - for(int i=0; i<3; i++) - { - // if the i'th neighbour is valid - if ( auNeighboursIdx[i] != MeshCore::FACET_INDEX_MAX ) - { - // try to project next interval - MeshGeomFacet N = MeshK.GetFacet( auNeighboursIdx[i] ); - gpPt = hCurve->Value(fAct+fStep); - if(MeshFacetFunc::IntersectWithLine (*It, Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()), -It->GetNormal(), cResultPoint) ) - { - HitCount++; - uStartFacetIdx = auNeighboursIdx[i]; - } - - } - } - - Sentinel++; - - }while(HitCount!=1 && Sentinel < 20); - - } - - -} -*/ -/* - -void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, - const std::vector &rclPoints, - std::vector &vSplitEdges) -{ - const MeshKernel &MeshK = *(_Mesh.getKernel()); - - Standard_Real fFirst, fLast; - Handle(Geom_Curve) hCurve = BRep_Tool::Curve( aEdge,fFirst,fLast ); - - // getting start point - gp_Pnt gpPt = hCurve->Value(fFirst); - - // projection of the first point - Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()); - Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal; - MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx; - MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as -FACET_INDEX_MAX MeshCore::FacetIndex auNeighboursIdx[3]; bool GoOn; - - if( !findStartPoint(MeshK,cStartPoint,cResultPoint,uStartFacetIdx) ) - return; - - FILE* file = fopen("projected.asc", "w"); - - // go through the whole Mesh - MeshFacetIterator It1(MeshK); - for(It1.Init();It1.More();It1.Next()) - { - // cycling through the points and find the first projecteble point ( if the curve starts outside -the mesh) for( std::vector::const_iterator It = -rclPoints.begin()+1;It!=rclPoints.end();++It) - { -// MeshGeomFacet facet = MeshK.GetFacet(uStartFacetIdx); - MeshGeomFacet facet = *It1; - - if(MeshFacetFunc::IntersectWithLine(facet, *It, facet.GetNormal(), cResultPoint) ) - fprintf(file, "%.4f %.4f %.4f\n", cResultPoint.x, cResultPoint.y, cResultPoint.z); - - } - } - - fclose(file); - -} -*/ bool CurveProjectorSimple::findStartPoint(const MeshKernel& MeshK, const Base::Vector3f& Pnt, @@ -801,8 +613,6 @@ void MeshProjection::findSectionParameters(const TopoDS_Edge& edge, BRepExtrema_DistShapeShape extss(aBuilder.Vertex(), edge); if (extss.NbSolution() == 1) { Standard_Real par; - // gp_pnt pnt = extss.PointOnShape2(1); - // Standard_Real par = BRep_Tool::Parameter(aBuilder.Vertex(), edge); extss.ParOnEdgeS2(1, par); parameters.insert(par); break; @@ -916,7 +726,6 @@ void MeshProjection::projectOnMesh(const std::vector& pointsIn, for (auto jt : boundaryEdges) { jt.ClosestPointsToLine(it, dir, result1, result2); float dot = (result1 - jt._aclPoints[0]).Dot(result1 - jt._aclPoints[1]); - // float distance = Base::Distance(result1, result2); Base::Vector3f vec = result1 - it; float angle = vec.GetAngle(dir); if (dot <= 0 && angle < 1e-6f) { @@ -1083,10 +892,6 @@ void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge, Standard_Real fLast = clCurve.LastParameter(); Handle(Geom_Curve) hCurve = BRep_Tool::Curve(aEdge, fFirst, fLast); - // bounds of curve - // Bnd_Box clBB; - // BndLib_Add3dCurve::Add( BRepAdaptor_Curve(aEdge), 0.0, clBB ); - MeshPointIterator cPI(_rcMesh); MeshFacetIterator cFI(_rcMesh); @@ -1108,9 +913,6 @@ void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge, if (auFaces.size() > 2) { continue; // non-manifold edge -> don't handle this } - // if ( clBB.IsOut( gp_Pnt(cE0.x, cE0.y, cE0.z) ) && clBB.IsOut( gp_Pnt(cE1.x, cE1.y, - // cE1.z) ) ) - // continue; Base::Vector3f cEdgeNormal; for (MeshCore::FacetIndex itF : auFaces) { diff --git a/src/Mod/MeshPart/App/MeshAlgos.cpp b/src/Mod/MeshPart/App/MeshAlgos.cpp index 150cb252cc..3309481dbf 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.cpp +++ b/src/Mod/MeshPart/App/MeshAlgos.cpp @@ -102,8 +102,6 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize) } } - // if there are no flipped triangles -> stop - // int f =fliped.size(); if (fliped.empty()) { break; } @@ -192,10 +190,6 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1, s1 = MeshAlgos::createGTSSurface(pMesh1); s2 = MeshAlgos::createGTSSurface(pMesh2); - // clear the mesh (memory) - // Mesh1.clear(); - // Mesh2.clear(); - /* check that the surfaces are orientable manifolds */ if (!gts_surface_is_orientable(s1)) { gts_object_destroy(GTS_OBJECT(s1)); @@ -214,9 +208,6 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1, self_intersects = gts_surface_is_self_intersecting(s1); if (self_intersects != NULL) { - // if (verbose) - // gts_surface_print_stats (self_intersects, stderr); - // gts_surface_write (self_intersects, stdout); gts_object_destroy(GTS_OBJECT(self_intersects)); gts_object_destroy(GTS_OBJECT(s1)); gts_object_destroy(GTS_OBJECT(s2)); @@ -224,9 +215,6 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1, } self_intersects = gts_surface_is_self_intersecting(s2); if (self_intersects != NULL) { - // if (verbose) - // gts_surface_print_stats (self_intersects, stderr); - // gts_surface_write (self_intersects, stdout); gts_object_destroy(GTS_OBJECT(self_intersects)); gts_object_destroy(GTS_OBJECT(s1)); gts_object_destroy(GTS_OBJECT(s2)); @@ -283,9 +271,6 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1, self_intersects = gts_surface_is_self_intersecting(s3); if (self_intersects != NULL) { - // if (verbose) - // gts_surface_print_stats (self_intersects, stderr); - // gts_surface_write (self_intersects, stdout); gts_object_destroy(GTS_OBJECT(self_intersects)); gts_object_destroy(GTS_OBJECT(s1)); gts_object_destroy(GTS_OBJECT(s2)); @@ -308,12 +293,6 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1, // destroy surfaces gts_object_destroy(GTS_OBJECT(s1)); gts_object_destroy(GTS_OBJECT(s2)); - // gts_object_destroy (GTS_OBJECT (s3)); - // gts_object_destroy (GTS_OBJECT (si)); - - // destroy bounding box trees (including bounding boxes) - // gts_bb_tree_destroy (tree1, true); - // gts_bb_tree_destroy (tree2, true); #endif return pMesh1; @@ -390,11 +369,6 @@ static void onFaces(GtsTriangle* t, std::vector* VAry) Base::Vector3f(mv2->p.x, mv2->p.y, mv2->p.z))); } -/* -static void onVertices(GtsVertex *v, MeshKernel *pKernel ) -{ - Base::Vector3f Point(GTS_POINT(v)->x,GTS_POINT(v)->y,GTS_POINT(v)->z); -}*/ void MeshAlgos::fillMeshFromGTSSurface(MeshCore::MeshKernel* pMesh, GtsSurface* pSurface) { @@ -403,7 +377,6 @@ void MeshAlgos::fillMeshFromGTSSurface(MeshCore::MeshKernel* pMesh, GtsSurface* // remove old mesh pMesh->Clear(); - // gts_surface_foreach_vertex(pSurface,(GtsFunc) onVertices,&MeshK); gts_surface_foreach_face(pSurface, (GtsFunc)onFaces, &VAry); // destroy surfaces @@ -431,27 +404,9 @@ void MeshAlgos::cutByShape(const TopoDS_Shape& aShape, const MeshCore::MeshKernel* pMesh, MeshCore::MeshKernel* pToolMesh) { - - // calculate the projection for each Edge - // CurveProjectorShape Project(aShape,*pMesh); CurveProjectorWithToolMesh Project(aShape, *pMesh, *pToolMesh); - - // IntersectionLine Lines; - // MeshWithProperty *ResultMesh = new MeshWithProperty(); - - - // boolean(pMesh,ToolMesh,ResultMesh,1); } -/* -void MeshAlgos::doIntersection(const MeshWithProperty &pMesh,const MeshWithProperty -ToolMesh,IntersectionLine &Lines) - { - - - } - -*/ void MeshAlgos::cutByCurve(MeshCore::MeshKernel* pMesh, const std::vector& vSplitEdges) @@ -546,8 +501,6 @@ void MeshAlgos::LoftOnCurve(MeshCore::MeshKernel& ResultMesh, Up.Normalize(); Base::Vector3f Third(Tng % Up); - // Base::Console().Log("Pos: %f %f %f \n",Ptn.x,Ptn.y,Ptn.z); - unsigned int l = 0; std::vector::const_iterator It; diff --git a/src/Mod/MeshPart/App/MeshAlgos.h b/src/Mod/MeshPart/App/MeshAlgos.h index e8cb0dd7b0..5a0412be20 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.h +++ b/src/Mod/MeshPart/App/MeshAlgos.h @@ -96,24 +96,9 @@ public: const Base::Vector3f& up = Base::Vector3f(0, 0, 1), float MaxSize = 0.1); - /* - struct FaceSplitEdge - { - unsigned long ulFaceIndex; - Base::Vector3f p1,p2; - }; - static void projectCurve( MeshWithProperty* pMesh, - const TopoDS_Edge& aEdge, - const std::vector &rclPoints, - std::vector &vSplitEdges); - */ static void cutByCurve(MeshCore::MeshKernel* pMesh, const std::vector& vSplitEdges); - /* - static bool projectPointToMesh(MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f - &Rslt,unsigned long &FaceIndex); - */ }; } // namespace MeshPart diff --git a/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp b/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp index c77a6b9268..879096235b 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp @@ -196,8 +196,6 @@ struct eigen_matrix BOOST_PYTHON_MODULE(flatmesh) { - //m.doc() = "functions to unwrapp faces/ meshes"; - py::class_("LscmRelax") .def(py::init, ColMat, std::vector>()) .def("lscm", &lscmrelax::LscmRelax::lscm) @@ -208,7 +206,6 @@ BOOST_PYTHON_MODULE(flatmesh) .def_readonly("MATRIX", &lscmrelax::LscmRelax::MATRIX) .def_readonly("area", &lscmrelax::LscmRelax::get_area) .def_readonly("flat_area", &lscmrelax::LscmRelax::get_flat_area) -// .def_readonly("flat_vertices", [](lscmrelax::LscmRelax& L){return L.flat_vertices.transpose();}, py::return_value_policy()) .def_readonly("flat_vertices_3D", &lscmrelax::LscmRelax::get_flat_vertices_3D); py::class_("NurbsBase2D") @@ -216,7 +213,6 @@ BOOST_PYTHON_MODULE(flatmesh) .def_readonly("u_knots", &nurbs::NurbsBase2D::u_knots) .def_readonly("weights", &nurbs::NurbsBase2D::weights) .def_readonly("degree_u", &nurbs::NurbsBase2D::degree_u) -// .def_readonly("v_knots", &nurbs::NurbsBase2D::u_knots) .def_readonly("degree_v", &nurbs::NurbsBase2D::degree_u) .def("getUVMesh", &nurbs::NurbsBase2D::getUVMesh) .def("computeFirstDerivatives", &nurbs::NurbsBase2D::computeFirstDerivatives) diff --git a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp index 03e28a57fc..9af4f3e676 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp @@ -158,7 +158,6 @@ NurbsBase2D::NurbsBase2D(Eigen::VectorXd u_knots, Eigen::VectorXd v_knots, Eigen::VectorXd weights, int degree_u, int degree_v) { - // assert(weights.size() == u_knots.size() * v_knots.size()); this->u_knots = u_knots; this->v_knots = v_knots; this->weights = weights; @@ -248,15 +247,12 @@ Eigen::VectorXd NurbsBase2D::getDuVector(Eigen::Vector2d u) n_v.resize(this->v_functions.size()); for (unsigned int u_i=0; u_i < this->u_functions.size(); u_i++) { - // std::cout << "u_i: " << u_i << " , n_u: " << n_u.size() - // << " , Dn_u: " << Dn_u.size() << std::endl; n_u[u_i] = this->u_functions[u_i](u.x()); Dn_u[u_i] = this->Du_functions[u_i](u.x()); } for (unsigned int v_i=0; v_i < this->v_functions.size(); v_i++) { n_v[v_i] = this->v_functions[v_i](u.y()); - // std::cout << v_i << std::endl; } for (unsigned int u_i=0; u_i < this->u_functions.size(); u_i++)