mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0021762: Integration of new Boolean Operation algorithm to OCCT.
Modifications: - BRepOffset/BRepOffset_Tool.cxx, Features and Fillets algorithms have been ported on new BO algorithm. - Old BO algorithm, that was implemented in BOP, BooleanOperations and BOPTools packages, has - been deleted. - Porting SALOME algorithms to new BOP algorithm. - Fixing regressions. Rebased on current master. - Corrections in post treatment of section edges; - Corrections in the accordance with the bug 0023293; - Small corrections in the bopcheck and bopargcheck commands. - NCollection maps have been replaced by NCollection indexed maps to guarantee the constant order of sub-shapes in the result of boolean operation. - Test case feat featprism M9 has been fixed. - Test cases chl 902 E3 H3 have been fixed (corrections in the treatment of section edges). - Test cases caf driver B6 B7, caf named_shape F6 F7 have been modified according to the new order of sub-shapes in the result of boolean operation. - Test cases blend buildevol G1, blend simple K4, bcommon_complex C7, feat featprism L6 have been modified as they are improvements. - Test case boolean bsection A3 has been modified according to the new syntax of the bsection command. - Test cases boolean bfuse_complex J1 P9 have been fixed (the function IsInternalFace has been modified to use the function GetFaceOff); - Test case chl 902 H3 has been fixed (changes in the treatment of section edges); - Test case boolean bsection D8 has been modified (removed TODO statement); - Test case boolean bsection A3 has been modified (as the shapes have been changed). - Added correction of the tolerance values of the shapes according to the bug 0023610. - test cases: boolean bcommon_complex C3, boolean bcut_complex F2 O7, boolean bfuse_complex C4 C5 E4, boolean bsection B6 M8 M9 N4 N5 N7, boolean bfuse_simple ZP6, draft angle G8, feat featprism S2 have been marked as invalid according to the bug 0022033; - New value of result has been set in the test cases : boolean bopsection D4 boolean bsection R8 as it is correct. - test case bugs modalg bug23472 has been rewritten according to the new format of bsection command. - The classes IntTools_Context and IntTools_ShrunkRange have been replaced by BOPInt_Context and BOPInt_ShrunkRange accordingly. - The new class BRepAlgoAPI_Check has been added according to the bug 0023648. - Some regressions have been fixed. - The following test cases have been marked as invalid or rewritten bugs modalg buc60462_2, 60531_2, 60776_1, bug472_1, bug472_2, bug472_3, bug497_3, bug62 bugs moddata bug26_1, bug26_2, - The test case bugs modalg buc60533 has been rewritten to use the general fuse algorithm for building the result. - The new value of the result has been set in the test case bugs modalg 60776_2. - The following test cases have been rewritten according to the new format of the bsection command bugs modlag fra62369, pro18892 bugs moddata bug75_1, bug75_2 - Corrected BRepAlgoAPI_Check. - Removed package BOPTColStd. - Rewritten test cases caf named_shape F8 F9. - Removed unnecessary comments. - Corrected the following test scripts : boolean bcut_complex(012) O3 O4 O5 O6 O8 boolean bfuse_complex(013) O5 O6 P8 boolean bopcommon_complex(021) D8 D9 boolean bopfuse_complex(022) H1 J6 boolean boptuc_complex(024) D5 bugs modalg(006) bug399 bug497_1 feat featprism(003) C4 - Corrections in the treatment of section edges (putting paves on the curves); - Corrections in BRepOffset_Tool; - The following test cases have been rewritten according to the new format of the bsection command bugs modalg bug6502, bug6554, bug6766_1, bug6766_3 - The new value of the result has been set in the following test cases bugs modalg bug1255, bug1255_1 - The following test cases have been marked as invalid or rewritten bugs modalg bug472_2, bug472_3, bug825_2 bugs moddata bug10603, bug152_1, bug152_2, bug3721_1, bug3721_2, bug3721_3 - The following test cases have been rewritten as improvements bugs modalg bug693, bug693_1, bug817_1 bugs moddata bug3721_5, bug3721_6, bug6862_3, bug6862_4, bug6862_6 - Test cases bugs modlag buc60787_1, buc60787_2, buc60788_2, buc60788_3 have been corrected. - Fixed some SALOME regressions (modifications in the treatment of the section edges); - Fixed test case bugs modalg bug23100; - Test cases bugs modalg bug21754, bug22990 have been corrected according to the new format of the bsection command. - Test cases bugs modalg bug13116_*, bug23711 have been fixed; - Test cases bugs modalg bug697_2, bug697_4, bug697_7, bug697_8 have been marked as invalid according to the issue 0022033; - Test cases bugs modalg bug22109_2, bug22109_3 have been corrected; - Test case bugs modalg bug18186 has been corrected as it is improvement; - Test case bugs modalg bug22802 has been deleted as there is no package BOPTColStd.
This commit is contained in:
330
src/BOPTools/BOPTools_Set.lxx
Normal file
330
src/BOPTools/BOPTools_Set.lxx
Normal file
@@ -0,0 +1,330 @@
|
||||
// Created by: Peter KURNEV
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
//#include <BOPTools_Set.ixx>
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
|
||||
static
|
||||
inline Standard_Boolean operator<(const TopoDS_Shape& theS1,
|
||||
const TopoDS_Shape& theS2);
|
||||
static
|
||||
inline void SortShell(const int n, TopoDS_Shape *a);
|
||||
|
||||
static
|
||||
inline Standard_Integer NormalizedIds(const Standard_Integer aId,
|
||||
const Standard_Integer aDiv);
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline BOPTools_Set::BOPTools_Set()
|
||||
:
|
||||
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
|
||||
myShapes(myAllocator)
|
||||
{
|
||||
myNbShapes=0;
|
||||
mySum=0;
|
||||
myUpper=432123;
|
||||
}
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline BOPTools_Set::BOPTools_Set(const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||
:
|
||||
myAllocator(theAllocator),
|
||||
myShapes(myAllocator)
|
||||
{
|
||||
myNbShapes=0;
|
||||
mySum=0;
|
||||
myUpper=432123;
|
||||
}
|
||||
//=======================================================================
|
||||
//function :~
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline BOPTools_Set::~BOPTools_Set()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void BOPTools_Set::Clear()
|
||||
{
|
||||
myNbShapes=0;
|
||||
mySum=0;
|
||||
myShapes.Clear();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NbShapes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Integer BOPTools_Set::NbShapes()const
|
||||
{
|
||||
return myNbShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
//function :Assign
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline BOPTools_Set& BOPTools_Set::Assign(const BOPTools_Set& theOther)
|
||||
{
|
||||
BOPCol_ListIteratorOfListOfShape aIt;
|
||||
//
|
||||
myShape=theOther.myShape;
|
||||
myNbShapes=theOther.myNbShapes;
|
||||
mySum=theOther.mySum;
|
||||
myUpper=theOther.myUpper;
|
||||
myAllocator=theOther.myAllocator;
|
||||
//
|
||||
myShapes.Clear();
|
||||
aIt.Initialize(theOther.myShapes);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aSx=aIt.Value();
|
||||
myShapes.Append(aSx);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline const TopoDS_Shape& BOPTools_Set::Shape()const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void BOPTools_Set::Add(const TopoDS_Shape& theS,
|
||||
const TopAbs_ShapeEnum theType)
|
||||
{
|
||||
if (theType==TopAbs_EDGE) {
|
||||
AddEdges(theS);
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Integer i, aNb, aId, aIdN;
|
||||
TopoDS_Shape *pShapes;
|
||||
TopExp_Explorer aExp;
|
||||
//
|
||||
myNbShapes=0;
|
||||
mySum=0;
|
||||
myShape=theS;
|
||||
//
|
||||
aExp.Init(theS, theType);
|
||||
for (aNb=0; aExp.More(); aExp.Next(), ++aNb) {
|
||||
}
|
||||
//
|
||||
if (!aNb) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
myNbShapes=aNb;
|
||||
pShapes=(TopoDS_Shape *)myAllocator->Allocate(aNb*sizeof(TopoDS_Shape));
|
||||
//
|
||||
aExp.ReInit();
|
||||
for (i=0; aExp.More(); aExp.Next(),++i) {
|
||||
const TopoDS_Shape& aSx=aExp.Current();
|
||||
new (pShapes+i) TopoDS_Shape();
|
||||
pShapes[i]=aSx;
|
||||
}
|
||||
//
|
||||
SortShell(aNb, pShapes);
|
||||
//
|
||||
myShapes.Clear();
|
||||
for (i=0; i<aNb; ++i) {
|
||||
const TopoDS_Shape& aSx=pShapes[i];
|
||||
myShapes.Append(aSx);
|
||||
//
|
||||
aId=aSx.HashCode(myUpper);
|
||||
aIdN=NormalizedIds(aId, aNb);
|
||||
mySum+=aIdN;
|
||||
}
|
||||
//
|
||||
for (i=0; i<aNb; ++i) {
|
||||
pShapes[i].~TopoDS_Shape();
|
||||
}
|
||||
myAllocator->Free((Standard_Address&)pShapes);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : AddEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void BOPTools_Set::AddEdges(const TopoDS_Shape& theS)
|
||||
{
|
||||
Standard_Integer i, aNb, aId, aIdN;
|
||||
TopoDS_Shape *pShapes;
|
||||
TopExp_Explorer aExp;
|
||||
//
|
||||
myNbShapes=0;
|
||||
mySum=0;
|
||||
myShape=theS;
|
||||
//
|
||||
aExp.Init(theS, TopAbs_EDGE);
|
||||
for (aNb=0; aExp.More(); aExp.Next()) {
|
||||
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
|
||||
if (!BRep_Tool::Degenerated(aE)) {
|
||||
++aNb;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (!aNb) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
myNbShapes=aNb;
|
||||
pShapes=(TopoDS_Shape *)myAllocator->Allocate(aNb*sizeof(TopoDS_Shape));
|
||||
//
|
||||
i=0;
|
||||
aExp.ReInit();
|
||||
for (; aExp.More(); aExp.Next()) {
|
||||
const TopoDS_Shape& aSx=aExp.Current();
|
||||
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aSx));
|
||||
if (!BRep_Tool::Degenerated(aE)) {
|
||||
new (pShapes+i) TopoDS_Shape();
|
||||
pShapes[i]=aSx;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
//
|
||||
SortShell(aNb, pShapes);
|
||||
//
|
||||
myShapes.Clear();
|
||||
for (i=0; i<aNb; ++i) {
|
||||
const TopoDS_Shape& aSx=pShapes[i];
|
||||
myShapes.Append(aSx);
|
||||
//
|
||||
aId=aSx.HashCode(myUpper);
|
||||
aIdN=NormalizedIds(aId, aNb);
|
||||
mySum+=aIdN;
|
||||
}
|
||||
//
|
||||
for (i=0; i<aNb; ++i) {
|
||||
pShapes[i].~TopoDS_Shape();
|
||||
}
|
||||
myAllocator->Free((Standard_Address&)pShapes);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsEqual
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean BOPTools_Set::IsEqual(const BOPTools_Set& theOther)const
|
||||
{
|
||||
Standard_Boolean bRet;
|
||||
//
|
||||
bRet=Standard_False;
|
||||
//
|
||||
if (theOther.myNbShapes!=myNbShapes) {
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
BOPCol_ListIteratorOfListOfShape aIt1, aIt2;
|
||||
//
|
||||
aIt1.Initialize(myShapes);
|
||||
aIt2.Initialize(theOther.myShapes);
|
||||
for (; aIt1.More()||aIt2.More(); aIt1.Next(), aIt2.Next()) {
|
||||
const TopoDS_Shape& aSx1=aIt1.Value();
|
||||
const TopoDS_Shape& aSx2=aIt2.Value();
|
||||
if (aSx1.TShape().operator->() != aSx2.TShape().operator->()) {
|
||||
return bRet;
|
||||
}
|
||||
}
|
||||
return !bRet;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : HashCode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Integer BOPTools_Set::HashCode(const Standard_Integer theUpper)const
|
||||
{
|
||||
return ::HashCode(mySum, theUpper);
|
||||
}
|
||||
//=======================================================================
|
||||
// function: NormalizedIds
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer NormalizedIds(const Standard_Integer aId,
|
||||
const Standard_Integer aDiv)
|
||||
{
|
||||
Standard_Integer aMax, aTresh, aIdRet;
|
||||
//
|
||||
aIdRet=aId;
|
||||
aMax=::IntegerLast();
|
||||
aTresh=aMax/aDiv;
|
||||
if (aId>aTresh) {
|
||||
aIdRet=aId%aTresh;
|
||||
}
|
||||
return aIdRet;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator<
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean operator<(const TopoDS_Shape& theS1,
|
||||
const TopoDS_Shape& theS2)
|
||||
{
|
||||
Standard_Address aAddr1, aAddr2;
|
||||
//
|
||||
const Handle(TopoDS_TShape)& aTS1=theS1.TShape();
|
||||
aAddr1=aTS1.operator->();
|
||||
//
|
||||
const Handle(TopoDS_TShape)& aTS2=theS2.TShape();
|
||||
aAddr2=aTS2.operator->();
|
||||
//
|
||||
return (aAddr1<aAddr2);
|
||||
}
|
||||
//=======================================================================
|
||||
// function: SortShell
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SortShell(const int n, TopoDS_Shape *a)
|
||||
{
|
||||
int nd, i, j, l, d=1;
|
||||
TopoDS_Shape x;
|
||||
//
|
||||
while(d<=n) {
|
||||
d*=2;
|
||||
}
|
||||
//
|
||||
while (d) {
|
||||
d=(d-1)/2;
|
||||
//
|
||||
nd=n-d;
|
||||
for (i=0; i<nd; ++i) {
|
||||
j=i;
|
||||
m30:;
|
||||
l=j+d;
|
||||
if (a[l] < a[j]){
|
||||
x=a[j];
|
||||
a[j]=a[l];
|
||||
a[l]=x;
|
||||
j-=d;
|
||||
if (j > -1) goto m30;
|
||||
}//if (a[l] < a[j]){
|
||||
}//for (i=0; i<nd; ++i)
|
||||
}//while (1)
|
||||
}
|
Reference in New Issue
Block a user