mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-08-31 07:17:46 +08:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
Executable
+104
@@ -0,0 +1,104 @@
|
||||
-- File: BRepAlgoAPI.cdl
|
||||
-- Created: Tue Jul 6 17:29:03 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- modified by Peter KURNEV Tue Mar 5 14:01:51 2002
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
package BRepAlgoAPI
|
||||
|
||||
---Purpose: The BRepAlgoAPI package provides a full range of
|
||||
-- services to perform Boolean Operations on arguments (shapes
|
||||
-- that are defined in the BRep data structures). The
|
||||
-- implemented new algorithm is intended to replace the Old
|
||||
-- Boolean Operations algorithm in the BRepAlgoAPI package.
|
||||
-- The New algorithm is free of a large number of weak spots
|
||||
-- and limitations characteristics of the Old algorithm.
|
||||
-- It is more powerful and flexible.
|
||||
-- It can process arguments the Old algorithm was not adapted for.
|
||||
-- The new algorithm is based on a new approach to operations
|
||||
-- with interfered shapes. The advantages of the new algorithm
|
||||
-- include an ability to treat arguments that have shared
|
||||
-- entities. It can properly process two solids with shared
|
||||
-- faces (in terms of TopoDS_Shape::IsSame()), two
|
||||
-- faces that have shared edges and so on. Now the New Boolean
|
||||
-- Operation algorithm can treat a wide range of shapes while the
|
||||
-- Old one fails on them.
|
||||
-- A generalization of treatment of same-domain faces
|
||||
-- was included into the New algorithm. Two faces that share
|
||||
-- the same domain are processed according to the common rule
|
||||
-- even if the underlying surfaces are of different types. This
|
||||
-- allows to execute Boolean Operations properly for the same
|
||||
-- domain faces. It also concerns solids and shells that have the
|
||||
-- same domain faces. It is quite frequent when two faces share
|
||||
-- the same domain. And the New algorithm successfully copes
|
||||
-- with it in contrast to the Old one.
|
||||
-- Generalization oftreatment of degenerated edges
|
||||
-- gives a possibility to process them properly. Although there
|
||||
-- are still some difficulties with processing faces in areas close
|
||||
-- to degenerated edges.
|
||||
-- Now the processing of arguments having internal sub-shapes gives
|
||||
-- a correct result. Internal sub-shape means a sub-shape of a
|
||||
-- shape with the orientation TopAbs_INTERNAL and is located
|
||||
-- inside the shape boundaries. The New algorithm processes faces
|
||||
-- with internal edges properly. The new API of the Boolean
|
||||
-- Operations (in addition to the old API) allows to reuse the
|
||||
-- already computed interference between arguments in different
|
||||
-- types of Boolean Operations. It is possible to use once computed
|
||||
-- interference in FUSE, CUT and COMMON operations on given
|
||||
-- arguments. So there is no need to re-compute the interference
|
||||
-- between the arguments. It allows to reduce time for more than one
|
||||
-- operation on given arguments.
|
||||
-- The shape type of a Boolean Operation result and types of the arguments:
|
||||
-- - For arguments with the same shape type (e.g. SOLID /
|
||||
-- SOLID) the type of the resulting shape will be a
|
||||
-- COMPOUND, containing shapes of this type;
|
||||
-- - For arguments with different shape types (e.g.
|
||||
-- SHELL / SOLID) the type of the resulting shape will be a
|
||||
-- COMPOUND, containing shapes of the type that is the same as
|
||||
-- that of the low type of the argument. Example: For
|
||||
-- SHELL/SOLID the result is a COMPOUND of SHELLs.
|
||||
-- - For arguments with different shape types some of
|
||||
-- Boolean Operations can not be done using the default
|
||||
-- implementation, because of a non-manifold type of the
|
||||
-- result. Example: the FUSE operation for SHELL and SOLID
|
||||
-- can not be done, but the CUT operation can be done, where
|
||||
-- SHELL is the object and SOLID is the tool.
|
||||
-- It is possible to perform Boolean Operations on arguments
|
||||
-- of the COMPOUND shape type. In this case each compound must not
|
||||
-- be heterogeneous, i.e. it must contain equidimensional shapes
|
||||
-- (EDGEs or/and WIREs, FACEs or/and SHELLs, SOLIDs). SOLIDs
|
||||
-- inside the COMPOUND must not contact (intersect or touch)
|
||||
-- each other. The same condition is true for SHELLs or FACEs,
|
||||
-- WIREs or EDGEs.
|
||||
-- It does not support Boolean Operations for COMPSOLID type of shape.
|
||||
|
||||
uses
|
||||
TopTools,
|
||||
TopoDS,
|
||||
gp,
|
||||
Geom,
|
||||
Geom2d,
|
||||
BOP,
|
||||
BOPTools,
|
||||
BRepBuilderAPI
|
||||
is
|
||||
|
||||
deferred class BooleanOperation;
|
||||
---Purpose: Root class for boolean operations.
|
||||
|
||||
class Fuse;
|
||||
---Purpose: Perform the boolean operation FUSE.
|
||||
---
|
||||
class Common;
|
||||
---Purpose: Perform the boolean operation COMMON.
|
||||
---
|
||||
class Cut;
|
||||
---Purpose: Perform the boolean operation CUT.
|
||||
---
|
||||
class Section;
|
||||
---Purpose: Perform the operation SECTION.
|
||||
---
|
||||
|
||||
end BRepAlgoAPI;
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
-- File: BRepAlgoAPI_BooleanOperation.cdl
|
||||
-- Created: Thu Oct 14 18:14:43 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- modified by Peter KURNEV Tue Mar 5 14:01:51 2002
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
deferred class BooleanOperation from BRepAlgoAPI
|
||||
inherits MakeShape from BRepBuilderAPI
|
||||
|
||||
---Purpose: The abstract class BooleanOperation is the root
|
||||
-- class of Boolean Operations (see Overview).
|
||||
-- Boolean Operations algorithm is divided onto two parts.
|
||||
-- - The first one is computing interference between arguments.
|
||||
-- - The second one is building the result of operation.
|
||||
-- The BooleanOperation class provides execution of both parts
|
||||
-- of the Boolean Operations algorithm. The second part
|
||||
-- (building the result) depends on given type of the Boolean
|
||||
-- Operation (see Constructor).
|
||||
|
||||
uses
|
||||
|
||||
Shape from TopoDS,
|
||||
ListOfShape from TopTools,
|
||||
Operation from BOP,
|
||||
PBuilder from BOP,
|
||||
HistoryCollector from BOP,
|
||||
PDSFiller from BOPTools,
|
||||
DSFiller from BOPTools,
|
||||
DataMapOfIntegerListOfShape from TopTools,
|
||||
DataMapOfIntegerShape from TopTools,
|
||||
DataMapOfShapeShape from TopTools
|
||||
|
||||
is
|
||||
|
||||
Initialize (S1 :Shape from TopoDS;
|
||||
S2 :Shape from TopoDS;
|
||||
anOperation:Operation from BOP);
|
||||
---Purpose: Prepares the operations for S1 and S2.
|
||||
|
||||
Initialize (S1 :Shape from TopoDS;
|
||||
S2 :Shape from TopoDS;
|
||||
aDSF :DSFiller from BOPTools;
|
||||
anOperation:Operation from BOP);
|
||||
---Purpose: Prepares the operations for S1 and S2.
|
||||
|
||||
SetOperation (me:out;
|
||||
anOp: Operation from BOP);
|
||||
---Purpose: Sets the type of Boolean operation to perform
|
||||
--- It can be BOP_SECTION
|
||||
--- BOP_COMMON
|
||||
--- BOP_FUSE
|
||||
--- BOP_CUT
|
||||
--- BOP_CUT21
|
||||
---
|
||||
|
||||
|
||||
Build (me:out)
|
||||
is redefined virtual;
|
||||
---Purpose: Provides the algorithm of Boolean Operations
|
||||
-- - Filling interference Data Structure (if it is necessary)
|
||||
-- - Building the result of the operation.
|
||||
|
||||
Shape1(me)
|
||||
returns Shape from TopoDS
|
||||
is static;
|
||||
---Purpose: Returns the first shape involved in this Boolean operation.
|
||||
---C++: return const &
|
||||
|
||||
Shape2(me)
|
||||
returns Shape from TopoDS
|
||||
is static;
|
||||
---Purpose: Returns the second shape involved in this Boolean operation.
|
||||
---C++: return const &
|
||||
|
||||
Operation (me)
|
||||
returns Operation from BOP;
|
||||
---Purpose: Returns the type of Boolean Operation that has been performed.
|
||||
|
||||
FuseEdges(me) returns Boolean from Standard;
|
||||
---Purpose: Returns the flag of edge refining
|
||||
|
||||
RefineEdges(me:out);
|
||||
---Purpose: Fuse C1 edges
|
||||
|
||||
PrepareFiller(me:out)
|
||||
returns Boolean from Standard
|
||||
is protected;
|
||||
|
||||
|
||||
---Category: Querying
|
||||
BuilderCanWork(me)
|
||||
returns Boolean from Standard;
|
||||
|
||||
ErrorStatus(me)
|
||||
returns Integer from Standard;
|
||||
---Purpose: Returns the error status of operation.
|
||||
--- 0 - Ok
|
||||
--- 1 - The Object is created but Nothing is Done
|
||||
--- 2 - Null source shapes is not allowed
|
||||
--- 3 - Check types of the arguments
|
||||
--- 4 - Can not allocate memory for the DSFiller
|
||||
--- 5 - The Builder can not work with such types of arguments
|
||||
--- 6 - Unknown operation is not allowed
|
||||
--- 7 - Can not allocate memory for the Builder
|
||||
-- > 100 - See the Builder's ErrorStatus
|
||||
|
||||
Modified (me: in out;
|
||||
aS : Shape from TopoDS)
|
||||
returns ListOfShape from TopTools
|
||||
is redefined virtual;
|
||||
---Purpose: Returns the list of shapes modified from the shape <S>.
|
||||
---C++: return const &
|
||||
|
||||
IsDeleted (me: in out;
|
||||
aS : Shape from TopoDS)
|
||||
returns Boolean
|
||||
is redefined virtual;
|
||||
---Purpose: Returns true if the shape S has been deleted. The
|
||||
-- result shape of the operation does not contain the shape S.
|
||||
|
||||
Modified2 (me: in out;
|
||||
aS : Shape from TopoDS)
|
||||
returns ListOfShape from TopTools
|
||||
is virtual;
|
||||
---Purpose: Returns the list of shapes modified from the shape <S>.
|
||||
--- For use in BRepNaming.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
|
||||
Generated (me: in out; S : Shape from TopoDS)
|
||||
returns ListOfShape from TopTools
|
||||
is redefined virtual;
|
||||
---Purpose: Returns the list of shapes generated from the shape <S>.
|
||||
--- For use in BRepNaming.
|
||||
---C++: return const &
|
||||
|
||||
HasModified (me)
|
||||
returns Boolean from Standard
|
||||
is virtual;
|
||||
---Purpose: Returns true if there is at least one modified shape.
|
||||
--- For use in BRepNaming.
|
||||
|
||||
HasGenerated (me)
|
||||
returns Boolean from Standard
|
||||
is virtual;
|
||||
---Purpose: Returns true if there is at least one generated shape.
|
||||
--- For use in BRepNaming.
|
||||
|
||||
HasDeleted (me)
|
||||
returns Boolean from Standard
|
||||
is virtual;
|
||||
---Purpose: Returns true if there is at least one deleted shape.
|
||||
--- For use in BRepNaming.
|
||||
|
||||
Destroy (me: in out);
|
||||
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_BooleanOperation(){Destroy();}"
|
||||
|
||||
--modified by NIZNHY-PKV Wed Mar 20 10:29:30 2002 f
|
||||
|
||||
SectionEdges (me: in out)
|
||||
returns ListOfShape from TopTools;
|
||||
--- Purpose: Returns a list of section edges.
|
||||
-- The edges represent the result of intersection between arguments of
|
||||
-- Boolean Operation. They are computed during operation execution.
|
||||
---C++: return const &
|
||||
--modified by NIZNHY-PKV Wed Mar 20 10:29:35 2002 t
|
||||
|
||||
RefinedList (me: in out; theL : ListOfShape from TopTools)
|
||||
returns ListOfShape from TopTools
|
||||
is private;
|
||||
---Purpose: Returns the list of shapes generated from the shape <S>.
|
||||
--- For use in BRepNaming.
|
||||
---C++: return const &
|
||||
|
||||
fields
|
||||
myS1 : Shape from TopoDS is protected;
|
||||
myS2 : Shape from TopoDS is protected;
|
||||
myBuilderCanWork : Boolean from Standard is protected;
|
||||
myOperation : Operation from BOP is protected;
|
||||
myErrorStatus : Integer from Standard is protected;
|
||||
myDSFiller : PDSFiller from BOPTools is protected;
|
||||
myBuilder : PBuilder from BOP is protected;
|
||||
|
||||
myHistory : HistoryCollector from BOP is protected;
|
||||
|
||||
myEntryType : Integer from Standard;
|
||||
|
||||
-- for edge refiner
|
||||
myFuseEdges : Boolean from Standard ;
|
||||
myModifFaces : DataMapOfShapeShape from TopTools;
|
||||
myEdgeMap : DataMapOfShapeShape from TopTools;
|
||||
|
||||
end BooleanOperation;
|
||||
|
||||
+641
@@ -0,0 +1,641 @@
|
||||
// File: BRepAlgoAPI_BooleanOperation.cxx
|
||||
// Created: Fri Oct 15 11:35:03 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
#include <BRepAlgoAPI_BooleanOperation.ixx>
|
||||
|
||||
#include <BOP_Builder.hxx>
|
||||
#include <BOP_Section.hxx>
|
||||
#include <BOP_ShellShell.hxx>
|
||||
#include <BOP_SolidSolid.hxx>
|
||||
#include <BOP_ShellSolid.hxx>
|
||||
#include <BOP_WireWire.hxx>
|
||||
#include <BOP_WireShell.hxx>
|
||||
#include <BOP_WireSolid.hxx>
|
||||
#include <BOPTools_DSFiller.hxx>
|
||||
#include <BOPTools_Tools3D.hxx>
|
||||
#include <BOP_EmptyBuilder.hxx>
|
||||
|
||||
#include <BOP_WireSolidHistoryCollector.hxx>
|
||||
#include <BOP_ShellSolidHistoryCollector.hxx>
|
||||
#include <BOP_SolidSolidHistoryCollector.hxx>
|
||||
#include <BOP_SectionHistoryCollector.hxx>
|
||||
#include <BRepLib_FuseEdges.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theShape1,
|
||||
const TopoDS_Shape& theShape2,
|
||||
const BOP_Operation theOperation);
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_BooleanOperation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1,
|
||||
const TopoDS_Shape& aS2,
|
||||
const BOP_Operation anOp)
|
||||
:
|
||||
myS1(aS1),
|
||||
myS2(aS2),
|
||||
myBuilderCanWork(Standard_False),
|
||||
myOperation(anOp),
|
||||
myErrorStatus(1),
|
||||
myDSFiller(NULL),
|
||||
myBuilder(NULL),
|
||||
myEntryType(1),
|
||||
myFuseEdges(Standard_False)
|
||||
{
|
||||
}
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_BooleanOperation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1,
|
||||
const TopoDS_Shape& aS2,
|
||||
const BOPTools_DSFiller& aDSFiller,
|
||||
const BOP_Operation anOp)
|
||||
:
|
||||
myS1(aS1),
|
||||
myS2(aS2),
|
||||
myBuilderCanWork(Standard_False),
|
||||
myOperation(anOp),
|
||||
myErrorStatus(1),
|
||||
myDSFiller(NULL),
|
||||
myBuilder(NULL),
|
||||
myEntryType(0),
|
||||
myFuseEdges(Standard_False)
|
||||
{
|
||||
if ((Standard_Address) &aDSFiller!=NULL) {
|
||||
myDSFiller=(BOPTools_PDSFiller)&aDSFiller;
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_BooleanOperation::Destroy()
|
||||
{
|
||||
if (myBuilder!=NULL) {
|
||||
delete myBuilder;
|
||||
myBuilder=NULL;
|
||||
}
|
||||
if (myDSFiller!=NULL && myEntryType) {
|
||||
delete myDSFiller;
|
||||
myDSFiller=NULL;
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : SetOperation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_BooleanOperation::SetOperation (const BOP_Operation anOp)
|
||||
{
|
||||
myOperation=anOp;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Operation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BOP_Operation BRepAlgoAPI_BooleanOperation::Operation ()const
|
||||
{
|
||||
return myOperation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FuseEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::FuseEdges ()const
|
||||
{
|
||||
return myFuseEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape1() const
|
||||
{
|
||||
return myS1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape2() const
|
||||
{
|
||||
return myS2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BuilderCanWork
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::BuilderCanWork() const
|
||||
{
|
||||
return myBuilderCanWork;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ErrorStatus
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepAlgoAPI_BooleanOperation::ErrorStatus()const
|
||||
{
|
||||
return myErrorStatus;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_Shape& aS)
|
||||
{
|
||||
if (myBuilder==NULL) {
|
||||
myGenerated.Clear();
|
||||
return myGenerated;
|
||||
}
|
||||
else {
|
||||
const TopTools_ListOfShape& aLM=myBuilder->Modified(aS);
|
||||
|
||||
if(myFuseEdges) {
|
||||
return RefinedList(aLM);
|
||||
}
|
||||
|
||||
return aLM;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::IsDeleted(const TopoDS_Shape& aS)
|
||||
{
|
||||
|
||||
// Standard_Boolean bDeleted = Standard_True;
|
||||
// if (myBuilder==NULL) {
|
||||
// return bDeleted;
|
||||
// }
|
||||
// else {
|
||||
// bDeleted=myBuilder->IsDeleted(aS);
|
||||
// return bDeleted;
|
||||
// }
|
||||
if(myHistory.IsNull()) {
|
||||
Standard_Boolean bDeleted = Standard_True;
|
||||
|
||||
if (myBuilder==NULL) {
|
||||
return bDeleted;
|
||||
}
|
||||
else {
|
||||
bDeleted = myBuilder->IsDeleted(aS);
|
||||
return bDeleted;
|
||||
}
|
||||
}
|
||||
return myHistory->IsDeleted(aS);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : PrepareFiller
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::PrepareFiller()
|
||||
{
|
||||
Standard_Boolean bIsNewFiller=Standard_False;
|
||||
myErrorStatus=1;
|
||||
//
|
||||
if (myS1.IsNull() || myS2.IsNull()) {
|
||||
myErrorStatus=2;
|
||||
return bIsNewFiller;
|
||||
}
|
||||
//
|
||||
if (myOperation==BOP_UNKNOWN) {
|
||||
myErrorStatus=6;
|
||||
return bIsNewFiller;
|
||||
}
|
||||
//
|
||||
if (myDSFiller==NULL) {
|
||||
bIsNewFiller=!bIsNewFiller;
|
||||
|
||||
myDSFiller=new BOPTools_DSFiller;
|
||||
//
|
||||
if (myDSFiller==NULL) {
|
||||
myErrorStatus=4;
|
||||
return bIsNewFiller;
|
||||
}
|
||||
//
|
||||
myDSFiller->SetShapes(myS1, myS2);
|
||||
if (!myDSFiller->IsDone()) {
|
||||
myErrorStatus=3;
|
||||
if (myDSFiller!=NULL) {
|
||||
delete myDSFiller;
|
||||
myDSFiller = NULL;
|
||||
return bIsNewFiller;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bIsNewFiller;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_BooleanOperation::Build()
|
||||
{
|
||||
Standard_Boolean bIsDone, bIsNewFiller;
|
||||
//
|
||||
myBuilderCanWork=Standard_False;
|
||||
NotDone();
|
||||
//
|
||||
bIsNewFiller=PrepareFiller();
|
||||
//
|
||||
if (myErrorStatus!=1) {
|
||||
// there was errors during the preparation
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (bIsNewFiller) {
|
||||
//Prepare the DS
|
||||
myDSFiller->Perform();
|
||||
}
|
||||
//
|
||||
if (myBuilder!=NULL) {
|
||||
delete myBuilder;
|
||||
myBuilder=NULL;
|
||||
}
|
||||
//
|
||||
const TopoDS_Shape& aS1 = myDSFiller->Shape1();
|
||||
const TopoDS_Shape& aS2 = myDSFiller->Shape2();
|
||||
//
|
||||
myShape.Nullify();
|
||||
//
|
||||
// SECTION
|
||||
//
|
||||
if (myOperation==BOP_SECTION) {
|
||||
myBuilder=new BOP_Section;
|
||||
}
|
||||
//
|
||||
// COMMON, FUSE, CUT12, CUT21
|
||||
//
|
||||
else if (myOperation==BOP_COMMON || myOperation==BOP_FUSE ||
|
||||
myOperation==BOP_CUT || myOperation==BOP_CUT21) {
|
||||
//
|
||||
// Check whether one or both of the arguments is(are) empty shape(s)
|
||||
// If yes, create BOP_EmptyBuilder object and build the result fast.
|
||||
{
|
||||
Standard_Boolean bIsEmptyShape1, bIsEmptyShape2;
|
||||
|
||||
bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(aS1);
|
||||
bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(aS2);
|
||||
//
|
||||
if (bIsEmptyShape1 || bIsEmptyShape2) {
|
||||
myBuilder=new BOP_EmptyBuilder;
|
||||
//
|
||||
if (myBuilder==NULL) {
|
||||
myErrorStatus=7;
|
||||
return ;
|
||||
}
|
||||
//
|
||||
myBuilder->SetShapes(aS1, aS2);
|
||||
myBuilder->SetOperation (myOperation);
|
||||
myBuilder->DoWithFiller (*myDSFiller);
|
||||
|
||||
bIsDone=myBuilder->IsDone();
|
||||
|
||||
if (bIsDone) {
|
||||
myErrorStatus=0;
|
||||
myBuilderCanWork=Standard_True;
|
||||
myShape=myBuilder->Result();
|
||||
Done();
|
||||
}
|
||||
else {
|
||||
myErrorStatus=100+myBuilder->ErrorStatus();
|
||||
NotDone();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
//
|
||||
TopAbs_ShapeEnum aT1, aT2;
|
||||
|
||||
aT1=aS1.ShapeType();
|
||||
aT2=aS2.ShapeType();
|
||||
//
|
||||
// Shell / Shell
|
||||
if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) {
|
||||
myBuilder=new BOP_ShellShell;
|
||||
}
|
||||
//
|
||||
// Solid / Solid
|
||||
else if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) {
|
||||
myBuilder=new BOP_SolidSolid;
|
||||
}
|
||||
//
|
||||
// Shell / Solid
|
||||
else if ((aT1==TopAbs_SOLID && aT2==TopAbs_SHELL)
|
||||
||
|
||||
(aT2==TopAbs_SOLID && aT1==TopAbs_SHELL)) {
|
||||
myBuilder=new BOP_ShellSolid;
|
||||
}
|
||||
//
|
||||
// Wire / Wire
|
||||
else if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){
|
||||
myBuilder=new BOP_WireWire;
|
||||
}
|
||||
//
|
||||
// Wire / Shell
|
||||
else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL)
|
||||
||
|
||||
(aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) {
|
||||
myBuilder=new BOP_WireShell;
|
||||
}
|
||||
//
|
||||
// Wire / Shell
|
||||
else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID)
|
||||
||
|
||||
(aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) {
|
||||
myBuilder=new BOP_WireSolid;
|
||||
}
|
||||
else {
|
||||
myErrorStatus=5;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (myBuilder==NULL) {
|
||||
myErrorStatus=7;
|
||||
return ;
|
||||
}
|
||||
//
|
||||
myBuilder->SetShapes(aS1, aS2);
|
||||
myBuilder->SetOperation (myOperation);
|
||||
|
||||
myHistory = MakeCollector(aS1, aS2, myOperation);
|
||||
myBuilder->SetHistoryCollector(myHistory);
|
||||
|
||||
myBuilder->DoWithFiller (*myDSFiller);
|
||||
|
||||
bIsDone=myBuilder->IsDone();
|
||||
|
||||
if (bIsDone) {
|
||||
myErrorStatus=0;
|
||||
myBuilderCanWork=Standard_True;
|
||||
myShape=myBuilder->Result();
|
||||
Done();
|
||||
}
|
||||
else {
|
||||
myErrorStatus=100+myBuilder->ErrorStatus();
|
||||
NotDone();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//=======================================================================
|
||||
//function : SectionEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges()
|
||||
{
|
||||
if (myBuilder==NULL) {
|
||||
myGenerated.Clear();
|
||||
return myGenerated;
|
||||
}
|
||||
else {
|
||||
const TopTools_ListOfShape& aLM=myBuilder->SectionEdges();
|
||||
|
||||
if(myFuseEdges) {
|
||||
return RefinedList(aLM);
|
||||
}
|
||||
|
||||
return aLM;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
// ================================================================================================
|
||||
// function: Modified2
|
||||
// purpose:
|
||||
// ================================================================================================
|
||||
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified2(const TopoDS_Shape& aS)
|
||||
{
|
||||
if(myHistory.IsNull()) {
|
||||
myGenerated.Clear();
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
if(myFuseEdges) {
|
||||
const TopTools_ListOfShape& aL = myHistory->Modified(aS);
|
||||
return RefinedList(aL);
|
||||
}
|
||||
|
||||
return myHistory->Modified(aS);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// function: Generated
|
||||
// purpose:
|
||||
// ================================================================================================
|
||||
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated(const TopoDS_Shape& S)
|
||||
{
|
||||
if(myHistory.IsNull()) {
|
||||
myGenerated.Clear();
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
if(myFuseEdges) {
|
||||
const TopTools_ListOfShape& aL = myHistory->Generated(S);
|
||||
return RefinedList(aL);
|
||||
}
|
||||
|
||||
return myHistory->Generated(S);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// function: HasModified
|
||||
// purpose:
|
||||
// ================================================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasModified() const
|
||||
{
|
||||
if(myHistory.IsNull()) {
|
||||
return Standard_False;
|
||||
}
|
||||
return myHistory->HasModified();
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// function: HasGenerated
|
||||
// purpose:
|
||||
// ================================================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasGenerated() const
|
||||
{
|
||||
if(myHistory.IsNull()) {
|
||||
return Standard_False;
|
||||
}
|
||||
return myHistory->HasGenerated();
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// function: HasDeleted
|
||||
// purpose:
|
||||
// ================================================================================================
|
||||
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const
|
||||
{
|
||||
if(myHistory.IsNull()) {
|
||||
return Standard_False;
|
||||
}
|
||||
return myHistory->HasDeleted();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : RefineEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepAlgoAPI_BooleanOperation::RefineEdges ()
|
||||
{
|
||||
|
||||
if(myFuseEdges) return; //Edges have been refined yet
|
||||
|
||||
BRepLib_FuseEdges FE(myShape);
|
||||
FE.SetConcatBSpl(Standard_True);
|
||||
|
||||
// avoid fusing old edges
|
||||
TopTools_IndexedMapOfShape mapOldEdges;
|
||||
TopExp::MapShapes (myS1, TopAbs_EDGE, mapOldEdges);
|
||||
TopExp::MapShapes (myS2, TopAbs_EDGE, mapOldEdges);
|
||||
FE.AvoidEdges (mapOldEdges);
|
||||
|
||||
// Get List of edges that have been fused
|
||||
myFuseEdges = Standard_False;
|
||||
myModifFaces.Clear();
|
||||
myEdgeMap.Clear();
|
||||
TopTools_DataMapOfIntegerListOfShape aFusedEdges;
|
||||
|
||||
FE.Edges(aFusedEdges);
|
||||
Standard_Integer nle = aFusedEdges.Extent();
|
||||
if (nle != 0) {
|
||||
FE.Perform();
|
||||
myShape = FE.Shape();
|
||||
|
||||
TopTools_DataMapOfIntegerShape aResultEdges;
|
||||
|
||||
FE.ResultEdges(aResultEdges);
|
||||
FE.Faces(myModifFaces);
|
||||
myFuseEdges = Standard_True;
|
||||
|
||||
|
||||
Standard_Integer i;
|
||||
for(i = 1; i <= nle; ++i) {
|
||||
const TopoDS_Shape& aNewE = aResultEdges(i);
|
||||
const TopTools_ListOfShape& aListOfOldEdges = aFusedEdges(i);
|
||||
TopTools_ListIteratorOfListOfShape anIter(aListOfOldEdges);
|
||||
for(; anIter.More(); anIter.Next()) {
|
||||
myEdgeMap.Bind(anIter.Value(), aNewE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RefinedList
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape&
|
||||
BRepAlgoAPI_BooleanOperation::RefinedList(const TopTools_ListOfShape& theL)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
TopTools_MapOfShape aMap;
|
||||
|
||||
TopTools_ListIteratorOfListOfShape anIter(theL);
|
||||
|
||||
for(; anIter.More(); anIter.Next()) {
|
||||
const TopoDS_Shape& anS = anIter.Value();
|
||||
|
||||
if(anS.ShapeType() == TopAbs_EDGE) {
|
||||
if(myEdgeMap.IsBound(anS)) {
|
||||
const TopoDS_Shape& aNewEdge = myEdgeMap.Find(anS);
|
||||
if(aMap.Add(aNewEdge)) {
|
||||
myGenerated.Append(aNewEdge);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myGenerated.Append(anS);
|
||||
}
|
||||
}
|
||||
else if (anS.ShapeType() == TopAbs_FACE) {
|
||||
if(myModifFaces.IsBound(anS)) {
|
||||
myGenerated.Append(myModifFaces.Find(anS));
|
||||
}
|
||||
else {
|
||||
myGenerated.Append(anS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myGenerated.Append(anS);
|
||||
}
|
||||
}
|
||||
|
||||
return myGenerated;
|
||||
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// static function: MakeCollector
|
||||
// purpose:
|
||||
// -----------------------------------------------------------------------------------------
|
||||
Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theShape1,
|
||||
const TopoDS_Shape& theShape2,
|
||||
const BOP_Operation theOperation) {
|
||||
|
||||
Handle(BOP_HistoryCollector) aresult;
|
||||
|
||||
if(theOperation == BOP_SECTION) {
|
||||
aresult = new BOP_SectionHistoryCollector(theShape1, theShape2);
|
||||
return aresult;
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum aT1, aT2;
|
||||
|
||||
aT1 = theShape1.ShapeType();
|
||||
aT2 = theShape2.ShapeType();
|
||||
//
|
||||
// Shell / Shell
|
||||
if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) {
|
||||
// aresult = new BOP_ShellShellHistoryCollector(theShape1, theShape2, theOperation, theDSFiller);
|
||||
}
|
||||
//
|
||||
// Solid / Solid
|
||||
else if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) {
|
||||
aresult = new BOP_SolidSolidHistoryCollector(theShape1, theShape2, theOperation);
|
||||
}
|
||||
//
|
||||
// Shell / Solid
|
||||
else if ((aT1==TopAbs_SOLID && aT2==TopAbs_SHELL)
|
||||
||
|
||||
(aT2==TopAbs_SOLID && aT1==TopAbs_SHELL)) {
|
||||
aresult = new BOP_ShellSolidHistoryCollector(theShape1, theShape2, theOperation);
|
||||
}
|
||||
//
|
||||
// Wire / Wire
|
||||
else if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){
|
||||
// aresult = new BOP_WireWireHistoryCollector(theShape1, theShape2, theOperation, theDSFiller);
|
||||
}
|
||||
//
|
||||
// Wire / Shell
|
||||
else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL)
|
||||
||
|
||||
(aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) {
|
||||
// aresult = new BOP_WireShellHistoryCollector(theShape1, theShape2, theOperation, theDSFiller);
|
||||
}
|
||||
//
|
||||
// Wire / Shell
|
||||
else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID)
|
||||
||
|
||||
(aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) {
|
||||
aresult = new BOP_WireSolidHistoryCollector(theShape1, theShape2, theOperation);
|
||||
}
|
||||
return aresult;
|
||||
}
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
-- File: BRepAlgoAPI_Common.cdl
|
||||
-- Created: Thu Oct 14 18:25:52 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Common from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
|
||||
|
||||
---Purpose: The class Common provides a
|
||||
-- Boolean common operation on a pair of arguments (Boolean Intersection).
|
||||
-- The class Common provides a framework for:
|
||||
-- - Defining the construction of a common shape;
|
||||
-- - Implementing the building algorithm
|
||||
-- - Consulting the result.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
DSFiller from BOPTools
|
||||
|
||||
is
|
||||
Create (S1,S2 : Shape from TopoDS)
|
||||
returns Common from BRepAlgoAPI;
|
||||
---Purpose: Constructs a common part for shapes aS1 and aS2 .
|
||||
|
||||
Create (S1,S2 : Shape from TopoDS;
|
||||
aDSF:DSFiller from BOPTools)
|
||||
returns Common from BRepAlgoAPI;
|
||||
end Common;
|
||||
--- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
// File: BRepAlgoAPI_Common.cxx
|
||||
// Created: Fri Oct 15 11:36:28 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
#include <BRepAlgoAPI_Common.ixx>
|
||||
|
||||
#include <BRepAlgoAPI_BooleanOperation.hxx>
|
||||
#include <BOP_Operation.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Common
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_COMMON)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Common
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2,
|
||||
const BOPTools_DSFiller& aDSF)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOP_COMMON)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
-- File: BRepAlgoAPI_Cut.cdl
|
||||
-- Created: Thu Oct 14 18:27:02 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Cut from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
|
||||
---Purpose: The class Cut provides a Boolean
|
||||
-- cut operation on a pair of arguments (Boolean Subtraction).
|
||||
-- The class Cut provides a framework for:
|
||||
-- - Defining the construction of a cut shape
|
||||
-- - Implementing the building algorithm
|
||||
-- - Consulting the result
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
DSFiller from BOPTools,
|
||||
Operation from BOP
|
||||
|
||||
is
|
||||
Create (S1,S2 : Shape from TopoDS)
|
||||
returns Cut from BRepAlgoAPI;
|
||||
---Purpose: Shape aS2 cuts shape aS1. The
|
||||
-- resulting shape is a new shape produced by the cut operation.
|
||||
|
||||
Create (S1,S2 : Shape from TopoDS;
|
||||
aDSF : DSFiller from BOPTools;
|
||||
bFWD : Boolean from Standard=Standard_True)
|
||||
returns Cut from BRepAlgoAPI;
|
||||
--- Purpose: Constructs a new shape cut from
|
||||
-- shape aS1 by shape aS2 using aDSFiller (see
|
||||
-- BRepAlgoAPI_BooleanOperation Constructor).
|
||||
|
||||
end Cut;
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
// File: BRepAlgoAPI_Cut.cxx
|
||||
// Created: Fri Oct 15 11:37:00 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
|
||||
#include <BRepAlgoAPI_Cut.ixx>
|
||||
|
||||
#include <BRepAlgoAPI_BooleanOperation.hxx>
|
||||
#include <BOP_Operation.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Cut
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_CUT)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Cut
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2,
|
||||
const BOPTools_DSFiller& aDSF,
|
||||
const Standard_Boolean bFWD)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOP_CUT : BOP_CUT21)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
-- File: BRepAlgoAPI_Fuse.cdl
|
||||
-- Created: Thu Oct 14 18:24:07 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Fuse from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
|
||||
|
||||
---Purpose: The class Fuse provides a
|
||||
-- Boolean fusion operation on a pair of arguments (Boolean Union).
|
||||
-- The class Fuse provides a framework for:
|
||||
-- - Defining the construction of a fused shape;
|
||||
-- - Implementing the building algorithm
|
||||
-- - Consulting the result.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
DSFiller from BOPTools
|
||||
|
||||
is
|
||||
Create (S1,S2 : Shape from TopoDS)
|
||||
returns Fuse from BRepAlgoAPI;
|
||||
---Purpose: Constructs a fuse of shapes aS1 and aS2.
|
||||
|
||||
Create (S1,S2 : Shape from TopoDS;
|
||||
aDSF:DSFiller from BOPTools)
|
||||
returns Fuse from BRepAlgoAPI;
|
||||
|
||||
---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller.
|
||||
|
||||
end Fuse;
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// File: BRepAlgoAPI_Fuse.cxx
|
||||
// Created: Fri Oct 15 11:35:59 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
#include <BRepAlgoAPI_Fuse.ixx>
|
||||
|
||||
#include <BRepAlgoAPI_BooleanOperation.hxx>
|
||||
#include <BOP_Operation.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Fuse
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_FUSE)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepAlgoAPI_Fuse
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2,
|
||||
const BOPTools_DSFiller& aDSF)
|
||||
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOP_FUSE)
|
||||
{
|
||||
BRepAlgoAPI_BooleanOperation* pBO=
|
||||
(BRepAlgoAPI_BooleanOperation*) (void*) this;
|
||||
pBO->Build();
|
||||
}
|
||||
Executable
+331
@@ -0,0 +1,331 @@
|
||||
-- File: BRepAlgoAPI_Section.cdl
|
||||
-- Created: Fri Feb 18 09:48:50 1994
|
||||
-- Author: Remi LEQUETTE
|
||||
--
|
||||
-- modified by Michael KLOKOV Wed Mar 6 15:01:25 2002
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
class Section from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
|
||||
|
||||
---Purpose: Computes the intersection of two shapes or geometries.
|
||||
-- Geometries can be surfaces of planes.
|
||||
-- Geometries are converted to faces
|
||||
-- When a geometry has been converted to
|
||||
-- topology the created shape can be found using
|
||||
-- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
|
||||
-- The result (Shape() method) is a compound containing
|
||||
-- edges built on intersection curves.
|
||||
-- By default, the section is performed immediatly in
|
||||
-- class constructors, with default values :
|
||||
-- - geometries built are NOT approximated.
|
||||
-- - PCurves are NOT computed on both parts.
|
||||
-- Example : giving two shapes S1,S2 accessing faces,
|
||||
-- let compute the section edges R on S1,S2,
|
||||
-- performing approximation on new curves,
|
||||
-- performing PCurve on part 1 but not on part 2 :
|
||||
-- Standard_Boolean PerformNow = Standard_False;
|
||||
-- BRepBoolAPI_Section S(S1,S2,PerformNow);
|
||||
-- S.ComputePCurveOn1(Standard_True);
|
||||
-- S.Approximation(Standard_True);
|
||||
-- S.Build();
|
||||
-- TopoDS_Shape R = S.Shape();
|
||||
-- On Null Shapes of geometries, NotDone() is called.
|
||||
|
||||
uses
|
||||
Pln from gp,
|
||||
Shape from TopoDS,
|
||||
Surface from Geom,
|
||||
Curve from Geom2d,
|
||||
DSFiller from BOPTools,
|
||||
ListOfShape from TopTools
|
||||
|
||||
is
|
||||
Create (S1,S2 : Shape from TopoDS;
|
||||
aDSF:DSFiller from BOPTools;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Create(Sh1,Sh2 : Shape from TopoDS;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
---Purpose: see upper
|
||||
---Level: Public
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Create(Sh : Shape from TopoDS; Pl : Pln from gp;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
---Purpose: see upper
|
||||
---Level: Public
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Create(Sh : Shape from TopoDS; Sf : Surface from Geom;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
---Purpose: see upper
|
||||
---Level: Public
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Create(Sf : Surface from Geom; Sh : Shape from TopoDS;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
---Purpose: see upper
|
||||
---Level: Public
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Create(Sf1 : Surface from Geom; Sf2 : Surface from Geom;
|
||||
PerformNow : Boolean = Standard_True)
|
||||
---Purpose: This and the above classes construct a framework for
|
||||
-- computing the section lines of:
|
||||
-- - two shapes Sh1 and Sh2, or
|
||||
-- - shape Sh and plane Pl, or
|
||||
-- - shape Sh and surface Sf, or
|
||||
-- - surface Sf and shape Sh, or
|
||||
-- - two surfaces Sf1 and Sf2,
|
||||
-- and builds a result if PerformNow equals true, its
|
||||
-- default value. If PerformNow equals false, the intersection
|
||||
-- will be computed later by the function Build.
|
||||
-- The constructed shape will be returned by the function Shape.
|
||||
-- This is a compound object composed of edges. These
|
||||
-- intersection edges may be built:
|
||||
-- - on new intersection lines, or
|
||||
-- - on coincident portions of edges in the two intersected shapes.
|
||||
-- These intersection edges are independent: they are not
|
||||
-- chained or grouped in wires. If no intersection edge exists, the
|
||||
-- result is an empty compound object.
|
||||
-- Note that other objects than TopoDS_Shape shapes involved in
|
||||
-- these syntaxes are converted into faces or shells before
|
||||
-- performing the computation of the intersection. A shape
|
||||
-- resulting from this conversion can be retrieved with the
|
||||
-- function Shape1 or Shape2.
|
||||
-- Parametric 2D curves on intersection edges
|
||||
-- No parametric 2D curve (pcurve) is defined for each elementary
|
||||
-- edge of the result. To attach such parametric curves to the
|
||||
-- constructed edges you may use a constructor with the PerformNow
|
||||
-- flag equal to false; then you use:
|
||||
-- - the function ComputePCurveOn1 to ask for
|
||||
-- the additional computation of a pcurve in the parametric
|
||||
-- space of the first shape,
|
||||
-- - the function ComputePCurveOn2 to ask for
|
||||
-- the additional computation of a pcurve in the parametric
|
||||
-- space of the second shape, in the end,
|
||||
-- - the function Build to construct the result.
|
||||
-- Approximation of intersection edges
|
||||
-- The underlying 3D geometry attached to each elementary edge
|
||||
-- of the result is:
|
||||
-- - analytic where possible, provided the corresponding
|
||||
-- geometry corresponds to a type of analytic curve
|
||||
-- defined in the Geom package; for example, the intersection
|
||||
-- of a cylindrical shape with a plane gives an ellipse or a circle;
|
||||
-- - or elsewhere, given as a succession of points grouped
|
||||
-- together in a BSpline curve of degree 1.
|
||||
-- If you prefer to have an attached 3D geometry which is a
|
||||
-- BSpline approximation of the computed set of points on
|
||||
-- computed elementary intersection edges whose underlying geometry
|
||||
-- is not analytic, you may use a constructor with the PerformNow
|
||||
-- flag equal to false. Then you use:
|
||||
-- - the function Approximation to ask for this
|
||||
-- computation option, and
|
||||
-- - the function Build to construct the result.
|
||||
-- - Note that as a result, approximations will only be
|
||||
-- computed on edges built on new intersection lines.
|
||||
-- - Example
|
||||
-- You may also combine these computation options. In the following example:
|
||||
-- - each elementary edge of the computed intersection,
|
||||
-- built on a new intersection line, which does not
|
||||
-- correspond to an analytic Geom curve, will be approximated by
|
||||
-- a BSpline curve whose degree is not greater than 8.
|
||||
-- - each elementary edge built on a new intersection line, will have:
|
||||
-- - a pcurve in the parametric space of the intersected face of shape S1,
|
||||
-- - no pcurve in the parametric space of the intersected face of shape S2.
|
||||
-- // TopoDS_Shape S1 = ... , S2 = ... ;
|
||||
-- Standard_Boolean PerformNow = Standard_False;
|
||||
-- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
|
||||
-- S.ComputePCurveOn1 (Standard_True);
|
||||
-- S.Approximation (Standard_True);
|
||||
-- S.Build();
|
||||
-- TopoDS_Shape R = S.Shape();
|
||||
returns Section from BRepAlgoAPI;
|
||||
|
||||
Init1(me : out;S1 : Shape from TopoDS);
|
||||
---Purpose: initialize first part
|
||||
---Level: Public
|
||||
|
||||
Init1(me : out;Pl : Pln from gp);
|
||||
---Purpose: initialize first part
|
||||
---Level: Public
|
||||
|
||||
Init1(me : out;Sf : Surface from Geom);
|
||||
---Purpose: initialize first part
|
||||
---Level: Public
|
||||
|
||||
Init2(me : out;S2 : Shape from TopoDS);
|
||||
---Purpose: initialize second part
|
||||
---Level: Public
|
||||
|
||||
Init2(me : out;Pl : Pln from gp);
|
||||
---Purpose: initialize second part
|
||||
---Level: Public
|
||||
|
||||
Init2(me : out;Sf : Surface from Geom);
|
||||
---Purpose: Reinitializes the first and the
|
||||
-- second parts on which this algorithm is going to perform
|
||||
-- the intersection computation. This is done with either: the
|
||||
-- surface Sf, the plane Pl or the shape Sh.
|
||||
-- You use the function Build to construct the result.
|
||||
|
||||
Approximation(me : out;B : Boolean);
|
||||
---Level: Public
|
||||
---Purpose: Defines an option for computation
|
||||
-- of further intersections. This computation will be performed by
|
||||
-- the function Build in this framework.
|
||||
-- By default, the underlying 3D geometry attached to each
|
||||
-- elementary edge of the result of a computed intersection is:
|
||||
-- - analytic where possible, provided the corresponding
|
||||
-- geometry corresponds to a type of analytic curve defined in
|
||||
-- the Geom package; for example the intersection of a
|
||||
-- cylindrical shape with a plane gives an ellipse or a circle;
|
||||
-- - or elsewhere, given as a succession of points grouped
|
||||
-- together in a BSpline curve of degree 1. If Approx equals
|
||||
-- true, when further computations are performed in this framework
|
||||
-- with the function Build, these edges will have an attached 3D
|
||||
-- geometry which is a BSpline approximation of the computed
|
||||
-- set of points.
|
||||
-- Note that as a result, approximations will be computed
|
||||
-- on edges built only on new intersection lines.
|
||||
|
||||
ComputePCurveOn1(me : out;B : Boolean);
|
||||
---Level: Public
|
||||
---Purpose:
|
||||
-- Indicates if the Pcurve must be (or not) performed on first part.
|
||||
|
||||
ComputePCurveOn2(me : out;B : Boolean);
|
||||
---Level: Public
|
||||
---Purpose: Define options for the computation of further
|
||||
-- intersections, which will be performed by the function Build
|
||||
-- in this framework.
|
||||
-- By default, no parametric 2D curve (pcurve) is defined for the
|
||||
-- elementary edges of the result. If ComputePCurve1 equals true,
|
||||
-- further computations performed in this framework with the function
|
||||
-- Build will attach an additional pcurve in the parametric space of
|
||||
-- the first shape to the constructed edges.
|
||||
-- If ComputePCurve2 equals true, the additional pcurve will be
|
||||
-- attached to the constructed edges in the parametric space of the
|
||||
-- second shape.
|
||||
-- These two functions may be used together.
|
||||
|
||||
Build(me : in out)
|
||||
---Purpose: Performs the computation of
|
||||
-- section lines between two parts defined at the time of
|
||||
-- construction of this framework or reinitialized with the Init1 and
|
||||
-- Init2 functions.
|
||||
-- The constructed shape will be returned by the function Shape.
|
||||
-- This is a compound object composed of edges. These
|
||||
-- intersection edges may be built:
|
||||
-- - on new intersection lines, or
|
||||
-- - on coincident portions of edges in the two intersected shapes.
|
||||
-- These intersection edges are independent: they are not chained
|
||||
-- or grouped into wires.
|
||||
-- If no intersection edge exists, the result is an empty compound object.
|
||||
-- The shapes involved in the construction of section lines can
|
||||
-- be retrieved with the function Shape1 or Shape2. Note that other
|
||||
-- objects than TopoDS_Shape shapes given as arguments at the
|
||||
-- construction time of this framework, or to the Init1 or
|
||||
-- Init2 function, are converted into faces or shells before
|
||||
-- performing the computation of the intersection.
|
||||
-- Parametric 2D curves on intersection edges
|
||||
-- No parametric 2D curve (pcurve) is defined for the elementary
|
||||
-- edges of the result. To attach parametric curves like this to
|
||||
-- the constructed edges you have to use:
|
||||
-- - the function
|
||||
-- ComputePCurveOn1 to ask for the additional computation of a
|
||||
-- pcurve in the parametric space of the first shape,
|
||||
-- - the function
|
||||
-- ComputePCurveOn2 to ask for the additional computation of a
|
||||
-- pcurve in the parametric space of the second shape.
|
||||
-- This must be done before calling this function.
|
||||
-- Approximation of intersection edges
|
||||
-- The underlying 3D geometry attached to each elementary edge of the result is:
|
||||
-- - analytic (where possible) provided the corresponding
|
||||
-- geometry corresponds to a type of analytic curve defined in
|
||||
-- the Geom package; for example, the intersection of a
|
||||
-- cylindrical shape with a plane gives an ellipse or a circle; or
|
||||
-- - elsewhere, given as a succession of points grouped
|
||||
-- together in a BSpline curve of degree 1.
|
||||
-- If, on computed elementary intersection edges whose
|
||||
-- underlying geometry is not analytic, you prefer to have an
|
||||
-- attached 3D geometry which is a Bspline approximation of the
|
||||
-- computed set of points, you have to use the function Approximation
|
||||
-- to ask for this computation option before calling this function.
|
||||
-- You may also have combined these computation options: look at the
|
||||
-- example given above to illustrate the use of the constructors.
|
||||
is redefined static;
|
||||
|
||||
HasAncestorFaceOn1(me; E : Shape from TopoDS;
|
||||
F : out Shape from TopoDS)
|
||||
returns Boolean;
|
||||
---Level: Public
|
||||
---Purpose:
|
||||
-- get the face of the first part giving section edge <E>.
|
||||
-- Returns True on the 3 following conditions :
|
||||
-- 1/ <E> is an edge returned by the Shape() method.
|
||||
-- 2/ First part of section performed is a shape.
|
||||
-- 3/ <E> is built on a intersection curve (i.e <E>
|
||||
-- is not the result of common edges)
|
||||
-- When False, F remains untouched.
|
||||
|
||||
HasAncestorFaceOn2(me; E : Shape from TopoDS;
|
||||
F : out Shape from TopoDS)
|
||||
returns Boolean;
|
||||
---Purpose: Identifies the ancestor faces of
|
||||
-- the intersection edge E resulting from the last
|
||||
-- computation performed in this framework, that is, the faces of
|
||||
-- the two original shapes on which the edge E lies:
|
||||
-- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and
|
||||
-- - HasAncestorFaceOn2 gives the ancestor face in the second shape.
|
||||
-- These functions return true if an ancestor face F is found, or false if not.
|
||||
-- An ancestor face is identifiable for the edge E if the following
|
||||
-- conditions are satisfied:
|
||||
-- - the first part on which this algorithm performed its
|
||||
-- last computation is a shape, that is, it was not given as
|
||||
-- a surface or a plane at the time of construction of this
|
||||
-- algorithm or at a later time by the Init1 function,
|
||||
-- - E is one of the elementary edges built by the
|
||||
-- last computation of this section algorithm.
|
||||
-- To use these functions properly, you have to test the returned
|
||||
-- Boolean value before using the ancestor face: F is significant
|
||||
-- only if the returned Boolean value equals true.
|
||||
|
||||
PCurveOn1(me; E : Shape from TopoDS)
|
||||
returns Curve from Geom2d;
|
||||
---Level: Public
|
||||
---Purpose: returns the PCurve connected to section edge <E>
|
||||
-- and lying on first part of Section.
|
||||
-- N.B : PCurve on first part is computed only if Section is performed
|
||||
-- after setting ComputePCurveOn1(Standard_True).
|
||||
|
||||
PCurveOn2(me; E : Shape from TopoDS)
|
||||
returns Curve from Geom2d;
|
||||
---Level: Public
|
||||
---Purpose: returns the PCurve connected to section edge <E>
|
||||
-- and lying on second part of Section.
|
||||
-- N.B : PCurve on second part is computed only if Section is performed
|
||||
-- after setting ComputePCurveOn2(Standard_True).
|
||||
-- Warning No pcurve is attached to an elementary edge of the
|
||||
-- resulting section, and the function returns a null
|
||||
-- handle, unless the function ComputePCurveOn1 or
|
||||
-- ComputePCurveOn2 was previously used to define
|
||||
-- this sort of option of computation.
|
||||
-- - A null handle is also returned if the edge E does
|
||||
-- not belong to the last computed intersection, that
|
||||
-- is, if it is not one of the elementary edges of the
|
||||
-- compound object returned by the function Shape.
|
||||
|
||||
InitParameters(me: out)
|
||||
---Level: Private
|
||||
is private;
|
||||
|
||||
fields
|
||||
myshapeisnull : Boolean from Standard;
|
||||
myparameterschanged : Boolean from Standard;
|
||||
myApprox : Boolean from Standard;
|
||||
myComputePCurve1 : Boolean from Standard;
|
||||
myComputePCurve2 : Boolean from Standard;
|
||||
|
||||
end Section from BRepAlgoAPI;
|
||||
Executable
+533
@@ -0,0 +1,533 @@
|
||||
// File: BRepAlgoAPI_Section.cxx
|
||||
// Created: Fri Feb 18 11:14:56 1994
|
||||
// Author: Remi LEQUETTE
|
||||
//
|
||||
// modified by Michael KLOKOV Wed Mar 6 15:01:25 2002
|
||||
|
||||
#include <BRepAlgoAPI_Section.ixx>
|
||||
|
||||
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeShell.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <BOP_Section.hxx>
|
||||
#include <BOPTools_SSIntersectionAttribute.hxx>
|
||||
|
||||
#include <BOPTools_SplitShapesPool.hxx>
|
||||
#include <BOPTools_InterferencePool.hxx>
|
||||
|
||||
#include <BOPTools_PaveBlock.hxx>
|
||||
#include <BOPTools_PaveFiller.hxx>
|
||||
#include <BooleanOperations_ShapesDataStructure.hxx>
|
||||
#include <BOPTools_ListOfPaveBlock.hxx>
|
||||
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
|
||||
#include <BOPTools_SSInterference.hxx>
|
||||
#include <BOPTools_Curve.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <BOP_SectionHistoryCollector.hxx>
|
||||
|
||||
static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
|
||||
{
|
||||
GeomAbs_Shape c = S->Continuity();
|
||||
if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S);
|
||||
else return BRepBuilderAPI_MakeShell(S);
|
||||
}
|
||||
|
||||
static Standard_Boolean HasAncestorFaces(const BOPTools_DSFiller& theDSFiller,
|
||||
const TopoDS_Shape& E,
|
||||
TopoDS_Shape& F1,
|
||||
TopoDS_Shape& F2);
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh1,
|
||||
const TopoDS_Shape& Sh2,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(Sh1, Sh2, BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(myS1.IsNull() || myS2.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
if (PerformNow)
|
||||
Build();
|
||||
}
|
||||
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1,
|
||||
const TopoDS_Shape& aS2,
|
||||
const BOPTools_DSFiller& aDSF,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(aS1, aS2, aDSF, BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(myS1.IsNull() || myS2.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
|
||||
if(PerformNow) {
|
||||
Build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh,
|
||||
const gp_Pln& Pl,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(new Geom_Plane(Pl)), BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(Sh.IsNull() || myS2.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
if (PerformNow)
|
||||
Build();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh,
|
||||
const Handle(Geom_Surface)& Sf,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(Sf), BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(Sh.IsNull() || myS2.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
if (PerformNow)
|
||||
Build();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf,
|
||||
const TopoDS_Shape& Sh,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(MakeShape(Sf), Sh, BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(myS1.IsNull() || Sh.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
if (PerformNow)
|
||||
Build();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf1,
|
||||
const Handle(Geom_Surface)& Sf2,
|
||||
const Standard_Boolean PerformNow)
|
||||
: BRepAlgoAPI_BooleanOperation(MakeShape(Sf1), MakeShape(Sf2), BOP_SECTION)
|
||||
{
|
||||
InitParameters();
|
||||
myparameterschanged = Standard_True;
|
||||
|
||||
if(myS1.IsNull() || myS2.IsNull()) {
|
||||
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
|
||||
myshapeisnull = Standard_True;
|
||||
}
|
||||
|
||||
if (PerformNow)
|
||||
Build();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init1(const TopoDS_Shape& S1)
|
||||
{
|
||||
if(!S1.IsNull()) {
|
||||
if (!S1.IsEqual(myS1)) {
|
||||
myS1 = S1;
|
||||
|
||||
if(!myS2.IsNull()) {
|
||||
myshapeisnull = Standard_False;
|
||||
}
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!myS1.IsNull()) {
|
||||
myS1 = S1;
|
||||
myshapeisnull = Standard_True;
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if(myparameterschanged)
|
||||
NotDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init1(const gp_Pln& Pl)
|
||||
{
|
||||
Init1(MakeShape(new Geom_Plane(Pl)));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init1(const Handle(Geom_Surface)& Sf)
|
||||
{
|
||||
Init1(MakeShape(Sf));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init2(const TopoDS_Shape& S2)
|
||||
{
|
||||
if(!S2.IsNull()) {
|
||||
if (!S2.IsEqual(myS2)) {
|
||||
myS2 = S2;
|
||||
|
||||
if(!myS1.IsNull()) {
|
||||
myshapeisnull = Standard_False;
|
||||
}
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!myS2.IsNull()) {
|
||||
myS2 = S2;
|
||||
myshapeisnull = Standard_True;
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if(myparameterschanged) {
|
||||
NotDone();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init2(const gp_Pln& Pl)
|
||||
{
|
||||
Init2(MakeShape(new Geom_Plane(Pl)));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Init2(const Handle(Geom_Surface)& Sf)
|
||||
{
|
||||
Init2(MakeShape(Sf));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Approximation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Approximation(const Standard_Boolean B)
|
||||
{
|
||||
if(myApprox != B) {
|
||||
myApprox = B;
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputePCurveOn1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::ComputePCurveOn1(const Standard_Boolean B)
|
||||
{
|
||||
if(myComputePCurve1 != B) {
|
||||
myComputePCurve1 = B;
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputePCurveOn2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::ComputePCurveOn2(const Standard_Boolean B)
|
||||
{
|
||||
if(myComputePCurve2 != B) {
|
||||
myComputePCurve2 = B;
|
||||
myparameterschanged = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::Build()
|
||||
{
|
||||
if(myshapeisnull) {
|
||||
myErrorStatus = 2;
|
||||
NotDone();
|
||||
return;
|
||||
}
|
||||
|
||||
if(myparameterschanged) {
|
||||
|
||||
myBuilderCanWork = Standard_False;
|
||||
|
||||
Standard_Boolean bIsNewFiller = PrepareFiller();
|
||||
//
|
||||
if (myErrorStatus!=1) {
|
||||
NotDone();
|
||||
// there were errors during the preparation
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (bIsNewFiller) {
|
||||
//Prepare the DS
|
||||
BOPTools_SSIntersectionAttribute aSectionAttribute(myApprox, myComputePCurve1, myComputePCurve2);
|
||||
myDSFiller->Perform(aSectionAttribute);
|
||||
}
|
||||
BOP_Section* aSectionAlgo = new BOP_Section();
|
||||
aSectionAlgo->SetShapes(myS1, myS2);
|
||||
|
||||
myHistory = new BOP_SectionHistoryCollector(myS1, myS2);
|
||||
aSectionAlgo->SetHistoryCollector(myHistory);
|
||||
|
||||
aSectionAlgo->DoWithFiller(*myDSFiller);
|
||||
|
||||
myBuilder = aSectionAlgo;
|
||||
|
||||
if(aSectionAlgo->IsDone()) {
|
||||
myErrorStatus=0;
|
||||
myBuilderCanWork=Standard_True;
|
||||
myShape = aSectionAlgo->Result();
|
||||
Done();
|
||||
}
|
||||
else {
|
||||
myErrorStatus = 100 + aSectionAlgo->ErrorStatus();
|
||||
NotDone();
|
||||
}
|
||||
myparameterschanged = Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasAncestorFaceOn1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn1(const TopoDS_Shape& E, TopoDS_Shape& F) const
|
||||
{
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
if(E.IsNull()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
if(E.ShapeType() != TopAbs_EDGE) {
|
||||
return aResult;
|
||||
}
|
||||
TopoDS_Shape F1, F2;
|
||||
aResult = HasAncestorFaces(*myDSFiller, E, F1, F2);
|
||||
|
||||
if(F1.IsNull()) {
|
||||
return Standard_False;
|
||||
}
|
||||
F = F1;
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasAncestorFaceOn2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn2(const TopoDS_Shape& E,TopoDS_Shape& F) const
|
||||
{
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
if(E.IsNull()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
if(E.ShapeType() != TopAbs_EDGE) {
|
||||
return aResult;
|
||||
}
|
||||
TopoDS_Shape F1, F2;
|
||||
aResult = HasAncestorFaces(*myDSFiller, E, F1, F2);
|
||||
|
||||
if(F2.IsNull()) {
|
||||
return Standard_False;
|
||||
}
|
||||
F = F2;
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurveOn1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom2d_Curve) BRepAlgoAPI_Section::PCurveOn1(const TopoDS_Shape& E) const
|
||||
{
|
||||
Handle(Geom2d_Curve) aResult;
|
||||
|
||||
if(myComputePCurve1) {
|
||||
TopoDS_Shape aShape;
|
||||
|
||||
if(HasAncestorFaceOn1(E, aShape)) {
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge(E);
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aShape);
|
||||
Standard_Real f, l;
|
||||
aResult = BRep_Tool::CurveOnSurface(anEdge, aFace, f, l);
|
||||
|
||||
if(!aResult->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
|
||||
aResult = new Geom2d_TrimmedCurve(aResult, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurveOn2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom2d_Curve) BRepAlgoAPI_Section::PCurveOn2(const TopoDS_Shape& E) const
|
||||
{
|
||||
Handle(Geom2d_Curve) aResult;
|
||||
|
||||
if(myComputePCurve2) {
|
||||
TopoDS_Shape aShape;
|
||||
|
||||
if(HasAncestorFaceOn2(E, aShape)) {
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge(E);
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aShape);
|
||||
Standard_Real f, l;
|
||||
aResult = BRep_Tool::CurveOnSurface(anEdge, aFace, f, l);
|
||||
|
||||
if(!aResult->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
|
||||
aResult = new Geom2d_TrimmedCurve(aResult, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Section::InitParameters()
|
||||
{
|
||||
myparameterschanged = Standard_False;
|
||||
myshapeisnull = Standard_False;
|
||||
myApprox = Standard_False;
|
||||
myComputePCurve1 = Standard_False;
|
||||
myComputePCurve2 = Standard_False;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// static function : HasAncestorFaces
|
||||
// purpose :
|
||||
// ------------------------------------------------------------------------
|
||||
static Standard_Boolean HasAncestorFaces(const BOPTools_DSFiller& theDSFiller,
|
||||
const TopoDS_Shape& E,
|
||||
TopoDS_Shape& F1,
|
||||
TopoDS_Shape& F2) {
|
||||
|
||||
BOPTools_PaveFiller* aPaveFiller = (BOPTools_PaveFiller*) &theDSFiller.PaveFiller();
|
||||
const BOPTools_CArray1OfSSInterference& aFFs = aPaveFiller->InterfPool()->SSInterferences();
|
||||
const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS();
|
||||
Standard_Integer aNb = aFFs.Extent();
|
||||
Standard_Integer i = 0;
|
||||
|
||||
for (i = 1; i <= aNb; i++) {
|
||||
BOPTools_SSInterference* aFFi = (BOPTools_SSInterference*) &aFFs(i);
|
||||
const BOPTools_SequenceOfCurves& aSeqOfCurve = aFFi->Curves();
|
||||
|
||||
for(Standard_Integer j = 1; j <= aSeqOfCurve.Length(); j++) {
|
||||
const BOPTools_Curve& aCurve = aSeqOfCurve.Value(j);
|
||||
BOPTools_ListIteratorOfListOfPaveBlock anIt(aCurve.NewPaveBlocks());
|
||||
|
||||
for(; anIt.More(); anIt.Next()) {
|
||||
const BOPTools_PaveBlock& aPB = anIt.Value();
|
||||
Standard_Integer anIndex = aPB.Edge();
|
||||
|
||||
if(anIndex <= 0)
|
||||
continue;
|
||||
|
||||
if(E.IsSame(aDS.Shape(anIndex))) {
|
||||
for(Standard_Integer fIt = 0; fIt < 2; fIt++) {
|
||||
anIndex = (fIt == 0) ? aFFi->Index1() : aFFi->Index2();
|
||||
|
||||
if(anIndex > 0) {
|
||||
if (fIt == 0)
|
||||
F1 = aDS.Shape(anIndex);
|
||||
else
|
||||
F2 = aDS.Shape(anIndex);
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOPTools_ListIteratorOfListOfPaveBlock anIt(aFFi->PaveBlocks());
|
||||
|
||||
for(; anIt.More(); anIt.Next()) {
|
||||
const BOPTools_PaveBlock& aPB = anIt.Value();
|
||||
Standard_Integer anIndex = aPB.Edge();
|
||||
|
||||
if(anIndex <= 0)
|
||||
continue;
|
||||
|
||||
if(E.IsSame(aDS.Shape(anIndex))) {
|
||||
for(Standard_Integer fIt = 0; fIt < 2; fIt++) {
|
||||
anIndex = (fIt == 0) ? aFFi->Index1() : aFFi->Index2();
|
||||
|
||||
if(anIndex > 0) {
|
||||
if (fIt == 0)
|
||||
F1 = aDS.Shape(anIndex);
|
||||
else
|
||||
F2 = aDS.Shape(anIndex);
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
Reference in New Issue
Block a user