mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0025597: Invalid curve on surface in the result of General Fuse operation
1. The tool of computing the max distance between 3D curve and its 2d representation on the face has been moved from static methods in BOPTools_AlgoTools class to BRepLib_CheckCurveOnSurface class. 2. The tools has been applied to 2d curves built during Boolean Operation and to some intersection curves. 3. The functions Standard_Boolean BOPTools_AlgoTools::ComputeTolerance (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, Standard_Real& theMaxDist, Standard_Real& theMaxPar) and Standard_Boolean IntTools_Tools::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) have been developed for easy access to BRepLib_CheckCurveOnSurface functionality. class IntTools_FaceFace method void IntTools_FaceFace::ComputeTolReached3d() Case for Plane/BSpline intersection added for treatment. Test case for issue CR25597 Fix for regression boolean bsection N7. class BOPAlgo_PaveFiller method void BOPAlgo_PaveFiller::UpdateFaceInfo (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME, const BOPCol_DataMapOfIntegerInteger& theDMV) Updating Face Info information with new vertices created in PostTreatFF. Correction boolean/bsection/N2 Updated test cases.
This commit is contained in:
@@ -133,6 +133,10 @@ is
|
||||
class FuseEdges;
|
||||
---Purpose:
|
||||
|
||||
class CheckCurveOnSurface;
|
||||
---Purpose:
|
||||
-- Computes the max distance between edge
|
||||
-- and its 2d representation on the face.
|
||||
|
||||
--
|
||||
-- Default precison methods.
|
||||
|
168
src/BRepLib/BRepLib_CheckCurveOnSurface.cdl
Normal file
168
src/BRepLib/BRepLib_CheckCurveOnSurface.cdl
Normal file
@@ -0,0 +1,168 @@
|
||||
-- Created by: Eugeny MALTCHIKOV
|
||||
-- Copyright (c) 2014 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.
|
||||
|
||||
class CheckCurveOnSurface from BRepLib
|
||||
|
||||
---Purpose:
|
||||
-- Computes the max distance between edge and its
|
||||
-- 2d representation on the face.
|
||||
--
|
||||
-- The algorithm can be initialized in the following ways:
|
||||
-- 1. Input args are Edge and Face;
|
||||
-- 2. Input args are 3D curve, 2d curve, Surface and
|
||||
-- parametric range of the curve (first and last values).
|
||||
|
||||
uses
|
||||
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Surface from Geom
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns CheckCurveOnSurface from BRepLib;
|
||||
---Purpose:
|
||||
-- Empty contructor
|
||||
|
||||
Create(
|
||||
theEdge : Edge from TopoDS;
|
||||
theFace : Face from TopoDS);
|
||||
---Purpose:
|
||||
-- Contructor
|
||||
|
||||
Create(
|
||||
theCurve : Curve from Geom;
|
||||
thePCurve : Curve from Geom2d;
|
||||
theSurface : Surface from Geom;
|
||||
theFirst : Real from Standard;
|
||||
theLast : Real from Standard);
|
||||
---Purpose:
|
||||
-- Contructor
|
||||
|
||||
Init(me:out;
|
||||
theEdge : Edge from TopoDS;
|
||||
theFace : Face from TopoDS);
|
||||
---Purpose:
|
||||
-- Sets the data for the algorithm
|
||||
|
||||
Init(me:out;
|
||||
theCurve : Curve from Geom;
|
||||
thePCurve : Curve from Geom2d;
|
||||
theSurface : Surface from Geom;
|
||||
theFirst : Real from Standard;
|
||||
theLast : Real from Standard);
|
||||
---Purpose:
|
||||
-- Sets the data for the algorithm
|
||||
|
||||
Curve(me)
|
||||
returns Curve from Geom;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose:
|
||||
-- Returns my3DCurve
|
||||
|
||||
PCurve(me)
|
||||
returns Curve from Geom2d;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose:
|
||||
-- Returns my2DCurve
|
||||
|
||||
PCurve2(me)
|
||||
returns Curve from Geom2d;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose:
|
||||
-- Returns my2DCurve
|
||||
|
||||
Surface(me)
|
||||
returns Surface from Geom;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose:
|
||||
-- Returns mySurface
|
||||
|
||||
Range(me:out;
|
||||
theFirst : out Real from Standard;
|
||||
theLast : out Real from Standard);
|
||||
---C++: inline
|
||||
---Purpose:
|
||||
-- Returns the range
|
||||
|
||||
-- computations
|
||||
--
|
||||
Perform(me:out);
|
||||
---Purpose:
|
||||
-- Performs the calculation
|
||||
|
||||
CheckData(me:out)
|
||||
is protected;
|
||||
---Purpose:
|
||||
-- Checks the data
|
||||
|
||||
Compute(me:out;
|
||||
thePCurve : Curve from Geom2d)
|
||||
is protected;
|
||||
---Purpose:
|
||||
-- Computes the max distance for the 3d curve <myCurve>
|
||||
-- and 2d curve <thePCurve>
|
||||
|
||||
-- results
|
||||
--
|
||||
IsDone(me)
|
||||
returns Boolean from Standard;
|
||||
---C++: inline
|
||||
---Purpose:
|
||||
-- Returns true if the max distance has been found
|
||||
|
||||
ErrorStatus(me)
|
||||
returns Integer from Standard;
|
||||
---C++: inline
|
||||
---Purpose:
|
||||
-- Returns error status
|
||||
-- The possible values are:
|
||||
-- 0 - OK;
|
||||
-- 1 - null curve or surface or 2d curve;
|
||||
-- 2 - invalid parametric range;
|
||||
-- 3 - error in calculations.
|
||||
|
||||
MaxDistance(me)
|
||||
returns Real from Standard;
|
||||
---C++: inline
|
||||
---Purpose:
|
||||
-- Returns max distance
|
||||
|
||||
MaxParameter(me)
|
||||
returns Real from Standard;
|
||||
---C++: inline
|
||||
---Purpose:
|
||||
-- Returns parameter in which the distance is maximal
|
||||
|
||||
fields
|
||||
-- source data
|
||||
myCurve : Curve from Geom;
|
||||
myPCurve : Curve from Geom2d;
|
||||
myPCurve2 : Curve from Geom2d;
|
||||
mySurface : Surface from Geom;
|
||||
myFirst : Real from Standard;
|
||||
myLast : Real from Standard;
|
||||
-- result
|
||||
myErrorStatus : Integer from Standard;
|
||||
myMaxDistance : Real from Standard;
|
||||
myMaxParameter : Real from Standard;
|
||||
|
||||
end CheckCurveOnSurface;
|
456
src/BRepLib/BRepLib_CheckCurveOnSurface.cxx
Normal file
456
src/BRepLib/BRepLib_CheckCurveOnSurface.cxx
Normal file
@@ -0,0 +1,456 @@
|
||||
// Created by: Eugeny MALTCHIKOV
|
||||
// Copyright (c) 2014 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 <BRepLib_CheckCurveOnSurface.ixx>
|
||||
|
||||
#include <math_GlobOptMin.hxx>
|
||||
#include <math_MultipleVarFunctionWithHessian.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
|
||||
#include <Geom2dAdaptor.hxx>
|
||||
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <GeomAdaptor_HCurve.hxx>
|
||||
|
||||
#include <GeomProjLib.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_CurveRepresentation.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
#include <ProjLib_ProjectedCurve.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//class : BRepLib_CheckCurveOnSurface_GlobOptFunc
|
||||
//purpose : provides necessary methods to be used in math_GlobOptMin
|
||||
//=======================================================================
|
||||
class BRepLib_CheckCurveOnSurface_GlobOptFunc :
|
||||
public math_MultipleVarFunctionWithHessian
|
||||
{
|
||||
public:
|
||||
BRepLib_CheckCurveOnSurface_GlobOptFunc
|
||||
(BRepLib_CheckCurveOnSurface_GlobOptFunc&);
|
||||
BRepLib_CheckCurveOnSurface_GlobOptFunc
|
||||
(const Handle(Geom_Curve)& theC3D,
|
||||
const Handle(Geom2d_Curve)& theC2D,
|
||||
const Handle(Geom_Surface)& theSurf,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast)
|
||||
:
|
||||
myCurve(theC3D),
|
||||
myPCurve(theC2D),
|
||||
mySurf(theSurf),
|
||||
myFirst(theFirst),
|
||||
myLast(theLast)
|
||||
{
|
||||
}
|
||||
//
|
||||
virtual Standard_Integer NbVariables() const {
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
virtual Standard_Boolean Value(const math_Vector& theX,
|
||||
Standard_Real& theFVal) {
|
||||
try {
|
||||
const Standard_Real aPar = theX(1);
|
||||
if (!CheckParameter(aPar))
|
||||
return Standard_False;
|
||||
gp_Pnt aP1, aP2;
|
||||
gp_Pnt2d aP2d;
|
||||
//
|
||||
myCurve->D0(aPar, aP1);
|
||||
myPCurve->D0(aPar, aP2d);
|
||||
mySurf->D0(aP2d.X(), aP2d.Y(), aP2);
|
||||
//
|
||||
theFVal = -1.0*aP1.SquareDistance(aP2);
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
return Standard_True;
|
||||
}
|
||||
//
|
||||
virtual Standard_Integer GetStateNumber() {
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
virtual Standard_Boolean Gradient(const math_Vector& theX,
|
||||
math_Vector& theGrad) {
|
||||
try {
|
||||
const Standard_Real aPar = theX(1);
|
||||
if (!CheckParameter(aPar)) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
gp_Pnt aP1, aP2;
|
||||
gp_Vec aDC3D, aDSU, aDSV;
|
||||
gp_Pnt2d aP2d;
|
||||
gp_Vec2d aDC2D;
|
||||
//
|
||||
myCurve->D1(aPar, aP1, aDC3D);
|
||||
myPCurve->D1(aPar, aP2d, aDC2D);
|
||||
mySurf->D1(aP2d.X(), aP2d.Y(), aP2, aDSU, aDSV);
|
||||
//
|
||||
aP1.SetXYZ(aP1.XYZ() - aP2.XYZ());
|
||||
aP2.SetXYZ(aDC3D.XYZ() - aDC2D.X()*aDSU.XYZ() - aDC2D.Y()*aDSV.XYZ());
|
||||
//
|
||||
theGrad(1) = -2.0*aP1.XYZ().Dot(aP2.XYZ());
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
return Standard_True;
|
||||
}
|
||||
//
|
||||
virtual Standard_Boolean Values(const math_Vector& theX,
|
||||
Standard_Real& theVal,
|
||||
math_Vector& theGrad) {
|
||||
if (!Value(theX, theVal)) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
if (!Gradient(theX, theGrad)) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
return Standard_True;
|
||||
}
|
||||
//
|
||||
virtual Standard_Boolean Values(const math_Vector& theX,
|
||||
Standard_Real& theVal,
|
||||
math_Vector& theGrad,
|
||||
math_Matrix& theHessian) {
|
||||
if (!Value(theX, theVal)) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
if (!Gradient(theX, theGrad)) {
|
||||
return Standard_False;
|
||||
}
|
||||
//
|
||||
theHessian(1,1) = theGrad(1);
|
||||
//
|
||||
return Standard_True;
|
||||
}
|
||||
//
|
||||
private:
|
||||
|
||||
Standard_Boolean CheckParameter(const Standard_Real theParam) {
|
||||
return ((myFirst <= theParam) && (theParam <= myLast));
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) myCurve;
|
||||
Handle(Geom2d_Curve) myPCurve;
|
||||
Handle(Geom_Surface) mySurf;
|
||||
Standard_Real myFirst;
|
||||
Standard_Real myLast;
|
||||
};
|
||||
|
||||
static
|
||||
void MinComputing(BRepLib_CheckCurveOnSurface_GlobOptFunc& theFunction,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEpsilon,
|
||||
Standard_Real& theBestValue,
|
||||
Standard_Real& theBestParameter);
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_CheckCurveOnSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface()
|
||||
:
|
||||
myFirst(0.),
|
||||
myLast(0.),
|
||||
myErrorStatus(0),
|
||||
myMaxDistance(0.),
|
||||
myMaxParameter(0.)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_CheckCurveOnSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface
|
||||
(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace)
|
||||
:
|
||||
myErrorStatus(0),
|
||||
myMaxDistance(0.),
|
||||
myMaxParameter(0.)
|
||||
{
|
||||
Init(theEdge, theFace);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_CheckCurveOnSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface
|
||||
(const Handle(Geom_Curve)& the3DCurve,
|
||||
const Handle(Geom2d_Curve)& the2DCurve,
|
||||
const Handle(Geom_Surface)& theSurface,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast)
|
||||
:
|
||||
myErrorStatus(0),
|
||||
myMaxDistance(0.),
|
||||
myMaxParameter(0.)
|
||||
{
|
||||
Init(the3DCurve, the2DCurve, theSurface, theFirst, theLast);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepLib_CheckCurveOnSurface::Init
|
||||
(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace)
|
||||
{
|
||||
if (theEdge.IsNull() || theFace.IsNull()) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (BRep_Tool::Degenerated(theEdge) ||
|
||||
!BRep_Tool::IsGeometric(theEdge)) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Boolean isPCurveFound;
|
||||
TopLoc_Location aLocE, aLocF, aLocC2D;
|
||||
//
|
||||
// 3D curve initialization
|
||||
myCurve = Handle(Geom_Curve)::
|
||||
DownCast(BRep_Tool::Curve(theEdge, aLocE, myFirst, myLast)->Copy());
|
||||
myCurve->Transform(aLocE.Transformation());
|
||||
//
|
||||
// Surface initialization
|
||||
const Handle(Geom_Surface)& aS = BRep_Tool::Surface(theFace, aLocF);
|
||||
mySurface = Handle(Geom_Surface)::
|
||||
DownCast(aS->Copy()->Transformed(aLocF.Transformation()));
|
||||
//
|
||||
// 2D curves initialization
|
||||
isPCurveFound = Standard_False;
|
||||
aLocC2D = aLocF.Predivided(aLocE);
|
||||
const Handle(BRep_TEdge)& aTE = *((Handle(BRep_TEdge)*)&theEdge.TShape());
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(aTE->Curves());
|
||||
//
|
||||
for (; itcr.More(); itcr.Next()) {
|
||||
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
|
||||
if (cr->IsCurveOnSurface(aS, aLocC2D)) {
|
||||
isPCurveFound = Standard_True;
|
||||
myPCurve = cr->PCurve();
|
||||
//
|
||||
if (cr->IsCurveOnClosedSurface()) {
|
||||
myPCurve2 = cr->PCurve2();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (isPCurveFound) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Handle(Geom_Plane) aPlane;
|
||||
Handle(Standard_Type) dtyp = mySurface->DynamicType();
|
||||
//
|
||||
if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
|
||||
aPlane = Handle(Geom_Plane)::
|
||||
DownCast(Handle(Geom_RectangularTrimmedSurface)::
|
||||
DownCast(mySurface)->BasisSurface()->Copy());
|
||||
}
|
||||
else {
|
||||
aPlane = Handle(Geom_Plane)::DownCast(mySurface->Copy());
|
||||
}
|
||||
//
|
||||
if (aPlane.IsNull()) { // not a plane
|
||||
return;
|
||||
}
|
||||
//
|
||||
aPlane = Handle(Geom_Plane)::DownCast(aPlane);
|
||||
//
|
||||
Handle(GeomAdaptor_HSurface) aGAHS = new GeomAdaptor_HSurface(aPlane);
|
||||
Handle(Geom_Curve) aProjOnPlane =
|
||||
GeomProjLib::ProjectOnPlane (new Geom_TrimmedCurve(myCurve, myFirst, myLast),
|
||||
aPlane, aPlane->Position().Direction(),
|
||||
Standard_True);
|
||||
Handle(GeomAdaptor_HCurve) aHCurve = new GeomAdaptor_HCurve(aProjOnPlane);
|
||||
//
|
||||
ProjLib_ProjectedCurve aProj(aGAHS, aHCurve);
|
||||
myPCurve = Geom2dAdaptor::MakeCurve(aProj);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepLib_CheckCurveOnSurface::Init
|
||||
(const Handle(Geom_Curve)& the3DCurve,
|
||||
const Handle(Geom2d_Curve)& the2DCurve,
|
||||
const Handle(Geom_Surface)& theSurface,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast)
|
||||
{
|
||||
myCurve = the3DCurve;
|
||||
myPCurve = the2DCurve;
|
||||
mySurface = theSurface;
|
||||
myFirst = theFirst;
|
||||
myLast = theLast;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepLib_CheckCurveOnSurface::Perform()
|
||||
{
|
||||
try {
|
||||
//
|
||||
// 1. Check data
|
||||
CheckData();
|
||||
if (myErrorStatus) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
// 2. Compute the max distance
|
||||
Compute(myPCurve);
|
||||
//
|
||||
if (!myPCurve2.IsNull()) {
|
||||
// compute max distance for myPCurve2
|
||||
// (for the second curve on closed surface)
|
||||
Compute(myPCurve2);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
myErrorStatus = 3;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepLib_CheckCurveOnSurface::Compute
|
||||
(const Handle(Geom2d_Curve)& thePCurve)
|
||||
{
|
||||
Standard_Integer aNbIt, aStatus;
|
||||
Standard_Real anEpsilonRange, aMinDelta;
|
||||
Standard_Real aFirst, aLast;
|
||||
Standard_Real aValue, aParam, aBP;
|
||||
Standard_Real theMaxDist, theMaxPar;
|
||||
//
|
||||
anEpsilonRange = 1.e-3;
|
||||
aMinDelta = 1.e-5;
|
||||
aFirst = myFirst;
|
||||
aLast = myLast;
|
||||
//
|
||||
BRepLib_CheckCurveOnSurface_GlobOptFunc aFunc
|
||||
(myCurve, thePCurve, mySurface, myFirst, myLast);
|
||||
//
|
||||
math_Vector anOutputParam(1, 1);
|
||||
anOutputParam(1) = aFirst;
|
||||
theMaxDist = 0.;
|
||||
theMaxPar = aFirst;
|
||||
aNbIt = 100;
|
||||
aStatus = Standard_True;
|
||||
//
|
||||
MinComputing(aFunc, aFirst, aLast, anEpsilonRange, theMaxDist, theMaxPar);
|
||||
//
|
||||
while((aNbIt-- >= 0) && aStatus) {
|
||||
aValue = theMaxDist;
|
||||
aParam = theMaxPar;
|
||||
aBP = theMaxPar - aMinDelta;
|
||||
MinComputing(aFunc, aFirst, aBP, anEpsilonRange, theMaxDist, theMaxPar);
|
||||
//
|
||||
if(theMaxDist < aValue) {
|
||||
aLast = aBP;
|
||||
aStatus = Standard_True;
|
||||
}
|
||||
else {
|
||||
theMaxDist = aValue;
|
||||
theMaxPar = aParam;
|
||||
aStatus = Standard_False;
|
||||
}
|
||||
//
|
||||
if(!aStatus) {
|
||||
aBP = theMaxPar + aMinDelta;
|
||||
MinComputing(aFunc, aBP, aLast, 1.0e-3, theMaxDist, theMaxPar);
|
||||
//
|
||||
if(theMaxDist < aValue) {
|
||||
aFirst = aBP;
|
||||
aStatus = Standard_True;
|
||||
}
|
||||
else {
|
||||
theMaxDist = aValue;
|
||||
theMaxPar = aParam;
|
||||
aStatus = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
theMaxDist = sqrt(Abs(theMaxDist));
|
||||
if (theMaxDist > myMaxDistance) {
|
||||
myMaxDistance = theMaxDist;
|
||||
myMaxParameter = theMaxPar;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : MinComputing
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void MinComputing
|
||||
(BRepLib_CheckCurveOnSurface_GlobOptFunc& theFunction,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEpsilon, //1.0e-3
|
||||
Standard_Real& theBestValue,
|
||||
Standard_Real& theBestParameter)
|
||||
{
|
||||
const Standard_Real aStepMin = 1.0e-2;
|
||||
math_Vector aFirstV(1, 1), aLastV(1, 1), anOutputParam(1, 1);
|
||||
aFirstV(1) = theFirst;
|
||||
aLastV(1) = theLast;
|
||||
//
|
||||
math_GlobOptMin aFinder(&theFunction, aFirstV, aLastV);
|
||||
aFinder.SetTol(aStepMin, theEpsilon);
|
||||
aFinder.Perform();
|
||||
//
|
||||
const Standard_Integer aNbExtr = aFinder.NbExtrema();
|
||||
for(Standard_Integer i = 1; i <= aNbExtr; i++)
|
||||
{
|
||||
Standard_Real aValue = 0.0;
|
||||
aFinder.Points(i, anOutputParam);
|
||||
theFunction.Value(anOutputParam, aValue);
|
||||
//
|
||||
if(aValue < theBestValue) {
|
||||
theBestValue = aValue;
|
||||
theBestParameter = anOutputParam(1);
|
||||
}
|
||||
}
|
||||
}
|
109
src/BRepLib/BRepLib_CheckCurveOnSurface.lxx
Normal file
109
src/BRepLib/BRepLib_CheckCurveOnSurface.lxx
Normal file
@@ -0,0 +1,109 @@
|
||||
// Created by: Eugeny MALTCHIKOV
|
||||
// Copyright (c) 2014 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.
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline const Handle(Geom_Curve)& BRepLib_CheckCurveOnSurface::Curve() const
|
||||
{
|
||||
return myCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline const Handle(Geom2d_Curve)& BRepLib_CheckCurveOnSurface::PCurve() const
|
||||
{
|
||||
return myPCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurve2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline const Handle(Geom2d_Curve)& BRepLib_CheckCurveOnSurface::PCurve2() const
|
||||
{
|
||||
return myPCurve2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline const Handle(Geom_Surface)& BRepLib_CheckCurveOnSurface::Surface() const
|
||||
{
|
||||
return mySurface;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Range
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void BRepLib_CheckCurveOnSurface::Range
|
||||
(Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
theFirst = myFirst;
|
||||
theLast = myLast;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckData
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void BRepLib_CheckCurveOnSurface::CheckData()
|
||||
{
|
||||
if (myCurve.IsNull() ||
|
||||
myPCurve.IsNull() ||
|
||||
mySurface.IsNull()) {
|
||||
myErrorStatus = 1;
|
||||
return;
|
||||
}
|
||||
//
|
||||
if ((myCurve->FirstParameter() > myFirst) ||
|
||||
(myCurve->LastParameter() < myLast) ||
|
||||
(myPCurve->FirstParameter() > myFirst) ||
|
||||
(myPCurve->LastParameter() < myLast)) {
|
||||
myErrorStatus = 2;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean BRepLib_CheckCurveOnSurface::IsDone() const
|
||||
{
|
||||
return (myErrorStatus == 0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxDistance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Real BRepLib_CheckCurveOnSurface::MaxDistance() const
|
||||
{
|
||||
return myMaxDistance;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Real BRepLib_CheckCurveOnSurface::MaxParameter() const
|
||||
{
|
||||
return myMaxParameter;
|
||||
}
|
Reference in New Issue
Block a user