1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
emv
2013-02-08 17:42:05 +04:00
parent a8676008f7
commit 4e57c75ee1
642 changed files with 41074 additions and 67959 deletions

91
src/BOPAlgo/BOPAlgo.cdl Normal file
View File

@@ -0,0 +1,91 @@
-- 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.
package BOPAlgo
---Purpose:
uses
gp,
TopAbs,
Geom,
GeomAPI,
BRepClass3d,
TopoDS,
TopTools,
IntTools,
IntSurf,
--
BOPDS,
BOPInt,
BOPCol,
BOPTools
is
enumeration Operation is
COMMON,
FUSE,
CUT,
CUT21,
SECTION,
UNKNOWN
end Operation;
enumeration CheckStatus is
CheckUnknown,
BadType,
SelfIntersect,
TooSmallEdge,
NonRecoverableFace,
IncompatibilityOfVertex,
IncompatibilityOfEdge,
IncompatibilityOfFace,
OperationAborted,
NotValid
end CheckStatus;
--
-- classes
--
deferred class Algo;
deferred class BuilderShape;
class PaveFiller;
class Builder;
class BOP;
--
deferred class BuilderArea;
class BuilderFace;
class WireEdgeSet;
class WireSplitter;
class BuilderSolid;
class Tools;
class SectionAttribute;
class CheckerSI;
class ArgumentAnalyzer;
class CheckResult;
--
-- pointers
--
pointer PPaveFiller to PaveFiller from BOPAlgo;
pointer PWireEdgeSet to WireEdgeSet from BOPAlgo;
pointer PBOP to BOP from BOPAlgo;
pointer PBuilder to Builder from BOPAlgo;
pointer PArgumentAnalyzer to ArgumentAnalyzer from BOPAlgo;
--
imported ListOfCheckResult;
end BOPAlgo;

View File

@@ -0,0 +1,63 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
deferred class Algo from BOPAlgo
---Purpose: provides the root interface for algorithms
uses
BaseAllocator from BOPCol
--raises
is
Initialize
returns Algo from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_Algo();"
Initialize (theAllocator: BaseAllocator from BOPCol)
returns Algo from BOPAlgo;
Perform(me:out)
is deferred;
ErrorStatus (me)
returns Integer from Standard;
WarningStatus (me)
returns Integer from Standard;
CheckData(me:out)
is virtual protected;
CheckResult(me:out)
is virtual protected;
Allocator(me)
returns BaseAllocator from BOPCol;
---C++: return const &
fields
myAllocator : BaseAllocator from BOPCol is protected;
myErrorStatus : Integer from Standard is protected;
myWarningStatus : Integer from Standard is protected;
end Algo;

View File

@@ -0,0 +1,97 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Algo.ixx>
#include <NCollection_BaseAllocator.hxx>
//=======================================================================
// function:
// purpose:
//=======================================================================
BOPAlgo_Algo::BOPAlgo_Algo()
:
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
myErrorStatus(1),
myWarningStatus(0)
{}
//=======================================================================
// function:
// purpose:
//=======================================================================
BOPAlgo_Algo::BOPAlgo_Algo(const Handle(NCollection_BaseAllocator)& theAllocator)
:
myAllocator(theAllocator),
myErrorStatus(1),
myWarningStatus(0)
{}
//=======================================================================
// function: ~
// purpose:
//=======================================================================
BOPAlgo_Algo::~BOPAlgo_Algo()
{
}
//=======================================================================
//function : Allocator
//purpose :
//=======================================================================
const Handle(NCollection_BaseAllocator)& BOPAlgo_Algo::Allocator()const
{
return myAllocator;
}
//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
void BOPAlgo_Algo::CheckData()
{
myErrorStatus=0;
}
//=======================================================================
// function: CheckResult
// purpose:
//=======================================================================
void BOPAlgo_Algo::CheckResult()
{
myErrorStatus=0;
}
//=======================================================================
// function: ErrorStatus
// purpose:
//=======================================================================
Standard_Integer BOPAlgo_Algo::ErrorStatus()const
{
return myErrorStatus;
}
//=======================================================================
// function: WarningStatus
// purpose:
//=======================================================================
Standard_Integer BOPAlgo_Algo::WarningStatus()const
{
return myWarningStatus;
}
// myErrorStatus
//
// 1 - object is just initialized

View File

@@ -0,0 +1,175 @@
-- Created on: 2004-09-03
-- Created by: Oleg FEDYAEV
-- Copyright (c) 2004-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.
class ArgumentAnalyzer from BOPAlgo
---Purpose: check the validity of argument(s) for Boolean Operations
uses
Shape from TopoDS,
Operation from BOPAlgo,
CheckStatus from BOPAlgo,
ShapeEnum from TopAbs,
ListOfCheckResult from BOPAlgo
is
Create
returns ArgumentAnalyzer;
---Purpose: empty constructor
SetShape1(me: in out; TheShape: Shape from TopoDS);
---Purpose: sets object shape
SetShape2(me: in out; TheShape: Shape from TopoDS);
---Purpose: sets tool shape
GetShape1(me)
returns Shape from TopoDS;
---C++: return const &
---Purpose: returns object shape;
GetShape2(me)
returns Shape from TopoDS;
---C++: return const &
---Purpose: returns tool shape
---options
OperationType(me: in out)
returns Operation from BOPAlgo;
---C++: return &
---Purpose: returns ref
StopOnFirstFaulty(me: in out)
returns Boolean from Standard;
---C++: return &
---Purpose: returns ref
ArgumentTypeMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode
-- that means checking types of shapes.
Prepare(me: in out)
is protected;
---Purpose: Prepares data;
SelfInterMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of self-intersection of shapes.
SmallEdgeMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of small edges.
RebuildFaceMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of possibility to split or rebuild faces.
TangentMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of tangency between subshapes.
MergeVertexMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of problem of merging vertices.
MergeEdgeMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of problem of merging edges.
---
Perform(me: out);
---Purpose: performs analysis
HasFaulty(me)
returns Boolean from Standard;
---Purpose: result of test
GetCheckResult(me)
returns ListOfCheckResult from BOPAlgo;
---C++: return const &
---Purpose: returns a result of test
--- protected
TestTypes(me: out)
is protected;
TestSelfInterferences(me: out)
is protected;
TestSmallEdge(me: out)
is protected;
TestRebuildFace(me: out)
is protected;
TestTangent(me: out)
is protected;
TestMergeSubShapes(me: out; theType: ShapeEnum from TopAbs)
is protected;
TestMergeVertex(me: out)
is protected;
TestMergeEdge(me: out)
is protected;
-- TestMergeFace(me: out)
-- is protected;
fields
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myStopOnFirst : Boolean from Standard;
myOperation : Operation from BOPAlgo;
myArgumentTypeMode : Boolean from Standard;
mySelfInterMode : Boolean from Standard;
mySmallEdgeMode : Boolean from Standard;
myRebuildFaceMode : Boolean from Standard;
myTangentMode : Boolean from Standard;
myMergeVertexMode : Boolean from Standard;
myMergeEdgeMode : Boolean from Standard;
myEmpty1,myEmpty2 : Boolean from Standard;
myResult : ListOfCheckResult from BOPAlgo;
end ArgumentAnalyzer;

View File

@@ -0,0 +1,824 @@
// Created on: 2004-09-02
// Copyright (c) 2004-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 <BOPAlgo_ArgumentAnalyzer.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_SequenceOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <TColStd_Array2OfBoolean.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_CommonPrt.hxx>
#include <BOPAlgo_Operation.hxx>
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPAlgo_BuilderFace.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPDS_VectorOfInterfEE.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
#include <BOPDS_VectorOfInterfEF.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
#include <BOPInt_Context.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_ListOfShape.hxx>
// ================================================================================
// function: Constructor
// purpose:
// ================================================================================
BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() :
myStopOnFirst(Standard_False),
myOperation(BOPAlgo_UNKNOWN),
myArgumentTypeMode(Standard_False),
mySelfInterMode(Standard_False),
mySmallEdgeMode(Standard_False),
myRebuildFaceMode(Standard_False),
myTangentMode(Standard_False),
myMergeVertexMode(Standard_False),
myMergeEdgeMode(Standard_False),
myEmpty1(Standard_False),
myEmpty2(Standard_False)
// myMergeFaceMode(Standard_False)
{
}
// ================================================================================
// function: SetShape1
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::SetShape1(const TopoDS_Shape & TheShape)
{
myShape1 = TheShape;
}
// ================================================================================
// function: SetShape2
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::SetShape2(const TopoDS_Shape & TheShape)
{
myShape2 = TheShape;
}
// ================================================================================
// function: GetShape1
// purpose:
// ================================================================================
const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape1() const
{
return myShape1;
}
// ================================================================================
// function: GetShape2
// purpose:
// ================================================================================
const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape2() const
{
return myShape2;
}
// ================================================================================
// function: OperationType
// purpose:
// ================================================================================
BOPAlgo_Operation& BOPAlgo_ArgumentAnalyzer::OperationType()
{
return myOperation;
}
// ================================================================================
// function: StopOnFirstFaulty
// purpose:
// ================================================================================
Standard_Boolean & BOPAlgo_ArgumentAnalyzer::StopOnFirstFaulty()
{
return myStopOnFirst;
}
// ================================================================================
// function: Prepare
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::Prepare()
{
Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull();
if (!isS1) {
myEmpty1 = BOPTools_AlgoTools3D::IsEmptyShape(myShape1);
}
if (!isS2) {
myEmpty2 = BOPTools_AlgoTools3D::IsEmptyShape(myShape2);
}
}
// ================================================================================
// function: Perform
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::Perform()
{
try {
OCC_CATCH_SIGNALS
myResult.Clear();
Prepare();
if(myArgumentTypeMode) {
TestTypes();
}
if(mySelfInterMode) {
TestSelfInterferences();
}
if(mySmallEdgeMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestSmallEdge();
}
if(myRebuildFaceMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestRebuildFace();
}
if(myTangentMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestTangent();
}
if(myMergeVertexMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestMergeVertex();
}
if(myMergeEdgeMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestMergeEdge();
}
}
catch(Standard_Failure) {
BOPAlgo_CheckResult aResult;
aResult.SetCheckStatus(BOPAlgo_CheckUnknown);
myResult.Append(aResult);
}
}
// ================================================================================
// function: HasFaulty
// purpose:
// ================================================================================
Standard_Boolean BOPAlgo_ArgumentAnalyzer::HasFaulty() const
{
return ( !myResult.IsEmpty());
}
// ================================================================================
// function: GetCheckResult
// purpose:
// ================================================================================
const BOPAlgo_ListOfCheckResult& BOPAlgo_ArgumentAnalyzer::GetCheckResult() const
{
return myResult;
}
// ================================================================================
// function: TestTypes
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestTypes()
{
Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull();
if(isS1 && isS2) {
BOPAlgo_CheckResult aResult;
aResult.SetCheckStatus(BOPAlgo_BadType);
myResult.Append(aResult);
return;
}
//single shape check
if((isS1 && !isS2) || (!isS1 && isS2)) {
Standard_Boolean bIsEmpty = (isS1) ? myEmpty2 : myEmpty1;
if(bIsEmpty || myOperation!=BOPAlgo_UNKNOWN) {
const TopoDS_Shape & aS = (isS1) ? myShape2 : myShape1;
BOPAlgo_CheckResult aResult;
aResult.SetShape1(aS);
aResult.SetCheckStatus(BOPAlgo_BadType);
myResult.Append(aResult);
return;
}
}
// two shapes check (begin)
else {
if(myEmpty1 || myEmpty2) {
BOPAlgo_CheckResult aResult;
if(myEmpty1 && myEmpty2) {
aResult.SetShape1(myShape1);
aResult.SetShape2(myShape2);
}
else {
const TopoDS_Shape & aS = myEmpty1 ? myShape1 : myShape2;
if(myEmpty1)
aResult.SetShape1(aS);
else
aResult.SetShape2(aS);
}
aResult.SetCheckStatus(BOPAlgo_BadType);
myResult.Append(aResult);
return;
}
//
Standard_Integer aDim1, aDim2;
Standard_Boolean bBadTypes = Standard_False;
//
aDim1 = BOPTools_AlgoTools::Dimension(myShape1);
aDim2 = BOPTools_AlgoTools::Dimension(myShape2);
if (aDim1 < aDim2) {
if (myOperation == BOPAlgo_FUSE ||
myOperation == BOPAlgo_CUT21) {
bBadTypes = Standard_True;
}
}
else if (aDim1 > aDim2) {
if (myOperation == BOPAlgo_FUSE ||
myOperation == BOPAlgo_CUT) {
bBadTypes = Standard_True;
}
}
if (bBadTypes) {
BOPAlgo_CheckResult aResult;
aResult.SetShape1(myShape1);
aResult.SetShape2(myShape2);
aResult.SetCheckStatus(BOPAlgo_BadType);
myResult.Append(aResult);
}
}
}
// ================================================================================
// function: TestSelfInterferences
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
{
Standard_Integer ii = 0, j;
Standard_Boolean bSelfInt;
for(ii = 0; ii < 2; ii++) {
TopoDS_Shape aS = (ii == 0) ? myShape1 : myShape2;
if(aS.IsNull())
continue;
Standard_Boolean bIsEmpty = (ii == 0) ? myEmpty1 : myEmpty2;
if (bIsEmpty) {
continue;
}
BOPAlgo_CheckerSI aChecker;
BOPCol_ListOfShape anArgs;
anArgs.Append(aS);
aChecker.SetArguments(anArgs);
//
aChecker.Perform();
Standard_Integer iErr = aChecker.ErrorStatus();
//
const BOPDS_PDS& theDS = aChecker.PDS();
BOPDS_VectorOfInterfVV& aVVs=theDS->InterfVV();
BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE();
BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE();
BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF();
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 ind = 0;
for (Standard_Integer aTypeInt = 0; aTypeInt < 6; ++aTypeInt) {
for (Standard_Integer 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))))));
//
Standard_Integer nI1 = aInt->Index1();
Standard_Integer nI2 = aInt->Index2();
if (nI1 == nI2) {
continue;
}
//
const TopoDS_Shape& aS1 = theDS->Shape(nI1);
const TopoDS_Shape& aS2 = theDS->Shape(nI2);
//
if (aTypeInt == 5) {
bSelfInt = Standard_False;
BOPDS_InterfFF& aFF = aFFs(i);
BOPDS_VectorOfPoint& aVP=aFF.ChangePoints();
Standard_Integer aNbP=aVP.Extent();
BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
Standard_Integer aNbC=aVC.Extent();
if (!aNbP && !aNbC) {
continue;
}
for (j=0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC(j);
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
if (aLPBC.Extent()) {
bSelfInt = Standard_True;
break;
}
}
if (!bSelfInt) {
continue;
}
}
//
BOPAlgo_CheckResult aResult;
if(ii == 0)
aResult.SetShape1(myShape1);
else
aResult.SetShape2(myShape2);
if(ii == 0) {
aResult.AddFaultyShape1(aS1);
aResult.AddFaultyShape1(aS2);
}
else {
aResult.AddFaultyShape2(aS1);
aResult.AddFaultyShape2(aS2);
}
aResult.SetCheckStatus(BOPAlgo_SelfIntersect);
myResult.Append(aResult);
}
}
if (iErr) {
BOPAlgo_CheckResult aResult;
if(ii == 0)
aResult.SetShape1(myShape1);
else
aResult.SetShape2(myShape2);
if(ii == 0) {
aResult.AddFaultyShape1(myShape1);
}
else {
aResult.AddFaultyShape2(myShape2);
}
aResult.SetCheckStatus(BOPAlgo_OperationAborted);
myResult.Append(aResult);
}
}
}
// ================================================================================
// function: TestSmallEdge
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
{
Standard_Integer i = 0;
BRepExtrema_DistShapeShape aDist;
Handle(BOPInt_Context) aCtx;
//
aCtx = new BOPInt_Context;
for(i = 0; i < 2; i++) {
TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2;
if(aS.IsNull())
continue;
TopExp_Explorer anExp(aS, TopAbs_EDGE);
for(; anExp.More(); anExp.Next()) {
TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());
if(BOPTools_AlgoTools::IsMicroEdge(anEdge, aCtx)) {
Standard_Boolean bKeepResult = Standard_True;
if(myOperation == BOPAlgo_SECTION) {
TopoDS_Shape anOtherS = (i == 0) ? myShape2 : myShape1;
if(!anOtherS.IsNull()) {
aDist.LoadS2(anOtherS);
Standard_Boolean bVertexIsOnShape = Standard_False;
Standard_Integer ii = 0;
TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX);
for(; anExpV.More(); anExpV.Next()) {
TopoDS_Shape aV = anExpV.Current();
aDist.LoadS1(aV);
aDist.Perform();
if(aDist.IsDone()) {
for(ii = 1; ii <= aDist.NbSolution(); ii++) {
Standard_Real aTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(aV));
TopoDS_Shape aSupportShape = aDist.SupportOnShape2(ii);
switch(aSupportShape.ShapeType()) {
case TopAbs_VERTEX: {
aTolerance += BRep_Tool::Tolerance(TopoDS::Vertex(aSupportShape));
break;
}
case TopAbs_EDGE: {
aTolerance += BRep_Tool::Tolerance(TopoDS::Edge(aSupportShape));
break;
}
case TopAbs_FACE: {
aTolerance += BRep_Tool::Tolerance(TopoDS::Face(aSupportShape));
break;
}
default:
break;
}
if(aDist.Value() < aTolerance) {
bVertexIsOnShape = Standard_True;
break;
}
}
}
}
if(!bVertexIsOnShape) {
bKeepResult = Standard_False;
}
}
}
if(bKeepResult) {
BOPAlgo_CheckResult aResult;
if(i == 0) {
aResult.SetShape1(myShape1);
aResult.AddFaultyShape1(anEdge);
}
else {
aResult.SetShape2(myShape2);
aResult.AddFaultyShape2(anEdge);
}
aResult.SetCheckStatus(BOPAlgo_TooSmallEdge);
myResult.Append(aResult);
if(myStopOnFirst) {
return;
}
}
}
}
}
}
// ================================================================================
// function: TestRebuildFace
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestRebuildFace()
{
if((myOperation == BOPAlgo_SECTION) ||
(myOperation == BOPAlgo_UNKNOWN))
return;
Standard_Integer i = 0;
for(i = 0; i < 2; i++) {
TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2;
if(aS.IsNull())
continue;
TopExp_Explorer anExp(aS, TopAbs_FACE);
BOPCol_ListOfShape aLS;
for(; anExp.More(); anExp.Next()) {
TopoDS_Face aFace = TopoDS::Face(anExp.Current());
TopoDS_Face aFF = aFace;
aFF.Orientation(TopAbs_FORWARD);
TopExp_Explorer anExpE(aFF, TopAbs_EDGE);
Standard_Integer nbstartedges = 0;
aLS.Clear();
//
for(; anExpE.More(); anExpE.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&anExpE.Current()));
TopAbs_Orientation anOriE=aE.Orientation();
//
if (anOriE==TopAbs_INTERNAL) {
TopoDS_Edge aEE=aE;
aEE.Orientation(TopAbs_FORWARD);
aLS.Append(aEE);
aEE.Orientation(TopAbs_REVERSED);
aLS.Append(aEE);
}
else {
aLS.Append(aE);
}
nbstartedges++;
}
BOPAlgo_BuilderFace aBF;
aBF.SetFace(aFace);
aBF.SetShapes(aLS);
aBF.Perform();
const BOPCol_ListOfShape& aLF = aBF.Areas();
Standard_Boolean bBadFace = Standard_False;
if(aLF.Extent() != 1) {
bBadFace = Standard_True;
}
else {
Standard_Integer nbedgeused = 0;
anExpE.Init(aLF.First(), TopAbs_EDGE);
for(; anExpE.More(); anExpE.Next(), nbedgeused++);
if(nbstartedges != nbedgeused) {
bBadFace = Standard_True;
}
}
if(bBadFace) {
BOPAlgo_CheckResult aResult;
if(i == 0) {
aResult.SetShape1(myShape1);
aResult.AddFaultyShape1(aFace);
}
else {
aResult.SetShape2(myShape2);
aResult.AddFaultyShape2(aFace);
}
aResult.SetCheckStatus(BOPAlgo_NonRecoverableFace);
myResult.Append(aResult);
if(myStopOnFirst) {
return;
}
}
}
}
}
// ================================================================================
// function: TestTangent
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestTangent()
{
// not implemented
}
// ================================================================================
// function: TestMergeSubShapes
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType)
{
if(myShape1.IsNull() || myShape2.IsNull())
return;
if (myEmpty1 || myEmpty2)
return;
BOPAlgo_CheckStatus aStatus = BOPAlgo_CheckUnknown;
switch(theType) {
case TopAbs_VERTEX: {
aStatus = BOPAlgo_IncompatibilityOfVertex;
break;
}
case TopAbs_EDGE: {
aStatus = BOPAlgo_IncompatibilityOfEdge;
break;
}
case TopAbs_FACE: {
aStatus = BOPAlgo_IncompatibilityOfFace;
break;
}
default:
return;
}
TopExp_Explorer anExp1(myShape1, theType);
TopExp_Explorer anExp2(myShape2, theType);
BOPCol_SequenceOfShape aSeq1, aSeq2;
BOPCol_MapOfShape aMap1, aMap2;
for(; anExp1.More(); anExp1.Next()) {
TopoDS_Shape aS1 = anExp1.Current();
if(aMap1.Contains(aS1))
continue;
aSeq1.Append(aS1);
aMap1.Add(aS1);
}
for(; anExp2.More(); anExp2.Next()) {
TopoDS_Shape aS2 = anExp2.Current();
if(aMap2.Contains(aS2))
continue;
aSeq2.Append(aS2);
aMap2.Add(aS2);
}
TColStd_Array2OfBoolean anArrayOfFlag(1, aSeq1.Length(), 1, aSeq2.Length());
Standard_Integer i = 0, j = 0;
for(i = 1; i <= aSeq1.Length(); i++)
for(j = 1; j <= aSeq2.Length(); j++)
anArrayOfFlag.SetValue(i, j, Standard_False);
for(i = 1; i <= aSeq1.Length(); i++) {
TopoDS_Shape aS1 = aSeq1.Value(i);
BOPCol_ListOfShape aListOfS2;
Standard_Integer nbs = 0;
for(j = 1; j <= aSeq2.Length(); j++) {
TopoDS_Shape aS2 = aSeq2.Value(j);
Standard_Boolean bIsEqual = Standard_False;
if(theType == TopAbs_VERTEX) {
TopoDS_Vertex aV1 = TopoDS::Vertex(aS1);
TopoDS_Vertex aV2 = TopoDS::Vertex(aS2);
gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
Standard_Real aDist = aP1.Distance(aP2);
if(aDist <= (BRep_Tool::Tolerance(aV1) + BRep_Tool::Tolerance(aV2))) {
bIsEqual = Standard_True;
}
}
else if(theType == TopAbs_EDGE) {
Standard_Integer aDiscretize = 30;
Standard_Real aDeflection = 0.01;
TopoDS_Edge aE1 = TopoDS::Edge(aS1);
TopoDS_Edge aE2 = TopoDS::Edge(aS2);
IntTools_EdgeEdge aEE;
aEE.SetEdge1 (aE1);
aEE.SetEdge2 (aE2);
aEE.SetTolerance1 (BRep_Tool::Tolerance(aE1));
aEE.SetTolerance2 (BRep_Tool::Tolerance(aE2));
aEE.SetDiscretize (aDiscretize);
aEE.SetDeflection (aDeflection);
Standard_Real f = 0., l = 0.;
BRep_Tool::Range(aE1, f, l);
aEE.SetRange1(f, l);
BRep_Tool::Range(aE2, f, l);
aEE.SetRange2(f, l);
aEE.Perform();
if (aEE.IsDone()) {
const IntTools_SequenceOfCommonPrts& aCPrts = aEE.CommonParts();
Standard_Integer ii = 0;
for (ii = 1; ii <= aCPrts.Length(); ii++) {
const IntTools_CommonPrt& aCPart = aCPrts(ii);
if (aCPart.Type() == TopAbs_EDGE) {
bIsEqual = Standard_True;
}
}
}
}
else if(theType == TopAbs_FACE) {
// not yet implemented!
}
if(bIsEqual) {
anArrayOfFlag.SetValue(i, j, Standard_True );
aListOfS2.Append(aS2);
nbs++;
}
}
if(nbs > 1) {
BOPAlgo_CheckResult aResult;
aResult.SetShape1(myShape1);
aResult.SetShape2(myShape2);
aResult.AddFaultyShape1(aS1);
BOPCol_ListIteratorOfListOfShape anIt(aListOfS2);
for(; anIt.More(); anIt.Next()) {
aResult.AddFaultyShape2(anIt.Value());
}
aResult.SetCheckStatus(aStatus);
myResult.Append(aResult);
if(myStopOnFirst) {
return;
}
}
}
for(i = 1; i <= aSeq2.Length(); i++) {
TopoDS_Shape aS2 = aSeq2.Value(i);
BOPCol_ListOfShape aListOfS1;
Standard_Integer nbs = 0;
for(j = 1; j <= aSeq1.Length(); j++) {
TopoDS_Shape aS1 = aSeq1.Value(j);
if(anArrayOfFlag.Value(j, i)) {
aListOfS1.Append(aS1);
nbs++;
}
}
if(nbs > 1) {
BOPAlgo_CheckResult aResult;
aResult.SetShape1(myShape1);
aResult.SetShape2(myShape2);
BOPCol_ListIteratorOfListOfShape anIt(aListOfS1);
for(; anIt.More(); anIt.Next()) {
aResult.AddFaultyShape1(anIt.Value());
}
aResult.AddFaultyShape2(aS2);
aResult.SetCheckStatus(aStatus);
myResult.Append(aResult);
if(myStopOnFirst) {
return;
}
}
}
}
// ================================================================================
// function: TestMergeVertex
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestMergeVertex()
{
TestMergeSubShapes(TopAbs_VERTEX);
}
// ================================================================================
// function: TestMergeEdge
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestMergeEdge()
{
TestMergeSubShapes(TopAbs_EDGE);
}
// ================================================================================
// function: TestMergeFace
// purpose:
// ================================================================================
// void BOPAlgo_ArgumentAnalyzer::TestMergeFace()
// {
// not implemented
// }

View File

@@ -0,0 +1,62 @@
// 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.
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::ArgumentTypeMode()
{
return myArgumentTypeMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::SelfInterMode()
{
return mySelfInterMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::SmallEdgeMode()
{
return mySmallEdgeMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::RebuildFaceMode()
{
return myRebuildFaceMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::TangentMode()
{
return myTangentMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeVertexMode()
{
return myMergeVertexMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeEdgeMode()
{
return myMergeEdgeMode;
}
// inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode()
// {
// return myMergeFaceMode;
// }

114
src/BOPAlgo/BOPAlgo_BOP.cdl Normal file
View File

@@ -0,0 +1,114 @@
-- 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.
class BOP from BOPAlgo
inherits Builder from BOPAlgo
---Purpose:
uses
Shape from TopoDS,
BaseAllocator from BOPCol,
ListOfShape from BOPCol,
MapOfShape from BOPCol,
IndexedDataMapOfShapeListOfShape from BOPCol,
Operation from BOPAlgo,
PaveFiller from BOPAlgo
--raises
is
Create
---Purpose: Empty constructor
returns BOP from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BOP();"
Create (theAllocator: BaseAllocator from BOPCol)
returns BOP from BOPAlgo;
Clear(me:out)
is redefined;
---Purpose: Clears internal fields and arguments
AddArgument (me:out;
theShape: Shape from TopoDS)
---Purpose: Adds Object argument of the operation
is redefined;
AddTool (me:out;
theShape: Shape from TopoDS)
---Purpose: Adds Tool argument of the operation
is virtual;
Object(me)
returns Shape from TopoDS;
---C++: return const &
Tool(me)
returns Shape from TopoDS;
---C++: return const &
SetOperation(me:out;
theOperation: Operation from BOPAlgo);
Operation(me)
returns Operation from BOPAlgo;
--
-- protected methods
--
CheckData(me:out)
is redefined protected;
Prepare(me:out)
is redefined protected;
---Purpose: Provides preparing actions
PerformInternal(me:out;
thePF:PaveFiller from BOPAlgo)
is redefined protected;
---Purpose: Performs calculations using prepared Filler
-- object theDSF
BuildShape(me:out)
is protected;
BuildRC(me:out)
is protected;
BuildSolid(me:out)
is protected;
BuildSection(me:out)
is protected;
IsBoundSplits(me:out;
theS:Shape from TopoDS;
theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol)
returns Boolean from Standard
is protected;
fields
myNbArgs : Integer from Standard is protected;
myOperation : Operation from BOPAlgo is protected;
myArgs : Shape from TopoDS[2] is protected;
myDims : Integer from Standard[2] is protected;
--
myRC : Shape from TopoDS is protected;
myTools : ListOfShape from BOPCol is protected;
myMapTools : MapOfShape from BOPCol is protected;
end BOP;

778
src/BOPAlgo/BOPAlgo_BOP.cxx Normal file
View File

@@ -0,0 +1,778 @@
// 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 <BOPAlgo_BOP.ixx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPAlgo_BuilderSolid.hxx>
#include <TopoDS_Edge.hxx>
static
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim);
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP()
:
BOPAlgo_Builder(),
myTools(myAllocator),
myMapTools(100, myAllocator)
{
myNbArgs=2;
Clear();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Builder(theAllocator),
myTools(myAllocator),
myMapTools(100, myAllocator)
{
myNbArgs=2;
Clear();
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_BOP::~BOPAlgo_BOP()
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_BOP::Clear()
{
myOperation=BOPAlgo_UNKNOWN;
myTools.Clear();
myMapTools.Clear();
myDims[0]=-1;
myDims[1]=-1;
//
BOPAlgo_Builder::Clear();
}
//=======================================================================
//function : AddArgument
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddArgument(const TopoDS_Shape& theShape)
{
if (myMapFence.Add(theShape)) {
myArguments.Append(theShape);
myArgs[0]=theShape;
}
}
//=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape)) {
myTools.Append(theShape);
myArgs[1]=theShape;
//
if (myMapFence.Add(theShape)) {
myArguments.Append(theShape);
}
}
}
//=======================================================================
//function : Object
//purpose :
//=======================================================================
const TopoDS_Shape& BOPAlgo_BOP::Object()const
{
return myArgs[0];
}
//=======================================================================
//function : Tool
//purpose :
//=======================================================================
const TopoDS_Shape& BOPAlgo_BOP::Tool()const
{
return myArgs[1];
}
//=======================================================================
//function : SetOperation
//purpose :
//=======================================================================
void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation)
{
myOperation=theOperation;
}
//=======================================================================
//function : Operation
//purpose :
//=======================================================================
BOPAlgo_Operation BOPAlgo_BOP::Operation()const
{
return myOperation;
}
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================
void BOPAlgo_BOP::CheckData()
{
Standard_Integer i, aNb;
Standard_Boolean bFlag;
//
myErrorStatus=0;
//
aNb=myArguments.Extent();
if (aNb!=myNbArgs) {
myErrorStatus=10; // invalid number of arguments
return;
}
//
BOPAlgo_Builder::CheckData();
if (myErrorStatus) {
return;
}
//
for (i=0; i<myNbArgs; ++i) {
if (myArgs[i].IsNull()) {
myErrorStatus=11; // argument is null shape
return;
}
}
//
for (i=0; i<myNbArgs; ++i) {
bFlag = BOPTools_AlgoTools3D::IsEmptyShape(myArgs[i]);
if(bFlag) {
myWarningStatus = 2;
}
}
//
for (i=0; i<myNbArgs; ++i) {
myDims[i]=BOPTools_AlgoTools::Dimension(myArgs[i]);
if (myDims[i]<0) {
myErrorStatus=13; // non-homogenious argument
return;
}
}
//
if (myOperation==BOPAlgo_UNKNOWN) {
myErrorStatus=14; // non-licit oprtation
return;
}
else if (myDims[0]<myDims[1]) {
if (myOperation==BOPAlgo_FUSE ||
myOperation==BOPAlgo_CUT21) {
myErrorStatus=14; // non-licit oprtation for the arguments
return;
}
}
else if (myDims[0]>myDims[1]) {
if (myOperation==BOPAlgo_FUSE ||
myOperation==BOPAlgo_CUT) {
myErrorStatus=14; // non-licit oprtation for the arguments
return;
}
}
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void BOPAlgo_BOP::Prepare()
{
Standard_Integer i;
BRep_Builder aBB;
//
BOPAlgo_Builder::Prepare();
//
if(myWarningStatus == 2) {
switch(myOperation) {
case BOPAlgo_FUSE:
for ( i = 0; i < myNbArgs; i++ ) {
aBB.Add(myShape, myArgs[i]);
}
break;
case BOPAlgo_COMMON:
case BOPAlgo_SECTION:
break;
case BOPAlgo_CUT:
if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[0])) {
break;
} else {
aBB.Add(myShape, myArgs[0]);
}
break;
case BOPAlgo_CUT21:
if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[1])) {
break;
} else {
aBB.Add(myShape, myArgs[1]);
}
break;
default:
break;
}
}
}
//=======================================================================
//function : PerformInternal
//purpose :
//=======================================================================
void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
{
myErrorStatus=0;
myWarningStatus=0;
//
myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
myDS=myPaveFiller->PDS();
myContext=myPaveFiller->Context();
//
// 1. CheckData
CheckData();
if (myErrorStatus && !myWarningStatus) {
return;
}
//
// 2. Prepare
Prepare();
if (myErrorStatus) {
return;
}
if(myWarningStatus == 2) {
return;
}
//
// 3. Fill Images
// 3.1 Vertices
FillImagesVertices();
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_VERTEX);
if (myErrorStatus) {
return;
}
// 3.2 Edges
FillImagesEdges();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_EDGE);
if (myErrorStatus) {
return;
}
//-------------------------------- SECTION f
if (myOperation==BOPAlgo_SECTION) {
BuildSection();
PrepareHistory();
PostTreat();
return;
}
//-------------------------------- SECTION t
//
// 3.3 Wires
FillImagesContainers(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
// 3.4 Faces
FillImagesFaces();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_FACE);
if (myErrorStatus) {
return;
}
// 3.5 Shells
FillImagesContainers(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
// 3.6 Solids
FillImagesSolids();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SOLID);
if (myErrorStatus) {
return;
}
// 3.7 CompSolids
FillImagesContainers(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
// 3.8 Compounds
FillImagesCompounds();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPOUND);
if (myErrorStatus) {
return;
}
//
// 6.BuildShape;
BuildShape();
//
// 4.History
PrepareHistory();
//
// 5 Post-treatment
PostTreat();
}
//=======================================================================
//function : BuildShape
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildShape()
{
Standard_Integer aDmin, aNbLCB;
TopAbs_ShapeEnum aT1, aT2, aTR;
TopoDS_Shape aR, aRC;
TopoDS_Iterator aIt;
BRep_Builder aBB;
BOPCol_ListOfShape aLCB;
BOPCol_ListIteratorOfListOfShape aItLCB;
//
myErrorStatus=0;
//
BuildRC();
//myShape=myRC;
//
aDmin=myDims[1];
if (myDims[0]<myDims[1]) {
aDmin=myDims[0];
}
//
if (!aDmin) {
myShape=myRC;
return;
}
//
else if (aDmin==1 || aDmin==2) { //edges, faces
aT1=TopAbs_VERTEX;
aT2=TopAbs_EDGE;
aTR=TopAbs_WIRE;
if (aDmin==2) {
aT1=TopAbs_EDGE;
aT2=TopAbs_FACE;
aTR=TopAbs_SHELL;
}
//
BOPTools_AlgoTools::MakeConnexityBlocks(myRC, aT1, aT2, aLCB);
aNbLCB=aLCB.Extent();
if (!aNbLCB) {
myShape=myRC;
return;
}
//
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
//
aItLCB.Initialize(aLCB);
for (; aItLCB.More(); aItLCB.Next()) {
BOPTools_AlgoTools::MakeContainer(aTR, aR);
//
const TopoDS_Shape& aCB=aItLCB.Value();
aIt.Initialize(aCB);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBB.Add(aR, aS);
}
//
if (aTR==TopAbs_SHELL) {
BOPTools_AlgoTools::OrientFacesOnShell(aR);
}
//
aBB.Add(aRC, aR);
}
myShape=aRC;
}// elase if (aDmin==1 || aDmin==2) {
else { //aDmin=3
if (myOperation==BOPAlgo_FUSE) {
BuildSolid();
}
else {
myShape=myRC;
}
}
}
//=======================================================================
//function : BuildRC
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildRC()
{
Standard_Boolean bFlag;
Standard_Integer i, aDmin, aNb[2], iX, iY;
TopAbs_ShapeEnum aTmin;
TopoDS_Compound aC, aCS[2];
BRep_Builder aBB;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aItIm;
BOPCol_IndexedMapOfShape aMS[2];
BOPCol_IndexedMapOfShape aMSV[2];
//
myErrorStatus=0;
//
// A. Fuse
if (myOperation==BOPAlgo_FUSE) {
aBB.MakeCompound(aC);
aTmin=TypeToExplore(myDims[0]);
aExp.Init(myShape, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aS=aExp.Current();
aBB.Add(aC, aS);
}
myRC=aC;
return;
}
//
// B. Non-Fuse
//
// 1. Compounds CS that consist of an Arg or Images of the Arg
for (i=0; i<myNbArgs; ++i) {
aBB.MakeCompound(aCS[i]);
const TopoDS_Shape& aS=myArgs[i];
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
aBB.Add(aCS[i], aSIm);
}
}
else {
aBB.Add(aCS[i], aS);
}
}
//
aDmin=myDims[1];
if (myDims[0]<myDims[1]) {
aDmin=myDims[0];
}
aTmin=TypeToExplore(aDmin);
for (i=0; i<myNbArgs; ++i) {
aExp.Init(aCS[i], aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aS=aExp.Current();
if (aTmin == TopAbs_EDGE) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aS));
if (BRep_Tool::Degenerated(aE)) {
TopExp_Explorer aExpE(aE, TopAbs_VERTEX);
TopoDS_Shape aS1 = aExpE.Current();
if (myImages.IsBound(aS1)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS1);
const TopoDS_Shape& aSIm=aLSIm.First();
aMSV[i].Add(aSIm);
} else {
aMSV[i].Add(aS1);
}
}
}
//
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
aMS[i].Add(aSIm);
}
}
else {
aMS[i].Add(aS);
}
}
aNb[i]=aMS[i].Extent();
}
//
aBB.MakeCompound(aC);
//
// 3. Find common parts
if (myOperation==BOPAlgo_COMMON) {
iX=(aNb[0]>aNb[1])? 1 : 0;
iY=(iX+1)%2;
}
else if (myOperation==BOPAlgo_CUT) {
iX=0;
iY=1;
}
else if (myOperation==BOPAlgo_CUT21) {
iX=1;
iY=0;
}
for (i=1; i<=aNb[iX]; ++i) {
const TopoDS_Shape& aSx=aMS[iX].FindKey(i);
bFlag=aMS[iY].Contains(aSx);
if (aTmin == TopAbs_EDGE) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aSx));
if (BRep_Tool::Degenerated(aE)) {
TopExp_Explorer aExpE(aE, TopAbs_VERTEX);
TopoDS_Shape aSx1 = aExpE.Current();
TopoDS_Shape aSIm;
if (myImages.IsBound(aSx1)) {
const BOPCol_ListOfShape& aLSIm=myImages.Find(aSx1);
aSIm=aLSIm.First();
} else {
aSIm = aSx1;
}
bFlag=aMSV[iY].Contains(aSIm);
}
}
//
if (myOperation!=BOPAlgo_COMMON) {
bFlag=!bFlag;
}
//
if (bFlag) {
aBB.Add(aC, aSx);
}
}
//
myRC=aC;
}
//
//=======================================================================
//function : TypeToExplore
//purpose :
//=======================================================================
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
{
TopAbs_ShapeEnum aRet;
//
switch(theDim) {
case 0:
aRet=TopAbs_VERTEX;
break;
case 1:
aRet=TopAbs_EDGE;
break;
case 2:
aRet=TopAbs_FACE;
break;
case 3:
aRet=TopAbs_SOLID;
break;
default:
aRet=TopAbs_SHAPE;
break;
}
return aRet;
}
//=======================================================================
//function : BuildSolid
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildSolid()
{
Standard_Integer i, aNbF, aNbSx, iX, iErr;
TopAbs_Orientation aOr, aOr1;
TopoDS_Iterator aIt;
TopoDS_Shape aRC;
BRep_Builder aBB;
TopExp_Explorer aExp;
BOPCol_IndexedMapOfShape aMFI;
BOPCol_IndexedDataMapOfShapeListOfShape aMFS, aMEF;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_ListOfShape aSFS;
BOPAlgo_BuilderSolid aSB;
//
myErrorStatus=0;
//
aIt.Initialize(myRC);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
aExp.Init(aSx, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aFx=aExp.Current();
//
aOr=aFx.Orientation();
if (aOr==TopAbs_INTERNAL) {
aMFI.Add(aFx);
continue;
}
//
if (!aMFS.Contains(aFx)) {
BOPCol_ListOfShape aLSx;
//
aLSx.Append(aSx);
aMFS.Add(aFx, aLSx);
}
else {
iX=aMFS.FindIndex(aFx);
const TopoDS_Shape& aFx1=aMFS.FindKey(iX);
aOr1=aFx1.Orientation();
if (aOr1!=aOr) {
BOPCol_ListOfShape& aLSx=aMFS.ChangeFromKey(aFx);
aLSx.Append(aSx);
aMFS.Add(aFx, aLSx);
}
}
}
}
//
BOPCol_ListOfShape aLF, aLFx; //faces that will be added in the end;
// SFS
aNbF=aMFS.Extent();
for (i=1; i<=aNbF; ++i) {
const TopoDS_Shape& aFx=aMFS.FindKey(i);
const BOPCol_ListOfShape& aLSx=aMFS(i);
aNbSx=aLSx.Extent();
if (aNbSx==1) {
BOPTools::MapShapesAndAncestors(aFx, TopAbs_EDGE, TopAbs_FACE, aMEF);
if (IsBoundSplits(aFx, aMEF)){
aLFx.Append(aFx);
continue;
}
aLF.Append(aFx);
}
}
aItLS.Initialize(aLF);
for(; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx=aItLS.Value();
aSFS.Append(aFx);
}
// add faces from aLFx to aSFS;
aItLS.Initialize(aLFx);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx=aItLS.Value();
aSFS.Append(aFx);
}
//
aNbF=aMFI.Extent();
for (i=1; i<=aNbF; ++i) {
TopoDS_Shape aFx;
//
aFx=aMFI.FindKey(i);
aFx.Orientation(TopAbs_FORWARD);
aSFS.Append(aFx);
aFx.Orientation(TopAbs_REVERSED);
aSFS.Append(aFx);
}
//
// BuilderSolid
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
//
aSB.SetContext(myContext);
aSB.SetShapes(aSFS);
aSB.Perform();
iErr=aSB.ErrorStatus();
if (iErr) {
myErrorStatus=30; // SolidBuilder failed
return;
}
//
const BOPCol_ListOfShape& aLSR=aSB.Areas();
//
aItLS.Initialize(aLSR);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSR=aItLS.Value();
aBB.Add(aRC, aSR);
}
myShape=aRC;
}
//=======================================================================
//function : IsBoundImages
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BOP::IsBoundSplits(const TopoDS_Shape& aS,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF)
{
Standard_Boolean bRet = Standard_False;
if (mySplits.IsBound(aS) || myOrigins.IsBound(aS)) {
return !bRet;
}
BOPCol_ListIteratorOfListOfShape aIt;
Standard_Integer aNbLS;
TopAbs_Orientation anOr;
//
//check face aF may be connected to face from mySplits
TopExp_Explorer aExp(aS, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current()));
//
anOr = aE.Orientation();
if (anOr==TopAbs_INTERNAL) {
continue;
}
//
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
const BOPCol_ListOfShape& aLS=aMEF.FindFromKey(aE);
aNbLS = aLS.Extent();
if (!aNbLS) {
continue;
}
//
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx = aIt.Value();
if (mySplits.IsBound(aSx) || myOrigins.IsBound(aS)) {
return !bRet;
}
}
}
return bRet;
}

View File

@@ -0,0 +1,110 @@
// 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 <BOPAlgo_BOP.ixx>
#include <BOPDS_DS.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPDS_VectorOfFaceInfo.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
//function : BuildSection
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildSection()
{
Standard_Integer i, aNb, nE, aNbPB, j;
TopoDS_Shape aRC;
BRep_Builder aBB;
BOPCol_MapOfShape aME;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
//
myErrorStatus=0;
//
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
//1. Common Blocks
const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool();
aNb=aPBP.Extent();
for (i=0; i<aNb; ++i) {
const BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
if (aPB->IsCommonBlock()) {
const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
nE=aPB1->Edge();
const TopoDS_Shape& aE=myDS->Shape(nE);
if (aME.Add(aE)) {
aBB.Add(aRC, aE);
}
}
}
}
//2. Section Edges
const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool();
aNb=aFIP.Extent();
for (i=0; i<aNb; ++i) {
const BOPDS_FaceInfo& aFI=aFIP(i);
const BOPDS_IndexedMapOfPaveBlock& aMPB=aFI.PaveBlocksSc();
//
aNbPB=aMPB.Extent();
for (j=1; j<=aNbPB; ++j) {
const Handle(BOPDS_PaveBlock)& aPB=aMPB(j);
nE=aPB->Edge();
const TopoDS_Shape& aE=myDS->Shape(nE);
if (aME.Add(aE)) {
aBB.Add(aRC, aE);
}
}
}
//3. Shared Edges
BOPCol_IndexedMapOfShape aMEO, aMET;
BOPCol_MapIteratorOfMapOfShape aItME;
//
BOPTools::MapShapes(myArgs[0], TopAbs_EDGE, aMEO);
BOPTools::MapShapes(myArgs[1], TopAbs_EDGE, aMET);
//
aItME.Initialize(aMEO);
for (; aItME.More(); aItME.Next()) {
const TopoDS_Shape& aE = aItME.Value();
if (aMET.Contains(aE)) {
if (aME.Add(aE)) {
aBB.Add(aRC, aE);
}
}
}
myShape=aRC;
}

View File

@@ -0,0 +1,240 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
class Builder from BOPAlgo
inherits BuilderShape from BOPAlgo
---Purpose:
uses
ShapeEnum from TopAbs,
Shape from TopoDS,
ListOfShape from TopTools,
--
BaseAllocator from BOPCol,
ListOfInteger from BOPCol,
ListOfShape from BOPCol,
MapOfShape from BOPCol,
DataMapOfShapeShape from BOPCol,
DataMapOfShapeListOfShape from BOPCol,
Context from BOPInt,
PDS from BOPDS,
PaveFiller from BOPAlgo,
PPaveFiller from BOPAlgo
--raises
is
Create
returns Builder from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_Builder();"
Create (theAllocator: BaseAllocator from BOPCol)
returns Builder from BOPAlgo;
Clear(me:out)
is virtual;
PPaveFiller(me:out)
returns PPaveFiller from BOPAlgo;
PDS(me:out)
returns PDS from BOPDS;
AddArgument (me:out;
theShape: Shape from TopoDS)
is virtual;
Arguments(me)
returns ListOfShape from BOPCol;
---C++: return const &
Perform(me:out)
is redefined;
PerformWithFiller(me:out;
theFiller: PaveFiller from BOPAlgo)
is virtual;
--
-- History support
--
PrepareHistory (me:out)
---Purpose: Prepare information for history support
is redefined protected;
Generated (me:out;
theS : Shape from TopoDS)
---Purpose: Returns the list of shapes generated from the
-- shape theS.
returns ListOfShape from TopTools
is redefined;
---C++: return const &
Modified (me:out;
theS : Shape from TopoDS)
---Purpose: Returns the list of shapes modified from the shape
-- theS.
returns ListOfShape from TopTools
is redefined;
---C++: return const &
IsDeleted (me:out;
theS : Shape from TopoDS)
---Purpose: Returns true if the shape theS has been deleted.
returns Boolean from Standard
is redefined;
--
-- Debug
--
Images(me)
returns DataMapOfShapeListOfShape from BOPCol;
---C++: return const &
--
-- protected methods
--
PerformInternal(me:out;
thePF: PaveFiller from BOPAlgo)
is virtual protected;
CheckData(me:out)
is redefined protected;
Prepare(me:out)
is virtual protected;
FillImagesVertices(me:out)
is protected;
FillImagesEdges(me:out)
is protected;
BuildResult(me:out;
theType: ShapeEnum from TopAbs)
is virtual protected;
IsInterferred(me;
theS:Shape from TopoDS)
returns Boolean from Standard;
FillImagesContainers(me:out;
theType:ShapeEnum from TopAbs)
is protected;
FillImagesCompounds(me:out)
is protected;
FillImagesContainer(me:out;
theS:Shape from TopoDS;
theType:ShapeEnum from TopAbs)
is protected;
FillImagesCompound(me:out;
theS:Shape from TopoDS;
theMF:out MapOfShape from BOPCol)
is protected;
FillImagesFaces (me:out)
is protected;
BuildSplitFaces (me:out)
is virtual protected;
FillSameDomainFaces (me:out)
is protected;
FillImagesFaces1 (me:out)
is protected;
FillInternalVertices(me:out;
theLF:out ListOfShape from BOPCol;
theLIV:out ListOfInteger from BOPCol)
is protected;
--
-- solids
--
FillImagesSolids(me:out)
is protected;
BuildDraftSolid(me:out;
theSolid:Shape from TopoDS;
theDraftSolid:out Shape from TopoDS;
theLIF:out ListOfShape from BOPCol)
is protected;
FillIn3DParts(me:out;
theInParts:out DataMapOfShapeListOfShape from BOPCol;
theDraftSolids:out DataMapOfShapeShape from BOPCol;
theAllocator:BaseAllocator from BOPCol)
is virtual protected;
BuildSplitSolids(me:out;
theInParts:out DataMapOfShapeListOfShape from BOPCol;
theDraftSolids:out DataMapOfShapeShape from BOPCol;
theAllocator:BaseAllocator from BOPCol)
is protected;
FillInternalShapes(me:out)
is protected;
--
-- misc
--
PostTreat (me:out)
is virtual protected;
Origins(me)
returns DataMapOfShapeShape from BOPCol;
---C++: return const &
---Purpose: Returns myOrigins.
ShapesSD(me)
returns DataMapOfShapeShape from BOPCol;
---C++: return const &
---Purpose: Returns myShapesSD.
Splits (me)
returns DataMapOfShapeListOfShape from BOPCol;
---C++: return const &
---Purpose: Returns mySplits.
fields
myArguments : ListOfShape from BOPCol is protected;
myMapFence : MapOfShape from BOPCol is protected;
myPaveFiller : PPaveFiller from BOPAlgo is protected;
myDS : PDS from BOPDS is protected;
myContext : Context from BOPInt is protected;
myEntryPoint : Integer from Standard is protected;
--
myImages : DataMapOfShapeListOfShape from BOPCol is protected;
myShapesSD : DataMapOfShapeShape from BOPCol is protected;
--
mySplits : DataMapOfShapeListOfShape from BOPCol is protected;
myOrigins : DataMapOfShapeShape from BOPCol is protected;
end Builder;

View File

@@ -0,0 +1,374 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Builder.ixx>
#include <NCollection_IncAllocator.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <BOPTools_AlgoTools.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_Builder::BOPAlgo_Builder()
:
BOPAlgo_BuilderShape(),
myArguments(myAllocator),
myMapFence(100, myAllocator),
myPaveFiller(NULL),
myDS(NULL),
//myContext(NULL),
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator)
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_Builder::BOPAlgo_Builder(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_BuilderShape(theAllocator),
myArguments(myAllocator),
myMapFence(100, myAllocator),
myPaveFiller(NULL),
myDS(NULL),
//myContext(NULL),
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_Builder::~BOPAlgo_Builder()
{
if (myEntryPoint==1) {
if (myPaveFiller) {
delete myPaveFiller;
myPaveFiller=NULL;
}
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_Builder::Clear()
{
myArguments.Clear();
myMapFence.Clear();
myImages.Clear();
myShapesSD.Clear();
mySplits.Clear();
myOrigins.Clear();
}
//=======================================================================
//function : AddArgument
//purpose :
//=======================================================================
void BOPAlgo_Builder::AddArgument(const TopoDS_Shape& theShape)
{
if (myMapFence.Add(theShape)) {
myArguments.Append(theShape);
}
}
//=======================================================================
//function : Arguments
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const
{
return myArguments;
}
//=======================================================================
//function : Images
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
{
return myImages;
}
//=======================================================================
//function : Origins
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const
{
return myOrigins;
}
//=======================================================================
//function : ShapesSd
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const
{
return myShapesSD;
}
//=======================================================================
//function : Splits
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const
{
return mySplits;
}
//=======================================================================
//function : PPaveFiller
//purpose :
//=======================================================================
BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller()
{
return myPaveFiller;
}
//=======================================================================
//function : PDS
//purpose :
//=======================================================================
BOPDS_PDS BOPAlgo_Builder::PDS()
{
return myDS;
}
//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
void BOPAlgo_Builder::CheckData()
{
Standard_Integer aNb;
//
myErrorStatus=0;
//
aNb=myArguments.Extent();
if (aNb<2) {
myErrorStatus=100; // too few arguments to process
return;
}
//
// myPaveFiller
if (!myPaveFiller) {
myErrorStatus=101;
return;
}
//
myErrorStatus=myPaveFiller->ErrorStatus();
if (myErrorStatus) {
myErrorStatus=102; // PaveFiller is failed
return;
}
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void BOPAlgo_Builder::Prepare()
{
myErrorStatus=0;
//
BRep_Builder aBB;
TopoDS_Compound aC;
//
// 1. myShape is empty compound
aBB.MakeCompound(aC);
myShape=aC;
myFlagHistory=Standard_True;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_Builder::Perform()
{
myErrorStatus=0;
//
if (myEntryPoint==1) {
if (myPaveFiller) {
delete myPaveFiller;
myPaveFiller=NULL;
}
}
//
Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator;
//
BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
//
pPF->SetArguments(myArguments);
//
pPF->Perform();
//
myEntryPoint=1;
PerformInternal(*pPF);
}
//=======================================================================
//function : PerformWithFiller
//purpose :
//=======================================================================
void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
{
myEntryPoint=0;
PerformInternal(theFiller);
}
//=======================================================================
//function : PerformInternal
//purpose :
//=======================================================================
void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
{
myErrorStatus=0;
//
myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
myDS=myPaveFiller->PDS();
myContext=myPaveFiller->Context();
//
// 1. CheckData
CheckData();
if (myErrorStatus) {
return;
}
//
// 2. Prepare
Prepare();
if (myErrorStatus) {
return;
}
//
// 3. Fill Images
// 3.1 Vertice
FillImagesVertices();
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_VERTEX);
if (myErrorStatus) {
return;
}
// 3.2 Edges
FillImagesEdges();
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_EDGE);
if (myErrorStatus) {
return;
}
//
// 3.3 Wires
FillImagesContainers(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_WIRE);
if (myErrorStatus) {
return;
}
// 3.4 Faces
FillImagesFaces();
if (myErrorStatus) {
return;
}
//
BuildResult(TopAbs_FACE);
if (myErrorStatus) {
return;
}
// 3.5 Shells
FillImagesContainers(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SHELL);
if (myErrorStatus) {
return;
}
// 3.6 Solids
FillImagesSolids();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_SOLID);
if (myErrorStatus) {
return;
}
// 3.7 CompSolids
FillImagesContainers(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPSOLID);
if (myErrorStatus) {
return;
}
// 3.8 Compounds
FillImagesCompounds();
if (myErrorStatus) {
return;
}
BuildResult(TopAbs_COMPOUND);
if (myErrorStatus) {
return;
}
//
// 4.History
PrepareHistory();
//
//
// 5 Post-treatment
PostTreat();
}
//
// myErrorStatus
//
// 0 - Ok
//
//=======================================================================
//function : PostTreat
//purpose :
//=======================================================================
void BOPAlgo_Builder::PostTreat()
{
//BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
BOPTools_AlgoTools::CorrectTolerances(myShape, 0.01);
BOPTools_AlgoTools::CorrectShapeTolerances(myShape);
}

View File

@@ -0,0 +1,85 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
deferred class BuilderArea from BOPAlgo
inherits Algo from BOPAlgo
---Purpose: The root class for algorithms to build
-- faces/solids from set of edges/faces
uses
Shape from TopoDS,
BaseAllocator from BOPCol,
ListOfShape from BOPCol,
MapOfOrientedShape from BOPCol,
Context from BOPInt
--raises
is
Initialize
returns BuilderArea from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderArea();"
Initialize(theAllocator: BaseAllocator from BOPCol)
returns BuilderArea from BOPAlgo;
SetContext(me:out;
theContext:Context from BOPInt);
Shapes(me)
returns ListOfShape from BOPCol;
---C++: return const &
---C++: alias "Standard_EXPORT void SetShapes(const BOPCol_ListOfShape& theLS);"
Loops(me)
returns ListOfShape from BOPCol;
---C++: return const &
Areas(me)
returns ListOfShape from BOPCol;
---C++: return const &
PerformShapesToAvoid(me:out)
is deferred protected;
PerformLoops(me:out)
is deferred protected;
PerformAreas(me:out)
is deferred protected;
PerformInternalShapes(me:out)
is deferred protected;
fields
myContext : Context from BOPInt is protected;
myShapes : ListOfShape from BOPCol is protected;
myLoops : ListOfShape from BOPCol is protected;
myLoopsInternal : ListOfShape from BOPCol is protected;
myAreas : ListOfShape from BOPCol is protected;
myShapesToAvoid : MapOfOrientedShape from BOPCol is protected;
--
end BuilderArea;

View File

@@ -0,0 +1,142 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_BuilderArea.ixx>
#include <BOPCol_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <NCollection_BaseAllocator.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderArea::BOPAlgo_BuilderArea()
:
BOPAlgo_Algo(),
//myContext(NULL),
myShapes(myAllocator),
myLoops(myAllocator),
myLoopsInternal(myAllocator),
myAreas(myAllocator),
myShapesToAvoid(100, myAllocator)
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderArea::BOPAlgo_BuilderArea(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator),
//myContext(NULL),
myShapes(myAllocator),
myLoops(myAllocator),
myLoopsInternal(myAllocator),
myAreas(myAllocator),
myShapesToAvoid(100, myAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_BuilderArea::~BOPAlgo_BuilderArea()
{
}
//=======================================================================
//function : SetContext
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::SetContext(const Handle(BOPInt_Context)& theContext)
{
myContext=theContext;
}
//=======================================================================
//function : SetShapes
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::SetShapes(const BOPCol_ListOfShape& theLF)
{
BOPCol_ListIteratorOfListOfShape aIt;
//
myShapes.Clear();
aIt.Initialize(theLF);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
myShapes.Append(aF);
}
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Shapes()const
{
return myShapes;
}
//=======================================================================
//function : Loops
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Loops()const
{
return myLoops;
}
//=======================================================================
//function : Areas
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Areas()const
{
return myAreas;
}
/*
//=======================================================================
//function :PerformShapesToAvoid
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::PerformShapesToAvoid()
{
}
//=======================================================================
//function : PerformLoops
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::PerformLoops()
{
}
//=======================================================================
//function : PerformAreas
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::PerformAreas()
{
}
//=======================================================================
//function : PerformInternalShapes
//purpose :
//=======================================================================
void BOPAlgo_BuilderArea::PerformInternalShapes()
{
}
*/

View File

@@ -0,0 +1,84 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
class BuilderFace from BOPAlgo
inherits BuilderArea from BOPAlgo
---Purpose: The algorithm to build faces from set of edges
uses
Face from TopoDS,
BaseAllocator from BOPCol
--raises
is
Create
returns BuilderFace from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderFace();"
Create (theAllocator: BaseAllocator from BOPCol)
returns BuilderFace from BOPAlgo;
SetFace(me:out;
theFace:Face from TopoDS);
---Purpose: Sets the face generatix
Face(me)
---Purpose: Returns the face generatix
returns Face from TopoDS;
---C++: return const &
Perform(me:out)
---Purpose: Performs the algorithm
is redefined;
PerformShapesToAvoid(me:out)
---Purpose: Collect the edges that
-- a) are internal
-- b) are the same and have different orientation
is redefined protected;
PerformLoops(me:out)
---Purpose: Build draft wires
-- a)myLoops - draft wires that consist of
-- boundary edges
-- b)myLoopsInternal - draft wires that contains
-- inner edges
is redefined protected;
PerformAreas(me:out)
---Purpose: Build draft faces that contains boundary edges
is redefined protected;
PerformInternalShapes(me:out)
---Purpose: Build finalized faces with internals
is redefined protected;
CheckData(me:out)
is redefined protected;
fields
myFace : Face from TopoDS is protected;
end BuilderFace;

View File

@@ -0,0 +1,704 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_BuilderFace.ixx>
#include <gp_Pnt2d.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Geom_Surface.hxx>
#include <TopAbs.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <IntTools_FClass2d.hxx>
#include <BOPInt_Context.hxx>
//
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx>
#include <BOPAlgo_WireEdgeSet.hxx>
//
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPTools.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPAlgo_WireSplitter.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
static
Standard_Boolean IsGrowthWire(const TopoDS_Shape& ,
const BOPCol_IndexedMapOfShape& );
static
Standard_Boolean IsInside(const TopoDS_Shape& ,
const TopoDS_Shape& ,
Handle(BOPInt_Context)& );
static
void MakeInternalWires(const BOPCol_MapOfShape& ,
BOPCol_ListOfShape& );
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderFace::BOPAlgo_BuilderFace()
:
BOPAlgo_BuilderArea()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderFace::BOPAlgo_BuilderFace(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_BuilderArea(theAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_BuilderFace::~BOPAlgo_BuilderFace()
{
}
//=======================================================================
//function : SetFace
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace)
{
myFace=theFace;
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
const TopoDS_Face& BOPAlgo_BuilderFace::Face()const
{
return myFace;
}
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::CheckData()
{
myErrorStatus=0;
//
if (myContext.IsNull()) {
//myErrorStatus=11;// Null Context
//return;
myContext = new BOPInt_Context;
}
//
if (myFace.IsNull()) {
myErrorStatus=12;// Null face generix
return;
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::Perform()
{
myErrorStatus=0;
//
CheckData();
if (myErrorStatus) {
return;
}
//
PerformShapesToAvoid();
if (myErrorStatus) {
return;
}
//
PerformLoops();
if (myErrorStatus) {
return;
}
//
PerformAreas();
if (myErrorStatus) {
return;
}
//
PerformInternalShapes();
if (myErrorStatus) {
return;
}
}
//=======================================================================
//function :PerformShapesToAvoid
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::PerformShapesToAvoid()
{
Standard_Boolean bFound;
Standard_Integer i, iCnt, aNbV, aNbE;
BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
BOPCol_ListIteratorOfListOfShape aIt;
//
myShapesToAvoid.Clear();
//
iCnt=0;
while (1) {
++iCnt;
bFound=Standard_False;
//
// 1. MEF
aMVE.Clear();
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (!myShapesToAvoid.Contains(aE)) {
BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
//else {
//int a=0;
//}
}
aNbV=aMVE.Extent();
//
// 2. myEdgesToAvoid
for (i=1; i<=aNbV; ++i) {
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aMVE.FindKey(i)));
//
BOPCol_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
aNbE=aLE.Extent();
if (!aNbE) {
continue;
}
//
const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aLE.First()));
if (aNbE==1) {
if (BRep_Tool::Degenerated(aE1)) {
continue;
}
if (aV.Orientation()==TopAbs_INTERNAL) {
continue;
}
bFound=Standard_True;
myShapesToAvoid.Add(aE1);
}
else if (aNbE==2) {
const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aLE.Last()));
if (aE2.IsSame(aE1)) {
TopoDS_Vertex aV1x, aV2x;
//
TopExp::Vertices(aE1, aV1x, aV2x);
if (aV1x.IsSame(aV2x)) {
continue;
}
bFound=Standard_True;
myShapesToAvoid.Add(aE1);
myShapesToAvoid.Add(aE2);
}
}
}// for (i=1; i<=aNbE; ++i) {
//
if (!bFound) {
break;
}
//
}//while (1)
//printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
}
//=======================================================================
//function : PerformLoops
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::PerformLoops()
{
myErrorStatus=0;
//
Standard_Boolean bFlag;
Standard_Integer iErr, aNbEA;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_MapIteratorOfMapOfOrientedShape aItM;
BOPCol_IndexedDataMapOfShapeListOfShape aVEMap;
BOPCol_MapOfOrientedShape aMAdded;
TopoDS_Iterator aItW;
BRep_Builder aBB;
BOPAlgo_WireEdgeSet aWES(myAllocator);
BOPAlgo_WireSplitter aWSp(myAllocator);
//
// 1.
myLoops.Clear();
aWES.SetFace(myFace);
//
aIt.Initialize(myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (!myShapesToAvoid.Contains(aE)) {
aWES.AddStartElement(aE);
}
}
//
aWSp.SetWES(aWES);
aWSp.Perform();
iErr=aWSp.ErrorStatus();
if (iErr) {
return;
}
//
const BOPCol_ListOfShape& aLW=aWES.Shapes();
aIt.Initialize (aLW);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aW=aIt.Value();
myLoops.Append(aW);
}
// Post Treatment
BOPCol_MapOfOrientedShape aMEP;
//
// a. collect all edges that are in loops
aIt.Initialize (myLoops);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aW=aIt.Value();
aItW.Initialize(aW);
for (; aItW.More(); aItW.Next()) {
const TopoDS_Shape& aE=aItW.Value();
aMEP.Add(aE);
}
}
//
// b. collect all edges that are to avoid
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aE=aItM.Key();
aMEP.Add(aE);
}
//
// c. add all edges that are not processed to myShapesToAvoid
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (!aMEP.Contains(aE)) {
myShapesToAvoid.Add(aE);
}
}
//
// 2. Internal Wires
myLoopsInternal.Clear();
//
aNbEA=myShapesToAvoid.Extent();
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aEE=aItM.Key();
BOPTools::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
}
//
bFlag=Standard_True;
aItM.Initialize(myShapesToAvoid);
for (; aItM.More()&&bFlag; aItM.Next()) {
const TopoDS_Shape& aEE=aItM.Key();
if (!aMAdded.Add(aEE)) {
continue;
}
//
// make new wire
TopoDS_Wire aW;
aBB.MakeWire(aW);
aBB.Add(aW, aEE);
//
aItW.Initialize(aW);
for (; aItW.More()&&bFlag; aItW.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItW.Value()));
//
TopoDS_Iterator aItE(aE);
for (; aItE.More()&&bFlag; aItE.Next()) {
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&aItE.Value()));
const BOPCol_ListOfShape& aLE=aVEMap.FindFromKey(aV);
aIt.Initialize(aLE);
for (; aIt.More()&&bFlag; aIt.Next()) {
const TopoDS_Shape& aEx=aIt.Value();
if (aMAdded.Add(aEx)) {
aBB.Add(aW, aEx);
if(aMAdded.Extent()==aNbEA) {
bFlag=!bFlag;
}
}
}//for (; aIt.More(); aIt.Next()) {
}//for (; aItE.More(); aItE.Next()) {
}//for (; aItW.More(); aItW.Next()) {
myLoopsInternal.Append(aW);
}//for (; aItM.More(); aItM.Next()) {
}
//=======================================================================
//function : PerformAreas
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::PerformAreas()
{
myErrorStatus=0;
//
Standard_Boolean bIsGrowth, bIsHole;
Standard_Real aTol;
TopoDS_Shape anInfinitePointShape;
//
BOPCol_ListOfShape aNewFaces, aHoleWires;
BOPCol_DataMapOfShapeShape aInOutMap;
BOPCol_DataMapOfShapeListOfShape aMSH;
BOPCol_IndexedMapOfShape aMHE;
BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
BOPCol_ListIteratorOfListOfShape aIt1, aIt2;
BRep_Builder aBB;
Handle(Geom_Surface) aS;
TopLoc_Location aLoc;
//
aTol=BRep_Tool::Tolerance(myFace);
aS=BRep_Tool::Surface(myFace, aLoc);
//
myAreas.Clear();
//
// Draft faces [aNewFaces]
aIt1.Initialize(myLoops);
for ( ; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aWire=aIt1.Value();
//
bIsGrowth=IsGrowthWire(aWire, aMHE);
if (bIsGrowth) {
// make a growth face from a wire
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
aBB.Add (aFace, aWire);
//
aNewFaces.Append (aFace);
}
else{
// check if a wire is a hole
//XX
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
aBB.Add (aFace, aWire);
//
IntTools_FClass2d& aClsf=myContext->FClass2d(aFace);
aClsf.Init(aFace, aTol);
//
bIsHole=aClsf.IsHole();
//
//bIsHole=BOPTools_AlgoTools::IsHole(aWire, myFace);
//XX
if (bIsHole) {
aHoleWires.Append(aWire);
BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE);
}
else {
// make a growth face from a wire
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
aBB.Add (aFace, aWire);
//
aNewFaces.Append (aFace);
}
}
}
//
// 2. Find outer growth shell that is most close to each hole shell
aIt2.Initialize(aHoleWires);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aHole = aIt2.Value();
//
aIt1.Initialize(aNewFaces);
for ( ; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aF=aIt1.Value();
//
if (!IsInside(aHole, aF, myContext)){
continue;
}
//
if ( aInOutMap.IsBound (aHole)){
const TopoDS_Shape& aF2=aInOutMap(aHole);
if (IsInside(aF, aF2, myContext)) {
aInOutMap.UnBind(aHole);
aInOutMap.Bind (aHole, aF);
}
}
else{
aInOutMap.Bind (aHole, aF);
}
}
//
// Add aHole to a map Face/ListOfHoles [aMSH]
if (aInOutMap.IsBound(aHole)){
const TopoDS_Shape& aF=aInOutMap(aHole);
if (aMSH.IsBound(aF)) {
BOPCol_ListOfShape& aLH=aMSH.ChangeFind(aF);
aLH.Append(aHole);
}
else {
BOPCol_ListOfShape aLH;
aLH.Append(aHole);
aMSH.Bind(aF, aLH);
}
}
}// for (; aIt2.More(); aIt2.Next())
//
// 3. Add aHoles to Faces
aItMSH.Initialize(aMSH);
for (; aItMSH.More(); aItMSH.Next()) {
TopoDS_Face aF=(*(TopoDS_Face *)(&aItMSH.Key()));
//
const BOPCol_ListOfShape& aLH=aItMSH.Value();
aIt2.Initialize(aLH);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aHole = aIt2.Value();
aBB.Add (aF, aHole);
}
//
// update classifier
aTol=BRep_Tool::Tolerance(aF);
IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
aClsf.Init(aF, aTol);
}
//
// These aNewFaces are draft faces that
// do not contain any internal shapes
//
aIt1.Initialize(aNewFaces);
for ( ; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aF=aIt1.Value();
myAreas.Append(aF);
}
}
//=======================================================================
//function : PerformInternalShapes
//purpose :
//=======================================================================
void BOPAlgo_BuilderFace::PerformInternalShapes()
{
myErrorStatus=0;
//
Standard_Integer aNbWI=myLoopsInternal.Extent();
if (!aNbWI) {// nothing to do
return;
}
//
//Standard_Real aTol;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aIt1, aIt2;
TopoDS_Iterator aIt;
BOPCol_MapOfShape aME, aMEP;
BOPCol_MapIteratorOfMapOfShape aItME;
BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
BOPCol_ListOfShape aLSI;
//
// 1. All internal edges
aIt1.Initialize(myLoopsInternal);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aWire=aIt1.Value();
aIt.Initialize(aWire);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
aME.Add(aE);
}
}
aNbWI=aME.Extent();
//
// 2 Process faces
aIt2.Initialize(myAreas);
for ( ; aIt2.More(); aIt2.Next()) {
TopoDS_Face& aF=(*(TopoDS_Face *)(&aIt2.Value()));
//
aMVE.Clear();
BOPTools::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
//
// 2.1 Separate faces to process aMEP
aMEP.Clear();
aItME.Initialize(aME);
for (; aItME.More(); aItME.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItME.Key()));
if (IsInside(aE, aF, myContext)) {
aMEP.Add(aE);
}
}
//
// 2.2 Make Internal Wires
aLSI.Clear();
MakeInternalWires(aMEP, aLSI);
//
// 2.3 Add them to aF
aIt1.Initialize(aLSI);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSI=aIt1.Value();
aBB.Add (aF, aSI);
}
//
// 2.4 Remove faces aMFP from aMF
aItME.Initialize(aMEP);
for (; aItME.More(); aItME.Next()) {
const TopoDS_Shape& aE=aItME.Key();
aME.Remove(aE);
}
//
aNbWI=aME.Extent();
if (!aNbWI) {
break;
}
} //for ( ; aIt2.More(); aIt2.Next()) {
}
//=======================================================================
//function : MakeInternalWires
//purpose :
//=======================================================================
void MakeInternalWires(const BOPCol_MapOfShape& theME,
BOPCol_ListOfShape& theWires)
{
BOPCol_MapIteratorOfMapOfShape aItM;
BOPCol_MapOfShape aAddedMap;
BOPCol_ListIteratorOfListOfShape aItE;
BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
BRep_Builder aBB;
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aE=aItM.Key();
BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
//
aItM.Initialize(theME);
for (; aItM.More(); aItM.Next()) {
TopoDS_Shape aEE=aItM.Key();
if (!aAddedMap.Add(aEE)) {
continue;
}
//
// make a new shell
TopoDS_Wire aW;
aBB.MakeWire(aW);
aEE.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEE);
//
TopoDS_Iterator aItAdded (aW);
for (; aItAdded.More(); aItAdded.Next()) {
const TopoDS_Shape& aE =aItAdded.Value();
//
TopExp_Explorer aExp(aE, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aV =aExp.Current();
const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aV);
aItE.Initialize(aLE);
for (; aItE.More(); aItE.Next()) {
TopoDS_Shape aEL=aItE.Value();
if (aAddedMap.Add(aEL)){
aEL.Orientation(TopAbs_INTERNAL);
aBB.Add(aW, aEL);
}
}
}
}
theWires.Append(aW);
}
}
//=======================================================================
//function : IsInside
//purpose :
//=======================================================================
Standard_Boolean IsInside(const TopoDS_Shape& theHole,
const TopoDS_Shape& theF2,
Handle(BOPInt_Context)& theContext)
{
Standard_Boolean bRet;
Standard_Real aT, aU, aV;
TopAbs_State aState;
TopExp_Explorer aExp;
BOPCol_IndexedMapOfShape aME2;
gp_Pnt2d aP2D;
//
bRet=Standard_False;
aState=TopAbs_UNKNOWN;
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&theF2));
//
BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);//AA
//
aExp.Init(theHole, TopAbs_EDGE);
if (aExp.More()) {
const TopoDS_Edge& aE =(*(TopoDS_Edge *)(&aExp.Current()));
if (aME2.Contains(aE)) {
return bRet;
}
if (!BRep_Tool::Degenerated(aE)) {
//
aT=BOPTools_AlgoTools2D::IntermediatePoint(aE);
BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV);
aP2D.SetCoord(aU, aV);
//
IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
aState=aClsf.Perform(aP2D);
bRet=(aState==TopAbs_IN);
}
}
//
return bRet;
}
//=======================================================================
//function : IsGrowthWire
//purpose :
//=======================================================================
Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
const BOPCol_IndexedMapOfShape& theMHE)
{
Standard_Boolean bRet;
TopoDS_Iterator aIt;
//
bRet=Standard_False;
if (theMHE.Extent()) {
aIt.Initialize(theWire);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (theMHE.Contains(aE)) {
return !bRet;
}
}
}
return bRet;
}
//BRepTools::Write(aFF, "ff");
//
// ErrorStatus :
// 11 - Null Context
// 12 - Null face generix

View File

@@ -0,0 +1,113 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
deferred class BuilderShape from BOPAlgo
inherits Algo from BOPAlgo
---Purpose: Root class for algorithms that has shape as result
uses
Shape from TopoDS,
ListOfShape from TopTools,
BaseAllocator from BOPCol,
MapOfShape from BOPCol,
IndexedDataMapOfShapeListOfShape from BOPCol
--raises
is
Initialize
returns BuilderShape from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderShape();"
Initialize (theAllocator: BaseAllocator from BOPCol)
returns BuilderShape from BOPAlgo;
Shape(me)
---Purpose: Returns the result of algorithm
returns Shape from TopoDS;
---C++: return const &
------------------------------------------------------------------
--- The following methods are not implemented at this level.
-- An empty list is returned.
--- They are optional and can be redefined.
------------------------------------------------------------------
Generated (me:out;
theS : Shape from TopoDS)
---Purpose: Returns the list of shapes generated from the
-- shape theS.
returns ListOfShape from TopTools
is virtual;
---C++: return const &
Modified (me:out;
theS : Shape from TopoDS)
---Purpose: Returns the list of shapes modified from the
-- shape theS.
returns ListOfShape from TopTools
is virtual;
---C++: return const &
IsDeleted (me:out;
theS : Shape from TopoDS)
---Purpose: Returns true if the shape theS has been deleted.
returns Boolean from Standard
is virtual;
HasDeleted (me)
---Purpose: Returns true if the at least one shape(or subshape)
-- of arguments has been deleted.
returns Boolean from Standard;
HasGenerated (me)
---Purpose: Returns true if the at least one shape(or subshape)
-- of arguments has generated shapes.
returns Boolean from Standard;
HasModified (me)
---Purpose: Returns true if the at least one shape(or subshape)
-- of arguments has modified shapes.
returns Boolean from Standard;
PrepareHistory (me:out)
---Purpose: Prepare information for history support
is virtual protected;
ImagesResult(me)
returns IndexedDataMapOfShapeListOfShape from BOPCol;
---C++: return const &
fields
myShape : Shape from TopoDS is protected;
--
myHistShapes : ListOfShape from TopTools is protected;
myMapShape : MapOfShape from BOPCol is protected;
myHasDeleted : Boolean from Standard is protected;
myHasGenerated : Boolean from Standard is protected;
myHasModified : Boolean from Standard is protected;
myImagesResult : IndexedDataMapOfShapeListOfShape from BOPCol is protected;
myFlagHistory : Boolean from Standard is protected;
end BuilderShape;

View File

@@ -0,0 +1,142 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_BuilderShape.ixx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderShape::BOPAlgo_BuilderShape()
:
BOPAlgo_Algo()
{
myHasDeleted=Standard_False;
myHasGenerated=Standard_False;
myHasModified=Standard_False;
myFlagHistory=Standard_False;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderShape::BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator)
{
myHasDeleted=Standard_False;
myHasGenerated=Standard_False;
myHasModified=Standard_False;
myFlagHistory=Standard_False;
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_BuilderShape::~BOPAlgo_BuilderShape()
{
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& BOPAlgo_BuilderShape::Shape() const
{
return myShape;
}
//
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_BuilderShape::Generated(const TopoDS_Shape& )
{
myHistShapes.Clear();
return myHistShapes;
}
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_BuilderShape::Modified(const TopoDS_Shape& )
{
myHistShapes.Clear();
return myHistShapes;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BuilderShape::IsDeleted(const TopoDS_Shape& theS)
{
Standard_Boolean bRet;
//
bRet=!myMapShape.Contains(theS);
return bRet;
}
//=======================================================================
//function : HasDeleted
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BuilderShape::HasDeleted()const
{
return myHasDeleted;
}
//=======================================================================
//function : HasGenerated
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BuilderShape::HasGenerated()const
{
return myHasGenerated;
}
//=======================================================================
//function : HasModified
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BuilderShape::HasModified()const
{
return myHasModified;
}
//=======================================================================
//function : PrepareHistory
//purpose :
//=======================================================================
void BOPAlgo_BuilderShape::PrepareHistory()
{
myHistShapes.Clear();
myMapShape.Clear();
myHasDeleted=Standard_False;
myHasGenerated=Standard_False;
myHasModified=Standard_False;
myFlagHistory=Standard_False;
}
//=======================================================================
//function : ImagesResult
//purpose :
//=======================================================================
const BOPCol_IndexedDataMapOfShapeListOfShape&
BOPAlgo_BuilderShape::ImagesResult()const
{
return myImagesResult;
}

View File

@@ -0,0 +1,69 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
class BuilderSolid from BOPAlgo
inherits BuilderArea from BOPAlgo
---Purpose: The algorithm to build solids from set of faces
uses
BaseAllocator from BOPCol
--raises
is
Create
returns BuilderSolid from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();"
Create (theAllocator: BaseAllocator from BOPCol)
returns BuilderSolid from BOPAlgo;
Perform(me:out)
---Purpose: Performs the algorithm
is redefined;
PerformShapesToAvoid(me:out)
---Purpose: Collect the faces that
-- a) are internal
-- b) are the same and have different orientation
is redefined protected;
PerformLoops(me:out)
---Purpose: Build draft shells
-- a)myLoops - draft shells that consist of
-- boundary faces
-- b)myLoopsInternal - draft shells that contains
-- inner faces
is redefined protected;
PerformAreas(me:out)
---Purpose: Build draft solids that contains boundary faces
is redefined protected;
PerformInternalShapes(me:out)
---Purpose: Build finalized solids with internal shells
is redefined protected;
--fields
end BuilderSolid;

View File

@@ -0,0 +1,847 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_BuilderSolid.ixx>
#include <gp_Pnt2d.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
//
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPTools.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfOrientedShape.hxx>
//
#include <NCollection_List.hxx>
//
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPInt_Context.hxx>
#include <BOPTools_CoupleOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
static
Standard_Boolean IsGrowthShell(const TopoDS_Shape& ,
const BOPCol_IndexedMapOfShape& );
static
Standard_Boolean IsHole(const TopoDS_Shape& ,
Handle(BOPInt_Context)& );
static
Standard_Boolean IsInside(const TopoDS_Shape& ,
const TopoDS_Shape& ,
Handle(BOPInt_Context)& );
static
void MakeInternalShells(const BOPCol_MapOfShape& ,
BOPCol_ListOfShape& );
static
Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell);
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderSolid::BOPAlgo_BuilderSolid()
:
BOPAlgo_BuilderArea()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_BuilderSolid::BOPAlgo_BuilderSolid(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_BuilderArea(theAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_BuilderSolid::~BOPAlgo_BuilderSolid()
{
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::Perform()
{
myErrorStatus=0;
//
if (myContext.IsNull()) {
//myErrorStatus=11;// Null Context
//return;
myContext=new BOPInt_Context;
}
//
TopoDS_Compound aC;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aIt;
//
aBB.MakeCompound(aC);
aIt.Initialize(myShapes);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
aBB.Add(aC, aF);
}
//
//
PerformShapesToAvoid();
if (myErrorStatus) {
return;
}
//
PerformLoops();
if (myErrorStatus) {
return;
}
PerformAreas();
if (myErrorStatus) {
return;
}
PerformInternalShapes();
if (myErrorStatus) {
return;
}
}
//=======================================================================
//function :PerformShapesToAvoid
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::PerformShapesToAvoid()
{
Standard_Boolean bFound;
Standard_Integer i, iCnt, aNbE, aNbF;
TopAbs_Orientation aOrE;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
BOPCol_ListIteratorOfListOfShape aIt;
//
myShapesToAvoid.Clear();
//
iCnt=0;
while (1) {
++iCnt;
bFound=Standard_False;
//
// 1. MEF
aMEF.Clear();
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (!myShapesToAvoid.Contains(aF)) {
BOPTools::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
}
else {
int a=0;
}
}
aNbE=aMEF.Extent();
//
// 2. myFacesToAvoid
for (i=1; i<=aNbE; ++i) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aMEF.FindKey(i)));
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
BOPCol_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
aNbF=aLF.Extent();
if (!aNbF) {
continue;
}
//
aOrE=aE.Orientation();
//
const TopoDS_Face& aF1=(*(TopoDS_Face*)(&aLF.First()));
if (aNbF==1) {
if (aOrE==TopAbs_INTERNAL) {
continue;
}
bFound=Standard_True;
myShapesToAvoid.Add(aF1);
}
else if (aNbF==2) {
const TopoDS_Face& aF2=(*(TopoDS_Face*)(&aLF.Last()));
if (aF2.IsSame(aF1)) {
if (BRep_Tool::IsClosed(aE, aF1)) {
continue;
}
//
if (aOrE==TopAbs_INTERNAL) {
continue;
}
//
bFound=Standard_True;
myShapesToAvoid.Add(aF1);
myShapesToAvoid.Add(aF2);
}
}
}// for (i=1; i<=aNbE; ++i) {
//
if (!bFound) {
break;
}
//
}//while (1)
}
//=======================================================================
//function : PerformLoops
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::PerformLoops()
{
myErrorStatus=0;
//
myLoops.Clear();
//
Standard_Integer aNbLF, aNbOff, aNbFP, aNbFA;
Standard_Integer i;
TopAbs_Orientation anOr;
TopoDS_Edge aEL;
BRep_Builder aBB;
TopoDS_Iterator aItS;
//
BOPCol_ListIteratorOfListOfShape aItF, aIt;
BOPCol_MapIteratorOfMapOfOrientedShape aItM;
BOPTools_CoupleOfShape aCSOff;
//
BOPCol_MapOfOrientedShape AddedFacesMap;
BOPCol_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP;
//
//=================================================
//
// 1. Shells Usual
//
aItF.Initialize (myShapes);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Shape& aFF = aItF.Value();
BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
}
//
aItF.Initialize (myShapes);
for (i=1; aItF.More(); aItF.Next(), ++i) {
const TopoDS_Shape& aFF = aItF.Value();
if (myShapesToAvoid.Contains(aFF)) {
continue;
}
if (!AddedFacesMap.Add(aFF)) {
continue;
}
//
// make a new shell
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
aBB.Add(aShell, aFF);
//
aMEFP.Clear();
BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
//
// loop on faces added to Shell; add their neighbor faces to Shell and so on
TopoDS_Iterator aItAddedF (aShell);
for (; aItAddedF.More(); aItAddedF.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItAddedF.Value()));
//
// loop on edges of aF; find a good neighbor face of aF by aE
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
for (; aEdgeExp.More(); aEdgeExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aEdgeExp.Current()));
//
//1
if (aMEFP.Contains(aE)) {
const BOPCol_ListOfShape& aLFP=aMEFP.FindFromKey(aE);
aNbFP=aLFP.Extent();
if (aNbFP>1) {
continue;
}
}
//2
anOr=aE.Orientation();
if (anOr==TopAbs_INTERNAL) {
continue;
}
//3
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
// candidate faces list
const BOPCol_ListOfShape& aLF=aEFMap.FindFromKey(aE);
aNbLF=aLF.Extent();
if (!aNbLF) {
continue;
}
//
// try to select one of neighbors
// check if a face already added to Shell shares E
Standard_Boolean bFound;
BOPCol_ListIteratorOfListOfShape aItLF;
BOPTools_ListOfCoupleOfShape aLCSOff;
//
aItLF.Initialize(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItLF.Value()));
if (myShapesToAvoid.Contains(aFL)) {
continue;
}
if (aF.IsSame(aFL)) {
continue;
}
if (AddedFacesMap.Contains(aFL)){
continue;
}
//
bFound=BOPTools_AlgoTools::GetEdgeOff(aE, aFL, aEL);
if (!bFound) {
continue;
}
//
aCSOff.SetShape1(aEL);
aCSOff.SetShape2(aFL);
aLCSOff.Append(aCSOff);
}//for (; aItLF.More(); aItLF.Next()) {
//
aNbOff=aLCSOff.Extent();
if (!aNbOff){
continue;
}
//
TopoDS_Face aSelF;
if (aNbOff==1) {
aSelF=(*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
}
else if (aNbOff>1){
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, myContext);
}
//
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
aBB.Add(aShell, aSelF);
BOPTools::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
}
} // for (; aEdgeExp.More(); aEdgeExp.Next()) {
} //for (; aItAddedF.More(); aItAddedF.Next()) {
//
if (IsClosedShell(aShell)) {
myLoops.Append(aShell);
}
} // for (; aItF.More(); aItF.Next()) {
//
// Post Treatment
BOPCol_MapOfOrientedShape aMP;
//
// a. collect all edges that are in loops
aIt.Initialize (myLoops);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aItS.Initialize(aS);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aF=aItS.Value();
aMP.Add(aF);
}
}
//
// b. collect all edges that are to avoid
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aF=aItM.Key();
aMP.Add(aF);
}
//
// c. add all edges that are not processed to myShapesToAvoid
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (!aMP.Contains(aF)) {
myShapesToAvoid.Add(aF);
}
}
//=================================================
//
// 2.Internal Shells
//
myLoopsInternal.Clear();
//
aEFMap.Clear();
AddedFacesMap.Clear();
//
aNbFA=myShapesToAvoid.Extent();
//
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aFF=aItM.Key();
BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
}
//
aItM.Initialize(myShapesToAvoid);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aFF=aItM.Key();
if (!AddedFacesMap.Add(aFF)) {
continue;
}
//
// make a new shell
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
aBB.Add(aShell, aFF);
//
TopoDS_Iterator aItAddedF (aShell);
for (; aItAddedF.More(); aItAddedF.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItAddedF.Value()));
//
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
for (; aEdgeExp.More(); aEdgeExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aEdgeExp.Current()));
const BOPCol_ListOfShape& aLF=aEFMap.FindFromKey(aE);
aItF.Initialize(aLF);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItF.Value()));
if (AddedFacesMap.Add(aFL)){
aBB.Add(aShell, aFL);
}
}
}
}
myLoopsInternal.Append(aShell);
}
}
//=======================================================================
//function : PerformAreas
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::PerformAreas()
{
myErrorStatus=0;
//
Standard_Boolean bIsGrowthShell, bIsHole;
BRep_Builder aBB;
TopoDS_Shape anInfinitePointShape;
BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
BOPCol_ListIteratorOfListOfShape aShellIt, aSolidIt;
//
BOPCol_ListOfShape aNewSolids, aHoleShells;
BOPCol_DataMapOfShapeShape aInOutMap;
BOPCol_DataMapOfShapeListOfShape aMSH;
BOPCol_IndexedMapOfShape aMHF;
//
myAreas.Clear();
//
// Draft solids [aNewSolids]
aShellIt.Initialize(myLoops);
for ( ; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aShell = aShellIt.Value();
//
bIsGrowthShell=IsGrowthShell(aShell, aMHF);
if (bIsGrowthShell) {
// make a growth solid from a shell
TopoDS_Solid Solid;
aBB.MakeSolid(Solid);
aBB.Add (Solid, aShell);
//
aNewSolids.Append (Solid);
}
else{
// check if a shell is a hole
//XX
bIsHole=IsHole(aShell, myContext);
//XX
if (bIsHole) {
aHoleShells.Append(aShell);
BOPTools::MapShapes(aShell, TopAbs_FACE, aMHF);
}
else {
// make a growth solid from a shell
TopoDS_Solid Solid;
aBB.MakeSolid(Solid);
aBB.Add (Solid, aShell);
//
aNewSolids.Append (Solid);
}
}
}
//
// 2. Find outer growth shell that is most close to each hole shell
aShellIt.Initialize(aHoleShells);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aHole = aShellIt.Value();
//
aSolidIt.Initialize(aNewSolids);
for ( ; aSolidIt.More(); aSolidIt.Next()) {
const TopoDS_Shape& aSolid = aSolidIt.Value();
//
if (!IsInside(aHole, aSolid, myContext)){
continue;
}
//
if ( aInOutMap.IsBound (aHole)){
const TopoDS_Shape& aSolid2 = aInOutMap(aHole);
if (IsInside(aSolid, aSolid2, myContext)) {
aInOutMap.UnBind(aHole);
aInOutMap.Bind (aHole, aSolid);
}
}
else{
aInOutMap.Bind (aHole, aSolid);
}
}
//
// Add aHole to a map Solid/ListOfHoles [aMSH]
if (aInOutMap.IsBound(aHole)){
const TopoDS_Shape& aSolid=aInOutMap(aHole);
if (aMSH.IsBound(aSolid)) {
BOPCol_ListOfShape& aLH=aMSH.ChangeFind(aSolid);
aLH.Append(aHole);
}
else {
BOPCol_ListOfShape aLH;
aLH.Append(aHole);
aMSH.Bind(aSolid, aLH);
}
//aBB.Add (aSolid, aHole);
}
}// for (; aShellIt.More(); aShellIt.Next()) {
//
// 3. Add aHoles to Solids
aItMSH.Initialize(aMSH);
for (; aItMSH.More(); aItMSH.Next()) {
TopoDS_Solid aSolid=(*(TopoDS_Solid*)(&aItMSH.Key()));
//
const BOPCol_ListOfShape& aLH=aItMSH.Value();
aShellIt.Initialize(aLH);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aHole = aShellIt.Value();
aBB.Add (aSolid, aHole);
}
//
// update classifier
BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
aSC.Load(aSolid);
//
}
//
// These aNewSolids are draft solids that
// do not contain any internal shapes
//
aShellIt.Initialize(aNewSolids);
for ( ; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aSx = aShellIt.Value();
myAreas.Append(aSx);
}
// Add holes that outside the solids to myAreas
aShellIt.Initialize(aHoleShells);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aHole = aShellIt.Value();
if (!aInOutMap.IsBound(aHole)){
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
aBB.Add (aSolid, aHole);
//
myAreas.Append(aSolid);
}
}
}
//=======================================================================
//function : PerformInternalShapes
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::PerformInternalShapes()
{
myErrorStatus=0;
//
Standard_Integer aNbFI=myLoopsInternal.Extent();
if (!aNbFI) {// nothing to do
return;
}
//
BRep_Builder aBB;
TopoDS_Iterator aIt;
BOPCol_ListIteratorOfListOfShape aShellIt, aSolidIt;
BOPCol_MapIteratorOfMapOfShape aItMF;
//
BOPCol_MapOfShape aMF, aMFP, aMFx;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
BOPCol_ListOfShape aLSI;
//
// 1. All internal faces
aShellIt.Initialize(myLoopsInternal);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aShell=aShellIt.Value();
aIt.Initialize(aShell);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
aMF.Add(aF);
}
}
aNbFI=aMF.Extent();
//
// 2 Process solids
aSolidIt.Initialize(myAreas);
for ( ; aSolidIt.More(); aSolidIt.Next()) {
TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aSolidIt.Value()));
//
TopExp_Explorer anExpSol(aSolid, TopAbs_FACE);;
for (; anExpSol.More(); anExpSol.Next()) {
const TopoDS_Shape& aF = anExpSol.Current();
TopoDS_Shape aFF=aF;
//
aFF.Orientation(TopAbs_FORWARD);
aMFx.Add(aFF);
aFF.Orientation(TopAbs_REVERSED);
aMFx.Add(aFF);
}
aMEF.Clear();
BOPTools::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF);
//
// 2.1 Separate faces to process aMFP
aMFP.Clear();
aItMF.Initialize(aMF);
for (; aItMF.More(); aItMF.Next()) {
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aItMF.Key()));
if (!aMFx.Contains(aF)) {
if (BOPTools_AlgoTools::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) {
aMFP.Add(aF);
}
}
}
aMFx.Clear();
//
// 2.2 Make Internal Shells
aLSI.Clear();
MakeInternalShells(aMFP, aLSI);
//
// 2.3 Add them to aSolid
aShellIt.Initialize(aLSI);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aSI=aShellIt.Value();
aBB.Add (aSolid, aSI);
}
//
// 2.4 Remove faces aMFP from aMF
aItMF.Initialize(aMFP);
for (; aItMF.More(); aItMF.Next()) {
const TopoDS_Shape& aF=aItMF.Key();
aMF.Remove(aF);
}
//
aNbFI=aMF.Extent();
if (!aNbFI) {
break;
}
} //for ( ; aSolidIt.More(); aSolidIt.Next()) {
if (aNbFI) {
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
//
MakeInternalShells(aMF, aLSI);
aShellIt.Initialize(aLSI);
for (; aShellIt.More(); aShellIt.Next()) {
const TopoDS_Shape& aSI=aShellIt.Value();
aBB.Add (aSolid, aSI);
}
myAreas.Append(aSolid);
}
}
//=======================================================================
//function : MakeInternalShells
//purpose :
//=======================================================================
void MakeInternalShells(const BOPCol_MapOfShape& theMF,
BOPCol_ListOfShape& theShells)
{
BOPCol_ListIteratorOfListOfShape aItF;
BRep_Builder aBB;
//
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
BOPCol_MapIteratorOfMapOfShape aItM;
BOPCol_MapOfShape aAddedFacesMap;
//
aItM.Initialize(theMF);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aF=aItM.Key();
BOPTools::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
}
//
aItM.Initialize(theMF);
for (; aItM.More(); aItM.Next()) {
TopoDS_Shape aFF=aItM.Key();
if (!aAddedFacesMap.Add(aFF)) {
continue;
}
//
// make a new shell
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
aFF.Orientation(TopAbs_INTERNAL);
aBB.Add(aShell, aFF);
//
TopoDS_Iterator aItAddedF (aShell);
for (; aItAddedF.More(); aItAddedF.Next()) {
const TopoDS_Shape& aF =aItAddedF.Value();
//
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
for (; aEdgeExp.More(); aEdgeExp.Next()) {
const TopoDS_Shape& aE =aEdgeExp.Current();
const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE);
aItF.Initialize(aLF);
for (; aItF.More(); aItF.Next()) {
TopoDS_Shape aFL=aItF.Value();
if (aAddedFacesMap.Add(aFL)){
aFL.Orientation(TopAbs_INTERNAL);
aBB.Add(aShell, aFL);
}
}
}
}
theShells.Append(aShell);
}
}
//=======================================================================
//function : IsHole
//purpose :
//=======================================================================
Standard_Boolean IsHole(const TopoDS_Shape& theS2,
Handle(BOPInt_Context)& theContext)
{
TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
//
aClsf.PerformInfinitePoint(::RealSmall());
//
return (aClsf.State()==TopAbs_IN);
}
//=======================================================================
//function : IsInside
//purpose :
//=======================================================================
Standard_Boolean IsInside(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
Handle(BOPInt_Context)& theContext)
{
TopExp_Explorer aExp;
TopAbs_State aState;
//
TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
//
aExp.Init(theS1, TopAbs_FACE);
if (!aExp.More()){
BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
aClsf.PerformInfinitePoint(::RealSmall());
aState=aClsf.State();
}
else {
BOPCol_IndexedMapOfShape aBounds;
BOPTools::MapShapes(*pS2, TopAbs_EDGE, aBounds);
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aExp.Current()));
aState=BOPTools_AlgoTools::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext);
}
return (aState==TopAbs_IN);
}
//=======================================================================
//function : IsGrowthShell
//purpose :
//=======================================================================
Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell,
const BOPCol_IndexedMapOfShape& theMHF)
{
Standard_Boolean bRet;
TopoDS_Iterator aIt;
//
bRet=Standard_False;
if (theMHF.Extent()) {
aIt.Initialize(theShell);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (theMHF.Contains(aF)) {
return !bRet;
}
}
}
return bRet;
}
//=======================================================================
//function : IsClosedShell
//purpose :
//=======================================================================
Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell)
{
Standard_Integer aNbE;
Standard_Boolean bRet;
TopoDS_Iterator aIt;
TopExp_Explorer aExp;
//
BOPCol_MapOfShape aM;
//
bRet=Standard_False;
aIt.Initialize(theShell);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aIt.Value()));
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
if (aE.Orientation()==TopAbs_INTERNAL) {
continue;
}
if (!aM.Add(aE)) {
aM.Remove(aE);
}
}
}
//
aNbE=aM.Extent();
if (!aNbE) {
bRet=!bRet;
}
return bRet;
}

View File

@@ -0,0 +1,309 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Builder.ixx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <BOPCol_DataMapOfIntegerInteger.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPTools_AlgoTools.hxx>
//=======================================================================
//function : FillImagesVertices
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesVertices()
{
myErrorStatus=0;
//
Standard_Integer nV, nVSD;
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aIt;
//
const BOPCol_DataMapOfIntegerInteger& aMSDV=myDS->ShapesSD();
aIt.Initialize(aMSDV);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Key();
nVSD=aIt.Value();
const TopoDS_Shape& aV=myDS->Shape(nV);
const TopoDS_Shape& aVSD=myDS->Shape(nVSD);
//
BOPCol_ListOfShape aLVSD(myAllocator);
//
aLVSD.Append(aVSD);
myImages.Bind(aV, aLVSD);
//
myShapesSD.Bind(aV, aVSD);
}
}
//=======================================================================
//function : FillImagesEdges
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesEdges()
{
myErrorStatus=0;
//
Standard_Integer i, aNbPBP, nE, nSp, nSpR;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
//
const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool();
aNbPBP=aPBP.Extent();
for (i=0; i<aNbPBP; ++i) {
const BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
if (aLPB.Extent()) {
BOPCol_ListOfShape aLS(myAllocator);
//
const Handle(BOPDS_PaveBlock)& aPB1=aLPB.First();
nE=aPB1->OriginalEdge();
const TopoDS_Shape& aE=myDS->Shape(nE);
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
const Handle(BOPDS_PaveBlock)& aPBR=aPB->RealPaveBlock();
//
nSpR=aPBR->Edge();
const TopoDS_Shape& aSpR=myDS->Shape(nSpR);
aLS.Append(aSpR);
myOrigins.Bind(aSpR, aE);
//
if (aPB->IsCommonBlockOnEdge()) {
nSp=aPB->Edge();
const TopoDS_Shape& aSp=myDS->Shape(nSp);
myShapesSD.Bind(aSp, aSpR);
}
}
myImages.Bind(aE, aLS);
}
}
}
//=======================================================================
// function: IsInterferred
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_Builder::IsInterferred(const TopoDS_Shape& theS)const
{
Standard_Boolean bInterferred;
TopoDS_Iterator aIt;
//
bInterferred=Standard_False;
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (myImages.IsBound(aSx)) {
bInterferred=!bInterferred;
break;
}
}
return bInterferred;
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
{
myErrorStatus=0;
//
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
BOPCol_MapOfShape aM;
BOPCol_ListIteratorOfListOfShape aIt, aItIm;
//
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==theType) {
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
if (aM.Add(aSIm)) {
aBB.Add(myShape, aSIm);
}
}
}
else {
if (aM.Add(aS)) {
aBB.Add(myShape, aS);
}
}
}
}
}
//=======================================================================
// function: FillImagesContainers
// purpose:
//=======================================================================
void BOPAlgo_Builder::FillImagesContainers(const TopAbs_ShapeEnum theType)
{
myErrorStatus=0;
//
Standard_Integer i, aNbS;
BOPCol_MapOfShape aMFP(100, myAllocator);
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()==theType) {
const TopoDS_Shape& aC=aSI.Shape();
FillImagesContainer(aC, theType);
}
}// for (; aItS.More(); aItS.Next()) {
}
//=======================================================================
// function: FillImagesCompounds
// purpose:
//=======================================================================
void BOPAlgo_Builder::FillImagesCompounds()
{
myErrorStatus=0;
//
Standard_Integer i, aNbS;
BOPCol_MapOfShape aMFP(100, myAllocator);
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()==TopAbs_COMPOUND) {
const TopoDS_Shape& aC=aSI.Shape();
FillImagesCompound(aC, aMFP);
}
}// for (; aItS.More(); aItS.Next()) {
}
//=======================================================================
//function : FillImagesContainer
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesContainer(const TopoDS_Shape& theS,
const TopAbs_ShapeEnum theType)
{
Standard_Boolean bInterferred, bToReverse;
TopoDS_Iterator aIt;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItIm;
//
bInterferred=IsInterferred(theS);
if (!bInterferred){
return;
}
//
TopoDS_Shape aCIm;
BOPTools_AlgoTools::MakeContainer(theType, aCIm);
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (myImages.IsBound(aSx)) {
const BOPCol_ListOfShape& aLFIm=myImages.Find(aSx);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aSxIm=aItIm.Value();
//
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSxIm, aSx, myContext);
if (bToReverse) {
aSxIm.Reverse();
}
aBB.Add(aCIm, aSxIm);
}
}
else {
aBB.Add(aCIm, aSx);
}
}
//
BOPCol_ListOfShape aLSIm(myAllocator);
aLSIm.Append(aCIm);
myImages.Bind(theS, aLSIm);
}
//=======================================================================
//function : FillImagesCompound
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& theMFP)
{
Standard_Boolean bInterferred;
TopAbs_Orientation aOrX;
TopoDS_Iterator aIt;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItIm;
//
if (!theMFP.Add(theS)) {
return;
}
//
bInterferred=Standard_False;
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (aSx.ShapeType()==TopAbs_COMPOUND) {
FillImagesCompound(aSx, theMFP);
}
if (myImages.IsBound(aSx)) {
bInterferred=Standard_True;
}
}
if (!bInterferred){
return;
}
//
TopoDS_Shape aCIm;
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aCIm);
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSX=aIt.Value();
aOrX=aSX.Orientation();
if (myImages.IsBound(aSX)) {
const BOPCol_ListOfShape& aLFIm=myImages.Find(aSX);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aSXIm=aItIm.Value();
aSXIm.Orientation(aOrX);
aBB.Add(aCIm, aSXIm);
}
}
else {
aBB.Add(aCIm, aSX);
}
}
//
BOPCol_ListOfShape aLSIm(myAllocator);
aLSIm.Append(aCIm);
myImages.Bind(theS, aLSIm);
}

View File

@@ -0,0 +1,663 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Builder.ixx>
#include <NCollection_IncAllocator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_DataMapOfIntegerListOfShape.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_VectorOfCurve.hxx>
#include <BOPDS_VectorOfPoint.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPAlgo_BuilderFace.hxx>
#include <BOPTools_CoupleOfShape.hxx>
#include <BOPTools_ListOfCoupleOfShape.hxx>
#include <BOPTools_MapOfSet.hxx>
#include <BOPTools_DataMapOfShapeSet.hxx>
static
Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
const BOPDS_FaceInfo& aFI2);
static
void FillMap(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
Handle(NCollection_IncAllocator)& aAllocator);
static
void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
Handle(NCollection_IncAllocator)& aAllocator);
//=======================================================================
//function : FillImagesFaces
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesFaces()
{
myErrorStatus=0;
//
BuildSplitFaces();
FillSameDomainFaces();
FillImagesFaces1();
}
//=======================================================================
//function : BuildSplitFaces
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildSplitFaces()
{
Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
Standard_Integer i, j, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
TopoDS_Face aFF, aFSD;
TopoDS_Edge aSp, aEE;
TopAbs_Orientation anOriF, anOriE;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_ListOfInteger aLIAV;
BOPCol_MapOfShape aMFence;
Handle(NCollection_IncAllocator) aAllocator;
BOPCol_ListOfShape aLFIm(myAllocator);
BOPCol_MapIteratorOfMapOfShape aItMS;
//
myErrorStatus=0;
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f
aAllocator=new NCollection_IncAllocator();
//
BOPCol_ListOfShape aLE(aAllocator);
BOPCol_MapOfShape aMDE(100, aAllocator);
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_FACE) {
continue;
}
//
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
//
bHasFaceInfo=myDS->HasFaceInfo(i);
if(!bHasFaceInfo) {
continue;
}
//
// aLFIm will contain images of aF
aLFIm.Clear();
//
const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
//
const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
aLIAV.Clear();
myDS->AloneVertices(i, aLIAV);
aNbPBIn=aMPBIn.Extent();
aNbPBOn=aMPBOn.Extent();
aNbPBSc=aMPBSc.Extent();
aNbAV=aLIAV.Extent();
if (!aNbPBIn && !aNbPBOn && !aNbPBSc && !aNbAV) { // not compete
continue;
}
//
aMFence.Clear();
//
anOriF=aF.Orientation();
aFF=aF;
aFF.Orientation(TopAbs_FORWARD);
//
//
// 1. Fill the egdes set for the face aFF -> LE
aLE.Clear();
//
//
// 1.1 Bounding edges
aExp.Init(aFF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
anOriE=aE.Orientation();
bIsDegenerated=BRep_Tool::Degenerated(aE);
bIsClosed=BRep_Tool::IsClosed(aE, aF);
//
if (!myImages.IsBound(aE)) {
if (anOriE==TopAbs_INTERNAL) {
aEE=aE;
aEE.Orientation(TopAbs_FORWARD);
aLE.Append(aEE);
aEE.Orientation(TopAbs_REVERSED);
aLE.Append(aEE);
}
else {
aLE.Append(aE);
}
}
else {//else 1
const BOPCol_ListOfShape& aLIE=myImages.Find(aE);
aIt.Initialize(aLIE);
for (; aIt.More(); aIt.Next()) {
aSp=(*(TopoDS_Edge*)(&aIt.Value()));
if (bIsDegenerated) {
aSp.Orientation(anOriE);
aLE.Append(aSp);
continue;
}
//
if (anOriE==TopAbs_INTERNAL) {
aSp.Orientation(TopAbs_FORWARD);
aLE.Append(aSp);
aSp.Orientation(TopAbs_REVERSED);
aLE.Append(aSp);
continue;
}
//
if (bIsClosed) {
if (aMFence.Add(aSp)) {
if (!BRep_Tool::IsClosed(aSp, aF)){
BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aF);
}
//
aSp.Orientation(TopAbs_FORWARD);
aLE.Append(aSp);
aSp.Orientation(TopAbs_REVERSED);
aLE.Append(aSp);
}// if (aMFence.Add(aSp))
continue;
}// if (bIsClosed){
//
aSp.Orientation(anOriE);
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
if (bToReverse) {
aSp.Reverse();
}
aLE.Append(aSp);
}// for (; aIt.More(); aIt.Next()) {
}// else 1
}// for (; aExp.More(); aExp.Next()) {
//
//
// 1.2 In edges
for (j=1; j<=aNbPBIn; ++j) {
const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
nSp=aPB->Edge();
aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
//
aSp.Orientation(TopAbs_FORWARD);
aLE.Append(aSp);
aSp.Orientation(TopAbs_REVERSED);
aLE.Append(aSp);
}
//
//
// 1.3 Section edges
for (j=1; j<=aNbPBSc; ++j) {
const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
nSp=aPB->Edge();
aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
//
aSp.Orientation(TopAbs_FORWARD);
aLE.Append(aSp);
aSp.Orientation(TopAbs_REVERSED);
aLE.Append(aSp);
}
//
// 3 Build split faces
BOPAlgo_BuilderFace aBF(aAllocator);
//
aBF.SetFace(aFF);
//aBF.SetContext(myContext);
//
// <-DEB ft
//
aBF.SetShapes(aLE);
//
aBF.Perform();
//
const BOPCol_ListOfShape& aLFR=aBF.Areas();
aIt.Initialize(aLFR);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape& aFR=aIt.ChangeValue();
if (anOriF==TopAbs_REVERSED) {
aFR.Orientation(TopAbs_REVERSED);
}
//aFR.Orientation(anOriF);
aLFIm.Append(aFR);
myOrigins.Bind(aFR, aF);
}
//
mySplits.Bind(aF, aLFIm);
}// for (i=0; i<aNbS; ++i) {
//
aAllocator.Nullify();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope t
}
//=======================================================================
//function : FillSameDomainFaces
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillSameDomainFaces()
{
Standard_Boolean bFlag;
Standard_Integer i, aNbFFs, aNbCurves, aNbPoints, nF1, nF2, aNbS;
Standard_Integer j;
Handle(NCollection_IncAllocator) aAllocator;
BOPCol_ListIteratorOfListOfShape aItF1, aItF2;
BOPTools_ListOfCoupleOfShape aLCS;
BOPCol_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
//
const BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
//
aNbFFs=aFFs.Extent();
if (!aNbFFs) {
return;
}
//-----------------------------------------------------scope f
aAllocator=new NCollection_IncAllocator();
BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(100, aAllocator);
BOPCol_DataMapOfIntegerListOfShape aMBlocks(100, aAllocator);
BOPTools_DataMapOfShapeSet aMSST(100, aAllocator);
//
BOPCol_ListOfShape aLFIm;
//
for (i=0; i<aNbFFs; ++i) {
const BOPDS_InterfFF& aFF=aFFs(i);
aFF.Indices(nF1, nF2);
//
const BOPDS_VectorOfCurve& aCurves=aFF.Curves();
aNbCurves=aCurves.Extent();
if (aNbCurves) {
//
bFlag=Standard_False;
for (j=0; j<aNbCurves; ++j) {
const BOPDS_Curve& aNC=aCurves.Value(j);
bFlag=aNC.HasEdge();
if (bFlag) {
break;
}
}
if (bFlag) {
continue;
}
//continue;
}
//
const BOPDS_VectorOfPoint& aPoints=aFF.Points();
aNbPoints=aPoints.Extent();
if (aNbPoints) {
continue;
}
//
if (!myDS->HasFaceInfo(nF1) || !myDS->HasFaceInfo(nF2) ) {
continue;
}
//
const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
bFlag=HasPaveBlocksOnIn(aFI1, aFI2);
if (!bFlag) {
continue;
}
//
const TopoDS_Face& aF1=(*(TopoDS_Face*)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face*)(&myDS->Shape(nF2)));
bFlag=mySplits.IsBound(aF1) && mySplits.IsBound(aF2);
if (!bFlag) {
continue;
}
//
const BOPCol_ListOfShape& aLF1=mySplits.Find(aF1);
const BOPCol_ListOfShape& aLF2=mySplits.Find(aF2);
//
aItF1.Initialize(aLF1);
for (; aItF1.More(); aItF1.Next()) {
const TopoDS_Face& aF1x=(*(TopoDS_Face*)(&aItF1.Value()));
if (!aMSST.IsBound(aF1x)) {
BOPTools_Set aST1(aAllocator);
//
aMSST.Bind(aF1x, aST1);
BOPTools_Set& aST=aMSST.ChangeFind(aF1x);
aST.AddEdges(aF1x);
}
//
aItF2.Initialize(aLF2);
for (; aItF2.More(); aItF2.Next()) {
const TopoDS_Face& aF2y=(*(TopoDS_Face*)(&aItF2.Value()));
if (!aMSST.IsBound(aF2y)) {
BOPTools_Set aST2(aAllocator);
//
aMSST.Bind(aF2y, aST2);
BOPTools_Set& aST=aMSST.ChangeFind(aF2y);
aST.AddEdges(aF2y);
}
//
const BOPTools_Set& aST1=aMSST.Find(aF1x);
const BOPTools_Set& aST2=aMSST.Find(aF2y);
//
if (aST1.IsEqual(aST2)) {
bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1x, aF2y, myContext);
if (bFlag) {
FillMap(aF1x, aF2y, aDMSLS, aAllocator);
}
}
}
}
} // for (i=0; i<aNbFFs; ++i) {
//
// 2. Make blocks
MakeBlocksCnx(aDMSLS, aMBlocks, aAllocator);
//
// 3. Fill same domain faces map -> aMSDF
aNbS = aMBlocks.Extent();
for (i=0; i<aNbS; ++i) {
const BOPCol_ListOfShape& aLSD=aMBlocks.Find(i);
if (aLSD.Extent()) {
const TopoDS_Shape& aFSD1=aLSD.First();
aItLS.Initialize(aLSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFSD=aItLS.Value();
myShapesSD.Bind(aFSD, aFSD1);
}
}
}
//
//-----------------------------------------------------scope t
aMSST.Clear();
aMBlocks.Clear();
aDMSLS.Clear();
aAllocator.Nullify();
}
//=======================================================================
// function: FillImagesFaces1
// purpose:
//=======================================================================
void BOPAlgo_Builder::FillImagesFaces1()
{
Standard_Integer i, aNbS, iSense;
TopoDS_Face aFSD;
BOPCol_ListOfInteger aLIAV;
BOPCol_ListOfShape aLFIm;
BOPCol_ListIteratorOfListOfShape aItLS;
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_FACE) {
continue;
}
//
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
//
if (!mySplits.IsBound(aF)) {
continue;
}
//
aLIAV.Clear();
myDS->AloneVertices(i, aLIAV);
aLFIm.Clear();
//
const BOPCol_ListOfShape& aLSp=mySplits.Find(aF);
aItLS.Initialize(aLSp);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
if (!myShapesSD.IsBound(aFSp)) {
aLFIm.Append(aFSp);
}
else {
aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp)));
iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD);
if (iSense<0) {
aFSD.Reverse();
}
aLFIm.Append(aFSD);
}
}
//
FillInternalVertices(aLFIm, aLIAV);
//
myImages.Bind(aF, aLFIm);
}// for (i=0; i<aNbS; ++i) {
}
//=======================================================================
// function: FillInternalVertices
// purpose:
//=======================================================================
void BOPAlgo_Builder::FillInternalVertices(BOPCol_ListOfShape& aLFIm,
BOPCol_ListOfInteger& aLIAV)
{
Standard_Integer nV, iFlag;
Standard_Real aU1, aU2;
TopoDS_Vertex aV;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfInteger aItV;
BOPCol_ListIteratorOfListOfShape aItF;
//
aItV.Initialize(aLIAV);
for (; aItV.More(); aItV.Next()) {
nV=aItV.Value();
aV=(*(TopoDS_Vertex*)(&myDS->Shape(nV)));
aV.Orientation(TopAbs_INTERNAL);
//
aItF.Initialize(aLFIm);
for (; aItF.More(); aItF.Next()) {
TopoDS_Face& aF=(*(TopoDS_Face*)(&aItF.Value()));
iFlag=myContext->ComputeVF(aV, aF, aU1, aU2);
if (!iFlag) {
aBB.Add(aF, aV);
break;
}
}
}
}
//=======================================================================
//function : MakeBlocksCnx
//purpose :
//=======================================================================
void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
Handle(NCollection_IncAllocator)& aAllocator)
{
Standard_Integer aNbV, aNbVS, aNbVP, aNbEC, k, i, j;
BOPCol_ListIteratorOfListOfShape aItLI;
//
BOPCol_MapOfShape aMVS(100, aAllocator);
BOPCol_IndexedMapOfShape aMEC(100, aAllocator);
BOPCol_IndexedMapOfShape aMVP(100, aAllocator);
BOPCol_IndexedMapOfShape aMVAdd(100, aAllocator);
//
aNbV=aMILI.Extent();
//
for (k=0,i=1; i<=aNbV; ++i) {
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
const TopoDS_Shape& nV=aMILI.FindKey(i);
if (aMVS.Contains(nV)){
continue;
}
aMVS.Add(nV);
//
aMEC.Clear();
aMVP.Clear();
aMVAdd.Clear();
//
aMVP.Add(nV);
while(1) {
aNbVP=aMVP.Extent();
for (j=1; j<=aNbVP; ++j) {
const TopoDS_Shape& nVP=aMVP(j);
const BOPCol_ListOfShape& aLV=aMILI.FindFromKey(nVP);
aItLI.Initialize(aLV);
for (; aItLI.More(); aItLI.Next()) {
const TopoDS_Shape& nVx=aItLI.Value();
if (aMEC.Contains(nVx)) {
continue;
}
//
aMVS.Add(nVx);
aMEC.Add(nVx);
aMVAdd.Add(nVx);
}
}
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
}
//
aMVP.Clear();
for (j=1; j<=aNbVP; ++j) {
aMVP.Add(aMVAdd(j));
}
aMVAdd.Clear();
}//while(1) {
//
BOPCol_ListOfShape aLIx(aAllocator);
//
aNbEC = aMEC.Extent();
for (j=1; j<=aNbEC; ++j) {
const TopoDS_Shape& nVx=aMEC(j);
aLIx.Append(nVx);
}
//
aMBlocks.Bind(k, aLIx);
++k;
}//for (k=0,i=1; i<=aNbV; ++i)
aMVAdd.Clear();
aMVP.Clear();
aMEC.Clear();
aMVS.Clear();
}
//=======================================================================
//function : FillMap
//purpose :
//=======================================================================
void FillMap(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
Handle(NCollection_IncAllocator)& aAllocator)
{
if (aDMSLS.Contains(aS1)) {
BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS1);
aLS.Append(aS2);
}
else {
BOPCol_ListOfShape aLS(aAllocator);
aLS.Append(aS2);
aDMSLS.Add(aS1, aLS);
}
//
if (aDMSLS.Contains(aS2)) {
BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS2);
aLS.Append(aS1);
}
else {
BOPCol_ListOfShape aLS(aAllocator);
aLS.Append(aS1);
aDMSLS.Add(aS2, aLS);
}
}
//=======================================================================
//function :HasPaveBlocksOnIn
//purpose :
//=======================================================================
Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
const BOPDS_FaceInfo& aFI2)
{
Standard_Boolean bRet;
BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
//
bRet=Standard_False;
const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
//
const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
aItMPB.Initialize(aMPBOn2);
for (; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
if (bRet) {
return bRet;
}
}
//
const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
aItMPB.Initialize(aMPBIn2);
for (; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
if (bRet) {
return bRet;
}
}
return bRet;
}
/*
//DEBf
{
TopoDS_Compound aCx;
BRep_Builder aBBx;
BOPCol_ListIteratorOfListOfShape aItx;
//
aBBx.MakeCompound(aCx);
aBBx.Add(aCx, aFF);
aItx.Initialize(aLE);
for (; aItx.More(); aItx.Next()) {
const TopoDS_Shape& aEx=aItx.Value();
aBBx.Add(aCx, aEx);
}
int a=0;
}
//DEBt
*/

View File

@@ -0,0 +1,791 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Builder.hxx>
#include <NCollection_IncAllocator.hxx>
#include <TopAbs_State.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Compound.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
//
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
//
#include <BOPDS_DS.hxx>
#include <BOPDS_ShapeInfo.hxx>
//
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
//
#include <BOPTools_MapOfSet.hxx>
#include <BOPTools_Set.hxx>
//
#include <BOPAlgo_BuilderSolid.hxx>
static
void OwnInternalShapes(const TopoDS_Shape& ,
BOPCol_IndexedMapOfShape& );
//=======================================================================
//function : FillImagesSolids
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillImagesSolids()
{
myErrorStatus=0;
//
Handle(NCollection_IncAllocator) aAllocator;
//-----------------------------------------------------scope_1 f
aAllocator=new NCollection_IncAllocator();
//
BOPCol_DataMapOfShapeListOfShape theInParts(100, aAllocator);
BOPCol_DataMapOfShapeShape theDraftSolids(100, aAllocator);
//
FillIn3DParts(theInParts, theDraftSolids, aAllocator);
BuildSplitSolids(theInParts, theDraftSolids, aAllocator);
FillInternalShapes();
//
theInParts.Clear();
theDraftSolids.Clear();
//-----------------------------------------------------scope_1 t
}
//=======================================================================
//function : FillIn3DParts
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
myErrorStatus=0;
//
Standard_Boolean bIsIN, bHasImage;
Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP;
TopAbs_ShapeEnum aType;
TopAbs_State aState;
TopoDS_Iterator aIt, aItF;
BRep_Builder aBB;
TopoDS_Solid aSolidSp;
TopoDS_Face aFP;
BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx;
//
BOPCol_ListOfShape aLIF(theAllocator);
BOPCol_MapOfShape aMFDone(100, theAllocator);
BOPCol_IndexedMapOfShape aMSolids(100, theAllocator);
BOPCol_IndexedMapOfShape aMFaces(100, theAllocator);
BOPCol_IndexedMapOfShape aMFIN(100, theAllocator);
BOPCol_IndexedMapOfShape aMS(100, theAllocator);
BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator);
//
theDraftSolids.Clear();
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
const TopoDS_Shape& aS=aSI.Shape();
//
aType=aSI.ShapeType();
switch(aType) {
case TopAbs_SOLID: {
aMSolids.Add(aS);
break;
}
//
case TopAbs_FACE: {
// all faces (originals or images)
if (myImages.IsBound(aS)) {
const BOPCol_ListOfShape& aLS=myImages.Find(aS);
aItS.Initialize(aLS);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aFx=aItS.Value();
aMFaces.Add(aFx);
}
}
else {
aMFaces.Add(aS);
}
break;
}
//
default:
break;
}
}
//
aNbFaces=aMFaces.Extent();
aNbSolids=aMSolids.Extent();
//
for (i=1; i<=aNbSolids; ++i) {
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aMSolids(i)));
//
aMFDone.Clear();
aMFIN.Clear();
aMEF.Clear();
//
aBB.MakeSolid(aSolidSp);
//
// Draft solid and its pure internal faces => aSolidSp, aLIF
aLIF.Clear();
BuildDraftSolid(aSolid, aSolidSp, aLIF);
aNbLIF=aLIF.Extent();
//
// 1 all faces/edges from aSolid [ aMS ]
bHasImage=Standard_False;
aMS.Clear();
aIt.Initialize(aSolid);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aShell=aIt.Value();
//
if (myImages.IsBound(aShell)) {
bHasImage=Standard_True;
//
const BOPCol_ListOfShape& aLS=myImages.Find(aShell);
aItS.Initialize(aLS);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSx=aItS.Value();
aMS.Add(aSx);
BOPTools::MapShapes(aSx, TopAbs_FACE, aMS);
BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS);
BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
}
}
else {
//aMS.Add(aShell);
BOPTools::MapShapes(aShell, TopAbs_FACE, aMS);
BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
}
}
//
// 2 all faces that are not from aSolid [ aLFP1 ]
BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator);
BOPCol_ListOfShape aLFP1(theAllocator);
BOPCol_ListOfShape aLFP(theAllocator);
BOPCol_ListOfShape aLCBF(theAllocator);
BOPCol_ListOfShape aLFIN(theAllocator);
BOPCol_ListOfShape aLEx(theAllocator);
//
// for all non-solid faces build EF map [ aMEFP ]
for (j=1; j<=aNbFaces; ++j) {
const TopoDS_Shape& aFace=aMFaces(j);
if (!aMS.Contains(aFace)) {
BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
}
}
//
// among all faces from aMEFP select these that have same edges
// with the solid (i.e aMEF). These faces will be treated first
// to prevent the usage of 3D classifier.
// The full list of faces to process is aLFP1.
aNbEFP=aMEFP.Extent();
for (j=1; j<=aNbEFP; ++j) {
const TopoDS_Shape& aE=aMEFP.FindKey(j);
//
if (aMEF.Contains(aE)) { // !!
const BOPCol_ListOfShape& aLF=aMEFP(j);
aItFP.Initialize(aLF);
for (; aItFP.More(); aItFP.Next()) {
const TopoDS_Shape& aF=aItFP.Value();
if (aMFDone.Add(aF)) {
aLFP1.Append(aF);
}
}
}
else {
aLEx.Append(aE);
}
}
//
aItEx.Initialize(aLEx);
for (; aItEx.More(); aItEx.Next()) {
const TopoDS_Shape& aE=aItEx.Value();
const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE);
aItFP.Initialize(aLF);
for (; aItFP.More(); aItFP.Next()) {
const TopoDS_Shape& aF=aItFP.Value();
if (aMFDone.Add(aF)) {
//aLFP2.Append(aF);
aLFP1.Append(aF);
}
}
}
//
//==========
//
// 3 Process faces aLFP1
aMFDone.Clear();
aNbFP=aLFP1.Extent();
aItFP.Initialize(aLFP1);
for (; aItFP.More(); aItFP.Next()) {
const TopoDS_Shape& aSP=aItFP.Value();
if (!aMFDone.Add(aSP)) {
continue;
}
//
// first face to process
aFP=(*(TopoDS_Face*)(&aSP));
bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext);
aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
//
// collect faces to process [ aFP is the first ]
aLFP.Clear();
aLFP.Append(aFP);
aItS.Initialize(aLFP1);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSk=aItS.Value();
if (!aMFDone.Contains(aSk)) {
aLFP.Append(aSk);
}
}
//
// Connexity Block that spreads from aFP the Bound
// or till the end of the block itself
aLCBF.Clear();
BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator);
//
// fill states for the Connexity Block
aItS.Initialize(aLCBF);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSx=aItS.Value();
aMFDone.Add(aSx);
if (aState==TopAbs_IN) {
aMFIN.Add(aSx);
}
}
//
aNbFPx=aMFDone.Extent();
if (aNbFPx==aNbFP) {
break;
}
}//for (; aItFP.More(); aItFP.Next())
//
// faces Inside aSolid
aLFIN.Clear();
aNbFIN=aMFIN.Extent();
if (aNbFIN || aNbLIF) {
for (j=1; j<=aNbFIN; ++j) {
const TopoDS_Shape& aFIn=aMFIN(j);
aLFIN.Append(aFIn);
}
//
aItS.Initialize(aLIF);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aFIN=aItS.Value();
aLFIN.Append(aFIN);
}
//
theInParts.Bind(aSolid, aLFIN);
}
if (aNbFIN || bHasImage) {
theDraftSolids.Bind(aSolid, aSolidSp);
}
}// for (; aItMS.More(); aItMS.Next()) {
}
//=======================================================================
//function : BuildDraftSolid
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid,
TopoDS_Shape& theDraftSolid,
BOPCol_ListOfShape& theLIF)
{
myErrorStatus=0;
//
Standard_Boolean bToReverse;
Standard_Integer iFlag;
TopAbs_Orientation aOrF, aOrSh, aOrSd;
TopoDS_Iterator aIt1, aIt2;
TopoDS_Shell aShD;
TopoDS_Shape aFSDx, aFx;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItS;
//
aOrSd=theSolid.Orientation();
theDraftSolid.Orientation(aOrSd);
//
aIt1.Initialize(theSolid);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSh=aIt1.Value();
if(aSh.ShapeType()!=TopAbs_SHELL) {
continue; // mb internal edges,vertices
}
//
aOrSh=aSh.Orientation();
aBB.MakeShell(aShD);
aShD.Orientation(aOrSh);
iFlag=0;
//
aIt2.Initialize(aSh);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aF=aIt2.Value();
aOrF=aF.Orientation();
//
if (myImages.IsBound(aF)) {
const BOPCol_ListOfShape& aLSp=myImages.Find(aF);
aItS.Initialize(aLSp);
for (; aItS.More(); aItS.Next()) {
aFx=aItS.Value();
//
if (myShapesSD.IsBound(aFx)) {
aFSDx=myShapesSD.Find(aFx);
//
if (aOrF==TopAbs_INTERNAL) {
aFSDx.Orientation(aOrF);
theLIF.Append(aFSDx);
}
else {
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aFSDx, aF, myContext);
if (bToReverse) {
aFSDx.Reverse();
}
//
iFlag=1;
aBB.Add(aShD, aFSDx);
}
}//if (myShapesSD.IsBound(aFx)) {
else {
aFx.Orientation(aOrF);
if (aOrF==TopAbs_INTERNAL) {
theLIF.Append(aFx);
}
else{
iFlag=1;
aBB.Add(aShD, aFx);
}
}
}
} // if (myImages.IsBound(aF)) {
//
else {
if (aOrF==TopAbs_INTERNAL) {
theLIF.Append(aF);
}
else{
iFlag=1;
aBB.Add(aShD, aF);
}
}
} //for (; aIt2.More(); aIt2.Next()) {
//
if (iFlag) {
aBB.Add(theDraftSolid, aShD);
}
} //for (; aIt1.More(); aIt1.Next()) {
}
//=======================================================================
//function : BuildSplitSolids
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
myErrorStatus=0;
//
Standard_Boolean bFlagSD;
Standard_Integer i, aNbS, iErr, aNbSFS;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_DataMapIteratorOfDataMapOfShapeShape aIt1;
//
BOPCol_ListOfShape aSFS(theAllocator), aLSEmpty(theAllocator);
BOPCol_MapOfShape aMFence(100, theAllocator);
BOPTools_MapOfSet aMST(100, theAllocator);
//
// 0. Find same domain solids for non-interferred solids
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
//
if (aSI.ShapeType()!=TopAbs_SOLID) {
continue;
}
//
const TopoDS_Shape& aS=aSI.Shape();
if (!aMFence.Add(aS)) {
continue;
}
if(theDraftSolids.IsBound(aS)) {
continue;
}
//
BOPTools_Set aST;
//
aST.Add(aS, TopAbs_FACE);
aMST.Add(aST);
//
} //for (i=1; i<=aNbS; ++i)
//
// 1. Build solids for interferred source solids
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
//
if (aSI.ShapeType()!=TopAbs_SOLID) {
continue;
}
//
const TopoDS_Shape& aS=aSI.Shape();
if(!theDraftSolids.IsBound(aS)) {
continue;
}
const TopoDS_Shape& aSD=theDraftSolids.Find(aS);
const BOPCol_ListOfShape& aLFIN=
(theInParts.IsBound(aS)) ? theInParts.Find(aS) : aLSEmpty;
//
// 1.1 Fill Shell Faces Set
aSFS.Clear();
aExp.Init(aSD, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aF=aExp.Current();
aSFS.Append(aF);
}
//
aIt.Initialize(aLFIN);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape aF=aIt.Value();
//
aF.Orientation(TopAbs_FORWARD);
aSFS.Append(aF);
aF.Orientation(TopAbs_REVERSED);
aSFS.Append(aF);
}
//
aNbSFS=aSFS.Extent();
//DEB f
// <-A
//DEB t
//
// 1.3 Build new solids
BOPAlgo_BuilderSolid aSB(theAllocator);
//
//aSB.SetContext(myContext);
aSB.SetShapes(aSFS);
aSB.Perform();
iErr=aSB.ErrorStatus();
if (iErr) {
myErrorStatus=30; // SolidBuilder failed
return;
}
//
const BOPCol_ListOfShape& aLSR=aSB.Areas();
//
// 1.4 Collect resulting solids and theirs set of faces.
// Update Images.
if (!myImages.IsBound(aS)) {
BOPCol_ListOfShape aLSx;
//
myImages.Bind(aS, aLSx);
BOPCol_ListOfShape& aLSIm=myImages.ChangeFind(aS);
//
aIt.Initialize(aLSR);
for (; aIt.More(); aIt.Next()) {
BOPTools_Set aST;
//
const TopoDS_Shape& aSR=aIt.Value();
aST.Add(aSR, TopAbs_FACE);
//
bFlagSD=aMST.Contains(aST);
//
const BOPTools_Set& aSTx=aMST.Added(aST);
const TopoDS_Shape& aSx=aSTx.Shape();
aLSIm.Append(aSx);
//
if (bFlagSD) {
myShapesSD.Bind(aSR, aSx);
}
}
}
} // for (; aIt1.More(); aIt1.Next()) {
}
//=======================================================================
//function :FillInternalShapes
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillInternalShapes()
{
myErrorStatus=0;
//
Standard_Integer i, j, aNbS, aNbSI, aNbSx, aNbSd;
TopAbs_ShapeEnum aType;
TopAbs_State aState;
TopoDS_Iterator aItS;
BRep_Builder aBB;
BOPCol_MapIteratorOfMapOfShape aItM;
BOPCol_ListIteratorOfListOfShape aIt, aIt1;
//
Handle(NCollection_IncAllocator) aAllocator;
//-----------------------------------------------------scope f
aAllocator=new NCollection_IncAllocator();
//
BOPCol_IndexedDataMapOfShapeListOfShape aMSx(100, aAllocator);
BOPCol_IndexedMapOfShape aMx(100, aAllocator);
BOPCol_MapOfShape aMSI(100, aAllocator);
BOPCol_MapOfShape aMFence(100, aAllocator);
BOPCol_MapOfShape aMSOr(100, aAllocator);
BOPCol_ListOfShape aLSd(aAllocator);
BOPCol_ListOfShape aLArgs(aAllocator);
//
// 1. Shapes to process
//
// 1.1 Shapes from pure arguments aMSI
// 1.1.1 vertex, edge, wire
//
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
if (!aMFence.Add(aS)) {
continue;
}
//
aType=aS.ShapeType();
if (aType==TopAbs_WIRE) {
aItS.Initialize(aS);
for(; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aE=aItS.Value();
if (aMFence.Add(aE)) {
aLArgs.Append(aE);
}
}
}
else if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE){
aLArgs.Append(aS);
}
}
aMFence.Clear();
//
aIt.Initialize(aLArgs);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||aType==TopAbs_WIRE) {
if (aMFence.Add(aS)) {
if (myImages.IsBound(aS)) {
const BOPCol_ListOfShape &aLSp=myImages.Find(aS);
aIt1.Initialize(aLSp);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSp=aIt1.Value();
aMSI.Add(aSp);
}
}
else {
aMSI.Add(aS);
}
}
}
}
aNbSI=aMSI.Extent();
//
// 2. Internal vertices, edges from source solids
aMFence.Clear();
aLSd.Clear();
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
//
if (aSI.ShapeType()!=TopAbs_SOLID) {
continue;
}
//
const TopoDS_Shape& aS=aSI.Shape();
//
aMx.Clear();
OwnInternalShapes(aS, aMx);
//
aNbSx=aMx.Extent();
for (j=1; j<=aNbSx; ++j) {
const TopoDS_Shape& aSi=aMx(j);
if (myImages.IsBound(aSi)) {
const BOPCol_ListOfShape &aLSp=myImages.Find(aSi);
aIt1.Initialize(aLSp);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSp=aIt1.Value();
aMSI.Add(aSp);
}
}
else {
aMSI.Add(aSi);
}
}
//
// build aux map from splits of solids
if (myImages.IsBound(aS)) {
const BOPCol_ListOfShape &aLSp=myImages.Find(aS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
if (aMFence.Add(aSp)) {
BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx);
BOPTools::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx);
aLSd.Append(aSp);
}
}
}
else {
if (aMFence.Add(aS)) {
BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx);
BOPTools::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx);
aLSd.Append(aS);
aMSOr.Add(aS);
}
}
}// for (i=0; i<aNbS; ++i) {
//
aNbSd=aLSd.Extent();
//
// 3. Some shapes of aMSI can be already tied with faces of
// split solids
aItM.Initialize(aMSI);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aSI=aItM.Key();
if (aMSx.Contains(aSI)) {
const BOPCol_ListOfShape &aLSx=aMSx.FindFromKey(aSI);
aNbSx=aLSx.Extent();
if (aNbSx) {
aMSI.Remove(aSI);
}
}
}
//
// 4. Just check it
aNbSI=aMSI.Extent();
if (!aNbSI) {
return;
}
//
// 5 Settle internal vertices and edges into solids
aMx.Clear();
aIt.Initialize(aLSd);
for (; aIt.More(); aIt.Next()) {
TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
//
aItM.Initialize(aMSI);
for (; aItM.More(); aItM.Next()) {
TopoDS_Shape aSI=aItM.Key();
aSI.Orientation(TopAbs_INTERNAL);
//
aState=BOPTools_AlgoTools::ComputeStateByOnePoint(aSI, aSd, 1.e-11, myContext);
if (aState==TopAbs_IN) {
//
if(aMSOr.Contains(aSd)) {
//
TopoDS_Solid aSdx;
//
aBB.MakeSolid(aSdx);
aItS.Initialize(aSd);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSh=aItS.Value();
aBB.Add(aSdx, aSh);
}
//
aBB.Add(aSdx, aSI);
//
if (myImages.IsBound(aSdx)) {
BOPCol_ListOfShape& aLS=myImages.ChangeFind(aSdx);
aLS.Append(aSdx);
}
else {
BOPCol_ListOfShape aLS;
aLS.Append(aSdx);
myImages.Bind(aSd, aLS);
}
//
aMSOr.Remove(aSd);
aSd=aSdx;
}
else {
aBB.Add(aSd, aSI);
}
//
aMSI.Remove(aSI);
} //if (aState==TopAbs_IN) {
}// for (; aItM.More(); aItM.Next()) {
}//for (; aIt1.More(); aIt1.Next()) {
//
//-----------------------------------------------------scope t
aLArgs.Clear();
aLSd.Clear();
aMSOr.Clear();
aMFence.Clear();
aMSI.Clear();
aMx.Clear();
aMSx.Clear();
}
//=======================================================================
//function : OwnInternalShapes
//purpose :
//=======================================================================
void OwnInternalShapes(const TopoDS_Shape& theS,
BOPCol_IndexedMapOfShape& theMx)
{
TopoDS_Iterator aIt;
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (aSx.ShapeType()!=TopAbs_SHELL) {
theMx.Add(aSx);
}
}
}
//
// ErrorStatus
// 30 - SolidBuilder failed
// A
/*
{
TopoDS_Compound aCx;
BRep_Builder aBBx;
BOPCol_ListIteratorOfListOfShape aItx;
//
aBBx.MakeCompound(aCx);
aItx.Initialize(aSFS1);
for (; aItx.More(); aItx.Next()) {
const TopoDS_Shape& aFx=aItx.Value();
aBBx.Add(aCx, aFx);
}
BRepTools::Write(aCx, "cxso");
int a=0;
}
*/

View File

@@ -0,0 +1,313 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_Builder.ixx>
#include <TopoDS_Iterator.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools.hxx>
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape& theS)
{
Standard_Boolean bHasImage, bToReverse;
TopAbs_ShapeEnum aType;
BOPCol_ListIteratorOfListOfShape aIt;
//
myHistShapes.Clear();
//
if (theS.IsNull()) {
return myHistShapes;
}
//
bHasImage=myImages.IsBound(theS);
if (!bHasImage) {
return myHistShapes;
}
//
aType=theS.ShapeType();
//
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return myHistShapes;
}
//
//PrepareHistory();
//
const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
if (myShapesSD.IsBound(aSp)) {
if (myMapShape.Contains(aSp)) {
TopoDS_Shape aSpR=myShapesSD.Find(aSp);
//
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
aSpR.Orientation(theS.Orientation());
}
else {
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSpR, theS, myContext);
if (bToReverse) {
aSpR.Reverse();
}
}
//
myHistShapes.Append(aSpR);
}
}
}
//
return myHistShapes;
}
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_Builder::Modified(const TopoDS_Shape& theS)
{
Standard_Boolean bHasImage, bToReverse;
TopAbs_ShapeEnum aType;
BOPCol_ListIteratorOfListOfShape aIt;
//
myHistShapes.Clear();
//
if (theS.IsNull()) {
return myHistShapes;
}
//
bHasImage=myImages.IsBound(theS);
if (!bHasImage) {
return myHistShapes;
}
//
aType=theS.ShapeType();
//
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return myHistShapes;
}
//
//PrepareHistory();
//
const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape aSp=aIt.Value();
if (!myShapesSD.IsBound(aSp)) {
if (myMapShape.Contains(aSp)) {
//
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
aSp.Orientation(theS.Orientation());
}
else {
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
if (bToReverse) {
aSp.Reverse();
}
}
//
myHistShapes.Append(aSp);
}
}
}
//
return myHistShapes;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
{
Standard_Boolean bRet, bHasImage, bContains;
TopAbs_ShapeEnum aType;
BOPCol_ListIteratorOfListOfShape aIt;
//
bRet=Standard_False;
//
if (theS.IsNull()) {
return !bRet; //true
}
//
aType=theS.ShapeType();
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return !bRet;
}
//
bHasImage=myImages.IsBound(theS);
if (!bHasImage) {
return !bRet; //true
}
//
//PrepareHistory();
//
bContains=myMapShape.Contains(theS);
if (bContains) {
return bRet; //false
}
//
const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape aSp=aIt.Value();
//
if (!myShapesSD.IsBound(aSp)) {
if (myMapShape.Contains(aSp)) {
return bRet; //false
}
}
else {
TopoDS_Shape aSpR=myShapesSD.Find(aSp);
if (myMapShape.Contains(aSpR)) {
return bRet; //false
}
}
}
return !bRet; // true
}
//=======================================================================
//function : PrepareHistory
//purpose :
//=======================================================================
void BOPAlgo_Builder::PrepareHistory()
{
if (!myFlagHistory) {
return;
}
//
if(myShape.IsNull()) {
return;
}
//
Standard_Boolean bHasImage, bContainsSD;
TopAbs_ShapeEnum aType;
BOPCol_MapOfShape aMS;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_MapIteratorOfMapOfShape aItM;
//
// 1. Clearing
BOPAlgo_BuilderShape::PrepareHistory();
//
// 2. myMapShape - all shapes of result with theirs sub-shapes
BOPTools::MapShapes(myShape, myMapShape);
//
// 3. MS - all argument shapes with theirs sub-shapes
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
BOPTools::MapShapes(aSx, aMS);
}
//
// 4. Treatment
aItM.Initialize(aMS);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aSx=aItM.Key();
aType=aSx.ShapeType();
//
// 4.1 .myImagesResult
bHasImage=myImages.IsBound(aSx);
//
BOPCol_ListOfShape aLSx;
if (!bHasImage) {
if (myMapShape.Contains(aSx)) {
aLSx.Append(aSx);
myImagesResult.Add(aSx, aLSx);
}
}
else {
const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
if (myMapShape.Contains(aSp)) {
aLSx.Append(aSp);
}
}
myImagesResult.Add(aSx, aLSx);
}
// <- A
//
// 4.2 As it was
if (!myHasDeleted) {
myHasDeleted=IsDeleted(aSx);
}
//
if (!myHasGenerated || !myHasModified) {
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
if (bHasImage) {
const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
//
if (myMapShape.Contains(aSp)) {
bContainsSD=myShapesSD.IsBound(aSp);
//
if (!myHasGenerated) {
if (bContainsSD) {
myHasGenerated=Standard_True;
}
}
if (!myHasModified) {
if (!bContainsSD) {
myHasModified=Standard_True;
}
}
} // if (myMapShape.Contains(aSp))
}
}
}
}
}
myFlagHistory=Standard_True;
}
// <- A
/*
BOPCol_ListOfShape aLSx;
if (!bHasImage) {
if (myMapShape.Contains(aSx)) {
aLSx.Append(aSx);
myImagesResult.Add(aSx, aLSx);
}
}
else {
const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
if (myMapShape.Contains(aSp)) {
aLSx.Append(aSp);
}
}
myImagesResult.Add(aSx, aLSx);
}
*/

View File

@@ -0,0 +1,84 @@
-- Created on: 2004-09-03
-- Created by: Oleg FEDYAEV
-- Copyright (c) 2004-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.
class CheckResult from BOPAlgo
---Purpose: contains information about faulty shapes and faulty types
--- can't be processed by Boolean Operations
uses
Shape from TopoDS,
CheckStatus from BOPAlgo,
ListOfShape from BOPCol
is
Create
returns CheckResult;
---Purpose: empty constructor
SetShape1(me: in out; TheShape : Shape from TopoDS);
---Purpose: sets ancestor shape (object) for faulty sub-shapes
AddFaultyShape1(me: in out; TheShape: Shape from TopoDS);
---Purpose: adds faulty sub-shapes from object to a list
SetShape2(me: in out; TheShape: Shape from TopoDS);
---Purpose: sets ancestor shape (tool) for faulty sub-shapes
AddFaultyShape2(me: in out; TheShape: Shape from TopoDS);
---Purpose: adds faulty sub-shapes from tool to a list
GetShape1(me)
returns Shape from TopoDS;
---C++: return const&
---Purpose: returns ancestor shape (object) for faulties
GetShape2(me)
returns Shape from TopoDS;
---C++: return const&
---Purpose: returns ancestor shape (tool) for faulties
GetFaultyShapes1(me)
returns ListOfShape from BOPCol;
---C++: return const&
---Purpose: returns list of faulty shapes for object
GetFaultyShapes2(me)
returns ListOfShape from BOPCol;
---C++: return const&
---Purpose: returns list of faulty shapes for tool
SetCheckStatus(me: in out; TheStatus: CheckStatus from BOPAlgo);
---Purpose: set status of faulty
GetCheckStatus(me)
returns CheckStatus from BOPAlgo;
---Purpose: gets status of faulty
fields
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myStatus : CheckStatus from BOPAlgo;
myFaulty1 : ListOfShape from BOPCol;
myFaulty2 : ListOfShape from BOPCol;
end CheckResult;

View File

@@ -0,0 +1,79 @@
// Created on: 2004-09-02
// Created by: Oleg FEDYAEV
// Copyright (c) 2004-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 <BOPAlgo_CheckResult.ixx>
//=======================================================================
// function: BOPAlgo_CheckResult()
// purpose:
//=======================================================================
BOPAlgo_CheckResult::BOPAlgo_CheckResult() : myStatus(BOPAlgo_CheckUnknown)
{
}
void BOPAlgo_CheckResult::SetShape1(const TopoDS_Shape& TheShape)
{
myShape1 = TheShape;
}
void BOPAlgo_CheckResult::AddFaultyShape1(const TopoDS_Shape& TheShape)
{
myFaulty1.Append(TheShape);
}
void BOPAlgo_CheckResult::SetShape2(const TopoDS_Shape& TheShape)
{
myShape2 = TheShape;
}
void BOPAlgo_CheckResult::AddFaultyShape2(const TopoDS_Shape& TheShape)
{
myFaulty2.Append(TheShape);
}
const TopoDS_Shape& BOPAlgo_CheckResult::GetShape1() const
{
return myShape1;
}
const TopoDS_Shape & BOPAlgo_CheckResult::GetShape2() const
{
return myShape2;
}
const BOPCol_ListOfShape& BOPAlgo_CheckResult::GetFaultyShapes1() const
{
return myFaulty1;
}
const BOPCol_ListOfShape& BOPAlgo_CheckResult::GetFaultyShapes2() const
{
return myFaulty2;
}
void BOPAlgo_CheckResult::SetCheckStatus(const BOPAlgo_CheckStatus TheStatus)
{
myStatus = TheStatus;
}
BOPAlgo_CheckStatus BOPAlgo_CheckResult::GetCheckStatus() const
{
return myStatus;
}

View File

@@ -0,0 +1,35 @@
-- Created by: Peter Kurnev
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
--
class CheckerSI from BOPAlgo
inherits PaveFiller from BOPAlgo
---Purpose: Checks shape on self-interference.
is
Create
returns CheckerSI from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_CheckerSI();"
Init (me:out)
is redefined protected;
end CheckerSI;

View File

@@ -0,0 +1,73 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_CheckerSI.ixx>
#include <BOPDS_DS.hxx>
#include <BOPDS_IteratorSI.hxx>
#include <BOPInt_Context.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_CheckerSI::BOPAlgo_CheckerSI()
:
BOPAlgo_PaveFiller()
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BOPAlgo_CheckerSI::Init()
{
myErrorStatus = 0;
//
if (!myArguments.Extent()) {
myErrorStatus=10;
return;
}
//
Clear();
//
// 1. myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
myDS->Init();
//
// 2.myIterator
myIterator=new BOPDS_IteratorSI(myAllocator);
myIterator->SetDS(myDS);
myIterator->Prepare();
//
// 3 myContext
myContext=new BOPInt_Context;
//
myErrorStatus=0;
}

View File

@@ -0,0 +1,27 @@
// Copyright (c) 20010-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.
#ifndef BOPAlgo_ListOfCheckResult_HeaderFile
#define BOPAlgo_ListOfCheckResult_HeaderFile
#include <NCollection_List.hxx>
#include <BOPAlgo_CheckResult.hxx>
typedef NCollection_List<BOPAlgo_CheckResult> BOPAlgo_ListOfCheckResult;
typedef BOPAlgo_ListOfCheckResult::Iterator BOPAlgo_ListIteratorOfListOfCheckResult;
#endif

View File

@@ -0,0 +1,351 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
class PaveFiller from BOPAlgo
inherits Algo from BOPAlgo
---Purpose:
uses
Pnt from gp,
Vertex from TopoDS,
Face from TopoDS,
Edge from TopoDS,
BaseAllocator from BOPCol,
ListOfShape from BOPCol,
MapOfInteger from BOPCol,
ListOfInteger from BOPCol,
DataMapOfShapeInteger from BOPCol,
IndexedDataMapOfShapeInteger from BOPCol,
DataMapOfIntegerListOfInteger from BOPCol,
DataMapOfShapeListOfShape from BOPCol,
IndexedDataMapOfShapeListOfShape from BOPCol,
--
Context from BOPInt,
--
SectionAttribute from BOPAlgo,
DS from BOPDS,
PDS from BOPDS,
Iterator from BOPDS,
PIterator from BOPDS,
PaveBlock from BOPDS,
Curve from BOPDS,
IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS,
MapOfPaveBlock from BOPDS,
ListOfPaveBlock from BOPDS,
ListOfPave from BOPDS,
ListOfPntOn2S from IntSurf,
Curve from IntTools,
DataMapOfPaveBlockListOfPaveBlock from BOPDS,
VectorOfCurve from BOPDS
--raises
is
Create
returns PaveFiller from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_PaveFiller();"
Create (theAllocator: BaseAllocator from BOPCol)
returns PaveFiller from BOPAlgo;
DS(me:out)
returns DS from BOPDS;
---C++:return const &
PDS(me:out)
returns PDS from BOPDS;
Iterator(me:out)
returns PIterator from BOPDS;
---C++:return const &
Arguments(me)
returns ListOfShape from BOPCol;
---C++: return const &
---C++: alias "Standard_EXPORT void SetArguments(const BOPCol_ListOfShape& theLS);"
Context(me:out)
returns Context from BOPInt;
SetSectionAttribute(me:out;
theSecAttr : SectionAttribute from BOPAlgo);
Perform(me:out)
is redefined;
--
-- protected methods
--
Clear(me:out)
is virtual protected;
Init(me:out)
is virtual protected;
PerformVV(me:out)
is virtual protected;
PerformVE(me:out)
is virtual protected;
PerformVF(me:out)
is virtual protected;
PerformEE(me:out)
is virtual protected;
PerformEF(me:out)
is virtual protected;
PerformFF(me:out)
is virtual protected;
TreatVerticesEE(me:out)
is protected;
MakeSplitEdges(me:out)
is protected;
MakeBlocks(me:out)
is protected;
MakePCurves(me:out)
is protected;
ProcessDE(me:out)
is protected;
FillShrunkData(me:out;
thePB:out PaveBlock from BOPDS)
is protected;
PerformVerticesEE(me:out;
theMVCPB:out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
theAllocator:out BaseAllocator from BOPCol)
returns Integer from Standard
is protected;
PerformVerticesEF(me:out;
theMVCPB:out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
theAllocator:out BaseAllocator from BOPCol)
returns Integer from Standard
is protected;
CheckFacePaves(me:out;
theVnew:Vertex from TopoDS;
theMIF:MapOfInteger from BOPCol)
returns Boolean from Standard
is protected;
CheckFacePaves(myclass;
theN:Integer from Standard;
theMIFOn:MapOfInteger from BOPCol;
theMIFIn:MapOfInteger from BOPCol)
returns Boolean from Standard
is protected;
IsExistingVertex(me;
theP:Pnt from gp;
theTol:Real from Standard;
theMVOn:MapOfInteger from BOPCol)
returns Boolean from Standard
is protected;
PutPaveOnCurve(me:out;
theMVOn:MapOfInteger from BOPCol;
theTolR3D:Real from Standard;
theNC:out Curve from BOPDS;
nF1:Integer from Standard;
nF2:Integer from Standard;
theMVEF:MapOfInteger from BOPCol)
is protected;
ExtendedTolerance(me:out;
nV:Integer from Standard;
aMI:MapOfInteger from BOPCol;
aTolVExt:out Real from Standard)
returns Boolean from Standard
is protected;
PutBoundPaveOnCurve(me:out;
theF1: Face from TopoDS;
theF2: Face from TopoDS;
theTolR3D:Real from Standard;
theNC:out Curve from BOPDS;
theMVOnIn:out MapOfInteger from BOPCol;
theMVB:out MapOfInteger from BOPCol)
is protected;
IsExistingPaveBlock(me:out;
thePB:PaveBlock from BOPDS;
theNC:Curve from BOPDS;
theTolR3D:Real from Standard;
theMPB:MapOfPaveBlock from BOPDS;
thePBOut:out PaveBlock from BOPDS)
returns Boolean from Standard
is protected;
IsExistingPaveBlock(me:out;
thePB:PaveBlock from BOPDS;
theNC:Curve from BOPDS;
theTolR3D:Real from Standard;
theLSE:ListOfInteger from BOPCol)
returns Boolean from Standard
is protected;
PostTreatFF(me:out;
theMSCPB:out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
theMVI:out DataMapOfShapeInteger from BOPCol;
theDMExEd:out DataMapOfPaveBlockListOfPaveBlock from BOPDS;
theAllocator:out BaseAllocator from BOPCol)
returns Integer from Standard
is protected;
--
-- Treatment of degenerated edges
--
FindPaveBlocks(me:out;
theV:Integer from Standard;
theF:Integer from Standard;
theLPB:out ListOfPaveBlock from BOPDS)
is protected;
FillPaves(me:out;
theV:Integer from Standard;
theE:Integer from Standard;
theF:Integer from Standard;
theLPB: ListOfPaveBlock from BOPDS;
thePB: PaveBlock from BOPDS)
is protected;
MakeSplitEdge(me:out;
theV:Integer from Standard;
theF:Integer from Standard)
is protected;
GetEFPnts(me:out;
nF1 : Integer from Standard;
nF2 : Integer from Standard;
aListOfPnts: out ListOfPntOn2S from IntSurf)
is protected;
PutEFPavesOnCurve(me:out;
nF1 : Integer from Standard;
nF2 : Integer from Standard;
theNC : out Curve from BOPDS;
theMVEF : MapOfInteger from BOPCol)
is protected;
PutStickPavesOnCurve(me:out;
nF1 : Integer from Standard;
nF2 : Integer from Standard;
theNC : out Curve from BOPDS;
theMVStick : MapOfInteger from BOPCol)
is protected;
GetStickVertices(me:out;
nF1 : Integer from Standard;
nF2 : Integer from Standard;
theMVStick : out MapOfInteger from BOPCol;
theMVEFk : out MapOfInteger from BOPCol)
is protected;
GetFullFaceMap(me:out;
nF : Integer from Standard;
theMI : out MapOfInteger from BOPCol)
is protected;
RemoveUsedVertices(me:out;
theNC : out Curve from BOPDS;
theMV : out MapOfInteger from BOPCol)
is protected;
PutPaveOnCurve(me:out;
nV : Integer from Standard;
theTolR3D : Real from Standard;
theNC : Curve from BOPDS;
thePB : out PaveBlock from BOPDS)
is protected;
ProcessExistingPaveBlocks(me:out;
theInt : Integer from Standard;
theMPBOnIn : MapOfPaveBlock from BOPDS;
theMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
theMVI : out DataMapOfShapeInteger from BOPCol;
theMVB : MapOfInteger from BOPCol;
theMPB : out MapOfPaveBlock from BOPDS)
is protected;
UpdateExistingPaveBlocks(me:out;
thePB : PaveBlock from BOPDS;
theLPB : out ListOfPaveBlock from BOPDS;
nF1 : Integer from Standard;
nF2 : Integer from Standard)
is protected;
TreatNewVertices(me:out;
theMVI : IndexedDataMapOfShapeInteger from BOPCol;
theImages : out IndexedDataMapOfShapeListOfShape from BOPCol)
is protected;
PutClosingPaveOnCurve (me:out;
aNC :out Curve from BOPDS)
is protected;
---Purpose:
--- Put paves on the curve <aBC> in case when <aBC>
--- is closed 3D-curve
PreparePostTreatFF(me:out;
aInt : Integer from Standard;
aPB : PaveBlock from BOPDS;
aMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
aMVI : out DataMapOfShapeInteger from BOPCol;
aVC : out VectorOfCurve from BOPDS)
is protected;
---Purpose:
---Keeps data for post treatment
RefineFaceInfoOn(me:out)
is protected;
---Purpose:
--- Refines the state On for the all faces having
--- state information
UpdateFaceInfo(me:out;
theDME:out DataMapOfPaveBlockListOfPaveBlock from BOPDS)
is protected;
---Purpose:
---Updates the information about faces
fields
myArguments : ListOfShape from BOPCol is protected;
myDS : PDS from BOPDS is protected;
myIterator : PIterator from BOPDS is protected;
myContext : Context from BOPInt is protected;
mySectionAttribute : SectionAttribute from BOPAlgo is protected;
end PaveFiller;

View File

@@ -0,0 +1,224 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <NCollection_BaseAllocator.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_Iterator.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
:
BOPAlgo_Algo()
{
myDS=NULL;
myIterator=NULL;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator)
{
myDS=NULL;
myIterator=NULL;
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
{
Clear();
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::Clear()
{
if (myIterator) {
delete myIterator;
myIterator=NULL;
}
if (myDS) {
delete myDS;
myDS=NULL;
}
myErrorStatus=2;
}
//=======================================================================
//function : DS
//purpose :
//=======================================================================
const BOPDS_DS& BOPAlgo_PaveFiller::DS()
{
return *myDS;
}
//=======================================================================
//function : PDS
//purpose :
//=======================================================================
BOPDS_PDS BOPAlgo_PaveFiller::PDS()
{
return myDS;
}
//=======================================================================
//function : Context
//purpose :
//=======================================================================
Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context()
{
return myContext;
}
//=======================================================================
//function : SectionAttribute
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetSectionAttribute(const BOPAlgo_SectionAttribute& theSecAttr)
{
mySectionAttribute = theSecAttr;
}
//=======================================================================
//function : SetArguments
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
{
myArguments=theLS;
}
//=======================================================================
//function : Arguments
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
{
return myArguments;
}
//=======================================================================
// function: Init
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::Init()
{
myErrorStatus=0;
//
if (!myArguments.Extent()) {
myErrorStatus=10;
return;
}
//
// 0 Clear
Clear();
//
// 1.myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
myDS->Init();
//
// 2.myIterator
myIterator=new BOPDS_Iterator(myAllocator);
myIterator->SetDS(myDS);
myIterator->Prepare();
//
// 3 myContext
myContext=new BOPInt_Context;
//
myErrorStatus=0;
}
//=======================================================================
// function: Perform
// purpose:
//=======================================================================
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;
}
//
}

View File

@@ -0,0 +1,146 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_BaseAllocator.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBndLib.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPAlgo_Tools.hxx>
//=======================================================================
// function: PerformVV
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformVV()
{
Standard_Boolean bWithSubShape;
Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX, k, aNbBlocks;
Handle(NCollection_IncAllocator) aAllocator;
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
TopoDS_Vertex aVn;
BOPDS_ShapeInfo aSIn;
//
myErrorStatus=0;
//
myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
aSize=myIterator->ExpectedLength();
if (!aSize) {
return;
}
//
aSIn.SetShapeType(TopAbs_VERTEX);
BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
aVVs.SetStartSize(aSize);
aVVs.SetIncrement(aSize);
aVVs.Init();
//
//-----------------------------------------------------scope f
aAllocator=new NCollection_IncAllocator();
BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
BOPCol_ListOfShape aLV(aAllocator);
//
// 1. Map V/LV
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(n1, n2, bWithSubShape);
//
const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
//
iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2);
if (!iFlag) {
BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
}
}
//
// 2. Make blocks
BOPAlgo_Tools::MakeBlocksCnx(aMILI, aMBlocks, aAllocator);
//
// 3. Make vertices
aNbBlocks=aMBlocks.Extent();
for (k=0; k<aNbBlocks; ++k) {
const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
//
aLV.Clear();
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nX=aItLI.Value();
const TopoDS_Shape& aV=myDS->Shape(nX);
aLV.Append(aV);
}
//
BOPTools_AlgoTools::MakeVertex(aLV, aVn);
//
// Appennd new vertex to the DS
aSIn.SetShape(aVn);
n=myDS->Append(aSIn);
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aVn, aBox);
//
// Fill ShapesSD
aItLI.Initialize(aLI);
for (i=0; aItLI.More(); aItLI.Next(), ++i) {
n1=aItLI.Value();
myDS->AddShapeSD(n1, n);
//
aItLI2.Initialize(aLI);
for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
if (j>i) {
n2=aItLI2.Value();
//
myDS->AddInterf(n1, n2);
iX=aVVs.Append()-1;
BOPDS_InterfVV& aVV=aVVs(iX);
aVV.SetIndices(n1, n2);
aVV.SetIndexNew(n);
}
}
}
}
aNbVV=aVVs.Extent();
//
//-----------------------------------------------------scope t
aLV.Clear();
aMBlocks.Clear();
aMILI.Clear();
aAllocator.Nullify();
}

View File

@@ -0,0 +1,125 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Tool.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_PassKey.hxx>
#include <BOPDS_MapOfPassKey.hxx>
#include <BRepBndLib.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
// function: PerformVE
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformVE()
{
Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i;
Standard_Real aT, aTolE, aTolV;
BOPDS_Pave aPave;
BOPDS_PassKey aPK;
BOPDS_MapOfPassKey aMPK;
BRep_Builder aBB;
//
myErrorStatus=0;
//
myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
iSize=myIterator->ExpectedLength();
if (!iSize) {
return;
}
//
BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
aVEs.SetStartSize(iSize);
aVEs.SetIncrement(iSize);
aVEs.Init();
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nV, nE, bJustAdd);
if(bJustAdd) {
continue;
}
//
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasSubShape(nV)) {
continue;
}
//
if (aSIE.HasFlag()){
continue;
}
//
if (myDS->HasInterfShapeSubShapes(nV, nE)) {
continue;
}
//
nVx=nV;
if (myDS->HasShapeSD(nV, nVSD)) {
nVx=nVSD;
}
//
aPK.SetIds(nVx, nE);
if (!aMPK.Add(aPK)) {
continue;
}
//
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
//
iFlag=myContext->ComputeVE (aV, aE, aT);
if (!iFlag) {
// 1
i=aVEs.Append()-1;
BOPDS_InterfVE& aVE=aVEs(i);
aVE.SetIndices(nV, nE);
aVE.SetParameter(aT);
// 2
myDS->AddInterf(nV, nE);
// 3
BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
Handle(BOPDS_PaveBlock)& aPB=*((Handle_BOPDS_PaveBlock*)&aLPB.First());
//
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
aTolV = BRep_Tool::Tolerance(aV);
aTolE = BRep_Tool::Tolerance(aE);
if ( aTolV < aTolE) {
aBB.UpdateVertex(aV, aTolE);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
}
}
}//for (; myIterator->More(); myIterator->Next()) {
}

View File

@@ -0,0 +1,665 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <Precision.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
//
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
#include <IntTools_SequenceOfRanges.hxx>
//
#include <BOPTools_AlgoTools.hxx>
//
#include <BOPCol_DataMapOfShapeInteger.hxx>
#include <BOPCol_DataMapOfIntegerShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeBox.hxx>
//
#include <BOPInt_Context.hxx>
#include <BOPInt_ShrunkRange.hxx>
#include <BOPInt_Tools.hxx>
//
#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_CoupleOfPaveBlocks.hxx>
#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_VectorOfInterfEE.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_Pave.hxx>
#include <BOPDS_BoxBndTree.hxx>
#include <BOPAlgo_Tools.hxx>
//=======================================================================
// function: PerformEE
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformEE()
{
Standard_Boolean bJustAdd, bOrder;
Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize;
Standard_Integer aNbCPrts, nWhat, nWith;
Standard_Real aTS11, aTS12, aTS21, aTS22;
Standard_Real aTolE1, aTolE2, aDeflection;
TopAbs_ShapeEnum aType;
TopoDS_Edge aEWhat, aEWith;
BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2;
Handle(NCollection_IncAllocator) aAllocator;
//
myErrorStatus=0;
//
myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
iSize=myIterator->ExpectedLength();
if (!iSize) {
return;
}
//
//-----------------------------------------------------scope f
aAllocator=new NCollection_IncAllocator();
BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator);
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
//
aDiscretize=30;
aDeflection=0.01;
//
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
aEEs.SetStartSize(iSize);
aEEs.SetIncrement(iSize);
aEEs.Init();
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nE1, nE2, bJustAdd);
if(bJustAdd) {
continue;
}
//
const BOPDS_ShapeInfo& aSIE1=myDS->ShapeInfo(nE1);
if (aSIE1.HasFlag()){
continue;
}
const BOPDS_ShapeInfo& aSIE2=myDS->ShapeInfo(nE2);
if (aSIE2.HasFlag()){
continue;
}
//
const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aSIE1.Shape()));
const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aSIE2.Shape()));
//
aTolE1=BRep_Tool::Tolerance(aE1);
aTolE2=BRep_Tool::Tolerance(aE2);
//
BOPDS_ListOfPaveBlock& aLPB1=myDS->ChangePaveBlocks(nE1);
BOPDS_ListOfPaveBlock& aLPB2=myDS->ChangePaveBlocks(nE2);
//
aIt1.Initialize(aLPB1);
for (; aIt1.More(); aIt1.Next()) {
Bnd_Box aBB1;
//
Handle(BOPDS_PaveBlock)& aPB1=aIt1.ChangeValue();
if (!aPB1->HasShrunkData()) {
FillShrunkData(aPB1);
if (myWarningStatus) {
continue;
}
}
aPB1->ShrunkData(aTS11, aTS12, aBB1);
//
aIt2.Initialize(aLPB2);
for (; aIt2.More(); aIt2.Next()) {
Bnd_Box aBB2;
//
Handle(BOPDS_PaveBlock)& aPB2=aIt2.ChangeValue();
if (!aPB2->HasShrunkData()) {
FillShrunkData(aPB2);
if (myWarningStatus) {
continue;
}
}
aPB2->ShrunkData(aTS21, aTS22, aBB2);
//
if (aBB1.IsOut(aBB2)) {
continue;
}
//
// -----------f
//DEBft
//printf(" nE1=%d nE2=%d\n", nE1, nE2);
//
IntTools_EdgeEdge aEdgeEdge;
//
aEdgeEdge.SetEdge1 (aE1);
aEdgeEdge.SetEdge2 (aE2);
aEdgeEdge.SetTolerance1 (aTolE1);
aEdgeEdge.SetTolerance2 (aTolE2);
aEdgeEdge.SetDiscretize (aDiscretize);
aEdgeEdge.SetDeflection (aDeflection);
//
IntTools_Range aSR1(aTS11, aTS12);
IntTools_Range aSR2(aTS21, aTS22);
IntTools_Range anewSR1 = aSR1;
IntTools_Range anewSR2 = aSR2;
//
BOPTools_AlgoTools::CorrectRange (aE1, aE2, aSR1, anewSR1);
BOPTools_AlgoTools::CorrectRange (aE2, aE1, aSR2, anewSR2);
//
aEdgeEdge.SetRange1(anewSR1);
aEdgeEdge.SetRange2(anewSR2);
//
aEdgeEdge.Perform();
if (!aEdgeEdge.IsDone()) {
continue;
}
//
bOrder=aEdgeEdge.Order();
if (!bOrder) {
aEWhat=aE1;
aEWith=aE2;
nWhat=nE1;
nWith=nE2;
}
else {
nWhat=nE2;
nWith=nE1;
aEWhat=aE2;
aEWith=aE1;
}
//
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeEdge.CommonParts();
//
aNbCPrts=aCPrts.Length();
for (i=1; i<=aNbCPrts; ++i) {
const IntTools_CommonPrt& aCPart=aCPrts(i);
aType=aCPart.Type();
switch (aType) {
case TopAbs_VERTEX: {
Standard_Boolean bIsOnPave1, bIsOnPave2;
Standard_Real aT1, aT2, aTol;
IntTools_Range aR1, aR2;
TopoDS_Vertex aVnew;
//
BOPInt_Tools::VertexParameters(aCPart, aT1, aT2);
aTol=Precision::Confusion();
//
//decide to keep the pave or not
aR1 = (bOrder) ? anewSR2 : anewSR1;
aR2 = (bOrder) ? anewSR1 : anewSR2;
//
bIsOnPave1=BOPInt_Tools::IsOnPave(aT1, aR1, aTol);
bIsOnPave2=BOPInt_Tools::IsOnPave(aT2, aR2, aTol);
//
if(bIsOnPave1 || bIsOnPave2) {
continue;
}
//
BOPTools_AlgoTools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aVnew);
// <-LXBR
{
Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound;
Standard_Real aTolVx, aTolVnew, aD2, aDT2;
BOPCol_MapOfInteger aMV;
gp_Pnt aPnew, aPx;
//
iFound=0;
j=-1;
nV11=aPB1->Pave1().Index();
nV12=aPB1->Pave2().Index();
nV21=aPB2->Pave1().Index();
nV22=aPB2->Pave2().Index();
aMV.Add(nV11);
aMV.Add(nV12);
//
if (aMV.Contains(nV21)) {
++j;
nVS[j]=nV21;
}
if (aMV.Contains(nV22)) {
++j;
nVS[j]=nV22;
}
//
aTolVnew=BRep_Tool::Tolerance(aVnew);
aPnew=BRep_Tool::Pnt(aVnew);
//
for (k=0; k<=j; ++k) {
const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k]));
aTolVx=BRep_Tool::Tolerance(aVx);
aPx=BRep_Tool::Pnt(aVx);
aD2=aPnew.SquareDistance(aPx);
//
aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
//
if (aD2<aDT2) {
iFound=1;
break;
}
}
//
if (iFound) {
continue;
}
}
// 1
iX=aEEs.Append()-1;
BOPDS_InterfEE& aEE=aEEs(iX);
aEE.SetIndices(nWhat, nWith);
aEE.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nWhat, nWith);
//
BOPDS_CoupleOfPaveBlocks aCPB;
//
aCPB.SetPaveBlocks(aPB1, aPB2);
aCPB.SetIndexInterf(iX);
aMVCPB.Add(aVnew, aCPB);
}//case TopAbs_VERTEX:
break;
//
case TopAbs_EDGE: {
Standard_Boolean bHasSameBounds;
Standard_Integer aNbComPrt2;
//
aNbComPrt2=aCPart.Ranges2().Length();
if (aNbComPrt2>1){
break;
}
//// <-LXBR
bHasSameBounds=aPB1->HasSameBounds(aPB2);
if (!bHasSameBounds) {
break;
}
// 1
iX=aEEs.Append()-1;
BOPDS_InterfEE& aEE=aEEs(iX);
aEE.SetIndices(nWhat, nWith);
aEE.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nWhat, nWith);
//
BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
}//case TopAbs_EDGE
break;
default:
break;
}//switch (aType) {
}//for (i=1; i<=aNbCPrts; i++) {
// -----------t
//
}// for (; aIt2.More(); aIt2.Next()) {
}// for (; aIt1.More(); aIt1.Next()) {
}
//
//=========================================
// post treatment
//=========================================
BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, aAllocator);
PerformVerticesEE(aMVCPB, aAllocator);
//-----------------------------------------------------scope t
aMPBLPB.Clear();
aMVCPB.Clear();
aAllocator.Nullify();
}
//=======================================================================
//function : PerformVertices
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbV, iRet;
//
iRet=0;
aNbV=theMVCPB.Extent();
if (!aNbV) {
return iRet;
}
//
Standard_Integer nVx, iV, j, nE, iFlag, iX, i, aNb;
Standard_Real aT;
TopoDS_Shape aV;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPDS_ShapeInfo aSI;
BOPDS_Pave aPave;
//
BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator);
BOPCol_ListOfShape aLS(theAllocator);
BOPCol_IndexedDataMapOfShapeInteger aMVI(100, theAllocator);
BOPCol_IndexedDataMapOfShapeListOfShape aImages;
//
aSI.SetShapeType(TopAbs_VERTEX);
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
//
// 1 prepare arguments
//
// <- DEB
for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aS=theMVCPB.FindKey(i);
const BOPDS_CoupleOfPaveBlocks& aCPB=theMVCPB.FindFromIndex(i);
iV=aCPB.IndexInterf();
aMVI.Add(aS, iV);
}
//
// 2 Fuse vertices
TreatNewVertices(aMVI, aImages);
//
// 3 Add new vertices to myDS;
// connect indices to CPB structure
aNb = aImages.Extent();
for (i=1; i<=aNb; ++i) {
const TopoDS_Vertex& aV=(*(TopoDS_Vertex*)(&aImages.FindKey(i)));
const BOPCol_ListOfShape& aLVSD=aImages.FindFromIndex(i);
//
aSI.SetShape(aV);
iV=myDS->Append(aSI);
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBox);
//
aItLS.Initialize(aLVSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aVx = aItLS.Value();
BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx);
aCPB.SetIndex(iV);
// update EE interference
iX=aCPB.IndexInterf();
BOPDS_InterfEE& aEE=aEEs(iX);
aEE.SetIndexNew(iV);
}
}
//
// 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI
{
Handle(BOPDS_PaveBlock) aPB[2];
//
for (i=1; i<=aNbV; ++i) {
const BOPDS_CoupleOfPaveBlocks& aCPB=theMVCPB.FindFromIndex(i);
iV=aCPB.Index();
aCPB.PaveBlocks(aPB[0], aPB[1]);
for (j=0; j<2; ++j) {
if (aMPBLI.Contains(aPB[j])) {
BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB[j]);
aLI.Append(iV);
}
else {
BOPCol_ListOfInteger aLI(theAllocator);
aLI.Append(iV);
aMPBLI.Add(aPB[j], aLI);
}
}
}
}
//
// 5
// 5.1 Compute Extra Paves and
// 5.2. Add Extra Paves to the PaveBlocks
aNb=aMPBLI.Extent();
for(i=1; i<=aNb; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nE=aPB->OriginalEdge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
// 1,2
const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i);
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nVx=aItLI.Value();
const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
//
iFlag=myContext->ComputeVE (aVx, aE, aT);
if (!iFlag) {
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
}
}
}
// 6 Split PaveBlocksa
aNb=aMPBLI.Extent();
for(i=1; i<=aNb; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nE=aPB->OriginalEdge();
// 3
if (!aPB->IsCommonBlock()) {
myDS->UpdatePaveBlock(aPB);
}
else {
const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
myDS->UpdateCommonBlock(aCB);
}
}//for (; aItMPBLI.More(); aItMPBLI.Next()) {
//
return iRet;
}
//=======================================================================
//function : TreatNewVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::TreatNewVertices(
const BOPCol_IndexedDataMapOfShapeInteger& aMapVI,
BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
{
Standard_Integer j, i, aNbV, aNbVSD;
Standard_Real aTol;
TopoDS_Shape aVF;
TopoDS_Vertex aVnew;
BOPCol_IndexedMapOfShape aMVProcessed;
BOPCol_ListIteratorOfListOfInteger aIt;
BOPCol_IndexedDataMapOfShapeListOfShape aMVLV;
BOPCol_DataMapOfIntegerShape aMIS;
BOPCol_IndexedDataMapOfShapeBox aMSB;
//
BOPDS_BoxBndTreeSelector aSelector;
BOPDS_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
aNbV = aMapVI.Extent();
for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMapVI.FindKey(i);
Bnd_Box aBox;
//
aTol=BRep_Tool::Tolerance(*(TopoDS_Vertex*)(&aV));
aBox.SetGap(aTol);
BRepBndLib::Add(aV, aBox);
//
aTreeFiller.Add(i, aBox);
//
aMIS.Bind(i, aV);
aMSB.Add(aV, aBox);
}
//
aTreeFiller.Fill();
// Chains
for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMapVI.FindKey(i);
//
if (aMVProcessed.Contains(aV)) {
continue;
}
//
Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
BOPCol_ListOfShape aLVSD;
BOPCol_MapOfInteger aMIP, aMIP1, aMIPC;
BOPCol_MapIteratorOfMapOfInteger aIt1;
//
aMIP.Add(i);
while(1) {
aNbIP=aMIP.Extent();
aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key();
if (aMIPC.Contains(aIP)) {
continue;
}
//
const TopoDS_Shape& aVP=aMIS.Find(aIP);
const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
//
aSelector.Clear();
aSelector.SetBox(aBoxVP);
//
aNbVSD=aBBTree.Select(aSelector);
if (!aNbVSD) {
continue; // it must not be
}
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) {
aIP1=aIt.Value();
if (aMIP.Contains(aIP1)) {
continue;
}
aMIP1.Add(aIP1);
} //for (; aIt.More(); aIt.Next()) {
}//for(; aIt1.More(); aIt1.Next()) {
//
aNbIP1=aMIP1.Extent();
if (!aNbIP1) {
break; // from while(1)
}
//
aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key();
aMIPC.Add(aIP);
}
//
aMIP.Clear();
aIt1.Initialize(aMIP1);
for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key();
aMIP.Add(aIP);
}
aMIP1.Clear();
}// while(1)
//...
aNbIP=aMIPC.Extent();
if (!aNbIP) {
aMIPC.Add(i);
}
//
aIt1.Initialize(aMIPC);
for(j=0; aIt1.More(); aIt1.Next(), ++j) {
aIP=aIt1.Key();
const TopoDS_Shape& aVP=aMIS.Find(aIP);
if (!j) {
aVF=aVP;
}
aLVSD.Append(aVP);
aMVProcessed.Add(aVP);
}
aMVLV.Add(aVF, aLVSD);
}// for (i=1; i<=aNbV; ++i) {
// Make new vertices
aNbV=aMVLV.Extent();
for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMVLV.FindKey(i);
BOPCol_ListOfShape& aLVSD=aMVLV.ChangeFromIndex(i);
aNbVSD=aLVSD.Extent();
if (aNbVSD>1) {
BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
myImages.Add(aVnew, aLVSD);
} else {
myImages.Add(aV, aLVSD);
}
}
}
//=======================================================================
//function : FillShrunkData
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
{
Standard_Integer nE, nV1, nV2, iErr;
Standard_Real aT1, aT2, aTS1, aTS2;
BOPInt_ShrunkRange aSR;
//
myErrorStatus=0;
myWarningStatus = 0;
//
const BOPDS_Pave& aPave1=thePB->Pave1();
nV1=aPave1.Index();
aT1=aPave1.Parameter();
const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
//
const BOPDS_Pave& aPave2=thePB->Pave2();
nV2=aPave2.Index();
aT2=aPave2.Parameter();
const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
//
nE=thePB->OriginalEdge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
aSR.SetData(aE, aT1, aT2, aV1, aV2, myContext);
//
aSR.Perform();
iErr=aSR.ErrorStatus();
if (iErr) {
myWarningStatus = 1;
//myErrorStatus=40;
return;
}
//
aSR.ShrunkRange(aTS1, aTS2);
const Bnd_Box& aBox=aSR.BndBox();
//
thePB->SetShrunkData(aTS1, aTS2, aBox);
}
/*
// DEBf
{
TopoDS_Compound aCx;
BRep_Builder aBBx;
aBBx.MakeCompound(aCx);
aItMVCPB.Initialize(theMVCPB);
for (; aItMVCPB.More(); aItMVCPB.Next()) {
const TopoDS_Shape& aS=aItMVCPB.Key();
aBBx.Add(aCx, aS);
}
BRepTools::Write(aCx, "cx");
}
// DEBt
*/

View File

@@ -0,0 +1,212 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <NCollection_IncAllocator.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBndLib.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_SubIterator.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPCol_MapOfInteger.hxx>
//=======================================================================
// function: PerformVF
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformVF()
{
Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, i;
Standard_Real aT1, aT2, aTolF, aTolV;
BRep_Builder aBB;
//
myErrorStatus=0;
//
myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
iSize=myIterator->ExpectedLength();
if (iSize) {
//
BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
aVFs.SetStartSize(iSize);
aVFs.SetIncrement(iSize);
aVFs.Init();
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nV, nF, bJustAdd);
if(bJustAdd) {
continue;
}
//
if (myDS->IsSubShape(nV, nF)) {
continue;
}
//
if (myDS->HasInterfShapeSubShapes(nV, nF)) {
continue;
}
//
nVx=nV;
if (myDS->HasShapeSD(nV, nVSD)) {
nVx=nVSD;
}
//
if (myDS->HasInterf(nVx, nF)) {
continue;
}
//
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
//
aTolV = BRep_Tool::Tolerance(aV);
aTolF = BRep_Tool::Tolerance(aF);
//
iFlag=myContext->ComputeVF(aV, aF, aT1, aT2);
if (!iFlag) {
// 1
i=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(i);
aVF.SetIndices(nVx, nF);
aVF.SetUV(aT1, aT2);
// 2
myDS->AddInterf(nVx, nF);
if (aTolV < aTolF) {
aBB.UpdateVertex(aV, aTolF);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aV, aBoxV);
}
}
}// for (; myIterator->More(); myIterator->Next()) {
}// if (iSize) {
else {
iSize=10;
BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
aVFs.SetStartSize(iSize);
aVFs.SetIncrement(iSize);
aVFs.Init();
}
//
TreatVerticesEE();
}
//=======================================================================
//function : TreatVerticesEE
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::TreatVerticesEE()
{
Standard_Integer i, aNbS, aNbEEs, nF, nV, iFlag;
Standard_Real aT1, aT2;
BOPCol_ListIteratorOfListOfInteger aItLI;
Handle(NCollection_IncAllocator) aAllocator;
//
//-----------------------------------------------------scope_1 f
aAllocator=new NCollection_IncAllocator();
BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator);
BOPCol_MapOfInteger aMI(100, aAllocator);
BOPDS_MapOfPaveBlock aMPBF(100, aAllocator);
//
myErrorStatus=0;
//
aNbS=myDS->NbSourceShapes();
//
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
aNbEEs=aEEs.Extent();
for (i=0; i<aNbEEs; ++i) {
BOPDS_InterfEE& aEE=aEEs(i);
if (aEE.HasIndexNew()) {
nV=aEE.IndexNew();
if (aMI.Add(nV)) {
aLIV.Append(nV);
}
}
}
if (!aLIV.Extent()) {
aAllocator.Nullify();
return;
}
//
aNbS=myDS->NbSourceShapes();
for (nF=0; nF<aNbS; ++nF) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(nF);
if (aSI.ShapeType()==TopAbs_FACE) {
aLIF.Append(nF);
}
}
if (!aLIF.Extent()) {
aAllocator.Nullify();
return;
}
//-------------------------------------------------------------
BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
//
BOPDS_SubIterator aIt(aAllocator);
//
aIt.SetDS(myDS);
aIt.SetSubSet1(aLIF);
aIt.SetSubSet2(aLIV);
aIt.Prepare();
aIt.Initialize();
for (; aIt.More(); aIt.Next()) {
aIt.Value(nV, nF);
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn();
//
if (!aMVOn.Contains(nV)) {
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
iFlag=myContext->ComputeVF(aV, aF, aT1, aT2);
if (!iFlag) {
// 1
i=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(i);
aVF.SetIndices(nV, nF);
aVF.SetUV(aT1, aT2);
// 2
myDS->AddInterf(nV, nF);
//
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
aMVIn.Add(nV);
}
}
}
//
aAllocator.Nullify();
//-----------------------------------------------------scope_1 t
}

View File

@@ -0,0 +1,509 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <NCollection_IncAllocator.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <IntTools_EdgeFace.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPInt_Context.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_Pave.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPDS_CoupleOfPaveBlocks.hxx>
#include <BRepBndLib.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPInt_Tools.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
//function : PerformEF
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PerformEF()
{
Standard_Integer iSize;
//
myErrorStatus=0;
//
myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
iSize=myIterator->ExpectedLength();
if (!iSize) {
return;
}
//----------------------------------------------------------------------
Standard_Boolean bJustAdd;
Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX;
Standard_Real aTolE, aTolF, aTS1, aTS2, aDeflection;
Handle(NCollection_IncAllocator) aAllocator;
TopAbs_ShapeEnum aType;
BOPDS_ListIteratorOfListOfPaveBlock aIt;
//-----------------------------------------------------scope f
//
BRep_Builder aBB;
//
aAllocator=new NCollection_IncAllocator();
BOPCol_MapOfInteger aMIEFC(100, aAllocator);
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator);
//
aDiscretize=35;
aDeflection=0.01;
//
BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
aEFs.SetStartSize(iSize);
aEFs.SetIncrement(iSize);
aEFs.Init();
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nE, nF, bJustAdd);
if(bJustAdd) {
continue;
}
//
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasFlag()){//degenerated
continue;
}
//
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
const Bnd_Box& aBBF=myDS->ShapeInfo(nF).Box();
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
//
aTolE=BRep_Tool::Tolerance(aE);
aTolF=BRep_Tool::Tolerance(aF);
//
BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
Handle(BOPDS_PaveBlock)& aPB=aIt.ChangeValue();
//
const Handle(BOPDS_PaveBlock)& aPBR=aPB->RealPaveBlock();
if (aMPBF.Contains(aPBR)) {
continue;
}
//
if (!aPB->HasShrunkData()) {
FillShrunkData(aPB);
if (myWarningStatus) {
continue;
}
}
//
Bnd_Box aBBE;
aPB->ShrunkData(aTS1, aTS2, aBBE);
//
if (aBBF.IsOut (aBBE)) {
continue;
}
//
// -----------f
IntTools_EdgeFace aEdgeFace;
//
aEdgeFace.SetEdge (aE);
aEdgeFace.SetFace (aF);
aEdgeFace.SetTolE (aTolE);
aEdgeFace.SetTolF (aTolF);
aEdgeFace.SetDiscretize (aDiscretize);
aEdgeFace.SetDeflection (aDeflection);
aEdgeFace.SetContext(myContext);
//
IntTools_Range aSR(aTS1, aTS2);
IntTools_Range anewSR=aSR;
//
BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR);
aEdgeFace.SetRange (anewSR);
//
aEdgeFace.Perform();
if (!aEdgeFace.IsDone()) {
continue;
}
//
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts();
aNbCPrts=aCPrts.Length();
for (i=1; i<=aNbCPrts; ++i) {
const IntTools_CommonPrt& aCPart=aCPrts(i);
aType=aCPart.Type();
switch (aType) {
case TopAbs_VERTEX: {
Standard_Boolean bIsOnPave1, bIsOnPave2, bV1, bV2;
Standard_Integer nV1, nV2;
Standard_Real aT, aTolToDecide;
TopoDS_Vertex aVnew;
BOPInt_Tools::VertexParameter(aCPart, aT);
BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew);
//
const IntTools_Range& aR=aCPart.Range1();
aTolToDecide=5.e-8;
bIsOnPave1=BOPInt_Tools::IsOnPave1(anewSR.First(), aR, aTolToDecide);
bIsOnPave2=BOPInt_Tools::IsOnPave1(anewSR.Last() , aR, aTolToDecide);
//
aPB->Indices(nV1, nV2);
//
if (bIsOnPave1 && bIsOnPave2) {
bV1=CheckFacePaves(nV1, aMIFOn, aMIFIn);
bV2=CheckFacePaves(nV2, aMIFOn, aMIFIn);
if (bV1 && bV2) {
iX=aEFs.Append()-1;
IntTools_CommonPrt aCP = aCPart;
aCP.SetType(TopAbs_EDGE);
BOPDS_InterfEF& aEF=aEFs(iX);
aEF.SetIndices(nE, nF);
aEF.SetCommonPart(aCP);
myDS->AddInterf(nE, nF);
// 3
BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
break;
}
}
if (bIsOnPave1) {
bV1=CheckFacePaves(nV1, aMIFOn, aMIFIn);
if (bV1) {
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV1);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
continue;
}
bIsOnPave1=!bIsOnPave1;
}
//
if (bIsOnPave2) {
bV2=CheckFacePaves(nV2, aMIFOn, aMIFIn);
if (bV2) {
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV2);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
continue;
}
bIsOnPave2=!bIsOnPave2;
}
//
if (!bIsOnPave1 && !bIsOnPave2) {
if (CheckFacePaves(aVnew, aMIFOn)) {
continue;
}
aBB.UpdateVertex(aVnew, aTolE);
//
aMIEFC.Add(nF);
// 1
iX=aEFs.Append()-1;
BOPDS_InterfEF& aEF=aEFs(iX);
aEF.SetIndices(nE, nF);
aEF.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nE, nF);
// 3
BOPDS_CoupleOfPaveBlocks aCPB;
//
aCPB.SetPaveBlocks(aPB, aPB);
aCPB.SetIndexInterf(iX);
aMVCPB.Add(aVnew, aCPB);
}
}
break;
case TopAbs_EDGE: {
aMIEFC.Add(nF);
//
// 1
iX=aEFs.Append()-1;
BOPDS_InterfEF& aEF=aEFs(iX);
aEF.SetIndices(nE, nF);
//
Standard_Boolean aCoinsideFlag;
aCoinsideFlag=BOPTools_AlgoTools::IsBlockInOnFace(anewSR, aF, aE, myContext);
if (!aCoinsideFlag) {
myDS->AddInterf(nE, nF);
break;
}
//update tolerance of edge if needed
if (aTolE < aTolF) {
myDS->UpdateEdgeTolerance(nE, aTolF);
aTolE = aTolF;
}
aEF.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nE, nF);
// 3
BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
}
break;
default:
break;
}//switch (aType) {
}//for (i=1; i<=aNbCPrts; ++i) {
// -----------t
}//for (; aIt.More(); aIt.Next()) {
}//for (; myIterator->More(); myIterator->Next()) {
//
//=========================================
// post treatment
//=========================================
BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator);
PerformVerticesEF(aMVCPB, aAllocator);
//
// Update FaceInfoIn for all faces having EF common parts
BOPCol_MapIteratorOfMapOfInteger aItMI;
aItMI.Initialize(aMIEFC);
for (; aItMI.More(); aItMI.Next()) {
nF=aItMI.Value();
myDS->UpdateFaceInfoIn(nF);
}
// Refine FaceInfoOn to remove all formal pave blocks
// made during EF processing
//myDS->RefineFaceInfoOn();
//-----------------------------------------------------scope t
aMIEFC.Clear();
aMVCPB.Clear();
aMPBLI.Clear();
aAllocator.Nullify();
//
}
//=======================================================================
//function : PerformVertices1
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbV, iRet;
//
iRet=0;
aNbV=theMVCPB.Extent();
if (!aNbV) {
return iRet;
}
//
Standard_Integer nVx, nVSD, iV, iErr, nE, iFlag, iX, i, aNbPBLI;
Standard_Real aT;
TopoDS_Shape aV;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPDS_PDS aPDS;
BOPDS_ShapeInfo aSI;
BOPDS_Pave aPave;
//
BOPCol_ListOfShape aLS(theAllocator);
BOPCol_DataMapOfShapeInteger aMVI(100, theAllocator);
BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator);
BOPAlgo_PaveFiller aPF(theAllocator);
//
aSI.SetShapeType(TopAbs_VERTEX);
BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
//
// 1 prepare arguments
for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aS=theMVCPB.FindKey(i);
aLS.Append(aS);
}
//
// 2 Fuse vertices
aPF.SetArguments(aLS);
aPF.Perform();
iErr=aPF.ErrorStatus();
if (iErr) {
iRet=1;
return iRet;
}
aPDS=aPF.PDS();
//
// 3 Add new vertices to theDS;
// 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aVx=aItLS.Value();
nVx=aPDS->Index(aVx);
//
if (aPDS->HasShapeSD(nVx, nVSD)) {
aV=aPDS->Shape(nVSD);
}
else {
aV=aVx;
}
// index of new vertex in theDS -> iV
if (!aMVI.IsBound(aV)) {
aSI.SetShape(aV);
iV=myDS->Append(aSI);
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBox);
//
aMVI.Bind(aV, iV);
}
else {
iV=aMVI.Find(aV);
}
//
BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx);
aCPB.SetIndex(iV);
// update EF interference
iX=aCPB.IndexInterf();
BOPDS_InterfEF& aEF=aEFs(iX);
aEF.SetIndexNew(iV);
// map aMPBLI
const Handle(BOPDS_PaveBlock)& aPB=aCPB.PaveBlock1();
if (aMPBLI.Contains(aPB)) {
BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB);
aLI.Append(iV);
}
else {
BOPCol_ListOfInteger aLI(theAllocator);
aLI.Append(iV);
aMPBLI.Add(aPB, aLI);
}
}
//
// 5
// 5.1 Compute Extra Paves and
// 5.2. Add Extra Paves to the PaveBlocks
aNbPBLI=aMPBLI.Extent();
for (i=1; i<=aNbPBLI; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i);
nE=aPB->OriginalEdge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nVx=aItLI.Value();
const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
//
iFlag=myContext->ComputeVE (aVx, aE, aT);
if (!iFlag) {
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
}
}
}
// 6 Split PaveBlocksa
for (i=1; i<=aNbPBLI; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nE=aPB->OriginalEdge();
// 3
if (!aPB->IsCommonBlock()) {
myDS->UpdatePaveBlock(aPB);
}
else {
const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
myDS->UpdateCommonBlock(aCB);
}
}//for (; aItMPBLI.More(); aItMPBLI.Next()) {
//
return iRet;
}
//=======================================================================
// function: CheckFacePaves
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const Standard_Integer nVx,
const BOPCol_MapOfInteger& aMIFOn,
const BOPCol_MapOfInteger& aMIFIn)
{
Standard_Boolean bRet;
Standard_Integer nV;
BOPCol_MapIteratorOfMapOfInteger aIt;
//
bRet=Standard_False;
//
aIt.Initialize(aMIFOn);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
if (nV==nVx) {
bRet=!bRet;
return bRet;
}
}
aIt.Initialize(aMIFIn);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
if (nV==nVx) {
bRet=!bRet;
return bRet;
}
}
//
return bRet;
}
//=======================================================================
// function: CheckFacePaves
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aVnew,
const BOPCol_MapOfInteger& aMIF)
{
Standard_Boolean bRet;
Standard_Integer nV, iFlag;
BOPCol_MapIteratorOfMapOfInteger aIt;
//
bRet=Standard_True;
//
aIt.Initialize(aMIF);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
iFlag=BOPTools_AlgoTools::ComputeVV(aVnew, aV);
if (!iFlag) {
return bRet;
}
}
//
return !bRet;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,345 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <NCollection_IncAllocator.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <BRepBndLib.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopExp.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx>
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_Pave.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_VectorOfCurve.hxx>
#include <BOPDS_VectorOfFaceInfo.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_Curve.hxx>
static void UpdateVertices(const TopoDS_Edge& aE,
const TopoDS_Face& aF);
//=======================================================================
// function: MakeSplitEdges
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::MakeSplitEdges()
{
Standard_Integer aNbPBP;
//
myErrorStatus=0;
//
BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
aNbPBP=aPBP.Extent();
if(!aNbPBP) {
return;
}
//
Standard_Boolean bCB,bV1, bV2;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, nOrE;
Standard_Real aT1, aT2;
TopoDS_Vertex aV1, aV2;
TopoDS_Edge aE, aSp;
Handle(NCollection_IncAllocator) aAllocator;
BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB;
Handle(BOPDS_PaveBlock) aPB, aPBx;
BOPDS_ShapeInfo aSI;
//
aSI.SetShapeType(TopAbs_EDGE);
//-----------------------------------------------------scope f
//
aAllocator=new NCollection_IncAllocator();
//
BOPDS_MapOfPaveBlock aMPB(100,aAllocator);
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aNbPB=aLPB.Extent();
//DEBf
if (aNbPB) {
aPBx=aLPB.First();
nOrE=aPBx->OriginalEdge();
}
//DEBt
if (aNbPB==1) {
aPB=aLPB.First();
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
//
if (!(bV1 || bV2)) {
nE=aPB->OriginalEdge();
aPB->SetEdge(nE);
continue;
}
}
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
bCB=!aCB.IsNull();
if (bCB) {
myDS->SortPaveBlocks(aCB);
aPB=aCB->PaveBlock1();
}
//
if (aMPB.Add(aPB)) {
nE=aPB->OriginalEdge();
//
const BOPDS_Pave& aPave1=aPB->Pave1();
aPave1.Contents(nV1, aT1);
//
const BOPDS_Pave& aPave2=aPB->Pave2();
aPave2.Contents(nV2, aT2);
//
aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
aE.Orientation(TopAbs_FORWARD);
//
aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
aV1.Orientation(TopAbs_FORWARD);
//
aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
aV2.Orientation(TopAbs_REVERSED);
//
BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
//
aSI.SetShape(aSp);
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aSp, aBox);
//
nSp=myDS->Append(aSI);
//
if (bCB) {
aCB->SetEdge(nSp);
}
else {
aPB->SetEdge(nSp);
}
}// if (aMPB.Add(aPB)) {
}// for (; aItPB.More(); aItPB.Next()) {
}// for (i=0; i<aNbPBP; ++i) {
//
//-----------------------------------------------------scope t
aMPB.Clear();
aAllocator.Nullify();
}
//=======================================================================
// function: MakePCurves
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::MakePCurves()
{
Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
TopoDS_Face aF1F, aF2F;
//
myErrorStatus=0;
//
// 1. Process Common Blocks
const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool();
//
aNbFI=aFIP.Extent();
for (i=0; i<aNbFI; ++i) {
const BOPDS_FaceInfo& aFI=aFIP(i);
nF1=aFI.Index();
//
aF1F=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
aF1F.Orientation(TopAbs_FORWARD);
// In
const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
aItMPB.Initialize(aMPBIn);
for(; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F);
}
// On
const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
aItMPB.Initialize(aMPBOn);
for(; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
if (aPB->IsCommonBlockOnEdge()) {
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F);
}
}
}
//
if (!mySectionAttribute.PCurveOnS1() &&
!mySectionAttribute.PCurveOnS2()) {
return;
}
//
// 2. Process section edges
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
aNbFF=aFFs.Extent();
for (i=0; i<aNbFF; ++i) {
const BOPDS_InterfFF& aFF=aFFs(i);
aFF.Indices(nF1, nF2);
//
aF1F=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
aF1F.Orientation(TopAbs_FORWARD);
aF2F=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
aF2F.Orientation(TopAbs_FORWARD);
//
const BOPDS_VectorOfCurve& aVNC=aFF.Curves();
aNbC=aVNC.Extent();
for (k=0; k<aNbC; ++k) {
const BOPDS_Curve& aNC=aVNC(k);
const BOPDS_ListOfPaveBlock& aLPB=aNC.PaveBlocks();
aItLPB.Initialize(aLPB);
for(; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
if (mySectionAttribute.PCurveOnS1()) {
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F);
UpdateVertices(aE, aF1F);
}
//
if (mySectionAttribute.PCurveOnS2()) {
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF2F);
UpdateVertices(aE, aF2F);
}
}
}
}
}
//=======================================================================
// function: RefineFaceInfoOn
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::RefineFaceInfoOn()
{
Standard_Integer aNbPBP;
//
myErrorStatus=0;
//
BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
aNbPBP=aPBP.Extent();
if(!aNbPBP) {
return;
}
//
Standard_Boolean bV1, bV2;
Standard_Integer i, nV1, nV2, aNbPB;
Handle(BOPDS_PaveBlock) aPB;
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aNbPB=aLPB.Extent();
if (aNbPB==1) {
aPB=aLPB.First();
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
//
if (!(bV1 || bV2)) {
if (!aPB->IsCommonBlock()) {
// the PB seems to be untouced
aLPB.Clear();
continue;
}
}//if (!(bV1 || bV2)) {
}//if (aNbPB==1) {
}//for (i=0; i<aNbPBP; ++i) {
myDS->RefineFaceInfoOn();
}
//=======================================================================
//function : UpdateVertices
//purpose : update tolerances of vertices comparing extremities of
// 3d and 2d curves
//=======================================================================
void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF)
{
Standard_Integer j;
Standard_Real aT[2], aUx, aVx, aTolV2, aD2, aD;
gp_Pnt aP3D, aP3Dx;
gp_Pnt2d aP2Dx;
Handle(Geom_Surface) aS;
Handle(Geom_Curve) aC3D;
Handle(Geom2d_Curve) aC2D;
TopoDS_Edge aEf;
TopoDS_Vertex aV[2];
BRep_Builder aBB;
//
aEf=aE;
aEf.Orientation(TopAbs_FORWARD);
//
TopExp::Vertices(aEf, aV[0], aV[1]);
//
aS=BRep_Tool::Surface(aF);
aC3D=BRep_Tool::Curve(aEf, aT[0], aT[1]);
aC2D=BRep_Tool::CurveOnSurface(aEf, aF, aT[0], aT[1]);
//
for (j=0; j<2; ++j) {
aTolV2=BRep_Tool::Tolerance(aV[j]);
aTolV2=aTolV2*aTolV2;
//
aC3D->D0(aT[j], aP3D);
aC2D->D0(aT[j], aP2Dx);
aP2Dx.Coord(aUx, aVx);
aS->D0(aUx, aVx, aP3Dx);
aD2=aP3D.SquareDistance(aP3Dx);
if (aD2>aTolV2) {
aD=sqrt(aD2);
aBB.UpdateVertex(aV[j], aD);
}
}
}

View File

@@ -0,0 +1,375 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_PaveFiller.ixx>
#include <Precision.hxx>
#include <NCollection_IncAllocator.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Lin2d.hxx>
#include <ElCLib.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BOPCol_ListOfInteger.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_Pave.hxx>
static
void MakeSplitEdge1 (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const TopoDS_Vertex& aV1,
const Standard_Real aP1,
const TopoDS_Vertex& aV2,
const Standard_Real aP2,
TopoDS_Edge& aNewEdge);
//=======================================================================
//function : ProcessDE
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::ProcessDE()
{
Standard_Integer nF, aNb, nE, nV, nVSD, aNbPB;
Handle(NCollection_IncAllocator) aAllocator;
Handle(BOPDS_PaveBlock) aPBD;
BOPCol_ListIteratorOfListOfInteger aItLI;
//
myErrorStatus=0;
//
// 1. Find degnerated edges
//-----------------------------------------------------scope f
//
aAllocator=new NCollection_IncAllocator();
BOPDS_ListOfPaveBlock aLPBOut(aAllocator);
//
aNb=myDS->NbSourceShapes();
for (nE=0; nE<aNb; ++nE) {
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.ShapeType()==TopAbs_EDGE) {
if (aSIE.HasFlag(nF)) {
const BOPDS_ShapeInfo& aSIF=myDS->ShapeInfo(nF);
nV=aSIE.SubShapes().First();
if (myDS->HasShapeSD(nV, nVSD)) {
nV=nVSD;
}
//nV,nE,nF
//
if (aSIF.ShapeType() == TopAbs_FACE) {
// 1. Find PaveBlocks that are go through nV for nF
FindPaveBlocks(nV, nF, aLPBOut);
aNbPB=aLPBOut.Extent();
if (!aNbPB) {
continue;
}
//
// 2.
BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE);
aPBD=aLPBD.First();
//
FillPaves(nV, nE, nF, aLPBOut, aPBD);
//
myDS->UpdatePaveBlock(aPBD);
//
MakeSplitEdge(nE, nF);
//
aLPBOut.Clear();
}
if (aSIF.ShapeType() == TopAbs_EDGE) {
Standard_Real aTol=1.e-7;
Standard_Integer nEn;
BRep_Builder BB;
const TopoDS_Edge& aDE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
const TopoDS_Vertex& aVn = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
//
TopoDS_Edge aE=aDE;
aE.EmptyCopy();
BB.Add(aE, aVn);
BB.Degenerated(aE, Standard_True);
BB.UpdateEdge(aE, aTol);
BOPDS_ShapeInfo aSI;
aSI.SetShapeType(TopAbs_EDGE);
aSI.SetShape(aE);
nEn=myDS->Append(aSI);
BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE);
aPBD=aLPBD.First();
aPBD->SetEdge(nEn);
}
}
}
}
}
//=======================================================================
//function : FindPaveBlocks
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::FindPaveBlocks(const Standard_Integer nV,
const Standard_Integer nF,
BOPDS_ListOfPaveBlock& aLPBOut)
{
Standard_Integer nV1, nV2;
BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
//
const BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
// In
const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
aItMPB.Initialize(aMPBIn);
for(; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
aPB->Indices(nV1, nV2);
if (nV==nV1 || nV==nV2) {
aLPBOut.Append(aPB);
}
}
// On
const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
aItMPB.Initialize(aMPBOn);
for(; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
aPB->Indices(nV1, nV2);
if (nV==nV1 || nV==nV2) {
aLPBOut.Append(aPB);
}
}
// Sections
const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
aItMPB.Initialize(aMPBSc);
for(; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
aPB->Indices(nV1, nV2);
if (nV==nV1 || nV==nV2) {
aLPBOut.Append(aPB);
}
}
}
//=======================================================================
//function : MakeSplitEdge
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::MakeSplitEdge (const Standard_Integer nDE,
const Standard_Integer nDF)
{
Standard_Integer nSp, nV1, nV2, aNbPB;
Standard_Real aT1, aT2;
TopoDS_Edge aDE, aSp;
TopoDS_Vertex aV1, aV2;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPDS_ShapeInfo aSI;
//
aSI.SetShapeType(TopAbs_EDGE);
//
aDE=(*(TopoDS_Edge *)(&myDS->Shape(nDE)));
aDE.Orientation(TopAbs_FORWARD);
//
const TopoDS_Face& aDF=(*(TopoDS_Face *)(&myDS->Shape(nDF)));
//
BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nDE);
aNbPB=aLPB.Extent();
//
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue();
//
const BOPDS_Pave& aPave1=aPB->Pave1();
aPave1.Contents(nV1, aT1);
//
const BOPDS_Pave& aPave2=aPB->Pave2();
aPave2.Contents(nV2, aT2);
//
if (myDS->IsNewShape(nV1) || aNbPB>1) {
aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
aV1.Orientation(TopAbs_FORWARD);
//
aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
aV2.Orientation(TopAbs_REVERSED);
//
MakeSplitEdge1(aDE, aDF, aV1, aT1, aV2, aT2, aSp);
//
aSI.SetShape(aSp);
nSp=myDS->Append(aSI);
aPB->SetEdge(nSp);
}
else {
//aPB->SetEdge(nDE);
aLPB.Clear();
break;
}
}
}
//=======================================================================
//function : FillPaves
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::FillPaves(const Standard_Integer nVD,
const Standard_Integer nED,
const Standard_Integer nFD,
const BOPDS_ListOfPaveBlock& aLPBOut,
const Handle(BOPDS_PaveBlock)& aPBD)
{
Standard_Boolean bXDir, bIsDone, bReject;
Standard_Integer nE, aNbPoints, j;
Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT;
Standard_Real aTolCmp;
gp_Pnt2d aP2d1, aP2d2, aP2D;
gp_Lin2d aLDE;
Handle(Geom2d_Line) aCLDE;
Handle(Geom2d_Curve) aC2DDE1, aC2D;
Handle(Geom2d_TrimmedCurve)aC2DDE;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPDS_Pave aPave;
//
aDT=Precision::PConfusion();
//
aPave.SetIndex(nVD);
//
const TopoDS_Edge& aDE=(*(TopoDS_Edge *)(&myDS->Shape(nED)));
const TopoDS_Face& aDF=(*(TopoDS_Face *)(&myDS->Shape(nFD)));
//aC2DDE
aC2DDE1=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2);
aC2DDE=new Geom2d_TrimmedCurve(aC2DDE1, aTD1, aTD2);
//aCLDE
Handle(Geom2d_TrimmedCurve) aCLDET1=Handle(Geom2d_TrimmedCurve)::DownCast(aC2DDE1);
if (aCLDET1.IsNull()) {
aCLDE=Handle(Geom2d_Line)::DownCast(aC2DDE1);
}
else {
Handle(Geom2d_Curve) aBasisCurve=aCLDET1->BasisCurve();
aCLDE=Handle(Geom2d_Line)::DownCast(aBasisCurve);
}
//
// Choose direction for degenerated edge
aC2DDE->D0(aTD1, aP2d1);
aC2DDE->D0(aTD2, aP2d2);
//
bXDir=Standard_False;
if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){
bXDir=!bXDir;
}
//
aItLPB.Initialize(aLPBOut);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2);
if (aC2D.IsNull()) {
continue;
}
//
// Intersection
Geom2dAdaptor_Curve aGAC1, aGAC2;
aGAC1.Load(aC2DDE, aTD1, aTD2);
//
Handle(Geom2d_Line) aL2D= Handle(Geom2d_Line)::DownCast(aC2D);
if (!aL2D.IsNull()) {
aGAC2.Load(aC2D);
}
else {
aGAC2.Load(aC2D, aT1, aT2);
}
//
aTolInter=0.001;
aTolCmp=1.414213562*aTolInter+aDT;
Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter);
bIsDone=aGInter.IsDone();
if(!bIsDone) {
continue;
}
//
aNbPoints=aGInter.NbPoints();
if (!aNbPoints){
continue;
}
//
for (j=1; j<=aNbPoints; ++j) {
aP2D=aGInter.Point(j).Value();
aX=aGInter.Point(j).ParamOnFirst();
//
if (fabs (aX-aTD1) < aTolCmp || fabs (aX-aTD2) < aTolCmp) {
continue;
}
if (aX < aTD1 || aX > aTD2) {
continue;
}
//
bReject=Standard_False;
if (aPBD->ContainsParameter(aX, aDT)) {
continue;
}
aPave.SetParameter(aX);
aPBD->AppendExtPave1(aPave);
}
}//for (; aItLPB.More(); aItLPB.Next()) {
//
myDS->UpdatePaveBlock(aPBD);
}
//=======================================================================
// function: MakeSplitEdge1
// purpose:
//=======================================================================
void MakeSplitEdge1 (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const TopoDS_Vertex& aV1,
const Standard_Real aP1,
const TopoDS_Vertex& aV2,
const Standard_Real aP2,
TopoDS_Edge& aNewEdge)
{
Standard_Real aTol=1.e-7;
TopoDS_Edge E=aE;
E.EmptyCopy();
BRep_Builder BB;
BB.Add (E, aV1);
BB.Add (E, aV2);
BB.Range(E, aF, aP1, aP2);
BB.Degenerated(E, Standard_True);
BB.UpdateEdge(E, aTol);
aNewEdge=E;
}

View File

@@ -0,0 +1,76 @@
-- Created on: 2002-03-04
-- Created by: Michael KLOKOV
-- Copyright (c) 2002-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.
class SectionAttribute from BOPAlgo
---Purpose: Class is a container of three flags used
--- by intersection algorithm
---
is
Create(Aproximation : Boolean from Standard = Standard_True;
PCurveOnS1 : Boolean from Standard = Standard_True;
PCurveOnS2 : Boolean from Standard = Standard_True)
returns SectionAttribute from BOPAlgo;
---Purpose:
--- Initializes me by flags
Approximation(me: in out; theFlag: Boolean from Standard);
---Purpose:
--- Modifier
---
PCurveOnS1(me: in out; theFlag: Boolean from Standard);
---Purpose:
--- Modifier
---
PCurveOnS2(me: in out; theFlag: Boolean from Standard);
---Purpose:
--- Modifier
---
Approximation(me)
returns Boolean from Standard;
---C++: inline
---Purpose:
--- Selector
---
PCurveOnS1(me)
returns Boolean from Standard;
---C++: inline
---Purpose:
--- Selector
---
PCurveOnS2(me)
returns Boolean from Standard;
---C++: inline
---Purpose:
--- Selector
---
fields
myApproximation : Boolean from Standard;
myPCurve1 : Boolean from Standard;
myPCurve2 : Boolean from Standard;
end SectionAttribute from BOPAlgo;

View File

@@ -0,0 +1,59 @@
// Created on: 2002-03-04
// Created by: Michael KLOKOV
// Copyright (c) 2002-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 <BOPAlgo_SectionAttribute.ixx>
//=======================================================================
// function: BOPAlgo_SectionAttribute
// purpose:
//=======================================================================
BOPAlgo_SectionAttribute::BOPAlgo_SectionAttribute(const Standard_Boolean Aproximation,
const Standard_Boolean PCurveOnS1,
const Standard_Boolean PCurveOnS2)
{
myApproximation = Aproximation;
myPCurve1 = PCurveOnS1;
myPCurve2 = PCurveOnS2;
}
//=======================================================================
// function: Approximation
// purpose:
//=======================================================================
void BOPAlgo_SectionAttribute::Approximation(const Standard_Boolean theFlag)
{
myApproximation = theFlag;
}
//=======================================================================
// function: PCurveOnS1
// purpose:
//=======================================================================
void BOPAlgo_SectionAttribute::PCurveOnS1(const Standard_Boolean theFlag)
{
myPCurve1 = theFlag;
}
//=======================================================================
// function: PCurveOnS2
// purpose:
//=======================================================================
void BOPAlgo_SectionAttribute::PCurveOnS2(const Standard_Boolean theFlag)
{
myPCurve2 = theFlag;
}

View File

@@ -0,0 +1,45 @@
// Created on: 2002-03-04
// Created by: Michael KLOKOV
// Copyright (c) 2002-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.
//=======================================================================
// function:Approximation
// purpose:
//=======================================================================
inline Standard_Boolean BOPAlgo_SectionAttribute::Approximation() const
{
return myApproximation;
}
//=======================================================================
// function:PCurveOnS1
// purpose:
//=======================================================================
inline Standard_Boolean BOPAlgo_SectionAttribute::PCurveOnS1() const
{
return myPCurve1;
}
//=======================================================================
// function:PCurveOnS2
// purpose:
//=======================================================================
inline Standard_Boolean BOPAlgo_SectionAttribute::PCurveOnS2() const
{
return myPCurve2;
}

View File

@@ -0,0 +1,76 @@
-- 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.
class Tools from BOPAlgo
---Purpose:
uses
BaseAllocator from BOPCol,
IndexedDataMapOfIntegerListOfInteger from BOPCol,
DataMapOfIntegerListOfInteger from BOPCol,
PaveBlock from BOPDS,
IndexedDataMapOfPaveBlockListOfInteger from BOPDS,
IndexedDataMapOfPaveBlockListOfPaveBlock from BOPDS,
DataMapOfIntegerListOfPaveBlock from BOPDS
--raises
is
---
--- static methods
---
MakeBlocksCnx(myclass;
theMILI :IndexedDataMapOfIntegerListOfInteger from BOPCol;
theMBlocks :out DataMapOfIntegerListOfInteger from BOPCol;
theAllocator:out BaseAllocator from BOPCol);
MakeBlocks(myclass;
theMILI :IndexedDataMapOfPaveBlockListOfPaveBlock from BOPDS;
theMBlocks :out DataMapOfIntegerListOfPaveBlock from BOPDS;
theAllocator:out BaseAllocator from BOPCol);
PerformCommonBlocks(myclass;
theMBlocks :out IndexedDataMapOfPaveBlockListOfPaveBlock from BOPDS;
theAllocator:out BaseAllocator from BOPCol);
FillMap(myclass;
tneN1:Integer from Standard;
tneN2:Integer from Standard;
theMILI : out IndexedDataMapOfIntegerListOfInteger from BOPCol;
theAllocator: out BaseAllocator from BOPCol);
FillMap(myclass;
tnePB1:PaveBlock from BOPDS;
tnePB2:PaveBlock from BOPDS;
theMILI : out IndexedDataMapOfPaveBlockListOfPaveBlock from BOPDS;
theAllocator: out BaseAllocator from BOPCol);
FillMap(myclass;
tnePB1:PaveBlock from BOPDS;
tneF:Integer from Standard;
theMILI : out IndexedDataMapOfPaveBlockListOfInteger from BOPDS;
theAllocator: out BaseAllocator from BOPCol);
PerformCommonBlocks(myclass;
theMBlocks :IndexedDataMapOfPaveBlockListOfInteger from BOPDS;
theAllocator:out BaseAllocator from BOPCol);
--fields
end Tools;

View File

@@ -0,0 +1,336 @@
// 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 <BOPAlgo_Tools.ixx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_IndexedMapOfPaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
#include <BOPCol_IndexedMapOfInteger.hxx>
//=======================================================================
//function : MakeBlocksCnx
//purpose :
//=======================================================================
void BOPAlgo_Tools::MakeBlocksCnx(const BOPCol_IndexedDataMapOfIntegerListOfInteger& aMILI,
BOPCol_DataMapOfIntegerListOfInteger& aMBlocks,
Handle(NCollection_BaseAllocator)& aAllocator)
{
Standard_Integer aNbV, nV, aNbVS, nVP, nVx, aNbVP, aNbEC, k, i, j;
BOPCol_ListIteratorOfListOfInteger aItLI;
//
BOPCol_MapOfInteger aMVS(100, aAllocator);
BOPCol_IndexedMapOfInteger aMEC(100, aAllocator);
BOPCol_IndexedMapOfInteger aMVP(100, aAllocator);
BOPCol_IndexedMapOfInteger aMVAdd(100, aAllocator);
//
aNbV=aMILI.Extent();
//
for (k=0,i=1; i<=aNbV; ++i) {
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
nV = aMILI.FindKey(i);
if (aMVS.Contains(nV)){
continue;
}
aMVS.Add(nV);
//
aMEC.Clear();
aMVP.Clear();
aMVAdd.Clear();
//
aMVP.Add(nV);
while(1) {
aNbVP=aMVP.Extent();
for (j=1; j<=aNbVP; ++j) {
nVP=aMVP(j);
const BOPCol_ListOfInteger& aLV=aMILI.FindFromKey(nVP);
aItLI.Initialize(aLV);
for (; aItLI.More(); aItLI.Next()) {
nVx=aItLI.Value();
if (aMEC.Contains(nVx)) {
continue;
}
//
aMVS.Add(nVx);
aMEC.Add(nVx);
aMVAdd.Add(nVx);
}
}
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
}
//
aMVP.Clear();
for (j=1; j<=aNbVP; ++j) {
aMVP.Add(aMVAdd(j));
}
aMVAdd.Clear();
}//while(1) {
//
BOPCol_ListOfInteger aLIx(aAllocator);
//
aNbEC = aMEC.Extent();
for (j=1; j<=aNbEC; ++j) {
nVx=aMEC(j);
aLIx.Append(nVx);
}
//
aMBlocks.Bind(k, aLIx);
++k;
}//for (k=0,i=1; i<=aNbV; ++i)
aMVAdd.Clear();
aMVP.Clear();
aMEC.Clear();
aMVS.Clear();
}
//=======================================================================
//function : FillMap
//purpose :
//=======================================================================
void BOPAlgo_Tools::FillMap(const Standard_Integer n1,
const Standard_Integer n2,
BOPCol_IndexedDataMapOfIntegerListOfInteger& aMILI,
Handle(NCollection_BaseAllocator)& aAllocator)
{
if (aMILI.Contains(n1)) {
BOPCol_ListOfInteger& aLI=aMILI.ChangeFromKey(n1);
aLI.Append(n2);
}
else {
BOPCol_ListOfInteger aLI(aAllocator);
aLI.Append(n2);
aMILI.Add(n1, aLI);
}
if (aMILI.Contains(n2)) {
BOPCol_ListOfInteger& aLI=aMILI.ChangeFromKey(n2);
aLI.Append(n1);
}
else {
BOPCol_ListOfInteger aLI(aAllocator);
aLI.Append(n1);
aMILI.Add(n2, aLI);
}
}
//=======================================================================
//function : FillMap
//purpose :
//=======================================================================
void BOPAlgo_Tools::FillMap(const Handle(BOPDS_PaveBlock)& aPB1,
const Handle(BOPDS_PaveBlock)& aPB2,
BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock& aMPBLPB,
Handle(NCollection_BaseAllocator)& aAllocator)
{
if (aMPBLPB.Contains(aPB1)) {
BOPDS_ListOfPaveBlock& aLPB=aMPBLPB.ChangeFromKey(aPB1);
aLPB.Append(aPB2);
}
else {
BOPDS_ListOfPaveBlock aLPB(aAllocator);
aLPB.Append(aPB2);
aMPBLPB.Add(aPB1, aLPB);
}
if (aMPBLPB.Contains(aPB2)) {
BOPDS_ListOfPaveBlock& aLPB=aMPBLPB.ChangeFromKey(aPB2);
aLPB.Append(aPB1);
}
else {
BOPDS_ListOfPaveBlock aLPB(aAllocator);
aLPB.Append(aPB1);
aMPBLPB.Add(aPB2, aLPB);
}
}
//=======================================================================
//function : FillMap
//purpose :
//=======================================================================
void BOPAlgo_Tools::FillMap(const Handle(BOPDS_PaveBlock)& aPB,
const Standard_Integer nF,
BOPDS_IndexedDataMapOfPaveBlockListOfInteger& aMPBLI,
Handle(NCollection_BaseAllocator)& aAllocator)
{
if (aMPBLI.Contains(aPB)) {
BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB);
aLI.Append(nF);
}
else {
BOPCol_ListOfInteger aLI(aAllocator);
aLI.Append(nF);
aMPBLI.Add(aPB, aLI);
}
}
//=======================================================================
//function : MakeBlocks
//purpose :
//=======================================================================
void BOPAlgo_Tools::MakeBlocks(const BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock& aMILI,
BOPDS_DataMapOfIntegerListOfPaveBlock& aMBlocks,
Handle(NCollection_BaseAllocator)& aAllocator)
{
Standard_Integer aNbV, aNbVS, aNbVP, aNbEC, k, i, j;
BOPDS_ListIteratorOfListOfPaveBlock aItLI;
//
BOPDS_MapOfPaveBlock aMVS(100, aAllocator);
BOPDS_IndexedMapOfPaveBlock aMEC(100, aAllocator);
BOPDS_IndexedMapOfPaveBlock aMVP(100, aAllocator);
BOPDS_IndexedMapOfPaveBlock aMVAdd(100, aAllocator);
//
aNbV=aMILI.Extent();
//
for (k=0, i=1; i<=aNbV; ++i) {
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
const Handle(BOPDS_PaveBlock)& nV=aMILI.FindKey(i);
if (aMVS.Contains(nV)){
continue;
}
aMVS.Add(nV);
//
aMEC.Clear();
aMVP.Clear();
aMVAdd.Clear();
//
aMVP.Add(nV);
while(1) {
aNbVP=aMVP.Extent();
for (j=1; j<=aNbVP; ++j) {
const Handle(BOPDS_PaveBlock)& nVP=aMVP(j);
const BOPDS_ListOfPaveBlock& aLV=aMILI.FindFromKey(nVP);
aItLI.Initialize(aLV);
for (; aItLI.More(); aItLI.Next()) {
const Handle(BOPDS_PaveBlock)& nVx=aItLI.Value();
if (aMEC.Contains(nVx)) {
continue;
}
//
aMVS.Add(nVx);
aMEC.Add(nVx);
aMVAdd.Add(nVx);
}
}
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
}
//
aMVP.Clear();
for (j=1; j<=aNbVP; ++j) {
aMVP.Add(aMVAdd(j));
}
aMVAdd.Clear();
}//while(1) {
//
BOPDS_ListOfPaveBlock aLIx(aAllocator);
//
aNbEC = aMEC.Extent();
for (j=1; j<=aNbEC; ++j) {
const Handle(BOPDS_PaveBlock)& nVx=aMEC(j);
aLIx.Append(nVx);
}
//
aMBlocks.Bind(k, aLIx);
++k;
}//for (k=0, i=1; i<=aNbV; ++i)
aMVAdd.Clear();
aMVP.Clear();
aMEC.Clear();
aMVS.Clear();
}
//=======================================================================
//function : PerformCommonBlocks
//purpose :
//=======================================================================
void BOPAlgo_Tools::PerformCommonBlocks(BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock& aMPBLPB,
Handle(NCollection_BaseAllocator)& aAllocator)
{
Standard_Integer aNbCB;
//
aNbCB=aMPBLPB.Extent();
if (!aNbCB) {
return;
}
//
Standard_Integer aNbPB, aNbBlocks, k;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
Handle(BOPDS_CommonBlock) aCB;
BOPDS_DataMapOfIntegerListOfPaveBlock aMBlocks(100, aAllocator);
//
BOPAlgo_Tools::MakeBlocks(aMPBLPB, aMBlocks, aAllocator);
//
aNbBlocks = aMBlocks.Extent();
for (k=0; k<aNbBlocks; ++k) {
const BOPDS_ListOfPaveBlock& aLPB=aMBlocks.Find(k);
aNbPB=aLPB.Extent();
if (aNbPB>1) {
aCB=new BOPDS_CommonBlock;
//
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
aCB->AddPaveBlock(aPBx);
}
//
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
aPBx->SetCommonBlock(aCB);
}
}//if (aNbPB>1) {
}
}
//=======================================================================
//function : PerformCommonBlocks
//purpose :
//=======================================================================
void BOPAlgo_Tools::PerformCommonBlocks(const BOPDS_IndexedDataMapOfPaveBlockListOfInteger& aMPBLI,
Handle(NCollection_BaseAllocator)& )//aAllocator)
{
Standard_Integer nF, i, aNb;
BOPCol_ListIteratorOfListOfInteger aItLI;
Handle(BOPDS_PaveBlock) aPB;
Handle(BOPDS_CommonBlock) aCB;
//
aNb=aMPBLI.Extent();
for (i=1; i<=aNb; ++i) {
aPB=aMPBLI.FindKey(i);
if (aPB->IsCommonBlock()) {
aCB=aPB->CommonBlock();
}
else {
aCB=new BOPDS_CommonBlock;
aCB->AddPaveBlock(aPB);
}
//
const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromKey(aPB);
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nF=aItLI.Value();
aCB->AddFace(nF);
}
aPB->SetCommonBlock(aCB);
}
}

View File

@@ -0,0 +1,80 @@
-- Created by: Peter KURNEV
-- Copyright (c) 2010-2012 OPEN CASCADE SAS
-- Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-- Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-- EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- 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.
class WireEdgeSet from BOPAlgo
---Purpose:
uses
Face from TopoDS,
Shape from TopoDS,
ListOfShape from BOPCol,
BaseAllocator from BOPCol
--raises
is
Create
returns WireEdgeSet from BOPAlgo;
---C++: inline
---C++: alias " virtual ~BOPAlgo_WireEdgeSet();"
Create (theAllocator: BaseAllocator from BOPCol)
returns WireEdgeSet from BOPAlgo;
---C++: inline
Clear(me:out);
---C++: inline
SetFace(me:out;
aF:Face from TopoDS);
---C++: inline
Face(me)
returns Face from TopoDS;
---C++: return const &
---C++: inline
AddStartElement(me:out;
sS: Shape from TopoDS);
---C++: inline
StartElements(me)
returns ListOfShape from BOPCol;
---C++: return const &
---C++: inline
AddShape(me:out;
sS:Shape from TopoDS);
---C++: inline
Shapes(me)
returns ListOfShape from BOPCol;
---C++: return const &
---C++: inline
fields
myFace : Face from TopoDS is protected;
myStartShapes : ListOfShape from BOPCol is protected;
myShapes : ListOfShape from BOPCol is protected;
end WireEdgeSet;

View File

@@ -0,0 +1,22 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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 <BOPAlgo_WireEdgeSet.ixx>

View File

@@ -0,0 +1,103 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2012 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//=======================================================================
//function :
//purpose :
//=======================================================================
inline BOPAlgo_WireEdgeSet::BOPAlgo_WireEdgeSet()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
inline BOPAlgo_WireEdgeSet::BOPAlgo_WireEdgeSet(const Handle(NCollection_BaseAllocator)& theAllocator)
:
myStartShapes(theAllocator),
myShapes(theAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
inline BOPAlgo_WireEdgeSet::~BOPAlgo_WireEdgeSet()
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
inline void BOPAlgo_WireEdgeSet::Clear()
{
myStartShapes.Clear();
myShapes.Clear();
}
//=======================================================================
//function : SetFace
//purpose :
//=======================================================================
inline void BOPAlgo_WireEdgeSet::SetFace(const TopoDS_Face& aF)
{
myFace=aF;
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
inline const TopoDS_Face& BOPAlgo_WireEdgeSet::Face()const
{
return myFace;
}
//=======================================================================
//function : AddStartElement
//purpose :
//=======================================================================
inline void BOPAlgo_WireEdgeSet::AddStartElement(const TopoDS_Shape& aE)
{
myStartShapes.Append(aE);
}
//=======================================================================
//function : StartElements
//purpose :
//=======================================================================
inline const BOPCol_ListOfShape& BOPAlgo_WireEdgeSet::StartElements()const
{
return myStartShapes;
}
//=======================================================================
//function : AddShape
//purpose :
//=======================================================================
inline void BOPAlgo_WireEdgeSet::AddShape(const TopoDS_Shape& aW)
{
myShapes.Append(aW);
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================
inline const BOPCol_ListOfShape& BOPAlgo_WireEdgeSet::Shapes()const
{
return myShapes;
}

View File

@@ -0,0 +1,77 @@
-- 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.
class WireSplitter from BOPAlgo
inherits Algo from BOPAlgo
---Purpose:
uses
Wire from TopoDS,
BaseAllocator from BOPCol,
ListOfShape from BOPCol,
WireEdgeSet from BOPAlgo,
PWireEdgeSet from BOPAlgo,
ConnexityBlock from BOPTools,
ListOfConnexityBlock from BOPTools
--raises
is
Create
returns WireSplitter from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_WireSplitter();"
Create(theAllocator: BaseAllocator from BOPCol)
returns WireSplitter from BOPAlgo;
SetWES(me:out;
theWES: WireEdgeSet from BOPAlgo);
WES(me:out)
returns WireEdgeSet from BOPAlgo;
---C++: return &
Perform(me:out)
is redefined;
MakeWire(myclass;
theLE:out ListOfShape from BOPCol;
theW :out Wire from TopoDS);
---C++: inline
CheckData(me:out)
is redefined protected;
MakeConnexityBlocks(me:out)
is protected;
MakeWires(me:out)
is protected;
SplitBlock(me:out;
theCB:out ConnexityBlock from BOPTools)
is protected;
fields
myWES : PWireEdgeSet from BOPAlgo is protected;
myLCB : ListOfConnexityBlock from BOPTools is protected;
end WireSplitter;

View File

@@ -0,0 +1,287 @@
// 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 <BOPAlgo_WireSplitter.ixx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPTools.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter()
:
BOPAlgo_Algo(),
myWES(NULL),
myLCB(myAllocator)
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::BOPAlgo_WireSplitter(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator),
myWES(NULL),
myLCB(myAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_WireSplitter::~BOPAlgo_WireSplitter()
{
}
//=======================================================================
//function : SetWES
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::SetWES(const BOPAlgo_WireEdgeSet& theWES)
{
myWES=(BOPAlgo_WireEdgeSet*)&theWES;
}
//=======================================================================
//function : WES
//purpose :
//=======================================================================
BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES()
{
return *myWES;
}
//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
void BOPAlgo_WireSplitter::CheckData()
{
myErrorStatus=0;
if (!myWES) {
myErrorStatus=10;
return;
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::Perform()
{
myErrorStatus=0;
//
CheckData();
if (myErrorStatus) {
return;
}
//
MakeConnexityBlocks();
MakeWires();
}
//=======================================================================
//function : MakeWires
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeWires()
{
Standard_Boolean bIsRegular;
TopoDS_Wire aW;
BOPTools_ListIteratorOfListOfConnexityBlock aItCB;
BOPCol_ListIteratorOfListOfShape aIt;
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
BOPCol_ListOfShape& aLE=aCB.ChangeShapes();
BOPAlgo_WireSplitter::MakeWire(aLE, aW);
myWES->AddShape(aW);
}
else {
SplitBlock(aCB);
//
const BOPCol_ListOfShape& aLW=aCB.Loops();
aIt.Initialize(aLW);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aWx=aIt.Value();
myWES->AddShape(aWx);
}
}
}
}
//=======================================================================
//function : MakeConnexityBlocks
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeConnexityBlocks()
{
Standard_Boolean bRegular, bClosed;
Standard_Integer i, j, aNbV, aNbVS, aNbVP, k;
TopoDS_Iterator aItE;
TopoDS_Shape aER;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_MapIteratorOfMapOfShape aItM;
//
BOPCol_IndexedDataMapOfShapeListOfShape aMVE(100, myAllocator);
BOPCol_IndexedMapOfShape aMVP(100, myAllocator);
BOPCol_IndexedMapOfShape aMEC(100, myAllocator);
BOPCol_MapOfShape aMER(100, myAllocator);
BOPCol_MapOfShape aMEP(100, myAllocator);
BOPCol_IndexedMapOfShape aMVAdd(100, myAllocator);
BOPCol_MapOfShape aMVS(100, myAllocator);
//
myLCB.Clear();
//
const BOPCol_ListOfShape& aLSE=myWES->StartElements();
aIt.Initialize(aLSE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEP.Add(aE)) {
BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
else {
aMER.Add(aE);
}
}
//
// 2
aNbV=aMVE.Extent();
for (i=1; i<=aNbV; ++i) {
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
const TopoDS_Shape& aV=aMVE.FindKey(i);
//
if (!aMVS.Add(aV)) {
continue;
}
// aMVS - globally processed vertices
//
//------------------------------------- goal: aMEC
aMEC.Clear(); // aMEC - edges of CB
aMVP.Clear(); // aMVP - vertices to process right now
aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1)
//
aMVP.Add(aV);
//
while(1) {
aNbVP=aMVP.Extent();
for (k=1; k<=aNbVP; ++k) {
const TopoDS_Shape& aVP=aMVP(k);
const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aVP);
aIt.Initialize(aLE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEC.Add(aE)) {
aItE.Initialize(aE);
for (; aItE.More(); aItE.Next()) {
const TopoDS_Shape& aVE=aItE.Value();
if (aMVS.Add(aVE)) {
aMVAdd.Add(aVE);
}
}
}
}
}//for (; aItM.More(); aItM.Next()) {
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
}
//
aMVP.Clear();
//
for (k=1; k<=aNbVP; ++k) {
const TopoDS_Shape& aVE=aMVAdd(k);
aMVP.Add(aVE);
}
aMVAdd.Clear();
}// while(1) {
//-------------------------------------
BOPTools_ConnexityBlock aCB(myAllocator);
BOPCol_ListOfShape& aLEC=aCB.ChangeShapes();
BOPCol_IndexedDataMapOfShapeListOfShape aMVER(100, myAllocator);
//
bRegular=Standard_True;
Standard_Integer aNbCB = aMEC.Extent();
for (j = 1; j <= aNbCB; j++) {
aER = aMEC(j);
//
if (aMER.Contains(aER)) {
aER.Orientation(TopAbs_FORWARD);
aLEC.Append(aER);
aER.Orientation(TopAbs_REVERSED);
aLEC.Append(aER);
bRegular=Standard_False;
}
else {
aLEC.Append(aER);
}
//
if (bRegular) {
BOPTools::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
}
}
//
if (bRegular) {
Standard_Integer k, aNbVR, aNbER;
//
aNbVR=aMVER.Extent();
for (k=1; k<=aNbVR; ++k) {
const BOPCol_ListOfShape& aLER=aMVER(k);
aNbER=aLER.Extent();
if (aNbER==1) {
const TopoDS_Edge& aEx=TopoDS::Edge(aER);
bClosed=BRep_Tool::IsClosed(aEx, myWES->Face());
if (!bClosed) {
bRegular=!bRegular;
break;
}
}
if (aNbER>2) {
bRegular=!bRegular;
break;
}
}
}
//
aCB.SetRegular(bRegular);
myLCB.Append(aCB);
}
}

View File

@@ -0,0 +1,105 @@
// 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 <BRep_Builder.hxx>
#include <TopoDS_Edge.hxx>
//=======================================================================
//function : BOPAlgo_EdgeInfo
//purpose :
//=======================================================================
class BOPAlgo_EdgeInfo {
public:
//
BOPAlgo_EdgeInfo() :
myPassed(Standard_False),
myInFlag(Standard_False),
myAngle (-1.) {
};
//
void SetEdge(const TopoDS_Edge& theE) {
myEdge=theE;
};
//
const TopoDS_Edge& Edge() const{
return myEdge;
};
//
void SetPassed(const Standard_Boolean theFlag) {
myPassed=theFlag;
};
//
Standard_Boolean Passed()const {
return myPassed;
};
//
void SetInFlag(const Standard_Boolean theFlag) {
myInFlag=theFlag;
};
//
Standard_Boolean IsIn()const {
return myInFlag;
};
//
void SetAngle(const Standard_Real theAngle) {
myAngle=theAngle;
};
//
Standard_Real Angle()const {
return myAngle;
};
//
protected:
TopoDS_Edge myEdge;
Standard_Boolean myPassed;
Standard_Boolean myInFlag;
Standard_Real myAngle;
};
#include <NCollection_List.hxx>
typedef NCollection_List<BOPAlgo_EdgeInfo> BOPAlgo_ListOfEdgeInfo;
typedef BOPAlgo_ListOfEdgeInfo::Iterator BOPAlgo_ListIteratorOfListOfEdgeInfo;
#define _NCollection_MapHasher
#include <NCollection_IndexedDataMap.hxx>
#include <TopTools_ShapeMapHasher.hxx>
typedef NCollection_IndexedDataMap<TopoDS_Shape, \
BOPAlgo_ListOfEdgeInfo, \
TopTools_ShapeMapHasher> BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo;
#undef _NCollection_MapHasher
//=======================================================================
//function : MakeWire
//purpose :
//=======================================================================
inline void BOPAlgo_WireSplitter::MakeWire(BOPCol_ListOfShape& aLE,
TopoDS_Wire& aWire)
{
BRep_Builder aBB;
aBB.MakeWire(aWire);
//
BOPCol_ListIteratorOfListOfShape aIt(aLE);
for (; aIt.More(); aIt.Next()){
aBB.Add(aWire, aIt.Value());
}
}

File diff suppressed because it is too large Load Diff

15
src/BOPAlgo/FILES Normal file
View File

@@ -0,0 +1,15 @@
BOPAlgo_PaveFiller_1.cxx
BOPAlgo_PaveFiller_2.cxx
BOPAlgo_PaveFiller_3.cxx
BOPAlgo_PaveFiller_4.cxx
BOPAlgo_PaveFiller_5.cxx
BOPAlgo_PaveFiller_6.cxx
BOPAlgo_PaveFiller_7.cxx
BOPAlgo_PaveFiller_8.cxx
BOPAlgo_Builder_1.cxx
BOPAlgo_Builder_2.cxx
BOPAlgo_Builder_3.cxx
BOPAlgo_Builder_4.cxx
BOPAlgo_BOP_1.cxx
BOPAlgo_WireSplitter_1.cxx
BOPAlgo_ListOfCheckResult.hxx