1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

374
src/BOPTools/BOPTools.cdl Executable file
View File

@@ -0,0 +1,374 @@
-- File: BOPTools.cdl
-- Created: Thu Nov 16 16:42:52 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
package BOPTools
---Purpose:
--- Contains main and auxiliary classes to fill the
--- Data Structure (DS) to provide boolean
--- operations between a couple BRep shapes.
---
uses
gp,
Bnd,
TopAbs,
TopoDS,
TopTools,
TCollection,
TColStd,
SortTools,
Geom,
Geom2d,
ProjLib,
BooleanOperations,
BOPTColStd,
IntTools
is
---
--- E n u m e r a t i o n s
---
enumeration IntersectionStatus is
INTERSECTED,
BOUNDINGBOXINTERSECTED,
BOUNDINGBOXOFSUBSHAPESINTERSECTED,
NONINTERSECTED,
UNKNOWN
end IntersectionStatus;
enumeration CheckStatus is
CHKUNKNOWN,
VERTEXVERTEX,
VERTEXEDGE,
VERTEXFACE,
EDGEEDGE,
EDGEEDGECOMBLK,
EDGEFACE,
EDGEFACECOMBLK,
FACEFACE,
BADSHRANKRANGE,
NULLSRANKRANGE
end CheckStatus;
---
--- T h e C l a s s e s
---
--- +==========================+
--- ! Fillers and friends !
--- +==========================+
class PaveFiller;
---Purpose:
--- Class that provides
--- 1. computation of interferences of all types
--- 2. storing the interferences in interferences' pool
--- 3. building new vertices, edges and storing them in the DS
--- 4. preparing the information about PaveBlocks, CommonBlocks
---
class DSFiller;
---Purpose:
--- Class that provides
--- 1. creation of the data structure (DS)
--- 2. creation of the interferences' pool
--- 3. invokation of PaveFiller->Perform() to fill the DS
---
---
class DEProcessor;
---Purpose:
--- Class to compute and store in interferences' pool
--- and DS the following values
--- for degenerated edges
--- 1. Paves/Pave set(s)
--- 2. Split parts
--- 3. States (3D) for split parts
---
class PCurveMaker;
---Purpose:
--- Class to compute p-curves for the edges and theirs
--- split parts
---
class SolidStateFiller;
---Purpose:
--- Class to compute states (3D) for the edges (and theirs
--- split parts), vertices, wires, faces, shells
---
class StateFiller;
---Purpose:
--- Root class for state fillers
---
class WireStateFiller;
---Purpose:
--- Class to compute states (3D) for the edges (and theirs
--- split parts), vertices, wires
---
--- +================================+
--- ! Paves and Blocks of Paves !
--- +================================+
class Pave;
---Purpose:
--- Class for storing info about a vertex on an edge
---
class PaveBlock;
---Purpose:
--- Class for storing info about a couple
--- of neighbouring paves on an edge
---
class PaveSet;
---Purpose:
--- Class for storing/sorting paves that belong to an edge
---
class PaveBlockIterator;
---Purpose:
--- Class providing iterations for PaveSet to
--- have the right order of paves along the edge
---
class ComparePave;
---Purpose:
--- Class providing interface necessary for sorting
--- paves along the edge
---
class CommonBlock;
---Purpose:
--- Class for storing info about a couple
--- of pave blocks that are considered as common
---
class CommonBlockAPI;
---Purpose:
--- Class that provide useful tools to manage with
--- List Of Common Block-s
---
--- +==============+
--- ! Intrferences !
--- +==============+
class ShapeShapeInterference;
---Purpose:
--- Root class for storing an Interference
--- between a couple BRep shapes
---
class VVInterference;
---Purpose:
--- Class for storing an Verex/Vertex
--- interference
---
class VSInterference;
---Purpose:
--- Class for storing an Verex/Face
--- interference
---
class VEInterference;
---Purpose:
--- Class for storing an Verex/Edge
--- interference
---
class EEInterference;
---Purpose:
--- Class for storing an Edge/Edge
--- interference
---
class ESInterference;
---Purpose:
--- Class for storing an Edge/Face
--- interference
---
class SSInterference;
---Purpose:
--- Class for storing an Face/Face
--- interference
---
class Interference;
---Purpose:
--- Class for storing information about an
--- interference
---
class InterferenceLine;
---Purpose:
--- Class for storing information about all
--- interferences for given shape
---
class InterferencePool;
---Purpose:
--- Class for storing information about
--- results of all interferences for all shapes
---
--- +=======+
--- ! Tools !
--- +=======+
class Tools;
class Tools2D;
class Tools3D;
--- +=============+
--- ! Miscellanea !
--- +=============+
class DEInfo;
---Purpose:
--- Class for storing information about
--- a degenerated edge
---
class PointBetween;
---Purpose:
--- Class for storing geometry information about
--- a point between neighbouring paves along
--- an edge
---
class Curve;
---Purpose:
--- Class for storing information about
--- intersection curve and set of paves on it
---
class CoupleOfInteger;
class Checker;
---Purpose:
--- Class that provides the algorithm
--- to check a shape on self-interference.
---
class CheckResult;
---Purpose: provides a container to store faulty
--- sub - shapes in tested shape with type of
--- detected faulty
---
--- P o i n t e r s
---
pointer PInterferencePool to InterferencePool from BOPTools;
pointer PPaveFiller to PaveFiller from BOPTools;
pointer PDSFiller to DSFiller from BOPTools;
pointer PShapeShapeInterference to ShapeShapeInterference from BOPTools;
---
--- I n s t a n t i a t i o n s
---
class ListOfCoupleOfInteger instantiates
List from TCollection (CoupleOfInteger from BOPTools);
class ListOfInterference instantiates
List from TCollection (Interference from BOPTools);
class CArray1OfInterferenceLine instantiates
CArray1 from BOPTColStd(InterferenceLine from BOPTools);
class CArray1OfSSInterference instantiates
CArray1 from BOPTColStd(SSInterference from BOPTools);
class CArray1OfESInterference instantiates
CArray1 from BOPTColStd(ESInterference from BOPTools);
class CArray1OfVSInterference instantiates
CArray1 from BOPTColStd(VSInterference from BOPTools);
class CArray1OfEEInterference instantiates
CArray1 from BOPTColStd(EEInterference from BOPTools);
class CArray1OfVEInterference instantiates
CArray1 from BOPTColStd(VEInterference from BOPTools);
class CArray1OfVVInterference instantiates
CArray1 from BOPTColStd(VVInterference from BOPTools);
class PavePool instantiates
CArray1 from BOPTColStd(PaveSet from BOPTools);
class ListOfPave instantiates
List from TCollection(Pave);
class ListOfCommonBlock instantiates
List from TCollection(CommonBlock from BOPTools);
class ListOfPaveBlock instantiates
List from TCollection(PaveBlock from BOPTools);
class CommonBlockPool instantiates
CArray1 from BOPTColStd (ListOfCommonBlock from BOPTools);
class SplitShapesPool instantiates
CArray1 from BOPTColStd (ListOfPaveBlock from BOPTools);
class Array1OfPave instantiates
Array1 from TCollection (Pave from BOPTools);
class CArray1OfPave instantiates
CArray1 from BOPTColStd (Pave from BOPTools);
class QuickSortPave instantiates
QuickSort from SortTools (Pave from BOPTools,
Array1OfPave from BOPTools,
ComparePave from BOPTools);
class IndexedDataMapOfIntegerState instantiates
IndexedDataMap from TCollection (Integer from Standard,
StateOfShape from BooleanOperations,
MapIntegerHasher from TColStd);
class SequenceOfCurves instantiates
Sequence from TCollection(Curve from BOPTools);
class IndexedDataMapOfShapeWithState instantiates
IndexedDataMap from TCollection (Shape from TopoDS,
StateOfShape from BooleanOperations,
ShapeMapHasher from TopTools);
class ListOfShapeEnum instantiates
List from TCollection(ShapeEnum from TopAbs);
class IndexedDataMapOfIntegerDEInfo instantiates
IndexedDataMap from TCollection (Integer from Standard,
DEInfo from BOPTools,
MapIntegerHasher from TColStd);
class Array2OfIntersectionStatus instantiates
Array2 from TCollection (IntersectionStatus from BOPTools);
class HArray2OfIntersectionStatus instantiates
HArray2 from TCollection (IntersectionStatus from BOPTools,
Array2OfIntersectionStatus from BOPTools);
class ListOfCheckResults instantiates
List from TCollection (CheckResult from BOPTools);
class RoughShapeIntersector;
class IteratorOfCoupleOfShape;
class SSIntersectionAttribute;
--
-- additions
--
class CoupleOfIntegerMapHasher;
class PaveBlockMapHasher;
class IndexedMapOfCoupleOfInteger instantiates
IndexedMap from TCollection(CoupleOfInteger from BOPTools,
CoupleOfIntegerMapHasher from BOPTools);
class IndexedDataMapOfIntegerPaveSet instantiates
IndexedDataMap from TCollection (Integer from Standard,
PaveSet from BOPTools,
MapIntegerHasher from TColStd);
class IMapOfPaveBlock instantiates
IndexedMap from TCollection(PaveBlock from BOPTools,
PaveBlockMapHasher from BOPTools);
class IDMapOfPaveBlockIMapOfPaveBlock instantiates
IndexedDataMap from TCollection (PaveBlock from BOPTools ,
IMapOfPaveBlock from BOPTools,
PaveBlockMapHasher from BOPTools);
class IDMapOfPaveBlockIMapOfInteger instantiates
IndexedDataMap from TCollection (PaveBlock from BOPTools ,
IndexedMapOfInteger from TColStd,
PaveBlockMapHasher from BOPTools);
class SequenceOfPaveBlock instantiates
Sequence from TCollection(PaveBlock from BOPTools);
end BOPTools;

View File

@@ -0,0 +1,52 @@
-- File: BOPTools_CheckResult.cdl
-- Created: Thu Sep 2 16:18:42 2004
-- Author: Oleg FEDYAEV
-- <ofv@opencascade.com>
---Copyright: Open Cascade 2004
class CheckResult from BOPTools
---Purpose: contains information about faulty shapes
-- and faulty types
uses
Shape from TopoDS,
ListOfShape from TopTools,
CheckStatus from BOPTools,
Geometry from Geom
is
Create
returns CheckResult;
---Purpose: empty constructor
AddShape(me: in out; TheShape: Shape from TopoDS);
---Purpose: adds a shape with faulty to a list
GetShapes(me)
returns ListOfShape from TopTools;
---C++: return const &
---Purpose: gets access to faulty shapes in a list const
SetCheckStatus(me:in out; TheStatus: CheckStatus from BOPTools);
---Purpose: sets faulty status for shapes
GetCheckStatus(me)
returns CheckStatus from BOPTools;
---Purpose: gets faulty status for shapes
SetInterferenceGeometry(me: in out; TheGeometry: Geometry from Geom);
---Purpose: sets an attached geometry to faulty shapes if any
GetInterferenceGeometry(me)
returns Geometry from Geom;
---C++: return const &
---Purpose: gets an attached geometry to shapes if any
fields
myStatus : CheckStatus from BOPTools;
myShapes : ListOfShape from TopTools;
myGeometry : Geometry from Geom;
end CheckResult;

View File

@@ -0,0 +1,75 @@
// File: BOPTools_CheckResult.cxx
// Created: 02.09.04 16:26:31
// Author: Oleg FEDYAEV
// Copyright: Open Cascade 2003
#include <BOPTools_CheckResult.ixx>
//=======================================================================
//function : BOPTools_CheckResult()
//purpose :
//=======================================================================
BOPTools_CheckResult::BOPTools_CheckResult() : myStatus(BOPTools_CHKUNKNOWN), myGeometry(0)
{
}
//=======================================================================
//function : AddShape()
//purpose :
//=======================================================================
void BOPTools_CheckResult::AddShape(const TopoDS_Shape & TheShape)
{
myShapes.Append(TheShape);
}
//=======================================================================
//function : GetShapes()
//purpose :
//=======================================================================
const TopTools_ListOfShape & BOPTools_CheckResult::GetShapes() const
{
return myShapes;
}
//=======================================================================
//function : SetCheckStatus()
//purpose :
//=======================================================================
void BOPTools_CheckResult::SetCheckStatus(const BOPTools_CheckStatus TheStatus)
{
myStatus = TheStatus;
}
//=======================================================================
//function : GetCheckStatus()
//purpose :
//=======================================================================
BOPTools_CheckStatus BOPTools_CheckResult::GetCheckStatus() const
{
return myStatus;
}
//=======================================================================
//function : SetGeometry()
//purpose :
//=======================================================================
void BOPTools_CheckResult::SetInterferenceGeometry(const Handle(Geom_Geometry)& TheGeometry)
{
myGeometry = TheGeometry;
}
//=======================================================================
//function : GetGeometry()
//purpose :
//=======================================================================
const Handle(Geom_Geometry)& BOPTools_CheckResult::GetInterferenceGeometry() const
{
return myGeometry;
}

131
src/BOPTools/BOPTools_Checker.cdl Executable file
View File

@@ -0,0 +1,131 @@
-- File: BOPTools_Checker.cdl
-- Created: Mon Aug 5 16:01:03 2002
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2002
class Checker from BOPTools inherits PaveFiller from BOPTools
---Purpose:
-- class that provides the algorithm
-- to check a shape on self-interference.
uses
ListOfCheckResults from BOPTools,
InterferencePool from BOPTools,
Shape from TopoDS,
ShapeEnum from TopAbs,
Geometry from Geom
is
Create
returns Checker from BOPTools;
---Purpose:
--- Empty Contructor
---
Create (aS:Shape from TopoDS)
returns Checker from BOPTools;
---Purpose:
--- Contructs the object using the shape <aS> to check
---
Create (aIP: InterferencePool from BOPTools)
returns Checker from BOPTools;
---Purpose:
--- Contructs the object using the <InterferencePool>
---
Destroy (me:out)
is redefined;
---C++: alias "Standard_EXPORT virtual ~BOPTools_Checker(){Destroy();}"
---Purpose:
--- Destructor
---
SetPerformType(me: in out; StopOnFirstFaulty: Boolean from Standard);
---Purpose: if <StopOnFirstFaulty == Standard_True> the process stops
-- and the exception throws; otherwise all faulties are searched
Perform (me:out)
is redefined;
---Purpose:
--- Launches the algorithm
---
SetShape(me:out;
aS:Shape from TopoDS);
---Purpose:
--- Selector
---
Shape(me)
returns Shape from TopoDS;
---C++:return const &
---Purpose:
--- Selector
---
GetCheckResult(me)
returns ListOfCheckResults from BOPTools;
---C++: return const &
---Purpose: returnes a result of check
HasFaulty(me)
returns Boolean from Standard;
---Purpose:
--- Selector.
--- Retrns TRUE if there is interferred sub-shapes .
---
PerformVV (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PerformVE (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PerformVF (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PerformEE (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PerformEF (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PerformFF (me:out)
is redefined protected ;
---Purpose:
--- See in base classe, please
---
PrepareEdges (me:out)
is redefined protected ;
---Purpose:
--- Prepare end paves for each edge
---
PreparePaveBlocks (me:out;
aType1: ShapeEnum from TopAbs;
aType2: ShapeEnum from TopAbs)
is redefined protected ;
---Purpose:
--- Internal usage
---
PreparePaveBlocks (me:out;
anE:Integer from Standard)
is redefined protected ;
---Purpose:
--- Prepare end paves for the edge <anE>
---
fields
myShape : Shape from TopoDS;
myCheckResults : ListOfCheckResults from BOPTools;
myStopOnFirst : Boolean from Standard;
myEntryType : Integer from Standard;
end Checker;

1083
src/BOPTools/BOPTools_Checker.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
-- File: BOPTools_CommonBlock.cdl
-- Created: Thu Feb 15 12:03:13 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class CommonBlock from BOPTools
---Purpose:
-- The class hold a structure for storing info about a couple
-- of pave blocks that are considered as common
uses
PaveBlock from BOPTools
is
Create
returns CommonBlock from BOPTools;
---Purpose:
--- Empty constructor
---
Create (aPB1:PaveBlock from BOPTools;
aPB2:PaveBlock from BOPTools);
---Purpose:
--- Constructor that uses couple of pave blocks
---
Create (aPB1:PaveBlock from BOPTools;
aF:Integer from Standard);
---Purpose:
--- Constructor that uses a pave block and a face
---
SetPaveBlock1 (me:out; aPB1:PaveBlock from BOPTools);
---Purpose:
--- Modifier
--- Sets first block
---
SetPaveBlock2 (me:out; aPB2:PaveBlock from BOPTools);
---Purpose:
--- Modifier
--- Sets second block
---
SetFace (me:out; aF: Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index of the face (if it exists) with which the
--- CommonBlock is common. 0 is default value
---
PaveBlock1 (me)
returns PaveBlock from BOPTools;
---C++: return const &
---Purpose:
--- Selector
--- Always returns first block myPB1
---
PaveBlock1 (me:out; anIndex: Integer from Standard)
returns PaveBlock from BOPTools;
---C++: return &
---Purpose:
--- Selector
--- Returns block that belongs to the original edge with
--- DS-index=anIndex
---
PaveBlock2 (me)
returns PaveBlock from BOPTools;
---C++: return const &
---Purpose:
--- Selector
--- Always returns first block myPB2
---
PaveBlock2 (me:out; anIndex: Integer from Standard)
returns PaveBlock from BOPTools;
---C++: return &
---Purpose:
--- Selector
--- Returns block that does not belong to the original edge with
--- DS-index=anIndex
---
Face(me)
returns Integer from Standard;
---Purpose:
--- Selector
--- Returns the DS-index of the face (if exists)
--- with which the CommonBlock is common.
--- Otherwise it returns 0.
---
fields
myPB1 : PaveBlock from BOPTools;
myPB2 : PaveBlock from BOPTools;
myFace : Integer from Standard;
end CommonBlock;

View File

@@ -0,0 +1,115 @@
// File: BOPTools_CommonBlock.cxx
// Created: Thu Feb 15 12:19:13 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_CommonBlock.ixx>
//=======================================================================
// function: BOPTools_CommonBlock::BOPTools_CommonBlock
// purpose:
//=======================================================================
BOPTools_CommonBlock::BOPTools_CommonBlock()
:
myFace(0)
{}
//=======================================================================
// function: BOPTools_CommonBlock::BOPTools_CommonBlock
// purpose:
//=======================================================================
BOPTools_CommonBlock::BOPTools_CommonBlock(const BOPTools_PaveBlock& thePB1,
const BOPTools_PaveBlock& thePB2)
{
myPB1=thePB1;
myPB2=thePB2;
myFace=0;
}
//=======================================================================
// function: BOPTools_CommonBlock::BOPTools_CommonBlock
// purpose:
//=======================================================================
BOPTools_CommonBlock::BOPTools_CommonBlock(const BOPTools_PaveBlock& thePB1,
const Standard_Integer aF)
{
myPB1=thePB1;
myFace=aF;
}
//=======================================================================
// function: SetFace
// purpose:
//=======================================================================
void BOPTools_CommonBlock::SetFace(const Standard_Integer aF)
{
myFace=aF;
}
//=======================================================================
// function: SetPaveBlock1
// purpose:
//=======================================================================
void BOPTools_CommonBlock::SetPaveBlock1(const BOPTools_PaveBlock& thePB1)
{
myPB1=thePB1;
}
//=======================================================================
// function: SetPaveBlock2
// purpose:
//=======================================================================
void BOPTools_CommonBlock::SetPaveBlock2(const BOPTools_PaveBlock& thePB2)
{
myPB2=thePB2;
}
//=======================================================================
// function: PaveBlock1
// purpose:
//=======================================================================
const BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock1() const
{
return myPB1;
}
//=======================================================================
// function: Face
// purpose:
//=======================================================================
Standard_Integer BOPTools_CommonBlock::Face() const
{
return myFace;
}
//=======================================================================
// function: PaveBlock1
// purpose:
//=======================================================================
BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock1(const Standard_Integer anIndex)
{
Standard_Integer anOriginalEdge;
anOriginalEdge=myPB1.OriginalEdge();
if (anIndex==anOriginalEdge) {
return myPB1;
}
return myPB2;
}
//=======================================================================
// function: PaveBlock2
// purpose:
//=======================================================================
const BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock2() const
{
return myPB2;
}
//=======================================================================
// function: PaveBlock2
// purpose:
//=======================================================================
BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock2(const Standard_Integer anIndex)
{
Standard_Integer anOriginalEdge;
anOriginalEdge=myPB1.OriginalEdge();
if (anIndex==anOriginalEdge) {
return myPB2;
}
return myPB1;
}

View File

@@ -0,0 +1,50 @@
-- File: BOPTools_CommonBlockAPI.cdl
-- Created: Wed Mar 14 14:56:48 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class CommonBlockAPI from BOPTools
---Purpose:
--- class that provide some useful tools
--- to manage with a List Of Common Block-s
uses
ListOfCommonBlock from BOPTools,
ListOfPaveBlock from BOPTools,
PaveBlock from BOPTools
is
Create (aList:ListOfCommonBlock from BOPTools)
returns CommonBlockAPI from BOPTools;
---Purpose:
--- Constructor
---
List(me)
returns ListOfCommonBlock from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
CommonPaveBlocks(me;
anE:Integer from Standard)
returns ListOfPaveBlock from BOPTools;
---C++: return const &
---Purpose:
--- Returns all PaveBlock-s (from the list) that are
--- common for the given edge with DS-index <anE>
---
IsCommonBlock (me;
aPB: PaveBlock from BOPTools)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if given PaveBlock <aPB> is
--- common for the Blocks from the list
---
fields
myListOfCommonBlock :Address from Standard;
myListOfPaveBlock :ListOfPaveBlock from BOPTools;
end CommonBlockAPI;

View File

@@ -0,0 +1,91 @@
// File: BOPTools_CommonBlockAPI.cxx
// Created: Wed Mar 14 15:03:09 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_CommonBlockAPI.ixx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
//=======================================================================
// function: BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI
// purpose:
//=======================================================================
BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI
(const BOPTools_ListOfCommonBlock& aLCB)
{
myListOfCommonBlock=(void *)&aLCB;
}
//=======================================================================
// function: List
// purpose:
//=======================================================================
const BOPTools_ListOfCommonBlock& BOPTools_CommonBlockAPI::List () const
{
BOPTools_ListOfCommonBlock* pListOfCommonBlock=
(BOPTools_ListOfCommonBlock*)myListOfCommonBlock;
return *pListOfCommonBlock;
}
//=======================================================================
// function: CommonPaveBlocks
// purpose: get all CommonPaveBlocks
//=======================================================================
const BOPTools_ListOfPaveBlock&
BOPTools_CommonBlockAPI::CommonPaveBlocks
(const Standard_Integer anE) const
{
Standard_Integer anECurrent, i;
BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=
(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
pmyListOfPaveBlock->Clear();
BOPTools_ListOfCommonBlock* pListOfCommonBlock=
(BOPTools_ListOfCommonBlock*)myListOfCommonBlock;
BOPTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
for (; anIt.More(); anIt.Next()) {
const BOPTools_CommonBlock& aCB=anIt.Value();
for (i=0; i<2; i++) {
const BOPTools_PaveBlock& aPB=(!i) ? aCB.PaveBlock1() : aCB.PaveBlock2();
anECurrent=aPB.OriginalEdge();
if (anECurrent==anE) {
pmyListOfPaveBlock->Append(aPB);
break;
}
}
}
return myListOfPaveBlock;
}
//=======================================================================
// function: IsCommonBlock
// purpose:
//=======================================================================
Standard_Boolean BOPTools_CommonBlockAPI::IsCommonBlock
(const BOPTools_PaveBlock& aPB) const
{
Standard_Integer anE;
anE=aPB.OriginalEdge();
CommonPaveBlocks(anE);
BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPB1=anIt.Value();
if (aPB1.IsEqual(aPB)) {
return Standard_True;
}
}
return Standard_False;
}

View File

@@ -0,0 +1,49 @@
-- File: BOPTools_ComparePave.cdl
-- Created: Fri Feb 16 15:43:15 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class ComparePave from BOPTools
---Purpose:
---
--- Auxiliary class for sorting paves along the edge
--- in acoordance with increasing order of parameter
uses
Pave from BOPTools
is
Create
returns ComparePave from BOPTools;
---Purpose:
--- Empty constructor
--- Default comparing tolerance value=1.e-12
---
Create (aTol:Real from Standard)
returns ComparePave from BOPTools;
---Purpose:
--- Constructor that use comparing tolerance value as parameter.
---
IsLower (me; Left, Right: Pave from BOPTools)
returns Boolean ;
---Purpose:
--- Returns True if <Left> is lower than <Right>.
---
IsGreater (me; Left, Right: Pave from BOPTools)
returns Boolean from Standard ;
---Purpose:
--- Returns True if <Left> is greater than <Right>.
---
IsEqual(me; Left, Right: Pave from BOPTools)
returns Boolean from Standard ;
---Purpose:
--- Returns True when <Right> and <Left> are equal.
---
fields
myTol: Real from Standard;
end ComparePave;

View File

@@ -0,0 +1,54 @@
// File: BOPTools_ComparePave.cxx
// Created: Fri Feb 16 15:47:07 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_ComparePave.ixx>
//=======================================================================
// function: BOPTools_ComparePave::BOPTools_ComparePave
// purpose:
//=======================================================================
BOPTools_ComparePave::BOPTools_ComparePave()
:myTol(1.e-12)
{}
//=======================================================================
// function: BOPTools_ComparePave::BOPTools_ComparePave
// purpose:
//=======================================================================
BOPTools_ComparePave::BOPTools_ComparePave(const Standard_Real aTol)
{
myTol=aTol;
}
//=======================================================================
// function: IsLower
// purpose:
//=======================================================================
Standard_Boolean BOPTools_ComparePave::IsLower(const BOPTools_Pave& aLeft,
const BOPTools_Pave& aRight)const
{
return aLeft.Param()<aRight.Param();
}
//=======================================================================
// function: IsGreater
// purpose:
//=======================================================================
Standard_Boolean BOPTools_ComparePave::IsGreater(const BOPTools_Pave& aLeft,
const BOPTools_Pave& aRight)const
{
return aLeft.Param()>aRight.Param();
}
//=======================================================================
// function: IsEqual
// purpose:
//=======================================================================
Standard_Boolean BOPTools_ComparePave::IsEqual(const BOPTools_Pave& aLeft,
const BOPTools_Pave& aRight)const
{
Standard_Real a, b;
a=aLeft.Param();
b=aRight.Param();
return fabs(a-b) < myTol;
}

View File

@@ -0,0 +1,74 @@
-- File: BOPTools_CoupleOfInteger.cdl
-- Created: Mon Apr 1 10:16:21 2002
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2002
class CoupleOfInteger from BOPTools
---Purpose:
-- Auxiliary class providing structure to
-- store info about a couple of integers
--uses
--raises
is
Create
returns CoupleOfInteger from BOPTools;
---Purpose:
--- Empty Constructor
---
Create(aFirst : Integer from Standard;
aSecond : Integer from Standard)
returns CoupleOfInteger from BOPTools;
---Purpose:
--- Constructor
---
SetCouple(me:out;
aFirst : Integer from Standard;
aSecond : Integer from Standard);
---Purpose:
--- Modifier
---
SetFirst(me:out;
aFirst : Integer from Standard);
---Purpose:
--- Modifier
---
SetSecond(me:out;
aSecond : Integer from Standard);
---Purpose:
--- Modifier
---
Couple (me;
aFirst :out Integer from Standard;
aSecond :out Integer from Standard);
---Purpose:
--- Selector
---
First(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Second(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
IsEqual(me;
aOther:like me)
returns Boolean from Standard;
HashCode(me;
Upper : Integer from Standard)
returns Integer from Standard;
fields
myFirst : Integer from Standard;
mySecond : Integer from Standard;
end CoupleOfInteger;

View File

@@ -0,0 +1,104 @@
// File: BOPTools_CoupleOfInteger.cxx
// Created: Mon Apr 1 10:21:26 2002
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_CoupleOfInteger.ixx>
//=======================================================================
// function: BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger
// purpose:
//=======================================================================
BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger()
:
myFirst(99),
mySecond(99)
{}
//=======================================================================
// function: BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger
// purpose:
//=======================================================================
BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger(const Standard_Integer aFirst,
const Standard_Integer aSecond)
:
myFirst(aFirst),
mySecond(aSecond)
{}
//=======================================================================
// function: SetCouple
// purpose:
//=======================================================================
void BOPTools_CoupleOfInteger::SetCouple(const Standard_Integer aFirst,
const Standard_Integer aSecond)
{
myFirst=aFirst;
mySecond=aSecond;
}
//=======================================================================
// function: SetFirst
// purpose:
//=======================================================================
void BOPTools_CoupleOfInteger::SetFirst(const Standard_Integer aFirst)
{
myFirst=aFirst;
}
//=======================================================================
// function: SetSecond
// purpose:
//=======================================================================
void BOPTools_CoupleOfInteger::SetSecond(const Standard_Integer aSecond)
{
mySecond=aSecond;
}
//=======================================================================
// function: Couple
// purpose:
//=======================================================================
void BOPTools_CoupleOfInteger::Couple(Standard_Integer& aFirst,
Standard_Integer& aSecond)const
{
aFirst=myFirst;
aSecond=mySecond;
}
//=======================================================================
// function: First
// purpose:
//=======================================================================
Standard_Integer BOPTools_CoupleOfInteger::First()const
{
return myFirst;
}
//=======================================================================
// function: Second
// purpose:
//=======================================================================
Standard_Integer BOPTools_CoupleOfInteger::Second()const
{
return mySecond;
}
//=======================================================================
// function: IsEqual
// purpose:
//=======================================================================
Standard_Boolean BOPTools_CoupleOfInteger::IsEqual(const BOPTools_CoupleOfInteger& aOther)const
{
Standard_Boolean b1, b2;
//
b1=(Standard_Boolean)((myFirst==aOther.myFirst ) && (mySecond==aOther.mySecond));
b2=(Standard_Boolean)((myFirst==aOther.mySecond) && (mySecond==aOther.myFirst ));
return (Standard_Boolean)(b1||b2);
}
//=======================================================================
// function: HashCode
// purpose:
//=======================================================================
Standard_Integer BOPTools_CoupleOfInteger::HashCode(const Standard_Integer aUpper)const
{
return (myFirst+mySecond)%aUpper;
}

View File

@@ -0,0 +1,32 @@
-- File: BOPTools_CoupleOfIntegerMapHasher.cdl
-- Created: Fri Dec 5 10:01:40 2003
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2003
class CoupleOfIntegerMapHasher from BOPTools
---Purpose:
uses
CoupleOfInteger from BOPTools
--raises
is
HashCode(myclass;
aPKey : CoupleOfInteger from BOPTools;
Upper : Integer from Standard)
returns Integer from Standard;
IsEqual(myclass;
aPKey1 : CoupleOfInteger from BOPTools;
aPKey2 : CoupleOfInteger from BOPTools)
returns Boolean from Standard;
--fields
end CoupleOfIntegerMapHasher;

View File

@@ -0,0 +1,26 @@
// File: BOPTools_CoupleOfIntegerMapHasher.cxx
// Created: Fri Dec 5 10:03:04 2003
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_CoupleOfIntegerMapHasher.ixx>
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer BOPTools_CoupleOfIntegerMapHasher::HashCode(const BOPTools_CoupleOfInteger& aPKey,
const Standard_Integer Upper)
{
return aPKey.HashCode(Upper);
}
//=======================================================================
//function :IsEqual
//purpose :
//=======================================================================
Standard_Boolean BOPTools_CoupleOfIntegerMapHasher::IsEqual(const BOPTools_CoupleOfInteger& aPKey1,
const BOPTools_CoupleOfInteger& aPKey2)
{
return aPKey1.IsEqual(aPKey2);
}

75
src/BOPTools/BOPTools_Curve.cdl Executable file
View File

@@ -0,0 +1,75 @@
-- File: BOPTools_Curve.cdl
-- Created: Tue May 8 13:07:58 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class Curve from BOPTools
---Purpose:
-- Class holds the structure for storing information about
--- intersection curve and set of paves on it
---
uses
ListOfInteger from TColStd,
Curve from IntTools,
PaveSet from BOPTools,
PaveBlock from BOPTools,
ListOfPaveBlock from BOPTools
is
Create
returns Curve from BOPTools;
---Purpose:
--- Empty constructor
---
Create (aIC:Curve from IntTools)
returns Curve from BOPTools;
---Purpose:
--- Constructor
---
SetCurve(me:out;
aIC:Curve from IntTools);
---Purpose:
--- Modifier
---
Curve(me)
returns Curve from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
Set(me:out)
returns PaveSet from BOPTools;
---C++: return &
---Purpose:
--- Selector
---
AppendNewBlock(me:out;
aPB:PaveBlock from BOPTools);
---Purpose:
--- Adds the PaveBlock <aPB> to the pave set
---
NewPaveBlocks(me)
returns ListOfPaveBlock from BOPTools;
---C++: return const &
---Purpose:
--- Returns the PaveBlock-s attached to the curve
---
TechnoVertices (me:out)
returns ListOfInteger from TColStd;
---C++: return &
---Purpose:
--- Returns indices TechnoVertices attached to the curve
---
fields
myCurve : Curve from IntTools;
myPaveSet: PaveSet from BOPTools;
myNewPBs : ListOfPaveBlock from BOPTools;
myTechnoVertices : ListOfInteger from TColStd;
end Curve;

72
src/BOPTools/BOPTools_Curve.cxx Executable file
View File

@@ -0,0 +1,72 @@
// File: BOPTools_Curve.cxx
// Created: Tue May 8 13:13:58 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Curve.ixx>
//=======================================================================
// function: BOPTools_Curve::BOPTools_Curve
// purpose:
//=======================================================================
BOPTools_Curve::BOPTools_Curve()
{}
//=======================================================================
// function: BOPTools_Curve::BOPTools_Curve
// purpose:
//=======================================================================
BOPTools_Curve::BOPTools_Curve (const IntTools_Curve& aIC)
{
myCurve=aIC;
}
//=======================================================================
// function: SetCurve
// purpose:
//=======================================================================
void BOPTools_Curve::SetCurve (const IntTools_Curve& aIC)
{
myCurve=aIC;
}
//=======================================================================
// function: Curve
// purpose:
//=======================================================================
const IntTools_Curve& BOPTools_Curve::Curve () const
{
return myCurve;
}
//=======================================================================
// function: Set
// purpose:
//=======================================================================
BOPTools_PaveSet& BOPTools_Curve::Set()
{
return myPaveSet;
}
//=======================================================================
//function : AppendNewBlock
//purpose :
//=======================================================================
void BOPTools_Curve::AppendNewBlock(const BOPTools_PaveBlock& aPB)
{
myNewPBs.Append(aPB);
}
//=======================================================================
//function : NewPaveBlocks
//purpose :
//=======================================================================
const BOPTools_ListOfPaveBlock& BOPTools_Curve::NewPaveBlocks() const
{
return myNewPBs;
}
//=======================================================================
//function : TechnoVertices
//purpose :
//=======================================================================
TColStd_ListOfInteger& BOPTools_Curve::TechnoVertices()
{
return myTechnoVertices;
}

View File

@@ -0,0 +1,60 @@
-- File: BOPTools_DEInfo.cdl
-- Created: Wed Sep 12 12:57:03 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class DEInfo from BOPTools
---Purpose:
-- Auxiliary class for storing information about
--- a degenerated edge
---
uses
ListOfInteger from TColStd
is
Create
returns DEInfo from BOPTools;
---Purpose:
--- Empty constructor
---
SetVertex (me:out;
nV:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the vertex to which
--- degenerated edge belongs to
---
SetFaces (me:out;
aLF: ListOfInteger from TColStd);
---Purpose:
--- Modifier
--- Sets DS-indices for the faces to which
--- degenerated edge belongs to
---
Faces(me)
returns ListOfInteger from TColStd;
---C++: return const &
---Purpose:
--- Selector
---
ChangeFaces(me:out)
returns ListOfInteger from TColStd;
---C++: return &
---Purpose:
--- Selector/Modifier
---
Vertex(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
fields
myFaces : ListOfInteger from TColStd;
myVertex : Integer from Standard;
end DEInfo;

View File

@@ -0,0 +1,65 @@
// File: BOPTools_DEInfo.cxx
// Created: Wed Sep 12 13:02:17 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_DEInfo.ixx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
//=======================================================================
// function: BOPTools_DEInfo::BOPTools_DEInfo
// purpose:
//=======================================================================
BOPTools_DEInfo::BOPTools_DEInfo()
{}
//=======================================================================
// function: SetVertex
// purpose:
//=======================================================================
void BOPTools_DEInfo::SetVertex(const Standard_Integer nV)
{
myVertex=nV;
}
//=======================================================================
// function: Vertex
// purpose:
//=======================================================================
Standard_Integer BOPTools_DEInfo::Vertex()const
{
return myVertex;
}
//=======================================================================
// function: SetFaces
// purpose:
//=======================================================================
void BOPTools_DEInfo::SetFaces(const TColStd_ListOfInteger& aLI)
{
myFaces.Clear();
TColStd_ListIteratorOfListOfInteger anIt(aLI);
for (; anIt.More(); anIt.Next()) {
Standard_Integer nF=anIt.Value();
myFaces.Append(nF);
}
}
//=======================================================================
// function: Faces
// purpose:
//=======================================================================
const TColStd_ListOfInteger& BOPTools_DEInfo::Faces()const
{
return myFaces;
}
//=======================================================================
// function: ChangeFaces
// purpose:
//=======================================================================
TColStd_ListOfInteger& BOPTools_DEInfo::ChangeFaces()
{
return myFaces;
}

View File

@@ -0,0 +1,114 @@
-- File: BOPTools_DEProcessor.cdl
-- Created: Wed Sep 12 12:08:37 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class DEProcessor from BOPTools
---Purpose:
--
-- The Algorithm to compute and store in interferences' pool
--- and in the Data Structure the following values
--- for degenerated edges
--- 1. Paves/Pave set(s)
--- 2. Split parts
--- 3. States (3D) for split parts
---
uses
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
PPaveFiller from BOPTools,
PaveFiller from BOPTools,
ListOfPaveBlock from BOPTools,
PShapesDataStructure from BooleanOperations,
IndexedDataMapOfIntegerDEInfo from BOPTools
is
Create (aFiller: PaveFiller from BOPTools;
aDim : Integer from Standard=3)
returns DEProcessor from BOPTools;
---Purpose:
--- Constructor
---
Do(me:out);
---Purpose:
--- Launches the processor
---
IsDone(me)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if it is Ok
---
---
--- Private block
---
---
FindDegeneratedEdges (me:out)
is private;
DoPaves (me:out)
is private;
FindPaveBlocks (me:out;
nED:Integer from Standard;
nVD:Integer from Standard;
nFD:Integer from Standard;
aLPB:out ListOfPaveBlock from BOPTools)
is private;
FillPaveSet (me:out;
nED:Integer from Standard;
nVD:Integer from Standard;
nFD:Integer from Standard;
aLPB:out ListOfPaveBlock from BOPTools)
is private;
FillSplitEdgesPool(me:out;
nED:Integer from Standard)
is private;
MakeSplitEdges(me:out;
nED:Integer from Standard;
nFD:Integer from Standard)
is private;
MakeSplitEdge (me:out;
aS1: Edge from TopoDS;
aF : Face from TopoDS;
aV1: Vertex from TopoDS;
aP1: Real from Standard;
aV2: Vertex from TopoDS;
aP2: Real from Standard;
aNewEdge:out Edge from TopoDS)
is private;
DoStates (me:out;
nED:Integer from Standard;
nFD:Integer from Standard)
is private;
DoStates2D (me:out;
nED:Integer from Standard;
nFD:Integer from Standard)
is private;
fields
myDim : Integer from Standard;
myFiller : PPaveFiller from BOPTools;
myDS : PShapesDataStructure from BooleanOperations;
myIsDone : Boolean from Standard;
myDEMap : IndexedDataMapOfIntegerDEInfo from BOPTools;
end DEProcessor;

View File

@@ -0,0 +1,698 @@
// File: BOPTools_DEProcessor.cxx
// Created: Wed Sep 12 12:10:52 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_DEProcessor.ixx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Solid.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Sphere.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <Precision.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_Context.hxx>
#include <BOPTools_DEInfo.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_SequenceOfCurves.hxx>
#include <BOPTools_Curve.hxx>
#include <BOPTools_PavePool.hxx>
#include <BOPTools_Pave.hxx>
#include <BOPTools_PaveSet.hxx>
#include <BOPTools_Tools3D.hxx>
#include <BOPTools_PaveBlockIterator.hxx>
#include <BOPTools_ListOfPave.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_PaveFiller.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_SplitShapesPool.hxx>
#include <BOPTools_StateFiller.hxx>
//=======================================================================
// function: BOPTools_DEProcessor::BOPTools_DEProcessor
// purpose:
//=======================================================================
BOPTools_DEProcessor::BOPTools_DEProcessor(const BOPTools_PaveFiller& aFiller,
const Standard_Integer aDim)
:
myIsDone(Standard_False)
{
myFiller=(BOPTools_PaveFiller*) &aFiller;
myDS=myFiller->DS();
myDim=aDim;
if (aDim<2 || aDim>3) {
myDim=3;
}
}
//=======================================================================
// function: IsDone
// purpose:
//=======================================================================
Standard_Boolean BOPTools_DEProcessor::IsDone() const
{
return myIsDone;
}
//=======================================================================
// function: Do
// purpose:
//=======================================================================
void BOPTools_DEProcessor::Do()
{
Standard_Integer aNbE;
myIsDone=Standard_False;
FindDegeneratedEdges();
aNbE=myDEMap.Extent();
if (!aNbE) {
myIsDone=Standard_True;
return;
}
DoPaves();
}
//=======================================================================
// function: FindDegeneratedEdges
// purpose:
//=======================================================================
void BOPTools_DEProcessor::FindDegeneratedEdges()
{
const BooleanOperations_ShapesDataStructure& aDS=*myDS;
const BOPTools_PaveFiller& aPaveFiller=*myFiller;
Standard_Integer i, aNbSourceShapes, nV, nF, nVx, ip, iRankE;
TopAbs_ShapeEnum aType;
const TopoDS_Shape& anObj=aDS.Object();
const TopoDS_Shape& aTool=aDS.Tool();
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE, TopAbs_FACE, aMEF);
TopExp::MapShapesAndAncestors (aTool, TopAbs_EDGE, TopAbs_FACE, aMEF);
aNbSourceShapes=aDS.NumberOfSourceShapes();
for (i=1; i<=aNbSourceShapes; i++) {
const TopoDS_Shape& aS=aDS.Shape(i);
aType=aS.ShapeType();
if (aType==TopAbs_EDGE) {
const TopoDS_Edge& aE=TopoDS::Edge(aS);
if (BRep_Tool::Degenerated(aE)) {
iRankE=aDS.Rank(i);
TopoDS_Vertex aV=TopExp::FirstVertex(aE);
nVx=aDS.ShapeIndex(aV, iRankE);
//
nV=nVx;
ip=aPaveFiller.FindSDVertex(nV);
if (ip) {
nV=ip;
}
//
TColStd_ListOfInteger aLFn;
const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
TopTools_ListIteratorOfListOfShape anIt(aLF);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aF=anIt.Value();
nF=aDS.ShapeIndex(aF, iRankE);
aLFn.Append(nF);
}
BOPTools_DEInfo aDEInfo;
aDEInfo.SetVertex(nV);
aDEInfo.SetFaces(aLFn);
myDEMap.Add (i, aDEInfo);
}
}
}
}
//=======================================================================
// function: DoPaves
// purpose:
//=======================================================================
void BOPTools_DEProcessor::DoPaves()
{
Standard_Integer i, aNbE, nED, nVD, nFD=0;
aNbE=myDEMap.Extent();
for (i=1; i<=aNbE; i++) {
nED=myDEMap.FindKey(i);
const BOPTools_DEInfo& aDEInfo=myDEMap(i);
nVD=aDEInfo.Vertex();
// Fill PaveSet for the edge nED
const TColStd_ListOfInteger& nLF=aDEInfo.Faces();
TColStd_ListIteratorOfListOfInteger anIt(nLF);
for (; anIt.More(); anIt.Next()) {
nFD=anIt.Value();
BOPTools_ListOfPaveBlock aLPB;
FindPaveBlocks(nED, nVD, nFD, aLPB);
FillPaveSet (nED, nVD, nFD, aLPB);
}
//
// Fill aSplitEdges for the edge nED
FillSplitEdgesPool(nED);
//
// MakeSplitEdges
MakeSplitEdges(nED, nFD);
//
// Compute States for Split parts
if (myDim==3) {
DoStates(nED, nFD);
}
if (myDim==2) {
DoStates2D(nED, nFD);
}
}// next nED
}
//=======================================================================
// function: DoStates
// purpose:
//=======================================================================
void BOPTools_DEProcessor::DoStates (const Standard_Integer nED,
const Standard_Integer nFD)
{
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED));
const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED));
const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD));
Standard_Integer nSp, iRank;
Standard_Real aT, aT1, aT2, aTol=1e-7;
TopoDS_Face aF;
gp_Pnt2d aPx2DNear;
gp_Pnt aPxNear;
iRank=myDS->Rank(nED);
const TopoDS_Shape& aReference=(iRank==1) ? myDS->Tool() : myDS->Object();
BRepExtrema_DistShapeShape aDSS;
aDSS.LoadS1(aReference);
aF=aDF;
aF.Orientation(TopAbs_FORWARD);
BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
for (; aPBIt.More(); aPBIt.Next()) {
BOPTools_PaveBlock& aPB=aPBIt.Value();
nSp=aPB.Edge();
const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp));
aPB.Parameters(aT1, aT2);
aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
TopoDS_Edge aDERight, aSpRight;
aDERight=aDE;
aSpRight=aSp;
BOPTools_Tools3D::OrientEdgeOnFace (aDE, aF, aDERight);
aSpRight.Orientation(aDERight.Orientation());
//
{
BRepAdaptor_Surface aBAS;
aBAS.Initialize (aDF, Standard_False);
if (aBAS.GetType()==GeomAbs_Sphere) {
Standard_Real aDt2D, aR, aDelta=1.e-14;
gp_Sphere aSphere=aBAS.Sphere();
aR=aSphere.Radius();
//
aDt2D=acos (1.-4.*aTol/aR)+aDelta ;
//
BOPTools_Tools3D::PointNearEdge(aSpRight, aF, aT, aDt2D, aPx2DNear, aPxNear);
}
else {
BOPTools_Tools3D::PointNearEdge(aSpRight, aF, aT, aPx2DNear, aPxNear);
}
}
//
TopAbs_State aState;
//
TopAbs_ShapeEnum aTypeReference;
aTypeReference=aReference.ShapeType();
if (aTypeReference==TopAbs_SOLID) {
// ... \ Solid processing
IntTools_Context& aContext=myFiller->ChangeContext();
const TopoDS_Solid& aReferenceSolid=TopoDS::Solid(aReference);
BRepClass3d_SolidClassifier& SC=aContext.SolidClassifier(aReferenceSolid);
//
SC.Perform(aPxNear, aTol);
//
aState=SC.State();
}
//
else if (aTypeReference==TopAbs_SHELL ||
aTypeReference==TopAbs_FACE) {
// ... \ Shell processing
TopoDS_Vertex aVxNear;
BRep_Builder BB;
BB.MakeVertex(aVxNear, aPxNear, aTol);
aDSS.LoadS2(aVxNear);
aDSS.Perform();
aState=TopAbs_OUT;
if (aDSS.IsDone()) {
Standard_Real aDist=aDSS.Value();
if (aDist < aTol) {
aState=TopAbs_ON;
}
}
}
else {
// unknown aTypeReference
aState=TopAbs_OUT;
}
//
BooleanOperations_StateOfShape aSt;
aSt=BOPTools_StateFiller::ConvertState(aState);
myDS->SetState(nSp, aSt);
}
}
//=======================================================================
// function: DoStates2D
// purpose:
//=======================================================================
void BOPTools_DEProcessor::DoStates2D (const Standard_Integer nED,
const Standard_Integer nFD)
{
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED));
const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED));
const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD));
Standard_Integer nSp, iRank;
Standard_Real aT, aT1, aT2;
TopoDS_Face aF;
gp_Pnt2d aPx2DNear;
gp_Pnt aPxNear;
iRank=myDS->Rank(nED);
const TopoDS_Shape& aReference=(iRank==1) ? myDS->Tool() : myDS->Object();
const TopoDS_Face& aFaceReference=TopoDS::Face(aReference);
aF=aDF;
aF.Orientation(TopAbs_FORWARD);
BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
for (; aPBIt.More(); aPBIt.Next()) {
BOPTools_PaveBlock& aPB=aPBIt.Value();
nSp=aPB.Edge();
const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp));
aPB.Parameters(aT1, aT2);
aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
TopoDS_Edge aDERight, aSpRight;
aDERight=aDE;
aSpRight=aSp;
BOPTools_Tools3D::OrientEdgeOnFace (aDE, aF, aDERight);
aSpRight.Orientation(aDERight.Orientation());
//
BOPTools_Tools3D::PointNearEdge(aSpRight, aDF, aT, aPx2DNear, aPxNear);
//
Standard_Boolean bIsValidPoint;
TopAbs_State aState=TopAbs_OUT;
//
IntTools_Context& aContext=myFiller->ChangeContext();
bIsValidPoint=aContext.IsValidPointForFace(aPxNear, aFaceReference, 1.e-3);
//
if (bIsValidPoint) {
aState=TopAbs_IN;
}
//
BooleanOperations_StateOfShape aSt;
aSt=BOPTools_StateFiller::ConvertState(aState);
myDS->SetState(nSp, aSt);
}
}
//=======================================================================
// function: FillSplitEdgesPool
// purpose:
//=======================================================================
void BOPTools_DEProcessor::FillSplitEdgesPool (const Standard_Integer nED)
{
BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->ChangeSplitShapesPool();
//
BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool.ChangeValue(myDS->RefEdge(nED));
//
aSplitEdges.Clear();
//
const BOPTools_PavePool& aPavePool=myFiller->PavePool();
BOPTools_PavePool* pPavePool=(BOPTools_PavePool*) &aPavePool;
BOPTools_PaveSet& aPaveSet= pPavePool->ChangeValue(myDS->RefEdge(nED));
BOPTools_PaveBlockIterator aPBIt(nED, aPaveSet);
for (; aPBIt.More(); aPBIt.Next()) {
BOPTools_PaveBlock& aPB=aPBIt.Value();
aSplitEdges.Append(aPB);
}
}
//=======================================================================
// function: MakeSplitEdges
// purpose:
//=======================================================================
void BOPTools_DEProcessor::MakeSplitEdges (const Standard_Integer nED,
const Standard_Integer nFD)
{
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED));
Standard_Integer nV1, nV2, aNewShapeIndex;
Standard_Real t1, t2;
TopoDS_Edge aE, aESplit;
TopoDS_Vertex aV1, aV2;
const TopoDS_Edge aDE=TopoDS::Edge(myDS->Shape(nED));
const TopoDS_Face aDF=TopoDS::Face(myDS->Shape(nFD));
BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
for (; aPBIt.More(); aPBIt.Next()) {
BOPTools_PaveBlock& aPB=aPBIt.Value();
const BOPTools_Pave& aPave1=aPB.Pave1();
nV1=aPave1.Index();
t1=aPave1.Param();
aV1=TopoDS::Vertex(myDS->GetShape(nV1));
aV1.Orientation(TopAbs_FORWARD);
const BOPTools_Pave& aPave2=aPB.Pave2();
nV2=aPave2.Index();
t2=aPave2.Param();
aV2=TopoDS::Vertex(myDS->GetShape(nV2));
aV2.Orientation(TopAbs_REVERSED);
MakeSplitEdge(aDE, aDF, aV1, t1, aV2, t2, aESplit);
//
// Add Split Part of the Original Edge to the DS
BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
anASSeq.SetNewSuccessor(nV1);
anASSeq.SetNewOrientation(aV1.Orientation());
anASSeq.SetNewSuccessor(nV2);
anASSeq.SetNewOrientation(aV2.Orientation());
myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq);
aNewShapeIndex=myDS->NumberOfInsertedShapes();
myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN);
//
// Fill Split Set for the Original Edge
aPB.SetEdge(aNewShapeIndex);
//
}
}
//=======================================================================
// function: MakeSplitEdge
// purpose:
//=======================================================================
void BOPTools_DEProcessor::MakeSplitEdge (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;
}
//=======================================================================
// function: FillPaveSet
// purpose:
//=======================================================================
void BOPTools_DEProcessor::FillPaveSet (const Standard_Integer nED,
const Standard_Integer nVD,
const Standard_Integer nFD,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Boolean bIsDone, bXDir;
Standard_Integer nE, aNbPoints, j;
Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT;
//
aDT=Precision::PConfusion();
//
BOPTools_PaveSet& aPaveSet= (myFiller->ChangePavePool()).ChangeValue(myDS->RefEdge(nED));
//
// Clear aPaveSet, aSplitEdges
aPaveSet.ChangeSet().Clear();
//
const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED));
const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD));
//
// 2D Curve of degenerated edge on the face aDF
Handle(Geom2d_Curve) aC2DDE=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2);
//
// Choose direction for Degenerated Edge
gp_Pnt2d aP2d1, aP2d2;
aC2DDE->D0(aTD1, aP2d1);
aC2DDE->D0(aTD2, aP2d2);
bXDir=Standard_False;
if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){
bXDir=!bXDir;
}
//
// Prepare bounding Paves
BOPTools_Pave aPave1 (nVD, aTD1, BooleanOperations_UnknownInterference);
aPaveSet.Append(aPave1);
BOPTools_Pave aPave2 (nVD, aTD2, BooleanOperations_UnknownInterference);
aPaveSet.Append(aPave2);
//
// Fill other paves
BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPB=anIt.Value();
nE=aPB.Edge();
const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2);
//
// Intersection
aTolInter=0.001;
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);
}
Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter);
bIsDone=aGInter.IsDone();
if(bIsDone) {
aNbPoints=aGInter.NbPoints();
if (aNbPoints) {
for (j=1; j<=aNbPoints; ++j) {
gp_Pnt2d aP2D=aGInter.Point(j).Value();
//
aX=(bXDir) ? aP2D.X(): aP2D.Y();
//
if (fabs (aX-aTD1) < aDT || fabs (aX-aTD2) < aDT) {
continue;
}
if (aX < aTD1 || aX > aTD2) {
continue;
}
//
Standard_Boolean bRejectFlag=Standard_False;
const BOPTools_ListOfPave& aListOfPave=aPaveSet.Set();
BOPTools_ListIteratorOfListOfPave aPaveIt(aListOfPave);
for (; aPaveIt.More(); aPaveIt.Next()) {
const BOPTools_Pave& aPavex=aPaveIt.Value();
Standard_Real aXx=aPavex.Param();
if (fabs (aX-aXx) < aDT) {
bRejectFlag=Standard_True;
break;
}
}
if (bRejectFlag) {
continue;
}
//
BOPTools_Pave aPave(nVD, aX, BooleanOperations_UnknownInterference);
aPaveSet.Append(aPave);
}
}
}
}
}
//=======================================================================
// function: FindPaveBlocks
// purpose:
//=======================================================================
void BOPTools_DEProcessor::FindPaveBlocks(const Standard_Integer ,
const Standard_Integer nVD,
const Standard_Integer nFD,
BOPTools_ListOfPaveBlock& aLPBOut)
{
BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences();
BOPTools_ListIteratorOfListOfPaveBlock anIt;
Standard_Integer i, aNb, nF2, nSp, nV;
//ZZ const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED));
aNb=aFFs.Extent();
for (i=1; i<=aNb; i++) {
BOPTools_SSInterference& aFF=aFFs(i);
//
nF2=aFF.OppositeIndex(nFD);
if (!nF2) {
continue;
}
//
// Split Parts
const BOPTools_ListOfPaveBlock& aLPBSplits=aFF.PaveBlocks();
anIt.Initialize(aLPBSplits);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPBSp=anIt.Value();
nSp=aPBSp.Edge();
const BOPTools_Pave& aPave1=aPBSp.Pave1();
nV=aPave1.Index();
if (nV==nVD) {
aLPBOut.Append(aPBSp);
continue;
}
const BOPTools_Pave& aPave2=aPBSp.Pave2();
nV=aPave2.Index();
if (nV==nVD) {
aLPBOut.Append(aPBSp);
continue;
}
}
//
// Section Parts
Standard_Integer j, aNbCurves;
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
aNbCurves=aSC.Length();
for (j=1; j<=aNbCurves; j++) {
const BOPTools_Curve& aBC=aSC(j);
const BOPTools_ListOfPaveBlock& aLPBSe=aBC.NewPaveBlocks();
anIt.Initialize(aLPBSe);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPBSe=anIt.Value();
const BOPTools_Pave& aPv1=aPBSe.Pave1();
nV=aPv1.Index();
if (nV==nVD) {
aLPBOut.Append(aPBSe);
continue;
}
const BOPTools_Pave& aPv2=aPBSe.Pave2();
nV=aPv2.Index();
if (nV==nVD) {
aLPBOut.Append(aPBSe);
continue;
}
}
}
} // for (i=1; i<=aNb; i++) Next FF interference
}

View File

@@ -0,0 +1,164 @@
-- File: BOPTools_PoolsFiller.cdl
-- Created: Tue Feb 20 12:38:40 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class DSFiller from BOPTools
---Purpose:
--- class that provides
--- 1. creation of the data structure (DS)
--- 2. creation of the interferences' pool
--- 3. invokation of PaveFiller->Perform() to fill the DS
---
uses
Shape from TopoDS,
ShapesDataStructure from BooleanOperations,
PShapesDataStructure from BooleanOperations,
InterferencePool from BOPTools,
PInterferencePool from BOPTools,
PavePool from BOPTools,
PPaveFiller from BOPTools,
PaveFiller from BOPTools,
SSIntersectionAttribute from BOPTools,
SplitShapesPool from BOPTools,
CommonBlockPool from BOPTools,
DataMapOfIntegerListOfInteger from TColStd,
SetOfInteger from TColStd
is
Create
returns DSFiller from BOPTools;
---Purpose:
--- Empty constructor
---
Destroy (me:out);
---C++: alias ~
---Purpose: Destructor
---
SetShapes (me:out; aS1, aS2: Shape from TopoDS);
---Purpose:
--- Modifier
--- Sets the arguments of boolean operation
---
Shape1(me)
returns Shape from TopoDS;
---C++: return const&
---Purpose:
--- Selector
---
Shape2(me)
returns Shape from TopoDS;
---C++: return const&
---Purpose:
--- Selector
---
Perform (me:out);
---Purpose:
--- Performs the filling of the DS
---
InitFillersAndPools(me:out);
PartialPerform(me:out; anObjSubSet, aToolSubSet: SetOfInteger from TColStd);
ToCompletePerform(me:out);
Perform (me:out; theSectionAttribute: SSIntersectionAttribute from BOPTools);
---Purpose:
--- Performs the filling of the DS
---
DS (me)
returns ShapesDataStructure from BooleanOperations;
---C++: return const&
---Purpose:
--- Selector
---
InterfPool (me)
returns InterferencePool from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
PavePool (me)
returns PavePool from BOPTools;
---C++: return const&
---Purpose:
--- Selector
---
CommonBlockPool(me)
returns CommonBlockPool from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
SplitShapesPool(me)
returns SplitShapesPool from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
PaveFiller (me)
returns PaveFiller from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
Clear (me:out)
is private;
---Purpose:
--- Clear contents of the DS and the interferences' pool
---
IsNewFiller(me)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if new DS and the interferences' pool has been created
---
SetNewFiller(me;
aFlag:Boolean from Standard);
---Purpose:
--- Modifier
---
IsDone(me)
returns Boolean from Standard;
---Purpose:
--- Selector
---
SplitFacePool(me)
---C++: return const&
---C++: inline
returns DataMapOfIntegerListOfInteger from TColStd;
ChangeSplitFacePool(me: out)
---C++: return &
---C++: inline
returns DataMapOfIntegerListOfInteger from TColStd;
--modified by NIZHNY-MKK Tue Sep 7 12:03:34 2004
TreatCompound(myclass; theShape: Shape from TopoDS;
theShapeResult: out Shape from TopoDS)
returns Integer from Standard;
---Purpose: Finds sub-shapes of theShape having equal type
-- and store them in theShapeResult.
-- Returns the following status codes:
-- 0 - OK
-- 1 - Error: theShape is a COMPSOLID
-- 2 - Error: theShape is not a COMPOUND
-- 3 - Error: theShape contains shapes of COMPSOLID type
-- 4 - Error: Subshape of theShape have unkown type
-- 5 - Error: theShape contains shapes of different type
fields
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myDS : PShapesDataStructure from BooleanOperations;
myInterfPool : PInterferencePool from BOPTools;
myPaveFiller : PPaveFiller from BOPTools;
myIsDone : Boolean from Standard;
mySplitFacePool: DataMapOfIntegerListOfInteger from TColStd;
myNewFiller : Boolean from Standard;
end DSFiller;

View File

@@ -0,0 +1,683 @@
// File: BOPTools_PoolsFiller.cxx
// Created: Tue Feb 20 12:44:28 2001
// Author: Peter KURNEV
// <pkv@irinox>
//
#include <BOPTools_DSFiller.ixx>
#include <BOPTools_PaveFiller.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BRep_Builder.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Edge.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <BOPTools_Tools3D.hxx>
//
static
void FillList(const TopoDS_Shape& aS,
Standard_Boolean& bCompSolidFound,
TopTools_ListOfShape& aResultList);
static
void BuildSolid(const TopTools_ListOfShape& aRL, TopoDS_Shape& aS);
static
void BuildShell(const TopTools_ListOfShape& aRL, TopoDS_Shape& aS);
static
void BuildWire (const TopTools_ListOfShape& aRL, TopoDS_Shape& aS);
static
TopAbs_ShapeEnum GetTypeCurrent(const TopAbs_ShapeEnum aTypeX);
// static
// Standard_Integer TreatCompound(const TopoDS_Shape& aS,
// TopoDS_Shape& aShapeResult);
// Peter KURNEV
// p-kurnev@opencascade.com
//=======================================================================
// function: BOPTools_PoolsFiller
// purpose:
//=======================================================================
BOPTools_DSFiller::BOPTools_DSFiller()
{
myPaveFiller=NULL;
myInterfPool=NULL;
myDS=NULL;
myNewFiller=Standard_True;
myIsDone=Standard_False;
}
//=======================================================================
// function: Clear
// purpose:
//=======================================================================
void BOPTools_DSFiller::Clear()
{
if (myPaveFiller!=NULL) {
delete myPaveFiller;
}
if (myInterfPool!=NULL) {
delete myInterfPool;
}
if (myDS!=NULL) {
delete myDS;
}
myPaveFiller=NULL;
myInterfPool=NULL;
myDS=NULL;
}
//=======================================================================
// function: Perform
// purpose:
//=======================================================================
void BOPTools_DSFiller::Perform()
{
myIsDone=Standard_False;
if (myShape1.IsNull() || myShape2.IsNull()) {
return;
}
//
// Clear contents of the DS if it was before
Clear();
//
myNewFiller=Standard_True;
//
myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2);
myInterfPool= new BOPTools_InterferencePool (*myDS);
//
// Build Vertices, Paves, splits,
myPaveFiller = new BOPTools_PaveFiller(*myInterfPool);
myPaveFiller->Perform();
myIsDone=myPaveFiller->IsDone();
}
//=======================================================================
// function: InitFillersAndPools
// purpose:
//=======================================================================
void BOPTools_DSFiller::InitFillersAndPools()
{
myIsDone=Standard_False;
if (myShape1.IsNull() || myShape2.IsNull()) {
return;
}
//
// Clear contents of the DS if it was before
Clear();
//
myNewFiller=Standard_True;
//
myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2);
myInterfPool= new BOPTools_InterferencePool (*myDS);
//
myPaveFiller = new BOPTools_PaveFiller(*myInterfPool);
}
//=======================================================================
// function: PartialPerform
// purpose:
//=======================================================================
void BOPTools_DSFiller::PartialPerform(const TColStd_SetOfInteger& anObjSubSet,
const TColStd_SetOfInteger& aToolSubSet)
{
myIsDone=Standard_False;
//
// Build Vertices, Paves, splits,
myPaveFiller->PartialPerform(anObjSubSet, aToolSubSet);
myIsDone=myPaveFiller->IsDone();
}
//=======================================================================
// function: ToCompletePerform
// purpose:
//=======================================================================
void BOPTools_DSFiller::ToCompletePerform()
{
if(myIsDone) {
myIsDone=Standard_False;
//
myPaveFiller->ToCompletePerform();
myIsDone=myPaveFiller->IsDone();
if(myIsDone) {
// Check if any interference exists
myIsDone=Standard_False;
Standard_Integer nbs = myDS->NumberOfNewShapes();
if(nbs > 0) {
myIsDone=Standard_True;
return;
}
}
}
}
//=======================================================================
// function: Perform
// purpose:
//=======================================================================
void BOPTools_DSFiller::Perform(const BOPTools_SSIntersectionAttribute& theSectionAttribute)
{
myIsDone=Standard_False;
if (myShape1.IsNull() || myShape2.IsNull()) {
return;
}
//
// Clear contents of the DS if it was before
Clear();
//
myNewFiller=Standard_True;
//
myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2);
myInterfPool= new BOPTools_InterferencePool (*myDS);
//
// Build Vertices, Paves, splits,
myPaveFiller = new BOPTools_PaveFiller(*myInterfPool, theSectionAttribute);
myPaveFiller->Perform();
myIsDone=myPaveFiller->IsDone();
}
//=======================================================================
// function:Destroy
// purpose:
//=======================================================================
void BOPTools_DSFiller::Destroy()
{
Clear();
}
//=======================================================================
// function: SetShapes
// purpose:
//=======================================================================
void BOPTools_DSFiller::SetShapes (const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2)
{
myShape1=aS1;
myShape2=aS2;
//
Standard_Integer aNbShapes;
TopAbs_ShapeEnum aT1, aT2;
aT1=aS1.ShapeType();
aT2=aS2.ShapeType();
//
if (aT1==TopAbs_COMPOUND || aT2==TopAbs_COMPOUND) {
Standard_Boolean bIsEmptyShape1, bIsEmptyShape2;
bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(myShape1);
bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(myShape2);
if (bIsEmptyShape1 || bIsEmptyShape2) {
myIsDone=Standard_True;
return;
}
}
//
// 1.1
TopoDS_Iterator anIt;
TopoDS_Shape aSTmp;
if (aT1==TopAbs_COMPOUND || aT1==TopAbs_COMPSOLID) {
aNbShapes=0;
anIt.Initialize(aS1);
for (; anIt.More(); anIt.Next()) {
if (!aNbShapes) {
aSTmp=anIt.Value();
}
aNbShapes++;
if (aNbShapes>1) {
break;
}
}
//
if (aT1==TopAbs_COMPOUND) {
if (aNbShapes==1) {
TreatCompound(aS1, aSTmp);
myShape1=aSTmp;
aT1=myShape1.ShapeType();
}
else if (aNbShapes>1) {
TreatCompound(aS1, aSTmp);
myShape1=aSTmp;
aT1=myShape1.ShapeType();
}
}
}
//
if (aT1==TopAbs_COMPOUND || aT1==TopAbs_COMPSOLID) {
myIsDone=Standard_False;
return;
}
//
// 1.2 aS2
if (aT2==TopAbs_COMPOUND || aT2==TopAbs_COMPSOLID) {
aNbShapes=0;
anIt.Initialize(aS2);
for (; anIt.More(); anIt.Next()) {
if (!aNbShapes) {
aSTmp=anIt.Value();
}
aNbShapes++;
if (aNbShapes>1) {
break;
}
}
//
if (aT2==TopAbs_COMPOUND) {
if (aNbShapes==1) {
TreatCompound(aS2, aSTmp);
myShape2=aSTmp;
aT2=myShape2.ShapeType();
}
else if (aNbShapes>1) {
TreatCompound(aS2, aSTmp);
myShape2=aSTmp;
aT2=myShape2.ShapeType();
}
}
}
//
if (aT2==TopAbs_COMPOUND || aT2==TopAbs_COMPSOLID) {
myIsDone=Standard_False;
return;
}
//
// 2.1
BRep_Builder BB;
TopoDS_Shell aSh1, aSh2;
TopoDS_Wire aW1, aW2;
if (aT1==TopAbs_FACE) {
if (aT2==TopAbs_SOLID ||
aT2==TopAbs_SHELL ||
aT2==TopAbs_FACE ||
aT2==TopAbs_WIRE ||
aT2==TopAbs_EDGE) {
BB.MakeShell(aSh1);
BB.Add(aSh1, myShape1);
myShape1=aSh1;
aT1=TopAbs_SHELL;
}
}
//
// 2.2
if (aT2==TopAbs_FACE) {
if (aT1==TopAbs_SOLID ||
aT1==TopAbs_SHELL ||
aT1==TopAbs_WIRE ||
aT1==TopAbs_EDGE) {
BB.MakeShell(aSh2);
BB.Add(aSh2, myShape2);
myShape2=aSh2;
aT2=TopAbs_SHELL;
}
}
// 3.1
if (aT1==TopAbs_EDGE) {
if (aT2==TopAbs_SOLID ||
aT2==TopAbs_SHELL ||
aT2==TopAbs_WIRE ||
aT2==TopAbs_EDGE) {
BB.MakeWire (aW1);
BB.Add(aW1, myShape1);
myShape1=aW1;
aT1=TopAbs_WIRE;
}
}
// 3.2
if (aT2==TopAbs_EDGE) {
if (aT1==TopAbs_SOLID ||
aT1==TopAbs_SHELL ||
aT1==TopAbs_WIRE) {
BB.MakeWire (aW2);
BB.Add(aW2, myShape2);
myShape2=aW2;
aT2=TopAbs_WIRE;
}
}
myIsDone=Standard_True;
}
//=======================================================================
// function: Shape1
// purpose:
//=======================================================================
const TopoDS_Shape& BOPTools_DSFiller::Shape1 () const
{
return myShape1;
}
//=======================================================================
// function: Shape2
// purpose:
//=======================================================================
const TopoDS_Shape& BOPTools_DSFiller::Shape2 () const
{
return myShape2;
}
//=======================================================================
// function: DS
// purpose:
//=======================================================================
const BooleanOperations_ShapesDataStructure& BOPTools_DSFiller::DS () const
{
return *myDS;
}
//=======================================================================
// function: InterfPool
// purpose:
//=======================================================================
const BOPTools_InterferencePool& BOPTools_DSFiller::InterfPool () const
{
return *myInterfPool;
}
//=======================================================================
// function: PavePool
// purpose:
//=======================================================================
const BOPTools_PavePool& BOPTools_DSFiller::PavePool () const
{
return myPaveFiller->PavePool();
}
//=======================================================================
// function: CommonBlockPool
// purpose:
//=======================================================================
const BOPTools_CommonBlockPool& BOPTools_DSFiller::CommonBlockPool () const
{
return myPaveFiller->CommonBlockPool();
}
//=======================================================================
// function: SplitShapesPool
// purpose:
//=======================================================================
const BOPTools_SplitShapesPool& BOPTools_DSFiller::SplitShapesPool() const
{
return myPaveFiller->SplitShapesPool();
}
//=======================================================================
// function: PaveFiller
// purpose:
//=======================================================================
const BOPTools_PaveFiller& BOPTools_DSFiller::PaveFiller() const
{
return *myPaveFiller;
}
//=======================================================================
// function: IsNewFiller
// purpose:
//=======================================================================
Standard_Boolean BOPTools_DSFiller::IsNewFiller() const
{
return myNewFiller;
}
//=======================================================================
// function: SetNewFiller
// purpose:
//=======================================================================
void BOPTools_DSFiller::SetNewFiller(const Standard_Boolean aFlag) const
{
BOPTools_DSFiller* pDSFiller=(BOPTools_DSFiller*)this;
pDSFiller->myNewFiller=aFlag;
}
//=======================================================================
// function: IsDone
// purpose:
//=======================================================================
Standard_Boolean BOPTools_DSFiller::IsDone()const
{
return myIsDone;
}
//
//=======================================================================
//function :TreatCompound
//purpose :
//=======================================================================
// Standard_Integer TreatCompound(const TopoDS_Shape& aS,
// TopoDS_Shape& aShapeResult)
Standard_Integer BOPTools_DSFiller::TreatCompound(const TopoDS_Shape& aS,
TopoDS_Shape& aShapeResult)
{
//
TopAbs_ShapeEnum aType, aTypeX;
//
aType=aS.ShapeType();
//
if (aType==TopAbs_COMPSOLID) {
aShapeResult=aS;
return 1;
}
//
if (aType!=TopAbs_COMPOUND) {
// Nothing to do
aShapeResult=aS;
return 2;
}
//
// 1 Fill the list by real shapes (solids, shells, wires, edges)
Standard_Boolean bCompSolidFound=Standard_False;
TopTools_ListOfShape aRL1, aRL;
FillList (aS, bCompSolidFound, aRL1);
if (bCompSolidFound) {
aShapeResult=aS;
return 3;
}
// 2
// Analyse the list and find the type
Standard_Integer i=0;
TopExp_Explorer anExp;
TopAbs_ShapeEnum aTypeCurrent=TopAbs_SHAPE,
aType0=TopAbs_SHAPE;
//aTypeCurrent=TopAbs_SHAPE;
TopTools_ListIteratorOfListOfShape anItL(aRL1);
for (; anItL.More(); anItL.Next(), i++) {
const TopoDS_Shape& aSX=anItL.Value();
aTypeX=aSX.ShapeType();
aTypeCurrent=GetTypeCurrent(aTypeX);
if (i==0) {
aType0=aTypeCurrent;
if (aType0==TopAbs_SHAPE) {
// Unknown shape type;
aShapeResult=aS;
return 4;
}
}
else {
if (aTypeCurrent!=aType0) {
// Heterogenous types occured;
aShapeResult=aS;
return 5;
}
}
//
// Fill the RL
if (aTypeCurrent==TopAbs_SOLID) {
anExp.Init(aSX, TopAbs_SHELL);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aSY=anExp.Current();
aRL.Append(aSY);
}
}
//
else if (aTypeCurrent==TopAbs_SHELL) {
if (aTypeX==TopAbs_FACE) {
aRL.Append(aSX);
}
else {
anExp.Init(aSX, TopAbs_FACE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aSY=anExp.Current();
aRL.Append(aSY);
}
}
}
//
else if (aTypeCurrent==TopAbs_WIRE) {
if (aTypeX==TopAbs_EDGE) {
aRL.Append(aSX);
}
else {
anExp.Init(aSX, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aSY=anExp.Current();
aRL.Append(aSY);
}
}
}
}
//
// Make Composite shape
//BRep_Builder aBB;
if (aType0==TopAbs_SOLID) {
BuildSolid(aRL, aShapeResult);
}
if (aType0==TopAbs_SHELL) {
BuildShell(aRL, aShapeResult);
}
if (aType0==TopAbs_WIRE) {
BuildWire(aRL, aShapeResult);
}
//OK
return 0;
}
//=======================================================================
//function : BuildSolid
//purpose :
//=======================================================================
void BuildSolid(const TopTools_ListOfShape& aRL,
TopoDS_Shape& aS)
{
BRep_Builder aBB;
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
TopTools_ListIteratorOfListOfShape anItL;
anItL.Initialize(aRL);
for (; anItL.More(); anItL.Next()) {
const TopoDS_Shape& aSX=anItL.Value();
aBB.Add(aSolid, TopoDS::Shell(aSX));
}
aS=aSolid;
}
//=======================================================================
//function : BuildShell
//purpose :
//=======================================================================
void BuildShell(const TopTools_ListOfShape& aRL,
TopoDS_Shape& aS)
{
BRep_Builder aBB;
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
TopTools_ListIteratorOfListOfShape anItL;
anItL.Initialize(aRL);
for (; anItL.More(); anItL.Next()) {
const TopoDS_Shape& aSX=anItL.Value();
aBB.Add(aShell, aSX);
}
aS=aShell;
}
//=======================================================================
//function : BuildWire
//purpose :
//=======================================================================
void BuildWire(const TopTools_ListOfShape& aRL,
TopoDS_Shape& aS)
{
BRep_Builder aBB;
TopoDS_Wire aWire;
aBB.MakeWire(aWire);
TopTools_ListIteratorOfListOfShape anItL;
anItL.Initialize(aRL);
for (; anItL.More(); anItL.Next()) {
const TopoDS_Shape& aSX=anItL.Value();
aBB.Add(aWire, aSX);
}
aS=aWire;
}
//=======================================================================
//function :FillList
//purpose :
//=======================================================================
void FillList(const TopoDS_Shape& aS,
Standard_Boolean& bCompSolidFound,
TopTools_ListOfShape& aResultList)
{
if (bCompSolidFound) {
return;
}
TopAbs_ShapeEnum aTypeX;
TopoDS_Iterator anIt;
anIt.Initialize(aS);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aSX=anIt.Value();
aTypeX=aSX.ShapeType();
//
if (aTypeX==TopAbs_COMPSOLID) {
bCompSolidFound=Standard_True;
return;
}
//
if (aTypeX==TopAbs_COMPOUND) {
FillList(aSX, bCompSolidFound, aResultList);
if (bCompSolidFound) {
return;
}
}
if (aTypeX!=TopAbs_COMPOUND) {
aResultList.Append(aSX);
}
}
}
//=======================================================================
//function :GetTypeCurrent
//purpose :
//=======================================================================
TopAbs_ShapeEnum GetTypeCurrent(const TopAbs_ShapeEnum aTypeX)
{
TopAbs_ShapeEnum aTypeCurrent=TopAbs_SHAPE;
if (aTypeX==TopAbs_SOLID) {
aTypeCurrent=TopAbs_SOLID;
}
if (aTypeX==TopAbs_SHELL || aTypeX==TopAbs_FACE ) {
aTypeCurrent=TopAbs_SHELL;
}
if (aTypeX==TopAbs_WIRE || aTypeX==TopAbs_EDGE ) {
aTypeCurrent=TopAbs_WIRE;
}
return aTypeCurrent;
}
//

View File

@@ -0,0 +1,16 @@
// File: BOPTools_DSFiller.lxx
// Created: Fri Jun 11 14:57:42 2004
// Author: Mikhail KLOKOV
// <mkk@kurox>
inline const TColStd_DataMapOfIntegerListOfInteger& BOPTools_DSFiller::SplitFacePool() const
{
return mySplitFacePool;
}
inline TColStd_DataMapOfIntegerListOfInteger& BOPTools_DSFiller::ChangeSplitFacePool()
{
return mySplitFacePool;
}

View File

@@ -0,0 +1,44 @@
-- File: BooleanOperations_EEInterference.cdl
-- Created: Tue Nov 21 15:41:16 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class EEInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose:
-- class for storing an Edge/Edge
--- interference
---
uses
CommonPrt from IntTools
is
Create
returns EEInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1, anIndex2: Integer from Standard;
aCPart:CommonPrt from IntTools)
returns EEInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
--- aCPart see IntTools_CommonPrt for details
---
CommonPrt(me)
returns CommonPrt from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
fields
myCommonPart: CommonPrt from IntTools;
end EEInterference;

View File

@@ -0,0 +1,38 @@
// File: BOPTools_EEInterference.cxx
// Created: Tue Nov 21 15:42:17 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_EEInterference.ixx>
//=======================================================================
//function : BOPTools_EEInterference
//purpose :
//=======================================================================
BOPTools_EEInterference::BOPTools_EEInterference()
:
BOPTools_ShapeShapeInterference(0,0)
{}
//=======================================================================
//function : BOPTools_ESInterference
//purpose :
//=======================================================================
BOPTools_EEInterference::BOPTools_EEInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2,
const IntTools_CommonPrt& aCPart)
:
BOPTools_ShapeShapeInterference(anIndex1,anIndex2)
{
myCommonPart=aCPart;
}
//=======================================================================
//function : CommonPrt
//purpose :
//=======================================================================
const IntTools_CommonPrt& BOPTools_EEInterference::CommonPrt() const
{
return myCommonPart;
}

View File

@@ -0,0 +1,42 @@
-- File: BOPTools_ESInterference.cdl
-- Created: Tue Nov 21 15:35:03 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class ESInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose: class for storing an Edge/Face
--- interference
---
uses
CommonPrt from IntTools
is
Create
returns ESInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1: Integer from Standard;
anIndex2: Integer from Standard;
aCPart:CommonPrt from IntTools)
returns ESInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
--- aCPart see IntTools_CommonPrt for details
---
CommonPrt(me)
returns CommonPrt from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
fields
myCommonPart: CommonPrt from IntTools;
end ESInterference;

View File

@@ -0,0 +1,39 @@
// File: BOPTools_ESInterference.cxx
// Created: Tue Nov 21 15:35:58 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_ESInterference.ixx>
//=======================================================================
//function : BOPTools_ESInterference
//purpose :
//=======================================================================
BOPTools_ESInterference::BOPTools_ESInterference()
:
BOPTools_ShapeShapeInterference(0,0)
{}
//=======================================================================
//function : BOPTools_ESInterference
//purpose :
//=======================================================================
BOPTools_ESInterference::BOPTools_ESInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2,
const IntTools_CommonPrt& aCPart)
:
BOPTools_ShapeShapeInterference(anIndex1,anIndex2)
{
myCommonPart=aCPart;
}
//=======================================================================
//function : CommonPrt
//purpose :
//=======================================================================
const IntTools_CommonPrt& BOPTools_ESInterference::CommonPrt() const
{
return myCommonPart;
}

View File

@@ -0,0 +1,69 @@
-- File: BOPTools_Interference.cdl
-- Created: Tue Nov 21 11:28:00 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class Interference from BOPTools
---Purpose: class for storing information about an interference
--- that takes place between given shape and shape
--- with DS-index =aWith
uses
KindOfInterference from BooleanOperations
is
Create
returns Interference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (aWith :Integer from Standard;
aType :KindOfInterference from BooleanOperations;
anIndex :Integer from Standard)
returns Interference from BOPTools;
---Purpose: constructor
--- aWith - DS-index for the opposite shape
--- aType - the type of the interference
--- anIndex- the index of the result in corresponding
--- interference table (if the result is computed
--- but there is no result -> anIndex=0)
---
SetWith (me:out; aWith :Integer from Standard);
---Purpose:
--- Modifier
---
SetType (me:out; aType : KindOfInterference from BooleanOperations);
---Purpose:
--- Modifier
---
SetIndex (me:out; anIndex :Integer from Standard);
---Purpose:
--- Modifier
---
With (me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Type (me)
returns KindOfInterference from BooleanOperations;
---Purpose:
--- Selector
---
Index (me)
returns Integer from Standard;
---Purpose:
--- Selector
---
fields
myWith : Integer from Standard;
myType : KindOfInterference from BooleanOperations;
myIndex : Integer from Standard; --< index in corresp.interference table
end Interference;

View File

@@ -0,0 +1,85 @@
// File: BOPTools_Interference.cxx
// Created: Tue Nov 21 11:44:31 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Interference.ixx>
//=======================================================================
//function : BOPTools_Interference::BOPTools_Interference
//purpose :
//=======================================================================
BOPTools_Interference::BOPTools_Interference()
:
myWith(0),
myType(BooleanOperations_UnknownInterference),
myIndex(0)
{
}
//=======================================================================
//function : BOPTools_Interference::BOPTools_Interference
//purpose :
//=======================================================================
BOPTools_Interference::BOPTools_Interference(const Standard_Integer aWith,
const BooleanOperations_KindOfInterference aType,
const Standard_Integer anIndex)
:
myWith(aWith),
myType(aType),
myIndex(anIndex)
{
}
//=======================================================================
//function : SetWith
//purpose :
//=======================================================================
void BOPTools_Interference::SetWith(const Standard_Integer aWith)
{
myWith=aWith;
}
//=======================================================================
//function : SetType
//purpose :
//=======================================================================
void BOPTools_Interference::SetType(const BooleanOperations_KindOfInterference aType)
{
myType=aType;
}
//=======================================================================
//function : SetIndex
//purpose :
//=======================================================================
void BOPTools_Interference::SetIndex(const Standard_Integer anIndex)
{
myIndex=anIndex;
}
//=======================================================================
//function : With
//purpose :
//=======================================================================
Standard_Integer BOPTools_Interference::With() const
{
return myWith;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
BooleanOperations_KindOfInterference BOPTools_Interference::Type() const
{
return myType;
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
Standard_Integer BOPTools_Interference::Index() const
{
return myIndex;
}

View File

@@ -0,0 +1,89 @@
-- File: BOPTools_InterferenceLine.cdl
-- Created: Tue Nov 21 11:54:46 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class InterferenceLine from BOPTools
---Purpose: class for storing information about all
--- interferences for given shape.
--- So, for each shape in the DS, we will have
--- the following interference list
--- (i1, t1, r1), (i2, t2, r2),...(iN, tN, rN),
--- where
--- (iN, tN, rN) - object of type BOPTools_Interference
--- The class BOPTools_InterferenceLine is dedicated
--- to provide convinient tools to manage this info.
---
uses
KindOfInterference from BooleanOperations,
ListOfInterference from BOPTools,
Interference from BOPTools
is
Create
returns InterferenceLine from BOPTools;
---Purpose:
--- Empty constructor
---
GetOnType(me;
aType :KindOfInterference from BooleanOperations)
returns ListOfInterference from BOPTools;
---C++: return const &
---Purpose:
--- Returns info. list for interferences of given type
---
IsComputed(me;
aWith :Integer from Standard;
aType :KindOfInterference from BooleanOperations)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the interference of type <aType>
--- with the shape <aWith> has already been computed.
---
AddInterference (me:out;
anInterference :Interference from BOPTools);
---Purpose:
--- Adds info. about the Interference to the list
---
AddInterference (me:out;
aWith :Integer from Standard;
aType :KindOfInterference from BooleanOperations;
anIndex:Integer from Standard);
---Purpose:
--- Adds info. about the Interference to the list
---
List(me)
returns ListOfInterference from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
RealList(me)
returns ListOfInterference from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
HasInterference(me)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the list contains at least one interference
--- with non-empty result
---
fields
myList : ListOfInterference from BOPTools;
mySSList : ListOfInterference from BOPTools;
myESList : ListOfInterference from BOPTools;
myVSList : ListOfInterference from BOPTools;
myEEList : ListOfInterference from BOPTools;
myVEList : ListOfInterference from BOPTools;
myVVList : ListOfInterference from BOPTools;
myEmptyList : ListOfInterference from BOPTools;
end InterferenceLine;

View File

@@ -0,0 +1,207 @@
// File: BOPTools_InterferenceLine.cxx
// Created: Tue Nov 21 12:19:30 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_InterferenceLine.ixx>
#include <BOPTools_ListIteratorOfListOfInterference.hxx>
//=======================================================================
//function : BOPTools_InterferenceLine::BOPTools_InterferenceLine
//purpose :
//=======================================================================
BOPTools_InterferenceLine::BOPTools_InterferenceLine() {}
//=======================================================================
//function : RealList
//purpose :
//=======================================================================
const BOPTools_ListOfInterference& BOPTools_InterferenceLine::RealList() const
{
Standard_Integer anInd;
List();
BOPTools_ListOfInterference aTmpList;
BOPTools_ListIteratorOfListOfInterference anIt;
anIt.Initialize(myList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
aTmpList.Append(anInterference);
}
//
BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
pList->Clear();
//
anIt.Initialize(aTmpList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
anInd=anInterference.Index();
if (anInd) {
pList->Append(anInterference);
}
}
return myList;
}
//=======================================================================
//function : List
//purpose :
//=======================================================================
const BOPTools_ListOfInterference& BOPTools_InterferenceLine::List () const
{
BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
pList->Clear();
BOPTools_ListIteratorOfListOfInterference anIt;
anIt.Initialize(mySSList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
anIt.Initialize(myESList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
anIt.Initialize(myVSList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
anIt.Initialize(myEEList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
anIt.Initialize(myVEList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
anIt.Initialize(myVVList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
pList->Append(anInterference);
}
return myList;
}
//=======================================================================
//function : GetOnType
//purpose :
//=======================================================================
const BOPTools_ListOfInterference& BOPTools_InterferenceLine::GetOnType
(const BooleanOperations_KindOfInterference theType) const
{
switch (theType) {
case BooleanOperations_SurfaceSurface:
return mySSList;
case BooleanOperations_EdgeSurface:
return myESList;
case BooleanOperations_VertexSurface:
return myVSList;
case BooleanOperations_EdgeEdge:
return myEEList;
case BooleanOperations_VertexEdge:
return myVEList;
case BooleanOperations_VertexVertex:
return myVVList;
default:
return myEmptyList;
}
}
//=======================================================================
//function : HasInterference
//purpose :
//=======================================================================
Standard_Boolean BOPTools_InterferenceLine::HasInterference () const
{
Standard_Integer anInd;
Standard_Boolean bFlag=Standard_False;
BOPTools_ListIteratorOfListOfInterference anIt;
//
List();
//
anIt.Initialize(myList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
anInd=anInterference.Index();
if (anInd) {
return !bFlag;
}
}
return bFlag;
}
//=======================================================================
//function : IsComputed
//purpose :
//=======================================================================
Standard_Boolean BOPTools_InterferenceLine::IsComputed
(const Standard_Integer theWith,
const BooleanOperations_KindOfInterference theType)const
{
BooleanOperations_KindOfInterference aType;
Standard_Integer aWith, anInd;
const BOPTools_ListOfInterference& aList=GetOnType(theType);
BOPTools_ListIteratorOfListOfInterference anIt(aList);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
aType=anInterference.Type();
aWith=anInterference.With();
//
anInd=anInterference.Index();
//
if ((aType==theType && aWith==theWith) && anInd) {
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : AddInterference
//purpose :
//=======================================================================
void BOPTools_InterferenceLine::AddInterference(const BOPTools_Interference& anInterference)
{
Standard_Integer aWith, anInd;
BooleanOperations_KindOfInterference aType;
aWith=anInterference.With();
aType=anInterference.Type();
anInd=anInterference.Index();
AddInterference(aWith, aType, anInd);
}
//=======================================================================
//function : AddInterference
//purpose :
//=======================================================================
void BOPTools_InterferenceLine::AddInterference(const Standard_Integer aWith,
const BooleanOperations_KindOfInterference aType,
const Standard_Integer anIndex)
{
BOPTools_Interference anInterference(aWith, aType, anIndex);
const BOPTools_ListOfInterference& aList=GetOnType(aType);
BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*) &aList;
pList->Append(anInterference);
}

View File

@@ -0,0 +1,172 @@
-- File: BOPTools_InterferencePool.cdl
-- Created: Fri Jan 26 12:00:38 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class InterferencePool from BOPTools
---Purpose:
-- Class for storing information about
--- results of all interferences for all shapes
uses
ShapesDataStructure from BooleanOperations,
PShapesDataStructure from BooleanOperations,
KindOfInterference from BooleanOperations,
CArray1OfInterferenceLine from BOPTools,
CArray1OfSSInterference from BOPTools,
CArray1OfESInterference from BOPTools,
CArray1OfVSInterference from BOPTools,
CArray1OfEEInterference from BOPTools,
CArray1OfVEInterference from BOPTools,
CArray1OfVVInterference from BOPTools,
PShapeShapeInterference from BOPTools
is
Create
returns InterferencePool from BOPTools ;
---Purpose:
--- Empty constructor
---
Create (aDS:ShapesDataStructure from BooleanOperations)
returns InterferencePool from BOPTools ;
---Purpose:
--- Constructor
---
SetDS (me:out;aDS:ShapesDataStructure from BooleanOperations);
---Purpose:
--- Modifier
---
DS(me)
returns PShapesDataStructure from BooleanOperations;
---Purpose:
--- Selector
---
HasInterference (me;
anInd :Integer from Standard)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the shape with DS_index <anInd>
--- has at least one interference with non-empty result
---
IsComputed (me;
anInd1 : Integer from Standard;
anInd2 : Integer from Standard)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the interference between shapes
--- <anInd1> and <anInd2> has already been computed.
---
SortTypes (me;
anInd1:in out Integer from Standard;
anInd2:in out Integer from Standard);
---Purpose:
--- Sorts types of shapes <anInd1> and <anInd2> in increasing order
---
InterferenceType (me;
anInd1: Integer from Standard;
anInd2: Integer from Standard)
returns KindOfInterference from BooleanOperations;
---Purpose:
--- Gets the type of interference in accordance with the types of
--- shapes <anInd1> and <anInd2>
---
AddInterference (me:out;
anInd1: Integer from Standard;
anInd2: Integer from Standard;
aType: KindOfInterference from BooleanOperations;
anIndex: Integer from Standard);
---Purpose:
--- Adds the info about interference in InterferenceLine-s for
--- shapes <anInd1> and <anInd2>
---
InterferenceTable (me)
returns CArray1OfInterferenceLine from BOPTools;
---C++: return const&
---Purpose:
--- Returns the reference to complete array of interference line-s
---
SSInterferences (me:out)
returns CArray1OfSSInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to array Of F/F interferences
---
ESInterferences (me:out)
returns CArray1OfESInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to array Of E/F interferences
---
VSInterferences (me:out)
returns CArray1OfVSInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to array Of V/F interferences
---
EEInterferences (me:out)
returns CArray1OfEEInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to arrray Of E/E interferences
---
VEInterferences (me:out)
returns CArray1OfVEInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to arrray Of V/E interferences
---
VVInterferences (me:out)
returns CArray1OfVVInterference from BOPTools;
---C++: return &
---Purpose:
--- Returns the reference to arrray Of V/V interferences
---
--------------
SSInterfs (me)
returns CArray1OfSSInterference from BOPTools;
---C++: return const &
ESInterfs (me)
returns CArray1OfESInterference from BOPTools;
---C++: return const &
VSInterfs (me)
returns CArray1OfVSInterference from BOPTools;
---C++: return const &
EEInterfs (me)
returns CArray1OfEEInterference from BOPTools;
---C++: return const &
VEInterfs (me)
returns CArray1OfVEInterference from BOPTools;
---C++: return const &
VVInterfs (me)
returns CArray1OfVVInterference from BOPTools;
---C++: return const &
GetInterference (me;
anIndex: Integer from Standard;
aType : KindOfInterference from BooleanOperations)
returns PShapeShapeInterference from BOPTools;
fields
myDS : PShapesDataStructure from BooleanOperations;
myNbSourceShapes : Integer from Standard;
myInterferenceTable: CArray1OfInterferenceLine from BOPTools;
mySSInterferences : CArray1OfSSInterference from BOPTools;
myESInterferences : CArray1OfESInterference from BOPTools;
myVSInterferences : CArray1OfVSInterference from BOPTools;
myEEInterferences : CArray1OfEEInterference from BOPTools;
myVEInterferences : CArray1OfVEInterference from BOPTools;
myVVInterferences : CArray1OfVVInterference from BOPTools;
end InterferencePool;

View File

@@ -0,0 +1,362 @@
// File: BOPTools_InterferencePool.cxx
// Created: Fri Jan 26 12:17:16 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_InterferencePool.ixx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
#include <BOPTools_VEInterference.hxx>
#include <BOPTools_VVInterference.hxx>
#include <BOPTools_VSInterference.hxx>
#include <BOPTools_EEInterference.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOPTools_InterferenceLine.hxx>
#include <IntTools_EdgeFace.hxx>
#include <BOPTools_ESInterference.hxx>
//=======================================================================
//function : BOPTools_InterferencePool
//purpose :
//=======================================================================
BOPTools_InterferencePool::BOPTools_InterferencePool()
{
myDS=NULL;
myNbSourceShapes=0;
}
//=======================================================================
//function : BOPTools_InterferencePool
//purpose :
//=======================================================================
BOPTools_InterferencePool::BOPTools_InterferencePool (const BooleanOperations_ShapesDataStructure& aDS)
{
SetDS(aDS);
}
//=======================================================================
//function : SetDS
//purpose :
//=======================================================================
void BOPTools_InterferencePool::SetDS(const BooleanOperations_ShapesDataStructure& aDS)
{
void* p=(void*) &aDS;
myDS=(BooleanOperations_ShapesDataStructure*) p;
myNbSourceShapes= myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool();
myInterferenceTable.Resize (myNbSourceShapes);
}
//=======================================================================
//function : DS
//purpose :
//=======================================================================
BooleanOperations_PShapesDataStructure BOPTools_InterferencePool::DS() const
{
return myDS;
}
//=======================================================================
//function : HasInterference
//purpose :
//=======================================================================
Standard_Boolean BOPTools_InterferencePool::HasInterference(const Standard_Integer anInd1)const
{
const BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(anInd1);
Standard_Boolean bFlag=aWhatLine.HasInterference();
return bFlag;
}
//=======================================================================
//function : IsComputed
//purpose :
//=======================================================================
Standard_Boolean BOPTools_InterferencePool::IsComputed(const Standard_Integer anInd1,
const Standard_Integer anInd2) const
{
BooleanOperations_KindOfInterference theType;
theType=InterferenceType(anInd1, anInd2);
if (theType==BooleanOperations_UnknownInterference) {
return Standard_False;
}
const BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(anInd1);
Standard_Boolean aFlag=aWhatLine.IsComputed(anInd2, theType);
return aFlag;
}
//===========================================================================
//function : AddInterference
//purpose :
//===========================================================================
void BOPTools_InterferencePool::AddInterference (const Standard_Integer theWhat,
const Standard_Integer theWith,
const BooleanOperations_KindOfInterference theType,
const Standard_Integer theIndexOfInterference)
{
BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(theWhat);
aWhatLine.AddInterference(theWith, theType, theIndexOfInterference);
BOPTools_InterferenceLine& aWithLine=myInterferenceTable(theWith);
aWithLine.AddInterference(theWhat, theType, theIndexOfInterference);
}
//=======================================================================
//function : InterferenceType
//purpose :
//=======================================================================
BooleanOperations_KindOfInterference
BOPTools_InterferencePool::InterferenceType(const Standard_Integer theWhat,
const Standard_Integer theWith) const
{
BooleanOperations_KindOfInterference theType;
Standard_Integer aWhat, aWith;
TopAbs_ShapeEnum aType1, aType2;
aWhat=theWhat;
aWith=theWith;
SortTypes(aWhat, aWith);
aType1= myDS->GetShapeType(aWhat),
aType2= myDS->GetShapeType(aWith);
if (aType1==TopAbs_VERTEX && aType2==TopAbs_VERTEX) {
theType=BooleanOperations_VertexVertex;
}
else if (aType1==TopAbs_VERTEX && aType2==TopAbs_EDGE) {
theType=BooleanOperations_VertexEdge;
}
else if (aType1==TopAbs_VERTEX && aType2==TopAbs_FACE) {
theType=BooleanOperations_VertexSurface;
}
else if (aType1==TopAbs_EDGE && aType2==TopAbs_EDGE) {
theType=BooleanOperations_EdgeEdge;
}
else if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE) {
theType=BooleanOperations_EdgeSurface;
}
else if (aType1==TopAbs_FACE && aType2==TopAbs_FACE) {
theType=BooleanOperations_SurfaceSurface;
}
else {
theType=BooleanOperations_UnknownInterference;
}
return theType;
}
//=======================================================================
//function : SortTypes
//purpose :
//=======================================================================
void BOPTools_InterferencePool::SortTypes(Standard_Integer& theWhat,
Standard_Integer& theWith) const
{
Standard_Boolean aReverseFlag=Standard_True;
TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat),
aType2= myDS->GetShapeType(theWith);
if (aType1==aType2)
return;
if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){
aReverseFlag=Standard_False;
}
if (aType1==TopAbs_VERTEX &&
(aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) {
aReverseFlag=Standard_False;
}
Standard_Integer aWhat, aWith;
aWhat=(aReverseFlag) ? theWith : theWhat;
aWith=(aReverseFlag) ? theWhat : theWith;
theWhat=aWhat;
theWith=aWith;
}
//===========================================================================
//function : InterferenceTable
//purpose :
//===========================================================================
const BOPTools_CArray1OfInterferenceLine&
BOPTools_InterferencePool::InterferenceTable()const
{
return myInterferenceTable;
}
//===========================================================================
//function : SSInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfSSInterference& BOPTools_InterferencePool::SSInterferences()
{
return mySSInterferences;
}
//===========================================================================
//function : ESInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfESInterference& BOPTools_InterferencePool::ESInterferences()
{
return myESInterferences;
}
//===========================================================================
//function : VSInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfVSInterference& BOPTools_InterferencePool::VSInterferences()
{
return myVSInterferences;
}
//===========================================================================
//function : EEInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfEEInterference& BOPTools_InterferencePool::EEInterferences()
{
return myEEInterferences;
}
//===========================================================================
//function : VEInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfVEInterference& BOPTools_InterferencePool::VEInterferences()
{
return myVEInterferences;
}
//===========================================================================
//function : VVInterferences
//purpose :
//===========================================================================
BOPTools_CArray1OfVVInterference& BOPTools_InterferencePool::VVInterferences()
{
return myVVInterferences;
}
////////////////////////
//===========================================================================
//function : SSInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfSSInterference& BOPTools_InterferencePool::SSInterfs()const
{
return mySSInterferences;
}
//===========================================================================
//function : ESInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfESInterference& BOPTools_InterferencePool::ESInterfs()const
{
return myESInterferences;
}
//===========================================================================
//function : VSInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfVSInterference& BOPTools_InterferencePool::VSInterfs()const
{
return myVSInterferences;
}
//===========================================================================
//function : EEInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfEEInterference& BOPTools_InterferencePool::EEInterfs()const
{
return myEEInterferences;
}
//===========================================================================
//function : VEInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfVEInterference& BOPTools_InterferencePool::VEInterfs()const
{
return myVEInterferences;
}
//===========================================================================
//function : VVInterfs
//purpose :
//===========================================================================
const BOPTools_CArray1OfVVInterference& BOPTools_InterferencePool::VVInterfs()const
{
return myVVInterferences;
}
//===========================================================================
//function : GetInterference
//purpose :
//===========================================================================
BOPTools_PShapeShapeInterference
BOPTools_InterferencePool::GetInterference(const Standard_Integer anIndex,
const BooleanOperations_KindOfInterference aType)const
{
Standard_Integer aNb;
BOPTools_PShapeShapeInterference pI=NULL;
switch (aType) {
//
case BooleanOperations_SurfaceSurface:
aNb=mySSInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&mySSInterferences(anIndex);
}
break;
//
case BooleanOperations_EdgeSurface:
aNb=myESInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&myESInterferences(anIndex);
}
break;
//
case BooleanOperations_VertexSurface:
aNb=myVSInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&myVSInterferences(anIndex);
}
break;
//
case BooleanOperations_EdgeEdge:
aNb=myEEInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&myEEInterferences(anIndex);
}
break;
//
case BooleanOperations_VertexEdge:
aNb=myVEInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&myVEInterferences(anIndex);
}
break;
//
case BooleanOperations_VertexVertex:
aNb=myVVInterferences.Extent();
if (anIndex > 0 && anIndex <= aNb) {
pI=(BOPTools_PShapeShapeInterference)&myVVInterferences(anIndex);
}
break;
//
case BooleanOperations_UnknownInterference:
default:
break;
}
return pI;
}

View File

@@ -0,0 +1,146 @@
-- File: BOPTools_IteratorOfCoupleOfShape.cdl
-- Created: Mon Nov 27 16:31:08 2000
-- Author: Michael KLOKOV
-- <mkk@nizhnox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class IteratorOfCoupleOfShape from BOPTools
---Purpose: The class IteratorOfCoupleOfShape provides the iteration
--- on the couples of shapes stored in ShapesDataStructure
--- according to the given types of shapes and
--- status of their intersection.
--- The statuses are stored in 2 dimension array.
uses
ShapeEnum from TopAbs,
HArray2OfIntersectionStatus from BOPTools,
PShapesDataStructure from BooleanOperations,
IntersectionStatus from BOPTools,
ListOfCoupleOfInteger from BOPTools,
ListIteratorOfListOfCoupleOfInteger from BOPTools,
NoSuchObject from Standard
raises NoSuchObject from Standard
is
Create
returns IteratorOfCoupleOfShape from BOPTools;
---Purpose:
--- Empty Constructor
---
Create(PDS: PShapesDataStructure from BooleanOperations;
Type1: ShapeEnum from TopAbs;
Type2: ShapeEnum from TopAbs)
returns IteratorOfCoupleOfShape from BOPTools;
---Purpose:
--- Initializes iterator by ShapesDataStructure and
--- shape types
---
Destroy(me: in out) is virtual;
---C++: alias "Standard_EXPORT virtual ~BOPTools_IteratorOfCoupleOfShape(){Destroy();}"
Initialize(me: in out; Type1: ShapeEnum from TopAbs;
Type2: ShapeEnum from TopAbs)
raises NoSuchObject from Standard
is virtual;
---Purpose:
--- Initializes iterator with shape types.
--- The iterator uses PDS assigned in constructor or in SetDataStructure().
--- Raises the exception if myPDS is null.
---
SetDataStructure(me: in out; PDS: PShapesDataStructure from BooleanOperations)
raises
NoSuchObject from Standard;
---Purpose:
--- Initialize iterator with ShapeDataStructure.
---
More(me)
returns Boolean from Standard
is virtual;
---Purpose:
--- Returns True if there are still not
--- treated couples of shapes
---
Next(me: in out)
is virtual;
---Purpose:
--- Moves to the next couple of iteration
---
Current(me; Index1: in out Integer from Standard;
Index2: in out Integer from Standard;
WithSubShape: out Boolean from Standard)
is virtual;
---Purpose:
--- Returns current couple of indices and
--- flag WithSubShape which is true
--- if bounding boxes of subshapes
--- are intersected
---
ListOfCouple(me)
returns ListOfCoupleOfInteger from BOPTools;
---C++: return const &
---Purpose:
--- Returns a list of couples of shape indices
--- according to shape types by which
--- the iterator was initialized
---
MoreP(me)
returns Boolean from Standard
is protected;
NextP(me: in out)
is protected;
CurrentP(me;Index1: in out Integer from Standard;
Index2: in out Integer from Standard)
raises NoSuchObject from Standard
is protected;
SetIntersectionStatus(me: in out; Index1: Integer from Standard;
Index2: Integer from Standard;
theStatus: IntersectionStatus from BOPTools);
---Purpose:
--- Sets status to array according to Index1 and Index2
---
GetTableOfIntersectionStatus(me)
returns HArray2OfIntersectionStatus from BOPTools;
---C++: return const &
---Purpose:
--- Returns 2 dimension array of intersection statuses
---
DumpTableOfIntersectionStatus(me);
---Purpose:
--- For internal use
---
fields
myPDS: PShapesDataStructure from BooleanOperations is protected;
myTableOfStatus: HArray2OfIntersectionStatus from BOPTools is protected;
myCurrentIndex1: Integer from Standard is protected;
myCurrentIndex2: Integer from Standard is protected;
myType1: ShapeEnum from TopAbs is protected;
myType2: ShapeEnum from TopAbs is protected;
--
myFirstLowerIndex :Integer from Standard is protected;
myFirstUpperIndex :Integer from Standard is protected;
mySecondLowerIndex:Integer from Standard is protected;
mySecondUpperIndex:Integer from Standard is protected;
myListOfCouple :ListOfCoupleOfInteger from BOPTools is protected;
myIterator :ListIteratorOfListOfCoupleOfInteger from BOPTools is protected;
--
end IteratorOfCoupleOfShape from BOPTools;

View File

@@ -0,0 +1,279 @@
#include <BOPTools_IteratorOfCoupleOfShape.ixx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BOPTools_RoughShapeIntersector.hxx>
#include <BOPTools_CoupleOfInteger.hxx>
// ================================================================================================
// function: Constructor
// ================================================================================================
BOPTools_IteratorOfCoupleOfShape::BOPTools_IteratorOfCoupleOfShape()
:
myCurrentIndex1(-1),
myCurrentIndex2(-1),
myType1(TopAbs_SHAPE),
myType2(TopAbs_SHAPE),
myFirstLowerIndex(1),
myFirstUpperIndex(0),
mySecondLowerIndex(1),
mySecondUpperIndex(0)
{
myPDS = NULL;
}
// ================================================================================================
// function: Constructor
// ================================================================================================
BOPTools_IteratorOfCoupleOfShape::BOPTools_IteratorOfCoupleOfShape(const BooleanOperations_PShapesDataStructure& PDS,
const TopAbs_ShapeEnum Type1,
const TopAbs_ShapeEnum Type2)
:
myCurrentIndex1(-1),
myCurrentIndex2(-1),
myType1(TopAbs_SHAPE),
myType2(TopAbs_SHAPE)
{
SetDataStructure(PDS);
Initialize(Type1, Type2);
}
// ================================================================================================
// function: virtual destructor
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::Destroy()
{
}
// ================================================================================================
// function: SetDataStructure
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::SetDataStructure(const BooleanOperations_PShapesDataStructure& PDS)
{
if(PDS==NULL) {
Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::SetDataStructure: PDS==NULL");
}
myListOfCouple.Clear();
myPDS = PDS;
BOPTools_RoughShapeIntersector aRoughIntersector(myPDS);
aRoughIntersector.Perform();
if(aRoughIntersector.IsDone()) {
myTableOfStatus = aRoughIntersector.TableOfStatus();
} else {
Handle(BOPTools_HArray2OfIntersectionStatus) anemptyhandle;
myTableOfStatus = anemptyhandle;
}
}
// ================================================================================================
// function: Initialize
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1,
const TopAbs_ShapeEnum Type2)
{
if(myPDS==NULL) {
Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL");
}
myType1 = Type1;
myType2 = Type2;
myCurrentIndex1 = -1;
myCurrentIndex2 = -1;
//
myFirstLowerIndex=1;
myFirstUpperIndex=myPDS->NumberOfShapesOfTheObject();
mySecondLowerIndex=myFirstUpperIndex+1;
mySecondUpperIndex=myFirstUpperIndex+myPDS->NumberOfShapesOfTheTool();
NextP();
Standard_Integer n1, n2;
myListOfCouple.Clear();
for (; MoreP(); NextP()) {
CurrentP(n1, n2);
BOPTools_CoupleOfInteger aCouple(n1, n2);
myListOfCouple.Append(aCouple);
}
myIterator.Initialize(myListOfCouple);
}
//=======================================================================
// function: More
// purpose:
//=======================================================================
Standard_Boolean BOPTools_IteratorOfCoupleOfShape::More()const
{
return myIterator.More();
}
//=======================================================================
// function: Next
// purpose:
//=======================================================================
void BOPTools_IteratorOfCoupleOfShape::Next()
{
myIterator.Next();
}
//=======================================================================
// function: Current
// purpose:
//=======================================================================
void BOPTools_IteratorOfCoupleOfShape::Current(Standard_Integer& Index1,
Standard_Integer& Index2,
Standard_Boolean& WithSubShape) const
{
WithSubShape = Standard_False;
const BOPTools_CoupleOfInteger& aCouple=myIterator.Value();
aCouple.Couple(Index1, Index2);
BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(Index1, Index2);
if(aStatus == BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED) {
WithSubShape = Standard_True;
}
}
//=======================================================================
// function: ListOfCouple
// purpose:
//=======================================================================
const BOPTools_ListOfCoupleOfInteger& BOPTools_IteratorOfCoupleOfShape::ListOfCouple() const
{
return myListOfCouple;
}
// ================================================================================================
// function: NextP
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::NextP()
{
if(myPDS==NULL) {
myCurrentIndex1 = -1;
myCurrentIndex2 = -1;
return;
}
Standard_Boolean couplefound, IsValidTableOfStatus = Standard_False;
Standard_Integer stopedindex1, stopedindex2, starti, i, startj, j;
TopAbs_ShapeEnum aTypei, aTypej;
stopedindex1 = myCurrentIndex1;
stopedindex2 = myCurrentIndex2;
if(!myTableOfStatus.IsNull()) {
IsValidTableOfStatus = Standard_True;
}
myCurrentIndex1 = -1;
myCurrentIndex2 = -1;
couplefound = Standard_False;
starti = stopedindex1;
if(starti < 0){
starti = myFirstLowerIndex;
}
for(i = starti; !couplefound && i<=myFirstUpperIndex; i++) {
startj = mySecondLowerIndex;
if(i==stopedindex1 && (stopedindex2 >= 0)) {
startj = stopedindex2 + 1;
}
for(j = startj; !couplefound && j<=mySecondUpperIndex; j++) {
aTypei=myPDS->GetShapeType(i);
aTypej=myPDS->GetShapeType(j);
if(((aTypei == myType1) && (aTypej == myType2)) ||
((aTypei == myType2) && (aTypej == myType1))) {
myCurrentIndex1 = i;
myCurrentIndex2 = j;
//
couplefound = Standard_True;
if(IsValidTableOfStatus) {
BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(i, j);
if(aStatus==BOPTools_INTERSECTED || aStatus==BOPTools_NONINTERSECTED) {
myCurrentIndex1 = -1;
myCurrentIndex2 = -1;
couplefound = Standard_False;
}
}
}
}
}
//}
}
// ================================================================================================
// function: More
// ================================================================================================
Standard_Boolean BOPTools_IteratorOfCoupleOfShape::MoreP() const
{
if((myCurrentIndex1 < 0) || (myCurrentIndex2 < 0))
return Standard_False;
return Standard_True;
}
// ================================================================================================
// function: Current
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::CurrentP(Standard_Integer& Index1,
Standard_Integer& Index2) const
{
if((myCurrentIndex1 < 0) || (myCurrentIndex2 < 0)) {
Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::Current");
}
Index1 = myCurrentIndex1;
Index2 = myCurrentIndex2;
}
// ================================================================================================
// function: SetIntersectionStatus
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::SetIntersectionStatus(const Standard_Integer Index1,
const Standard_Integer Index2,
const BOPTools_IntersectionStatus theStatus)
{
if((Index1 >= myTableOfStatus->LowerRow()) &&
(Index1 <= myTableOfStatus->UpperRow()) &&
(Index2 >= myTableOfStatus->LowerCol()) &&
(Index2 <= myTableOfStatus->UpperCol())) {
myTableOfStatus->ChangeValue(Index1, Index2) = theStatus;
}
}
// ================================================================================================
// function: GetTableOfIntersectionStatus
// ================================================================================================
const Handle(BOPTools_HArray2OfIntersectionStatus)&
BOPTools_IteratorOfCoupleOfShape::GetTableOfIntersectionStatus() const
{
return myTableOfStatus;
}
// ================================================================================================
// function: DumpTableOfIntersectionStatus
// ================================================================================================
void BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus() const
{
cout << "*BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus.BEGIN*" << endl;
cout << "myTableOfStatus.LowerRow="<< myTableOfStatus->LowerRow() << endl;
cout << "myTableOfStatus.UpperRow="<< myTableOfStatus->UpperRow() << endl;
cout << "myTableOfStatus.LowerCol()="<< myTableOfStatus->LowerCol() << endl;
cout << "myTableOfStatus.UpperCol()="<< myTableOfStatus->UpperCol() << endl;
for(Standard_Integer k=myTableOfStatus->LowerCol(); k<=myTableOfStatus->UpperCol(); k++) {
cout << k << " ";
}
cout << endl;
for(Standard_Integer i=myTableOfStatus->LowerRow(); i<=myTableOfStatus->UpperRow(); i++) {
for(Standard_Integer j=myTableOfStatus->LowerCol(); j<=myTableOfStatus->UpperCol(); j++) {
cout << myTableOfStatus->Value(i, j) << " ";
}
cout << endl;
}
cout << "*BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus.END*" << endl;
}

View File

@@ -0,0 +1,41 @@
-- File: BOPTools_PCurveMaker.cdl
-- Created: Wed May 30 09:42:36 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PCurveMaker from BOPTools
---Purpose:
-- Class provides computation p-curves for the edges and theirs
--- split parts
uses
PPaveFiller from BOPTools,
PaveFiller from BOPTools,
PInterferencePool from BOPTools,
PShapesDataStructure from BooleanOperations
is
Create (aFiller: PaveFiller from BOPTools)
returns PCurveMaker from BOPTools;
---Purpose:
--- Constructor
---
Do(me:out);
---Purpose:
--- Launch the processor
---
IsDone(me)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if Ok
---
fields
myFiller : PPaveFiller from BOPTools;
myDS : PShapesDataStructure from BooleanOperations;
myIsDone : Boolean from Standard;
end PCurveMaker;

View File

@@ -0,0 +1,200 @@
// File: BOPTools_PCurveMaker.cxx
// Created: Wed May 30 09:45:32 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PCurveMaker.ixx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepTools.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <IntTools_Curve.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOPTools_SequenceOfCurves.hxx>
#include <BOPTools_Curve.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_Tools2D.hxx>
//=======================================================================
// function: BOPTools_PCurveMaker
// purpose:
//=======================================================================
BOPTools_PCurveMaker::BOPTools_PCurveMaker(const BOPTools_PaveFiller& aFiller)
:
myIsDone(Standard_False)
{
myFiller=(BOPTools_PaveFiller*) &aFiller;
myDS=myFiller->DS();
}
//=======================================================================
// function: IsDone
// purpose:
//=======================================================================
Standard_Boolean BOPTools_PCurveMaker::IsDone() const
{
return myIsDone;
}
//=======================================================================
// function: Do
// purpose:
//=======================================================================
void BOPTools_PCurveMaker::Do()
{
BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences();
Standard_Integer i, aNb, nF1, nF2, nE;
BOPTools_ListIteratorOfListOfPaveBlock anIt;
aNb=aFFs.Extent();
for (i=1; i<=aNb; i++) {
BOPTools_SSInterference& aFF=aFFs(i);
// Faces
nF1=aFF.Index1();
const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
nF2=aFF.Index2();
const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
//
// 1.Forwarding the Faces
TopoDS_Face aF1FWD=aF1;
aF1FWD.Orientation(TopAbs_FORWARD);
TopoDS_Face aF2FWD=aF2;
aF2FWD.Orientation(TopAbs_FORWARD);
//
// 2. In, On parts processing
const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
anIt.Initialize(aLPBInOn);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPBInOn=anIt.Value();
nE=aPBInOn.Edge();
const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
}
//
// 3. Section Edges processing
Standard_Integer j, aNbCurves, k, aNbV;
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
aNbCurves=aSC.Length();
for (j=1; j<=aNbCurves; j++) {
const BOPTools_Curve& aBC=aSC(j);
const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
anIt.Initialize(aLPB);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPB=anIt.Value();
nE=aPB.Edge();
const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
//
Standard_Real aTolEdge, aTolR2D, aTolFact, aTolV, aTolVmax;
//
aTolEdge=BRep_Tool::Tolerance(aE);
aTolR2D=aFF.TolR2D();
aTolFact=Max(aTolEdge, aTolR2D);
//
// Check vertices tolerances and correct them if necessary
// to prevent situation when TolE > TolV
//
TopTools_IndexedMapOfShape aVMap;
TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap);
aTolVmax=-1.;
aNbV=aVMap.Extent();
for (k=1; k<=aNbV; ++k) {
const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k));
aTolV=BRep_Tool::Tolerance(aV);
if (aTolV>aTolVmax) {
aTolVmax=aTolV;
}
}
//
if (aTolFact>aTolVmax) {
aTolFact=aTolVmax;
}
//
BRep_Builder aBB;
const IntTools_Curve& aIC=aBC.Curve();
//ZZ const Handle(Geom_Curve)& aC3D=aIC.Curve();
//
Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol;
const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast);
Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast);
//
//modified by NIZNHY-PKV Wed Sep 3 11:13:41 2003 f
Handle(Geom2d_Curve) aC2D1, aC2D1A, aC2D2, aC2D2A;
//
aC2D1=aIC.FirstCurve2d();
if (aC2D1.IsNull()) {
BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
BOPTools_Tools2D::CurveOnSurface(aE, aF1FWD, aC2D1, aOutFirst, aOutLast, aOutTol, Standard_True);
}
//const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d();
//Handle(Geom2d_Curve) aC2D1A;
//modified by NIZNHY-PKV Wed Sep 3 11:13:48 2003 t
//
if (aC3DE->IsPeriodic()) {
BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aTFirst, aTLast, aC2D1, aC2D1A);
}
else {
BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aC3DETrim, aC2D1, aC2D1A);
}
//
aBB.UpdateEdge(aE, aC2D1A, aF1FWD, aTolFact);
//modified by NIZNHY-PKV Wed Sep 3 11:23:00 2003 f
aC2D2=aIC.SecondCurve2d();
if (aC2D2.IsNull()) {
BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
BOPTools_Tools2D::CurveOnSurface(aE, aF2FWD, aC2D2, aOutFirst, aOutLast, aOutTol, Standard_True);
}
//const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d();
//Handle(Geom2d_Curve) aC2D2A;
//modified by NIZNHY-PKV Wed Sep 3 11:23:12 2003 t
//
if (aC3DE->IsPeriodic()) {
BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aTFirst, aTLast, aC2D2, aC2D2A);
}
else {
BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aC3DETrim, aC2D2, aC2D2A);
}
//
aBB.UpdateEdge(aE, aC2D2A, aF2FWD, aTolFact);
}
}// for (j=1; j<=aNbCurves; j++)
} // for (i=1; i<=aNb; i++)
myIsDone=Standard_True;
}

82
src/BOPTools/BOPTools_Pave.cdl Executable file
View File

@@ -0,0 +1,82 @@
-- File: BOPTools_Pave.cdl
-- Created: Thu Feb 8 12:26:04 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class Pave from BOPTools
---Purpose:
-- Class for storing info about a vertex on an edge
uses
KindOfInterference from BooleanOperations
is
Create
returns Pave from BOPTools;
---Purpose:
--- Empty constructor
---
Create (Index: Integer from Standard;
aParam:Real from Standard;
aType: KindOfInterference from BooleanOperations
=BooleanOperations_UnknownInterference)
returns Pave from BOPTools;
---Purpose:
--- Constructor
--- Index - DS-index of the vertex
--- aParam - value of the parameter of the vertex on an edge
--- aType - the type of interference from which the pave comes from
---
SetParam (me:out; aParam:Real from Standard);
---Purpose:
--- Modifier
---
SetIndex (me:out; Index: Integer from Standard);
---Purpose:
--- Modifier
---
SetType (me:out; aType:KindOfInterference from BooleanOperations);
---Purpose:
--- Modifier
---
SetInterference (me:out; Index: Integer from Standard);
---Purpose:
--- Modifier
--- Sets the index of the interference in corresponding table
---
Param (me)
returns Real from Standard;
---Purpose:
--- Selector
---
Index (me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Type (me)
returns KindOfInterference from BooleanOperations;
---Purpose:
--- Selector
---
Interference(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
IsEqual(me; Other:Pave from BOPTools)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if <Other>==me
---
fields
myParam: Real from Standard;
myIndex: Integer from Standard;
myType : KindOfInterference from BooleanOperations;
myInterf: Integer from Standard;
end Pave;

115
src/BOPTools/BOPTools_Pave.cxx Executable file
View File

@@ -0,0 +1,115 @@
// File: BOPTools_Pave.cxx
// Created: Thu Feb 8 12:32:40 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Pave.ixx>
//=======================================================================
// function: BOPTools_Pave::BOPTools_Pave
// purpose:
//=======================================================================
BOPTools_Pave::BOPTools_Pave()
:
myParam(0.),
myIndex(0),
myType(BooleanOperations_UnknownInterference),
myInterf(0)
{}
//=======================================================================
// function: BOPTools_Pave::BOPTools_Pave
// purpose:
//=======================================================================
BOPTools_Pave::BOPTools_Pave(const Standard_Integer anIndex,
const Standard_Real aParam,
const BooleanOperations_KindOfInterference aType)
:
myParam(aParam),
myIndex(anIndex),
myType(aType),
myInterf(0)
{}
//=======================================================================
// function: SetParam
// purpose:
//=======================================================================
void BOPTools_Pave::SetParam(const Standard_Real aParam)
{
myParam=aParam;
}
//=======================================================================
// function: SetIndex
// purpose:
//=======================================================================
void BOPTools_Pave::SetIndex(const Standard_Integer anIndex)
{
myIndex=anIndex;
}
//=======================================================================
// function: SetType
// purpose:
//=======================================================================
void BOPTools_Pave::SetType(const BooleanOperations_KindOfInterference aType)
{
myType=aType;
}
//=======================================================================
// function: SetInterference
// purpose:
//=======================================================================
void BOPTools_Pave::SetInterference(const Standard_Integer anIndex)
{
myInterf=anIndex;
}
//=======================================================================
// function: Param
// purpose:
//=======================================================================
Standard_Real BOPTools_Pave::Param() const
{
return myParam;
}
//=======================================================================
// function: Index
// purpose:
//=======================================================================
Standard_Integer BOPTools_Pave::Index() const
{
return myIndex;
}
//=======================================================================
// function: Type
// purpose:
//=======================================================================
BooleanOperations_KindOfInterference BOPTools_Pave::Type() const
{
return myType;
}
//=======================================================================
// function: Interference
// purpose:
//=======================================================================
Standard_Integer BOPTools_Pave::Interference() const
{
return myInterf;
}
//=======================================================================
// function: IsEqual
// purpose:
//=======================================================================
Standard_Boolean BOPTools_Pave::IsEqual(const BOPTools_Pave& Other) const
{
Standard_Integer anIndOther;
Standard_Real aParamOther, dt=1.e-14;
anIndOther=Other.Index();
if (anIndOther!=myIndex) {
return Standard_False;
}
aParamOther=Other.Param();
if (fabs (aParamOther-myParam) > dt){
return Standard_False;
}
return Standard_True;
}

View File

@@ -0,0 +1,183 @@
-- File: BOPTools_PaveBlock.cdl
-- Created: Thu Feb 15 11:21:52 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PaveBlock from BOPTools
---Purpose:
-- Class for storing info about a couple
--- of neighbouring paves on an edge
uses
Pave from BOPTools,
PointBetween from BOPTools,
Range from IntTools,
ShrunkRange from IntTools,
Curve from IntTools
is
Create
returns PaveBlock from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anEdge: Integer from Standard;
aPave1: Pave from BOPTools;
aPave2: Pave from BOPTools);
---Purpose:
--- Constructor
--- Index - DS-index of the edge
--- aPave1 - one pave
--- aPave2 - other pave
---
SetEdge (me:out;
anEdge:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the edge that is between aPave1 and aPave2
---
SetOriginalEdge (me:out;
anEdge:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the edge from which this pave block comes from
---
SetPave1(me:out;
aPave: Pave from BOPTools);
---Purpose:
--- Modifier
---
SetPave2(me:out;
aPave: Pave from BOPTools);
---Purpose:
--- Modifier
---
SetShrunkRange (me:out;
aSR:ShrunkRange from IntTools);
---Purpose:
--- Modifier
--- Sets the Shrunk Range for the pave block
---
SetPointBetween (me:out;
aP: PointBetween from BOPTools);
---Purpose:
--- Modifier
--- Sets the point between the paves for the pave block
---
--- Case of Face/Face Pave Block
---
SetCurve (me:out;
aC:Curve from IntTools);
---Purpose:
--- Modifier
--- Sets the intersection curve to which the pave block belongs to
---
SetFace1 (me:out;
nF1:Integer from Standard);
---Purpose:
--- Modifier
--- Sets the DS-index of the first face
---
SetFace2 (me:out;
nF2:Integer from Standard);
---Purpose:
--- Modifier
--- Sets the DS-index of the second face
---
Edge (me)
returns Integer from Standard;
---Purpose:
--- Selector
---
OriginalEdge(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Pave1(me)
returns Pave from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
Pave2(me)
returns Pave from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
IsValid(me)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if both paves have vertex index !=0
---
IsEqual(me;
Other:PaveBlock from BOPTools)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if <Other> is equal to me
---
Parameters (me;
aT1:out Real from Standard;
aT2:out Real from Standard);
---Purpose:
--- Returns values for paves' parameters
---
Range (me)
returns Range from IntTools;
---C++: return const &
---Purpose:
--- Returns parmetric range for paves' parameters
---
ShrunkRange(me)
returns ShrunkRange from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
PointBetween (me)
returns PointBetween from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
Curve(me)
returns Curve from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
Face1(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Face2(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
IsInBlock(me;
aPaveX: Pave from BOPTools)
returns Boolean from Standard;
fields
myEdge : Integer from Standard;
myOriginalEdge : Integer from Standard;
myPave1 : Pave from BOPTools;
myPave2 : Pave from BOPTools;
myRange : Range from IntTools;
myShrunkRange : ShrunkRange from IntTools;
myCurve : Curve from IntTools;
myFace1 : Integer from Standard;
myFace2 : Integer from Standard;
myPointBetween : PointBetween from BOPTools;
end PaveBlock;

View File

@@ -0,0 +1,288 @@
// File: BOPTools_PaveBlock.cxx
// Created: Thu Feb 15 11:32:13 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveBlock.ixx>
//=======================================================================
// function: BOPTools_PaveBlock::BOPTools_PaveBlock
// purpose:
//=======================================================================
BOPTools_PaveBlock::BOPTools_PaveBlock()
:
myEdge(0),
myOriginalEdge(0),
myFace1(0),
myFace2(0)
{}
//=======================================================================
// function: BOPTools_PaveBlock::BOPTools_PaveBlock
// purpose:
//=======================================================================
BOPTools_PaveBlock::BOPTools_PaveBlock(const Standard_Integer theEdge,
const BOPTools_Pave& thePave1,
const BOPTools_Pave& thePave2)
{
myOriginalEdge=theEdge;
myPave1=thePave1;
myPave2=thePave2;
myFace1=0;
myFace2=0;
}
//=======================================================================
// function: SetCurve
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetCurve(const IntTools_Curve& aC)
{
myCurve=aC;
}
//=======================================================================
// function: SetFace1
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetFace1(const Standard_Integer theFace1)
{
myFace1=theFace1;
}
//=======================================================================
// function: SetFace2
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetFace2(const Standard_Integer theFace2)
{
myFace2=theFace2;
}
//=======================================================================
// function: Face1
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveBlock::Face1() const
{
return myFace1;
}
//=======================================================================
// function: Face2
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveBlock::Face2() const
{
return myFace2;
}
//=======================================================================
// function: Curve
// purpose:
//=======================================================================
const IntTools_Curve& BOPTools_PaveBlock::Curve() const
{
return myCurve;
}
//=======================================================================
// function: SetEdge
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetEdge(const Standard_Integer theEdge)
{
myEdge=theEdge;
}
//=======================================================================
// function: SetOriginalEdge
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge)
{
myOriginalEdge=theEdge;
}
//=======================================================================
// function: SetPave1
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetPave1(const BOPTools_Pave& thePave1)
{
myPave1=thePave1;
}
//=======================================================================
// function: SetPave2
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetPave2(const BOPTools_Pave& thePave2)
{
myPave2=thePave2;
}
//=======================================================================
// function: SetShrunkRange
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetShrunkRange(const IntTools_ShrunkRange& theSR)
{
myShrunkRange=theSR;
}
//=======================================================================
// function: SetPointBetween
// purpose:
//=======================================================================
void BOPTools_PaveBlock::SetPointBetween (const BOPTools_PointBetween& thePB)
{
myPointBetween=thePB;
}
//=======================================================================
// function: PointBetween
// purpose:
//=======================================================================
const BOPTools_PointBetween& BOPTools_PaveBlock::PointBetween ()const
{
return myPointBetween;
}
//=======================================================================
// function: Pave1
// purpose:
//=======================================================================
const BOPTools_Pave& BOPTools_PaveBlock::Pave1() const
{
Standard_Real t1, t2;
t1=myPave1.Param();
t2=myPave2.Param();
if (t1<t2) {
return myPave1;
}
return myPave2;
}
//=======================================================================
// function: Pave2
// purpose:
//=======================================================================
const BOPTools_Pave& BOPTools_PaveBlock::Pave2() const
{
Standard_Real t1, t2;
t1=myPave1.Param();
t2=myPave2.Param();
if (t1>t2) {
return myPave1;
}
return myPave2;
}
//=======================================================================
// function: Edge
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveBlock::Edge() const
{
return myEdge;
}
//=======================================================================
// function: OriginalEdge
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveBlock::OriginalEdge() const
{
return myOriginalEdge;
}
//=======================================================================
// function: IsValid
// purpose:
//=======================================================================
Standard_Boolean BOPTools_PaveBlock::IsValid() const
{
Standard_Integer anInd1, anInd2;
anInd1=myPave1.Index();
anInd2=myPave2.Index();
return (anInd1 && anInd2);
}
//=======================================================================
// function: IsEqual
// purpose:
//=======================================================================
Standard_Boolean BOPTools_PaveBlock::IsEqual(const BOPTools_PaveBlock& Other) const
{
if (myOriginalEdge==Other.myOriginalEdge) {
const BOPTools_Pave& aP11=Pave1();
const BOPTools_Pave& aP12=Pave2();
const BOPTools_Pave& aP21=Other.Pave1();
const BOPTools_Pave& aP22=Other.Pave2();
if (aP11.IsEqual(aP21)) {
if (aP12.IsEqual(aP22)) {
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
// function: Parameters
// purpose:
//=======================================================================
void BOPTools_PaveBlock::Parameters(Standard_Real& aT1,
Standard_Real& aT2) const
{
Standard_Real t1, t2;
t1=myPave1.Param();
t2=myPave2.Param();
aT1= (t1<t2) ? t1 : t2;
aT2= (t1>t2) ? t1 : t2;
}
//=======================================================================
// function: Range
// purpose:
//=======================================================================
const IntTools_Range& BOPTools_PaveBlock::Range() const
{
Standard_Real t1, t2;
t1=myPave1.Param();
t2=myPave2.Param();
IntTools_Range* pRange=(IntTools_Range*) &myRange;
if (t1<t2) {
pRange->SetFirst (t1);
pRange->SetLast (t2);
}
else {
pRange->SetFirst (t2);
pRange->SetLast (t1);
}
return myRange;
}
//=======================================================================
// function: ShrunkRange
// purpose:
//=======================================================================
const IntTools_ShrunkRange& BOPTools_PaveBlock::ShrunkRange()const
{
return myShrunkRange;
}
//=======================================================================
// function: IsInBlock
// purpose:
//=======================================================================
Standard_Boolean BOPTools_PaveBlock::IsInBlock(const BOPTools_Pave& thePaveX) const
{
Standard_Boolean bIsInBlock;
Standard_Real aT1, aT2, aTx;
//
aTx=thePaveX.Param();
Parameters(aT1, aT2);
bIsInBlock=(aTx > aT1 && aTx < aT2);
return bIsInBlock;
}

View File

@@ -0,0 +1,61 @@
-- File: BOPTools_PaveBlockIterator.cdl
-- Created: Wed Mar 7 15:59:24 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PaveBlockIterator from BOPTools
---Purpose:
--- class providing iterations for PaveSet to
--- have the right order of paves along the edge
---
uses
PaveSet from BOPTools,
CArray1OfPave from BOPTools,
PaveBlock from BOPTools
is
Create
returns PaveBlockIterator from BOPTools;
---Purpose:
--- Empty constructor
---
Create (aEdge : Integer from Standard;
aPaveSet: PaveSet from BOPTools)
returns PaveBlockIterator from BOPTools;
---Purpose:
--- Constructor
--- aEdge - DS-index of the edge
--- aPaveSet - a set of paves for the edge
---
Initialize(me:out;aEdge : Integer from Standard;
aPaveSet: PaveSet from BOPTools);
---Purpose:
--- Resets the iterator on the PaveSet <aPaveSet>
---
More(me)
returns Boolean from Standard;
---Purpose:
--- Returns True if there is a current Pave in
--- the iteration.
---
Next(me:out);
---Purpose:
--- Moves to the next Pave in the PaveSet
---
Value(me:out)
returns PaveBlock from BOPTools;
---C++: return &
---Purpose:
--- Returns the current Pave
---
fields
myEdge : Integer from Standard;
myIndex : Integer from Standard;
myPaveSet : PaveSet from BOPTools;
myPaves : CArray1OfPave from BOPTools;
myPaveBlock: PaveBlock from BOPTools;
end PaveBlockIterator;

View File

@@ -0,0 +1,102 @@
// File: BOPTools_PaveBlockIterator.cxx
// Created: Wed Mar 7 16:05:08 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveBlockIterator.ixx>
#include <BOPTools_ListOfPave.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOPTools_Pave.hxx>
//=======================================================================
// function:BOPTools_PaveBlockIterator
// purpose:
//=======================================================================
BOPTools_PaveBlockIterator::BOPTools_PaveBlockIterator()
:
myEdge(0),
myIndex(1)
{
}
//=======================================================================
// function:BOPTools_PaveBlockIterator
// purpose:
//=======================================================================
BOPTools_PaveBlockIterator::BOPTools_PaveBlockIterator (const Standard_Integer anEdge,
const BOPTools_PaveSet& aPaveSet)
{
Initialize (anEdge, aPaveSet);
}
//=======================================================================
// function:Initialize
// purpose:
//=======================================================================
void BOPTools_PaveBlockIterator::Initialize(const Standard_Integer anEdge,
const BOPTools_PaveSet& aPaveSet)
{
Standard_Integer i, aNb;
myPaveSet=aPaveSet;
myIndex=1;
myEdge=anEdge;
myPaveBlock.SetOriginalEdge(myEdge);
myPaveSet.SortSet();
BOPTools_ListOfPave& aLP=myPaveSet.ChangeSet();
aNb=aLP.Extent();
myPaves.Resize(aNb);
BOPTools_ListIteratorOfListOfPave anIt(aLP);
for (i=1; anIt.More(); anIt.Next(), i++) {
const BOPTools_Pave& aPave=anIt.Value();
myPaves(i)=aPave;
}
}
//=======================================================================
// function:More
// purpose:
//=======================================================================
Standard_Boolean BOPTools_PaveBlockIterator::More() const
{
Standard_Integer aNb;
aNb=myPaves.Extent();
return (myIndex < aNb);
}
//=======================================================================
// function:Next
// purpose:
//=======================================================================
void BOPTools_PaveBlockIterator::Next()
{
myIndex++;
}
//=======================================================================
// function:Value
// purpose:
//=======================================================================
BOPTools_PaveBlock& BOPTools_PaveBlockIterator::Value()
{
Standard_Integer i1, i2;
Standard_Real aT1, aT2;
BOPTools_PaveBlock* pPB= (BOPTools_PaveBlock*) &myPaveBlock;
i1=myIndex;
i2=i1+1;
const BOPTools_Pave& aPave1=myPaves(i1);
const BOPTools_Pave& aPave2=myPaves(i2);
aT1=aPave1.Param();
aT2=aPave2.Param();
if (aT1 > aT2) {
pPB->SetPave1(aPave1);
pPB->SetPave2(aPave2);
}
else {
pPB->SetPave1(aPave2);
pPB->SetPave2(aPave1);
}
return myPaveBlock;
}

View File

@@ -0,0 +1,29 @@
-- File: BOPTools_PaveBlockMapHasher.cdl
-- Created: Thu Dec 11 14:09:07 2003
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2003
class PaveBlockMapHasher from BOPTools
---Purpose:
uses
PaveBlock from BOPTools
--raises
is
HashCode(myclass;
aPB : PaveBlock from BOPTools;
Upper : Integer from Standard)
returns Integer from Standard;
IsEqual(myclass;
aPB1 : PaveBlock from BOPTools;
aPB2 : PaveBlock from BOPTools)
returns Boolean from Standard;
--fields
end PaveBlockMapHasher;

View File

@@ -0,0 +1,36 @@
// File: BOPTools_PaveBlockMapHasher.cxx
// Created: Thu Dec 11 14:10:44 2003
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveBlockMapHasher.ixx>
#include <BOPTools_Pave.hxx>
#include <BOPTools_PaveBlock.hxx>
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer BOPTools_PaveBlockMapHasher::HashCode(const BOPTools_PaveBlock& aPB,
const Standard_Integer aUpper)
{
Standard_Integer aS, nV1, nV2, nE;
//
nV1=aPB.Pave1().Index();
nV2=aPB.Pave2().Index();
nE=aPB.OriginalEdge();
aS=nV1+nV2+nE;
return aS%aUpper;
}
//=======================================================================
//function :IsEqual
//purpose :
//=======================================================================
Standard_Boolean BOPTools_PaveBlockMapHasher::IsEqual(const BOPTools_PaveBlock& aPB1,
const BOPTools_PaveBlock& aPB2)
{
return aPB1.IsEqual(aPB2);
}

View File

@@ -0,0 +1,598 @@
-- File: BOPTools_PaveFiller.cdl
-- Created: Thu Feb 8 14:07:33 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PaveFiller from BOPTools
---Purpose: The algorithm that provides
--- 1. creation of the data structure (DS)
--- 2. creation of the interferences' pool
--- 3. invocation of Perform() to fill the DS
---
---
uses
PShapesDataStructure from BooleanOperations,
InterferencePool from BOPTools,
PInterferencePool from BOPTools,
PavePool from BOPTools,
CommonBlockPool from BOPTools,
SplitShapesPool from BOPTools,
Pave from BOPTools,
PaveBlock from BOPTools,
PaveSet from BOPTools,
Curve from BOPTools,
SSInterference from BOPTools,
ListOfPaveBlock from BOPTools,
IteratorOfCoupleOfShape from BOPTools,
SSInterference from BOPTools,
SSIntersectionAttribute from BOPTools,
ShrunkRange from IntTools,
Context from IntTools,
ShapeEnum from TopAbs,
ListOfInteger from TColStd,
IndexedMapOfInteger from TColStd,
Pnt from gp,
Vertex from TopoDS,
SetOfInteger from TColStd
is
Create
returns PaveFiller from BOPTools;
---Purpose:
--- Empty Contructor
---
Create (aIP: InterferencePool from BOPTools)
returns PaveFiller from BOPTools;
---Purpose:
--- Constructor
---
Create (theIP : InterferencePool from BOPTools;
theSectionAttribute: SSIntersectionAttribute from BOPTools)
returns PaveFiller from BOPTools;
---Purpose:
--- Constructor
---
Destroy (me: in out)
is virtual;
---C++: alias "Standard_EXPORT virtual ~BOPTools_PaveFiller(){Destroy();}"
---Purpose:
--- Destructor
---
Perform (me:out)
is virtual;
---Purpose:
--- Fills the DS
---
PartialPerform(me:out; anObjSubSet, aToolSubSet: SetOfInteger from TColStd)
is virtual;
ToCompletePerform(me:out)
is virtual;
PerformVV (me:out)
is virtual protected;
---Purpose:
--- Computes Vertex/Vertex interferences
---
PerformVE (me:out)
is virtual protected;
---Purpose:
--- Computes Vertex/Edge interferences
---
PerformVF (me:out)
is virtual protected;
---Purpose:
--- Computes Vertex/Face interferences
---
PerformEE (me:out)
is virtual protected;
---Purpose:
--- Computes Edge/Edge interferences
---
PerformEF (me:out)
is virtual protected;
---Purpose:
--- Computes Edge/Face interferences
---
PerformFF (me:out)
is virtual protected;
---Purpose:
--- Computes Face/Face interferences
---
--------------------------------------------------------------
---
--- Selectors
---
---
Context(me)
returns Context from IntTools;
---C++:return const &
---Purpose:
--- Selector
---
ChangeContext(me:out)
returns Context from IntTools;
---C++:return &
---Purpose:
--- Selector
---
SetInterferencePool(me:out;
aPool:InterferencePool from BOPTools);
---Purpose:
--- Selector
---
IsDone(me)
returns Boolean from Standard;
---Purpose:
--- Selector
---
PavePool(me)
returns PavePool from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
ChangePavePool(me:out)
returns PavePool from BOPTools;
---C++:return &
---Purpose:
--- Selector
---
CommonBlockPool(me)
returns CommonBlockPool from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
ChangeCommonBlockPool(me:out)
returns CommonBlockPool from BOPTools;
---C++:return &
---Purpose:
--- Selector
---
SplitShapesPool(me)
returns SplitShapesPool from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
ChangeSplitShapesPool(me:out)
returns SplitShapesPool from BOPTools;
---C++:return &
---Purpose:
--- Selector
---
DS(me:out)
returns PShapesDataStructure from BooleanOperations;
---Purpose:
--- Selector
---
InterfPool(me:out)
returns PInterferencePool from BOPTools;
---Purpose:
--- Selector
---
IteratorOfCoupleOfShape(me)
returns IteratorOfCoupleOfShape from BOPTools;
---C++:return const &
---Purpose:
--- Selector
---
SectionAttribute(me)
returns SSIntersectionAttribute from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
SetSectionAttribute(me:out;
anAtt : SSIntersectionAttribute from BOPTools);
---Purpose:
--- Selector
---
--------------------------------------------------------------
---
--- PaveBlocks for Split Parts of Edges.
---
---
SortTypes (me;
anInd1:in out Integer from Standard;
anInd2:in out Integer from Standard)
is protected;
---Purpose:
--- Sorts the types of shapes with DS-indices
--- <anInd1> and <anInd2> in increasing order of
--- types of the shapes
---
PerformNewVertices (me:out)
is protected;
IsSuccesstorsComputed (me;
iF1:Integer from Standard;
iF2:Integer from Standard)
returns Boolean from Standard
is protected;
PrepareEdges (me:out)
is virtual protected;
---Purpose:
--- Prepare end paves for each edge
---
PreparePaveBlocks (me:out;
aType1: ShapeEnum from TopAbs;
aType2: ShapeEnum from TopAbs)
is virtual protected;
---Purpose:
--- Prepare PaveBlocks for each edge (EE-interferences)
---
PreparePaveBlocks (me:out;
anE:Integer from Standard)
is virtual protected;
---Purpose:
--- Prepare PaveBlocks for given edge (EE-interferences)
---
RefinePavePool(me:out)
is protected;
---Purpose:
--- Refines myPavePool taking into account new Paves obtained from EE algo
---
MakeSplitEdges(me:out)
is protected;
---Purpose:
--- Makes split edges from source edges
---
DoSDEdges(me:out)
is protected;
---Purpose:
--- Update Lists of PaveBlocks with info about
--- indices of split edges that are Same Domain
--- with other splits or faces
---
CorrectShrunkRanges(me:out;
aSide: Integer from Standard;
aPave: Pave from BOPTools;
aSR : out ShrunkRange from IntTools)
is protected;
---Purpose:
--- Update Shrunk Range <aSR> for Pave <aPave>
---
SplitIndex (me:out; aPB:PaveBlock from BOPTools)
returns Integer from Standard
is protected;
---Purpose:
--- Returns the Index of Split edge for the PaveBlock <aPB>
--- in DS.
--- If the PaveBlock is not found, returns 0;
---
IsBlocksCoinside (me;
aPB1:PaveBlock from BOPTools;
aPB2:PaveBlock from BOPTools)
returns Boolean from Standard
is protected;
---Purpose:
--- Returns TRUE if the two PaveBlocks have vertices
--- that touch each other in terms of Tolerances of
--- the vertices
---
--------------------------------------------------------------
---
--- Some of API FUNCTIONS
---
---
SplitsInFace(me:out;
aBid:Integer from Standard;
nF1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfInteger from TColStd)
returns Integer from Standard;
---Purpose:
--- For the face <nF1> get all splits that are IN-2D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsInFace(me:out;
nE1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfInteger from TColStd)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all splits that are IN-2D
--- to the face <nF1>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnEdge(me:out;
nE1 :Integer from Standard;
nE2 :Integer from Standard;
aLs :out ListOfInteger from TColStd)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all splits that are ON-3D
--- to the edge <nE2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnFace(me:out;
nE1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfInteger from TColStd)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all splits that are ON-3D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnFace(me:out;
aBid:Integer from Standard;
nF1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfInteger from TColStd)
returns Integer from Standard;
---Purpose:
--- For the face <nF1> get all splits that are ON-3D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsInFace(me:out;
aBid:Integer from Standard;
nF1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfPaveBlock from BOPTools)
returns Integer from Standard;
---Purpose:
--- For the face <nF1> get all PaveBlocks that are IN-2D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsInFace(me:out;
nE1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfPaveBlock from BOPTools)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all PaveBlocks that are IN-2D
--- to the face <nF1>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnEdge(me:out;
nE1 :Integer from Standard;
nE2 :Integer from Standard;
aLs :out ListOfPaveBlock from BOPTools)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all PaveBlocks that are ON-3D
--- to the edge <nE2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnFace(me:out;
nE1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfPaveBlock from BOPTools)
returns Integer from Standard;
---Purpose:
--- For the edge <nE1> get all PaveBlocks that are ON-3D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
SplitsOnFace(me:out;
aBid:Integer from Standard;
nF1 :Integer from Standard;
nF2 :Integer from Standard;
aLs :out ListOfPaveBlock from BOPTools)
returns Integer from Standard;
---Purpose:
--- For the face <nF1> get all PaveBlocks that are ON-3D
--- to the face <nF2>; The result is in <aLs>
--- Returns 0 if OK;
---
FindSDVertex (me;
nV: Integer from Standard)
returns Integer from Standard;
---Purpose:
--- Find for the vertex <nV> SD-vertex (if possible) and return
--- its DS-index. Otherwise it returns 0.
---
---------------------------------------------------------------
---
--- Section Edges. Protected Block.
---
---
MakeBlocks(me:out)
is protected;
---Purpose:
--- Make Pave Blocks for intersection curves
---
MakeAloneVertices(me:out)
is protected;
---Purpose:
--- Make vertices that are place of intersection
--- between faces
---
PutPaveOnCurve(me:out;
aPaveSet: PaveSet from BOPTools;
aTolR3D : Real from Standard;
aBCurve :out Curve from BOPTools)
is protected;
---Purpose:
--- Among Paves from <aPaveSet> find ones that belong
--- to intersection curve <aBCurve> with 3D-tolerance
--- value <aTolR3D>
---
PutPaveOnCurve(me:out;
aPave : Pave from BOPTools;
aTolR3D : Real from Standard;
aBCurve :out Curve from BOPTools)
is protected;
---Purpose:
--- Try to put Pave <aPave> on intersection curve <aBCurve>
--- with 3D-tolerance value <aTolR3D>
---
PutPavesOnCurves(me:out)
is protected;
PrepareSetForFace(me:out;
nF1 :Integer from Standard;
nF2 :Integer from Standard;
aPaveSet:out PaveSet from BOPTools);
---Purpose:
--- For couple of faces <nF1>, <nF2> prepare set of all paves
--- of all edges <aPaveSet>
---
MakeSectionEdges(me:out)
is protected;
---Purpose:
--- For all inrefered faces make section edges from
--- intersection curves and corresp. Paves on them
---
PutBoundPaveOnCurve (me:out;
aBC :out Curve from BOPTools;
aFF :out SSInterference from BOPTools)
is protected;
---Purpose:
--- Try to put own bounds of the curve on the curve <aBC>
---
PutBoundPaveOnCurve (me:out;
aP : Pnt from gp;
aT : Real from Standard;
aBC :out Curve from BOPTools;
aFF :out SSInterference from BOPTools)
is protected;
---Purpose:
--- Try to put 3D-point <aP> (parameter aT) on the curve <aBC>
---
PutBoundPaveOnCurveSpec (me:out;
aBC :out Curve from BOPTools;
aFF :out SSInterference from BOPTools)
is protected;
---Purpose:
--- Try to put own bounds of the curve on the curve <aBC>
---
PutBoundPaveOnCurveSpec (me:out;
aP : Pnt from gp;
aT : Real from Standard;
aBC :out Curve from BOPTools;
aFF :out SSInterference from BOPTools)
is protected;
---Purpose:
--- Try to put 3D-point <aP> (parameter aT) on the curve <aBC>
---
FindPave (me:out;
aP :Pnt from gp;
aTpV: Real from Standard;
aPS: PaveSet from BOPTools;
aPV:out Pave from BOPTools)
returns Boolean from Standard
is protected;
---Purpose:
--- Returns TRUE if 3D-point <aP> coinsides with some Pave
--- from <aPS> (with 3D-tolerance value <aTpV>);
--- In TRUE case <aPV> will contain the Pave .
---
CheckCoincidence(me:out;
aPB: PaveBlock from BOPTools;
aFF: SSInterference from BOPTools)
returns Boolean from Standard
is protected;
---Purpose:
--- Returns TRUE if PaveBlock <aPB> lays on the faces
--- from FF-interference <aFF>
---
CheckIntermediatePoint(me:out;
aPB : PaveBlock from BOPTools;
aPBR: PaveBlock from BOPTools;
aTol: Real from Standard)
returns Integer from Standard
is protected;
---Purpose:
--- Returns 0 if some arbitrary intermediate point from
--- PaveBlock <aPB> lays on the PaveBlock <aPBR>
--- (with 3D-tolerance value <aTol>)
---
CheckFacePaves(me:out;
aV : Vertex from TopoDS;
nF: Integer from Standard)
returns Integer from Standard
is protected;
---Purpose:
--- Internal usage
---
StickVertices (me:out;
nF1: Integer from Standard;
nF2: Integer from Standard;
aMV:out IndexedMapOfInteger from TColStd)
is protected;
---Purpose:
--- Internal usage
---
ExpectedPoolLength(me)
returns Integer from Standard
is protected;
---Purpose:
--- Returns the value of expected length of array of interferences
---
RestrictCurveIn2d(me: in out; nE, nF1, nF2 : Integer from Standard;
theTolerance: Real from Standard;
theBC : in out Curve from BOPTools)
is private;
RecomputeCommonBlocks(me: in out; nE: Integer from Standard)
is private;
--modified by NIZNHY-PKV Tue Oct 19 10:28:42 2004f
ExtendedTolerance(me:out;
nV : Integer from Standard;
aTolExt : out Real from Standard)
returns Boolean from Standard
is protected;
--modified by NIZNHY-PKV Tue Oct 19 10:28:44 2004t
fields
myIntrPool : PInterferencePool from BOPTools
is protected;
myDS : PShapesDataStructure from BooleanOperations
is protected;
myPavePool : PavePool from BOPTools
is protected;
myPavePoolNew : PavePool from BOPTools
is protected;
myCommonBlockPool : CommonBlockPool from BOPTools
is protected;
mySplitShapesPool : SplitShapesPool from BOPTools
is protected;
mySectionAttribute : SSIntersectionAttribute from BOPTools
is protected;
myNbSources : Integer from Standard
is protected;
myNbEdges : Integer from Standard
is protected;
myIsDone : Boolean from Standard
is protected;
myDSIt : IteratorOfCoupleOfShape from BOPTools
is protected;
myContext : Context from IntTools
is protected;
end PaveFiller;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,605 @@
// File: BOPTools_PaveFiller_1.cxx
// Created: Tue Mar 13 16:12:16 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveFiller.ixx>
#include <Precision.hxx>
#include <SortTools_QuickSortOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TCollection_CompareOfReal.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <IntTools_EdgeFace.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
#include <IntTools_SequenceOfRanges.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
#include <BooleanOperations_OnceExplorer.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_IteratorOfCoupleOfShape.hxx>
#include <BOPTools_VVInterference.hxx>
#include <BOPTools_VEInterference.hxx>
#include <BOPTools_EEInterference.hxx>
#include <BOPTools_CArray1OfVEInterference.hxx>
#include <BOPTools_CArray1OfVVInterference.hxx>
#include <BOPTools_CArray1OfEEInterference.hxx>
#include <BOPTools_Tools.hxx>
#include <BOPTools_Pave.hxx>
#include <BOPTools_PaveSet.hxx>
#include <BOPTools_PaveBlockIterator.hxx>
#include <BOPTools_ListOfPave.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ESInterference.hxx>
#include <BOPTools_CommonBlockAPI.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfInterference.hxx>
#include <BOPTools_Interference.hxx>
#include <BOPTools_InterferenceLine.hxx>
#include <BOPTools_CArray1OfInterferenceLine.hxx>
#include <BOPTColStd_Failure.hxx>
#include <stdio.h>
//=======================================================================
// function: PerformEF
// purpose:
//=======================================================================
void BOPTools_PaveFiller::PerformEF()
{
myIsDone=Standard_False;
Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength;
BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
//
// E/F Interferences [BooleanOperations_EdgeFace]
myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE);
//
// BlockLength correction
aNbEFs=ExpectedPoolLength();
aBlockLength=aEFs.BlockLength();
if (aNbEFs > aBlockLength) {
aEFs.SetBlockLength(aNbEFs);
}
//
for (; myDSIt.More(); myDSIt.Next()) {
Standard_Boolean justaddinterference = Standard_True;
myDSIt.Current(n1, n2, justaddinterference);
if(justaddinterference) {
if (!myIntrPool->IsComputed(n1, n2)) {
anIndexIn = 0;
nE=n1;
nF=n2;
SortTypes(nE, nF);
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
}
continue;
}
//
if (myIntrPool->IsComputed(n1, n2)) {
continue;
}
//
nE=n1;
nF=n2;
SortTypes(nE, nF);
//
// ListOfCommonBlock for nE and CommonBlockAPI object to avoid
// CommonBlocks processing
BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
BOPTools_CommonBlockAPI aCBAPI(aLCB);
//
Standard_Real aTolE, aTolF, aDeflection=0.01;
Standard_Integer aDiscretize=35;
// modified by NIZHNY-MKK Thu Oct 27 12:31:45 2005
// const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE));
TopoDS_Edge aE=TopoDS::Edge(myDS->GetShape(nE));
//
if (BRep_Tool::Degenerated(aE)){
continue;
}
//
aTolE=BRep_Tool::Tolerance(aE);
// modified by NIZHNY-MKK Thu Oct 27 12:31:52 2005
// const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF));
TopoDS_Face aF=TopoDS::Face(myDS->GetShape(nF));
aTolF=BRep_Tool::Tolerance(aF);
// modified by NIZHNY-MKK Thu Oct 27 12:32:02 2005
// const Bnd_Box& aBBF=myDS->GetBoundingBox(nF);
Bnd_Box aBBF=myDS->GetBoundingBox(nF);
//
BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
for (; anIt.More(); anIt.Next()) {
BOPTools_PaveBlock& aPB=anIt.Value();
if (aCBAPI.IsCommonBlock(aPB)) {
// avoid CommonBlocks processing
continue;
}
const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
const Bnd_Box& aBBE=aShrunkRange.BndBox();
//////////////////////////////////////////////
if (aBBF.IsOut (aBBE)) {
continue;
}
//
// EF
IntTools_EdgeFace aEF;
aEF.SetEdge (aE);
aEF.SetFace (aF);
aEF.SetTolE (aTolE);
aEF.SetTolF (aTolF);
aEF.SetDiscretize (aDiscretize);
aEF.SetDeflection (aDeflection);
//
aEF.SetContext((IntTools_PContext)&myContext);
//
BRepAdaptor_Curve aCurve(aE);
IntTools_Range anewSR = aSR;
//
// Correction of the Shrunk Range
//
BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
//
aEF.SetRange (anewSR);
//
aEF.Perform();
//
anIndexIn=0;
//
if (aEF.IsDone()) {
//
const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
Standard_Integer i, aNbCPrts;
aNbCPrts=aCPrts.Length();
// modified by NIZHNY-MKK Thu Aug 26 17:37:07 2004.BEGIN
if(aNbCPrts != 0) {
char buf[512];
if(!aShrunkRange.IsDone()) {
sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE);
throw BOPTColStd_Failure(buf) ;
}
}
// modified by NIZHNY-MKK Thu Aug 26 17:37:09 2004.END
for (i=1; i<=aNbCPrts; i++) {
const IntTools_CommonPrt& aCPart=aCPrts.Value(i);
//
anIndexIn=0;
//
TopAbs_ShapeEnum aType=aCPart.Type();
switch (aType) {
case TopAbs_VERTEX: {
Standard_Real aT;
Standard_Integer aNewShape;
const IntTools_Range& aR=aCPart.Range1();
Standard_Real aRFirst, aRLast;
aR.Range(aRFirst, aRLast);
aT=0.5*(aRFirst+aRLast);
if((aCPart.VertexParameter1() >= aRFirst) &&
(aCPart.VertexParameter1() <= aRLast)) {
aT = aCPart.VertexParameter1();
}
TopoDS_Vertex aNewVertex;
BOPTools_Tools::MakeNewVertex(aE, aT, aF,aNewVertex);
//
Standard_Boolean isonpave1, isonpave2;
Standard_Real aTolToDecide;
aTolToDecide=5.e-8;
// modified by NIZHNY-IFV Feb 15 2007
// for occ11565
//Check that whole edge belongs face
isonpave1 = (Abs(anewSR.First() - aRFirst) < aTolToDecide);
isonpave2 = (Abs(anewSR.Last() - aRLast) < aTolToDecide);
//++
if(isonpave1 && isonpave2) {
//Seems whole edge belongs face
Standard_Boolean aCoinsideFlag =
BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
if (aCoinsideFlag) {
//
// Add Interference to the Pool
IntTools_CommonPrt aCP = aCPart;
aCP.SetType(TopAbs_EDGE);
BOPTools_ESInterference anInterf (nE, nF, aCP);
anIndexIn=aEFs.Append(anInterf);
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
//
BOPTools_CommonBlock aCB(aPB, nF);
aLCB.Append(aCB);
break;
}
}
// modified by NIZHNY-IFV Feb 15 2007. end
//
//decide to add pave or not.begin
isonpave1 = (Abs(anewSR.First() - aT) < aTolToDecide);
isonpave2 = (Abs(anewSR.Last() - aT) < aTolToDecide);
// modified by NIZHNY-MKK Wed Nov 6 14:43:07 2002.BEGIN
if(!isonpave1 && !isonpave2) {
isonpave1 = (Abs(anewSR.First() - aR.First()) < aTolToDecide);
isonpave2 = (Abs(anewSR.Last() - aR.Last()) < aTolToDecide);
}
// modified by NIZHNY-MKK Wed Nov 6 14:43:11 2002.END
//++
{
Standard_Integer nVP1, nVP2;
Standard_Boolean bIsComputed;
// Pave 1
const BOPTools_Pave& aPave1=aPB.Pave1();
nVP1=aPave1.Index();
bIsComputed=Standard_True;
if (nVP1 <= myNbSources) {
if(((nVP1 <= myDS->NumberOfShapesOfTheObject()) &&
(nF <= myDS->NumberOfShapesOfTheObject())) ||
((nVP1 > myDS->NumberOfShapesOfTheObject()) &&
(nF > myDS->NumberOfShapesOfTheObject()))) {
bIsComputed=myIntrPool->IsComputed(nVP1, nE);
if (!bIsComputed) {
bIsComputed=IsSuccesstorsComputed(nVP1, nE);
}
}
else {
bIsComputed=myIntrPool->IsComputed(nVP1, nF);
if (!bIsComputed) {
bIsComputed=IsSuccesstorsComputed(nVP1, nF);
}
}
}
if (bIsComputed && isonpave1) {
//
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP1));
BOPTools_Tools::UpdateVertex(aE, aT, aVF);
continue;
}
// Pave 2
const BOPTools_Pave& aPave2=aPB.Pave2();
nVP2=aPave2.Index();
bIsComputed=Standard_True;
if (nVP2 <= myNbSources) {
if((nVP2 <= myDS->NumberOfShapesOfTheObject() &&
nF <= myDS->NumberOfShapesOfTheObject()) ||
(nVP2 > myDS->NumberOfShapesOfTheObject() &&
nF > myDS->NumberOfShapesOfTheObject())) {
bIsComputed=myIntrPool->IsComputed(nVP2, nE);
if (!bIsComputed) {
bIsComputed=IsSuccesstorsComputed(nVP2, nE);
}
}
else {
bIsComputed=myIntrPool->IsComputed(nVP2, nF);
if (!bIsComputed) {
bIsComputed=IsSuccesstorsComputed(nVP2, nF);
}
}
}
if (bIsComputed && isonpave2) {
//
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP2));
BOPTools_Tools::UpdateVertex(aE, aT, aVF);
continue;
}
}
//decide to add pave or not.end
//
// Insert New Vertex in DS;
// aNewShape is # of DS-line, where aNewVertex is kept
//
BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
//
Standard_Integer nVF, iFlag;
nVF=CheckFacePaves(aNewVertex, nF);
if (nVF) {
const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
Standard_Real aTNew;
//
iFlag=myContext.ComputeVE(aVF, aE, aTNew);
//
aT=aTNew;
aNewShape=nVF;
BOPTools_Tools::UpdateVertex(aVF, aNewVertex);
}
//
else {
myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
aNewShape=myDS->NumberOfInsertedShapes();
}
//
// Add Interference to the Pool
BOPTools_ESInterference anInterf (nE, nF, aCPart);
anIndexIn=aEFs.Append(anInterf);
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
//
// State of the new Vertex is ON
myDS->SetState (aNewShape, BooleanOperations_ON);
//
// Insert New Vertex in EE Interference
BOPTools_ESInterference& aESInterf= aEFs(anIndexIn);
aESInterf.SetNewShape(aNewShape);
//
// Add Pave to the myPavePoolNew
BOPTools_Pave aPave;
aPave.SetInterference(anIndexIn);
aPave.SetType (BooleanOperations_EdgeSurface);
aPave.SetIndex(aNewShape);
aPave.SetParam(aT);
BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
aPaveSet.Append(aPave);
}// case TopAbs_VERTEX:
break;
case TopAbs_EDGE: {
Standard_Boolean aCoinsideFlag;
aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
if (!aCoinsideFlag) {
//
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
break;
}
// Add Interference to the Pool
BOPTools_ESInterference anInterf (nE, nF, aCPart);
anIndexIn=aEFs.Append(anInterf);
myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
//
BOPTools_CommonBlock aCB(aPB, nF);
aLCB.Append(aCB);
}// case TopAbs_EDGE:
break;
default:
break;
} // switch (aType)
} // for (i=1; i<=aNbCPrts; i++)
} //if (aEF.IsDone())
} // for (; anIt.More(); anIt.Next())
}// for (; myDSIt.More(); myDSIt.Next())
myIsDone=Standard_True;
}
//=======================================================================
// function: DoSDEdges
// purpose:
//=======================================================================
void BOPTools_PaveFiller::DoSDEdges()
{
myIsDone=Standard_False;
Standard_Integer aNbObj, nEObj, nETool, aSplitIndexObj, aSplitIndexTool;
TopAbs_ShapeEnum aType;
aNbObj=myDS->NumberOfShapesOfTheObject();
for (nEObj=1; nEObj<=aNbObj; nEObj++) {
// modified by NIZHNY-MKK Thu Oct 27 12:32:37 2005
// const TopoDS_Shape& aS=myDS->GetShape(nEObj);
TopoDS_Shape aS=myDS->GetShape(nEObj);
aType=aS.ShapeType();
if (aType==TopAbs_EDGE) {
//ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nEObj));
BOPTools_ListOfCommonBlock& aLCBObj=myCommonBlockPool(myDS->RefEdge(nEObj));
BOPTools_ListIteratorOfListOfCommonBlock anItCBObj(aLCBObj);
for (; anItCBObj.More(); anItCBObj.Next()) {
BOPTools_CommonBlock& aCBObj=anItCBObj.Value();
if (aCBObj.Face()) {
continue;
}
BOPTools_PaveBlock& aPBObj1=aCBObj.PaveBlock1(nEObj);
BOPTools_PaveBlock& aPBObj2=aCBObj.PaveBlock2(nEObj);
//
// Tool
nETool=aPBObj2.OriginalEdge();
BOPTools_ListOfCommonBlock& aLCBTool=myCommonBlockPool(myDS->RefEdge(nETool));
BOPTools_ListIteratorOfListOfCommonBlock anItCBTool(aLCBTool);
for (; anItCBTool.More(); anItCBTool.Next()) {
BOPTools_CommonBlock& aCBTool=anItCBTool.Value();
BOPTools_PaveBlock& aPBTool1=aCBTool.PaveBlock1(nETool);
BOPTools_PaveBlock& aPBTool2=aCBTool.PaveBlock2(nETool);
if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) {
//
// That is aCBObj==aCBTool
// Find SplitIndices in DS for aPBObj1 and aPBTool1
aSplitIndexObj =SplitIndex(aPBObj1);
aSplitIndexTool=SplitIndex(aPBTool1);
if (aSplitIndexObj && aSplitIndexTool) {
aPBObj1. SetEdge(aSplitIndexObj);
aPBObj2. SetEdge(aSplitIndexTool);
aPBTool1.SetEdge(aSplitIndexTool);
aPBTool2.SetEdge(aSplitIndexObj);
break;
}
else {
//error: can not find SplitIndex
throw
BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex");
myIsDone=Standard_False;
return;
}
} // if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1))
} // for (; anItCBTool.More(); anItCBTool.Next())
} // for (; anItCBObj.More(); anItCBObj.Next())
} // if (aType==TopAbs_EDGE)
} // for (nEObj=1; nEObj<=aNbObj; nEObj++)
//
// 2. EF CommonBlocks
//
Standard_Integer nE, aSplitIndex;
for (nE=1; nE<=myNbSources; nE++) {
// modified by NIZHNY-MKK Thu Oct 27 12:32:57 2005
// const TopoDS_Shape& aS=myDS->GetShape(nE);
TopoDS_Shape aS=myDS->GetShape(nE);
aType=aS.ShapeType();
if (aType==TopAbs_EDGE) {
//ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE));
BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
if (aCB.Face()) {
BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE);
aSplitIndex =SplitIndex(aPB);
if (aSplitIndex) {
aPB.SetEdge(aSplitIndex);
//break;
}
else {
//error: can not find SplitIndex
throw
BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex");
myIsDone=Standard_False;
return;
}
}
}
}
}
myIsDone=Standard_True;
}
//=======================================================================
// function: SplitIndex
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx)
{
Standard_Integer anOriginalEdge, anEdgeIndex=0;
anOriginalEdge=aPBx.OriginalEdge();
BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge));
BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
for (; anIt.More(); anIt.Next()) {
BOPTools_PaveBlock& aPB=anIt.Value();
if (aPB.IsEqual(aPBx)) {
anEdgeIndex=aPB.Edge();
return anEdgeIndex;
}
}
return anEdgeIndex;
}
//=======================================================================
// function: CheckFacePaves
// purpose:
//=======================================================================
Standard_Integer BOPTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex,
const Standard_Integer nF)
{
Standard_Integer nEF, nVF, iFlag;
BOPTools_ListIteratorOfListOfPave anIt;
// 1.
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nEF=aExp.Current();
BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nEF));
const BOPTools_ListOfPave& aLP=aPaveSet.Set();
anIt.Initialize(aLP);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Pave& aPave=anIt.Value();
nVF=aPave.Index();
const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
if (!iFlag) {
return nVF;
}
}
}
//
// 2.
aExp.Init(nF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nEF=aExp.Current();
BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF));
const BOPTools_ListOfPave& aLP=aPaveSet.Set();
anIt.Initialize(aLP);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Pave& aPave=anIt.Value();
nVF=aPave.Index();
const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
if (!iFlag) {
return nVF;
}
}
}
return 0;
}
//

View File

@@ -0,0 +1,326 @@
// File: BOPTools_PaveFiller_2.cxx
// Created: Tue Mar 27 17:43:41 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveFiller.ixx>
#include <TColStd_ListOfInteger.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_OnceExplorer.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_CommonBlock.hxx>
//=======================================================================
//
// A P I F U N C T I O N S
//
//=======================================================================
// function: SplitsInFace
// purpose: splits of edges from nF1 in nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
const Standard_Integer nF1,
const Standard_Integer nF2,
TColStd_ListOfInteger& aSplits)
{
Standard_Integer nE1;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nF1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE1=aExp.Current();
SplitsInFace (nE1, nF2, aSplits);
}
return 0; //Ok
}
//=======================================================================
// function: SplitsInFace
// purpose: splits of edge nE1 in aFace2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
const Standard_Integer nF2,
TColStd_ListOfInteger& aSplits)
{
Standard_Integer nF1, nSp;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
nF1=aCB.Face();
if (nF1==nF2) {
nSp=aPB1.Edge();
aSplits.Append(nSp);
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnEdge
// purpose: splits of edge nE1 on nE2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
const Standard_Integer nE2,
TColStd_ListOfInteger& aSplits)
{
Standard_Integer nE, nSp;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nE2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
return 1; // Type mismatch
}
const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1);
nE=aPB2.OriginalEdge();
if (nE==nE2) {
nSp=aPB1.Edge();
aSplits.Append(nSp);
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnFace
// purpose: splits of edge nE1 on face nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
const Standard_Integer nF2,
TColStd_ListOfInteger& aSplits)
{
Standard_Integer nE2, ip;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF2, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE2=aExp.Current();
ip=SplitsOnEdge(nE1, nE2, aSplits);
if (ip) {
return ip;
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnFace
// purpose: splits of edges from face nF1 on face nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
const Standard_Integer nF1,
const Standard_Integer nF2,
TColStd_ListOfInteger& aSplits)
{
Standard_Integer nE1, ip;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nF1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE1=aExp.Current();
ip=SplitsOnFace(nE1, nF2, aSplits);
if (ip) {
return ip;
}
}
return 0; //Ok
}
///////////////////////////////////////////////////////////////////////////////////
//=======================================================================
// function: SplitsInFace
// purpose: splits of edges from nF1 in nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
const Standard_Integer nF1,
const Standard_Integer nF2,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Integer nE1;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nF1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE1=aExp.Current();
SplitsInFace (nE1, nF2, aLPB);
}
return 0; //Ok
}
//=======================================================================
// function: SplitsInFace
// purpose: splits of edge nE1 in aFace2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
const Standard_Integer nF2,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Integer nF1;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
nF1=aCB.Face();
if (nF1==nF2) {
aLPB.Append(aPB1);
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnEdge
// purpose: splits of edge nE1 on nE2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
const Standard_Integer nE2,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Integer nE;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nE2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
return 1; // Type mismatch
}
const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1);
nE=aPB2.OriginalEdge();
if (nE==nE2) {
//modified by NIZNHY-PKV Tue Apr 4 16:59:24 2006f
//aLPB.Append(aPB1);
const BOPTools_PaveBlock& aPB1R=aCB.PaveBlock1();
aLPB.Append(aPB1R);
//modified by NIZNHY-PKV Tue Apr 4 16:59:28 2006t
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnFace
// purpose: splits of edge nE1 on face nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
const Standard_Integer nF2,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Integer nE2, ip;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nE1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF2, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE2=aExp.Current();
ip=SplitsOnEdge(nE1, nE2, aLPB);
if (ip) {
return ip;
}
}
return 0; //Ok
}
//=======================================================================
// function: SplitsOnFace
// purpose: splits of edges from face nF1 on face nF2
//=======================================================================
Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
const Standard_Integer nF1,
const Standard_Integer nF2,
BOPTools_ListOfPaveBlock& aLPB)
{
Standard_Integer nE1, ip;
TopAbs_ShapeEnum aT1, aT2;
aT1=myDS->GetShapeType(nF1);
aT2=myDS->GetShapeType(nF2);
if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
return 1; // Type mismatch
}
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nE1=aExp.Current();
ip=SplitsOnFace(nE1, nF2, aLPB);
if (ip) {
return ip;
}
}
return 0; //Ok
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,135 @@
// File: BOPTools_PaveFiller_4.cxx
// Created: Tue Feb 22 11:12:16 2002
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveFiller.ixx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopoDS_Shape.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_OnceExplorer.hxx>
#include <BooleanOperations_KindOfInterference.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BOPTools_ListIteratorOfListOfInterference.hxx>
#include <BOPTools_CArray1OfInterferenceLine.hxx>
#include <BOPTools_InterferenceLine.hxx>
#include <BOPTools_ListOfInterference.hxx>
#include <BOPTools_Interference.hxx>
#include <BOPTools_PShapeShapeInterference.hxx>
static
void GetFullFaceMap(const Standard_Integer nF2,
const BOPTools_InterferencePool& myIntrPool,
TColStd_IndexedMapOfInteger& aMF2);
static
void GetInterferedVertices(const Standard_Integer nF1,
const TColStd_IndexedMapOfInteger& aMF2,
const BOPTools_InterferencePool& myIntrPool,
TColStd_IndexedMapOfInteger& aMV);
//=======================================================================
// function: StickVertices
// purpose:
//=======================================================================
void BOPTools_PaveFiller::StickVertices(const Standard_Integer nF1,
const Standard_Integer nF2,
TColStd_IndexedMapOfInteger& aMV)
{
Standard_Integer i, aNb, iEntity;
TColStd_IndexedMapOfInteger aMF1, aMF2;
//
GetFullFaceMap(nF1, *myIntrPool, aMF1);
GetFullFaceMap(nF2, *myIntrPool, aMF2);
//
aNb=aMF1.Extent();
for (i=1; i<=aNb; ++i) {
iEntity=aMF1(i);
GetInterferedVertices(iEntity, aMF2, *myIntrPool, aMV);
}
//
aNb=aMF2.Extent();
for (i=1; i<=aNb; ++i) {
iEntity=aMF2(i);
GetInterferedVertices(iEntity, aMF1, *myIntrPool, aMV);
}
}
//=======================================================================
// function: GetFullFaceMap
// purpose:
//=======================================================================
void GetFullFaceMap(const Standard_Integer nF2,
const BOPTools_InterferencePool& anIntrPool,
TColStd_IndexedMapOfInteger& aMF2)
{
Standard_Integer nEF2, nVF2;
//
aMF2.Add(nF2);
BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS();
BooleanOperations_OnceExplorer aExp(*myDS);
aExp.Init(nF2, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
nEF2=aExp.Current();
aMF2.Add(nEF2);
}
//
aExp.Init(nF2, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
nVF2=aExp.Current();
aMF2.Add(nVF2);
}
}
//=======================================================================
// function: GetInterferedVertices
// purpose:
//=======================================================================
void GetInterferedVertices(const Standard_Integer nF1,
const TColStd_IndexedMapOfInteger& aMF2,
const BOPTools_InterferencePool& anIntrPool,
TColStd_IndexedMapOfInteger& aMV)
{
Standard_Integer aIndex, aNewShape, aWith;
BooleanOperations_KindOfInterference aType;
TopAbs_ShapeEnum aShapeType;
BOPTools_ListIteratorOfListOfInterference anIt;
BOPTools_PShapeShapeInterference pI;
//
BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS();
const BOPTools_CArray1OfInterferenceLine& aITable= anIntrPool.InterferenceTable();
const BOPTools_InterferenceLine& aILineF1=aITable(nF1);
const BOPTools_ListOfInterference& aLIF1=aILineF1.RealList();
//
anIt.Initialize(aLIF1);
for (; anIt.More(); anIt.Next()) {
const BOPTools_Interference& anInterference=anIt.Value();
aWith=anInterference.With();
if (aMF2.Contains(aWith)) {
aIndex=anInterference.Index();
aType= anInterference.Type();
pI=anIntrPool.GetInterference(aIndex, aType);
if (pI!=NULL) {
//aNewShape=anIntrPool.NewShape(aIndex, aType);
aNewShape=pI->NewShape();
if (aNewShape) {
const TopoDS_Shape& aS=myDS->Shape(aNewShape);
aShapeType=aS.ShapeType();
if (aShapeType==TopAbs_VERTEX) {
aMV.Add(aNewShape);
}
}
}
}
}
}

View File

@@ -0,0 +1,48 @@
-- File: BOPTools_PaveSet.cdl
-- Created: Thu Feb 8 12:39:32 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PaveSet from BOPTools
---Purpose:
-- class for storing/sorting paves that
-- belong to an edge
uses
ListOfPave from BOPTools,
Pave from BOPTools
is
Create
returns PaveSet from BOPTools;
---Purpose:
--- Empty constructor
---
ChangeSet(me:out)
returns ListOfPave from BOPTools;
---C++: return &
---Purpose:
--- Access to the list
---
Set(me)
returns ListOfPave from BOPTools;
---C++: return const &
---Purpose:
--- Access to the list const
---
Append (me:out; aPave:Pave from BOPTools);
---Purpose:
--- Appends <aPave> to the list
---
SortSet (me:out);
---Purpose:
--- Sorts list in increasing order of paves' parameters
---
fields
myPaveList: ListOfPave from BOPTools;
end PaveSet;

View File

@@ -0,0 +1,80 @@
// File: BOPTools_PaveSet.cxx
// Created: Thu Feb 8 12:47:16 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PaveSet.ixx>
#include <BOPTools_Array1OfPave.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOPTools_QuickSortPave.hxx>
#include <BOPTools_ComparePave.hxx>
#ifdef WNT
#pragma warning ( disable : 4101 )
#endif
//=======================================================================
// function: BOPTools_PaveSet::BOPTools_PaveSet
// purpose:
//=======================================================================
BOPTools_PaveSet::BOPTools_PaveSet() {}
//=======================================================================
// function: ChangeSet
// purpose:
//=======================================================================
BOPTools_ListOfPave& BOPTools_PaveSet::ChangeSet()
{
return myPaveList;
}
//=======================================================================
// function: Set
// purpose:
//=======================================================================
const BOPTools_ListOfPave& BOPTools_PaveSet::Set() const
{
return myPaveList;
}
//=======================================================================
// function: Append
// purpose:
//=======================================================================
void BOPTools_PaveSet::Append(const BOPTools_Pave& aPave)
{
myPaveList.Append(aPave);
}
//=======================================================================
// function: SortSet
// purpose:
//=======================================================================
void BOPTools_PaveSet::SortSet()
{
// Not implemented yet
Standard_Integer aNbPaves, i;
aNbPaves=myPaveList.Extent();
if (aNbPaves>1) {
BOPTools_Array1OfPave anArray1OfPave (1, aNbPaves);
BOPTools_ListIteratorOfListOfPave anIt(myPaveList);
for (i=1; anIt.More(); anIt.Next(), i++) {
const BOPTools_Pave& aPave=anIt.Value();
anArray1OfPave(i)=aPave;
}
BOPTools_QuickSortPave aQuickSortPave;
BOPTools_ComparePave aComparePave;
aQuickSortPave.Sort (anArray1OfPave, aComparePave);
myPaveList.Clear();
for (i=1; i<=aNbPaves; i++){
const BOPTools_Pave& aPave=anArray1OfPave(i);
myPaveList.Append (aPave);
}
}
}
#ifdef WNT
#pragma warning ( default : 4101 )
#endif

View File

@@ -0,0 +1,70 @@
-- File: BOPTools_PointBetween.cdl
-- Created: Thu Apr 19 11:05:34 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class PointBetween from BOPTools
---Purpose:
-- class for storing geometry information about
-- a point between neighbouring paves along
-- an edge
---
uses
Pnt from gp
is
Create
returns PointBetween from BOPTools;
---Purpose:
--- Empty constructor
---
SetParameter (me:out;
T:Real from Standard);
---Purpose:
--- Modifier
--- sets value of the point's parameter on the edge
---
SetUV (me:out;
U:Real from Standard;
V:Real from Standard);
---Purpose:
--- Modifier
--- sets values of the point's parameter on the face
---
SetPnt (me:out;
aP:Pnt from gp);
---Purpose:
--- Modifier
--- sets the 3D-point
---
Parameter (me)
returns Real from Standard ;
---Purpose:
--- Selector
---
UV (me;
U:out Real from Standard;
V:out Real from Standard);
---Purpose:
--- Selector
---
Pnt (me)
returns Pnt from gp;
---C++: return const &
---Purpose:
--- Selector
---
fields
myT : Real from Standard;
myU : Real from Standard;
myV : Real from Standard;
myPnt: Pnt from gp;
end PointBetween;

View File

@@ -0,0 +1,75 @@
// File: BOPTools_PointBetween.cxx
// Created: Thu Apr 19 11:19:20 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_PointBetween.ixx>
//=======================================================================
// function: BOPTools_PointBetween:: BOPTools_PointBetween
// purpose:
//=======================================================================
BOPTools_PointBetween::BOPTools_PointBetween()
:
myT(0.),
myU(0.),
myV(0.)
{}
//=======================================================================
// function: SetParameter
// purpose:
//=======================================================================
void BOPTools_PointBetween::SetParameter(const Standard_Real aT)
{
myT=aT;
}
//=======================================================================
// function: Parameter
// purpose:
//=======================================================================
Standard_Real BOPTools_PointBetween::Parameter()const
{
return myT;
}
//=======================================================================
// function: SetUV
// purpose:
//=======================================================================
void BOPTools_PointBetween::SetUV(const Standard_Real aU,
const Standard_Real aV)
{
myU=aU;
myV=aV;
}
//=======================================================================
// function: UV
// purpose:
//=======================================================================
void BOPTools_PointBetween::UV(Standard_Real& aU,
Standard_Real& aV) const
{
aU=myU;
aV=myV;
}
//=======================================================================
// function: SetPnt
// purpose:
//=======================================================================
void BOPTools_PointBetween::SetPnt (const gp_Pnt& aP)
{
myPnt=aP;
}
//=======================================================================
// function: Pnt
// purpose:
//=======================================================================
const gp_Pnt& BOPTools_PointBetween::Pnt () const
{
return myPnt;
}

View File

@@ -0,0 +1,83 @@
-- File: BOPTools_RoughShapeIntersector.cdl
-- Created: Fri Nov 24 15:07:01 2000
-- Author: Michael KLOKOV
-- <mkk@nizhnox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class RoughShapeIntersector from BOPTools
---Purpose: The class RoughShapeIntersector describes the algorithm of
-- intersection of bounding boxes of
-- shapes stored in ShapesDataStructure.
-- It stores statuses of intersection in 2 dimension array.
uses
Array1OfListOfInteger from TColStd,
ListOfInteger from TColStd,
HArray2OfIntersectionStatus from BOPTools,
IntersectionStatus from BOPTools,
HArray1OfBox from Bnd,
PShapesDataStructure from BooleanOperations
is
Create(PDS: PShapesDataStructure from BooleanOperations)
returns RoughShapeIntersector from BOPTools;
---Purpose:
-- Initializes algorithm by shapes data structure
--
Perform(me: in out);
---Purpose:
-- Perform computations.
--
-- Warning:
-- Using this function, after the destructor of
-- the object pointed by PDS (see constructor)
-- was invoked, lead to crash.
--
TableOfStatus(me)
returns HArray2OfIntersectionStatus from BOPTools;
---C++: return const &
---Purpose:
-- Returns 2 dimension array of status flags.
-- First indices of the array corresponds to indices of
-- subshapes of Object of myPDS.
-- Second indices of array corresponds to indices of
-- subshapes of Tool of myPDS.
--
IsDone(me) returns Boolean from Standard;
---Purpose:
-- Returns False if some errors occured during
-- computations or method Perform
-- was not invoked before,
-- otherwise returns True.
--
-- private methods
Prepare(me: in out)
is private;
PropagateForSuccessors1(me: in out; AncestorsIndex1: Integer from Standard;
AncestorsIndex2: Integer from Standard;
theStatus : IntersectionStatus from BOPTools)
is private;
PropagateForSuccessors2(me: in out; AncestorsIndex1: Integer from Standard;
AncestorsIndex2: Integer from Standard;
theStatus : IntersectionStatus from BOPTools)
is private;
fields
myPDS: PShapesDataStructure from BooleanOperations;
myBoundingBoxes: HArray1OfBox from Bnd;
myTableOfStatus: HArray2OfIntersectionStatus from BOPTools;
---Purpose: First indices of array corresponds to indices of subshapes of Object of myPDS.
-- Second indices of array corresponds to indices of subshapes of Tool of myPDS.
myIsDone: Boolean from Standard;
end RoughShapeIntersector from BOPTools;

View File

@@ -0,0 +1,222 @@
#include <BOPTools_RoughShapeIntersector.ixx>
#include <TopExp_Explorer.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_Array1OfListOfInteger.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <Bnd_Box.hxx>
static Standard_Integer TypeToIndex(const TopAbs_ShapeEnum& theType);
static Bnd_Box GetBoxEnlargedBySubShape(const Standard_Integer theIndex,
const BooleanOperations_PShapesDataStructure& PDS);
// =============================================================================================
// function: Constructor
// =============================================================================================
BOPTools_RoughShapeIntersector::BOPTools_RoughShapeIntersector(const BooleanOperations_PShapesDataStructure& PDS)
:
myIsDone(Standard_False)
{
myPDS = PDS;
}
// =============================================================================================
// function: Perform
// =============================================================================================
void BOPTools_RoughShapeIntersector::Perform()
{
myIsDone = Standard_True;
Prepare();
// check flag myIsDone after Prepare() function
if(!myIsDone)
return;
TColStd_ListOfInteger thelist;
TColStd_Array1OfListOfInteger aSortedByTypeShapes1(TypeToIndex(TopAbs_COMPOUND), TypeToIndex(TopAbs_VERTEX));
aSortedByTypeShapes1.Init(thelist);
TColStd_ListOfInteger thelist1;
TColStd_Array1OfListOfInteger aSortedByTypeShapes2(TypeToIndex(TopAbs_COMPOUND), TypeToIndex(TopAbs_VERTEX));
aSortedByTypeShapes2.Init(thelist1);
Standard_Integer k = 0;
for(k = myTableOfStatus->LowerRow(); k <= myTableOfStatus->UpperRow(); k++) {
aSortedByTypeShapes1(TypeToIndex(myPDS->GetShapeType(k))).Append(k);
}
for(k = myTableOfStatus->LowerCol(); k <= myTableOfStatus->UpperCol(); k++) {
aSortedByTypeShapes2(TypeToIndex(myPDS->GetShapeType(k))).Append(k);
}
//
Standard_Integer aStartIndex = TypeToIndex(TopAbs_COMPOUND);
Standard_Integer anEndIndex = TypeToIndex(TopAbs_VERTEX);
for(Standard_Integer index1 = aStartIndex; index1 <= anEndIndex; index1++) {
//
if(aSortedByTypeShapes1(index1).IsEmpty())
continue;
for(Standard_Integer index2 = aStartIndex; index2 <= anEndIndex; index2++) {
if(aSortedByTypeShapes2(index2).IsEmpty())
continue;
TColStd_ListIteratorOfListOfInteger anIt1;
TColStd_ListIteratorOfListOfInteger anIt2;
for(anIt1.Initialize(aSortedByTypeShapes1.Value(index1)); anIt1.More(); anIt1.Next()) {
for(anIt2.Initialize(aSortedByTypeShapes2.Value(index2)); anIt2.More(); anIt2.Next()) {
//
BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(anIt1.Value(), anIt2.Value());
if(aStatus != BOPTools_UNKNOWN && aStatus != BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED)
continue;
const Bnd_Box& B1 = myBoundingBoxes->Value(anIt1.Value());
const Bnd_Box& B2 = myBoundingBoxes->Value(anIt2.Value());
//
BOPTools_IntersectionStatus aNewValue = BOPTools_BOUNDINGBOXINTERSECTED;
if(B1.IsOut(B2)) {
aNewValue = BOPTools_NONINTERSECTED;
//
PropagateForSuccessors1(anIt1.Value(), anIt2.Value(), aNewValue);
//
}
else {
aNewValue = BOPTools_BOUNDINGBOXINTERSECTED;
const Bnd_Box& BB1 = myPDS->GetBoundingBox(anIt1.Value());
const Bnd_Box& BB2 = myPDS->GetBoundingBox(anIt2.Value());
if(BB1.IsOut(BB2)) {
aNewValue = BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED;
}
}
// It is important to place this line after Propagation
myTableOfStatus->ChangeValue(anIt1.Value(), anIt2.Value()) = aNewValue;
}
}
}
}
}
// =============================================================================================
// function: TableOfStatus
// =============================================================================================
const Handle(BOPTools_HArray2OfIntersectionStatus)& BOPTools_RoughShapeIntersector::TableOfStatus() const
{
return myTableOfStatus;
}
// =============================================================================================
// function: Prepare
// =============================================================================================
void BOPTools_RoughShapeIntersector::Prepare()
{
myIsDone = Standard_False;
if(!myTableOfStatus.IsNull() &&
(myPDS != NULL) &&
(myTableOfStatus->LowerRow() == 1) &&
(myTableOfStatus->UpperRow() == myPDS->NumberOfShapesOfTheObject()) &&
(myTableOfStatus->LowerCol() == myPDS->NumberOfShapesOfTheObject() + 1) &&
(myTableOfStatus->UpperCol() == myPDS->NumberOfShapesOfTheObject() + myPDS->NumberOfShapesOfTheTool())) {
myIsDone = Standard_True;
}
else {
if(myPDS != NULL) {
Standard_Integer firstlowerindex = 1;
Standard_Integer firstupperindex = myPDS->NumberOfShapesOfTheObject();
Standard_Integer secondlowerindex = myPDS->NumberOfShapesOfTheObject() + 1;
Standard_Integer secondupperindex = myPDS->NumberOfShapesOfTheTool() + myPDS->NumberOfShapesOfTheObject();
myTableOfStatus = new BOPTools_HArray2OfIntersectionStatus(firstlowerindex, firstupperindex,
secondlowerindex, secondupperindex);
myIsDone = Standard_True;
}
}
if(!myIsDone)
return;
myTableOfStatus->Init(BOPTools_UNKNOWN);
//
myBoundingBoxes = new Bnd_HArray1OfBox(1, myPDS->NumberOfSourceShapes());
for(Standard_Integer i = 1; i <= myPDS->NumberOfSourceShapes(); i++) {
const Bnd_Box& aBox = GetBoxEnlargedBySubShape(i, myPDS);
myBoundingBoxes->SetValue(i, aBox);
}
}
// =============================================================================================
// function: IsDone
// =============================================================================================
Standard_Boolean BOPTools_RoughShapeIntersector::IsDone() const
{
return myIsDone;
}
// =============================================================================================
// function: PropagateForSuccessors1
// =============================================================================================
void BOPTools_RoughShapeIntersector::PropagateForSuccessors1(const Standard_Integer AncestorsIndex1,
const Standard_Integer AncestorsIndex2,
const BOPTools_IntersectionStatus theStatus)
{
if(myTableOfStatus->Value(AncestorsIndex1, AncestorsIndex2) != BOPTools_UNKNOWN)
return;
myTableOfStatus->ChangeValue(AncestorsIndex1, AncestorsIndex2) = theStatus;
PropagateForSuccessors2(AncestorsIndex1, AncestorsIndex2, theStatus);
Standard_Integer i = 1;
for(i = 1; i <= myPDS->NumberOfSuccessors(AncestorsIndex1); i++) {
Standard_Integer asuccessor1 = myPDS->GetSuccessor(AncestorsIndex1, i);
PropagateForSuccessors1(asuccessor1, AncestorsIndex2, theStatus);
}
}
// =============================================================================================
// function: PropagateForSuccessors2
// =============================================================================================
void BOPTools_RoughShapeIntersector::PropagateForSuccessors2(const Standard_Integer AncestorsIndex1,
const Standard_Integer AncestorsIndex2,
const BOPTools_IntersectionStatus theStatus)
{
for(Standard_Integer j = 1; j <= myPDS->NumberOfSuccessors(AncestorsIndex2); j++) {
Standard_Integer asuccessor2 = myPDS->GetSuccessor(AncestorsIndex2, j);
if(myTableOfStatus->Value(AncestorsIndex1, asuccessor2) == BOPTools_UNKNOWN) {
myTableOfStatus->ChangeValue(AncestorsIndex1, asuccessor2) = theStatus;
PropagateForSuccessors2(AncestorsIndex1, asuccessor2, theStatus);
}
}
}
// =============================================================================================
// function: TypeToIndex
// =============================================================================================
Standard_Integer TypeToIndex(const TopAbs_ShapeEnum& theType) {
return (Standard_Integer) theType;
}
// =============================================================================================
// function: GetBoxEnlargedBySubShape
// =============================================================================================
Bnd_Box GetBoxEnlargedBySubShape(const Standard_Integer theIndex,
const BooleanOperations_PShapesDataStructure& PDS) {
Bnd_Box aBox = PDS->GetBoundingBox(theIndex);
for(Standard_Integer i=1; i<= PDS->NumberOfSuccessors(theIndex); i++) {
Standard_Integer asuccessorindex = PDS->GetSuccessor(theIndex, i);
aBox.Add(GetBoxEnlargedBySubShape(asuccessorindex, PDS));
}
return aBox;
}

View File

@@ -0,0 +1,173 @@
-- File: BOPTools_SSInterference.cdl
-- Created: Tue Nov 21 15:26:34 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class SSInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose: class for storing a Face/Face interference
--- Each F/F interference contains information about
--- 1. myPBs - PaveBlocks (made from edges from the faces
--- that are IN-2D or ON-2D;
--- 2. myCurves- Sequence of curves of intersection;
--- 3. myTangentFacesFlag - The BOOL flag indicates that
--- the faces are SD in terms of the F/F Intersector.
--- 4. mySenseFlag - value that is equal +1 or -1 depending
--- on scalar product between normals to each face. This
--- valie is valid for the SDF only.
--- 5. myAlonePnts - contains 3D-points that are place
--- of intersection between the two faces
--- 6. myAloneVertices - contains indices of vertices
--- that correspond to the points myAlonePnts;
---
uses
PaveBlock from BOPTools,
PaveSet from BOPTools,
ListOfPaveBlock from BOPTools,
SequenceOfCurves from BOPTools,
IndexedDataMapOfIntegerState from BOPTools,
SequenceOfCurves from IntTools,
SequenceOfPntOn2Faces from IntTools,
ListOfInteger from TColStd
--
is
Create
returns SSInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1: Integer from Standard;
anIndex2: Integer from Standard;
aTolR3D : Real from Standard;
aTolR2D : Real from Standard;
aCurves : SequenceOfCurves from IntTools;
aPnts : SequenceOfPntOn2Faces from IntTools)
returns SSInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
--- aTolR3D - value of tolerance to reach in 3D-space
--- aTolR2D - value of tolerance to reach in 2D-space
--- aCurves see IntTools_Curve for details, please
---
AppendBlock(me:out;
aPB:PaveBlock from BOPTools);
---Purpose:
--- Modifier
---
PaveBlocks(me)
returns ListOfPaveBlock from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
NewPaveSet(me:out)
returns PaveSet from BOPTools;
---C++: return &
---Purpose:
--- Selector
---
TolR3D (me)
returns Real from Standard;
---Purpose:
--- Selector
---
TolR2D (me)
returns Real from Standard;
---Purpose:
--- Selector
---
Curves(me:out)
returns SequenceOfCurves from BOPTools;
---C++: return &
---Purpose:
--- Selector
---
SetTangentFacesFlag(me:out;
aFlag:Boolean from Standard);
---Purpose:
--- Modifier
---
IsTangentFaces(me)
returns Boolean from Standard;
---Purpose:
--- Selector
---
SetSenseFlag (me:out;
aFlag:Integer from Standard);
---Purpose:
--- Modifier
---
SenseFlag (me)
returns Integer from Standard;
---Purpose:
--- Selector
---
SetStatesMap(me:out;
aStatesMap: IndexedDataMapOfIntegerState from BOPTools);
---Purpose:
--- Modifier
---
StatesMap(me)
returns IndexedDataMapOfIntegerState from BOPTools;
---C++: return const &
---Purpose:
--- Selector
---
SetAlonePnts(me:out;
aPnts:SequenceOfPntOn2Faces from IntTools);
---Purpose:
--- Modifier
---
AlonePnts(me)
returns SequenceOfPntOn2Faces from IntTools;
---C++: return const &
---Purpose:
--- Selector
---
AloneVertices(me:out)
returns ListOfInteger from TColStd;
---C++: return &
---Purpose:
--- Selector
---
--modified by NIZNHY-PKV Fri Jun 30 10:05:36 2006f
SetSharedEdges(me:out;
aLS:ListOfInteger from TColStd);
---Purpose:
--- Modifier
---
SharedEdges(me)
returns ListOfInteger from TColStd;
---C++: return const &
---Purpose:
--- Selector
---
--modified by NIZNHY-PKV Fri Jun 30 10:05:41 2006t
fields
myPBs : ListOfPaveBlock from BOPTools is protected;
myNewPaveSet : PaveSet from BOPTools is protected;
myTolR3D : Real from Standard is protected;
myTolR2D : Real from Standard is protected;
myCurves : SequenceOfCurves from BOPTools is protected;
myAlonePnts : SequenceOfPntOn2Faces from IntTools is protected;
myAloneVertices : ListOfInteger from TColStd is protected;
myTangentFacesFlag : Boolean from Standard is protected;
mySenseFlag : Integer from Standard is protected;
myStatesMap : IndexedDataMapOfIntegerState from BOPTools is protected;
--modified by NIZNHY-PKV Fri Jun 30 10:02:27 2006f
mySharedEdges : ListOfInteger from TColStd is protected;
--modified by NIZNHY-PKV Fri Jun 30 10:02:34 2006
end SSInterference;

View File

@@ -0,0 +1,251 @@
// File: BOPTools_SSInterference.cxx
// Created: Tue Nov 21 15:29:28 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_SSInterference.ixx>
#include <IntTools_Curve.hxx>
#include <IntTools_SequenceOfCurves.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_PntOn2Faces.hxx>
#include <BOPTools_Curve.hxx>
//
//modified by NIZNHY-PKV Fri Jun 30 10:08:51 2006
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
//=======================================================================
//function : BOPTools_SSInterference
//purpose :
//=======================================================================
BOPTools_SSInterference::BOPTools_SSInterference()
:
BOPTools_ShapeShapeInterference(0, 0),
myTangentFacesFlag(Standard_False),
mySenseFlag(0)
{}
//=======================================================================
//function : BOPTools_SSInterference::BOPTools_SSInterference
//purpose :
//=======================================================================
BOPTools_SSInterference::BOPTools_SSInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2,
const Standard_Real aTolR3D,
const Standard_Real aTolR2D,
const IntTools_SequenceOfCurves& aCvs,
const IntTools_SequenceOfPntOn2Faces& aPnts)
:
BOPTools_ShapeShapeInterference(anIndex1, anIndex2),
myTangentFacesFlag(Standard_False),
mySenseFlag(0)
{
myTolR3D=aTolR3D;
myTolR2D=aTolR2D;
myCurves.Clear();
Standard_Integer i, aNbCurves;
aNbCurves=aCvs.Length();
for (i=1; i<=aNbCurves; i++) {
const IntTools_Curve& aIC=aCvs(i);
BOPTools_Curve aBC(aIC);
myCurves.Append(aBC);
}
//
SetAlonePnts(aPnts);
}
//=======================================================================
//function : AppendBlock
//purpose :
//=======================================================================
void BOPTools_SSInterference::AppendBlock(const BOPTools_PaveBlock& aPB)
{
myPBs.Append(aPB);
}
//=======================================================================
//function : PaveBlocks
//purpose :
//=======================================================================
const BOPTools_ListOfPaveBlock& BOPTools_SSInterference::PaveBlocks() const
{
return myPBs;
}
//=======================================================================
//function : TolR3D
//purpose :
//=======================================================================
Standard_Real BOPTools_SSInterference::TolR3D() const
{
return myTolR3D;
}
//=======================================================================
//function : TolR2D
//purpose :
//=======================================================================
Standard_Real BOPTools_SSInterference::TolR2D() const
{
return myTolR2D;
}
//=======================================================================
//function : Curves
//purpose :
//=======================================================================
BOPTools_SequenceOfCurves& BOPTools_SSInterference::Curves()
{
return myCurves;
}
//=======================================================================
//function : NewPaveSet
//purpose :
//=======================================================================
BOPTools_PaveSet& BOPTools_SSInterference::NewPaveSet()
{
return myNewPaveSet;
}
//=======================================================================
//function : SetTangentFacesFlag
//purpose :
//=======================================================================
void BOPTools_SSInterference::SetTangentFacesFlag(const Standard_Boolean aFlag)
{
myTangentFacesFlag=aFlag;
}
//=======================================================================
//function : IsTangentFaces
//purpose :
//=======================================================================
Standard_Boolean BOPTools_SSInterference::IsTangentFaces()const
{
return myTangentFacesFlag;
}
//=======================================================================
// function: SetSenseFlag
// purpose:
//=======================================================================
void BOPTools_SSInterference::SetSenseFlag (const Standard_Integer iFlag)
{
mySenseFlag=iFlag;
}
//=======================================================================
// function: SenseFlag
// purpose:
//=======================================================================
Standard_Integer BOPTools_SSInterference::SenseFlag () const
{
return mySenseFlag;
}
//=======================================================================
// function: SetStatesMap
// purpose:
//=======================================================================
void BOPTools_SSInterference::SetStatesMap (const BOPTools_IndexedDataMapOfIntegerState& aMap)
{
myStatesMap=aMap;
}
//=======================================================================
// function: StatesMap
// purpose:
//=======================================================================
const BOPTools_IndexedDataMapOfIntegerState& BOPTools_SSInterference::StatesMap () const
{
return myStatesMap;
}
//=======================================================================
// function: SetAlonePnts
// purpose:
//=======================================================================
void BOPTools_SSInterference::SetAlonePnts (const IntTools_SequenceOfPntOn2Faces& aPnts)
{
Standard_Integer i, aNb;
myAlonePnts.Clear();
aNb=aPnts.Length();
for (i=1; i<=aNb; ++i) {
const IntTools_PntOn2Faces& aPntOn2Faces=aPnts(i);
myAlonePnts.Append(aPntOn2Faces);
}
}
//=======================================================================
// function: AlonePnts
// purpose:
//=======================================================================
const IntTools_SequenceOfPntOn2Faces& BOPTools_SSInterference::AlonePnts ()const
{
return myAlonePnts;
}
//=======================================================================
// function: AloneVertices
// purpose:
//=======================================================================
TColStd_ListOfInteger& BOPTools_SSInterference::AloneVertices ()
{
return myAloneVertices;
}
//modified by NIZNHY-PKV Fri Jun 30 10:06:12 2006f
//=======================================================================
// function: SetSharedEdges
// purpose:
//=======================================================================
void BOPTools_SSInterference::SetSharedEdges (const TColStd_ListOfInteger& aLS)
{
Standard_Integer nE;
TColStd_ListIteratorOfListOfInteger aIt;
//
aIt.Initialize(aLS);
for(; aIt.More(); aIt.Next()) {
nE=aIt.Value();
mySharedEdges.Append(nE);
}
}
//=======================================================================
// function: SharedEdges
// purpose:
//=======================================================================
const TColStd_ListOfInteger& BOPTools_SSInterference::SharedEdges()const
{
return mySharedEdges;
}
/*
//=======================================================================
// function: SetSharedEdges
// purpose:
//=======================================================================
void BOPTools_SSInterference::SetSharedEdges (const TopTools_ListOfShape& aLS)
{
TopTools_ListIteratorOfListOfShape aIt;
//
aIt.Initialize(aLS);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
mySharedEdges.Append(aE);
}
}
//=======================================================================
// function: SharedEdges
// purpose:
//=======================================================================
const TopTools_ListOfShape& BOPTools_SSInterference::SharedEdges()const
{
return mySharedEdges;
}
*/
//modified by NIZNHY-PKV Fri Jun 30 10:06:14 2006t

View File

@@ -0,0 +1,64 @@
-- File: BOPTools_SSIntersectionAttribute.cdl
-- Created: Mon Mar 4 12:01:34 2002
-- Author: Michael KLOKOV
-- <mkk@kurox>
---Copyright: Matra Datavision 2002
class SSIntersectionAttribute from BOPTools
---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 SSIntersectionAttribute from BOPTools;
---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 SSIntersectionAttribute from BOPTools;

View File

@@ -0,0 +1,44 @@
// File: BOPTools_SSIntersectionAttribute.cxx
// Created: Mon Mar 4 12:05:23 2002
// Author: Michael KLOKOV
// <mkk@kurox>
#include <BOPTools_SSIntersectionAttribute.ixx>
//=======================================================================
// function: BOPTools_SSIntersectionAttribute
// purpose:
//=======================================================================
BOPTools_SSIntersectionAttribute::BOPTools_SSIntersectionAttribute(const Standard_Boolean Aproximation,
const Standard_Boolean PCurveOnS1,
const Standard_Boolean PCurveOnS2)
{
myApproximation = Aproximation;
myPCurve1 = PCurveOnS1;
myPCurve2 = PCurveOnS2;
}
//=======================================================================
// function: Approximation
// purpose:
//=======================================================================
void BOPTools_SSIntersectionAttribute::Approximation(const Standard_Boolean theFlag)
{
myApproximation = theFlag;
}
//=======================================================================
// function: PCurveOnS1
// purpose:
//=======================================================================
void BOPTools_SSIntersectionAttribute::PCurveOnS1(const Standard_Boolean theFlag)
{
myPCurve1 = theFlag;
}
//=======================================================================
// function: PCurveOnS2
// purpose:
//=======================================================================
void BOPTools_SSIntersectionAttribute::PCurveOnS2(const Standard_Boolean theFlag)
{
myPCurve2 = theFlag;
}

View File

@@ -0,0 +1,30 @@
// File: BOPTools_SSIntersectionAttribute.lxx
// Created: Mon Mar 4 12:05:47 2002
// Author: Michael KLOKOV
// <mkk@kurox>
//=======================================================================
// function:Approximation
// purpose:
//=======================================================================
inline Standard_Boolean BOPTools_SSIntersectionAttribute::Approximation() const
{
return myApproximation;
}
//=======================================================================
// function:PCurveOnS1
// purpose:
//=======================================================================
inline Standard_Boolean BOPTools_SSIntersectionAttribute::PCurveOnS1() const
{
return myPCurve1;
}
//=======================================================================
// function:PCurveOnS2
// purpose:
//=======================================================================
inline Standard_Boolean BOPTools_SSIntersectionAttribute::PCurveOnS2() const
{
return myPCurve2;
}

View File

@@ -0,0 +1,77 @@
-- File: BOPTools_ShapeShapeInterference.cdl
-- Created: Tue Nov 21 15:16:07 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class ShapeShapeInterference from BOPTools
---Purpose:
-- Root class for storing an Interference
-- between a couple BRep shapes
is
Create
returns ShapeShapeInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1: Integer from Standard;
anIndex2: Integer from Standard)
returns ShapeShapeInterference from BOPTools;
---Purpose:
--- Constructor
---
SetIndex1(me:out; anIndex1:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the first shape from the couple
---
SetIndex2(me:out; anIndex2:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the second shape from the couple
---
SetNewShape(me:out; anIndex:Integer from Standard);
---Purpose:
--- Modifier
--- Sets DS-index for the new shape
---
Index1(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Index2(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
Indices(me;
anIndex1:out Integer from Standard;
anIndex2:out Integer from Standard);
---Purpose:
--- Selector
---
OppositeIndex(me;
anIndex:Integer from Standard)
returns Integer from Standard;
---Purpose:
--- Selector
--- Gets the value of index
--- if anIndex==myIndex1 it returns myIndex2;
--- if anIndex==myIndex2 it returns myIndex1;
--- otherwise it returns 0;
---
NewShape(me)
returns Integer from Standard;
---Purpose:
--- Selector
---
fields
myIndex1 : Integer from Standard;
myIndex2 : Integer from Standard;
myNewShape: Integer from Standard;
end ShapeShapeInterference;

View File

@@ -0,0 +1,111 @@
// File: BOPTools_ShapeShapeInterference.cxx
// Created: Tue Nov 21 15:21:34 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_ShapeShapeInterference.ixx>
//=======================================================================
//function : BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference
//purpose :
//=======================================================================
BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference()
:
myIndex1(0), myIndex2(0), myNewShape(0)
{}
//=======================================================================
//function : BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference
//purpose :
//=======================================================================
BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2)
:
myIndex1(anIndex1),
myIndex2(anIndex2),
myNewShape(0)
{}
//=======================================================================
//function : SetIndex1
//purpose :
//=======================================================================
void BOPTools_ShapeShapeInterference::SetIndex1(const Standard_Integer anIndex1)
{
myIndex1=anIndex1;
}
//=======================================================================
//function : SetIndex2
//purpose :
//=======================================================================
void BOPTools_ShapeShapeInterference::SetIndex2(const Standard_Integer anIndex2)
{
myIndex2=anIndex2;
}
//=======================================================================
//function : SetNewShape
//purpose :
//=======================================================================
void BOPTools_ShapeShapeInterference::SetNewShape(const Standard_Integer anIndex)
{
myNewShape=anIndex;
}
//=======================================================================
//function : Index1
//purpose :
//=======================================================================
Standard_Integer BOPTools_ShapeShapeInterference::Index1() const
{
return myIndex1;
}
//=======================================================================
//function : Index2
//purpose :
//=======================================================================
Standard_Integer BOPTools_ShapeShapeInterference::Index2() const
{
return myIndex2;
}
//=======================================================================
//function : OppositeIndex
//purpose :
//=======================================================================
Standard_Integer BOPTools_ShapeShapeInterference::OppositeIndex
(const Standard_Integer anIndex) const
{
if (anIndex==myIndex1) {
return myIndex2;
}
else if(anIndex==myIndex2) {
return myIndex1;
}
else {
return 0;
}
}
//=======================================================================
//function : Indices
//purpose :
//=======================================================================
void BOPTools_ShapeShapeInterference::Indices(Standard_Integer& i1,
Standard_Integer& i2) const
{
i1=myIndex1;
i2=myIndex2;
}
//=======================================================================
//function : NewShape
//purpose :
//=======================================================================
Standard_Integer BOPTools_ShapeShapeInterference::NewShape() const
{
return myNewShape;
}

View File

@@ -0,0 +1,59 @@
-- File: BOPTools_SolidStateFiller.cdl
-- Created: Mon May 28 12:39:19 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class SolidStateFiller from BOPTools inherits StateFiller from BOPTools
---Purpose:
-- class to compute states (3D) for the edges (and theirs
--- split parts), vertices, wires, faces, shells
---
uses
PPaveFiller from BOPTools,
PaveFiller from BOPTools,
PShapesDataStructure from BooleanOperations,
StateOfShape from BooleanOperations,
Shape from TopoDS,
Edge from TopoDS,
State from TopAbs,
ShapeEnum from TopAbs
is
Create (aFiller: PaveFiller from BOPTools)
returns SolidStateFiller from BOPTools;
---Purpose:
--- Constructor
---
Do(me:out)
is redefined;
---Purpose:
--- Launch the Filler
---
---
---
--- private block
---
DoNonSections (me:out;
iRankShape: Integer from Standard)
is private;
DoShellNonSections (me:out;
iRankShape: Integer from Standard)
is private;
DoSections (me:out)
is private;
IsFaceIntersected(me:out;
nF: Integer from Standard)
returns Boolean from Standard
is private;
end SolidStateFiller;

View File

@@ -0,0 +1,917 @@
// File: BOPTools_SolidStateFiller.cxx
// Created: Mon May 28 12:42:08 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_SolidStateFiller.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_State.hxx>
#include <Geom_Curve.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <gp_Pnt.hxx>
#include <IntTools_Tools.hxx>
#include <BooleanOperations_StateOfShape.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
#include <BOPTools_ListOfShapeEnum.hxx>
#include <BOPTools_ListIteratorOfListOfShapeEnum.hxx>
#include <BOPTools_IndexedDataMapOfShapeWithState.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_SplitShapesPool.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_CArray1OfESInterference.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfESInterference.hxx>
#include <BOPTools_ESInterference.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOPTools_SequenceOfCurves.hxx>
#include <BOPTools_Curve.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_CommonBlockPool.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_StateFiller.hxx>
static
void IntersectionStates(const TopoDS_Shape& aE,
const TopTools_IndexedDataMapOfShapeListOfShape& aM,
TopTools_IndexedMapOfShape& anIntersectedShapes);
static
void PropagateState(const TopoDS_Shape& aS,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
TopTools_IndexedMapOfShape& aProcessedShapes);
static
void PropagateState(const TopoDS_Shape& aF,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aEFMap,
TopTools_IndexedMapOfShape& aProcessedShapes);
static
Standard_Boolean HasConnexity(const TopoDS_Shape& aS,
const BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
BooleanOperations_StateOfShape& aState);
// Peter KURNEV
// p-kurnev@opencascade.com
//=======================================================================
// function: BOPTools_SolidStateFiller::BOPTools_SolidStateFiller
// purpose:
//=======================================================================
BOPTools_SolidStateFiller::BOPTools_SolidStateFiller(const BOPTools_PaveFiller& aFiller)
:
BOPTools_StateFiller(aFiller)
{
}
//=======================================================================
// function: Do
// purpose:
//=======================================================================
void BOPTools_SolidStateFiller::Do()
{
const TopoDS_Shape& anObj=myDS->Object();
const TopoDS_Shape& aTool=myDS->Tool();
//
myIsDone=Standard_True;
//
TopAbs_ShapeEnum aT1, aT2;
aT1=anObj.ShapeType();
aT2=aTool.ShapeType();
if (aT1==TopAbs_FACE) {
aT1=TopAbs_SHELL;
}
if (aT2==TopAbs_FACE) {
aT2=TopAbs_SHELL;
}
if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) {
DoNonSections(1);
DoNonSections(2);
DoSections();
}
else if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) {
DoShellNonSections(1);
DoShellNonSections(2);
DoSections();
}
else if (aT1==TopAbs_SHELL && aT2==TopAbs_SOLID) {
DoNonSections(1);
DoShellNonSections(2);
DoSections();
}
else if (aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) {
DoShellNonSections(1);
DoNonSections(2);
DoSections();
}
else {
myIsDone=!myIsDone;
}
}
//=======================================================================
// function: DoNonSections
// purpose:
//=======================================================================
void BOPTools_SolidStateFiller::DoNonSections(const Standard_Integer iRankObj)
{
//
// 0. Restore data and preparing
const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool();
const TopoDS_Shape& aTool=(iRankObj==1) ? myDS->Tool() : myDS->Object();
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj);
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool();
Standard_Integer i, nE, nF, aNbPaveBlocks, aNb;
BooleanOperations_StateOfShape aState;
TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes;
TopTools_IndexedDataMapOfShapeListOfShape aM, aMVE, aMEF;
//
// aM Map
TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_WIRE , TopAbs_FACE , aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_FACE , TopAbs_SHELL, aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_SHELL, TopAbs_SOLID, aM);
//
// VE Map
TopExp::MapShapesAndAncestors (anObj, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
//
// 1. anIntersectedShapes
//
// 1.1. Check EF FF interferences with nF
TopExp::MapShapes(anObj, TopAbs_FACE, aEM);
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aF=aEM(i);
nF=aDSMap.FindFromKey(aF);
Standard_Boolean bExists=IsFaceIntersected(nF);
if (bExists) {
anIntersectedShapes.Add(aF);
IntersectionStates (aF, aM, anIntersectedShapes);
}
}
//
aEM.Clear();
TopExp::MapShapes(anObj, TopAbs_EDGE, aEM);
//
// 1.2. Edges that have Split parts
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aEM(i);
nE=aDSMap.FindFromKey(aE);
const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nE));
aNbPaveBlocks=aSplitEdges.Extent();
//
if (!aNbPaveBlocks) {
continue;
}
//
if (aNbPaveBlocks==1) {
const BOPTools_ListOfCommonBlock& aCBlocks=aCommonBlockPool(myDS->RefEdge(nE));
if (!aCBlocks.Extent()) {
const BOPTools_PaveBlock& aPB=aSplitEdges.First();
Standard_Integer nEB=aPB.Edge();
if (nEB==aPB.OriginalEdge()) {
Standard_Boolean bHasInterference=//;
Standard_False; //LNX
Standard_Integer j, aNbSuc, nV;
aNbSuc=myDS->NumberOfSuccessors(nEB);
for (j=1; j<=aNbSuc; j++) {
nV=myDS->GetSuccessor(nE, j);
bHasInterference=myIntrPool->HasInterference(nV);
if (bHasInterference) {
break;
}
}
if (!bHasInterference) {
continue;
}
}
}
}
//
anIntersectedShapes.Add(aE);
IntersectionStates (aE, aM, anIntersectedShapes);
} // for (i=1; i<=aNb; i++)
//
// 1.3. Write Intersected state for anIntersectedShapes to the DS
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, BooleanOperations_INTERSECTED);
}
//
// 2. aNonIntersectedShapes
//
aNb=aM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aM.FindKey(i);
if (!anIntersectedShapes.Contains(aS)) {
aNonIntersectedShapes.Add(aS);
}
}
//
// 2.1. Processing of Non-intersected shapes
BRep_Builder BB;
TopoDS_Compound aCompound;
BB.MakeCompound(aCompound);
aNb=aNonIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aNonIntersectedShapes(i);
BB.Add(aCompound, aS);
}
TopExp::MapShapesAndAncestors (aCompound, TopAbs_EDGE, TopAbs_FACE, aMEF);
//
TopTools_IndexedMapOfShape aProcessedShapes;
BOPTools_IndexedDataMapOfShapeWithState aSWS;
Standard_Boolean bHasConnexity;
//
BOPTools_ListOfShapeEnum aEnumList;
aEnumList.Append(TopAbs_SHELL);
aEnumList.Append(TopAbs_FACE);
aEnumList.Append(TopAbs_WIRE);
aEnumList.Append(TopAbs_EDGE);
BOPTools_ListIteratorOfListOfShapeEnum anIt(aEnumList);
for (; anIt.More(); anIt.Next()) {
TopAbs_ShapeEnum anEnum=anIt.Value();
aEM.Clear();
TopExp::MapShapes(aCompound, anEnum, aEM);
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aEM(i);
//
// DEBUG
//nE=aDSMap.FindFromKey(aS);
//
if (!aProcessedShapes.Contains(aS)) {
bHasConnexity=HasConnexity(aS, aSWS, aMVE, aState);
if (!bHasConnexity) {
aState=BOPTools_StateFiller::ClassifyShapeByRef (aS, aTool);
}
aSWS.Add(aS, aState);
aProcessedShapes.Add(aS);
if (anEnum==TopAbs_FACE) {
PropagateState(aS, aState, myDS, iRankObj, aSWS, aMEF, aProcessedShapes);
}
else {
PropagateState(aS, aState, myDS, iRankObj, aSWS, aProcessedShapes);
}
}
}
}
//
// 2.2. Write Stats for Non-intersected Shapes to the DS
aNb=aSWS.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aSWS.FindKey(i);
aState=aSWS.FindFromIndex(i);
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, aState);
}
//---------------------------------------------------
//
// 3. Intersected Edges' Processing
//
//---------------------------------------------------
Standard_Integer nSp, aNBVertices, nV1, nV2;
BooleanOperations_StateOfShape aStV1, aStV2;
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
if (aS.ShapeType()==TopAbs_EDGE) {
nE=aDSMap.FindFromKey(aS);
//
// 3.1. On Parts Processing
const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
const BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB;
BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE);
nSp=aPB.Edge();
myDS->SetState(nSp, BooleanOperations_ON);
}
//
// 3.2. IN, OUT Parts Processing
const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits);
for (; anItPB.More(); anItPB.Next()) {
const BOPTools_PaveBlock& aPB=anItPB.Value();
nSp=aPB.Edge();
const TopoDS_Shape& aSplit=myDS->Shape(nSp);
aState=myDS->GetState(nSp);
if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){
aNBVertices=myDS->NumberOfSuccessors(nE);
if (aNBVertices==2) {
nV1=myDS->GetSuccessor(nSp, 1);
aStV1=myDS->GetState(nV1);
nV2=myDS->GetSuccessor(nSp, 2);
aStV2=myDS->GetState(nV2);
if ((aStV1==BooleanOperations_IN || aStV1==BooleanOperations_OUT)
&& (aStV2==BooleanOperations_ON)) {
myDS->SetState(nSp, aStV1);
}
else if ((aStV2==BooleanOperations_IN || aStV2==BooleanOperations_OUT)
&& (aStV1==BooleanOperations_ON)) {
myDS->SetState(nSp, aStV2);
}
else {
aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool);
myDS->SetState(nSp, aState);
if (aStV1==BooleanOperations_UNKNOWN) {
myDS->SetState(nV1, aState);
}
if (aStV2==BooleanOperations_UNKNOWN) {
myDS->SetState(nV2, aState);
}
}
}// if (aNBVertices==2)
else {
aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool);
myDS->SetState(nSp, aState);
}
}// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED)
}//for (; anItPB.More(); anItPB.Next())
}// if (aS.ShapeType()==TopAbs_EDGE)
}// next "Intersected" Edge
}
//
//=======================================================================
// function: DoShellNonSections
// purpose:
//=======================================================================
void BOPTools_SolidStateFiller::DoShellNonSections(const Standard_Integer iRankObj)
{
const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool();
//
// 0. Restore data and preparing
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj);
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool();
Standard_Integer i, nE, aNbPaveBlocks, aNb, nF1, nF2, iRank, nFx;
BooleanOperations_StateOfShape aState;
TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes;
TopTools_IndexedDataMapOfShapeListOfShape aM;
//
// aM Map
TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_WIRE , TopAbs_FACE , aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_FACE , TopAbs_SHELL, aM);
TopExp::MapShapesAndAncestors (anObj, TopAbs_SHELL, TopAbs_SOLID, aM);
//
// 1. anIntersectedShapes
//
// 1.1. Check EF FF interferences with nF
const BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
aNb=aFFs.Extent();
for (i=1; i<=aNb; i++) {
const BOPTools_SSInterference& aFF=aFFs(i);
// nF1
nF1=aFF.Index1();
nF2=aFF.Index2();
iRank=myDS->Rank(nF1);
nFx=(iRank==myDS->Rank(nF1)) ? nF1 : nF2;
const TopoDS_Shape& aFx=myDS->Shape(nFx);
anIntersectedShapes.Add(aFx);
IntersectionStates (aFx, aM, anIntersectedShapes);
}
//
TopExp::MapShapes(anObj, TopAbs_EDGE, aEM);
//
// 1.2. Edges that have Split parts
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aEM(i);
nE=aDSMap.FindFromKey(aE);
const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nE));
aNbPaveBlocks=aSplitEdges.Extent();
//
if (!aNbPaveBlocks) {
continue;
}
//
if (aNbPaveBlocks==1) {
const BOPTools_ListOfCommonBlock& aCBlocks=aCommonBlockPool(myDS->RefEdge(nE));
if (!aCBlocks.Extent()) {
const BOPTools_PaveBlock& aPB=aSplitEdges.First();
Standard_Integer nEB=aPB.Edge();
if (nEB==aPB.OriginalEdge()) {
Standard_Boolean bHasInterference=//; LNX
Standard_False;//LNX
Standard_Integer j, aNbSuc, nV;
aNbSuc=myDS->NumberOfSuccessors(nEB);
for (j=1; j<=aNbSuc; j++) {
nV=myDS->GetSuccessor(nE, j);
bHasInterference=myIntrPool->HasInterference(nV);
if (bHasInterference) {
break;
}
}
if (!bHasInterference) {
continue;
}
}
}
}
//
anIntersectedShapes.Add(aE);
IntersectionStates (aE, aM, anIntersectedShapes);
} // for (i=1; i<=aNb; i++)
//
// 1.3. Write Intersected state for anIntersectedShapes to the DS
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
if (aDSMap.Contains(aS)) {
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, BooleanOperations_INTERSECTED);
}
}
//
// 2. aNonIntersectedShapes
//
aNb=aM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aM.FindKey(i);
if (!anIntersectedShapes.Contains(aS)) {
aNonIntersectedShapes.Add(aS);
}
}
//
// 2.1. Write Stats for Non-intersected Shapes to the DS
aNb=aNonIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aNonIntersectedShapes(i);
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, BooleanOperations_OUT);
}
//---------------------------------------------------
//
// 3. Intersected Edges' Processing
//
//---------------------------------------------------
Standard_Integer nSp;
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
if (aS.ShapeType()==TopAbs_EDGE) {
nE=aDSMap.FindFromKey(aS);
//
// 3.1. On Parts Processing
const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
const BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB;
BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE);
nSp=aPB.Edge();
myDS->SetState(nSp, BooleanOperations_ON);
}
//
// 3.2. IN, OUT Parts Processing
const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits);
for (; anItPB.More(); anItPB.Next()) {
const BOPTools_PaveBlock& aPB=anItPB.Value();
nSp=aPB.Edge();
//const TopoDS_Shape& aSplit=myDS->Shape(nSp);//LNX
aState=myDS->GetState(nSp);
if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){
myDS->SetState(nSp, BooleanOperations_OUT);
}// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED)
}//for (; anItPB.More(); anItPB.Next())
}// if (aS.ShapeType()==TopAbs_EDGE)
}// next "Intersected" Edge
}
//
//=======================================================================
// function: DoSections
// purpose:
//=======================================================================
void BOPTools_SolidStateFiller::DoSections()
{
Standard_Integer i, j, aNb, aNbCurves, n1, n2, nE;
BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
aNb=aFFs.Extent();
for (i=1; i<=aNb; i++) {
BOPTools_SSInterference& aFF=aFFs(i);
n1=aFF.Index1();
n2=aFF.Index2();
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
aNbCurves=aSC.Length();
for (j=1; j<=aNbCurves; j++) {
const BOPTools_Curve& aBC=aSC(j);
const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
for (; anIt.More(); anIt.Next()) {
const BOPTools_PaveBlock& aPB=anIt.Value();
nE=aPB.Edge();
myDS->SetState(nE, BooleanOperations_ON);
}
}
}
}
//=======================================================================
// function: IsFaceIntersected
// purpose:
//=======================================================================
Standard_Boolean BOPTools_SolidStateFiller::IsFaceIntersected(const Standard_Integer nF)
{
Standard_Boolean bFlag=Standard_False;
Standard_Integer i, aNb, n1, n2;
const BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
aNb=aEFs.Extent();
for (i=1; i<=aNb; i++) {
const BOPTools_ESInterference& aEF=aEFs(i);
n1=aEF.Index1();
n2=aEF.Index2();
if (n1==nF || n2==nF) {
return !bFlag;
}
}
const BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
aNb=aFFs.Extent();
for (i=1; i<=aNb; i++) {
const BOPTools_SSInterference& aFF=aFFs(i);
n1=aFF.Index1();
n2=aFF.Index2();
if (n1==nF || n2==nF) {
return !bFlag;
}
}
return bFlag;
}
//=======================================================================
// function: PropagateState [for faces]
// purpose:
//=======================================================================
void PropagateState(const TopoDS_Shape& aF,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aEFMap,
TopTools_IndexedMapOfShape& aProcessedShapes)
{
// PropagateState for Sub-Shapes
PropagateState (aF, aState, pDS, iRank, aSWS, aProcessedShapes);
// PropagateState for connected Faces;
TopTools_IndexedMapOfShape anEdgeMap;
TopExp::MapShapes(aF, TopAbs_EDGE, anEdgeMap);
Standard_Integer i, aNbE;
aNbE=anEdgeMap.Extent();
for (i=1; i<=aNbE; i++) {
const TopoDS_Shape& aE=anEdgeMap(i);
//
const TopTools_ListOfShape& aFacesList=aEFMap.FindFromKey(aE);
//
TopTools_ListIteratorOfListOfShape anIt(aFacesList);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aFi=anIt.Value();
if (!aProcessedShapes.Contains(aFi)) {
if (!aFi.IsSame(aF)) {
aSWS.Add(aFi, aState);
aProcessedShapes.Add(aFi);
PropagateState(aFi, aState, pDS, iRank, aSWS, aEFMap, aProcessedShapes);
}
}
}
}
}
//=======================================================================
// function: PropagateState
// purpose:
//=======================================================================
void PropagateState(const TopoDS_Shape& aSS,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
TopTools_IndexedMapOfShape& aProcessedShapes)
{
TopAbs_ShapeEnum aSubType;
aSubType=BOPTools_StateFiller::SubType(aSS);
if (aSubType==TopAbs_SHAPE) {
return;
}
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap= pDS->ShapeIndexMap(iRank);
TopTools_IndexedMapOfShape aSubMap;
TopExp::MapShapes(aSS, aSubType, aSubMap);
Standard_Integer i, aNb, nV;
aNb=aSubMap.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aSubMap(i);
if (!aProcessedShapes.Contains(aS)) {
if (aSubType==TopAbs_VERTEX) {
nV=aDSMap.FindFromKey(aS);
BooleanOperations_StateOfShape aSt=pDS->GetState(nV);
if (aSt!=BooleanOperations_UNKNOWN){
aProcessedShapes.Add(aS);
continue;
}
}
aSWS.Add(aS, aState);
aProcessedShapes.Add(aS);
PropagateState (aS, aState, pDS, iRank, aSWS, aProcessedShapes);
}
}
}
//=======================================================================
// function: IntersectionStates
// purpose:
//=======================================================================
void IntersectionStates(const TopoDS_Shape& aE,
const TopTools_IndexedDataMapOfShapeListOfShape& aM,
TopTools_IndexedMapOfShape& anIntersectedShapes)
{
if (aM.Contains(aE)) {
const TopTools_ListOfShape& anAncesstors=aM.FindFromKey(aE);
TopTools_ListIteratorOfListOfShape anIt(anAncesstors);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& anAnc=anIt.Value();
anIntersectedShapes.Add(anAnc);
IntersectionStates(anAnc, aM, anIntersectedShapes);
}
}
}
//=======================================================================
// function: HasConnexity
// purpose:
//=======================================================================
Standard_Boolean HasConnexity(const TopoDS_Shape& aS,
const BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
BooleanOperations_StateOfShape& aState)
{
TopAbs_ShapeEnum aType;
BooleanOperations_StateOfShape aSt;
aType=aS.ShapeType();
if (aType!=TopAbs_EDGE) {
Standard_Integer i, aNb;
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(aS, TopAbs_EDGE, aME);
aNb=aME.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aME(i);
if (aSWS.Contains(aE)){
aSt=aSWS.FindFromKey(aE);
aState=aSt;
return Standard_True;
}
}
}
else {
TopExp_Explorer anExp (aS, TopAbs_VERTEX);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aV=anExp.Current();
if (aMVE.Contains(aV)) {
const TopTools_ListOfShape& anEdgesList=aMVE.FindFromKey(aV);
TopTools_ListIteratorOfListOfShape anIt(anEdgesList);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aEx=anIt.Value();
if (aSWS.Contains(aEx)) {
aSt=aSWS.FindFromKey(aEx);
aState=aSt;
return Standard_True;
}
}
}
}
}
aState=BooleanOperations_UNKNOWN;
return Standard_False;
}
/*
//=======================================================================
// function: ConvertState
// purpose:
//=======================================================================
BooleanOperations_StateOfShape
BOPTools_SolidStateFiller::ConvertState(const TopAbs_State aSt)
{
BooleanOperations_StateOfShape aState;
switch (aSt) {
case TopAbs_IN:
aState=BooleanOperations_IN;
break;
case TopAbs_OUT:
aState=BooleanOperations_OUT;
break;
case TopAbs_ON:
aState=BooleanOperations_ON;
break;
case TopAbs_UNKNOWN:
aState=BooleanOperations_UNKNOWN;
break;
default:
aState=BooleanOperations_UNKNOWN;
break;
}
return aState;
}
//=======================================================================
// function: ConvertState
// purpose:
//=======================================================================
TopAbs_State
BOPTools_SolidStateFiller::ConvertState(const BooleanOperations_StateOfShape aSt)
{
TopAbs_State aState;
switch (aSt) {
case BooleanOperations_IN:
aState=TopAbs_IN;
break;
case BooleanOperations_OUT:
aState=TopAbs_OUT;
break;
case BooleanOperations_ON:
aState=TopAbs_ON;
break;
case BooleanOperations_UNKNOWN:
aState=TopAbs_UNKNOWN;
break;
default:
aState=TopAbs_UNKNOWN;
break;
}
return aState;
}
//=======================================================================
// function: ClassifyShapeByRef
// purpose:
//=======================================================================
BooleanOperations_StateOfShape
BOPTools_SolidStateFiller::ClassifyShapeByRef (const TopoDS_Shape& aS,
const TopoDS_Shape& aRef)
{
TopAbs_ShapeEnum aType;
aType=aS.ShapeType();
TopoDS_Edge aE;
if (aType!=TopAbs_EDGE) {
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(aS, TopAbs_EDGE, aME);
aE=TopoDS::Edge(aME(1));
}
else {
aE=TopoDS::Edge(aS);
}
TopAbs_State aSt=BOPTools_SolidStateFiller::ClassifyEdgeToSolidByOnePoint(aE, aRef);
BooleanOperations_StateOfShape aState=BOPTools_SolidStateFiller::ConvertState(aSt) ;
return aState;
}
//=======================================================================
// function: ClassifyEdgeToSolidByOnePoint
// purpose:
//=======================================================================
TopAbs_State
BOPTools_SolidStateFiller::ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E,
const TopoDS_Shape& Ref)
{
Standard_Real f2 = 0., l2 = 0., par = 0.;
Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2);
gp_Pnt aP3d;
if(C3D.IsNull()) {
//it means that we are in degenerated edge
const TopoDS_Vertex& fv = TopExp::FirstVertex(E);
if(fv.IsNull()){
return TopAbs_UNKNOWN;
}
aP3d = BRep_Tool::Pnt(fv);
}
else {//usual case
par=IntTools_Tools::IntermediatePoint(f2, l2);
C3D -> D0(par, aP3d);
}
BRepClass3d_SolidClassifier SC(Ref);
SC.Perform(aP3d, 1e-7);
TopAbs_State aState=SC.State();
return aState;
}
//=======================================================================
// function: SubType
// purpose:
//=======================================================================
TopAbs_ShapeEnum BOPTools_SolidStateFiller::SubType(const TopoDS_Shape& aS)
{
TopAbs_ShapeEnum aSourceType, aReturnType;
aSourceType=aS.ShapeType();
switch (aSourceType) {
case TopAbs_SOLID:
aReturnType=TopAbs_SHELL;
break;
case TopAbs_SHELL:
aReturnType=TopAbs_FACE;
break;
case TopAbs_FACE:
aReturnType=TopAbs_WIRE;
break;
case TopAbs_WIRE:
aReturnType=TopAbs_EDGE;
break;
case TopAbs_EDGE:
aReturnType=TopAbs_VERTEX;
break;
default:
aReturnType=TopAbs_SHAPE;
break;
}
return aReturnType;
}
*/

View File

@@ -0,0 +1,88 @@
-- File: BOPTools_StateFiller.cdl
-- Created: Mon Feb 4 10:04:52 2002
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2002
class StateFiller from BOPTools
---Purpose:
--- root class to compute states (3D)
---
uses
PaveFiller from BOPTools,
PPaveFiller from BOPTools,
PInterferencePool from BOPTools,
PShapesDataStructure from BooleanOperations,
Shape from TopoDS,
Edge from TopoDS,
State from TopAbs,
ShapeEnum from TopAbs,
StateOfShape from BooleanOperations
--raises
is
Create (aFiller: PaveFiller from BOPTools)
returns StateFiller from BOPTools;
---Purpose:
--- Constructor
---
Do(me:out)
is virtual;
---Purpose:
--- Launch the Filler
---
IsDone(me)
returns Boolean from Standard;
---Purpose:
--- Returns true if Ok
---
ConvertState (myclass;
aSt: State from TopAbs)
returns StateOfShape from BooleanOperations;
---Purpose:
--- Convert conventional states to VDS-states
---
ConvertState (myclass;
aSt: StateOfShape from BooleanOperations)
returns State from TopAbs;
---Purpose:
--- Convert VDS-states to conventional states
---
ClassifyEdgeToSolidByOnePoint (me:out;
anEdge: Edge from TopoDS;
aRef : Shape from TopoDS)
returns State from TopAbs;
---Purpose:
--- Computation the 3D-state of the edge <anEdge>
--- to solid <aRef>
---
ClassifyShapeByRef (me:out;
aShape: Shape from TopoDS;
aRef : Shape from TopoDS)
returns StateOfShape from BooleanOperations;
---Purpose:
--- Computation the 3D-state of the shape <aShape>
--- to solid <aRef>
---
SubType (myclass;
aShape: Shape from TopoDS)
returns ShapeEnum from TopAbs;
---Purpose:
--- Returns first subtype of <Shape>
---
fields
myFiller : PPaveFiller from BOPTools
is protected;
myDS : PShapesDataStructure from BooleanOperations
is protected;
myIntrPool: PInterferencePool from BOPTools
is protected;
myIsDone : Boolean from Standard
is protected;
end StateFiller;

View File

@@ -0,0 +1,306 @@
// File: BOPTools_StateFiller.cxx
// Created: Mon Feb 4 10:08:20 2002
// Author: Peter KURNEV
// <pkv@irinox>
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450
#include <BOPTools_StateFiller.ixx>
#include <Precision.hxx>
#include <Geom_Curve.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Solid.hxx>
#include <TopAbs_State.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <BooleanOperations_StateOfShape.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_Context.hxx>
#include <Geom_Surface.hxx>
//=======================================================================
// function: BOPTools_StateFiller::BOPTools_StateFiller
// purpose:
//=======================================================================
BOPTools_StateFiller::BOPTools_StateFiller(const BOPTools_PaveFiller& aFiller)
:
myIsDone(Standard_False)
{
myFiller=(BOPTools_PaveFiller*) &aFiller;
myDS=myFiller->DS();
myIntrPool=myFiller->InterfPool();
}
//=======================================================================
// function: Do
// purpose:
//=======================================================================
void BOPTools_StateFiller::Do()
{
}
//=======================================================================
// function: IsDone
// purpose:
//=======================================================================
Standard_Boolean BOPTools_StateFiller::IsDone() const
{
return myIsDone;
}
//=======================================================================
// function: ConvertState
// purpose:
//=======================================================================
BooleanOperations_StateOfShape BOPTools_StateFiller::ConvertState(const TopAbs_State aSt)
{
BooleanOperations_StateOfShape aState;
switch (aSt) {
case TopAbs_IN:
aState=BooleanOperations_IN;
break;
case TopAbs_OUT:
aState=BooleanOperations_OUT;
break;
case TopAbs_ON:
aState=BooleanOperations_ON;
break;
case TopAbs_UNKNOWN:
aState=BooleanOperations_UNKNOWN;
break;
default:
aState=BooleanOperations_UNKNOWN;
break;
}
return aState;
}
//=======================================================================
// function: ConvertState
// purpose:
//=======================================================================
TopAbs_State BOPTools_StateFiller::ConvertState(const BooleanOperations_StateOfShape aSt)
{
TopAbs_State aState;
switch (aSt) {
case BooleanOperations_IN:
aState=TopAbs_IN;
break;
case BooleanOperations_OUT:
aState=TopAbs_OUT;
break;
case BooleanOperations_ON:
aState=TopAbs_ON;
break;
case BooleanOperations_UNKNOWN:
aState=TopAbs_UNKNOWN;
break;
default:
aState=TopAbs_UNKNOWN;
break;
}
return aState;
}
//=======================================================================
// function: ClassifyShapeByRef
// purpose:
//=======================================================================
BooleanOperations_StateOfShape BOPTools_StateFiller::ClassifyShapeByRef (const TopoDS_Shape& aS,
const TopoDS_Shape& aRef)
{
TopAbs_ShapeEnum aType;
aType=aS.ShapeType();
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin
Standard_Boolean hasEdge = Standard_True;
// Modified by skv - Tue Aug 24 12:31:17 2004 OCC6450 End
TopoDS_Edge aE;
if (aType!=TopAbs_EDGE) {
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(aS, TopAbs_EDGE, aME);
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin
if (aME.Extent() == 0)
hasEdge = Standard_False;
else
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 End
aE=TopoDS::Edge(aME(1));
}
else {
aE=TopoDS::Edge(aS);
}
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin
// TopAbs_State aSt=ClassifyEdgeToSolidByOnePoint(aE, aRef);
TopAbs_State aSt;
if (hasEdge) {
aSt = ClassifyEdgeToSolidByOnePoint(aE, aRef);
} else {
TopTools_IndexedMapOfShape aMF;
Standard_Boolean hasFace = Standard_True;
TopoDS_Face aF;
TopExp::MapShapes(aS, TopAbs_FACE, aMF);
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin
if (aMF.Extent() == 0) {
hasFace = Standard_False;
} else {
aF = TopoDS::Face(aMF(1));
}
if (!hasFace) {
aSt = TopAbs_UNKNOWN;
} else {
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aF);
Standard_Real aUMin;
Standard_Real aUMax;
Standard_Real aVMin;
Standard_Real aVMax;
aSurf->Bounds(aUMin, aUMax, aVMin, aVMax);
Standard_Boolean isMinInf = Precision::IsNegativeInfinite(aUMin);
Standard_Boolean isMaxInf = Precision::IsPositiveInfinite(aUMax);
Standard_Real dT=10.;
Standard_Real aParU;
Standard_Real aParV;
if (isMinInf && !isMaxInf) {
aParU = aUMax - dT;
} else if (!isMinInf && isMaxInf) {
aParU = aUMin + dT;
} else if (isMinInf && isMaxInf) {
aParU = 0.;
} else {
aParU = IntTools_Tools::IntermediatePoint(aUMin, aUMax);
}
isMinInf = Precision::IsNegativeInfinite(aVMin);
isMaxInf = Precision::IsPositiveInfinite(aVMax);
if (isMinInf && !isMaxInf) {
aParV = aVMax - dT;
} else if (!isMinInf && isMaxInf) {
aParV = aVMin + dT;
} else if (isMinInf && isMaxInf) {
aParV = 0.;
} else {
aParV = IntTools_Tools::IntermediatePoint(aVMin, aVMax);
}
gp_Pnt aP3d = aSurf->Value(aParU, aParV);
const TopoDS_Solid &aRefSolid = TopoDS::Solid(aRef);
IntTools_Context &aContext = myFiller->ChangeContext();
BRepClass3d_SolidClassifier &aSC =
aContext.SolidClassifier(aRefSolid);
//
aSC.Perform(aP3d, 1e-7);
//
aSt = aSC.State();
}
}
// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin
BooleanOperations_StateOfShape aState=BOPTools_StateFiller::ConvertState(aSt) ;
return aState;
}
//=======================================================================
// function: ClassifyEdgeToSolidByOnePoint
// purpose:
//=======================================================================
TopAbs_State BOPTools_StateFiller::ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E,
const TopoDS_Shape& Ref)
{
Standard_Real f2 = 0., l2 = 0., par = 0.;
Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2);
gp_Pnt aP3d;
if(C3D.IsNull()) {
//it means that we are in degenerated edge
const TopoDS_Vertex& fv = TopExp::FirstVertex(E);
if(fv.IsNull()){
return TopAbs_UNKNOWN;
}
aP3d = BRep_Tool::Pnt(fv);
}
else {//usual case
Standard_Boolean bF2Inf, bL2Inf;
Standard_Real dT=10.;
//
bF2Inf = Precision::IsNegativeInfinite(f2);
bL2Inf = Precision::IsPositiveInfinite(l2);
//
if (bF2Inf && !bL2Inf) {
par=l2-dT;
}
else if (!bF2Inf && bL2Inf) {
par=f2+dT;
}
else if (bF2Inf && bL2Inf) {
par=0.;
}
else {
par=IntTools_Tools::IntermediatePoint(f2, l2);
}
C3D -> D0(par, aP3d);
}
//
const TopoDS_Solid& aRefSolid=TopoDS::Solid(Ref);
IntTools_Context& aContext=myFiller->ChangeContext();
BRepClass3d_SolidClassifier& aSC=aContext.SolidClassifier(aRefSolid);
//
aSC.Perform(aP3d, 1e-7);
//
TopAbs_State aState=aSC.State();
return aState;
}
//=======================================================================
// function: SubType
// purpose:
//=======================================================================
TopAbs_ShapeEnum BOPTools_StateFiller::SubType(const TopoDS_Shape& aS)
{
TopAbs_ShapeEnum aSourceType, aReturnType;
aSourceType=aS.ShapeType();
switch (aSourceType) {
case TopAbs_SOLID:
aReturnType=TopAbs_SHELL;
break;
case TopAbs_SHELL:
aReturnType=TopAbs_FACE;
break;
case TopAbs_FACE:
aReturnType=TopAbs_WIRE;
break;
case TopAbs_WIRE:
aReturnType=TopAbs_EDGE;
break;
case TopAbs_EDGE:
aReturnType=TopAbs_VERTEX;
break;
default:
aReturnType=TopAbs_SHAPE;
break;
}
return aReturnType;
}

170
src/BOPTools/BOPTools_Tools.cdl Executable file
View File

@@ -0,0 +1,170 @@
-- File: BOPTools_Tools.cdl
-- Created: Thu Nov 16 11:40:16 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class Tools from BOPTools
---Purpose:
--- The class contains handy static functions
--- dealing with the topology
uses
Pnt from gp ,
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Range from IntTools,
Context from IntTools,
Curve from IntTools,
PaveBlock from BOPTools,
IndexedMapOfShape from TopTools
is
MakeNewVertex (myclass;
aP1 : Pnt from gp;
aTol: Real from Standard;
aNewVertex:out Vertex from TopoDS);
---Purpose:
--- Make a vertex using 3D-point <aP1> and 3D-tolerance value <aTol>
---
MakeNewVertex (myclass;
aV1,aV2: Vertex from TopoDS;
aNewVertex:out Vertex from TopoDS);
---Purpose:
--- Make a vertex using couple of vertices <aV1, aV2>
---
MakeNewVertex (myclass;
aE1: Edge from TopoDS;
aP1: Real from Standard;
aE2: Edge from TopoDS;
aP2: Real from Standard;
aNewVertex:out Vertex from TopoDS);
---Purpose:
--- Make a vertex in place of intersection between two edges
--- <aE1, aE2> with parameters <aP1, aP2>
---
MakeNewVertex (myclass;
aE1: Edge from TopoDS;
aP1: Real from Standard;
aF2: Face from TopoDS;
aNewVertex:out Vertex from TopoDS);
---Purpose:
--- Make a vertex in place of intersection between the edge <aE1>
--- with parameter <aP1> and the face <aF2>
---
PointOnEdge (myclass;
aEdge: Edge from TopoDS;
aPrm: Real from Standard;
aP:out Pnt from gp);
---Purpose:
--- Compute a 3D-point on the edge <aEdge> at parameter <aPrm>
---
MakeSplitEdge (myclass;
aE1: Edge from TopoDS;
aV1: Vertex from TopoDS;
aP1: Real from Standard;
aV2: Vertex from TopoDS;
aP2: Real from Standard;
aNewEdge:out Edge from TopoDS);
---Purpose:
--- Make the edge from base edge <aE1> and two vertices <aV1,aV2>
--- at parameters <aP1,aP2>
---
MakeSectEdge (myclass;
aIC: Curve from IntTools;
aV1: Vertex from TopoDS;
aP1: Real from Standard;
aV2: Vertex from TopoDS;
aP2: Real from Standard;
aNewEdge:out Edge from TopoDS);
---Purpose:
--- Make the edge from 3D-Curve <aIC> and two vertices <aV1,aV2>
--- at parameters <aP1,aP2>
---
UpdateVertex (myclass;
aIC: Curve from IntTools;
aT : Real from Standard;
aV : Vertex from TopoDS);
---Purpose:
--- Update the tolerance value for vertex <aV>
--- taking into account the fact that <aV> lays on
--- the curve <aIC>
---
UpdateVertex (myclass;
aE : Edge from TopoDS;
aT : Real from Standard;
aV : Vertex from TopoDS);
---Purpose:
--- Update the tolerance value for vertex <aV>
--- taking into account the fact that <aV> lays on
--- the edge <aE>
---
UpdateVertex (myclass;
aVF : Vertex from TopoDS;
aVN : Vertex from TopoDS);
---Purpose:
--- Update the tolerance value for vertex <aVN>
--- taking into account the fact that <aVN> should
--- cover tolerance zone of <aVF>
---
IsBlocksCoinside(myclass;
aPB1: PaveBlock from BOPTools;
aPB2: PaveBlock from BOPTools)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if PaveBlocks <aPB1>,<aPB2> coinside in 3D
--- taking into account corresp. tolerances' values of vertices,
--- edges
---
IsBlockInOnFace(myclass;
aPB : PaveBlock from BOPTools;
aF : Face from TopoDS;
aContext:out Context from IntTools)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if PaveBlock <aPB> lays on the face <aF>, i.e
--- the <PB> is IN or ON in 2D of <aF>
---
MapShapes (myclass;
aS : Shape from TopoDS;
aM :out IndexedMapOfShape from TopTools);
---Purpose:
--- Get a Map <aM> containing the shape itself and all its subshapes
---
CorrectRange (myclass;
aE1: Edge from TopoDS;
aE2: Edge from TopoDS;
aSR: Range from IntTools;
aNewSR:out Range from IntTools);
---Purpose:
--- Correct shrunk range <aSR> taking into account 3D-curve
--- resolution and corresp. tolerances' values of <aE1>, <aE2>
---
CorrectRange (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aSR: Range from IntTools;
aNewSR:out Range from IntTools);
---Purpose:
--- Correct shrunk range <aSR> taking into account 3D-curve
--- resolution and corresp. tolerances' values of <aE>, <aF>
---
CopySource (myclass;
aSourceShape: Shape from TopoDS;
aDestShape:out Shape from TopoDS);
---Purpose:
--- Make a copy of <aSourceShape>
---
end Tools;

642
src/BOPTools/BOPTools_Tools.cxx Executable file
View File

@@ -0,0 +1,642 @@
// File: BOPTools_Tools.cxx
// Created: Thu Nov 16 11:42:23 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Tools.ixx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <gp_Pnt.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAbs_CurveType.hxx>
#include <BooleanOperations_OnceExplorer.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_Range.hxx>
static
void CopySrc(const TopoDS_Shape& E,
TopTools_IndexedDataMapOfShapeShape& aMapSS,
TopoDS_Shape& anEdge);
//=======================================================================
// function: IsBlockInOnFace
// purpose:
//=======================================================================
Standard_Boolean BOPTools_Tools::IsBlockInOnFace (const BOPTools_PaveBlock& aPB1,
const TopoDS_Face& aF,
IntTools_Context& aContext)
{
Standard_Boolean bFlag;
Standard_Real f1, l1, ULD, VLD;
gp_Pnt2d aP2D;
gp_Pnt aP11, aP12;
//
// Edge's data
const IntTools_ShrunkRange& aSR1=aPB1.ShrunkRange();
const TopoDS_Edge& aE1=aSR1.Edge();
const IntTools_Range& aShrR= aSR1.ShrunkRange();
aShrR.Range(f1, l1);
//
Standard_Real dt=0.0075, k;//dt=0.001, k;
k=dt*(l1-f1);
f1=f1+k;
l1=l1-k;
//
// Treatment P11
BOPTools_Tools::PointOnEdge(aE1, f1, aP11);
//
GeomAPI_ProjectPointOnSurf& aProjector=aContext.ProjPS(aF);
aProjector.Perform(aP11);
//
bFlag=aProjector.IsDone();
if (!bFlag) {
return bFlag;
}
aProjector.LowerDistanceParameters(ULD, VLD);
aP2D.SetCoord(ULD, VLD);
//
bFlag=aContext.IsPointInOnFace (aF, aP2D);
//
if (!bFlag) {
return bFlag;
}
//
// Treatment P12
BOPTools_Tools::PointOnEdge(aE1, l1, aP12);
//
aProjector.Perform(aP12);
//
bFlag=aProjector.IsDone();
if (!bFlag) {
return bFlag;
}
aProjector.LowerDistanceParameters(ULD, VLD);
aP2D.SetCoord(ULD, VLD);
//
bFlag=aContext.IsPointInOnFace (aF, aP2D);
//
if (!bFlag) {
return bFlag;
}
//
// Treatment intemediate
Standard_Real m1, aTolF, aTolE, aTol, aDist;
m1=IntTools_Tools::IntermediatePoint(f1, l1);
BOPTools_Tools::PointOnEdge(aE1, m1, aP12);
//
aProjector.Perform(aP12);
//
bFlag=aProjector.IsDone();
if (!bFlag) {
return bFlag;
}
//
aTolE=BRep_Tool::Tolerance(aE1);
aTolF=BRep_Tool::Tolerance(aF);
aTol=aTolE+aTolF;
aDist=aProjector.LowerDistance();
if (aDist > aTol){
return Standard_False;
}
aProjector.LowerDistanceParameters(ULD, VLD);
aP2D.SetCoord(ULD, VLD);
//
bFlag=aContext.IsPointInOnFace (aF, aP2D);
//
if (!bFlag) {
return bFlag;
}
return bFlag;
}
//=======================================================================
// function: IsBlocksCoinside
// purpose:
//=======================================================================
Standard_Boolean BOPTools_Tools::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1,
const BOPTools_PaveBlock& aPB2)
{
//
Standard_Real f1, l1, aTol1;
const IntTools_ShrunkRange aSR1=aPB1.ShrunkRange();
const TopoDS_Edge& aE1=aSR1.Edge();
aTol1=BRep_Tool::Tolerance(aE1);
aPB1.Parameters(f1, l1);
gp_Pnt aP11, aP12;
BOPTools_Tools::PointOnEdge(aE1, f1, aP11);
BOPTools_Tools::PointOnEdge(aE1, l1, aP12);
//
Standard_Real f2, l2, aTol2;
const IntTools_ShrunkRange aSR2=aPB2.ShrunkRange();
const TopoDS_Edge& aE2=aSR2.Edge();
aTol2=BRep_Tool::Tolerance(aE2);
aPB2.Parameters(f2, l2);
gp_Pnt aP21, aP22;
BOPTools_Tools::PointOnEdge(aE2, f2, aP21);
BOPTools_Tools::PointOnEdge(aE2, l2, aP22);
////
Standard_Real aTolSum, d1121, d1122, d1222, d1221;
aTolSum=1.05*(aTol1+aTol2);
d1121=aP11.Distance(aP21);
if (d1121<aTolSum) {
d1222=aP12.Distance(aP22);
if (d1222<aTolSum) {
return Standard_True;
}
}
//
d1122=aP11.Distance(aP22);
if (d1122<aTolSum) {
d1221=aP12.Distance(aP21);
if (d1221<aTolSum) {
return Standard_True;
}
}
return Standard_False;
}
//
//=======================================================================
// function: UpdateVertex
// purpose:
//=======================================================================
void BOPTools_Tools::UpdateVertex (const TopoDS_Vertex& aVF,
const TopoDS_Vertex& aNewVertex)
{
Standard_Real aTolVF, aTolNewVertex, aDist, aDTol=1.e-12, aNewTol;
//
gp_Pnt aPVF=BRep_Tool::Pnt(aVF);
gp_Pnt aPNewVertex=BRep_Tool::Pnt(aNewVertex);
aTolVF=BRep_Tool::Tolerance(aVF);
aTolNewVertex=BRep_Tool::Tolerance(aNewVertex);
aDist=aPVF.Distance(aPNewVertex);
aNewTol=aDist+aTolNewVertex;
if (aNewTol>aTolVF) {
BRep_Builder BB;
BB.UpdateVertex (aVF, aNewTol+aDTol);
}
}
//
//=======================================================================
// function: UpdateVertex
// purpose:
//=======================================================================
void BOPTools_Tools::UpdateVertex (const TopoDS_Edge& aE,
const Standard_Real aT,
const TopoDS_Vertex& aV)
{
Standard_Real aTolV, aDist, aDTol=1.e-12, aFirst, aLast;
gp_Pnt aPc;
gp_Pnt aPv=BRep_Tool::Pnt(aV);
aTolV=BRep_Tool::Tolerance(aV);
Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aE, aFirst, aLast);
aC3D->D0(aT, aPc);
aDist=aPv.Distance(aPc);
if (aDist>aTolV) {
BRep_Builder BB;
BB.UpdateVertex (aV, aDist+aDTol);
}
}
//
//=======================================================================
// function: UpdateVertex
// purpose:
//=======================================================================
void BOPTools_Tools::UpdateVertex (const IntTools_Curve& aC,
const Standard_Real aT,
const TopoDS_Vertex& aV)
{
Standard_Real aTolV, aDist, aDTol=1.e-12;
gp_Pnt aPc;
gp_Pnt aPv=BRep_Tool::Pnt(aV);
aTolV=BRep_Tool::Tolerance(aV);
Handle(Geom_Curve) aC3D=aC.Curve();
aC3D->D0(aT, aPc);
aDist=aPv.Distance(aPc);
if (aDist>aTolV) {
BRep_Builder BB;
BB.UpdateVertex (aV, aDist+aDTol);
}
}
//=======================================================================
// function: MakeSectEdge
// purpose:
//=======================================================================
void BOPTools_Tools::MakeSectEdge(const IntTools_Curve& aIC,
const TopoDS_Vertex& aV1,
const Standard_Real aP1,
const TopoDS_Vertex& aV2,
const Standard_Real aP2,
TopoDS_Edge& aNewEdge)
{
Handle(Geom_Curve) aC=aIC.Curve ();
BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2);
const TopoDS_Edge& aE=TopoDS::Edge(aMakeEdge.Shape());
//
// Range must be as it was !
BRep_Builder aBB;
aBB.Range (aE, aP1, aP2);
//
aNewEdge=aE;
}
//=======================================================================
// function: MakeSplitEdge
// purpose:
//=======================================================================
void BOPTools_Tools::MakeSplitEdge(const TopoDS_Edge& aE,
const TopoDS_Vertex& aV1,
const Standard_Real aP1,
const TopoDS_Vertex& aV2,
const Standard_Real aP2,
TopoDS_Edge& aNewEdge)
{
Standard_Real f, l, aTol;
Handle(Geom_Curve) aC=BRep_Tool::Curve (aE, f, l);
aTol=BRep_Tool::Tolerance(aE);
//
// MakeEdge is used for chechking all input data only
BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2);
//ZZ const TopoDS_Edge& E1=TopoDS::Edge(aMakeEdge.Shape());
TopoDS_Edge E=aE;
E.EmptyCopy();
BRep_Builder BB;
BB.Add (E, aV1);
BB.Add (E, aV2);
BB.Range(E, aP1, aP2);
BB.UpdateEdge(E, aTol);
aNewEdge=E;
}
//=======================================================================
// function: MakeNewVertex
// purpose:
//=======================================================================
void BOPTools_Tools::MakeNewVertex(const TopoDS_Vertex& aV1,
const TopoDS_Vertex& aV2,
TopoDS_Vertex& aNewVertex)
{
gp_Pnt aPnt1=BRep_Tool::Pnt(aV1);
Standard_Real aTol1=BRep_Tool::Tolerance(aV1);
gp_Pnt aPnt2=BRep_Tool::Pnt(aV2);
Standard_Real aTol2=BRep_Tool::Tolerance(aV2);
Standard_Real aMaxTol, aDist;
aDist=aPnt1.Distance(aPnt2);
aMaxTol=(aTol1>aTol2)? aTol1 : aTol2;
aMaxTol=aMaxTol+0.5*aDist;
const gp_XYZ& aXYZ1=aPnt1.XYZ();
const gp_XYZ& aXYZ2=aPnt2.XYZ();
gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2);
gp_Pnt aNewPnt(aNewXYZ);
BRep_Builder aBB;
aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol);
}
//=======================================================================
// function: MakeNewVertex
// purpose:
//=======================================================================
void BOPTools_Tools::MakeNewVertex(const gp_Pnt& aP,
const Standard_Real aTol,
TopoDS_Vertex& aNewVertex)
{
BRep_Builder aBB;
aBB.MakeVertex (aNewVertex, aP, aTol);
}
//=======================================================================
// function: MakeNewVertex
// purpose:
//=======================================================================
void BOPTools_Tools::MakeNewVertex(const TopoDS_Edge& aE1,
const Standard_Real aParm1,
const TopoDS_Edge& aE2,
const Standard_Real aParm2,
TopoDS_Vertex& aNewVertex)
{
Standard_Real aTol1, aTol2, aMaxTol, aDist;
gp_Pnt aPnt1, aPnt2;
PointOnEdge (aE1, aParm1, aPnt1);
PointOnEdge (aE2, aParm2, aPnt2);
aTol1=BRep_Tool::Tolerance(aE1);
aTol2=BRep_Tool::Tolerance(aE2);
aDist=aPnt1.Distance(aPnt2);
aMaxTol=(aTol1>aTol2)? aTol1 : aTol2;
aMaxTol=aMaxTol+0.5*aDist;
const gp_XYZ& aXYZ1=aPnt1.XYZ();
const gp_XYZ& aXYZ2=aPnt2.XYZ();
gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2);
gp_Pnt aNewPnt(aNewXYZ);
BRep_Builder aBB;
aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol);
}
//=======================================================================
// function: MakeNewVertex
// purpose:
//=======================================================================
void BOPTools_Tools::MakeNewVertex(const TopoDS_Edge& aE1,
const Standard_Real aParm1,
const TopoDS_Face& aF1,
TopoDS_Vertex& aNewVertex)
{
Standard_Real aTol1, aTol2, aMaxTol, delta=1.e-12;
gp_Pnt aPnt;
PointOnEdge (aE1, aParm1, aPnt);
aTol1=BRep_Tool::Tolerance(aE1);
aTol2=BRep_Tool::Tolerance(aF1);
//
//aMaxTol=(aTol1>aTol2)? aTol1 : aTol2;
aMaxTol=aTol1+aTol2+delta;
//
BRep_Builder aBB;
aBB.MakeVertex (aNewVertex, aPnt, aMaxTol);
}
//=======================================================================
// function: PointOnEdge
// purpose:
//=======================================================================
void BOPTools_Tools::PointOnEdge(const TopoDS_Edge& aE,
const Standard_Real aParm,
gp_Pnt& aPnt)
{
Standard_Real f, l;
Handle(Geom_Curve) C1=BRep_Tool::Curve(aE, f, l);
C1->D0(aParm, aPnt);
}
//=======================================================================
//function : CopySource
//purpose :
//=======================================================================
void BOPTools_Tools::CopySource(const TopoDS_Shape& aSS,
TopoDS_Shape& aSD)
{
TopTools_IndexedDataMapOfShapeShape aMapSS;
CopySrc (aSS, aMapSS, aSD);
}
//=======================================================================
//function : MapShapes
//purpose :
//=======================================================================
void BOPTools_Tools::MapShapes(const TopoDS_Shape& aS,
TopTools_IndexedMapOfShape& aM)
{
aM.Add(aS);
TopoDS_Iterator anIt;
anIt.Initialize(aS);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aSx=anIt.Value();
BOPTools_Tools::MapShapes(aSx, aM);
}
}
//=======================================================================
//function : CorrectRange
//purpose :
//=======================================================================
void BOPTools_Tools::CorrectRange(const TopoDS_Edge& aE1,
const TopoDS_Edge& aE2,
const IntTools_Range& aSR,
IntTools_Range& aNewSR)
{
Standard_Integer i;
Standard_Real aRes, aTolE1, aTolE2, aTF, aTL, dT;
BRepAdaptor_Curve aBC;
GeomAbs_CurveType aCT;
gp_Pnt aP;
gp_Vec aDer;
//
aNewSR=aSR;
//
//modified by NIZNHY-PKV Tue Feb 10 08:47:03 2009f
aBC.Initialize(aE1);
aCT=aBC.GetType();
if (aCT==GeomAbs_Line) {
return;
}
//modified by NIZNHY-PKV Tue Feb 10 08:47:06 2009t
//
dT=Precision::PConfusion();
aTF=aSR.First();
aTL=aSR.Last();
//
//modified by NIZNHY-PKV Tue Feb 10 08:47:39 2009f
/*
aBC.Initialize(aE1);
aCT=aBC.GetType();
*/
//modified by NIZNHY-PKV Tue Feb 10 08:47:43 2009t
//
aTolE1=BRep_Tool::Tolerance(aE1);
aTolE2=BRep_Tool::Tolerance(aE2);
//
for(i=0; i<2; ++i) {
aRes = 2.*(aTolE1 + aTolE2);
//
if (aCT==GeomAbs_BezierCurve ||
aCT==GeomAbs_BSplineCurve||
aCT==GeomAbs_OtherCurve) {
if(!i){
aBC.D1 (aTF, aP, aDer);
}
else {
aBC.D1 (aTL, aP, aDer);
}
//
Standard_Real aMgn = aDer.Magnitude();
if(aMgn > 1.e-12) {
aRes = aRes/aMgn ;
}
else {
aRes = aBC.Resolution(aRes);
}
} // if (aCT==GeomAbs_BezierCurve||...
else {
aRes = aBC.Resolution(aRes);
}
//
if(!i) {
aNewSR.SetFirst (aTF+aRes);
}
else {
aNewSR.SetLast (aTL-aRes);
}
//
if ((aNewSR.Last()-aNewSR.First()) < dT) {
aNewSR=aSR;
}
//aNewSR=((aNewSR.Last()-aNewSR.First()) < dT) ? aSR : aNewSR;
}
}
//=======================================================================
//function : CorrectRange
//purpose :
//=======================================================================
void BOPTools_Tools::CorrectRange(const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const IntTools_Range& aSR,
IntTools_Range& aNewSR)
{
Standard_Integer i;
Standard_Real aRes, aTolF, aTF, aTL, dT;
BRepAdaptor_Curve aBC;
GeomAbs_CurveType aCT;
gp_Pnt aP;
gp_Vec aDer;
//
aNewSR=aSR;
//
dT=Precision::PConfusion();
aTF=aSR.First();
aTL=aSR.Last();
//
aBC.Initialize(aE);
aCT=aBC.GetType();
//
aTolF=BRep_Tool::Tolerance(aF);
//
for(i=0; i<2; ++i) {
aRes =aTolF;
if (aCT==GeomAbs_BezierCurve ||
aCT==GeomAbs_BSplineCurve||
aCT==GeomAbs_OtherCurve) {
if(!i){
aBC.D1 (aTF, aP, aDer);
}
else {
aBC.D1 (aTL, aP, aDer);
}
//
Standard_Real aMgn = aDer.Magnitude();
if(aMgn > 1.e-12) {
aRes = aRes/aMgn ;
}
else {
aRes = aBC.Resolution(aRes);
}
} // if (aCT==GeomAbs_BezierCurve||...
else {
aRes = aBC.Resolution(aRes);
}
//
if(!i) {
aNewSR.SetFirst (aTF+aRes);
}
else {
aNewSR.SetLast (aTL-aRes);
}
//
if ((aNewSR.Last()-aNewSR.First()) < dT) {
aNewSR=aSR;
}
}
}
//=======================================================================
//function : CopySrc
//purpose :
//=======================================================================
void CopySrc(const TopoDS_Shape& E,
TopTools_IndexedDataMapOfShapeShape& aMapSS,
TopoDS_Shape& anEdge)
{
BRep_Builder BB;
TopAbs_ShapeEnum aTT;
Standard_Integer aR;
aTT=E.ShapeType();
if (aMapSS.Contains(E)) {
anEdge=aMapSS.ChangeFromKey(E);
if (aTT==TopAbs_EDGE)
return;
}
else {
anEdge=E.EmptyCopied();
aMapSS.Add(E, anEdge);
}
aR=(Standard_Integer)aTT+1;
if (aR>TopAbs_VERTEX) {
return;
}
Standard_Boolean free = anEdge.Free();
anEdge.Free(Standard_True);
aTT=(TopAbs_ShapeEnum) aR;
TopExp_Explorer anExpVertices(E, aTT);
for (; anExpVertices.More(); anExpVertices.Next()) {
const TopoDS_Shape& V=anExpVertices.Current();
TopoDS_Shape aVertex;
CopySrc (V, aMapSS, aVertex);
aVertex.Orientation(V.Orientation());
BB.Add(anEdge, aVertex);
}
anEdge.Free(free);
}

234
src/BOPTools/BOPTools_Tools2D.cdl Executable file
View File

@@ -0,0 +1,234 @@
-- File: BOPTools_Tools2D.cdl
-- Created: Mon Apr 2 12:20:21 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class Tools2D from BOPTools
---Purpose:
--- The class contains handy static functions
--- dealing with the topology
uses
Vec from gp,
Dir from gp,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Curve from Geom2d,
Curve from Geom,
ProjectedCurve from ProjLib
is
RemovePCurveForEdgeOnFace (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS);
---Purpose:
--- Remove P-Curve of the edge <aE> on the face <aF>
---
BuildPCurveForEdgeOnFace (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS);
---Purpose:
--- Compute P-Curve for the edge <aE> on the face <aF>
---
EdgeTangent (myclass;
anE : Edge from TopoDS;
aT : Real from Standard;
Tau : out Vec from gp)
returns Boolean from Standard;
---Purpose:
--- Compute tangent for the edge <aE> [in 3D] at parameter <aT>
---
FaceNormal (myclass;
aF: Face from TopoDS;
U : Real from Standard;
V : Real from Standard;
aN: out Vec from gp);
---Purpose:
--- Compute normal for the face <aF> at parameters <U,V>
--- of the corresp. surface.
---
PointOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aT: Real from Standard;
U : out Real from Standard;
V : out Real from Standard);
---Purpose:
--- Compute surface parameters <U,V> of the face <aF>
--- for the point from the edge <aE> at parameter <aT>.
---
CurveOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aC : out Curve from Geom2d;
aToler: out Real from Standard;
aTrim3d:Boolean from Standard);
---Purpose:
--- Get P-Curve <aC> for the edge <aE> on surface <aF> .
--- If the P-Curve does not exist, build it using Make2D().
--- [aToler] - reached tolerance
--- [aTrim3d] - trimming flag.
---
CurveOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aC : out Curve from Geom2d;
aFirst: out Real from Standard;
aLast : out Real from Standard;
aToler: out Real from Standard;
aTrim3d:Boolean from Standard);
---Purpose:
--- Get P-Curve <aC> for the edge <aE> on surface <aF> .
--- If the P-Curve does not exist, build it using Make2D().
--- [aFirst, aLast] - range of the P-Curve
--- [aToler] - reached tolerance
--- [aTrim3d] - trimming flag.
---
HasCurveOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aC : out Curve from Geom2d;
aFirst: out Real from Standard;
aLast : out Real from Standard;
aToler: out Real from Standard)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the edge <aE> has P-Curve <aC>
--- on surface <aF> .
--- [aFirst, aLast] - range of the P-Curve
--- [aToler] - reached tolerance
--- If the P-Curve does not exist, aC.IsNull()=TRUE.
---
HasCurveOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the edge <aE> has P-Curve <aC>
--- on surface <aF> .
--- If the P-Curve does not exist, aC.IsNull()=TRUE.
---
MakeCurveOnSurface (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aC : out Curve from Geom2d;
aFirst: out Real from Standard;
aLast : out Real from Standard;
aToler: out Real from Standard;
aTrim3d:Boolean from Standard);
---Purpose:
--- Same as Make2D()
---
Make2D (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aC : out Curve from Geom2d;
aFirst: out Real from Standard;
aLast : out Real from Standard;
aToler: out Real from Standard;
aTrim3d:Boolean from Standard);
---Purpose:
--- Make P-Curve <aC> for the edge <aE> on surface <aF> .
--- [aFirst, aLast] - range of the P-Curve
--- [aToler] - reached tolerance
--- [aTrim3d] - trimming flag.
---
MakePCurveOnFace (myclass;
aF: Face from TopoDS;
C3D : Curve from Geom;
aC : out Curve from Geom2d;
aToler: out Real from Standard) ;
---Purpose:
--- Make P-Curve <aC> for the 3D-curve <C3D> on surface <aF> .
--- [aToler] - reached tolerance
---
MakePCurveOnFace (myclass;
aF: Face from TopoDS;
C3D : Curve from Geom;
aT1 : Real from Standard;
aT2 : Real from Standard;
aC : out Curve from Geom2d;
aToler: out Real from Standard) ;
---Purpose:
--- Make P-Curve <aC> for the 3D-curve <C3D> on surface <aF> .
--- [aT1, aT2] - range to build
--- [aToler] - reached tolerance
---
AdjustPCurveOnFace (myclass;
aF : Face from TopoDS;
C3D : Curve from Geom;
aC2D : Curve from Geom2d;
aC2DA : out Curve from Geom2d);
---Purpose:
--- Adjust P-Curve <aC2D> (3D-curve <C3D>) on surface <aF> .
---
AdjustPCurveOnFace (myclass;
aF : Face from TopoDS;
aT1 : Real from Standard;
aT2 : Real from Standard;
aC2D : Curve from Geom2d;
aC2DA : out Curve from Geom2d);
---Purpose:
--- Adjust P-Curve <aC2D> (3D-curve <C3D>) on surface <aF> .
--- [aT1, aT2] - range to adjust
---
MakePCurveOfType (myclass;
PC : ProjectedCurve from ProjLib;
aC : out Curve from Geom2d);
---Purpose:
--- Make empty P-Curve <aC> of relevant to <PC> type
---
TangentOnEdge (myclass;
aParm: Real from Standard;
anE : Edge from TopoDS;
aTang: out Vec from gp)
returns Boolean from Standard;
---Purpose:
--- Compute tangent for the edge <anE> at parameter <aParm>
---
TangentOnEdge (myclass;
anE : Edge from TopoDS;
aDTang: out Dir from gp)
returns Boolean from Standard;
---Purpose:
--- Compute tangent for the edge <anE> at arbitrary intermediate parameter.
---
TangentOnVertex (myclass;
aVF : Vertex from TopoDS;
aVL : Vertex from TopoDS;
anE : Edge from TopoDS;
aTang: out Vec from gp)
returns Boolean from Standard;
---Purpose:
--- Compute tangent for the vertex point <aVF> for the edge <anE>.
--- <aVL> is opposite vertex of the edge
---
EdgeBounds (myclass;
anE : Edge from TopoDS;
aFirst: out Real from Standard;
aLast : out Real from Standard);
---Purpose:
--- Returns parametric range for the edge <anE>.
---
IntermediatePoint (myclass;
aFirst: Real from Standard;
aLast : Real from Standard)
returns Real from Standard;
---Purpose:
--- Compute intermediate value in between [aFirst, aLast] .
---
IntermediatePoint (myclass;
anE : Edge from TopoDS)
returns Real from Standard;
---Purpose:
--- Compute intermediate value of parameter for the edge <anE>.
---
end Tools2D;

734
src/BOPTools/BOPTools_Tools2D.cxx Executable file
View File

@@ -0,0 +1,734 @@
// File: BOPTools_Tools2D.cxx
// Created: Mon Apr 2 12:29:22 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Tools2D.ixx>
#include <Standard_NotImplemented.hxx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Surface.hxx>
static
Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E);
//=======================================================================
//function : EdgeTangent
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::EdgeTangent(const TopoDS_Edge& anEdge,
const Standard_Real aT,
gp_Vec& aTau)
{
Standard_Boolean isdgE;
Standard_Real first, last;
isdgE = BRep_Tool::Degenerated(anEdge);
if (isdgE) {
return Standard_False;
}
if (!CheckEdgeLength(anEdge)) {
return Standard_False;
}
Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last);
gp_Pnt aP;
aC->D1(aT, aP, aTau);
Standard_Real mod = aTau.Magnitude();
if(mod > gp::Resolution()) {
aTau /= mod;
}
else {
return Standard_False;
}
//aTau.Normalize();
if (anEdge.Orientation() == TopAbs_REVERSED){
aTau.Reverse();
}
return Standard_True;
}
//=======================================================================
//function : FaceNormal
//purpose :
//=======================================================================
void BOPTools_Tools2D::FaceNormal (const TopoDS_Face& aF,
const Standard_Real U,
const Standard_Real V,
gp_Vec& aN)
{
gp_Pnt aPnt ;
gp_Vec aD1U, aD1V;
Handle(Geom_Surface) aSurface;
aSurface=BRep_Tool::Surface(aF);
aSurface->D1 (U, V, aPnt, aD1U, aD1V);
aN=aD1U.Crossed(aD1V);
aN.Normalize();
if (aF.Orientation() == TopAbs_REVERSED){
aN.Reverse();
}
return;
}
//=======================================================================
//function : RemovePCurveForEdgeOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::RemovePCurveForEdgeOnFace (const TopoDS_Edge& aE,
const TopoDS_Face& aF)
{
BRep_Builder aBB;
Handle(Geom2d_Curve) aC2D;
Standard_Real aTol;
aTol=BRep_Tool::Tolerance(aE);
aBB.UpdateEdge(aE, aC2D, aF, aTol);
}
//=======================================================================
//function : BuildPCurveForEdgeOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
const TopoDS_Face& aF)
{
BRep_Builder aBB;
Handle(Geom2d_Curve) aC2D;
Standard_Real aTolPC, aTolFact, aTolEdge, aFirst, aLast;
Standard_Boolean aHasOld;
aHasOld=BOPTools_Tools2D::HasCurveOnSurface (aE, aF, aC2D, aFirst, aLast, aTolEdge);
if (aHasOld) {
return;
}
BOPTools_Tools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, Standard_True);
aTolEdge=BRep_Tool::Tolerance(aE);
aTolFact=Max(aTolEdge, aTolPC);
aBB.UpdateEdge(aE, aC2D, aF, aTolFact);
return;
}
//=======================================================================
//function : PointOnOnSurface
//purpose :
//=======================================================================
void BOPTools_Tools2D::PointOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const Standard_Real aParameter,
Standard_Real& U,
Standard_Real& V)
{
gp_Pnt2d aP2D;
Handle(Geom2d_Curve) aC2D;
Standard_Real aToler, aFirst, aLast;
BOPTools_Tools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, Standard_True);
aC2D->D0(aParameter, aP2D);
U=aP2D.X();
V=aP2D.Y();
return;
}
//=======================================================================
//function : CurveOnSurface
//purpose :
//=======================================================================
void BOPTools_Tools2D::CurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aToler,
const Standard_Boolean trim3d)
{
Standard_Real aFirst, aLast;
BOPTools_Tools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, trim3d);
return;
}
//=======================================================================
//function : CurveOnSurface
//purpose :
//=======================================================================
void BOPTools_Tools2D::CurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
Standard_Real& aToler,
const Standard_Boolean trim3d)
{
Standard_Boolean aHasOld;
Handle(Geom2d_Curve) C2D;
aHasOld=BOPTools_Tools2D::HasCurveOnSurface (aE, aF, C2D, aFirst, aLast, aToler);
if (aHasOld) {
aC2D=C2D;
return;
}
BOPTools_Tools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, trim3d);
aC2D=C2D;
return;
}
//=======================================================================
//function : HasCurveOnSurface
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
Standard_Real& aToler)
{
Standard_Boolean aHasOld;
aToler=BRep_Tool::Tolerance(aE);
BRep_Tool::Range(aE, aFirst, aLast);
if((aLast - aFirst) < Precision::PConfusion()) {
return Standard_False;
}
aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
aHasOld=!aC2D.IsNull();
return aHasOld;
}
//=======================================================================
//function : HasCurveOnSurface
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF)
{
Standard_Boolean aHasOld;
Handle(Geom2d_Curve) aC2D;
Standard_Real aFirst, aLast;
BRep_Tool::Range(aE, aFirst, aLast);
if((aLast - aFirst) < Precision::PConfusion()) {
return Standard_False;
}
aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
aHasOld=!aC2D.IsNull();
return aHasOld;
}
//=======================================================================
//function : MakeCurveOnSurface
//purpose :
//=======================================================================
void BOPTools_Tools2D::MakeCurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
Standard_Real& aToler,
const Standard_Boolean trim3d)
{
BOPTools_Tools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler, trim3d);
}
//=======================================================================
//function : Make2D
//purpose :
//=======================================================================
void BOPTools_Tools2D::Make2D (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
Standard_Real& aToler,
const Standard_Boolean trim3d)
{
Standard_Boolean aLocIdentity;
Standard_Real f3d, l3d;
TopLoc_Location aLoc;
Handle(Geom2d_Curve) C2D;
C2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
if (!C2D.IsNull()) {
aC2D=C2D;
return;
}
Handle(Geom_Curve) C3D3, C3D2, C3D;
C3D = BRep_Tool::Curve(aE, aLoc, f3d, l3d);
//
if (C3D.IsNull()) {
// aE has no 3D curve, so nothing is done
}
//
aLocIdentity=aLoc.IsIdentity();
if (aLocIdentity) {
C3D2 = C3D;
}
else {
C3D2 = Handle(Geom_Curve)::
DownCast(C3D->Transformed(aLoc.Transformation()));
}
if (trim3d) {
C3D3=C3D2;
}
else {
C3D3=C3D2;
}
//
aToler=.5*BRep_Tool::Tolerance(aE);
BOPTools_Tools2D::MakePCurveOnFace(aF, C3D3, f3d, l3d, aC2D, aToler);
//
aFirst = f3d;
aLast = l3d;
}
//=======================================================================
//function : MakePCurveOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::MakePCurveOnFace (const TopoDS_Face& aF,
const Handle(Geom_Curve)& aC3D,
Handle(Geom2d_Curve)& aC2D, //->
Standard_Real& TolReached2d)
{
Standard_Real aFirst, aLast;
aFirst = aC3D -> FirstParameter();
aLast = aC3D -> LastParameter();
//
TolReached2d=0.;
//
BOPTools_Tools2D::MakePCurveOnFace (aF, aC3D, aFirst, aLast, aC2D, TolReached2d);
}
//=======================================================================
//function : MakePCurveOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::MakePCurveOnFace (const TopoDS_Face& aF,
const Handle(Geom_Curve)& aC3D,
const Standard_Real aFirst,
const Standard_Real aLast,
Handle(Geom2d_Curve)& aC2D,
Standard_Real& TolReached2d)
{
Standard_Real aTolR;
Handle(Geom2d_Curve) aC2DA;
BRepAdaptor_Surface aBAS(aF, Standard_False);
Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS);
Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1
BOPTools_Tools2D::MakePCurveOfType(aProjCurv, aC2D);
aTolR=aProjCurv.GetTolerance();
//
if (aC2D.IsNull()) {
ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2
BOPTools_Tools2D::MakePCurveOfType(aProjCurvAgain, aC2D);
aTolR = aProjCurvAgain.GetTolerance();
//
if (aC2D.IsNull()) {
Standard_Real aTR=0.0001;
ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3
BOPTools_Tools2D::MakePCurveOfType(aProj3, aC2D);
aTolR = aProj3.GetTolerance();
}
}
TolReached2d=aTolR;
BOPTools_Tools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA);
aC2D=aC2DA;
}
//=======================================================================
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
const Handle(Geom_Curve)& aC3D,
const Handle(Geom2d_Curve)& aC2D,
Handle(Geom2d_Curve)& aC2DA)
{
Standard_Real first, last;
first = aC3D -> FirstParameter();
last = aC3D -> LastParameter();
BOPTools_Tools2D::AdjustPCurveOnFace (aF, first, last, aC2D, aC2DA);
}
//=======================================================================
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
void BOPTools_Tools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
const Standard_Real aFirst,
const Standard_Real aLast,
const Handle(Geom2d_Curve)& aC2D,
Handle(Geom2d_Curve)& aC2DA)
{
Standard_Boolean mincond, maxcond, decalu, decalv;
Standard_Integer k, iCnt;
Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta;
Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx;
//
aDelta=Precision::PConfusion();
BRepAdaptor_Surface aBAS(aF, Standard_False);
BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax);
aT =.5*(aFirst+aLast);
gp_Pnt2d pC2D;
aC2D->D0(aT, pC2D);
u2 = pC2D.X();
v2 = pC2D.Y();
du = 0.;
if (aBAS.IsUPeriodic()) {
aUPeriod=aBAS.UPeriod();
mincond = (u2 < UMin-aDelta);
maxcond = (u2 > UMax+aDelta);
decalu = mincond || maxcond;
if (decalu) {
//modified by NIZNHY-PKV Mon Mar 25 16:44:46 2008f
//du = ( mincond ) ? UPeriod : -UPeriod;
//
iCnt=1;
aUP2=aUPeriod+aUPeriod+aDelta;
aUP1=aUPeriod+aDelta;
//
if (u2 > aUP2) {
for(k=1; 1; ++k) {
aUx=u2-k*aUPeriod;
if (aUx < aUP1) {
iCnt=k;
break;
}
}
}
else if (u2 < -aUP2) {
for(k=1; 1; ++k) {
aUx=u2+k*aUPeriod;
if (aUx > -aUP1) {
iCnt=k;
break;
}
}
}
du = ( mincond ) ? aUPeriod : -aUPeriod;
du=iCnt*du;
//modified by NIZNHY-PKV Mon Mar 25 16:44:49 2008t
}
//
aUNew=u2+du;
if (aUNew<(UMin-aDelta) ||
aUNew>(UMax+aDelta)) {
// So previous correction was wrong.
// Try to be closer to UMin or UMax.
du=0.;
if (u2>UMax){
aDif=u2-UMax;
if (aDif < 4.e-7) {
du=-aDif;
}
}
}
} // if (BAHS->IsUPeriodic())
//
// dv
dv = 0.;
if (aBAS.IsVPeriodic()) {
Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr;
//
aVPeriod=aBAS.VPeriod();
mincond = (VMin - v2 > aDelta);
maxcond = (v2 - VMax > aDelta);
decalv = mincond || maxcond;
if (decalv) {
dv = ( mincond ) ? aVPeriod : -aVPeriod;
}
//
//xf
if ((VMax-VMin<aVPeriod) && dv) {
aVm=v2;
aVr=v2+dv;
aVmid=0.5*(VMin+VMax);
dVm=fabs(aVm-aVmid);
dVr=fabs(aVr-aVmid);
if (dVm<dVr) {
dv=0.;
}
}
//xt
}
//
// Translation if necessary
Handle(Geom2d_Curve) aC2Dx=aC2D;
if ( du != 0. || dv != 0.) {
Handle(Geom2d_Curve) PCT = Handle(Geom2d_Curve)::DownCast(aC2Dx->Copy());
gp_Vec2d aV2D(du,dv);
PCT->Translate(aV2D);
aC2Dx = PCT;
}
aC2DA=aC2Dx;
}
//=======================================================================
//function : MakePCurveOfType
//purpose :
//=======================================================================
void BOPTools_Tools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC,
Handle(Geom2d_Curve)& C2D)
{
switch (PC.GetType()) {
case GeomAbs_Line :
C2D = new Geom2d_Line(PC.Line());
break;
case GeomAbs_Circle :
C2D = new Geom2d_Circle(PC.Circle());
break;
case GeomAbs_Ellipse :
C2D = new Geom2d_Ellipse(PC.Ellipse());
break;
case GeomAbs_Parabola :
C2D = new Geom2d_Parabola(PC.Parabola());
break;
case GeomAbs_Hyperbola :
C2D = new Geom2d_Hyperbola(PC.Hyperbola());
break;
case GeomAbs_BSplineCurve :
C2D = PC.BSpline();
break;
case GeomAbs_BezierCurve :
case GeomAbs_OtherCurve :
default :
Standard_NotImplemented::Raise("BOPTools_Tools2D::MakePCurveOfType");
break;
}
}
//=======================================================================
//function : TangentOnEdge
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::TangentOnEdge(const Standard_Real par,
const TopoDS_Edge& E,
gp_Vec& Tg)
{
Standard_Boolean isdgE;
isdgE = BRep_Tool::Degenerated(E);
if (isdgE) {
return Standard_False;
}
if (!CheckEdgeLength(E)) {
return Standard_False;
}
BRepAdaptor_Curve BC(E);
//
// Body
Standard_Real f, l, tolE, tolp;
Standard_Boolean onf, onl, inbounds;
f = BC.FirstParameter();
l = BC.LastParameter();
tolE = BC.Tolerance();
tolp = BC.Resolution(tolE);
onf = Abs(f-par)<tolp;
onl = Abs(l-par)<tolp;
inbounds = (f<par) && (par<l);
if ((!inbounds) && (!onf) && (!onl)) {
return Standard_False;
}
gp_Pnt aP;
BC.D1(par, aP, Tg);
Tg.Normalize();
return Standard_True;
}
//=======================================================================
//function : TangentOnEdge
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::TangentOnEdge(const TopoDS_Edge& aE,
gp_Dir& DTg)
{
Standard_Real aT;
gp_Vec aTg;
DTg.SetCoord(1.,0.,0.);
aT= BOPTools_Tools2D::IntermediatePoint (aE);
Standard_Boolean bIsFound=BOPTools_Tools2D::TangentOnEdge(aT, aE, aTg);
if (bIsFound) {
gp_Dir aDTmp(aTg);
DTg=aDTmp;
}
return bIsFound;
}
//=======================================================================
//function : TangentOnVertex
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools2D::TangentOnVertex (const TopoDS_Vertex& v,
const TopoDS_Vertex& vl,
const TopoDS_Edge& e,
gp_Vec& aVec)
// tg oriented INSIDE 1d(e)
// vl : last vertex of e
{
Standard_Boolean ok;
Standard_Real par;
gp_Vec tg;
par = BRep_Tool::Parameter(v, e);
ok =BOPTools_Tools2D::TangentOnEdge (par, e, tg);
if (!ok) {
return ok;
}
if (v.IsSame(vl)) {
tg.Reverse();
}
aVec=tg;
return ok;
}
//=======================================================================
//function : EdgeBounds
//purpose :
//=======================================================================
void BOPTools_Tools2D::EdgeBounds (const TopoDS_Edge& aE,
Standard_Real& aFirst,
Standard_Real& aLast)
{
BRepAdaptor_Curve aBC(aE);
aFirst= aBC.FirstParameter();
aLast = aBC.LastParameter();
}
//=======================================================================
//function : IntermediatePoint
//purpose :
//=======================================================================
Standard_Real BOPTools_Tools2D::IntermediatePoint (const Standard_Real aFirst,
const Standard_Real aLast)
{
//define parameter division number as 10*e^(-PI) = 0.43213918
const Standard_Real PAR_T = 0.43213918;
Standard_Real aParm;
aParm=(1.-PAR_T)*aFirst + PAR_T*aLast;
return aParm;
}
//=======================================================================
//function : IntermediatePoint
//purpose :
//=======================================================================
Standard_Real BOPTools_Tools2D::IntermediatePoint (const TopoDS_Edge& aE)
{
Standard_Real aT, aT1, aT2;
Handle(Geom_Curve)aC1=BRep_Tool::Curve(aE, aT1, aT2);
aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
return aT;
}
//=======================================================================
//function : CheckEdgeLength
//purpose :
//=======================================================================
Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
{
BRepAdaptor_Curve BC(E);
TopTools_IndexedMapOfShape aM;
TopExp::MapShapes(E, TopAbs_VERTEX, aM);
Standard_Integer i, anExtent, aN=10;
Standard_Real ln=0., d, t, f, l, dt;
anExtent=aM.Extent();
if (anExtent!=1)
return Standard_True;
gp_Pnt p1, p2;
f = BC.FirstParameter();
l = BC.LastParameter();
dt=(l-f)/aN;
BC.D0(f, p1);
for (i=1; i<=aN; i++) {
t=f+i*dt;
if (i==aN)
BC.D0(l, p2);
else
BC.D0(t, p2);
d=p1.Distance(p2);
ln+=d;
p1=p2;
}
return (ln > Precision::Confusion());
}

458
src/BOPTools/BOPTools_Tools3D.cdl Executable file
View File

@@ -0,0 +1,458 @@
-- File: BOP_Tools.cdl
-- Created: Mon Apr 5 12:20:21 2001
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2001
class Tools3D from BOPTools
---Purpose:
-- The class contains handy static functions
-- dealing with the topology
uses
Pln from gp,
Dir from gp,
Pnt from gp,
Pnt2d from gp,
Surface from Geom,
Shape from TopoDS,
Wire from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Solid from TopoDS,
ShapeEnum from TopAbs,
Orientation from TopAbs,
State from TopAbs,
ListOfShape from TopTools,
Context from IntTools,
IndexedDataMapOfShapeListOfShape from TopTools
is
SubShapesAmount (myclass;
aS: Shape from TopoDS;
aT: ShapeEnum from TopAbs)
returns Integer from Standard ;
---Purpose:
-- Returns amount of sub-shapes of type <aT>
-- for the shape <aS>
--
IsConvexWire (myclass;
aW: Wire from TopoDS)
returns Boolean from Standard ;
---Purpose:
-- Returns TRUE if
-- amount of the vertices <= amount of the edges>
-- for the wire <aW>
--
RemoveSims (myclass;
aF: Face from TopoDS;
aContext:out Context from IntTools);
---Purpose:
-- Remove seam edges from face <aF>
--
RemoveSims (myclass;
aS: Shape from TopoDS;
aContext:out Context from IntTools);
---Purpose:
-- Remove seam edges from all faces of shape <aS>
--
EdgeOrientation (myclass;
aEx: Edge from TopoDS;
aF1: Face from TopoDS;
aF2: Face from TopoDS)
returns Orientation from TopAbs;
---Purpose:
-- For the draft section edge <aEx> computes orientation
-- in accordance with vector product between normals to
-- the faces <aF1>, <aF2>
--
IsSplitToReverse1 (myclass;
aE1: Edge from TopoDS;
aE2: Edge from TopoDS;
aContext:out Context from IntTools)
returns Boolean from Standard;
---Purpose:
-- Returns TRUE if direction of the edge <aE1> is not
-- the same as for the edge <aE2>
-- (using projection)
--
DoSplitSEAMOnFace (myclass;
aSp: Edge from TopoDS;
aF : Face from TopoDS);
---Purpose:
-- Make the edge <aSp> seam edge for the face <aF>
--
--modified by NIZHNY-MKK Mon Feb 17 15:02:01 2003.BEGIN
DoSplitSEAMOnFace (myclass;
theSplit : Edge from TopoDS;
theSeam : Edge from TopoDS;
theFace : Face from TopoDS;
IsReversed: out Boolean from Standard)
returns Boolean from Standard;
---Purpose:
-- Make the edge <theSplit> seam edge for the face <theFace>
-- It uses pcurves of <theSeam> to make <theSplit> seam edge.
-- IsReversed is true if pcurves of <theSplit> and <theSeam> are
-- reversed according to each other.
-- Returns true if <theSplit> was made seam edge for <theFace>
--
--modified by NIZHNY-MKK Mon Feb 17 15:02:04 2003.END
IsTouchCase (myclass;
aEx: Edge from TopoDS;
aF1: Face from TopoDS;
aF2: Face from TopoDS)
returns Boolean from Standard;
---Purpose:
-- Returns TRUE if the edge <aEx> is section edge
-- between touching faces <aF1>, <aF2>
--
GetTangentToEdge (myclass;
aE: Edge from TopoDS;
aT: Real from Standard;
aD:out Dir from gp)
returns Boolean from Standard;
---Purpose:
-- Computes tangent (3D) for the edge <aE>
-- at parameter <aT>
-- Returns TRUE if the edge <aE> is not degenerated.
--
GetTangentToEdge (myclass;
aE: Edge from TopoDS;
aD:out Dir from gp)
returns Boolean from Standard;
---Purpose:
--- Computes tangent (3D) for the edge <aE>
--- at arbitrary intermediate parameter
--- Returns TRUE if the edge <aE> is not degenerated.
---
GetNormalToFaceOnEdge (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aT: Real from Standard;
aD:out Dir from gp);
---Purpose:
--- Computes normal to the face <aF> for the point on the edge <aE>
--- at parameter <aT>
---
GetNormalToFaceOnEdge (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aD:out Dir from gp);
---Purpose:
--- Computes normal to the face <aF> for the point on the edge <aE>
--- at arbitrary intermediate parameter
---
GetBiNormal (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aT: Real from Standard;
aD:out Dir from gp);
---Purpose:
--- Computes binormal to the face <aF> for the point on the edge <aE>
--- at parameter <aT>
---
GetBiNormal (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aD:out Dir from gp);
---Purpose:
--- Computes binormal to the face <aF> for the point on the edge <aE>
--- at arbitrary intermediate parameter
---
IsSplitToReverse(myclass;
aE : Edge from TopoDS;
aSp: Edge from TopoDS)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if direction of the edge <aE1> is not
--- the same as for the edge <aE2>
---
GetAdjacentFace (myclass;
aF : Face from TopoDS;
aE : Edge from TopoDS;
aEFMap: IndexedDataMapOfShapeListOfShape from TopTools;
anAdjF:out Face from TopoDS)
returns Boolean from Standard;
---Purpose:
--- Get face <anAdjF> that is adjacent to the face <aF> through
--- the edge <aE> (using map EF <aEFMap>)
--- Returns FALSE if adjacent face is not found
---
IsKeepTwice (myclass;
aF1 : Face from TopoDS;
aF2 : Face from TopoDS;
aF2Adj: Face from TopoDS;
aSpEF2: Edge from TopoDS)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if pair of faces <aF2> and <aF2Adj>
--- that are adjacent faces through the edge <aSpEF2>
--- crosses the face <aF1> by <aSpEF2>
---
SenseFlag (myclass;
aNF1 : Dir from gp;
aNF2 : Dir from gp)
returns Integer from Standard;
---Purpose:
--- Returns 1 if scalar product aNF1* aNF2>0.
--- Returns 0 if directions aNF1 aNF2 coinside
--- Returns -1 if scalar product aNF1* aNF2<0.
---
GetNormalToSurface (myclass;
aS: Surface from Geom;
U : Real from Standard;
V : Real from Standard;
aD:out Dir from gp)
returns Boolean from Standard;
---Purpose:
--- Compute normal <aD> to surface <aS> in point (U,V)
--- Returns TRUE if directions aD1U, aD1V coinside
---
GetPlanes (myclass;
aSp : Edge from TopoDS;
aE2 : Edge from TopoDS;
aEFMap2: IndexedDataMapOfShapeListOfShape from TopTools;
aE1 : Edge from TopoDS;
aF1 : Face from TopoDS;
aST1:out State from TopAbs;
aContext:out Context from IntTools);
---Purpose:
--- Internal usage
---
Orientation (myclass;
aE : Edge from TopoDS;
aF : Face from TopoDS)
returns Orientation from TopAbs;
---Purpose:
--- Get the orientation for the edge <aE> on the face <aF>
--- Returns TopAbs_INTERNAL if the edge <aE> is not found
--- on the face <aF>
---
SignDistance (myclass;
aP : Pnt from gp;
aPL: Pln from gp)
returns Real from Standard;
---Purpose:
--- Computes signed distance between the 3D-point <aP>
--- and the plane <aPL>.
---
-- Warning:
--- The distance is not divided by sqrt(A*A+B*B+C*C)
---
GetApproxNormalToFaceOnEdge (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aT: Real from Standard;
aPx:out Pnt from gp;
aD:out Dir from gp);
---Purpose:
--- Computes normal to the face <aF> for the 3D-point that
--- belonds to the edge <aE> at parameter <aT>.
-- Output:
--- aPx - the 3D-point where the normal computed
--- aD - the normal;
---
-- Warning:
--- The normal is computed not exactly in the point on the
--- edge, but in point that is near to the edge towards to
--- the face material (so, we'll have approx. normal)
---
PointNearEdge (myclass;
aE : Edge from TopoDS;
aF : Face from TopoDS;
aT : Real from Standard;
aDt2D: Real from Standard;
aP2D :out Pnt2d from gp;
aPx :out Pnt from gp);
---Purpose:
--- Compute the point <aPx>, (<aP2D>) that is near to
--- the edge <aE> at parameter <aT> towards to the
--- material of the face <aF>. The value of shifting in
--- 2D is <aDt2D>
---
PointNearEdge (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aT: Real from Standard;
aP2D:out Pnt2d from gp;
aPx:out Pnt from gp);
---Purpose:
--- Computes the point <aPx>, (<aP2D>) that is near to
--- the edge <aE> at parameter <aT> towards to the
--- material of the face <aF>. The value of shifting in
-- 2D is dt2D=BOPTools_Tools3D::MinStepIn2d()
---
PointNearEdge (myclass;
aE: Edge from TopoDS;
aF: Face from TopoDS;
aP2D:out Pnt2d from gp;
aPx:out Pnt from gp);
---Purpose:
--- Compute the point <aPx>, (<aP2D>) that is near to
--- the edge <aE> at arbitrary parameter towards to the
--- material of the face <aF>. The value of shifting in
-- 2D is dt2D=BOPTools_Tools3D::MinStepIn2d()
---
PointToCompare (myclass;
aP1: Pnt from gp;
aP2: Pnt from gp;
aF: Face from TopoDS;
aPx:out Pnt from gp;
aContext:out Context from IntTools);
---Purpose:
--- For 3D-point <aP1> find projection point <aPx> on the face <aF>.
--- If the distance (<aP1>, <aPx>) > TolF =>
--- For 3D-point <aP2> find projection point <aPx> on the face <aF>.
--- If the distance (<aP2>, <aPx>) > TolF => returns <aP1>
---
GetPlane (myclass;
aSp : Edge from TopoDS;
aE1 : Edge from TopoDS;
aF1 : Face from TopoDS;
aF2 : Face from TopoDS;
aST:out State from TopAbs;
aContext:out Context from IntTools);
---Purpose:
--- Compute 3D-state for the point on the split edge <aSp>
--- (with base edge <aE1> and the face <aF1>) comparing with
--- the face <aF2>
---
GetPointState (myclass;
aSp : Edge from TopoDS;
aEF2 : Edge from TopoDS;
aF2Adj : Face from TopoDS;
aF1 : Face from TopoDS;
aST:out State from TopAbs);
---Purpose:
--- Compute 3D-state for the point on the split edge <aSp>
--- (with base edge <aEF2> and the adjacent face <aF2Adj>) comparing with
--- the face <aF1>
---
OrientEdgeOnFace (myclass;
aE : Edge from TopoDS;
aF : Face from TopoDS;
aER : out Edge from TopoDS);
---Purpose:
--- Get the edge <aER> from the face <aF> that is the same as
--- the edge <aE>
---
OrientTouchEdgeOnF1 (myclass;
aSp: Edge from TopoDS;
aEx: Edge from TopoDS;
aF1: Face from TopoDS;
aF2: Face from TopoDS)
returns Orientation from TopAbs;
---Purpose:
--- Computes orientation for the split edge <aSp>
--- [with base edge <aEx> and face <aF2>] on the
--- face <aF1>
---
GetSeams (myclass;
aF : Face from TopoDS;
aSimm1 : out Edge from TopoDS;
aSimm2 : out Edge from TopoDS);
---Purpose:
--- Get seam edges <aSimm1>, <aSimm2> for the face <aF>
---
GetSeam (myclass;
aF : Face from TopoDS;
aS1: Edge from TopoDS;
aS2: out Edge from TopoDS);
---Purpose:
--- Get opposite seam edge <aS2> for the face <aF> with
--- known seam edge <aS1>
---
IsValidArea (myclass;
aF : Face from TopoDS;
aNegativeFlag : out Boolean from Standard)
returns Boolean from Standard;
---Purpose:
--- Check validity of the area of face <aF>.
--- Returns TRUE if the Abs. value of the area
--- is greater than 1.e-16
---
MinStepIn2d(myclass)
returns Real from Standard;
---Purpose:
--- Returns simple step value that is used in 2D-computations
--- = 1.e-5
---
IsEmptyShape(myclass;
aS: Shape from TopoDS)
returns Boolean from Standard;
---Purpose:
--- Returns TRUE if the shape <aS> does not contain
--- geometry information (e.g. empty compound)
---
InvertShape(myclass;
aS : Shape from TopoDS;
aSInv:out Shape from TopoDS);
---Purpose:
--- Change orientations to opposite for the shape <aS>
--- and all its sub-shapes. Returns <aSInv>
---
GetStatePartIN2D(myclass;
aSp :Edge from TopoDS;
aEF1 :Edge from TopoDS;
aF1 :Face from TopoDS;
aF2 :Face from TopoDS;
aContext:out Context from IntTools)
returns State from TopAbs;
---Purpose:
--- Used in touch case
--- Compute the 3D-state for the point on the split
--- edge <aSp> (with base edge <aEF1> on face <aF1>)
--- comparing with <aF2>.
--- Used in touch case <aF1>/<aF2>
---
CheckSameDomainFaceInside(myclass; theFace1: Face from TopoDS;
theFace2: Face from TopoDS;
theContext: in out Context from IntTools)
returns Boolean from Standard;
ComputeFaceState(myclass; theFace: Face from TopoDS;
theRef : Solid from TopoDS;
theContext: in out Context from IntTools;
theState: out State from TopAbs)
returns Boolean from Standard;
TreatedAsAnalytic(myclass; aTx :Real from Standard;
aPx :Pnt from gp;
aEx :Edge from TopoDS;
aFx :Face from TopoDS;
aE1 :Edge from TopoDS;
aF1 :Face from TopoDS;
aTolTangent:Real from Standard;
aTolRadius :Real from Standard;
aState :out State from TopAbs;
aContext:out Context from IntTools)
returns Boolean from Standard;
TreatedAsAnalytic (myclass; aFx :Face from TopoDS;
aSpE1 :Edge from TopoDS;
aF1 :Face from TopoDS;
aTolTangent:Real from Standard;
aTolRadius :Real from Standard;
aState :out State from TopAbs;
aContext:out Context from IntTools)
returns Boolean from Standard;
HasAnalyticSurfaceType (myclass; aF: Face from TopoDS)
returns Boolean from Standard;
end Tools3D;

1407
src/BOPTools/BOPTools_Tools3D.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,996 @@
// File: BOPTools_Tools3D_1.cxx
// Created: Mon Jun 18 09:51:53 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Tools3D.ixx>
#include <math.h>
#include <gp.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BOPTools_Tools2D.hxx>
//=======================================================================
//function : GetApproxNormalToFaceOnEdge
//purpose :
//=======================================================================
void BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const Standard_Real aT,
gp_Pnt& aPNear,
gp_Dir& aDNF)
{
Standard_Real aFirst, aLast;
Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast);
if (aC2D.IsNull()) {
return;
}
//gp_Pnt aPNear;
gp_Pnt2d aPx2DNear;
BOPTools_Tools3D::PointNearEdge (aE, aF, aT, aPx2DNear, aPNear);
Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
BOPTools_Tools3D::GetNormalToSurface (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF);
if (aF.Orientation()==TopAbs_REVERSED){
aDNF.Reverse();
}
}
//=======================================================================
//function : PointNearEdge
//purpose :
//=======================================================================
void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const Standard_Real aT,
const Standard_Real aDt2D,
gp_Pnt2d& aPx2DNear,
gp_Pnt& aPxNear)
{
Standard_Real aFirst, aLast, aETol, aFTol, transVal;
GeomAbs_SurfaceType aTS;
Handle(Geom2d_Curve) aC2D;
Handle(Geom_Surface) aS;
//
aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast);
if (aC2D.IsNull()) {
aPx2DNear.SetCoord (99., 99);
return;
}
//
aS=BRep_Tool::Surface(aF);
//
gp_Pnt2d aPx2D;
gp_Vec2d aVx2D;
aC2D->D1 (aT, aPx2D, aVx2D);
gp_Dir2d aDx2D(aVx2D);
gp_Dir2d aDP;
aDP.SetCoord (-aDx2D.Y(), aDx2D.X());
if (aE.Orientation()==TopAbs_REVERSED){
aDP.Reverse();
}
if (aF.Orientation()==TopAbs_REVERSED) {
aDP.Reverse();
}
//
aETol = BRep_Tool::Tolerance(aE);
aFTol = BRep_Tool::Tolerance(aF);
// pkv NPAL19220
GeomAdaptor_Surface aGAS(aS);
aTS=aGAS.GetType();
if (aTS==GeomAbs_BSplineSurface) {
if (aETol > 1.e-5) {
aFTol=aETol;
}
}
//modified by NIZNHY-PKV Thu Mar 19 14:15:15 2009f
if( aETol > 1.e-5 || aFTol > 1.e-5 ) {
//if( aETol > 1.e-5 && aFTol > 1.e-5 ) {
//modified by NIZNHY-PKV Thu Mar 19 14:15:24 2009t
//pkv/103/D7
if(aTS!=GeomAbs_Sphere) {
gp_Vec2d transVec( aDP );
transVal = aDt2D + aETol + aFTol;
if (aTS==GeomAbs_Cylinder) {// pkv/909/F8
Standard_Real aR, dT;
//
gp_Cylinder aCyl=aGAS.Cylinder();
aR=aCyl.Radius();
dT=1.-transVal/aR;
dT=acos(dT);
transVal=dT;
}
//
transVec.Multiply(transVal);
//
aPx2DNear = aPx2D.Translated( transVec );
}
else {
aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y());
}
}
else {
aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y());
}
//
aS->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear);
}
//=======================================================================
//function : PointNearEdge
//purpose :
//=======================================================================
void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
const Standard_Real aT,
gp_Pnt2d& aPx2DNear,
gp_Pnt& aPxNear)
{
Standard_Real dt2D=BOPTools_Tools3D::MinStepIn2d();//~1.e-5;
//
BOPTools_Tools3D::PointNearEdge (aE, aF, aT, dt2D, aPx2DNear, aPxNear);
}
//=======================================================================
// function: PointNearEdge
// purpose:
//=======================================================================
void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
gp_Pnt2d& aPInFace2D,
gp_Pnt& aPInFace)
{
Standard_Real aT, aT1, aT2;
//
// 1.
BRep_Tool::Range(aE, aT1, aT2);
aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
//
// 2. a Point inside Face near aPOnEdge aPInFace;
TopoDS_Face aFF=aF;
TopoDS_Edge aERight;
aFF.Orientation(TopAbs_FORWARD);
BOPTools_Tools3D::OrientEdgeOnFace (aE, aFF, aERight);
BOPTools_Tools3D::PointNearEdge (aERight, aFF, aT, aPInFace2D, aPInFace);
}
//=======================================================================
//function : PointToCompare
//purpose :
//=======================================================================
void BOPTools_Tools3D::PointToCompare (const gp_Pnt& aP1,
const gp_Pnt& aP2,
const TopoDS_Face& aF,
gp_Pnt& aPF,
IntTools_Context& aContext)
{
Standard_Boolean bFlag;
Standard_Real aD, aTolF, U, V;
Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
aTolF=BRep_Tool::Tolerance(aF);
//
GeomAPI_ProjectPointOnSurf& aProjector=aContext.ProjPS(aF);
//
aProjector.Perform(aP1);
//
bFlag=aProjector.IsDone();
if (bFlag) {
aD=aProjector.LowerDistance();
if (aD<aTolF) {
aProjector.LowerDistanceParameters (U, V);
aS->D0(U, V, aPF);
return;
}
}
//
aProjector.Perform(aP2);
//
bFlag=aProjector.IsDone();
if (bFlag) {
aD=aProjector.LowerDistance();
if (aD<aTolF) {
aProjector.LowerDistanceParameters (U, V);
aS->D0(U, V, aPF);
return;
}
}
aPF=aP1;
}
//=======================================================================
//function : GetPlane
//purpose :
//=======================================================================
void BOPTools_Tools3D::GetPlane (const TopoDS_Edge& aSpEF1,
const TopoDS_Edge& aEF1,
const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
TopAbs_State& aStPF,
IntTools_Context& aContext)
{
Standard_Real aT1, aT2, aT, aTolF2, aDt2D;
gp_Pnt2d aPx2DNear;
gp_Pnt aPxNear, aPxF2;
gp_Dir aDNF2;
Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF1, aT1, aT2);
aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aEF1, aF1, aT1, aT2);
aStPF=TopAbs_OUT;
//
aDt2D=BOPTools_Tools3D::MinStepIn2d();//~1.e-5;
aTolF2=BRep_Tool::Tolerance(aF2);
//
{
GeomAbs_SurfaceType aType1;
Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
GeomAdaptor_Surface aGASF1(aS1);
aType1=aGASF1.GetType();
if (aType1==GeomAbs_Cylinder) {
Standard_Real aCT, aDt2Dx, aPC=0.99;
aCT=1.-aGASF1.UResolution(aTolF2);
aDt2Dx=aPC*acos(aCT);
if (aDt2Dx>aDt2D) {
aDt2D=aDt2Dx;
}
}
}
//
BOPTools_Tools3D::PointNearEdge (aEF1, aF1, aT, aDt2D, aPx2DNear, aPxNear);
//
//-- EJG
Standard_Boolean isIn = aContext.IsPointInFace(aF1,aPx2DNear);
if( !isIn ) {
Standard_Real aEF1Tol = BRep_Tool::Tolerance(aEF1);
Standard_Real aF1Tol = BRep_Tool::Tolerance(aF1);
if( aEF1Tol > 1.e-5 || ( aF1Tol > 1.e-5 || aTolF2 > 1.e-5 ) ) {
gp_Pnt2d aP2DOnC;
aC2D->D0(aT, aP2DOnC);
gp_Vec2d aP2Dir( aPx2DNear, aP2DOnC );
Standard_Real transVal = aP2Dir.Magnitude();
gp_Vec2d aP2DirN = aP2Dir.Normalized();
if( aF1Tol > 1.e-5 && aTolF2 > 1.e-5 ) {
transVal = 2.*transVal +aEF1Tol + aF1Tol + aTolF2;
}
else {
transVal *= 2.;
}
aPx2DNear.Translate( (transVal*aP2DirN) );
Handle(Geom_Surface) aS1 = BRep_Tool::Surface(aF1);
aS1->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear);
}
}
//-- EJG
Standard_Boolean bFlag;
Standard_Real aD, U, V;
//
GeomAPI_ProjectPointOnSurf& aProjector=aContext.ProjPS(aF2);
//
Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
//
aProjector.Perform(aPxNear);
//
bFlag=aProjector.IsDone();
if (!bFlag) {
return;
}
//
aD=aProjector.LowerDistance();
if (aD<aTolF2) {
// aPxF2, aDNF2, aPlnF2
aProjector.LowerDistanceParameters (U, V);
aS2->D0(U, V, aPxF2);
BOPTools_Tools3D::GetNormalToSurface (aS2, U, V, aDNF2);
if (aF2.Orientation()==TopAbs_REVERSED){
aDNF2.Reverse();
}
gp_Pln aPlnF2(aPxF2, aDNF2);
//
aD=BOPTools_Tools3D::SignDistance(aPxNear, aPlnF2);
if (aD<=0.) {
aStPF=TopAbs_IN;
}
}
}
//=======================================================================
//function : GetPointState
//purpose :
//=======================================================================
void BOPTools_Tools3D::GetPointState (const TopoDS_Edge& aSpEF2,
const TopoDS_Edge& aEF2,
const TopoDS_Face& aF2adj,
const TopoDS_Face& aF1,
TopAbs_State& aStPF)
{
Standard_Real aT1, aT2, aT, aTolEF2;
gp_Dir aDNF1;
gp_Pnt2d aPxOnF1, aPxOnF2;
//
TopoDS_Face aF2adjF=aF2adj;
aF2adjF.Orientation(TopAbs_FORWARD);
//
aTolEF2=BRep_Tool::Tolerance(aEF2);
//
aStPF=TopAbs_OUT;
//
Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF2, aT1, aT2);
aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
//
// 2D-curves of aSpEF2 for aF1, aF2adj
Handle(Geom2d_Curve) aC2DF1= BRep_Tool::CurveOnSurface (aSpEF2, aF1, aT1, aT2);
aC2DF1->D0(aT, aPxOnF1);
Handle(Geom2d_Curve) aC2DF2= BRep_Tool::CurveOnSurface (aSpEF2, aF2adjF, aT1, aT2);
aC2DF2->D0(aT, aPxOnF2);
//
// Surfaces
Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2adjF);
//
// Step aDt2D
Standard_Real aDt2D, aDt2dMin, aURes, aVRes;
//
GeomAdaptor_Surface aGASF2adjF(aS2);
//
aURes=aGASF2adjF.UResolution(aTolEF2);
aVRes=aGASF2adjF.VResolution(aTolEF2);
aDt2D=(aURes>aVRes) ? aURes : aVRes;
//
aDt2dMin=BOPTools_Tools3D::MinStepIn2d();
//
if (aDt2D < aDt2dMin) {
aDt2D=aDt2dMin;
}
//
// Point aPxNear on aF2adjF that is Near Edge aEF2Right at parameter aT
gp_Pnt2d aPx2DNear;
gp_Pnt aPxNear;
TopoDS_Edge aEF2Right;
//
BOPTools_Tools3D::OrientEdgeOnFace (aEF2, aF2adjF, aEF2Right);
//
BOPTools_Tools3D::PointNearEdge (aEF2Right, aF2adjF, aT, aDt2D, aPx2DNear, aPxNear);
//
// Normal to the face aF1 at the point aPxOnF1
BOPTools_Tools3D::GetNormalToSurface (aS1, aPxOnF1.X(), aPxOnF1.Y(), aDNF1);
if (aF1.Orientation()==TopAbs_REVERSED){
aDNF1.Reverse();
}
//
// Plane to compare aPlnF1
gp_Pnt aPxF1, aPxF2;
//
aS1->D0(aPxOnF1.X(), aPxOnF1.Y(), aPxF1);
//
gp_Pln aPlnF1(aPxF1, aDNF1);
//
// Correction on shifting vector aVx
{
Standard_Real aX, aY, aZ;
//
aS2->D0(aPxOnF2.X(), aPxOnF2.Y(), aPxF2);
gp_Vec aVx(aPxF2, aPxF1);
//
aX=aPxNear.X()+aVx.X();
aY=aPxNear.Y()+aVx.Y();
aZ=aPxNear.Z()+aVx.Z();
//
aPxNear.SetCoord(aX, aY, aZ);
}
//
// Signed Distance between aPxNear, aPlnF1
Standard_Real aD;
aD=BOPTools_Tools3D::SignDistance(aPxNear, aPlnF1);
if (aD<=0.) {
aStPF=TopAbs_IN;
}
}
//=======================================================================
//function : OrientEdgeOnFace
//purpose :
//=======================================================================
void BOPTools_Tools3D::OrientEdgeOnFace (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
TopoDS_Edge& aERight)
{
if (BRep_Tool::IsClosed(aE, aF)) {
aERight=aE;
aERight.Orientation(aE.Orientation());
Standard_Integer iFoundCount = 0;
TopoDS_Edge anEdge = aE;
TopExp_Explorer anExp(aF, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aSS=anExp.Current();
if (aSS.IsSame(aE)) {
anEdge = TopoDS::Edge(aSS);
iFoundCount++;
}
}
if(iFoundCount == 1) {
aERight = anEdge;
}
return;
}
TopExp_Explorer anExp(aF, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aSS=anExp.Current();
if (aSS.IsSame(aE)) {
aERight=aE;
aERight.Orientation(aSS.Orientation());
return;
}
}
aERight=aE;
aERight.Orientation(aE.Orientation());
}
//=======================================================================
//function : OrientTouchEdgeOnF1
//purpose :
//=======================================================================
TopAbs_Orientation BOPTools_Tools3D::OrientTouchEdgeOnF1 (const TopoDS_Edge& aSpEF2,
const TopoDS_Edge& aEF2,
const TopoDS_Face& aF2adj,
const TopoDS_Face& aF1)
{
Standard_Real aT1, aT2, aT;
//
Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF2, aT1, aT2);
//
// point on edge aEF2 inside range of aSpEF2:
gp_Pnt aPx;
aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
aC3D->D0(aT, aPx);
//
// Normal to aF1
gp_Dir aDNF1;
Handle(Geom2d_Curve) aC2DF1= BRep_Tool::CurveOnSurface (aSpEF2, aF1, aT1, aT2);
gp_Pnt2d aPxOnF1;
aC2DF1->D0(aT, aPxOnF1);
Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
BOPTools_Tools3D::GetNormalToSurface (aS1, aPxOnF1.X(), aPxOnF1.Y(), aDNF1);
if (aF1.Orientation()==TopAbs_REVERSED){
aDNF1.Reverse();
}
//
// Point aPxNear that is ON F2adj and near Px
gp_Pnt2d aPx2DNear;
gp_Pnt aPxNear;
Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aEF2, aF2adj, aT1, aT2);
TopoDS_Face aF2adjF=aF2adj;
aF2adjF.Orientation(TopAbs_FORWARD);
TopoDS_Edge aEF2Right;
BOPTools_Tools3D::OrientEdgeOnFace (aEF2, aF2adjF, aEF2Right);
BOPTools_Tools3D::PointNearEdge (aEF2Right, aF2adjF, aT, aPx2DNear, aPxNear);
//
// Normal to aF2adj
gp_Dir aDNF2;
Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2adj);
BOPTools_Tools3D::GetNormalToSurface (aS2, aPx2DNear.X(), aPx2DNear.Y(), aDNF2);
if (aF2adj.Orientation()==TopAbs_REVERSED){
aDNF2.Reverse();
}
//
// vector product
gp_Dir aDTN=aDNF1^aDNF2;
// Tangent for split
gp_Vec aTE;
BOPTools_Tools2D::TangentOnEdge(aT, aSpEF2, aTE);
gp_Dir aDTE(aTE);
Standard_Real aScPr;
aScPr=aDTN*aDTE;
TopAbs_Orientation anOr;
anOr=TopAbs_FORWARD;
if (aScPr<0.) {
anOr=TopAbs_REVERSED;
}
return anOr;
}
//=======================================================================
// function: GetSeams
// purpose:
//=======================================================================
void BOPTools_Tools3D::GetSeams (const TopoDS_Face& aF,
TopoDS_Edge& aSim1,
TopoDS_Edge& aSim2)
{
TopTools_ListOfShape aLS;
TopExp_Explorer anExpEdges (aF, TopAbs_EDGE);
for (; anExpEdges.More(); anExpEdges.Next()) {
const TopoDS_Edge& aE= TopoDS::Edge(anExpEdges.Current());
if (BRep_Tool::IsClosed(aE, aF)) {
aLS.Append(aE);
}
}
aSim1=TopoDS::Edge(aLS.First());
aSim2=TopoDS::Edge(aLS.Last ());
}
//=======================================================================
// function: GetSeam
// purpose:
//=======================================================================
void BOPTools_Tools3D::GetSeam (const TopoDS_Face& aF,
const TopoDS_Edge& aSim1,
TopoDS_Edge& aSim2)
{
TopExp_Explorer anExpEdges (aF, TopAbs_EDGE);
for (; anExpEdges.More(); anExpEdges.Next()) {
const TopoDS_Edge& aE= TopoDS::Edge(anExpEdges.Current());
if (BRep_Tool::IsClosed(aE, aF)) {
if (aE.IsSame(aSim1)) {
if (aE!=aSim1) {
aSim2=aE;
return;
}
}
}
}
}
//=======================================================================
//function : MinStepIn2d
//purpose :
//=======================================================================
Standard_Real BOPTools_Tools3D::MinStepIn2d()
{
Standard_Real dt=1.e-5;
return dt;
}
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRep_PointRepresentation.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_TFace.hxx>
#include <Poly_Triangulation.hxx>
#include <BRep_Builder.hxx>
static
Standard_Boolean HasGeometry(const TopoDS_Shape& aS);
static
void Add(const TopoDS_Shape& aS,
TopTools_IndexedMapOfShape& myShapes,
Standard_Boolean& bHasGeometry);
//=======================================================================
//function : IsEmptyShape
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools3D::IsEmptyShape(const TopoDS_Shape& aS)
{
Standard_Boolean bHasGeometry=Standard_False;
//
TopTools_IndexedMapOfShape myShapes;
//
Add(aS, myShapes, bHasGeometry);
return !bHasGeometry;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Add(const TopoDS_Shape& aS,
TopTools_IndexedMapOfShape& myShapes,
Standard_Boolean& bHasGeometry)
{
Standard_Integer anIndex;
//
if (bHasGeometry) {
return;
}
//
if (aS.IsNull()) {
return;
}
//
TopoDS_Shape aSx = aS;
//
anIndex=myShapes.FindIndex(aSx);
if (!anIndex) {
bHasGeometry=HasGeometry (aSx);
if (bHasGeometry) {
return;
}
//
TopoDS_Iterator anIt(aSx, Standard_False, Standard_False);
for(; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aSy=anIt.Value();
Add(aSy, myShapes, bHasGeometry);
//
if (bHasGeometry) {
return;
}
//
myShapes.Add(aSx);
}
}
}
//=======================================================================
//function : HasGeometry
//purpose :
//=======================================================================
Standard_Boolean HasGeometry(const TopoDS_Shape& aS)
{
Standard_Boolean bHasGeometry=Standard_True;
TopAbs_ShapeEnum aType= aS.ShapeType();
if (aType == TopAbs_VERTEX) {
Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(aS.TShape());
BRep_ListIteratorOfListOfPointRepresentation itrp(TV->Points());
while (itrp.More()) {
const Handle(BRep_PointRepresentation)& PR = itrp.Value();
if (PR->IsPointOnCurve()) {
return bHasGeometry;
}
else if (PR->IsPointOnCurveOnSurface()) {
return bHasGeometry;
}
else if (PR->IsPointOnSurface()) {
return bHasGeometry;
}
itrp.Next();
}
}
//
else if (aType == TopAbs_EDGE) {
Handle(BRep_TEdge) TE = Handle(BRep_TEdge)::DownCast(aS.TShape());
BRep_ListIteratorOfListOfCurveRepresentation itrc(TE->Curves());
while (itrc.More()) {
const Handle(BRep_CurveRepresentation)& CR = itrc.Value();
if (CR->IsCurve3D()) {
if (!CR->Curve3D().IsNull()) {
return bHasGeometry;
}
}
else if (CR->IsCurveOnSurface()) {
return bHasGeometry;
}
else if (CR->IsRegularity()) {
return bHasGeometry;
}
else if (!CR->Polygon3D().IsNull()) {
return bHasGeometry;
}
else if (CR->IsPolygonOnTriangulation()) {
return bHasGeometry;
}
else if (CR->IsPolygonOnSurface()) {
return bHasGeometry;
}
itrc.Next();
}
}
//
else if (aType == TopAbs_FACE) {
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(aS.TShape());
if (!TF->Surface().IsNull()) {
return bHasGeometry;
}
Handle(Poly_Triangulation) Tr = TF->Triangulation();
if (!Tr.IsNull()) {
return bHasGeometry;
}
}
return !bHasGeometry;
}
//=======================================================================
// function: InvertShape
// purpose:
//=======================================================================
void BOPTools_Tools3D::InvertShape(const TopoDS_Shape& aS,
TopoDS_Shape& aSInvert)
{
BRep_Builder aBB;
aSInvert=aS.EmptyCopied();
TopoDS_Iterator anIt(aS);
while (anIt.More()) {
aBB.Add(aSInvert, anIt.Value().Reversed());
anIt.Next();
}
}
//=======================================================================
// function: GetStatePartIN2D
// purpose:
//=======================================================================
TopAbs_State BOPTools_Tools3D::GetStatePartIN2D(const TopoDS_Edge& aSp,
const TopoDS_Edge& aEF1,
const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
IntTools_Context& aContext)
{
gp_Dir aDBF1, aDNF2;
TopAbs_State aStPF;
BOPTools_Tools3D::GetBiNormal (aSp, aF1, aDBF1);
BOPTools_Tools3D::GetNormalToFaceOnEdge (aSp, aF2, aDNF2);
Standard_Real aTolScPr, aScPr;
aTolScPr=1.e-7;
aScPr=aDBF1*aDNF2;
//XX 909/G2
BRepAdaptor_Surface aBAS1, aBAS2;
GeomAbs_SurfaceType aType1, aType2;
aBAS1.Initialize (aF1, Standard_False);
aBAS2.Initialize (aF2, Standard_False);
aType1=aBAS1.GetType();
aType2=aBAS2.GetType();
if (aType1==GeomAbs_BSplineSurface
||
aType2==GeomAbs_BSplineSurface) {
//aTolScPr=1.e-5;
aTolScPr=5.5e-5;
}
//XX
if (fabs(aScPr) < aTolScPr) {
BOPTools_Tools3D::GetPlane(aSp, aEF1, aF1, aF2, aStPF, aContext);
aScPr=1.; // >0.
if (aStPF==TopAbs_IN) {
aScPr=-1.; // <0.
}
}
aStPF=TopAbs_OUT;
if (aScPr<0.) {
aStPF=TopAbs_IN;
}
return aStPF;
}
// ===========================================================================================
// function: CheckSameDomainFaceInside
// purpose: Check if distance between several points of theFace1 and
// theFace2
// ===========================================================================================
Standard_Boolean BOPTools_Tools3D::CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
IntTools_Context& theContext)
{
Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.;
BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax);
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1);
Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1);
aTolerance += BRep_Tool::Tolerance(theFace2);
Standard_Integer nbpoints = 5;
Standard_Real adeltau = (umax - umin) / (nbpoints + 1);
Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1);
Standard_Real U = umin + adeltau;
Standard_Boolean bFoundON = Standard_False;
GeomAPI_ProjectPointOnSurf& aProjector = theContext.ProjPS(theFace2);
for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) {
Standard_Real V = vmin + adeltav;
for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) {
gp_Pnt2d aPoint(U,V);
if(theContext.IsPointInFace(theFace1, aPoint)) {
gp_Pnt aP3d = aSurface->Value(U, V);
aProjector.Perform(aP3d);
if(aProjector.IsDone()) {
Standard_Real U2 = 0., V2 = 0.;
aProjector.LowerDistanceParameters(U2, V2);
aPoint = gp_Pnt2d(U2, V2);
if(aProjector.LowerDistance() > aTolerance)
return Standard_False;
else if(theContext.IsPointInFace(theFace2, aPoint))
bFoundON = Standard_True;
}
}
}
}
return bFoundON;
}
// ===========================================================================================
// function: ComputeFaceState
// purpose:
// ===========================================================================================
Standard_Boolean BOPTools_Tools3D::ComputeFaceState(const TopoDS_Face& theFace,
const TopoDS_Solid& theRef,
IntTools_Context& theContext,
TopAbs_State& theState)
{
TopAbs_State aState = TopAbs_ON;
Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.;
BRepTools::UVBounds(theFace, umin, umax, vmin, vmax);
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace);
Standard_Real aTolerance = BRep_Tool::Tolerance(theFace);
Standard_Integer nbpoints = 5;
Standard_Real adeltau = (umax - umin) / (nbpoints + 1);
Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1);
Standard_Real U = umin + adeltau;
Standard_Boolean bFoundValidPoint = Standard_False;
Standard_Boolean bFoundInFacePoint = Standard_False;
BRepClass3d_SolidClassifier& aSolidClassifier = theContext.SolidClassifier(theRef);
Standard_Integer i = 0, j = 0;
for(i = 1; !bFoundValidPoint && (i <= nbpoints); i++, U+=adeltau) {
Standard_Real V = vmin + adeltav;
for(j = 1; !bFoundValidPoint && (j <= nbpoints); j++, V+=adeltav) {
gp_Pnt2d aPoint(U,V);
if(theContext.IsPointInFace(theFace, aPoint)) {
bFoundInFacePoint = Standard_True;
gp_Pnt aP3d = aSurface->Value(U, V);
aSolidClassifier.Perform(aP3d, aTolerance);
aState = aSolidClassifier.State();
if(aState != TopAbs_ON) {
if(!aSolidClassifier.Rejected()) {
TopoDS_Face aFace2 = aSolidClassifier.Face();
if(!aFace2.IsNull()) {
if(BOPTools_Tools3D::CheckSameDomainFaceInside(theFace, aFace2, theContext))
aState = TopAbs_ON;
else {
break;
}
}
}
}
}
}
}
if(!bFoundInFacePoint) {
U = (umin + umax) * 0.5;
nbpoints /= 2;
for(i = 1; !bFoundValidPoint && (i <= nbpoints); i++, U+=adeltau) {
Standard_Real V = (vmin + vmax) * 0.5;
for(j = 1; !bFoundValidPoint && (j <= nbpoints); j++, V+=adeltav) {
gp_Pnt2d aPoint(U,V);
if(theContext.IsPointInOnFace(theFace, aPoint)) {
bFoundInFacePoint = Standard_True;
gp_Pnt aP3d = aSurface->Value(U, V);
aSolidClassifier.Perform(aP3d, aTolerance);
aState = aSolidClassifier.State();
if(aState != TopAbs_ON) {
if(!aSolidClassifier.Rejected()) {
TopoDS_Face aFace2 = aSolidClassifier.Face();
if(!aFace2.IsNull()) {
GeomAPI_ProjectPointOnSurf& aProjector = theContext.ProjPS(aFace2);
aProjector.Perform(aP3d);
if(aProjector.IsDone()) {
Standard_Real U2 = 0., V2 = 0.;
aProjector.LowerDistanceParameters(U2, V2);
gp_Pnt2d aPoint2(U2, V2);
if(aProjector.LowerDistance() < aTolerance) {
if(theContext.IsPointInFace(aFace2, aPoint2))
aState = TopAbs_ON;
}
}
bFoundValidPoint = Standard_True;
break;
}
}
else {
bFoundInFacePoint = Standard_False;
}
}
}
}
}
}
if(!bFoundInFacePoint)
return Standard_False;
theState = aState;
return Standard_True;
}

View File

@@ -0,0 +1,348 @@
// File: BOPTools_Tools3D_2.cxx
// Created: Thu Jun 10 09:11:01 2004
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_Tools3D.ixx>
#include <math.h>
#include <gp_Dir.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Cone.hxx>
#include <TopAbs_Orientation.hxx>
#include <Geom_Surface.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <IntTools_Tools.hxx>
#include <BOPTools_Tools2D.hxx>
#include <Geom_Curve.hxx>
#include <gp_Vec.hxx>
static
Standard_Boolean AnalyticState(const TopoDS_Face& aF1,
const TopoDS_Face& aFx,
const gp_Pnt& aP,
const gp_Dir& aDNSx,
const Standard_Real aTolR,
TopAbs_State& aSt);
static
gp_Pnt ProjectedPoint (const gp_Pnt&,
const gp_Ax1&);
//=======================================================================
//function : TreatedAsAnalytic
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools3D::TreatedAsAnalytic(const TopoDS_Face& aFx,
const TopoDS_Edge& aSpE1,
const TopoDS_Face& aF1,
const Standard_Real aTolTangent,
const Standard_Real aTolR,
TopAbs_State& aSt,
IntTools_Context& )
{
Standard_Boolean bFlag, bIsAnalytic, bIsDirsCoinside;
Standard_Real aT1, aTb, aTe;
gp_Dir aDNSx, aDNS1;
gp_Pnt aP1;
//
bFlag=Standard_False;
//
bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aFx);
if (!bIsAnalytic) {
return bFlag;
}
bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aF1);
if (!bIsAnalytic) {
return bFlag;
}
//
Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpE1, aTb, aTe);
aT1=BOPTools_Tools2D::IntermediatePoint (aTb, aTe);
aC3D->D0(aT1, aP1);
//
BOPTools_Tools3D::GetNormalToFaceOnEdge(aSpE1, aF1, aT1, aDNS1);
BOPTools_Tools3D::GetNormalToFaceOnEdge(aSpE1, aFx, aT1, aDNSx);
//
bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNSx, aDNS1, aTolTangent);
if (!bIsDirsCoinside) {
return bFlag;
}
//
bFlag=AnalyticState(aF1, aFx, aP1, aDNSx, aTolR, aSt);
//
return bFlag;
}
//=======================================================================
//function : TreatedAsAnalytic
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools3D::TreatedAsAnalytic(const Standard_Real aTx,
const gp_Pnt& aPx,
const TopoDS_Edge& anEx,
const TopoDS_Face& aFx,
const TopoDS_Edge& anE1,
const TopoDS_Face& aF1,
const Standard_Real aTolTangent,
const Standard_Real aTolR,
TopAbs_State& aSt,
IntTools_Context& aContext)
{
Standard_Boolean bFlag, bIsAnalytic, bIsDirsCoinside;
Standard_Real aT1;
gp_Dir aDNSx, aDNS1;
//
bFlag=Standard_False;
//
bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aFx);
if (!bIsAnalytic) {
return bFlag;
}
bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aF1);
if (!bIsAnalytic) {
return bFlag;
}
//
BOPTools_Tools3D::GetNormalToFaceOnEdge(anEx, aFx, aTx, aDNSx);
aContext.ProjectPointOnEdge(aPx, anE1, aT1);
BOPTools_Tools3D::GetNormalToFaceOnEdge(anE1, aF1, aT1, aDNS1);
//
bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNSx, aDNS1, aTolTangent);
if (!bIsDirsCoinside) {
return bFlag;
}
//
bFlag=AnalyticState(aF1, aFx, aPx, aDNSx, aTolR, aSt);
//
return bFlag;
}
//=======================================================================
//function : AnalyticState
//purpose :
//=======================================================================
Standard_Boolean AnalyticState(const TopoDS_Face& aF1,
const TopoDS_Face& aFx,
const gp_Pnt& aP,
const gp_Dir& aDNSx,
const Standard_Real aTolR,
TopAbs_State& aSt)
{
Standard_Boolean bFlag;
Standard_Real aScPr;
Handle(Geom_Surface) aSF1, aSFx;
GeomAbs_SurfaceType aTypeF1, aTypeFx;
TopAbs_Orientation anOrFx;
gp_Dir aDNFx;
gp_Pnt aPOnAxis;
//
bFlag=Standard_False;
aSt=TopAbs_OUT;
//
aSF1=BRep_Tool::Surface(aF1);
GeomAdaptor_Surface aGASF1(aSF1);
aTypeF1=aGASF1.GetType();
//
aSFx=BRep_Tool::Surface(aFx);
GeomAdaptor_Surface aGASFx(aSFx);
aTypeFx=aGASFx.GetType();
//
aDNFx=aDNSx;
anOrFx=aFx.Orientation();
if (anOrFx==TopAbs_REVERSED){
aDNFx.Reverse();
}
//
// Plane/Cylinder
if (aTypeF1==GeomAbs_Plane && aTypeFx==GeomAbs_Cylinder) {
gp_Cylinder aCYx;
//
aCYx=aGASFx.Cylinder();
aPOnAxis=ProjectedPoint(aP, aCYx.Axis());
gp_Vec aVTC(aP, aPOnAxis);
gp_Dir aDTC(aVTC);
//
aScPr=aDNFx*aDTC;
if (aScPr>0.) {
aSt=TopAbs_IN;
}
bFlag=!bFlag;
//
}
//
// Cylinder/Plane
else if (aTypeF1==GeomAbs_Cylinder && aTypeFx==GeomAbs_Plane) {
gp_Cylinder aCY1;
//
aCY1=aGASF1.Cylinder();
aPOnAxis=ProjectedPoint(aP, aCY1.Axis());
gp_Vec aVTC(aP, aPOnAxis);
gp_Dir aDTC(aVTC);
//
aScPr=aDNFx*aDTC;
if (aScPr<0.) {
aSt=TopAbs_IN;
}
bFlag=!bFlag;
} //
//
// Plane/Cone
else if ( aTypeF1==GeomAbs_Plane && aTypeFx==GeomAbs_Cone) {
gp_Cone aCNx;
//
aCNx=aGASFx.Cone();
aPOnAxis=ProjectedPoint(aP, aCNx.Axis());
gp_Vec aVTC(aP, aPOnAxis);
gp_Dir aDTC(aVTC);
//
aScPr=aDNFx*aDTC;
if (aScPr>0.) {
aSt=TopAbs_IN;
}
bFlag=!bFlag;
}
// Cone/Plane
else if (aTypeF1==GeomAbs_Cone && aTypeFx==GeomAbs_Plane) {
gp_Cone aCN1;
//
aCN1=aGASF1.Cone();
aPOnAxis=ProjectedPoint(aP, aCN1.Axis());
gp_Vec aVTC(aP, aPOnAxis);
gp_Dir aDTC(aVTC);
//
aScPr=aDNFx*aDTC;
if (aScPr<0.) {
aSt=TopAbs_IN;
}
bFlag=!bFlag;
} //
//
// Cylinder(Cone)/Cylinder(Cone)
else if ((aTypeF1==GeomAbs_Cylinder || aTypeF1==GeomAbs_Cone) &&
(aTypeFx==GeomAbs_Cylinder || aTypeFx==GeomAbs_Cone)) {
//
Standard_Real aPr, aR1, aRx, aSemiAngle, aDist;
gp_Pnt aPOnAxis1, aPOnAxisx;
gp_Cylinder aCY1, aCYx;
gp_Cone aCN1, aCNx;
gp_Ax1 anAx1, anAxx;
//
// surface 1
if (aTypeF1==GeomAbs_Cylinder) {
aCY1=aGASF1.Cylinder();
anAx1=aCY1.Axis();
aR1=aCY1.Radius();
aPOnAxis1=ProjectedPoint(aP, anAx1);
}
else {
aCN1=aGASF1.Cone();
anAx1=aCN1.Axis();
aSemiAngle=aCN1.SemiAngle();
gp_Lin aLin(anAx1);
aDist=aLin.Distance(aP);
aR1=aDist/cos(aSemiAngle);
aPOnAxis1=ProjectedPoint(aP, anAx1);
}
// surface x
if (aTypeFx==GeomAbs_Cylinder) {
aCYx=aGASFx.Cylinder();
anAxx=aCYx.Axis();
aRx=aCYx.Radius();
aPOnAxisx=ProjectedPoint(aP, anAxx);
}
else {
aCNx=aGASFx.Cone();
anAxx=aCNx.Axis();
aSemiAngle=aCNx.SemiAngle();
gp_Lin aLin(anAxx);
aDist=aLin.Distance(aP);
aRx=aDist/cos(aSemiAngle);
aPOnAxisx=ProjectedPoint(aP, anAxx);
}
//
if (fabs(aRx-aR1) < aTolR) {
return bFlag;
}
//
gp_Vec aVTC1(aP, aPOnAxis1);
gp_Vec aVTCx(aP, aPOnAxisx);
gp_Dir aDTC1(aVTC1);
gp_Dir aDTCx(aVTCx);
//
aPr=aDTC1*aDTCx;
if (aPr < 0.) {
// opposite case
aScPr=aDNFx*aDTCx;
if (aScPr>0.) {
aSt=TopAbs_IN;
}
}
else {
// one inside other
aScPr=aDNFx*aDTC1;
if (aRx<aR1) {
if (aScPr>0.) {
aSt=TopAbs_IN;
}
}
else {
if (aScPr<0.) {
aSt=TopAbs_IN;
}
}
}
bFlag=!bFlag;
//
}
//
return bFlag;
}
//=======================================================================
//function : HasAnalyticSurfaceType
//purpose :
//=======================================================================
Standard_Boolean BOPTools_Tools3D::HasAnalyticSurfaceType(const TopoDS_Face& aF)
{
Standard_Boolean bFlag=Standard_False;
GeomAbs_SurfaceType aType;
//
Handle(Geom_Surface) aS;
//
aS=BRep_Tool::Surface(aF);
GeomAdaptor_Surface aGAS(aS);
aType=aGAS.GetType();
//
bFlag= (aType==GeomAbs_Plane ||
aType==GeomAbs_Cylinder ||
aType==GeomAbs_Cone ||
aType==GeomAbs_Sphere);
//
return bFlag;
}
//=======================================================================
//function :ProjectedPoint
//purpose :
//=======================================================================
gp_Pnt ProjectedPoint (const gp_Pnt& aP,
const gp_Ax1& anAx1)
{
Standard_Real aDist;
//
gp_Vec aVDirection(anAx1.Direction());
gp_Pnt anOrigin=anAx1.Location();
gp_Vec aV(anOrigin, aP);
aDist = aVDirection.Dot(aV);
//
gp_Pnt aPx= anOrigin.Translated(aDist*aVDirection);
return aPx;
}

View File

@@ -0,0 +1,43 @@
-- File: BOPTools_VEInterference.cdl
-- Created: Tue Nov 21 15:43:14 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class VEInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose:
-- class for storing info about an Verex/Edge interference
---
is
Create
returns VEInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1, anIndex2: Integer from Standard;
aT: Real from Standard)
returns VEInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
--- aT - values of parameter on the edge
---
SetParameter (me:out; aT: Real from Standard);
---Purpose:
--- Modifier
---
Parameter (me)
returns Real from Standard;
---Purpose:
--- Selector
---
fields
myParameter: Real from Standard;
end VEInterference;

View File

@@ -0,0 +1,46 @@
// File: BOPTools_VEInterference.cxx
// Created: Tue Nov 21 15:43:57 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_VEInterference.ixx>
//=======================================================================
//function : BOPTools_VEInterference
//purpose :
//=======================================================================
BOPTools_VEInterference::BOPTools_VEInterference()
:
BOPTools_ShapeShapeInterference(0,0)
{}
//=======================================================================
//function : BOPTools_ESInterference
//purpose :
//=======================================================================
BOPTools_VEInterference::BOPTools_VEInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2,
const Standard_Real aT)
:
BOPTools_ShapeShapeInterference(anIndex1,anIndex2),
myParameter(aT)
{}
//=======================================================================
//function : SetParameter
//purpose :
//=======================================================================
void BOPTools_VEInterference::SetParameter (const Standard_Real aT)
{
myParameter=aT;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real BOPTools_VEInterference::Parameter ()const
{
return myParameter;
}

View File

@@ -0,0 +1,44 @@
-- File: BOPTools_VSInterference.cdl
-- Created: Tue Nov 21 15:38:48 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class VSInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose:
-- Class for storing info about an Verex/Face interference
---
is
Create
returns VSInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1: Integer from Standard;
anIndex2: Integer from Standard;
U: Real from Standard;
V: Real from Standard)
returns VSInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
--- U, V - values of parameters on the surface
---
SetUV (me:out; U, V: Real from Standard);
---Purpose:
--- Modifier
---
UV (me; U:out Real from Standard;
V:out Real from Standard);
---Purpose:
--- Selector
---
fields
myU:Real from Standard;
myV:Real from Standard;
end VSInterference;

View File

@@ -0,0 +1,51 @@
// File: BOPTools_VSInterference.cxx
// Created: Tue Nov 21 15:39:57 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_VSInterference.ixx>
//=======================================================================
//function : BOPTools_VSInterference
//purpose :
//=======================================================================
BOPTools_VSInterference::BOPTools_VSInterference()
:
BOPTools_ShapeShapeInterference(0,0)
{}
//=======================================================================
//function : BOPTools_VSInterference
//purpose :
//=======================================================================
BOPTools_VSInterference::BOPTools_VSInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2,
const Standard_Real U,
const Standard_Real V)
:
BOPTools_ShapeShapeInterference(anIndex1,anIndex2),
myU(U),
myV(V)
{}
//=======================================================================
//function : SetUV
//purpose :
//=======================================================================
void BOPTools_VSInterference::SetUV (const Standard_Real U,
const Standard_Real V)
{
myU=U;
myV=V;
}
//=======================================================================
//function : UV
//purpose :
//=======================================================================
void BOPTools_VSInterference::UV (Standard_Real& U, Standard_Real& V) const
{
U=myU;
V=myV;
}

View File

@@ -0,0 +1,28 @@
-- File: BOPTools_VVInterference.cdl
-- Created: Tue Nov 21 15:44:47 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class VVInterference from BOPTools
inherits ShapeShapeInterference from BOPTools
---Purpose: class for storing an Verex/Vertex
--- interference
is
Create
returns VVInterference from BOPTools;
---Purpose:
--- Empty constructor
---
Create (anIndex1, anIndex2: Integer from Standard)
returns VVInterference from BOPTools;
---Purpose:
--- Constructor
--- anIndex1,
--- anIndex2 see BOPTools_ShapeShapeInterference for details
---
end VVInterference;

View File

@@ -0,0 +1,26 @@
// File: BOPTools_VVInterference.cxx
// Created: Tue Nov 21 15:45:28 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_VVInterference.ixx>
//=======================================================================
//function : BOPTools_VVInterference
//purpose :
//=======================================================================
BOPTools_VVInterference::BOPTools_VVInterference()
:
BOPTools_ShapeShapeInterference(0,0)
{}
//=======================================================================
//function : BOPTools_VVInterference
//purpose :
//=======================================================================
BOPTools_VVInterference::BOPTools_VVInterference
(const Standard_Integer anIndex1,
const Standard_Integer anIndex2)
:
BOPTools_ShapeShapeInterference(anIndex1,anIndex2)
{}

View File

@@ -0,0 +1,46 @@
-- File: BOPTools_WireStateFiller.cdl
-- Created: Mon Feb 4 10:16:43 2002
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2002
class WireStateFiller from BOPTools inherits StateFiller from BOPTools
---Purpose:
-- class to compute states (3D) for the edges (and theirs
--- split parts), vertices, wires
---
uses
PaveFiller from BOPTools
--raises
is
Create (aFiller: PaveFiller from BOPTools)
returns WireStateFiller from BOPTools;
---Purpose:
--- Constructor
---
Do(me:out)
is redefined;
---Purpose:
--- Launch the Filler
---
DoWires (me:out;
iRank: Integer from Standard)
is private;
---Purpose:
--- Internal usage
---
DoWireSolid (me:out;
iRank: Integer from Standard)
is private;
---Purpose:
--- Internal usage
---
--fields
end WireStateFiller;

View File

@@ -0,0 +1,469 @@
// File: BOPTools_WireStateFiller.cxx
// Created: Mon Feb 4 10:18:15 2002
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTools_WireStateFiller.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BRep_Tool.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
#include <BooleanOperations_StateOfShape.hxx>
#include <BOPTools_SplitShapesPool.hxx>
#include <BOPTools_CommonBlockPool.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_InterferencePool.hxx>
//=======================================================================
// function: BOPTools_WireStateFiller::BOPTools_WireStateFiller
// purpose:
//=======================================================================
BOPTools_WireStateFiller::BOPTools_WireStateFiller(const BOPTools_PaveFiller& aFiller)
:
BOPTools_StateFiller(aFiller)
{
}
//=======================================================================
// function: Do
// purpose:
//=======================================================================
void BOPTools_WireStateFiller::Do()
{
TopAbs_ShapeEnum aT1, aT2;
aT1=(myDS->Object()).ShapeType();
aT2=(myDS->Tool()).ShapeType();
myIsDone=Standard_True;
if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){
DoWires(1);
DoWires(2);
}
else if (aT1==TopAbs_WIRE && aT2==TopAbs_SHELL){
DoWires(1);
}
else if (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL){
DoWires(2);
}
else if (aT1==TopAbs_WIRE && aT2==TopAbs_SOLID){
DoWireSolid(1);
}
else if (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID){
DoWireSolid(2);
}
else {
myIsDone=!myIsDone;
}
}
//=======================================================================
// function: DoWires
// purpose:
//=======================================================================
void BOPTools_WireStateFiller::DoWires (const Standard_Integer iRankObj)
{
const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool();
//
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj);
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool();
//
Standard_Integer i, aNbPaveBlocks, nSp, aNbE, nE;
BooleanOperations_StateOfShape aSt;
BOPTools_ListIteratorOfListOfPaveBlock anItPB;
BOPTools_ListIteratorOfListOfCommonBlock anItCB;
TopTools_IndexedMapOfShape aEM;
//
TopExp::MapShapes(anObj, TopAbs_EDGE, aEM);
aNbE=aEM.Extent();
//
// 1
for (i=1; i<=aNbE; i++) {
const TopoDS_Edge& aE=TopoDS::Edge(aEM(i));
nE=aDSMap.FindFromKey(aE);
//
if (BRep_Tool::Degenerated(aE)){
continue;
}
//
const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE));
//
anItCB.Initialize(aLCB);
for (; anItCB.More(); anItCB.Next()) {
BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE);
nSp=aPB.Edge();
myDS->SetState(nSp, BooleanOperations_ON);
}
}
//
// 2
for (i=1; i<=aNbE; i++) {
const TopoDS_Edge& aE=TopoDS::Edge(aEM(i));
nE=aDSMap.FindFromKey(aE);
//
if (BRep_Tool::Degenerated(aE)){
continue;
}
//
const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(myDS->RefEdge(nE));
//
aNbPaveBlocks=aLPB.Extent();
if (!aNbPaveBlocks) {
myDS->SetState(nE, BooleanOperations_OUT);
continue;
}
//
anItPB.Initialize(aLPB);
for (; anItPB.More(); anItPB.Next()) {
const BOPTools_PaveBlock& aPB=anItPB.Value();
nSp=aPB.Edge();
aSt=myDS-> GetState(nSp);
if (aSt!=BooleanOperations_ON) {
myDS->SetState(nSp, BooleanOperations_OUT);
}
}
}
}
//=======================================================================
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <BRep_Builder.hxx>
#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
#include <BOPTools_SplitShapesPool.hxx>
#include <BOPTools_CommonBlockPool.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_IndexedDataMapOfShapeWithState.hxx>
#include <BOPTools_StateFiller.hxx>
static
void PropagateState(const TopoDS_Shape& aS,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
TopTools_IndexedMapOfShape& aProcessedShapes);
static
Standard_Boolean HasConnexity(const TopoDS_Shape& aS,
const BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
BooleanOperations_StateOfShape& aState);
//=======================================================================
// function: DoWireSolid
// purpose:
//=======================================================================
void BOPTools_WireStateFiller::DoWireSolid (const Standard_Integer iRankObj)
{
const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool();
const TopoDS_Shape& aTool=(iRankObj==1) ? myDS->Tool() : myDS->Object();
//
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj);
const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool();
const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool();
//
Standard_Integer i, aNb, nE, aNbPB;
BooleanOperations_StateOfShape aState;
TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes;
TopTools_IndexedDataMapOfShapeListOfShape aM, aMVE;
//
// aM Map
TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM);
// VE Map
TopExp::MapShapesAndAncestors (anObj, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
//
// 1.2. Edges that have Split parts
TopExp::MapShapes(anObj, TopAbs_EDGE, aEM);
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aEM(i);
nE=aDSMap.FindFromKey(aE);
const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(myDS->RefEdge(nE));
aNbPB=aLPB.Extent();
//
if (!aNbPB) {
continue;
}
//
if (aNbPB==1) {
const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE));
if (!aLCB.Extent()) {
const BOPTools_PaveBlock& aPB=aLPB.First();
Standard_Integer nEB=aPB.Edge();
if (nEB==aPB.OriginalEdge()) {
Standard_Boolean bHasInterference=Standard_False;// Wng in Gcc 3.0
Standard_Integer j, aNbSuc, nV;
aNbSuc=myDS->NumberOfSuccessors(nEB);
for (j=1; j<=aNbSuc; j++) {
nV=myDS->GetSuccessor(nE, j);
bHasInterference=myIntrPool->HasInterference(nV);
if (bHasInterference) {
break;
}
}
if (!bHasInterference) {
continue;
}
}
}
}
anIntersectedShapes.Add(aE);
}// for (i=1; i<=aNb; i++)
//
// 1.3. Write Intersected state for anIntersectedShapes to the DS
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, BooleanOperations_INTERSECTED);
}
//
// 2. aNonIntersectedShapes
//
aNb=aM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aM.FindKey(i);
if (!anIntersectedShapes.Contains(aS)) {
aNonIntersectedShapes.Add(aS);
}
}
//
// 2.1. Processing of Non-intersected shapes
BRep_Builder BB;
TopoDS_Compound aCompound;
BB.MakeCompound(aCompound);
aNb=aNonIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aNonIntersectedShapes(i);
BB.Add(aCompound, aS);
}
//
TopTools_IndexedMapOfShape aProcessedShapes;
BOPTools_IndexedDataMapOfShapeWithState aSWS;
Standard_Boolean bHasConnexity;
//
aEM.Clear();
TopExp::MapShapes(aCompound, TopAbs_EDGE, aEM);
aNb=aEM.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aEM(i);
if (!aProcessedShapes.Contains(aS)) {
bHasConnexity=HasConnexity(aS, aSWS, aMVE, aState);
if (!bHasConnexity) {
aState=BOPTools_StateFiller::ClassifyShapeByRef (aS, aTool);
}
aSWS.Add(aS, aState);
aProcessedShapes.Add(aS);
PropagateState(aS, aState, myDS, iRankObj, aSWS, aProcessedShapes);
}
}
//
// 2.2. Write Stats for Non-intersected Shapes to the DS
aNb=aSWS.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aSWS.FindKey(i);
aState=aSWS.FindFromIndex(i);
nE=aDSMap.FindFromKey(aS);
myDS->SetState(nE, aState);
}
//---------------------------------------------------
//
// 3. Intersected Edges' Processing
//
//---------------------------------------------------
Standard_Integer nSp, aNBVertices, nV1, nV2;
BooleanOperations_StateOfShape aStV1, aStV2;
aNb=anIntersectedShapes.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=anIntersectedShapes(i);
if (aS.ShapeType()==TopAbs_EDGE) {
nE=aDSMap.FindFromKey(aS);
//
// 3.1. On Parts Processing
const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
for (; anItCB.More(); anItCB.Next()) {
const BOPTools_CommonBlock& aCB=anItCB.Value();
BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB;
BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE);
nSp=aPB.Edge();
myDS->SetState(nSp, BooleanOperations_ON);
}
//
// 3.2. IN, OUT Parts Processing
const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE));
BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits);
for (; anItPB.More(); anItPB.Next()) {
const BOPTools_PaveBlock& aPB=anItPB.Value();
nSp=aPB.Edge();
const TopoDS_Shape& aSplit=myDS->Shape(nSp);
aState=myDS->GetState(nSp);
if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){
aNBVertices=myDS->NumberOfSuccessors(nE);
if (aNBVertices==2) {
nV1=myDS->GetSuccessor(nSp, 1);
aStV1=myDS->GetState(nV1);
nV2=myDS->GetSuccessor(nSp, 2);
aStV2=myDS->GetState(nV2);
if ((aStV1==BooleanOperations_IN || aStV1==BooleanOperations_OUT)
&& (aStV2==BooleanOperations_ON)) {
myDS->SetState(nSp, aStV1);
}
else if ((aStV2==BooleanOperations_IN || aStV2==BooleanOperations_OUT)
&& (aStV1==BooleanOperations_ON)) {
myDS->SetState(nSp, aStV2);
}
else {
aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool);
myDS->SetState(nSp, aState);
if (aStV1==BooleanOperations_UNKNOWN) {
myDS->SetState(nV1, aState);
}
if (aStV2==BooleanOperations_UNKNOWN) {
myDS->SetState(nV2, aState);
}
}
}// if (aNBVertices==2)
else {
aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool);
myDS->SetState(nSp, aState);
}
}// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED)
}//for (; anItPB.More(); anItPB.Next())
}// if (aS.ShapeType()==TopAbs_EDGE)
}// next "Intersected" Edge
}
//=======================================================================
// function: HasConnexity
// purpose:
//=======================================================================
Standard_Boolean HasConnexity(const TopoDS_Shape& aS,
const BOPTools_IndexedDataMapOfShapeWithState& aSWS,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
BooleanOperations_StateOfShape& aState)
{
TopAbs_ShapeEnum aType;
BooleanOperations_StateOfShape aSt;
aType=aS.ShapeType();
if (aType!=TopAbs_EDGE) {
Standard_Integer i, aNb;
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(aS, TopAbs_EDGE, aME);
aNb=aME.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aME(i);
if (aSWS.Contains(aE)){
aSt=aSWS.FindFromKey(aE);
aState=aSt;
return Standard_True;
}
}
}
else {
TopExp_Explorer anExp (aS, TopAbs_VERTEX);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aV=anExp.Current();
if (aMVE.Contains(aV)) {
const TopTools_ListOfShape& anEdgesList=aMVE.FindFromKey(aV);
TopTools_ListIteratorOfListOfShape anIt(anEdgesList);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aEx=anIt.Value();
if (aSWS.Contains(aEx)) {
aSt=aSWS.FindFromKey(aEx);
aState=aSt;
return Standard_True;
}
}
}
}
}
aState=BooleanOperations_UNKNOWN;
return Standard_False;
}
//=======================================================================
// function: PropagateState
// purpose:
//=======================================================================
void PropagateState(const TopoDS_Shape& aSS,
const BooleanOperations_StateOfShape aState,
BooleanOperations_ShapesDataStructure* pDS,
const Standard_Integer iRank,
BOPTools_IndexedDataMapOfShapeWithState& aSWS,
TopTools_IndexedMapOfShape& aProcessedShapes)
{
TopAbs_ShapeEnum aSubType;
aSubType=BOPTools_StateFiller::SubType(aSS);
if (aSubType==TopAbs_SHAPE) {
return;
}
const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap= pDS->ShapeIndexMap(iRank);
TopTools_IndexedMapOfShape aSubMap;
TopExp::MapShapes(aSS, aSubType, aSubMap);
Standard_Integer i, aNb, nV;
aNb=aSubMap.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aSubMap(i);
if (!aProcessedShapes.Contains(aS)) {
if (aSubType==TopAbs_VERTEX) {
nV=aDSMap.FindFromKey(aS);
BooleanOperations_StateOfShape aSt=pDS->GetState(nV);
if (aSt!=BooleanOperations_UNKNOWN){
aProcessedShapes.Add(aS);
continue;
}
}
aSWS.Add(aS, aState);
aProcessedShapes.Add(aS);
PropagateState (aS, aState, pDS, iRank, aSWS, aProcessedShapes);
}
}
}

6
src/BOPTools/FILES Executable file
View File

@@ -0,0 +1,6 @@
BOPTools_Tools3D_1.cxx
BOPTools_Tools3D_2.cxx
BOPTools_PaveFiller_1.cxx
BOPTools_PaveFiller_2.cxx
BOPTools_PaveFiller_3.cxx
BOPTools_PaveFiller_4.cxx