From a6735cf090893b2d185d14c9f03ff5e52e3cbbc1 Mon Sep 17 00:00:00 2001 From: ika Date: Tue, 10 Oct 2023 15:40:19 +0100 Subject: [PATCH] - fix bug - remove bezier option - add segmentation --- src/BRepTest/BRepTest_BasicCommands.cxx | 7 +- .../BRepTools_HullTransformation.cxx | 79 ++++++++----------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/BRepTest/BRepTest_BasicCommands.cxx b/src/BRepTest/BRepTest_BasicCommands.cxx index e5bc0c524f..adff1cbc7e 100644 --- a/src/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/BRepTest/BRepTest_BasicCommands.cxx @@ -1404,7 +1404,7 @@ static Standard_Integer hulltrsf(Draw_Interpretor& di, Standard_Integer n, const { if (n < 3) { - di << "Usage result hull [-l cm cb_new cb_old lpp] or [-q incrX aftlim cca ccf forelim aft_coef fore_coef modify_aft_zone modify_fore_zone] "; + di << "Usage result hull [-l cm cb_new cb_old lpp] or [-q aftlim cca ccf forelim aft_coef fore_coef modify_aft_zone modify_fore_zone] "; di << "[-s XCoord_section1 ... XCoord_sectionN]\n"; return 1; } @@ -1426,7 +1426,7 @@ static Standard_Integer hulltrsf(Draw_Interpretor& di, Standard_Integer n, const double _cb_new = Atof(a[i + 2]); double _cb_old = Atof(a[i + 3]); double _lpp = Atof(a[i + 4]); - aHTrsf.InitLinear(_cm, _cb_old, _cb_new, _lpp); + aHTrsf.InitLinear(_cm, _cb_new, _cb_old, _lpp); i += 4; } if (a[i][0] == '-' && a[i][1] == 'q' && n > i+8) @@ -1484,6 +1484,7 @@ static Standard_Integer hulltrsf(Draw_Interpretor& di, Standard_Integer n, const aShapeFixTool->Init(aHTrsf.Shape()); aShapeFixTool->Perform(); DBRep::Set(a[1], aShapeFixTool->Shape()); + //DBRep::Set(a[1], aHTrsf.Shape()); } else { return 1; @@ -1659,7 +1660,7 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) theCommands.Add("hulltrsf", "hulltrsf result hull " "[-l cm cb_new cb_old lpp] for linear or " - "[-q incrX aftlim cca ccf forelim aft_coef fore_coef modify_aft_zone modify_fore_zone] for quad " + "[-q aftlim cca ccf forelim aft_coef fore_coef modify_aft_zone modify_fore_zone] for quad " "[-s XCoord_section1 ... XCoord_sectionN] to add sections\n", __FILE__, hulltrsf, g); diff --git a/src/BRepTools/BRepTools_HullTransformation.cxx b/src/BRepTools/BRepTools_HullTransformation.cxx index 836fc5c905..909e5a317c 100644 --- a/src/BRepTools/BRepTools_HullTransformation.cxx +++ b/src/BRepTools/BRepTools_HullTransformation.cxx @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -46,7 +47,7 @@ void BRepTools_HullTransformation::InitLinear(const double theCM, _cb_new = theCBNew; _cb_old = theCBOld; _lpp = theLPP; - myScale = (_cm - _cb_new) / (_cm - _cb_old); + myScale = 1.0;// (_cm - _cb_new) / (_cm - _cb_old); } //======================================================================= @@ -107,19 +108,17 @@ gp_Pnt BRepTools_HullTransformation::NewPointFrom(const gp_Pnt& theOldPoint) else { if (_modify_aft_zone && // Aft - oldX >= _aftlim && oldX <= _cca) + oldX >= _aftlim && oldX <= _cca) { incrX = _aft_coef * (oldX - _aftlim)*(oldX - _cca); } - else if (_modify_fore_zone && // Fore - oldX >= _ccf && oldX <= _forelim) + oldX >= _ccf && oldX <= _forelim) { incrX = _fore_coef * (oldX - _ccf)*(oldX - _forelim); } newX = oldX + incrX; } - return gp_Pnt(newX, theOldPoint.Y(), theOldPoint.Z()); } @@ -141,28 +140,25 @@ Standard_Boolean BRepTools_HullTransformation::NewSurface(const TopoDS_Face& F, RevWires = Standard_False; RevFace = (myScale > 0); S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation())); + if (S.IsNull()) + return Standard_True; Handle(Standard_Type) TheTypeS = S->DynamicType(); - if (TheTypeS == STANDARD_TYPE(Geom_BSplineSurface)) { - Handle(Geom_BSplineSurface) S2 = Handle(Geom_BSplineSurface)::DownCast(S); - for(Standard_Integer i = 1; i <= S2->NbUPoles(); i++) - for(Standard_Integer j = 1; j <= S2->NbVPoles(); j++) { - gp_Pnt P = NewPointFrom(S2->Pole(i, j)); - S2->SetPole(i, j, P); - } + if (TheTypeS != STANDARD_TYPE(Geom_BSplineSurface)) + { + throw Standard_NoSuchObject("BRepTools_HullTransformation : Not BSpline Type of Surface"); } - else - if (TheTypeS == STANDARD_TYPE(Geom_BezierSurface)) { - Handle(Geom_BezierSurface) S2 = Handle(Geom_BezierSurface)::DownCast(S); - for(Standard_Integer i = 1; i <= S2->NbUPoles(); i++) - for(Standard_Integer j = 1; j <= S2->NbVPoles(); j++) { - gp_Pnt P = NewPointFrom(S2->Pole(i, j)); - S2->SetPole(i, j, P); - } - } - else{ - throw Standard_NoSuchObject("BRepTools_HullTransformation : Pb no BSpline/Bezier Type Surface"); + Handle(Geom_BSplineSurface) S2 = Handle(Geom_BSplineSurface)::DownCast(S); + Standard_Real aUMin, aUMax, aVMin, aVMax; + BRepTools::UVBounds(F, aUMin, aUMax, aVMin, aVMax); + S2->CheckAndSegment(aUMin, aUMax, aVMin, aVMax); + for (Standard_Integer i = 1; i <= S2->NbUPoles(); i++) + { + for (Standard_Integer j = 1; j <= S2->NbVPoles(); j++) { + gp_Pnt P = NewPointFrom(S2->Pole(i, j)); + S2->SetPole(i, j, P); } + } L.Identity(); return Standard_True; @@ -180,29 +176,24 @@ Standard_Boolean BRepTools_HullTransformation::NewCurve(const TopoDS_Edge& E, Standard_Real f,l; Tol = BRep_Tool::Tolerance(E) * myScale; C = BRep_Tool::Curve(E, L, f, l); + if (C.IsNull()) + return Standard_True; - if (!C.IsNull()) { - C = Handle(Geom_Curve)::DownCast(C->Copy()->Transformed(L.Transformation())); - Handle(Standard_Type) TheTypeC = C->DynamicType(); - if (TheTypeC == STANDARD_TYPE(Geom_BSplineCurve)) { - Handle(Geom_BSplineCurve) C2 = Handle(Geom_BSplineCurve)::DownCast(C); - for(Standard_Integer i = 1; i <= C2->NbPoles(); i++) { - gp_Pnt P = NewPointFrom(C2->Pole(i)); - C2->SetPole(i, P); - } - } - else - if(TheTypeC == STANDARD_TYPE(Geom_BezierCurve)) { - Handle(Geom_BezierCurve) C2 = Handle(Geom_BezierCurve)::DownCast(C); - for(Standard_Integer i = 1; i <= C2->NbPoles(); i++) { - gp_Pnt P = NewPointFrom(C2->Pole(i)); - C2->SetPole(i, P); - } - } - else { - throw Standard_NoSuchObject("BRepTools_HullTransformation : Pb no BSpline/Bezier Type Curve"); - } + C = Handle(Geom_Curve)::DownCast(C->Copy()->Transformed(L.Transformation())); + Handle(Standard_Type) TheTypeC = C->DynamicType(); + if (TheTypeC != STANDARD_TYPE(Geom_BSplineCurve)) + { + throw Standard_NoSuchObject("BRepTools_HullTransformation : Not BSpline Type of Curve"); } + + Handle(Geom_BSplineCurve) C2 = Handle(Geom_BSplineCurve)::DownCast(C); + C2->Segment(f, l); + for(Standard_Integer i = 1; i <= C2->NbPoles(); i++) + { + gp_Pnt P = NewPointFrom(C2->Pole(i)); + C2->SetPole(i, P); + } + L.Identity(); return Standard_True; } -- 2.39.5