From 79512f8c25ce4cd1f85581b45d62d1cf4c729ea1 Mon Sep 17 00:00:00 2001 From: ika Date: Tue, 18 Jul 2023 13:45:51 +0100 Subject: [PATCH] Hull transformation draft. Implement the hull transformation API. Implement the test DRAW method to call the API. --- src/BRepBuilderAPI/BRepBuilderAPI.hxx | 2 + .../BRepBuilderAPI_HullTransform.cxx | 120 ++++++++ .../BRepBuilderAPI_HullTransform.hxx | 72 +++++ src/BRepBuilderAPI/FILES | 2 + src/BRepTest/BRepTest_BasicCommands.cxx | 111 ++++++++ src/BRepTools/BRepTools.hxx | 2 + .../BRepTools_HullTransformation.cxx | 264 ++++++++++++++++++ .../BRepTools_HullTransformation.hxx | 137 +++++++++ src/BRepTools/FILES | 2 + 9 files changed, 712 insertions(+) create mode 100644 src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.cxx create mode 100644 src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.hxx create mode 100644 src/BRepTools/BRepTools_HullTransformation.cxx create mode 100644 src/BRepTools/BRepTools_HullTransformation.hxx diff --git a/src/BRepBuilderAPI/BRepBuilderAPI.hxx b/src/BRepBuilderAPI/BRepBuilderAPI.hxx index f9c72e0fc5..8e58f33afd 100644 --- a/src/BRepBuilderAPI/BRepBuilderAPI.hxx +++ b/src/BRepBuilderAPI/BRepBuilderAPI.hxx @@ -39,6 +39,7 @@ class BRepBuilderAPI_ModifyShape; class BRepBuilderAPI_Transform; class BRepBuilderAPI_NurbsConvert; class BRepBuilderAPI_GTransform; +class BRepBuilderAPI_HullTransform; class BRepBuilderAPI_Copy; class BRepBuilderAPI_Collect; @@ -151,6 +152,7 @@ friend class BRepBuilderAPI_ModifyShape; friend class BRepBuilderAPI_Transform; friend class BRepBuilderAPI_NurbsConvert; friend class BRepBuilderAPI_GTransform; +friend class BRepBuilderAPI_HullTransform; friend class BRepBuilderAPI_Copy; friend class BRepBuilderAPI_Collect; diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.cxx b/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.cxx new file mode 100644 index 0000000000..1f7fa2388d --- /dev/null +++ b/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.cxx @@ -0,0 +1,120 @@ +// Created on: 2023-07-07 +// Created by: Irina KOCHETKOVA +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + + +#include +#include +#include + +//======================================================================= +//function : BRepBuilderAPI_HullTransform +//purpose : +//======================================================================= +BRepBuilderAPI_HullTransform::BRepBuilderAPI_HullTransform () +{ + myModification = new BRepTools_HullTransformation(); +} + +//======================================================================= +//function : InitLinear +//purpose : +//======================================================================= +void BRepBuilderAPI_HullTransform::InitLinear(const double theCM, + const double theCBNew, + const double theCBOld, + const double theLPP) +{ + Handle(BRepTools_HullTransformation) aHullTrsf = Handle(BRepTools_HullTransformation)::DownCast(myModification); + aHullTrsf->InitLinear(theCM, theCBNew, theCBOld, theLPP); +} + +//======================================================================= +//function : InitQuad +//purpose : +//======================================================================= +void BRepBuilderAPI_HullTransform::InitQuad(const double theAftlim, + const double theCCA, + const double theCCF, + const double theForelim, + const double theAftCoef, + const double theForeCoef, + const bool theModifyAftZone, + const bool theModifyForeZone) +{ + Handle(BRepTools_HullTransformation) aHullTrsf = Handle(BRepTools_HullTransformation)::DownCast(myModification); + aHullTrsf->InitQuad(theAftlim, theCCA, theCCF, theForelim, theAftCoef, theForeCoef, theModifyAftZone, theModifyForeZone); +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void BRepBuilderAPI_HullTransform::Perform(const TopoDS_Shape& S, + const Standard_Boolean Copy) +{ + BRepBuilderAPI_NurbsConvert nc; + nc.Perform(S, Copy); + myHist.Add(S,nc); + TopoDS_Shape Slocal = nc.Shape(); + Handle(BRepTools_HullTransformation) theModif = + Handle(BRepTools_HullTransformation)::DownCast(myModification); + DoModif(Slocal,myModification); +} + + +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + +const TopTools_ListOfShape& BRepBuilderAPI_HullTransform::Modified + (const TopoDS_Shape& F) +{ + myGenerated.Clear(); + const TopTools_DataMapOfShapeListOfShape& M = myHist.Modification(); + if (M.IsBound(F)) { + TopTools_ListOfShape Li; + TopTools_ListIteratorOfListOfShape itL(M(F)); + for (;itL.More();itL.Next()) + Li.Assign(BRepBuilderAPI_ModifyShape::Modified(itL.Value())); + } + return myGenerated; +} + + +//======================================================================= +//function : ModifiedShape +//purpose : +//======================================================================= + +TopoDS_Shape BRepBuilderAPI_HullTransform::ModifiedShape + (const TopoDS_Shape& S) const +{ + const TopTools_DataMapOfShapeListOfShape &aMapModif = myHist.Modification(); + TopoDS_Shape aShape = S; + + if (aMapModif.IsBound(S)) { + const TopTools_ListOfShape &aListModShape = aMapModif(S); + Standard_Integer aNbShapes = aListModShape.Extent(); + + if (aNbShapes > 0) + aShape = aListModShape.First(); + } + + return BRepBuilderAPI_ModifyShape::ModifiedShape(aShape); +} + diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.hxx b/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.hxx new file mode 100644 index 0000000000..f2fb5d9a18 --- /dev/null +++ b/src/BRepBuilderAPI/BRepBuilderAPI_HullTransform.hxx @@ -0,0 +1,72 @@ +// Created on: 2023-07-07 +// Created by: Irina KOCHETKOVA +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _BRepBuilderAPI_HullTransform_HeaderFile +#define _BRepBuilderAPI_HullTransform_HeaderFile + +#include +#include + +//! Custom geometric transformation on a shape. +class BRepBuilderAPI_HullTransform : public BRepBuilderAPI_ModifyShape +{ +public: + + DEFINE_STANDARD_ALLOC + + + //! Constructs a framework for applying the geometric + //! transformation to a shape. + //! Use InitLinear/InitQuad to define transformation parameters. + //! After that use Perform to define the shape to transform and do the modification. + Standard_EXPORT BRepBuilderAPI_HullTransform(); + + //! Initialize parameters for linear transformation function. + Standard_EXPORT void InitLinear(const double theCM, + const double theCBNew, + const double theCBOld, + const double theLPP); + + //! Initialize parameters for quad transformation function. + Standard_EXPORT void InitQuad(const double theAftlim, + const double theCCA, + const double theCCF, + const double theForelim, + const double theAftCoef, + const double theForeCoef, + const bool theModifyAftZone, + const bool theModifyForeZone); + + //! Applies the geometric transformation defined at the + //! time of construction of this framework to the shape S. + //! The transformation will applied to a duplicate of S. + //! Use the function Shape to access the result. + //! Note: this framework can be reused to apply the same + //! geometric transformation to other shapes: just specify + //! them by calling the function Perform again. + Standard_EXPORT void Perform (const TopoDS_Shape& S, const Standard_Boolean Copy = Standard_True); + + //! Returns the list of shapes modified from the shape + //! . + Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE; + + //! Returns the modified shape corresponding to . + Standard_EXPORT virtual TopoDS_Shape ModifiedShape (const TopoDS_Shape& S) const Standard_OVERRIDE; + +private: + + BRepBuilderAPI_Collect myHist; +}; +#endif // _BRepBuilderAPI_HullTransform_HeaderFile diff --git a/src/BRepBuilderAPI/FILES b/src/BRepBuilderAPI/FILES index 4cd5112637..aa7726ff96 100644 --- a/src/BRepBuilderAPI/FILES +++ b/src/BRepBuilderAPI/FILES @@ -16,6 +16,8 @@ BRepBuilderAPI_FindPlane.cxx BRepBuilderAPI_FindPlane.hxx BRepBuilderAPI_GTransform.cxx BRepBuilderAPI_GTransform.hxx +BRepBuilderAPI_HullTransform.cxx +BRepBuilderAPI_HullTransform.hxx BRepBuilderAPI_MakeEdge.cxx BRepBuilderAPI_MakeEdge.hxx BRepBuilderAPI_MakeEdge2d.cxx diff --git a/src/BRepTest/BRepTest_BasicCommands.cxx b/src/BRepTest/BRepTest_BasicCommands.cxx index d12d9da8f1..e5bc0c524f 100644 --- a/src/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/BRepTest/BRepTest_BasicCommands.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,13 @@ #include +#include +#include +#include +#include +#include +#include + #include Standard_IMPORT Draw_Viewer dout; @@ -1389,6 +1397,101 @@ static Standard_Integer issubshape(Draw_Interpretor& di, return 0; } +///======================================================================= +// hulltrsf +//======================================================================= +static Standard_Integer hulltrsf(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + 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 << "[-s XCoord_section1 ... XCoord_sectionN]\n"; + return 1; + } + + TopoDS_Shape S = DBRep::Get(a[2]); + if (S.IsNull()) { + di << a[2] << " is not a valid shape\n"; + return 0; + } + BRepBuilderAPI_HullTransform aHTrsf; + std::list aSections; + int i = 3; + while (i < n) + { + if (a[i][0] == '-' && a[i][1] == 'l' && n > i + 4) + { + // init linear transformation parameters + double _cm = Atof(a[i + 1]); + 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); + i += 4; + } + if (a[i][0] == '-' && a[i][1] == 'q' && n > i+8) + { + // init quad transformation parameters + double _aftlim = Atof(a[i + 1]); + double _cca = Atof(a[i + 2]); + double _ccf = Atof(a[i + 3]); + double _forelim = Atof(a[i + 4]); + double _aft_coef = Atof(a[i + 5]); + double _fore_coef = Atof(a[i + 6]); + bool _modify_aft_zone = (Draw::Atoi(a[i + 7]) == 1); + bool _modify_fore_zone = (Draw::Atoi(a[i + 8]) == 1); + aHTrsf.InitQuad(_aftlim, _cca, _ccf, _forelim, _aft_coef, _fore_coef, _modify_aft_zone, _modify_fore_zone); + i += 8; + } + if (a[i][0] == '-' && a[i][1] == 's') + { + i++; + while (i < n) + { + aSections.push_back(Atof(a[i])); + i++; + } + } + i++; + } + if (aSections.size() > 0) + { + // Add splitting edges + TopTools_ListOfShape aLSObjects; + aLSObjects.Append(S); + TopTools_ListOfShape aLSTools; + for each (double aPlaneX in aSections) + { + Handle(Geom_Plane) aPlane = new Geom_Plane(gp_Pnt(aPlaneX, 0, 0), gp_Dir(1, 0, 0)); + TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(aPlane, -1000, 1000, -1000, 1000, Precision::Confusion()); + aLSTools.Append(aFace); + } + + BOPAlgo_Splitter pSplitter; + pSplitter.Clear(); + pSplitter.SetArguments(aLSObjects); + pSplitter.SetTools(aLSTools); + pSplitter.Perform(); + S = pSplitter.Shape(); + } + + // Perform transformation + aHTrsf.Perform(S, true); + if (aHTrsf.IsDone()) { + // Fix shape + Handle(ShapeFix_Shape) aShapeFixTool = new ShapeFix_Shape; + aShapeFixTool->Init(aHTrsf.Shape()); + aShapeFixTool->Perform(); + DBRep::Set(a[1], aShapeFixTool->Shape()); + } + else { + return 1; + } + + return 0; +} + void BRepTest::BasicCommands(Draw_Interpretor& theCommands) { static Standard_Boolean done = Standard_False; @@ -1552,6 +1655,14 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) "deform newname name CoeffX CoeffY CoeffZ", __FILE__, deform,g); + + 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 " + "[-s XCoord_section1 ... XCoord_sectionN] to add sections\n", + __FILE__, + hulltrsf, g); theCommands.Add("findplane", "findplane name planename ", diff --git a/src/BRepTools/BRepTools.hxx b/src/BRepTools/BRepTools.hxx index 6fd63e66c9..7b4c0a142a 100644 --- a/src/BRepTools/BRepTools.hxx +++ b/src/BRepTools/BRepTools.hxx @@ -46,6 +46,7 @@ class BRepTools_Modifier; class BRepTools_TrsfModification; class BRepTools_NurbsConvertModification; class BRepTools_GTrsfModification; +class BRepTools_HullTransformation; class BRepTools_Substitution; class BRepTools_Quilt; class BRepTools_ShapeSet; @@ -269,6 +270,7 @@ friend class BRepTools_Modifier; friend class BRepTools_TrsfModification; friend class BRepTools_NurbsConvertModification; friend class BRepTools_GTrsfModification; +friend class BRepTools_HullTransformation; friend class BRepTools_Substitution; friend class BRepTools_Quilt; friend class BRepTools_ShapeSet; diff --git a/src/BRepTools/BRepTools_HullTransformation.cxx b/src/BRepTools/BRepTools_HullTransformation.cxx new file mode 100644 index 0000000000..836fc5c905 --- /dev/null +++ b/src/BRepTools/BRepTools_HullTransformation.cxx @@ -0,0 +1,264 @@ +// Created on: 2023-07-07 +// Created by: Irina KOCHETKOVA +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + + +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(BRepTools_HullTransformation,BRepTools_Modification) + +//======================================================================= +//function : BRepTools_HullTransformation +//purpose : +//======================================================================= +BRepTools_HullTransformation::BRepTools_HullTransformation() +{ +} + +//======================================================================= +//function : InitLinear +//purpose : +//======================================================================= +void BRepTools_HullTransformation::InitLinear(const double theCM, + const double theCBNew, + const double theCBOld, + const double theLPP) +{ + myLinear = true; + _cm = theCM; + _cb_new = theCBNew; + _cb_old = theCBOld; + _lpp = theLPP; + myScale = (_cm - _cb_new) / (_cm - _cb_old); +} + +//======================================================================= +//function : InitQuad +//purpose : +//======================================================================= +void BRepTools_HullTransformation::InitQuad(const double theAftlim, + const double theCCA, + const double theCCF, + const double theForelim, + const double theAftCoef, + const double theForeCoef, + const bool theModifyAftZone, + const bool theModifyForeZone) +{ + myLinear = false; + + _aftlim = theAftlim; + _cca = theCCA; + _ccf = theCCF; + _forelim = theForelim; + _aft_coef = theAftCoef; + _fore_coef = theForeCoef; + _modify_aft_zone = theModifyAftZone; + _modify_fore_zone = theModifyForeZone; + + myScale = 1; +} + + +//======================================================================= +//function : NewPointFrom +//purpose : +//======================================================================= +gp_Pnt BRepTools_HullTransformation::NewPointFrom(const gp_Pnt& theOldPoint) +{ + Standard_Real oldX = theOldPoint.X(); + Standard_Real newX = _lpp / 2; + Standard_Real incrX = 0; + + if (myLinear) + { + if (oldX <= _lpp / 2) + { + newX = oldX * (_cm - _cb_new) / (_cm - _cb_old); + if (newX > _lpp / 2) + newX = _lpp / 2; + } + else if (oldX > _lpp / 2) + { + newX = oldX * (_cm - _cb_new) / (_cm - _cb_old) + + _lpp * (_cb_new - _cb_old) / (_cm - _cb_old); + if (newX < _lpp / 2) { + newX = _lpp / 2; + } + } + } + else + { + if (_modify_aft_zone && // Aft + oldX >= _aftlim && oldX <= _cca) + { + incrX = _aft_coef * (oldX - _aftlim)*(oldX - _cca); + } + + else if (_modify_fore_zone && // Fore + oldX >= _ccf && oldX <= _forelim) + { + incrX = _fore_coef * (oldX - _ccf)*(oldX - _forelim); + } + newX = oldX + incrX; + } + + return gp_Pnt(newX, theOldPoint.Y(), theOldPoint.Z()); +} + +//======================================================================= +//function : NewSurface +//purpose : +//======================================================================= +Standard_Boolean BRepTools_HullTransformation::NewSurface(const TopoDS_Face& F, + Handle(Geom_Surface)& S, + TopLoc_Location& L, + Standard_Real& Tol, + Standard_Boolean& RevWires, + Standard_Boolean& RevFace) +{ + S = Handle(Geom_Surface)::DownCast(BRep_Tool::Surface(F,L)->Copy()); + + Tol = BRep_Tool::Tolerance(F); + Tol *= myScale; + RevWires = Standard_False; + RevFace = (myScale > 0); + S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation())); + + 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); + } + } + 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"); + } + + L.Identity(); + return Standard_True; +} + +//======================================================================= +//function : NewCurve +//purpose : +//======================================================================= +Standard_Boolean BRepTools_HullTransformation::NewCurve(const TopoDS_Edge& E, + Handle(Geom_Curve)& C, + TopLoc_Location& L, + Standard_Real& Tol) +{ + Standard_Real f,l; + Tol = BRep_Tool::Tolerance(E) * myScale; + C = BRep_Tool::Curve(E, L, f, l); + + 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"); + } + } + L.Identity(); + return Standard_True; +} + +//======================================================================= +//function : NewPoint +//purpose : +//======================================================================= +Standard_Boolean BRepTools_HullTransformation::NewPoint(const TopoDS_Vertex& V, + gp_Pnt& P, + Standard_Real& Tol) +{ + gp_Pnt Pnt = BRep_Tool::Pnt(V); + Tol = BRep_Tool::Tolerance(V); + Tol *= myScale; + P = NewPointFrom(Pnt); + + return Standard_True; +} + +//======================================================================= +//function : NewCurve2d +//purpose : +//======================================================================= +Standard_Boolean BRepTools_HullTransformation::NewCurve2d(const TopoDS_Edge&, + const TopoDS_Face&, + const TopoDS_Edge&, + const TopoDS_Face&, + Handle(Geom2d_Curve)&, + Standard_Real& ) +{ + return Standard_False; +} + +//======================================================================= +//function : NewParameter +//purpose : +//======================================================================= +Standard_Boolean BRepTools_HullTransformation::NewParameter(const TopoDS_Vertex&, + const TopoDS_Edge&, + Standard_Real&, + Standard_Real&) +{ + return Standard_False; +} + +//======================================================================= +//function : Continuity +//purpose : +//======================================================================= +GeomAbs_Shape BRepTools_HullTransformation::Continuity(const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const TopoDS_Edge&, + const TopoDS_Face&, + const TopoDS_Face&) +{ + return BRep_Tool::Continuity(E,F1,F2); +} diff --git a/src/BRepTools/BRepTools_HullTransformation.hxx b/src/BRepTools/BRepTools_HullTransformation.hxx new file mode 100644 index 0000000000..1f6d6a87f9 --- /dev/null +++ b/src/BRepTools/BRepTools_HullTransformation.hxx @@ -0,0 +1,137 @@ +// Created on: 2023-07-07 +// Created by: Irina KOCHETKOVA +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _BRepTools_HullTransformation_HeaderFile +#define _BRepTools_HullTransformation_HeaderFile + +#include +//class gp_GTrsf; +//class TopoDS_Face; +//class Geom_Surface; +//class TopLoc_Location; +//class TopoDS_Edge; +//class Geom_Curve; +//class TopoDS_Vertex; +//class gp_Pnt; +//class Geom2d_Curve; + + +class BRepTools_HullTransformation; +DEFINE_STANDARD_HANDLE(BRepTools_HullTransformation, BRepTools_Modification) + +//! Defines a modification of the geometry by a custom function. +//! All methods return True and transform the geometry. +class BRepTools_HullTransformation : public BRepTools_Modification +{ + +public: + + + Standard_EXPORT BRepTools_HullTransformation(); + + //! Calculate a new point's position. + Standard_EXPORT gp_Pnt NewPointFrom(const gp_Pnt& theOldP); + + //! Returns Standard_True if the face has been + //! modified. In this case, is the new geometric + //! support of the face, the new location, + //! the new tolerance. has to be set to + //! Standard_True when the modification reverses the + //! normal of the surface.(the wires have to be + //! reversed). has to be set to + //! Standard_True if the orientation of the modified + //! face changes in the shells which contain it. -- + //! Here, will return Standard_True if the + //! -- gp_Trsf is negative. + Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& Tol, Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE; + + //! Returns Standard_True if the edge has been + //! modified. In this case, is the new geometric + //! support of the edge, the new location, + //! the new tolerance. Otherwise, returns + //! Standard_False, and , , are not + //! significant. + Standard_EXPORT Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C, TopLoc_Location& L, Standard_Real& Tol) Standard_OVERRIDE; + + //! Returns Standard_True if the vertex has been + //! modified. In this case,

is the new geometric + //! support of the vertex, the new tolerance. + //! Otherwise, returns Standard_False, and

, + //! are not significant. + Standard_EXPORT Standard_Boolean NewPoint (const TopoDS_Vertex& V, gp_Pnt& P, Standard_Real& Tol) Standard_OVERRIDE; + + //! Returns Standard_True if the edge has a new + //! curve on surface on the face .In this case, + //! is the new geometric support of the edge, the + //! new location, the new tolerance. + //! Otherwise, returns Standard_False, and , , + //! are not significant. + Standard_EXPORT Standard_Boolean NewCurve2d (const TopoDS_Edge& E, const TopoDS_Face& F, const TopoDS_Edge& NewE, const TopoDS_Face& NewF, Handle(Geom2d_Curve)& C, Standard_Real& Tol) Standard_OVERRIDE; + + //! Returns Standard_True if the Vertex has a new + //! parameter on the edge . In this case,

is + //! the parameter, the new tolerance. + //! Otherwise, returns Standard_False, and

, + //! are not significant. + Standard_EXPORT Standard_Boolean NewParameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, Standard_Real& P, Standard_Real& Tol) Standard_OVERRIDE; + + //! Returns the continuity of between + //! and . + //! + //! is the new edge created from . + //! (resp. ) is the new face created from + //! (resp. ). + Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE; + + //! Initialize parameters for linear transformation function. + Standard_EXPORT void InitLinear(const double theCM, + const double theCBNew, + const double theCBOld, + const double theLPP); + + //! Initialize parameters for quad transformation function. + Standard_EXPORT void InitQuad(const double theAftlim, + const double theCCA, + const double theCCF, + const double theForelim, + const double theAftCoef, + const double theForeCoef, + const bool theModifyAftZone, + const bool theModifyForeZone); + + DEFINE_STANDARD_RTTIEXT(BRepTools_HullTransformation,BRepTools_Modification) + +private: + + Standard_Real myScale; + bool myLinear; + + double _cm; + double _cb_new; + double _cb_old; + double _lpp; + + double _aftlim; + double _cca; + double _ccf; + double _forelim; + double _aft_coef; + double _fore_coef; + bool _modify_aft_zone; + bool _modify_fore_zone; + +}; + +#endif // _BRepTools_HullTransformation_HeaderFile diff --git a/src/BRepTools/FILES b/src/BRepTools/FILES index bebdc4807e..921473d9b6 100644 --- a/src/BRepTools/FILES +++ b/src/BRepTools/FILES @@ -6,6 +6,8 @@ BRepTools_GTrsfModification.cxx BRepTools_GTrsfModification.hxx BRepTools_History.hxx BRepTools_History.cxx +BRepTools_HullTransformation.cxx +BRepTools_HullTransformation.hxx BRepTools_MapOfVertexPnt2d.hxx BRepTools_Modification.cxx BRepTools_Modification.hxx -- 2.39.5