From: nbv Date: Fri, 1 Apr 2016 11:54:12 +0000 (+0300) Subject: 0027325: [Regression to 6.9.1] geom/revolution_00/A1: BOPTools_AlgoTools2D::AttachExi... X-Git-Tag: V7_0_0~6 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=6ca1c7466b6d2a7fe98d25154acb757e0fd061f0 0027325: [Regression to 6.9.1] geom/revolution_00/A1: BOPTools_AlgoTools2D::AttachExistingPCurve doesn't work 1. Check, if edge is same-range, is now made with some tolerance (not strictly) in GeomLib_CheckCurveOnSurface class. Default value of this tolerance is Precision::PConfusion(). However, this value can be changed with corresponding interface. 2. DRAW-command "attachpcurve" has been added to BOPTest_UtilityCommands.cxx file. This command creates p-curve of given edge on given face. It can assign 2D-curve of one of the edge already included in the face or (if it is not possible) rebuilds new 2D-curve. Creation of test case for this issue. Adjusting test case boolean volumemaker A8 according to its new behavior on Windows. --- diff --git a/src/BOPTest/BOPTest.cxx b/src/BOPTest/BOPTest.cxx index 429ddde3d0..2055ddb5c3 100644 --- a/src/BOPTest/BOPTest.cxx +++ b/src/BOPTest/BOPTest.cxx @@ -44,6 +44,7 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands) BOPTest::HistoryCommands (theCommands); BOPTest::DebugCommands (theCommands); BOPTest::CellsCommands (theCommands); + BOPTest::UtilityCommands (theCommands); } //======================================================================= //function : Factory diff --git a/src/BOPTest/BOPTest.hxx b/src/BOPTest/BOPTest.hxx index bfded0a47d..df17232bc4 100644 --- a/src/BOPTest/BOPTest.hxx +++ b/src/BOPTest/BOPTest.hxx @@ -58,7 +58,9 @@ public: Standard_EXPORT static void DebugCommands (Draw_Interpretor& aDI); Standard_EXPORT static void CellsCommands (Draw_Interpretor& aDI); - + + Standard_EXPORT static void UtilityCommands (Draw_Interpretor& aDI); + protected: diff --git a/src/BOPTest/BOPTest_UtilityCommands.cxx b/src/BOPTest/BOPTest_UtilityCommands.cxx new file mode 100644 index 0000000000..970fb105e6 --- /dev/null +++ b/src/BOPTest/BOPTest_UtilityCommands.cxx @@ -0,0 +1,104 @@ +// Created on: 2016-04-01 +// Created by: Nikolai BUKHALOV +// Copyright (c) 2000-2016 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 +#include + +static Standard_Integer attachpcurve (Draw_Interpretor&, Standard_Integer, const char**); + + + +//======================================================================= +//function : BOPCommands +//purpose : +//======================================================================= + void BOPTest::UtilityCommands(Draw_Interpretor& theCommands) +{ + static Standard_Boolean done = Standard_False; + if (done) return; + done = Standard_True; + // Chapter's name + const char* group = "BOPTest commands"; + // Commands + + theCommands.Add("attachpcurve", "attachpcurve eold enew face", __FILE__, attachpcurve, group); +} + +//======================================================================= +//function : BOPCommands +//purpose : Attaches p-curve of the given edge to the given face. +//======================================================================= +static Standard_Integer attachpcurve(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char ** theArgVal) +{ + if (theNArg != 4) + { + theDI << "Use: " << theArgVal[0] << " eold enew face\n"; + return 1; + } + + TopoDS_Shape aShEOld(DBRep::Get(theArgVal[1])); + TopoDS_Shape aShENew(DBRep::Get(theArgVal[2])); + TopoDS_Shape aShFace(DBRep::Get(theArgVal[3])); + + if (aShEOld.IsNull()) { + theDI << theArgVal[1] << " is null shape\n"; + return 1; + } else if (aShEOld.ShapeType() != TopAbs_EDGE) { + theDI << theArgVal[1] << " is not an edge\n"; + return 1; + } + + if (aShENew.IsNull()) { + theDI << theArgVal[2] << " is null shape\n"; + return 1; + } else if (aShENew.ShapeType() != TopAbs_EDGE) { + theDI << theArgVal[2] << " is not an edge\n"; + return 1; + } + + if (aShFace.IsNull()) { + theDI << theArgVal[3] << " is null shape\n"; + return 1; + } else if (aShFace.ShapeType() != TopAbs_FACE) { + theDI << theArgVal[3] << " is not a face\n"; + return 1; + } + + TopoDS_Edge aEOld = TopoDS::Edge(aShEOld); + TopoDS_Edge aENew = TopoDS::Edge(aShENew); + TopoDS_Face aFace = TopoDS::Face(aShFace); + + // Try to copy PCurve from old edge to the new one. + Handle(IntTools_Context) aCtx = new IntTools_Context; + const Standard_Integer iRet = + BOPTools_AlgoTools2D::AttachExistingPCurve(aEOld, aENew, aFace, aCtx); + + if (iRet) { + theDI << "Error! Code: " << iRet << "\n"; + } else { + theDI << "PCurve is attached successfully\n"; + } + + return 0; +} diff --git a/src/BOPTest/FILES b/src/BOPTest/FILES index 8b8155711b..4895c625c8 100755 --- a/src/BOPTest/FILES +++ b/src/BOPTest/FILES @@ -15,3 +15,4 @@ BOPTest_TolerCommands.cxx BOPTest_HistoryCommands.cxx BOPTest_DebugCommands.cxx BOPTest_CellsCommands.cxx +BOPTest_UtilityCommands.cxx \ No newline at end of file diff --git a/src/BOPTools/BOPTools_AlgoTools2D_1.cxx b/src/BOPTools/BOPTools_AlgoTools2D_1.cxx index 14b04d0c04..667db5c536 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D_1.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D_1.cxx @@ -114,7 +114,7 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve Handle(Geom_Surface) aSF = BRep_Tool::Surface(aF); // bComp = IntTools_Tools::ComputeTolerance - (aCE1, aC2DT, aSF, aT11, aT12, aTolSP, aTMax); + (aCE1, aC2DT, aSF, aT11, aT12, aTolSP, aTMax, aTolPPC); if (!bComp) { iRet = 3; return iRet; diff --git a/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx b/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx index 1fde4f57fa..7f8c8a8ae6 100644 --- a/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx +++ b/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx @@ -310,7 +310,8 @@ GeomLib_CheckCurveOnSurface::GeomLib_CheckCurveOnSurface() myLast(0.), myErrorStatus(0), myMaxDistance(RealLast()), - myMaxParameter(0.) + myMaxParameter(0.), + myTolRange(Precision::PConfusion()) { } @@ -322,14 +323,16 @@ GeomLib_CheckCurveOnSurface:: GeomLib_CheckCurveOnSurface(const Handle(Geom_Curve)& theCurve, const Handle(Geom_Surface)& theSurface, const Standard_Real theFirst, - const Standard_Real theLast): + const Standard_Real theLast, + const Standard_Real theTolRange): myCurve(theCurve), mySurface(theSurface), myFirst(theFirst), myLast(theLast), myErrorStatus(0), myMaxDistance(RealLast()), - myMaxParameter(0.) + myMaxParameter(0.), + myTolRange(theTolRange) { } @@ -346,6 +349,7 @@ void GeomLib_CheckCurveOnSurface::Init() myErrorStatus = 0; myMaxDistance = RealLast(); myMaxParameter = 0.0; + myTolRange = Precision::PConfusion(); } //======================================================================= @@ -355,7 +359,8 @@ void GeomLib_CheckCurveOnSurface::Init() void GeomLib_CheckCurveOnSurface::Init( const Handle(Geom_Curve)& theCurve, const Handle(Geom_Surface)& theSurface, const Standard_Real theFirst, - const Standard_Real theLast) + const Standard_Real theLast, + const Standard_Real theTolRange) { myCurve = theCurve; mySurface = theSurface; @@ -364,13 +369,13 @@ void GeomLib_CheckCurveOnSurface::Init( const Handle(Geom_Curve)& theCurve, myErrorStatus = 0; myMaxDistance = RealLast(); myMaxParameter = 0.0; + myTolRange = theTolRange; } //======================================================================= //function : Perform //purpose : //======================================================================= - #ifndef HAVE_TBB //After fixing bug # 26365, this fragment should be deleted //(together the text "#ifdef HAVE_TBB") @@ -392,10 +397,10 @@ void GeomLib_CheckCurveOnSurface::Perform(const Handle(Geom2d_Curve)& thePCurve, return; } - if( (myCurve->FirstParameter() > myFirst) || - (myCurve->LastParameter() < myLast) || - (thePCurve->FirstParameter() > myFirst) || - (thePCurve->LastParameter() < myLast)) + if(((myCurve->FirstParameter() - myFirst) > myTolRange) || + ((myCurve->LastParameter() - myLast) < -myTolRange) || + ((thePCurve->FirstParameter() - myFirst) > myTolRange) || + ((thePCurve->LastParameter() - myLast) < -myTolRange)) { myErrorStatus = 2; return; diff --git a/src/GeomLib/GeomLib_CheckCurveOnSurface.hxx b/src/GeomLib/GeomLib_CheckCurveOnSurface.hxx index f0ff6ad24b..d33d6d6d28 100644 --- a/src/GeomLib/GeomLib_CheckCurveOnSurface.hxx +++ b/src/GeomLib/GeomLib_CheckCurveOnSurface.hxx @@ -16,6 +16,7 @@ #define _GeomLib_CheckCurveOnSurface_HeaderFile #include +#include #include class Geom_Surface; @@ -33,16 +34,20 @@ public: Standard_EXPORT GeomLib_CheckCurveOnSurface(void); //! Contructor - Standard_EXPORT GeomLib_CheckCurveOnSurface(const Handle(Geom_Curve)& theCurve, - const Handle(Geom_Surface)& theSurface, - const Standard_Real theFirst, - const Standard_Real theLast); + Standard_EXPORT + GeomLib_CheckCurveOnSurface(const Handle(Geom_Curve)& theCurve, + const Handle(Geom_Surface)& theSurface, + const Standard_Real theFirst, + const Standard_Real theLast, + const Standard_Real theTolRange = + Precision::PConfusion()); //! Sets the data for the algorithm Standard_EXPORT void Init (const Handle(Geom_Curve)& theCurve, const Handle(Geom_Surface)& theSurface, const Standard_Real theFirst, - const Standard_Real theLast); + const Standard_Real theLast, + const Standard_Real theTolRange = Precision::PConfusion()); //! Initializes all members by dafault values Standard_EXPORT void Init(); @@ -112,6 +117,7 @@ private: Standard_Integer myErrorStatus; Standard_Real myMaxDistance; Standard_Real myMaxParameter; + Standard_Real myTolRange; }; #endif // _BRepLib_CheckCurveOnSurface_HeaderFile diff --git a/src/IntTools/IntTools_Tools.cxx b/src/IntTools/IntTools_Tools.cxx index 21a029aad1..9a3c1123aa 100644 --- a/src/IntTools/IntTools_Tools.cxx +++ b/src/IntTools/IntTools_Tools.cxx @@ -787,11 +787,12 @@ Standard_Boolean IntTools_Tools::ComputeTolerance const Standard_Real theFirst, const Standard_Real theLast, Standard_Real& theMaxDist, - Standard_Real& theMaxPar) + Standard_Real& theMaxPar, + const Standard_Real theTolRange) { GeomLib_CheckCurveOnSurface aCS; // - aCS.Init(theCurve3D, theSurf, theFirst, theLast); + aCS.Init(theCurve3D, theSurf, theFirst, theLast, theTolRange); aCS.Perform(theCurve2D); if (!aCS.IsDone()) { return Standard_False; diff --git a/src/IntTools/IntTools_Tools.hxx b/src/IntTools/IntTools_Tools.hxx index 7fbf7d338a..8e465362c6 100644 --- a/src/IntTools/IntTools_Tools.hxx +++ b/src/IntTools/IntTools_Tools.hxx @@ -25,6 +25,7 @@ #include #include #include +#include class TopoDS_Vertex; class TopoDS_Wire; class TopoDS_Face; @@ -160,7 +161,16 @@ public: //! Computes the max distance between points //! taken from 3D and 2D curves by the same parameter - Standard_EXPORT static Standard_Boolean ComputeTolerance (const Handle(Geom_Curve)& theCurve3D, const Handle(Geom2d_Curve)& theCurve2D, const Handle(Geom_Surface)& theSurf, const Standard_Real theFirst, const Standard_Real theLast, Standard_Real& theMaxDist, Standard_Real& theMaxPar); + Standard_EXPORT static + Standard_Boolean ComputeTolerance(const Handle(Geom_Curve)& theCurve3D, + const Handle(Geom2d_Curve)& theCurve2D, + const Handle(Geom_Surface)& theSurf, + const Standard_Real theFirst, + const Standard_Real theLast, + Standard_Real& theMaxDist, + Standard_Real& theMaxPar, + const Standard_Real theTolRange = + Precision::PConfusion()); //! Computes the correct Intersection range for diff --git a/tests/boolean/volumemaker/A8 b/tests/boolean/volumemaker/A8 index 9cd6af9838..da27bbdc69 100644 --- a/tests/boolean/volumemaker/A8 +++ b/tests/boolean/volumemaker/A8 @@ -1,7 +1,7 @@ # test script on make volume operation # plane sphere -puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO OCC26020 Linux: Faulty shapes in variables faulty_1 to faulty_" puts "TODO OCC26020 ALL: Error: bopcheck failed" puts "TODO OCC26020 ALL: Error : The area of result shape is" diff --git a/tests/bugs/modalg_6/bug27325 b/tests/bugs/modalg_6/bug27325 new file mode 100644 index 0000000000..2c3f19e399 --- /dev/null +++ b/tests/bugs/modalg_6/bug27325 @@ -0,0 +1,22 @@ + puts "============" +puts "OCC27325" +puts "============" +puts "" +############################### +## [Regression to 6.9.1] geom/revolution_00/A1: BOPTools_AlgoTools2D::AttachExistingPCurve doesn't work +############################### + +restore [locate_data_file bug27325_edge.brep] en +restore [locate_data_file bug27325_face.brep] f +explode f e +attachpcurve f_3 en f + +#Check attached p-curve +pcurve result en f +#whatis result +set ind [string first "2d curve" [whatis result]] +if {${ind} < 0} { + puts "Error: PCurve has not been attached" +} else { + dump result +} \ No newline at end of file