inherits PaveFiller from BOPAlgo
---Purpose: Checks shape on self-interference.
-
+
+uses
+ DataMapOfShapeShape from BOPCol
+
is
Create
- returns CheckerSI from BOPAlgo;
+ returns CheckerSI from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_CheckerSI();"
Perform(me:out)
- is redefined;
+ is redefined;
Init (me:out)
- is redefined protected;
+ is redefined protected;
SetLevelOfCheck(me:out;
theLevel: Integer from Standard);
-- 4 - V/V, V/E, E/E, V/F and E/F;
-- 5 - all interferences, default value.
-
+ SetNonDestructive(me:out;
+ theFlag: Boolean from Standard);
+ ---Purpose: Sets the flag <theFlag> that defines
+ -- the mode of the treatment:
+ -- the copy of the argument when theFlag is true
+ -- the argument itself when theFlag is false
+
+ NonDestructive(me)
+ returns Boolean from Standard;
+ ---Purpose: Returns the flag that defines the
+ -- mode of the treatment:
+ -- true when the copy of the argument is used
+ -- false when the argument itself is used
+
PostTreat (me:out)
- is protected;
- ---Purpose: Provides post-tratment actions
+ is protected;
+ ---Purpose: Provides post-treatment actions
PerformVZ(me:out)
is virtual protected;
PerformZZ(me:out)
is virtual protected;
--Purpose: Computes Solid/Solid interferences
-
+
+ PrepareCopy(me:out)
+ is virtual protected;
+
+ PostTreatCopy (me:out)
+ is protected;
+ ---Purpose: Provides post-treatment actions for the copy
fields
myLevelOfCheck: Integer from Standard is protected;
+ myNonDestructive: Boolean from Standard is protected;
+ myNewOldMap : DataMapOfShapeShape from BOPCol is protected;
end CheckerSI;
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <TopTools_ListOfShape.hxx>
+
+#include <BOPCol_MapOfShape.hxx>
+
#include <BOPDS_DS.hxx>
#include <BOPDS_IteratorSI.hxx>
#include <BOPDS_PIteratorSI.hxx>
-#include <BOPInt_Context.hxx>
-
#include <BOPDS_Interf.hxx>
#include <BOPDS_MapOfPassKey.hxx>
#include <BOPDS_PassKey.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
#include <BOPDS_VectorOfInterfEF.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
-#include <BOPDS_VectorOfPoint.hxx>
+
+#include <BOPInt_Context.hxx>
+
+#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
//=======================================================================
BOPAlgo_PaveFiller()
{
myLevelOfCheck=BOPDS_DS::NbInterfTypes()-1;
+ myNonDestructive=Standard_True;
}
//=======================================================================
//function : ~
}
}
//=======================================================================
+//function : SetNonDestructive
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::SetNonDestructive(const Standard_Boolean theFlag)
+{
+ myNonDestructive=theFlag;
+}
+//=======================================================================
+//function : NonDestructive
+//purpose :
+//=======================================================================
+Standard_Boolean BOPAlgo_CheckerSI::NonDestructive() const
+{
+ return myNonDestructive;
+}
+//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BOPAlgo_CheckerSI::Init()
{
- myErrorStatus = 0;
- //
- if (!myArguments.Extent()) {
- myErrorStatus=10;
- return;
- }
+ myErrorStatus=0;
//
Clear();
//
try {
OCC_CATCH_SIGNALS
//
+ myErrorStatus=0;
+ if (myArguments.Extent()!=1) {
+ myErrorStatus=10;
+ return;
+ }
+ //
+ if (myNonDestructive) {
+ PrepareCopy();
+ if (myErrorStatus) {
+ return;
+ }
+ }
+ //
BOPAlgo_PaveFiller::Perform();
if (myErrorStatus) {
return;
}
//
PostTreat();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ if (myNonDestructive) {
+ PostTreatCopy();
+ }
}
catch (Standard_Failure) {
+ myErrorStatus=11;
}
-
}
+
//=======================================================================
//function : PostTreat
//purpose :
Standard_Integer i, aNb, n1, n2;
BOPDS_PassKey aPK;
//
- BOPDS_MapOfPassKey& aMPK=*((BOPDS_MapOfPassKey*)&myDS->Interferences());
+ myErrorStatus=0;
+ //
+ BOPDS_MapOfPassKey& aMPK=
+ *((BOPDS_MapOfPassKey*)&myDS->Interferences());
aMPK.Clear();
//
// 0
//
iFound=0;
if (bTangentFaces) {
- const TopoDS_Face& aF1 = *((TopoDS_Face*)&myDS->Shape(n1));
- const TopoDS_Face& aF2 = *((TopoDS_Face*)&myDS->Shape(n2));
- bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1, aF2, myContext);
+ const TopoDS_Face& aF1=*((TopoDS_Face*)&myDS->Shape(n1));
+ const TopoDS_Face& aF2=*((TopoDS_Face*)&myDS->Shape(n2));
+ bFlag=BOPTools_AlgoTools::AreFacesSameDomain
+ (aF1, aF2, myContext);
if (bFlag) {
- ++iFound;
+ ++iFound;
}
}
else {
for (j=0; j!=aNbC; ++j) {
- const BOPDS_Curve& aNC=aVC(j);
- const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
- if (aLPBC.Extent()) {
- ++iFound;
- break;
- }
+ const BOPDS_Curve& aNC=aVC(j);
+ const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
+ if (aLPBC.Extent()) {
+ ++iFound;
+ break;
+ }
}
}
//
aMPK.Add(aPK);
}
}
+//=======================================================================
+//function : PrepareCopy
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PrepareCopy()
+{
+ Standard_Boolean bIsDone;
+ BRepBuilderAPI_Copy aCopier;
+ BOPCol_MapOfShape aMSA;
+ BOPCol_MapIteratorOfMapOfShape aItMS;
+ //
+ myErrorStatus=0;
+ //
+ myNewOldMap.Clear();
+ //
+ const TopoDS_Shape& aSA=myArguments.First();
+ //
+ BOPTools::MapShapes(aSA, aMSA);
+ //
+ aCopier.Perform(aSA, Standard_False);
+ bIsDone=aCopier.IsDone();
+ if (!bIsDone) {
+ myErrorStatus=12;
+ return;
+ }
+ //
+ const TopoDS_Shape& aSC=aCopier.Shape();
+ //
+ aItMS.Initialize(aMSA);
+ for(; aItMS.More(); aItMS.Next()) {
+ const TopoDS_Shape& aSAx=aItMS.Value();
+ const TopoDS_Shape& aSCx=aCopier.Modified(aSAx).First();
+ myNewOldMap.Bind(aSCx, aSAx);
+ }
+ //
+ myArguments.Clear();
+ myArguments.Append(aSC);
+}
+//=======================================================================
+//function : PostTreatCopy
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PostTreatCopy()
+{
+ Standard_Integer i, aNb;
+ //
+ myErrorStatus=0;
+ //
+ aNb=myDS->NbSourceShapes();
+ for (i=0; i!=aNb; ++i) {
+ BOPDS_ShapeInfo& aSI=myDS->ChangeShapeInfo(i);
+ const TopoDS_Shape& aSCi=aSI.Shape();
+ if (!myNewOldMap.IsBound(aSCi)) {
+ myErrorStatus=13;
+ return;
+ }
+ //
+ const TopoDS_Shape& aSAi=myNewOldMap.Find(aSCi);
+ aSI.SetShape(aSAi);
+ }
+}
+//
+// myErrorStatus:
+//
+// 10 - The number of the arguments is not 1
+// 11 - Exception is caught
+// 12 - BRepBuilderAPI_Copy is not done
+// 13 - myNewOldMap doe not contain DS shape
+
#include <BOPAlgo_PaveFiller.ixx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+
#include <NCollection_BaseAllocator.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_Iterator.hxx>
+
//=======================================================================
//function :
//purpose :
//=======================================================================
- BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
+BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
:
BOPAlgo_Algo()
{
//function :
//purpose :
//=======================================================================
- BOPAlgo_PaveFiller::BOPAlgo_PaveFiller(const Handle(NCollection_BaseAllocator)& theAllocator)
+BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
+ (const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator)
{
//function : ~
//purpose :
//=======================================================================
- BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
+BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
{
Clear();
}
//function : Clear
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::Clear()
+void BOPAlgo_PaveFiller::Clear()
{
if (myIterator) {
delete myIterator;
delete myDS;
myDS=NULL;
}
- myErrorStatus=2;
}
//=======================================================================
//function : DS
//purpose :
//=======================================================================
- const BOPDS_DS& BOPAlgo_PaveFiller::DS()
+const BOPDS_DS& BOPAlgo_PaveFiller::DS()
{
return *myDS;
}
//function : PDS
//purpose :
//=======================================================================
- BOPDS_PDS BOPAlgo_PaveFiller::PDS()
+BOPDS_PDS BOPAlgo_PaveFiller::PDS()
{
return myDS;
}
//function : Context
//purpose :
//=======================================================================
- Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context()
+Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context()
{
return myContext;
}
//function : SectionAttribute
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::SetSectionAttribute(const BOPAlgo_SectionAttribute& theSecAttr)
+void BOPAlgo_PaveFiller::SetSectionAttribute
+ (const BOPAlgo_SectionAttribute& theSecAttr)
{
mySectionAttribute = theSecAttr;
}
//function : SetArguments
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
+void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
{
myArguments=theLS;
}
//function : Arguments
//purpose :
//=======================================================================
- const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
+const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
{
return myArguments;
}
// function: Init
// purpose:
//=======================================================================
- void BOPAlgo_PaveFiller::Init()
+void BOPAlgo_PaveFiller::Init()
{
myErrorStatus=0;
//
// function: Perform
// purpose:
//=======================================================================
- void BOPAlgo_PaveFiller::Perform()
+void BOPAlgo_PaveFiller::Perform()
{
myErrorStatus=0;
- //
- Init();
- if (myErrorStatus) {
- return;
- }
- // 00
- PerformVV();
- if (myErrorStatus) {
- return;
- }
- // 01
- PerformVE();
- if (myErrorStatus) {
- return;
- }
- //
- myDS->UpdatePaveBlocks();
- // 11
- PerformEE();
- if (myErrorStatus) {
- return;
- }
- // 02
- PerformVF();
- if (myErrorStatus) {
- return;
- }
- // 12
- PerformEF();
- if (myErrorStatus) {
- return;
- }
- //
- MakeSplitEdges();
- if (myErrorStatus) {
- return;
- }
- //
- // 22
- PerformFF();
- if (myErrorStatus) {
- return;
- }
- //
- MakeBlocks();
- if (myErrorStatus) {
- return;
- }
- //
- RefineFaceInfoOn();
- //
- MakePCurves();
- if (myErrorStatus) {
- return;
- }
- //
- ProcessDE();
- if (myErrorStatus) {
- return;
- }
- //
+ try {
+ OCC_CATCH_SIGNALS
+ //
+ Init();
+ if (myErrorStatus) {
+ return;
+ }
+ // 00
+ PerformVV();
+ if (myErrorStatus) {
+ return;
+ }
+ // 01
+ PerformVE();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ myDS->UpdatePaveBlocks();
+ // 11
+ PerformEE();
+ if (myErrorStatus) {
+ return;
+ }
+ // 02
+ PerformVF();
+ if (myErrorStatus) {
+ return;
+ }
+ // 12
+ PerformEF();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ MakeSplitEdges();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ // 22
+ PerformFF();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ MakeBlocks();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ RefineFaceInfoOn();
+ //
+ MakePCurves();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ ProcessDE();
+ if (myErrorStatus) {
+ return;
+ }
+ } // try {
+ catch (Standard_Failure) {
+ myErrorStatus=11;
+ }
}
// Chapter's name
const char* g = "CCR commands";
//
- theCommands.Add("bopcheck" , "Use >bopcheck Shape [level of check: 0(V/V) - 5(all)]", __FILE__, bopcheck, g);
- theCommands.Add("bopargcheck" , "Use bopargcheck without parameters to get ", __FILE__, bopargcheck, g);
+ theCommands.Add("bopcheck",
+ "Use >bopcheck Shape [level of check: 0(V/V) - 5(all)]",
+ __FILE__, bopcheck, g);
+ theCommands.Add("bopargcheck" ,
+ "Use bopargcheck without parameters to get ",
+ __FILE__, bopargcheck, g);
}
//=======================================================================
//function : bopcheck
//purpose :
//=======================================================================
-Standard_Integer bopcheck (Draw_Interpretor& di, Standard_Integer n, const char** a )
+Standard_Integer bopcheck
+ (Draw_Interpretor& di, Standard_Integer n, const char** a )
{
-
if (n<2) {
di << " Use >bopcheck Shape [level of check: 0 - 5" << "\n";
- di << " The level of check defines which interferferences will be checked:\n";
+ di << " The level of check defines ";
+ di << " which interferferences will be checked:\n";
di << " 0 - only V/V;\n";
di << " 1 - V/V and V/E;\n";
di << " 2 - V/V, V/E and E/E;\n";
di << "null shapes are not allowed here!";
return 1;
}
- TopoDS_Shape aS = BRepBuilderAPI_Copy(aS1).Shape();
+ TopoDS_Shape aS = aS1;
//
Standard_Integer iErr, aTypeInt, i, ind, j;
Standard_Integer nI1, nI2, theLevelOfCheck;
theLevelOfCheck = (n==3) ? Draw::Atoi(a[2]) : 5;
if (theLevelOfCheck >= 0 && theLevelOfCheck < 5) {
- di << "Info:\nThe level of check is set to " << type[theLevelOfCheck]
- << ", i.e. intersection(s)\n";
+ di << "Info:\nThe level of check is set to "
+ << type[theLevelOfCheck] << ", i.e. intersection(s)\n";
for (i=theLevelOfCheck+1; i<=5; ++i) {
di << type[i];
if (i<5) {
BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF();
BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF();
//
- Standard_Integer aNb[6] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(),
- aVFs.Extent(), aEFs.Extent(), aFFs.Extent()};
+ Standard_Integer aNb[6] ={
+ aVVs.Extent(), aVEs.Extent(), aEEs.Extent(),
+ aVFs.Extent(), aEFs.Extent(), aFFs.Extent()
+ };
//
bSelfInt = Standard_False;
ind = 0;
for (aTypeInt = 0; aTypeInt < 6; ++aTypeInt) {
for (i = 0; i < aNb[aTypeInt]; ++i) {
- BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
- ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
- ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
- ((aTypeInt==3) ? (BOPDS_Interf*)(&aVFs(i)) :
- ((aTypeInt==4) ? (BOPDS_Interf*)(&aEFs(i)) : (BOPDS_Interf*)(&aFFs(i))))));
+ BOPDS_Interf* aInt =
+ (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
+ ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
+ ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
+ ((aTypeInt==3) ? (BOPDS_Interf*)(&aVFs(i)) :
+ ((aTypeInt==4) ? (BOPDS_Interf*)(&aEFs(i)) :
+ (BOPDS_Interf*)(&aFFs(i))))));
//
nI1 = aInt->Index1();
nI2 = aInt->Index2();
bSelfInt = Standard_True;
}
}
-
+ //
if (iErr) {
- di << "There were errors during the operation, so the list may be incomplete." << "\n";
+ di << "There were errors during the operation, ";
+ di << "so the list may be incomplete." << "\n";
}
-
+ //
if (!bSelfInt) {
di << " This shape seems to be OK." << "\n";
}
-
return 0;
}
-static void MakeShapeForFullOutput(const TCollection_AsciiString & aBaseName,
- const Standard_Integer aIndex,
- const BOPCol_ListOfShape & aList,
- Standard_Integer& aCount,
- Draw_Interpretor& di)
+//=======================================================================
+//function : MakeShapeForFullOutput
+//purpose :
+//=======================================================================
+static void MakeShapeForFullOutput
+ (const TCollection_AsciiString & aBaseName,
+ const Standard_Integer aIndex,
+ const BOPCol_ListOfShape & aList,
+ Standard_Integer& aCount,
+ Draw_Interpretor& di)
{
TCollection_AsciiString aNum(aIndex);
TCollection_AsciiString aName = aBaseName + aNum;
}
-Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const char** a )
+//=======================================================================
+//function : bopargcheck
+//purpose :
+//=======================================================================
+Standard_Integer bopargcheck
+ (Draw_Interpretor& di, Standard_Integer n, const char** a )
{
if (n<2) {
di << "\n";
- di << " Use >bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n";
+ di << " Use >bopargcheck Shape1 [[Shape2] ";
+ di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n";
di << " -<Boolean Operation>" << "\n";
di << " F (fuse)" << "\n";
di << " O (common)" << "\n";
di << " T (cut21)" << "\n";
di << " S (section)" << "\n";
di << " U (unknown)" << "\n";
- di << " For example: \"bopargcheck s1 s2 -F\" enables checking for Fuse operation" << "\n";
+ di << " For example: \"bopargcheck s1 s2 -F\" enables" ;
+ di << "checking for Fuse operation" << "\n";
di << " default - section" << "\n" << "\n";
di << " /<Test Options>" << "\n";
di << " R (disable small edges (shrank range) test)" << "\n";
di << " I (disable self-interference test)" << "\n";
di << " P (disable shape type test)" << "\n";
di << " C (disable test for shape continuity)" << "\n";
- di << " For example: \"bopargcheck s1 s2 /RI\" disables small edge detection and self-intersection detection" << "\n";
+ di << " For example: \"bopargcheck s1 s2 /RI\" disables ";
+ di << "small edge detection and self-intersection detection" << "\n";
di << " default - all options are enabled" << "\n" << "\n";
di << " #<Additional Test Options>" << "\n";
di << " B (stop test on first faulty found); default OFF" << "\n";
- di << " F (full output for faulty shapes); default - output in a short format" << "\n" << "\n";
- di << " NOTE: <Boolean Operation> and <Test Options> are used only for couple" << "\n";
- di << " of argument shapes, except I and P options that are always used for" << "\n";
- di << " couple of shapes as well as for single shape test." << "\n";
+ di << " F (full output for faulty shapes); default - output ";
+ di << "in a short format" << "\n" << "\n";
+ di << " NOTE: <Boolean Operation> and <Test Options> are ";
+ di << "used only for couple" << "\n";
+ di << " of argument shapes, except I and P options ";
+ di << "that are always used for" << "\n";
+ di << " couple of shapes as well as for ";
+ di <<"single shape test." << "\n";
return 1;
}
- TopoDS_Shape aS11 = DBRep::Get(a[1]);
+ TopoDS_Shape aS1 = DBRep::Get(a[1]);
- if(aS11.IsNull()) {
+ if(aS1.IsNull()) {
di << "Error: null shape not allowed!" << "\n";
- di << "Type bopargcheck without arguments for more information" << "\n";
+ di << "Type bopargcheck without arguments for more ";
+ di <<"information" << "\n";
return 1;
}
- TopoDS_Shape aS1 = BRepBuilderAPI_Copy(aS11).Shape();
-
Standard_Boolean isBO = Standard_False;
Standard_Integer indxBO = 0;
--- /dev/null
+puts "============"
+puts "OCC24620"
+puts "============"
+puts ""
+#######################################################################
+# BOPAlgo_CheckerSI returns interferences that are not sub-shapes of the source shape
+#######################################################################
+
+vertex v1 0 0 0
+vertex v2 10 0 0
+vertex v3 4 -5 0
+vertex v4 4 5 0
+edge e1 v1 v2
+edge e2 v3 v4
+compound e1 e2 b1
+
+bopcheck b1
+
+compound x0 x1 b1 result
+
+set nb_v_good 4
+set nb_e_good 2
+set nb_w_good 0
+set nb_f_good 0
+set nb_sh_good 0
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 2
+set nb_shape_good 8
+
+set 2dviewer 1
-puts "TODO OCC12345 ALL: An exception was caught"
-puts "TODO OCC12345 ALL: \\*\\* Exception \\*\\*.*"
+#puts "TODO OCC12345 ALL: An exception was caught"
+#puts "TODO OCC12345 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO OCC12345 ALL: TEST INCOMPLETE"
+puts "TODO OCC12345 ALL: xception"
puts "========================"
puts " OCC469 "