Add '-exact' option to checkshape command to use exact method to validate edges using BRepLib_ValidateEdge class. Default mode is calculating in finite number of points.
//=======================================================================
void BRepCheck_Analyzer::Init (const TopoDS_Shape& theShape,
const Standard_Boolean B,
- const Standard_Boolean theIsParallel)
+ const Standard_Boolean theIsParallel,
+ const Standard_Boolean theIsExact)
{
if (theShape.IsNull())
{
myShape = theShape;
myMap.Clear();
- Put (theShape, B, theIsParallel);
+ Put (theShape, B, theIsParallel, theIsExact);
Perform (theIsParallel);
}
//=======================================================================
void BRepCheck_Analyzer::Put (const TopoDS_Shape& theShape,
const Standard_Boolean B,
- const Standard_Boolean theIsParallel)
+ const Standard_Boolean theIsParallel,
+ const Standard_Boolean theIsExact)
{
if (myMap.Contains (theShape))
{
case TopAbs_EDGE:
HR = new BRepCheck_Edge (TopoDS::Edge (theShape));
Handle(BRepCheck_Edge)::DownCast(HR)->GeometricControls (B);
+ Handle(BRepCheck_Edge)::DownCast(HR)->SetExactMethod(theIsExact);
break;
case TopAbs_WIRE:
HR = new BRepCheck_Wire (TopoDS::Wire (theShape));
for (TopoDS_Iterator theIterator (theShape); theIterator.More(); theIterator.Next())
{
- Put (theIterator.Value(), B, theIsParallel); // performs minimum on each shape
+ Put (theIterator.Value(), B, theIsParallel, theIsExact); // performs minimum on each shape
}
}
//function : Perform
//purpose :
//=======================================================================
-void BRepCheck_Analyzer::Perform (Standard_Boolean theIsParallel)
+void BRepCheck_Analyzer::Perform (const Standard_Boolean theIsParallel)
{
const Standard_Integer aMapSize = myMap.Size();
const Standard_Integer aMinTaskSize = 10;
//! BRepCheck_SelfIntersectingWire
BRepCheck_Analyzer (const TopoDS_Shape& S,
const Standard_Boolean GeomControls = Standard_True,
- const Standard_Boolean theIsParallel = Standard_False)
+ const Standard_Boolean theIsParallel = Standard_False,
+ const Standard_Boolean theIsExact = Standard_False)
{
- Init (S, GeomControls, theIsParallel);
+ Init (S, GeomControls, theIsParallel, theIsExact);
}
//! <S> is the shape to control. <GeomControls> If
//! BRepCheck_SelfIntersectingWire
Standard_EXPORT void Init (const TopoDS_Shape& S,
const Standard_Boolean GeomControls = Standard_True,
- const Standard_Boolean theIsParallel = Standard_False);
+ const Standard_Boolean theIsParallel = Standard_False,
+ const Standard_Boolean theIsExact = Standard_False);
//! <S> is a subshape of the original shape. Returns
//! <STandard_True> if no default has been detected on
Standard_EXPORT void Put (const TopoDS_Shape& S,
const Standard_Boolean Gctrl,
- const Standard_Boolean theIsParallel);
+ const Standard_Boolean theIsParallel,
+ const Standard_Boolean theIsExact);
- Standard_EXPORT void Perform (Standard_Boolean theIsParallel);
+ Standard_EXPORT void Perform (const Standard_Boolean theIsParallel);
Standard_EXPORT Standard_Boolean ValidSub (const TopoDS_Shape& S, const TopAbs_ShapeEnum SubType) const;
BRepLib_ValidateEdge aValidateEdge(myHCurve, ACS, SameParameter);
aValidateEdge.SetExitIfToleranceExceeded(Tol);
+ aValidateEdge.SetExactMethod(myIsExactMethod);
+ aValidateEdge.SetParallel(myIsParallel);
aValidateEdge.Process();
if (!aValidateEdge.IsDone() || !aValidateEdge.CheckTolerance(Tol))
{
BRepLib_ValidateEdge aValidateEdgeOnClosedSurf(myHCurve, ACS, SameParameter);
aValidateEdgeOnClosedSurf.SetExitIfToleranceExceeded(Tol);
+ aValidateEdgeOnClosedSurf.SetExactMethod(myIsExactMethod);
+ aValidateEdgeOnClosedSurf.SetParallel(myIsParallel);
aValidateEdgeOnClosedSurf.Process();
if (!aValidateEdgeOnClosedSurf.IsDone() || !aValidateEdgeOnClosedSurf.CheckTolerance(Tol))
{
BRepLib_ValidateEdge aValidateEdgeProj(myHCurve, ACS, SameParameter);
aValidateEdgeProj.SetExitIfToleranceExceeded(Tol);
+ aValidateEdgeProj.SetExactMethod(myIsExactMethod);
+ aValidateEdgeProj.SetParallel(myIsParallel);
aValidateEdgeProj.Process();
if (!aValidateEdgeProj.IsDone() || !aValidateEdgeProj.CheckTolerance(Tol))
{
//! Sets status of Edge;
Standard_EXPORT void SetStatus (const BRepCheck_Status theStatus);
+
+ //! Sets validate edge method
+ void SetExactMethod(Standard_Boolean theIsExact)
+ {
+ myIsExactMethod = theIsExact;
+ }
//! Checks, if polygon on triangulation of heEdge
//! is out of 3D-curve of this edge.
Handle(BRep_CurveRepresentation) myCref;
Handle(Adaptor3d_Curve) myHCurve;
Standard_Boolean myGctrl;
-
+ Standard_Boolean myIsExactMethod;
};
#endif // _BRepCheck_Edge_HeaderFile
//=======================================================================
BRepCheck_Result::BRepCheck_Result()
: myMin (Standard_False),
- myBlind (Standard_False)
+ myBlind (Standard_False),
+ myIsParallel (Standard_False)
{
//
}
myShape = S;
myMin = Standard_False;
myBlind = Standard_False;
+ myIsParallel = Standard_False;
myMap.Clear();
Minimum();
}
//=======================================================================
void BRepCheck_Result::SetParallel(Standard_Boolean theIsParallel)
{
+ myIsParallel = Standard_False;
if (theIsParallel && myMutex.IsNull())
{
myMutex.reset(new Standard_HMutex());
Standard_Boolean myMin;
Standard_Boolean myBlind;
BRepCheck_DataMapOfShapeListOfStatus myMap;
+ Standard_Boolean myIsParallel;
mutable Handle(Standard_HMutex) myMutex;
private:
#include <Adaptor3d_CurveOnSurface.hxx>
#include <BRepCheck.hxx>
#include <Extrema_LocateExtPC.hxx>
+#include <GeomLib_CheckCurveOnSurface.hxx>
//=============================================================================
//function : BRepLib_ValidateEdge
myToleranceForChecking(0),
myCalculatedDistance(0),
myExitIfToleranceExceeded(Standard_False),
- myIsDone(Standard_False)
+ myIsDone(Standard_False),
+ myIsExactMethod(Standard_False)
{ }
//=============================================================================
//purpose :
//=============================================================================
void BRepLib_ValidateEdge::Process()
+{
+ if (myIsExactMethod && mySameParameter)
+ {
+ ProcessExact();
+ }
+ else
+ {
+ ProcessApprox();
+ }
+}
+
+//=============================================================================
+//function : ProcessApprox
+//purpose :
+//=============================================================================
+void BRepLib_ValidateEdge::ProcessApprox()
{
myIsDone = Standard_True;
Standard_Real aSquareToleranceForChecking = myToleranceForChecking * myToleranceForChecking;
myCalculatedDistance = Sqrt(aMaxSquareDistance);
}
+//=============================================================================
+//function : ProcessExact
+//purpose :
+//=============================================================================
+void BRepLib_ValidateEdge::ProcessExact()
+{
+ GeomLib_CheckCurveOnSurface aCheckCurveOnSurface(myReferenceCurve);
+ aCheckCurveOnSurface.Perform(myOtherCurve, myIsParallel);
+ myIsDone = aCheckCurveOnSurface.IsDone();
+ if (myIsDone)
+ {
+ myCalculatedDistance = aCheckCurveOnSurface.MaxDistance();
+ }
+}
+
class Adaptor3d_Curve;
class Adaptor3d_CurveOnSurface;
-//! Computes the max distance between 3D-curve and curve on
-//! surface in fixed points number
+//! Computes the max distance between 3D-curve and curve on surface.
+//! This class uses 2 methods: approximate using finite
+//! number of points (default) and exact
class BRepLib_ValidateEdge
{
public:
myControlPointsNumber = theControlPointsNumber;
}
- //! Sets the maximal allowed distance in the Process() function. If the distance greater than
- //! theToleranceForChecking the Process() function stops. Use this for best performance
- //! in case of checking of tolerance.
- Standard_EXPORT void SetExitIfToleranceExceeded(Standard_Real theToleranceForChecking);
+ //! Sets method to calculate distance: Calculating in finite number of points (if theIsExact
+ //! is false, faster, but possible not correct result) or exact calculating by using
+ //! BRepLib_CheckCurveOnSurface class (if theIsExact is true, slowly, but more correctly.
+ //! Default method is exact
+ void SetExactMethod(Standard_Boolean theIsExact)
+ {
+ myIsExactMethod = theIsExact;
+ }
+
+ //! Sets limit to compute a distance in the Process() function. If the distance greater than
+ //! theToleranceForChecking the Process() function stopped. Use this in case checking of
+ //! tolerance for best performcnce. Has no effect in case using exact method.
+ void SetExitIfToleranceExceeded(Standard_Real theToleranceForChecking);
//! Computes the max distance for the 3d curve <myReferenceCurve>
//! and curve on surface <myOtherCurve>. If the SetExitIfToleranceExceeded()
//! function was called before <myCalculatedDistance> containts first
- //! greater than SetExitIfToleranceExceeded() parameter value
+ //! greater than SetExitIfToleranceExceeded() parameter value. In case
+ //! using exact method always computes real max distance.
Standard_EXPORT void Process();
//! Returns true if the distance has been found for all points
- Standard_EXPORT Standard_Boolean IsDone()
+ Standard_Boolean IsDone() const
{
return myIsDone;
}
+ //! Sets process validating in parallel
+ void SetParallel(const Standard_Boolean theIsParallel)
+ {
+ myIsParallel = theIsParallel;
+ }
+
//! Returns true if computed distance is less than <theToleranceToCheck>
Standard_EXPORT Standard_Boolean CheckTolerance(Standard_Real theToleranceToCheck);
//! Adds some margin for distance checking
Standard_Real CorrectTolerance(Standard_Real theTolerance);
-private:
+ //! Calculating in finite number of points
+ void ProcessApprox();
+
+ //! Calculating by using BRepLib_CheckCurveOnSurface class
+ void ProcessExact();
+
Handle(Adaptor3d_Curve) myReferenceCurve;
Handle(Adaptor3d_CurveOnSurface) myOtherCurve;
Standard_Boolean mySameParameter;
Standard_Real myCalculatedDistance;
Standard_Boolean myExitIfToleranceExceeded;
Standard_Boolean myIsDone;
+ Standard_Boolean myIsExactMethod;
+ Standard_Boolean myIsParallel;
};
-#endif // _BRepLib_ValidateEdge_HeaderFile
\ No newline at end of file
+#endif // _BRepLib_ValidateEdge_HeaderFile
return 0;
}
- if (narg > 6)
+ if (narg > 7)
{
theCommands << "Invalid number of args!!!\n";
theCommands << "No args to have help.\n";
Standard_Boolean IsShortDump = Standard_False;
Standard_Boolean IsContextDump = Standard_True;
Standard_Boolean IsParallel = Standard_False;
+ Standard_Boolean IsExact = Standard_False;
Standard_CString aPref(NULL);
if (aCurInd < narg && strncmp(a[aCurInd], "-", 1))
{
{
IsParallel = Standard_True;
}
+ else if (anArg == "-exact")
+ {
+ IsExact = Standard_True;
+ }
else
{
theCommands << "Syntax error at '" << anArg << "'";
try
{
OCC_CATCH_SIGNALS
- BRepCheck_Analyzer anAna (aShape, aGeomCtrl, IsParallel);
+ BRepCheck_Analyzer anAna (aShape, aGeomCtrl, IsParallel, IsExact);
Standard_Boolean isValid = anAna.IsValid();
if (isValid)
{
public:
GeomLib_CheckCurveOnSurface_Local(
- const Handle(Adaptor3d_Curve) theCurve3D,
- const Handle(Adaptor3d_Curve)& theCurveOnSurface,
- const TColStd_Array1OfReal& theIntervalsArr,
- const Standard_Real theEpsilonRange,
- const Standard_Integer theNbParticles):
- myCurve3D(theCurve3D),
- myCurveOnSurface(theCurveOnSurface),
- mySubIntervals(theIntervalsArr),
- myEpsilonRange(theEpsilonRange),
- myNbParticles(theNbParticles),
- myArrOfDist(theIntervalsArr.Lower(), theIntervalsArr.Upper()-1),
- myArrOfParam(theIntervalsArr.Lower(), theIntervalsArr.Upper()-1)
- {
- }
-
- GeomLib_CheckCurveOnSurface_Local(
- const Handle(HArray1OfHCurve) theAdaptorArray,
- const Handle(Adaptor3d_Curve)& theCurveOnSurface,
+ const Handle(HArray1OfHCurve) theCurveArray,
+ const Handle(HArray1OfHCurve) theCurveOnSurfaceArray,
const TColStd_Array1OfReal& theIntervalsArr,
const Standard_Real theEpsilonRange,
const Standard_Integer theNbParticles) :
- myAdaptorArray(theAdaptorArray),
- myCurveOnSurface(theCurveOnSurface),
+ myCurveArray(theCurveArray),
+ myCurveOnSurfaceArray(theCurveOnSurfaceArray),
mySubIntervals(theIntervalsArr),
myEpsilonRange(theEpsilonRange),
myNbParticles(theNbParticles),
//This optimal value will be put in corresponding (depending on theIndex - the
//identificator of the current interval in mySubIntervals array) cell of
//myArrOfDist and myArrOfParam arrays.
- GeomLib_CheckCurveOnSurface_TargetFunc aFunc(myCurve3D, myCurveOnSurface,
- mySubIntervals.Value(theIndex),
- mySubIntervals.Value(theIndex+1));
+ GeomLib_CheckCurveOnSurface_TargetFunc aFunc(myCurveArray->Value(0),
+ myCurveOnSurfaceArray->Value(0),
+ mySubIntervals.Value(theIndex),
+ mySubIntervals.Value(theIndex+1));
Standard_Real aMinDist = RealLast(), aPar = 0.0;
if(!MinComputing(aFunc, myEpsilonRange, myNbParticles, aMinDist, aPar))
void operator()(int theThreadIndex, int theElemIndex) const
{
- GeomLib_CheckCurveOnSurface_TargetFunc aFunc(myAdaptorArray->Value(theThreadIndex),
- myCurveOnSurface,
+ GeomLib_CheckCurveOnSurface_TargetFunc aFunc(myCurveArray->Value(theThreadIndex),
+ myCurveOnSurfaceArray->Value(theThreadIndex),
mySubIntervals.Value(theElemIndex),
mySubIntervals.Value(theElemIndex + 1));
}
private:
- GeomLib_CheckCurveOnSurface_Local operator=(GeomLib_CheckCurveOnSurface_Local&);
- const Handle(Adaptor3d_Curve) myCurve3D;
- Handle(HArray1OfHCurve) myAdaptorArray;
- const Handle(Adaptor3d_Curve)& myCurveOnSurface;
+ GeomLib_CheckCurveOnSurface_Local operator=(const GeomLib_CheckCurveOnSurface_Local&) Standard_DELETE;
+
+private:
+ Handle(HArray1OfHCurve) myCurveArray;
+ Handle(HArray1OfHCurve) myCurveOnSurfaceArray;
const TColStd_Array1OfReal& mySubIntervals;
const Standard_Real myEpsilonRange;
{
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
const int aNbThreads = isMultiThread ? Min(anIntervals.Size(), aThreadPool->NbDefaultThreadsToLaunch()) : 1;
- Handle(HArray1OfHCurve) anAdaptorArray = new HArray1OfHCurve(0, aNbThreads - 1);
+ Handle(HArray1OfHCurve) aCurveArray = new HArray1OfHCurve(0, aNbThreads - 1);
+ Handle(HArray1OfHCurve) aCurveOnSurfaceArray = new HArray1OfHCurve(0, aNbThreads - 1);
for (Standard_Integer anI = 0; anI < aNbThreads; ++anI)
{
- anAdaptorArray->SetValue(anI, myCurve->ShallowCopy());
+ aCurveArray->SetValue(anI, myCurve->ShallowCopy());
+ aCurveOnSurfaceArray->SetValue(anI, theCurveOnSurface->ShallowCopy());
}
- GeomLib_CheckCurveOnSurface_Local aComp(anAdaptorArray, theCurveOnSurface, anIntervals,
+ GeomLib_CheckCurveOnSurface_Local aComp(aCurveArray, aCurveOnSurfaceArray, anIntervals,
anEpsilonRange, aNbParticles);
OSD_ThreadPool::Launcher aLauncher(*aThreadPool, aNbThreads);
aLauncher.Perform(anIntervals.Lower(), anIntervals.Upper(), aComp);
}
else
{
- GeomLib_CheckCurveOnSurface_Local aComp(myCurve, theCurveOnSurface, anIntervals,
+ Handle(HArray1OfHCurve) aCurveArray = new HArray1OfHCurve(0, 0);
+ aCurveArray->SetValue(0, myCurve);
+ Handle(HArray1OfHCurve) aCurveOnSurfaceArray = new HArray1OfHCurve(0, 0);
+ aCurveOnSurfaceArray->SetValue(0, myCurve);
+ GeomLib_CheckCurveOnSurface_Local aComp(aCurveArray, aCurveOnSurfaceArray, anIntervals,
anEpsilonRange, aNbParticles);
for (Standard_Integer anI = anIntervals.Lower(); anI < anIntervals.Upper(); ++anI)
{
//! and 2d curve <thePCurve>
//! If isMultiThread == Standard_True then computation will be performed in parallel.
Standard_EXPORT void Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
- const Standard_Boolean isMultiThread = Standard_True);
+ const Standard_Boolean isMultiThread = Standard_False);
//! Returns true if the max distance has been found
Standard_Boolean IsDone() const
puts "Error: different result between single-thread and parallel on $path"
}
}
+
+proc CheckExact {path} {
+ puts ""
+ puts "model: $path"
+ restore $path c
+
+ dchrono s reset; dchrono s start;
+ set cres [checkshape c]
+ dchrono s stop;
+ regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono s show] full s_Hours s_Minutes s_Seconds
+ set s_Time [expr ${s_Hours}*60.*60. + ${s_Minutes}*60. + ${s_Seconds} ]
+ puts "approx time: $s_Time"
+
+ dchrono s reset; dchrono s start;
+ set eres [checkshape c -exact]
+ dchrono s stop;
+ regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono s show] full s_Hours s_Minutes s_Seconds
+ set e_Time [expr ${s_Hours}*60.*60. + ${s_Minutes}*60. + ${s_Seconds} ]
+ puts "exact time: $e_Time"
+
+ dchrono p reset; dchrono p start;
+ set pres [checkshape c -exact -parallel]
+ dchrono p stop;
+ regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono p show] full p_Hours p_Minutes p_Seconds
+ set p_Time [expr ${p_Hours}*60.*60. + ${p_Minutes}*60. + ${p_Seconds} ]
+ puts "multithreaded time: $p_Time"
+
+ set es_ratio [expr ${e_Time}/${s_Time} ]
+ puts "deceleration in exact mode: $es_ratio"
+
+ set pe_ratio [expr ${e_Time}/${p_Time} ]
+ puts "acceleration in excat multi-threaded work: $pe_ratio"
+
+
+# if {[string compare $cres $pres] != 0} {
+# puts "Error: different result between single-thread and parallel on $path"
+# }
+}
+
-puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_51"
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_31"
puts "=========="
puts "0027814: Parallelize BRepCheck_Analyzer"
puts "=========="
puts ""
-CheckPerform [locate_data_file OCC394.brep]
\ No newline at end of file
+CheckPerform [locate_data_file OCC396.brep]
\ No newline at end of file
-puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_31"
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_287"
puts "=========="
puts "0027814: Parallelize BRepCheck_Analyzer"
puts "=========="
puts ""
-CheckPerform [locate_data_file OCC396.brep]
\ No newline at end of file
+CheckPerform [locate_data_file OCC54.brep]
\ No newline at end of file
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_88"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file bug27814.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_6101"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file OCC54.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file 5000-12.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_3675"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file BPLSEITLI.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file bug24525_License.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_8234"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file bug26278_E01754_000000_P00_01_0_VS3_1_20070102_sewed_fixed.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_7656"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file bug30360_GES-13500-000.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_1943"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file OCC187_from_bug_description.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_502"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file OCC394.brep] b
+checkshape b -exact -parallel
--- /dev/null
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_467"
+puts "=========="
+puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
+puts "=========="
+puts ""
+
+restore [locate_data_file OCC396.brep] b
+checkshape b -exact -parallel