mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-09 18:50:54 +03:00
0029484: Avoid inheritance of the BRepAlgoAPI_Check from BRepBuilderAPI_MakeShape
Inherit BRepAlgoAPI_Check class from BOPAlgo_Options instead of BRepAlgoAPI_Algo, as the latter is too excessive for checking purposes. Implementation of the Draw command "bopapicheck" for testing the BRepAlgoAPI_Check algorithm.
This commit is contained in:
parent
03a3ba9ebe
commit
a981082925
@ -22,6 +22,7 @@
|
|||||||
#include <BOPTest_Objects.hxx>
|
#include <BOPTest_Objects.hxx>
|
||||||
#include <BOPTools_AlgoTools.hxx>
|
#include <BOPTools_AlgoTools.hxx>
|
||||||
#include <BRep_Builder.hxx>
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepAlgoAPI_Check.hxx>
|
||||||
#include <BRepBuilderAPI_Copy.hxx>
|
#include <BRepBuilderAPI_Copy.hxx>
|
||||||
#include <DBRep.hxx>
|
#include <DBRep.hxx>
|
||||||
#include <Draw.hxx>
|
#include <Draw.hxx>
|
||||||
@ -50,6 +51,7 @@ static
|
|||||||
//
|
//
|
||||||
static Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );
|
static Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
static Standard_Integer bopargcheck(Draw_Interpretor&, Standard_Integer, const char** );
|
static Standard_Integer bopargcheck(Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
|
static Standard_Integer bopapicheck(Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
static Standard_Integer xdistef(Draw_Interpretor&, Standard_Integer, const char** );
|
static Standard_Integer xdistef(Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
static Standard_Integer checkcurveonsurf (Draw_Interpretor&, Standard_Integer, const char**);
|
static Standard_Integer checkcurveonsurf (Draw_Interpretor&, Standard_Integer, const char**);
|
||||||
|
|
||||||
@ -79,6 +81,16 @@ void BOPTest::CheckCommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("checkcurveonsurf",
|
theCommands.Add("checkcurveonsurf",
|
||||||
"use checkcurveonsurf shape",
|
"use checkcurveonsurf shape",
|
||||||
__FILE__, checkcurveonsurf, g);
|
__FILE__, checkcurveonsurf, g);
|
||||||
|
theCommands.Add("bopapicheck",
|
||||||
|
"Checks the validity of shape/pair of shapes.\n"
|
||||||
|
"\t\tUsage: bopapicheck s1 [s2] [-op common/fuse/cut/tuc] [-se] [-si]\n"
|
||||||
|
"\t\tOptions:\n"
|
||||||
|
"\t\ts1, s2 - shapes for checking;\n"
|
||||||
|
"\t\t-op - specifies the type of Boolean operation, for which the validity of shapes should be checked;"
|
||||||
|
" Should be followed by the operation;\n"
|
||||||
|
"\t\t-se - disables the check of the shapes on small edges;\n"
|
||||||
|
"\t\t-si - disables the check of the shapes on self-interference.\n",
|
||||||
|
__FILE__, bopapicheck, g);
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//class : BOPTest_Interf
|
//class : BOPTest_Interf
|
||||||
@ -909,6 +921,123 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : bopapicheck
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer bopapicheck(Draw_Interpretor& di,
|
||||||
|
Standard_Integer n,
|
||||||
|
const char** a)
|
||||||
|
{
|
||||||
|
if (n < 2)
|
||||||
|
{
|
||||||
|
di.PrintHelp(a[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape aS1 = DBRep::Get(a[1]);
|
||||||
|
TopoDS_Shape aS2;
|
||||||
|
if (n > 2)
|
||||||
|
{
|
||||||
|
// Try to get the second shape
|
||||||
|
aS2 = DBRep::Get(a[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOPAlgo_Operation anOp = BOPAlgo_UNKNOWN;
|
||||||
|
Standard_Boolean bTestSE = Standard_True;
|
||||||
|
Standard_Boolean bTestSI = Standard_True;
|
||||||
|
|
||||||
|
for (Standard_Integer i = aS2.IsNull() ? 2 : 3; i < n; ++i)
|
||||||
|
{
|
||||||
|
if (!strcmp(a[i], "-op"))
|
||||||
|
{
|
||||||
|
// Get the operation type
|
||||||
|
++i;
|
||||||
|
if (!strcmp(a[i], "common"))
|
||||||
|
anOp = BOPAlgo_COMMON;
|
||||||
|
else if (!strcmp(a[i], "fuse"))
|
||||||
|
anOp = BOPAlgo_FUSE;
|
||||||
|
else if (!strcmp(a[i], "cut"))
|
||||||
|
anOp = BOPAlgo_CUT;
|
||||||
|
else if (!strcmp(a[i], "tuc"))
|
||||||
|
anOp = BOPAlgo_CUT21;
|
||||||
|
else if (!strcmp(a[i], "section"))
|
||||||
|
anOp = BOPAlgo_SECTION;
|
||||||
|
}
|
||||||
|
else if (!strcmp(a[i], "-se"))
|
||||||
|
{
|
||||||
|
bTestSE = Standard_False;
|
||||||
|
}
|
||||||
|
else if (!strcmp(a[i], "-si"))
|
||||||
|
{
|
||||||
|
bTestSI = Standard_False;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
di << "Invalid key: " << a[i] << ". Skipped.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRepAlgoAPI_Check aChecker(aS1, aS2, anOp, bTestSE, bTestSI);
|
||||||
|
if (aChecker.IsValid())
|
||||||
|
{
|
||||||
|
if (aS2.IsNull())
|
||||||
|
di << "The shape seems to be valid\n";
|
||||||
|
else
|
||||||
|
di << "The shapes seem to be valid\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shapes seem to be invalid.
|
||||||
|
// Analyze the invalidity.
|
||||||
|
|
||||||
|
Standard_Boolean isInv1 = Standard_False, isInv2 = Standard_False;
|
||||||
|
Standard_Boolean isBadOp = Standard_False;
|
||||||
|
BOPAlgo_ListIteratorOfListOfCheckResult itF(aChecker.Result());
|
||||||
|
for (; itF.More(); itF.Next())
|
||||||
|
{
|
||||||
|
const BOPAlgo_CheckResult& aFaulty = itF.Value();
|
||||||
|
if (aFaulty.GetCheckStatus() == BOPAlgo_BadType)
|
||||||
|
{
|
||||||
|
isBadOp = Standard_True;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!isInv1)
|
||||||
|
{
|
||||||
|
isInv1 = !aFaulty.GetShape1().IsNull();
|
||||||
|
}
|
||||||
|
if (!isInv2)
|
||||||
|
{
|
||||||
|
isInv2 = !aFaulty.GetShape2().IsNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInv1 && isInv2 && isBadOp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInv1)
|
||||||
|
{
|
||||||
|
if (aS2.IsNull())
|
||||||
|
di << "The shape is invalid\n";
|
||||||
|
else
|
||||||
|
di << "The first shape is invalid\n";
|
||||||
|
}
|
||||||
|
if (isInv2)
|
||||||
|
{
|
||||||
|
di << "The second shape is invalid\n";
|
||||||
|
}
|
||||||
|
if (isBadOp)
|
||||||
|
{
|
||||||
|
if (aS2.IsNull())
|
||||||
|
di << "The shape is empty\n";
|
||||||
|
else
|
||||||
|
di << "The shapes are not valid for Boolean operation\n";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : xdistef
|
//function : xdistef
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -14,20 +14,21 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
|
||||||
#include <BOPAlgo_ArgumentAnalyzer.hxx>
|
|
||||||
#include <BRepAlgoAPI_Check.hxx>
|
#include <BRepAlgoAPI_Check.hxx>
|
||||||
|
|
||||||
|
#include <BOPAlgo_ArgumentAnalyzer.hxx>
|
||||||
#include <BRepCheck_Analyzer.hxx>
|
#include <BRepCheck_Analyzer.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : BRepAlgoAPI_Check
|
//function : BRepAlgoAPI_Check
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
BRepAlgoAPI_Check::BRepAlgoAPI_Check()
|
BRepAlgoAPI_Check::BRepAlgoAPI_Check()
|
||||||
:
|
:
|
||||||
BRepAlgoAPI_Algo(),
|
BOPAlgo_Options(),
|
||||||
myAnalyzer(NULL),
|
myTestSE(Standard_True),
|
||||||
myFuzzyValue(0.)
|
myTestSI(Standard_True),
|
||||||
|
myOperation(BOPAlgo_UNKNOWN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +39,13 @@ BRepAlgoAPI_Check::BRepAlgoAPI_Check()
|
|||||||
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
|
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
|
||||||
const Standard_Boolean bTestSE,
|
const Standard_Boolean bTestSE,
|
||||||
const Standard_Boolean bTestSI)
|
const Standard_Boolean bTestSI)
|
||||||
: BRepAlgoAPI_Algo(),
|
:
|
||||||
myFuzzyValue(0.)
|
BOPAlgo_Options(),
|
||||||
|
myS1(theS),
|
||||||
|
myTestSE(bTestSE),
|
||||||
|
myTestSI(bTestSI),
|
||||||
|
myOperation(BOPAlgo_UNKNOWN)
|
||||||
{
|
{
|
||||||
Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
|
|
||||||
//
|
|
||||||
Perform();
|
Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,11 +58,14 @@ BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
|
|||||||
const BOPAlgo_Operation theOp,
|
const BOPAlgo_Operation theOp,
|
||||||
const Standard_Boolean bTestSE,
|
const Standard_Boolean bTestSE,
|
||||||
const Standard_Boolean bTestSI)
|
const Standard_Boolean bTestSI)
|
||||||
: BRepAlgoAPI_Algo(),
|
:
|
||||||
myFuzzyValue(0.)
|
BOPAlgo_Options(),
|
||||||
|
myS1(theS1),
|
||||||
|
myS2(theS2),
|
||||||
|
myTestSE(bTestSE),
|
||||||
|
myTestSI(bTestSI),
|
||||||
|
myOperation(theOp)
|
||||||
{
|
{
|
||||||
Init(theS1, theS2, theOp, bTestSE, bTestSI);
|
|
||||||
//
|
|
||||||
Perform();
|
Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,97 +75,6 @@ BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
|
BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
|
||||||
{
|
{
|
||||||
if(myAnalyzer){
|
|
||||||
delete myAnalyzer;
|
|
||||||
myAnalyzer=NULL;
|
|
||||||
}
|
|
||||||
myResult.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetFuzzyValue
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void BRepAlgoAPI_Check::SetFuzzyValue(const Standard_Real theFuzz)
|
|
||||||
{
|
|
||||||
myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
|
|
||||||
}
|
|
||||||
//=======================================================================
|
|
||||||
//function : FuzzyValue
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Real BRepAlgoAPI_Check::FuzzyValue() const
|
|
||||||
{
|
|
||||||
return myFuzzyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetData
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
|
|
||||||
const Standard_Boolean bTestSE,
|
|
||||||
const Standard_Boolean bTestSI)
|
|
||||||
{
|
|
||||||
Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetData
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
|
|
||||||
const TopoDS_Shape& theS2,
|
|
||||||
const BOPAlgo_Operation theOp,
|
|
||||||
const Standard_Boolean bTestSE,
|
|
||||||
const Standard_Boolean bTestSI)
|
|
||||||
{
|
|
||||||
Init(theS1, theS2, theOp, bTestSE, bTestSI);
|
|
||||||
}
|
|
||||||
//=======================================================================
|
|
||||||
//function : Init
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
|
|
||||||
const TopoDS_Shape& theS2,
|
|
||||||
const BOPAlgo_Operation theOp,
|
|
||||||
const Standard_Boolean bTestSE,
|
|
||||||
const Standard_Boolean bTestSI)
|
|
||||||
{
|
|
||||||
myResult.Clear();
|
|
||||||
myS1 = theS1;
|
|
||||||
myS2 = theS2;
|
|
||||||
//
|
|
||||||
myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
|
|
||||||
//
|
|
||||||
myAnalyzer->SetShape1(myS1);
|
|
||||||
myAnalyzer->SetShape2(myS2);
|
|
||||||
myAnalyzer->OperationType() = theOp;
|
|
||||||
myAnalyzer->ArgumentTypeMode() = Standard_True;
|
|
||||||
myAnalyzer->SmallEdgeMode() = bTestSE;
|
|
||||||
myAnalyzer->SelfInterMode() = bTestSI;
|
|
||||||
//
|
|
||||||
myAnalyzer->SetRunParallel(myRunParallel);
|
|
||||||
myAnalyzer->SetProgressIndicator(myProgressIndicator);
|
|
||||||
myAnalyzer->SetFuzzyValue(myFuzzyValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Result
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
|
|
||||||
{
|
|
||||||
return myResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : IsValid
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Boolean BRepAlgoAPI_Check::IsValid()
|
|
||||||
{
|
|
||||||
return myResult.IsEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -168,38 +83,40 @@ Standard_Boolean BRepAlgoAPI_Check::IsValid()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BRepAlgoAPI_Check::Perform()
|
void BRepAlgoAPI_Check::Perform()
|
||||||
{
|
{
|
||||||
Standard_Boolean isS1, isS2;
|
// Check the incompatibility of shapes types, small edges and self-interference
|
||||||
//incompatibility of shape types, small edges and self-interference
|
BOPAlgo_ArgumentAnalyzer anAnalyzer;
|
||||||
myAnalyzer->Perform();
|
// Set the shapes and options for the check
|
||||||
if (myAnalyzer->HasFaulty()) {
|
anAnalyzer.SetShape1(myS1);
|
||||||
myResult = myAnalyzer->GetCheckResult();
|
anAnalyzer.SetShape2(myS2);
|
||||||
}
|
anAnalyzer.OperationType() = myOperation;
|
||||||
|
anAnalyzer.ArgumentTypeMode() = Standard_True;
|
||||||
|
anAnalyzer.SmallEdgeMode() = myTestSE;
|
||||||
|
anAnalyzer.SelfInterMode() = myTestSI;
|
||||||
|
// Set options from BOPAlgo_Options
|
||||||
|
anAnalyzer.SetRunParallel(myRunParallel);
|
||||||
|
anAnalyzer.SetProgressIndicator(myProgressIndicator);
|
||||||
|
anAnalyzer.SetFuzzyValue(myFuzzyValue);
|
||||||
|
// Perform the check
|
||||||
|
anAnalyzer.Perform();
|
||||||
|
// Get the results
|
||||||
|
myFaultyShapes = anAnalyzer.GetCheckResult();
|
||||||
|
|
||||||
//topological validity
|
// Check the topological validity of the shapes
|
||||||
isS1 = !myS1.IsNull();
|
Standard_Boolean isValidS1 = !myS1.IsNull() ?
|
||||||
isS2 = !myS2.IsNull();
|
BRepCheck_Analyzer(myS1).IsValid() : Standard_True;
|
||||||
if (isS1) {
|
|
||||||
BRepCheck_Analyzer anS1(myS1);
|
Standard_Boolean isValidS2 = !myS2.IsNull() ?
|
||||||
isS1 = anS1.IsValid();
|
BRepCheck_Analyzer(myS2).IsValid() : Standard_True;
|
||||||
} else {
|
|
||||||
isS1 = Standard_True;
|
if (!isValidS1 || !isValidS2) {
|
||||||
}
|
|
||||||
//
|
|
||||||
if (isS2) {
|
|
||||||
BRepCheck_Analyzer anS2(myS2);
|
|
||||||
isS2 = anS2.IsValid();
|
|
||||||
} else {
|
|
||||||
isS2 = Standard_True;
|
|
||||||
}
|
|
||||||
if (!isS1 || !isS2) {
|
|
||||||
BOPAlgo_CheckResult aRes;
|
BOPAlgo_CheckResult aRes;
|
||||||
aRes.SetCheckStatus(BOPAlgo_NotValid);
|
aRes.SetCheckStatus(BOPAlgo_NotValid);
|
||||||
if (!isS1) {
|
if (!isValidS1) {
|
||||||
aRes.SetShape1(myS1);
|
aRes.SetShape1(myS1);
|
||||||
}
|
}
|
||||||
if (!isS1) {
|
if (!isValidS2) {
|
||||||
aRes.SetShape2(myS2);
|
aRes.SetShape2(myS2);
|
||||||
}
|
}
|
||||||
myResult.Append(aRes);
|
myFaultyShapes.Append(aRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,121 +20,157 @@
|
|||||||
#include <Standard_DefineAlloc.hxx>
|
#include <Standard_DefineAlloc.hxx>
|
||||||
#include <Standard_Handle.hxx>
|
#include <Standard_Handle.hxx>
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <BOPAlgo_PArgumentAnalyzer.hxx>
|
|
||||||
#include <BOPAlgo_ListOfCheckResult.hxx>
|
#include <BOPAlgo_ListOfCheckResult.hxx>
|
||||||
#include <Standard_Real.hxx>
|
|
||||||
#include <BRepAlgoAPI_Algo.hxx>
|
|
||||||
#include <Standard_Boolean.hxx>
|
|
||||||
#include <BOPAlgo_Operation.hxx>
|
#include <BOPAlgo_Operation.hxx>
|
||||||
class TopoDS_Shape;
|
#include <BOPAlgo_Options.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//! The class Check provides a diagnostic tool for checking the validity
|
||||||
//! The class Check provides a diagnostic tool for checking
|
//! of the single shape or couple of shapes.
|
||||||
//! single shape or couple of shapes.
|
//! The shapes are checked on:
|
||||||
//! Single shape is checking on topological validity, small edges
|
//! - Topological validity;
|
||||||
//! and self-interference. For couple of shapes added check
|
//! - Small edges;
|
||||||
//! on validity for boolean operation of given type.
|
//! - Self-interference;
|
||||||
|
//! - Validity for Boolean operation of certain type (for couple of shapes only).
|
||||||
//!
|
//!
|
||||||
//! The class provides two ways of checking shape(-s)
|
//! The class provides two ways of checking shape(-s)
|
||||||
//! 1. Constructors
|
//! 1. Constructors
|
||||||
//! BRepAlgoAPI_Check aCh(theS);
|
//! BRepAlgoAPI_Check aCh(theS);
|
||||||
//! Standard_Boolean bV=aCh.IsValid();
|
//! Standard_Boolean isValid = aCh.IsValid();
|
||||||
//! 2. Methods SetData and Perform
|
//! 2. Methods SetData and Perform
|
||||||
//! BRepAlgoAPI_Check aCh;
|
//! BRepAlgoAPI_Check aCh;
|
||||||
//! aCh.SetData(theS1, theS2, BOPAlgo_FUSE, Standard_False);
|
//! aCh.SetData(theS1, theS2, BOPAlgo_FUSE, Standard_False);
|
||||||
//! aCh.Perform();
|
//! aCh.Perform();
|
||||||
//! Standard_Boolean bV=aCh.IsValid();
|
//! Standard_Boolean isValid = aCh.IsValid();
|
||||||
class BRepAlgoAPI_Check : public BRepAlgoAPI_Algo
|
//!
|
||||||
|
class BRepAlgoAPI_Check : public BOPAlgo_Options
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
|
|
||||||
|
public: //! @name Constructors
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
Standard_EXPORT BRepAlgoAPI_Check();
|
Standard_EXPORT BRepAlgoAPI_Check();
|
||||||
Standard_EXPORT virtual ~BRepAlgoAPI_Check();
|
Standard_EXPORT virtual ~BRepAlgoAPI_Check();
|
||||||
|
|
||||||
//! Constructor for checking single shape.
|
//! Constructor for checking single shape.
|
||||||
//! It calls methods
|
//!
|
||||||
//! Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI)
|
//! @param theS [in] - the shape to check;
|
||||||
//! and Perform().
|
//! @param bTestSE [in] - flag which specifies whether to check the shape
|
||||||
//! Params:
|
//! on small edges or not; by default it is set to TRUE;
|
||||||
//! theS - the shape that should be checked;
|
//! @param bTestSI [in] - flag which specifies whether to check the shape
|
||||||
//! bTestSE - flag that specifies whether check on small edges
|
//! on self-interference or not; by default it is set to TRUE;
|
||||||
//! should be performed; by default it is set to TRUE;
|
Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS,
|
||||||
//! bTestSI - flag that specifies whether check on self-interference
|
const Standard_Boolean bTestSE = Standard_True,
|
||||||
//! should be performed; by default it is set to TRUE;
|
const Standard_Boolean bTestSI = Standard_True);
|
||||||
Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS, const Standard_Boolean bTestSE = Standard_True, const Standard_Boolean bTestSI = Standard_True);
|
|
||||||
|
//! Constructor for checking the couple of shapes.
|
||||||
//! Constructor for couple of shapes.
|
//! Additionally to the validity checks of each given shape,
|
||||||
//! It calls methods
|
//! the types of the given shapes will be checked on validity
|
||||||
//! Init(theS1, theS2, theOp, bTestSE, bTestSI) and Perform().
|
//! for Boolean operation of given type.
|
||||||
//! Params:
|
//!
|
||||||
//! theS1, theS2 - the initial shapes.
|
//! @param theS1 [in] - the first shape to check;
|
||||||
//! theOp - the type of Boolean Operation;
|
//! @param theS2 [in] - the second shape to check;
|
||||||
//! if it is not defined (set to UNKNOWN) for each shape
|
//! @param theOp [in] - the type of Boolean Operation for which the validity
|
||||||
//! performed check as for single shape.
|
//! of given shapes should be checked.
|
||||||
//! bTestSE - flag that specifies whether check on small edges
|
//! @param bTestSE [in] - flag which specifies whether to check the shape
|
||||||
//! should be performed; by default it is set to TRUE;
|
//! on small edges or not; by default it is set to TRUE;
|
||||||
//! bTestSI - flag that specifies whether check on self-interference
|
//! @param bTestSI [in] - flag which specifies whether to check the shape
|
||||||
//! should be performed; by default it is set to TRUE;
|
//! on self-interference or not; by default it is set to TRUE;
|
||||||
Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN, const Standard_Boolean bTestSE = Standard_True, const Standard_Boolean bTestSI = Standard_True);
|
Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2,
|
||||||
//! Sets data for check by Init method.
|
const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN,
|
||||||
//! The method provides alternative way for checking single shape.
|
const Standard_Boolean bTestSE = Standard_True,
|
||||||
Standard_EXPORT void SetData (const TopoDS_Shape& theS, const Standard_Boolean bTestSE = Standard_True, const Standard_Boolean bTestSI = Standard_True);
|
const Standard_Boolean bTestSI = Standard_True);
|
||||||
|
|
||||||
//! Sets data for check by Init method.
|
|
||||||
//! The method provides alternative way for checking couple of shapes.
|
public: //! @name Initializing the algorithm
|
||||||
Standard_EXPORT void SetData (const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN, const Standard_Boolean bTestSE = Standard_True, const Standard_Boolean bTestSI = Standard_True);
|
|
||||||
|
//! Initializes the algorithm with single shape.
|
||||||
|
//!
|
||||||
|
//! @param theS [in] - the shape to check;
|
||||||
|
//! @param bTestSE [in] - flag which specifies whether to check the shape
|
||||||
|
//! on small edges or not; by default it is set to TRUE;
|
||||||
|
//! @param bTestSI [in] - flag which specifies whether to check the shape
|
||||||
|
//! on self-interference or not; by default it is set to TRUE;
|
||||||
|
void SetData(const TopoDS_Shape& theS,
|
||||||
|
const Standard_Boolean bTestSE = Standard_True,
|
||||||
|
const Standard_Boolean bTestSI = Standard_True)
|
||||||
|
{
|
||||||
|
myS1 = theS;
|
||||||
|
myS2 = TopoDS_Shape();
|
||||||
|
myTestSE = bTestSE;
|
||||||
|
myTestSI = bTestSI;
|
||||||
|
myFaultyShapes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Initializes the algorithm with couple of shapes.
|
||||||
|
//! Additionally to the validity checks of each given shape,
|
||||||
|
//! the types of the given shapes will be checked on validity
|
||||||
|
//! for Boolean operation of given type.
|
||||||
|
//!
|
||||||
|
//! @param theS1 [in] - the first shape to check;
|
||||||
|
//! @param theS2 [in] - the second shape to check;
|
||||||
|
//! @param theOp [in] - the type of Boolean Operation for which the validity
|
||||||
|
//! of given shapes should be checked.
|
||||||
|
//! @param bTestSE [in] - flag which specifies whether to check the shape
|
||||||
|
//! on small edges or not; by default it is set to TRUE;
|
||||||
|
//! @param bTestSI [in] - flag which specifies whether to check the shape
|
||||||
|
//! on self-interference or not; by default it is set to TRUE;
|
||||||
|
void SetData(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2,
|
||||||
|
const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN,
|
||||||
|
const Standard_Boolean bTestSE = Standard_True,
|
||||||
|
const Standard_Boolean bTestSI = Standard_True)
|
||||||
|
{
|
||||||
|
myS1 = theS1;
|
||||||
|
myS2 = theS2;
|
||||||
|
myOperation = theOp;
|
||||||
|
myTestSE = bTestSE;
|
||||||
|
myTestSI = bTestSI;
|
||||||
|
myFaultyShapes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public: //! @name Performing the operation
|
||||||
|
|
||||||
//! Performs the check.
|
//! Performs the check.
|
||||||
Standard_EXPORT void Perform();
|
Standard_EXPORT void Perform();
|
||||||
|
|
||||||
|
|
||||||
|
public: //! @name Getting the results.
|
||||||
|
|
||||||
//! Shows whether shape(s) valid or not.
|
//! Shows whether shape(s) valid or not.
|
||||||
Standard_EXPORT Standard_Boolean IsValid();
|
Standard_Boolean IsValid()
|
||||||
|
{
|
||||||
|
return myFaultyShapes.IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
//! Returns faulty shapes.
|
//! Returns faulty shapes.
|
||||||
Standard_EXPORT const BOPAlgo_ListOfCheckResult& Result();
|
const BOPAlgo_ListOfCheckResult& Result()
|
||||||
|
{
|
||||||
//! Sets the additional tolerance
|
return myFaultyShapes;
|
||||||
Standard_EXPORT void SetFuzzyValue (const Standard_Real theFuzz);
|
}
|
||||||
|
|
||||||
//! Returns the additional tolerance
|
|
||||||
Standard_EXPORT Standard_Real FuzzyValue() const;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
//! Initialyzes data.
|
|
||||||
Standard_EXPORT void Init (const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, const BOPAlgo_Operation theOp, const Standard_Boolean bTestSE, const Standard_Boolean bTestSI);
|
|
||||||
|
|
||||||
|
|
||||||
TopoDS_Shape myS1;
|
|
||||||
TopoDS_Shape myS2;
|
|
||||||
BOPAlgo_PArgumentAnalyzer myAnalyzer;
|
|
||||||
BOPAlgo_ListOfCheckResult myResult;
|
|
||||||
Standard_Real myFuzzyValue;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
|
protected: //! @name Fields
|
||||||
|
|
||||||
|
// Inputs
|
||||||
|
TopoDS_Shape myS1; //!< The first shape
|
||||||
|
TopoDS_Shape myS2; //!< The second shape
|
||||||
|
Standard_Boolean myTestSE; //!< Flag defining whether to look for small edges in the given shapes or not
|
||||||
|
Standard_Boolean myTestSI; //!< Flag defining whether to check the input edges on self-interference or not
|
||||||
|
BOPAlgo_Operation myOperation; //!< Type of Boolean operation for which the validity of input shapes should be checked
|
||||||
|
|
||||||
|
// Results
|
||||||
|
BOPAlgo_ListOfCheckResult myFaultyShapes; //!< Found faulty shapes
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _BRepAlgoAPI_Check_HeaderFile
|
#endif // _BRepAlgoAPI_Check_HeaderFile
|
||||||
|
90
tests/bugs/modalg_7/bug29484
Normal file
90
tests/bugs/modalg_7/bug29484
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC29484"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
#################################################
|
||||||
|
# Avoid inheritance of the BRepAlgoAPI_Check from BRepBuilderAPI_MakeShape
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
puts "check simple box"
|
||||||
|
|
||||||
|
box b1 2 2 2
|
||||||
|
if {![regexp "The shape seems to be valid" [bopapicheck b1]]} {
|
||||||
|
puts "Error: The simple box is considered as invalid by BRepAlgoAPI_Check"
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "add another box"
|
||||||
|
|
||||||
|
box b2 1 1 1 2 2 2
|
||||||
|
compound b1 b2 c
|
||||||
|
|
||||||
|
puts "check si compound"
|
||||||
|
|
||||||
|
if {![regexp "The shape is invalid" [bopapicheck c]]} {
|
||||||
|
puts "Error: Self-intersection is not detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shape seems to be valid" [bopapicheck c -si]]} {
|
||||||
|
puts "Error: Check on self-intersection is still enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
puts "increase tolerance of the vertices of the box to test Small edges detection"
|
||||||
|
|
||||||
|
foreach v [explode b1 v] {settolerance $v 5.}
|
||||||
|
|
||||||
|
if {![regexp "The shape is invalid" [bopapicheck b1 -si]]} {
|
||||||
|
puts "Error: Small edges are not detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shape seems to be valid" [bopapicheck c -si -se]]} {
|
||||||
|
puts "Error: Check on small edges is still enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "b1 - invalid, b2 - ok"
|
||||||
|
|
||||||
|
if {![regexp "The first shape is invalid" [bopapicheck b1 b2]]} {
|
||||||
|
puts "Error: The check is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The second shape is invalid" [bopapicheck b2 b1]]} {
|
||||||
|
puts "Error: The check is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
puts "test types"
|
||||||
|
|
||||||
|
if {![regexp "The shapes seem to be valid" [bopapicheck b1 b2 -op fuse -se -si]]} {
|
||||||
|
puts "Error: The check on types is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "check empty shape"
|
||||||
|
compound c
|
||||||
|
|
||||||
|
if {![regexp "The shape is empty" [bopapicheck c]]} {
|
||||||
|
puts "Error: Empty shape is not detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shapes are not valid for Boolean operation" [bopapicheck b2 c]]} {
|
||||||
|
puts "Error: Empty shape is not detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
puts "check vertex/solid BOPs"
|
||||||
|
vertex v 1 1 1
|
||||||
|
|
||||||
|
if {![regexp "The shapes seem to be valid" [bopapicheck b2 v -op common]]} {
|
||||||
|
puts "Error: The check on types is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shapes are not valid for Boolean operation" [bopapicheck b2 v -op fuse]]} {
|
||||||
|
puts "Error: The check on types is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shapes are not valid for Boolean operation" [bopapicheck b2 v -op cut]]} {
|
||||||
|
puts "Error: The check on types is invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![regexp "The shapes seem to be valid" [bopapicheck b2 v -op tuc]]} {
|
||||||
|
puts "Error: The check on types is invalid"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user