1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00

0030151: Modeling Algorithms - Removal of the API level of old Boolean operations algorithm (BRepAlgo_BooleanOperation)

The following classes have been removed as obsolete:
- BRepAlgo_BooleanOperation
- BRepAlgo_Fuse
- BRepAlgo_Cut
- BRepAlgo_Common
- BRepAlgo_Section

The corresponding classes from BRepAlgoAPI package have to be used instead.

Draw commands:
- fuse
- cut
- common
- section/psection
have also been removed as obsolete.

The corresponding commands for modern Boolean operations algorithm (bfuse/bcut/bcommon/bsection) have to be used instead.

Adjustment of the test cases to use the commands for modern algorithm.
This commit is contained in:
emv 2018-09-21 11:43:16 +03:00 committed by smoskvin
parent 35ad04e78b
commit efac173377
41 changed files with 185 additions and 2591 deletions

View File

@ -2263,3 +2263,33 @@ For example:
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
BRepAlgoApi_Cut(S1, S2, aProgress->Start()); // method Start() creates range for usage in cut algorithm
~~~~
@subsection upgrade_occt760_old_bop_removed Removal of old Boolean operations algorithm (BRepAlgo_BooleanOperation)
* The method *BRepAlgo_Tool::Deboucle3D* has been removed as duplicating. The corresponding method from *BRepOffset_Tool* class has to be used instead.
* The API classes from *BRepAlgo* package performing old Boolean operations algorithm have been removed:
- *BRepAlgo_BooleanOperation*
- *BRepAlgo_Fuse*
- *BRepAlgo_Common*
- *BRepAlgo_Cut*
- *BRepAlgo_Section*
The corresponding classes from the *BRepAlgoAPI* package have to be used instead.
@subsection upgrade_occt760_change_check_to_adaptors Changes in BRepLib_CheckCurveOnSurface & GeomLib_CheckCurveOnSurface interfaces
Now the classes accept adaptors instead objects as input parameters.
*BRepLib_CheckCurveOnSurface* does no more provide access to curves, surface and parameters: methods PCurve(), PCurve2(), Surface() and Range() have been removed.
*BRepLib_CheckCurveOnSurface*: the default value of the *isMultiThread* parameter of the *Perform()* function has been changed from *true* to *false*
*GeomLib_CheckCurveOnSurface* does no more provide access to curve, surface and parameters: methods Curve(), Surface() and Range() have been removed.
*GeomLib_CheckCurveOnSurface*: the default value of the *isMultiThread* parameter of the *Perform()* function has been changed from *true* to *false*
The following functions in *GeomLib_CheckCurveOnSurface* have been modified:
~~~~{.cpp}
GeomLib_CheckCurveOnSurface(const Handle(Adaptor3d_Curve)& theCurve,
const Standard_Real theTolRange);
void Init (const Handle(Adaptor3d_Curve)& theCurve, const Standard_Real theTolRange);
void Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread);
~~~~

View File

@ -1,4 +1,4 @@
Draw Test Harness {#occt_user_guides__test_harness}
Draw Test Harness {#occt_user_guides__test_harness}
===============================
@tableofcontents
@ -6866,83 +6866,9 @@ tscale c1 0 0 0 0.5
~~~~
@subsection occt_draw_7_6 Old Topological operations
* **fuse**, **cut**, **common** are boolean operations.
* **section**, **psection** compute sections.
* **sewing** joins two or more shapes.
@subsubsection occt_draw_7_6_1 fuse, cut, common
These commands are no longer supported, so the result may be unpredictable.
Use the commands bfuse, bcut, bcommon instead.
Syntax:
~~~~{.php}
fuse name shape1 shape2
cut name shape1 shape2
common name shape1 shape2
~~~~
**fuse** creates a new shape by a boolean operation on two existing shapes. The new shape contains both originals intact.
**cut** creates a new shape which contains all parts of the second shape but only the first shape without the intersection of the two shapes.
**common** creates a new shape which contains only what is in common between the two original shapes in their intersection.
**Example:**
~~~~{.php}
# all four boolean operations on a box and a cylinder
box b 0 -10 5 20 20 10
pcylinder c 5 20
fuse s1 b c
ttranslate s1 40 0 0
cut s2 b c
ttranslate s2 -40 0 0
cut s3 c b
ttranslate s3 0 40 0
common s4 b c
ttranslate s4 0 -40 0
~~~~
@subsubsection occt_draw_7_6_2 section, psection
These commands are no longer supported, so the result may be unpredictable.
Use the command **bsection** instead.
Syntax:
~~~~{.php}
section result shape1 shape2
psection name shape plane
~~~~
**section** creates a compound object consisting of the edges for the intersection curves on the faces of two shapes.
**psection** creates a planar section consisting of the edges for the intersection curves on the faces of a shape and a plane.
**Example:**
~~~~{.php}
# section line between a cylinder and a box
pcylinder c 10 20
box b 0 0 5 15 15 15
trotate b 0 0 0 1 1 1 20
section s b c
# planar section of a cone
pcone c 10 30 30
plane p 0 0 15 1 1 2
psection s c p
~~~~
@subsubsection occt_draw_7_6_3 sewing
@subsection occt_draw_7_6 Sewing
**sewing** joins two or more shapes.
Syntax:
~~~~{.php}
sewing result [tolerance] shape1 shape2 ...
@ -6960,7 +6886,8 @@ whatis sr
sr is a shape COMPOUND FORWARD Free Modified
~~~~
@subsection occt_draw_7_7 New Topological operations
@subsection occt_draw_7_7 Topological operations
The new algorithm of Boolean operations avoids a large number of weak points and limitations presented in the old Boolean operation algorithm.
It also provides wider range of options and diagnostics.

View File

@ -802,7 +802,7 @@ if (MaxOnVertex > MaxAllowed) {
Class ShapeAnalysis_FreeBounds is intended to analyze and output the free bounds of a shape. Free bounds are wires consisting of edges referenced only once by only one face in the shape.
This class works on two distinct types of shapes when analyzing their free bounds:
* Analysis of possible free bounds taking the specified tolerance into account. This analysis can be applied to a compound of faces. The analyzer of the sewing algorithm (*BRepAlgo_Sewing*) is used to forecast what free bounds would be obtained after the sewing of these faces is performed. The following method should be used for this analysis:
* Analysis of possible free bounds taking the specified tolerance into account. This analysis can be applied to a compound of faces. The analyzer of the sewing algorithm is used to forecast what free bounds would be obtained after the sewing of these faces is performed. The following method should be used for this analysis:
~~~~{.cpp}
ShapeAnalysis_FreeBounds safb(shape,toler);
~~~~

View File

@ -26,12 +26,10 @@
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepBuild_HBuilder.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepAlgo_Cut.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgo.hxx>
#include <TDF_Data.hxx>
@ -305,7 +303,7 @@ void Sample()
ToolSelector.Select(Tool, Tool);
const TopoDS_Shape& TOOL = ToolSelector.NamedShape()->Get();
BRepAlgo_Cut mkCUT (OBJECT, TOOL);
BRepAlgoAPI_Cut mkCUT (OBJECT, TOOL);
if (!mkCUT.IsDone()) {
std::cout << "CUT: Algorithm failed" << std::endl;
@ -365,8 +363,7 @@ void Sample()
// push in the DF section edges
TNaming_Builder IntersBuilder(Intersections);
Handle(TopOpeBRepBuild_HBuilder) build = mkCUT.Builder();
TopTools_ListIteratorOfListOfShape its = build->Section();
TopTools_ListIteratorOfListOfShape its(mkCUT.SectionEdges());
for (; its.More(); its.Next()) {
// TNaming_Evolution == SELECTED
IntersBuilder.Select(its.Value(),its.Value());

View File

@ -34,9 +34,10 @@ bcommon teeth teeth outer
tcopy inner profile
set nbteeths 25
for {set i 0} {$i < $nbteeths} {incr i} {
fuse profile profile teeth
bfuse profile profile teeth
trotate teeth 0 0 0 0 0 1 360./$nbteeths
}
unifysamedom profile profile
# sweep profile along curved shape

View File

@ -37,8 +37,8 @@ mkface circle1 p0 circle1
mkface circle2 p0 circle2
bcommon sec rectangle1 circle1
# note use of 'fuse' instead of 'bfuse' -- we need to get single face
fuse sec sec circle2
bfuse sec sec circle2
unifysamedom sec sec
# Construct flute profile so as to have cutting lip straight after sharpening.
# Here we need to take into account spiral shift of the flute edge

View File

@ -17,10 +17,6 @@
#ifndef _BRepAlgo_HeaderFile
#define _BRepAlgo_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
@ -28,38 +24,22 @@
class TopoDS_Wire;
class TopoDS_Edge;
class TopoDS_Shape;
class BRepAlgo_BooleanOperation;
class BRepAlgo_Fuse;
class BRepAlgo_Cut;
class BRepAlgo_Common;
class BRepAlgo_Section;
class BRepAlgo_Loop;
class BRepAlgo_Tool;
class BRepAlgo_Image;
class BRepAlgo_AsDes;
class BRepAlgo_FaceRestrictor;
class BRepAlgo_NormalProjection;
//! The BRepAlgo package provides a full range of
//! services to perform Old Boolean Operations in Open CASCADE.
//! Attention:
//! The New Boolean Operation has replaced the Old
//! Boolean Operations algorithm in the BrepAlgoAPI
//! package in Open CASCADE.
//! The BRepAlgo class provides the following tools for:
//! - Checking validity of the shape;
//! - Concatenation of the edges of the wire.
class BRepAlgo
{
public:
DEFINE_STANDARD_ALLOC
//! this method makes a wire whose edges are C1 from
//! a Wire whose edges could be G1. It removes a vertex
//! between G1 edges.
//! Option can be G1 or C1.
Standard_EXPORT static TopoDS_Wire ConcatenateWire (const TopoDS_Wire& Wire, const GeomAbs_Shape Option, const Standard_Real AngularTolerance = 1.0e-4);
Standard_EXPORT static TopoDS_Wire ConcatenateWire (const TopoDS_Wire& Wire,
const GeomAbs_Shape Option,
const Standard_Real AngularTolerance = 1.0e-4);
//! this method makes an edge from a wire.
//! Junction points between edges of wire may be sharp,
@ -78,7 +58,10 @@ public:
//! If <GeomCtrl> is False the geometry of new
//! vertices and edges are not verified and the
//! auto-intersection of new wires are not searched.
Standard_EXPORT static Standard_Boolean IsValid (const TopTools_ListOfShape& theArgs, const TopoDS_Shape& theResult, const Standard_Boolean closedSolid = Standard_False, const Standard_Boolean GeomCtrl = Standard_True);
Standard_EXPORT static Standard_Boolean IsValid (const TopTools_ListOfShape& theArgs,
const TopoDS_Shape& theResult,
const Standard_Boolean closedSolid = Standard_False,
const Standard_Boolean GeomCtrl = Standard_True);
//! Checks if the shape is "correct".
//! If not, returns FALSE, else returns TRUE.
@ -86,38 +69,6 @@ public:
//! (intersection of wires, pcurve validity) are performed.
Standard_EXPORT static Standard_Boolean IsTopologicallyValid (const TopoDS_Shape& S);
protected:
private:
friend class BRepAlgo_BooleanOperation;
friend class BRepAlgo_Fuse;
friend class BRepAlgo_Cut;
friend class BRepAlgo_Common;
friend class BRepAlgo_Section;
friend class BRepAlgo_Loop;
friend class BRepAlgo_Tool;
friend class BRepAlgo_Image;
friend class BRepAlgo_AsDes;
friend class BRepAlgo_FaceRestrictor;
friend class BRepAlgo_NormalProjection;
};
#endif // _BRepAlgo_HeaderFile

View File

@ -1,917 +0,0 @@
// Created on: 1993-10-15
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#define TRC 0
#define MODIF 1
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAlgo_BooleanOperation.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepCheck.hxx>
#include <BRepCheck_Edge.hxx>
#include <BRepCheck_Shell.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepLib.hxx>
#include <BRepTools_Substitution.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopOpeBRep_DSFiller.hxx>
#include <TopOpeBRepBuild_HBuilder.hxx>
#include <TopOpeBRepBuild_Tools.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <TopOpeBRepDS_HDataStructure.hxx>
#include <TopOpeBRepTool_GeomTool.hxx>
#include <TopOpeBRepTool_OutCurveType.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
// sewing
#ifdef OCCT_DEBUG
extern Standard_Boolean TopOpeBRepTool_GetcontextNOSEW();
#endif
#define Opecom(st1,st2) (((st1)==TopAbs_IN) && ((st2)==TopAbs_IN))
#define Opefus(st1,st2) (((st1)==TopAbs_OUT) && ((st2)==TopAbs_OUT))
#define Opecut(st1,st2) (((st1)==TopAbs_OUT) && ((st2)==TopAbs_IN))
// -------------------------------------------------------------------
static void Sub_Classify(TopExp_Explorer& Ex,
const TopAbs_State St1,
TopTools_ListOfShape& Solids2,
BRep_Builder& BB,
TopTools_ListIteratorOfListOfShape& LIter,
TopoDS_Shape& myShape);
#ifdef OCCT_DEBUG
Standard_IMPORT Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
#endif
//modified by NIZHNY-MZV Wed Apr 19 17:19:11 2000
//see comments at the top of file TopOpeBRepBuild_Builder1.cxx
//about using of this global variable
extern Standard_Boolean GLOBAL_USE_NEW_BUILDER;
//
//modified by NIZNHY-PKV Sun Dec 15 17:17:56 2002 f
extern void FDSCNX_Close();// see TopOpeBRepDS_connex.cxx
extern void FDSSDM_Close();// see TopOpeBRepDS_samdom.cxx
//=======================================================================
//function : ~BRepAlgo_BooleanOperation
//purpose :
//=======================================================================
BRepAlgo_BooleanOperation::~BRepAlgo_BooleanOperation()
{
FDSSDM_Close();
FDSCNX_Close();
}
//modified by NIZNHY-PKV Sun Dec 15 17:17:58 2002 t
//=======================================================================
//function : BRepAlgoAPI_BooleanOperation
//purpose :
//=======================================================================
BRepAlgo_BooleanOperation::BRepAlgo_BooleanOperation(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: myS1(S1),myS2(S2),myBuilderCanWork(Standard_False)
{
TopOpeBRepDS_BuildTool BT;
myHBuilder = new TopOpeBRepBuild_HBuilder(BT);
}
//=======================================================================
//function : PerformDS
//purpose :
//=======================================================================
void BRepAlgo_BooleanOperation::PerformDS()
{
// const Standard_Boolean CheckShapes = Standard_True;
// create a data structure
Handle(TopOpeBRepDS_HDataStructure) HDS;
if (myHBuilder->DataStructure().IsNull())
HDS = new TopOpeBRepDS_HDataStructure();
else {
HDS = myHBuilder->DataStructure();
HDS->ChangeDS().Init();
}
// fill the data Structure
TopOpeBRep_DSFiller DSFiller;
// define face/face intersection tolerances
Standard_Boolean forcetoli = Standard_False;
if (forcetoli) {
Standard_Real tolarc=0,toltang=0;
TopOpeBRep_ShapeIntersector& tobsi = DSFiller.ChangeShapeIntersector();
TopOpeBRep_FacesIntersector& tobfi = tobsi.ChangeFacesIntersector();
tobfi.ForceTolerances(tolarc,toltang);
}
DSFiller.Insert(myS1,myS2,HDS);
// 020499 : JYL : reject if there is an edge of the SD
// not coded sameparameter and not degenerated
Standard_Boolean esp = HDS->EdgesSameParameter();
Standard_Boolean tede = Standard_True;
if (!esp) {
Standard_Integer i,n = HDS->NbShapes();
for (i = 1 ; i <= n; i++) {
const TopoDS_Shape& s = HDS->Shape(i);
if ( s.ShapeType() == TopAbs_EDGE ) {
const TopoDS_Edge& e = TopoDS::Edge(s);
Standard_Boolean sp = BRep_Tool::SameParameter(e);
Standard_Boolean de = BRep_Tool::Degenerated(e);
if ( !sp && !de ) {
tede = Standard_False;
break;
}
}
}
}
myBuilderCanWork = (esp || tede) ;
#ifdef OCCT_DEBUG
if (!esp) std::cout<<"BRepAlgo_BooleanOperation(DEB) some edges not SameParameter"<<std::endl;
#endif
if (!myBuilderCanWork) return;
Standard_Real tol3dAPPROX = 1e-7;
Standard_Real tol2dAPPROX = 1e-7;
// set tolerance values used by the APPROX process
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
GTofBTofBuilder.SetTolerances(tol3dAPPROX,tol2dAPPROX);
//modified by NIZHNY-MZV Thu Apr 20 09:35:44 2000
//see comments at the top of file TopOpeBRepBuild_Builder1.cxx
//about using of this global variable
GLOBAL_USE_NEW_BUILDER = Standard_True;
myHBuilder->Perform(HDS,myS1,myS2);
GLOBAL_USE_NEW_BUILDER = Standard_False;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepAlgo_BooleanOperation::Perform(const TopAbs_State St1,
const TopAbs_State St2)
{
if ( ! BuilderCanWork() ) {
return;
}
// modif JYL suite aux modifs LBR #if MODIF ...
// on privilegie le traitement KPart (si c'en est un)
// a tous les autres
Standard_Integer kp = myHBuilder->IsKPart();
BRep_Builder BB;
Standard_Boolean sewing = Standard_True;
if ( kp ) {
//modified by NIZHNY-MZV Thu Apr 20 09:34:33 2000
//see comments at the top of file TopOpeBRepBuild_Builder1.cxx
//about using of this global variable
GLOBAL_USE_NEW_BUILDER = Standard_True;
myHBuilder->MergeKPart(St1,St2);
GLOBAL_USE_NEW_BUILDER = Standard_False;
BB.MakeCompound(TopoDS::Compound(myShape));
Done();
TopTools_ListIteratorOfListOfShape its(myHBuilder->Merged(myS1,St1));
for(; its.More(); its.Next()) BB.Add(myShape,its.Value());
}
else {
#if MODIF
//======================================================================
//== Exploration of input shapes
//== Creation of the list of solids
//== Creation of the list of faces OUT OF solid
//== Creation of the list of edges OUT OF face
Standard_Integer nbs1,nbs2,nbf1,nbf2,nbe1,nbe2,nbv1,nbv2;
TopTools_ListOfShape Solids1,Solids2,Faces1,Faces2,Edges1,Edges2,Vertex1,Vertex2;
TopExp_Explorer Ex;
for(Ex.Init(myS1,TopAbs_SOLID),nbs1=0; Ex.More(); Ex.Next()) {
Solids1.Append(Ex.Current()); nbs1++;
}
for(Ex.Init(myS2,TopAbs_SOLID),nbs2=0; Ex.More(); Ex.Next()) {
Solids2.Append(Ex.Current()); nbs2++;
}
//== Faces not in a solid
for(Ex.Init(myS1,TopAbs_FACE,TopAbs_SOLID),nbf1=0; Ex.More(); Ex.Next()) {
Faces1.Append(Ex.Current()); nbf1++;
}
for(Ex.Init(myS2,TopAbs_FACE,TopAbs_SOLID),nbf2=0; Ex.More(); Ex.Next()) {
Faces2.Append(Ex.Current()); nbf2++;
}
//== Edges not in a solid
for(Ex.Init(myS1,TopAbs_EDGE,TopAbs_FACE),nbe1=0; Ex.More(); Ex.Next()) {
Edges1.Append(Ex.Current()); nbe1++;
}
for(Ex.Init(myS2,TopAbs_EDGE,TopAbs_FACE),nbe2=0; Ex.More(); Ex.Next()) {
Edges2.Append(Ex.Current()); nbe2++;
}
//== Vertices not in an edge
for(Ex.Init(myS1,TopAbs_VERTEX,TopAbs_EDGE),nbv1=0; Ex.More(); Ex.Next()) {
Vertex1.Append(Ex.Current()); nbv1++;
}
for(Ex.Init(myS2,TopAbs_VERTEX,TopAbs_EDGE),nbv2=0; Ex.More(); Ex.Next()) {
Vertex2.Append(Ex.Current()); nbv2++;
}
//-- std::cout<<"Solids1: "<<nbs1<<" Faces1: "<<nbf1<<" Edges1:"<<nbe1<<" Vtx1:"<<nbv1<<std::endl;
//-- std::cout<<"Solids2: "<<nbs2<<" Faces2: "<<nbf2<<" Edges2:"<<nbe2<<" Vtx2:"<<nbv2<<std::endl;
//==
//== Reject operations without direction
//-- Cut Solid by Edge
// Standard_Boolean Correct = Standard_True;
if( (nbs1 && nbs2==0 && St1==TopAbs_OUT && St2==TopAbs_IN)
|| (nbs2 && nbs1==0 && St2==TopAbs_OUT && St1==TopAbs_IN)) {
//-- std::cout<<"***** Invalid Operation : Cut of a Solid by a Non Solid "<<std::endl;
Done();
return;
}
if( (nbs1 && nbs2==0 && St1==TopAbs_OUT && St2==TopAbs_OUT)
|| (nbs2 && nbs1==0 && St2==TopAbs_OUT && St1==TopAbs_OUT)) {
//-- std::cout<<"***** Invalid Operation : Fusion of a Solid and a Non Solid "<<std::endl;
Done();
return;
}
if( (nbs1>0 && nbs2>0)
&& (nbe1 || nbe2 || nbf1 || nbf2 || nbv1 || nbv2)) {
//-- std::cout<<"***** Not Yet Implemented : Compound of solid and non Solid"<<std::endl;
Done();
return;
}
//======================================================================
// make a compound with the new solids
BB.MakeCompound(TopoDS::Compound(myShape));
TopTools_ListIteratorOfListOfShape LIter;
//----------------------------------------------------------------------
TopoDS_Shape SNULL;
if (nbf1 && nbf2) {
SNULL.Nullify();
if ( Opecom(St1,St2) ) {
TopTools_ListIteratorOfListOfShape itloe = myHBuilder->Section();
for(; itloe.More(); itloe.Next()) BB.Add(myShape,itloe.Value());
}
else {
if(nbf1) {
myHBuilder->MergeShapes(myS1,St1,SNULL,St2);
for(LIter.Initialize(Faces1);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St1)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St1));
its.More();its.Next()) BB.Add(myShape,its.Value());
}
else {
const TopoDS_Shape& LV = LIter.Value();
if( (LV.Orientation() == TopAbs_EXTERNAL && St1==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St1==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St1,Solids2,BB,LIter,myShape);
}
//-- End Classification
}
}
} // nbf1
SNULL.Nullify();
if ( Opefus(St1,St2) ) {
if(nbf2) {
myHBuilder->MergeShapes(SNULL,St1,myS2,St2);
for(LIter.Initialize(Faces2);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St2)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St2));
its.More();its.Next()) BB.Add(myShape,its.Value());
}
else {
const TopoDS_Shape& LV = LIter.Value();
if( (LV.Orientation() == TopAbs_EXTERNAL && St2==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St2==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St2,Solids1,BB,LIter,myShape);
}
//-- End Classification
}
}
} // nbf2
} // Fus
}
} // nbf1 && nbf2
else if (nbf1 || nbf2) {
SNULL.Nullify();
if(nbf1) {
myHBuilder->MergeShapes(myS1,St1,SNULL,St2);
// modified by IFV for treating operation between shell and solid
const TopTools_ListOfShape& MergedShapes = myHBuilder->Merged(myS1,St1);
TopTools_IndexedMapOfShape aMapOfFaces;
sewing = Standard_False;
if(MergedShapes.Extent() != 0) {
TopTools_ListIteratorOfListOfShape its(MergedShapes);
for(; its.More(); its.Next()) {
BB.Add(myShape,its.Value());
}
TopExp::MapShapes(myShape, TopAbs_FACE, aMapOfFaces);
}
for(LIter.Initialize(Faces1);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St1)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St1));
its.More();its.Next()) {
if(!aMapOfFaces.Contains(its.Value())) BB.Add(myShape,its.Value());
}
}
else {
const TopoDS_Shape& LV = LIter.Value();
if(!aMapOfFaces.Contains(LV)) {
if( (LV.Orientation() == TopAbs_EXTERNAL && St1==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St1==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St1,Solids2,BB,LIter,myShape);
}
//-- End Classification
}
}
}
} // nbf1
SNULL.Nullify();
if(nbf2) {
myHBuilder->MergeShapes(SNULL,St1,myS2,St2);
// modified by IFV for treating operation between shell and solid
const TopTools_ListOfShape& MergedShapes = myHBuilder->Merged(myS2,St2);
TopTools_IndexedMapOfShape aMapOfFaces;
sewing = Standard_False;
if(MergedShapes.Extent() != 0) {
TopTools_ListIteratorOfListOfShape its(MergedShapes);
for(; its.More(); its.Next()) {
BB.Add(myShape,its.Value());
}
TopExp::MapShapes(myShape, TopAbs_FACE, aMapOfFaces);
}
for(LIter.Initialize(Faces2);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St2)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St2));
its.More();its.Next()) {
if(!aMapOfFaces.Contains(its.Value())) BB.Add(myShape,its.Value());
}
}
else {
const TopoDS_Shape& LV = LIter.Value();
if(!aMapOfFaces.Contains(LV)) {
if( (LV.Orientation() == TopAbs_EXTERNAL && St2==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St2==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St2,Solids1,BB,LIter,myShape);
}
//-- End Classification
}
}
}
} // nbf2
} // (nbf1 || nbf2)
//----------------------------------------------------------------------
if(nbe1) {
myHBuilder->MergeShapes(myS1,St1,SNULL,St2);
for(LIter.Initialize(Edges1);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St1)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St1));
its.More();its.Next()) {
BB.Add(myShape,its.Value());
}
}
else {
const TopoDS_Shape& LV = LIter.Value();
if( (LV.Orientation() == TopAbs_EXTERNAL && St1==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St1==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St1,Solids2,BB,LIter,myShape);
}
//-- End Classification
}
}
}
if(nbe2) {
myHBuilder->MergeShapes(SNULL,St1,myS2,St2);
for(LIter.Initialize(Edges2);LIter.More();LIter.Next()) {
if (myHBuilder->IsSplit(LIter.Value(),St2)) {
TopTools_ListIteratorOfListOfShape its;
for(its.Initialize(myHBuilder->Splits(LIter.Value(),St2));
its.More();its.Next()) {
BB.Add(myShape,its.Value());
}
}
else {
const TopoDS_Shape& LV = LIter.Value();
if( (LV.Orientation() == TopAbs_EXTERNAL && St2==TopAbs_OUT )
||(LV.Orientation() == TopAbs_INTERNAL && St2==TopAbs_IN )) {
BB.Add(myShape,LV);
}
else {
//-- Classify :
Sub_Classify(Ex,St2,Solids1,BB,LIter,myShape);
}
//-- End Classification
}
}
}
//----------------------------------------------------------------------
//-- V1:Vertex1 state1 = OUT -> Preserve V1 if V1 is Out all S2
//-- V1:Vertex1 state1 = IN -> Preserve V1 if V1 is In one of S2
if(nbv1 && nbs2) {
if(St1 == TopAbs_IN) {
for(LIter.Initialize(Vertex1);LIter.More();LIter.Next()) {
Standard_Boolean keep = Standard_False;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(LIter.Value());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids2);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() == TopAbs_IN) {
ok=Standard_False;
keep = Standard_True;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
}
else {
if(St1 == TopAbs_OUT) {
for(LIter.Initialize(Vertex1);LIter.More();LIter.Next()) {
Standard_Boolean keep = Standard_True;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(LIter.Value());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids2);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() != TopAbs_OUT) {
keep = Standard_False;
ok = Standard_False;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
}
}
}
if(nbv2 && nbs1) {
if(St2 == TopAbs_IN) {
for(LIter.Initialize(Vertex2);LIter.More();LIter.Next()) {
Standard_Boolean keep = Standard_False;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(LIter.Value());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids1);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() == TopAbs_IN) {
ok=Standard_False;
keep = Standard_True;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
}
else {
if(St2 == TopAbs_OUT) {
for(LIter.Initialize(Vertex2);LIter.More();LIter.Next()) {
Standard_Boolean keep = Standard_True;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(LIter.Value());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids1);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() != TopAbs_OUT) {
keep = Standard_False;
ok = Standard_False;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
}
}
}
if(nbs1 && nbs2 ) {
myHBuilder->MergeShapes(myS1,St1,myS2,St2);
if(myHBuilder->IsMerged(myS1,St1)) {
TopTools_ListIteratorOfListOfShape its;
its = myHBuilder->Merged(myS1,St1);
Standard_Integer nbSolids = 0;
for(; its.More(); its.Next(), nbSolids++) {
BB.Add(myShape,its.Value());
}
}
}
#else
myHBuilder->MergeSolids(myS1,St1,myS2,St2);
TopTools_ListIteratorOfListOfShape its;
BB.MakeCompound(TopoDS::Compound(myShape));
its = myHBuilder->Merged(myS1,St1);
while (its.More()) {
BB.Add(myShape,its.Value());
its.Next();
}
#endif
// #if MODIF
}
// Creation of the Map used in IsDeleted.
TopExp_Explorer ex;
ex.Init(myShape,TopAbs_FACE);
for (; ex.More(); ex.Next()) myMap.Add(ex.Current());
ex.Init(myShape,TopAbs_EDGE); // for FRIKO
for (; ex.More(); ex.Next()) myMap.Add(ex.Current());
// Checking same parameter of new edges of section
Standard_Real eTol,cTol;
for (myHBuilder->InitSection(1);
myHBuilder->MoreSection();
myHBuilder->NextSection()) {
const TopoDS_Shape& cur = myHBuilder->CurrentSection();
if (cur.ShapeType()==TopAbs_EDGE) {
BRepCheck_Edge bce(TopoDS::Edge(cur));
cTol=bce.Tolerance();
eTol = BRep_Tool::Tolerance(TopoDS::Edge(cur));
if (eTol<cTol) {
BB.UpdateEdge(TopoDS::Edge(cur), cTol);
for (ex.Init(cur, TopAbs_VERTEX); ex.More(); ex.Next()) {
eTol = BRep_Tool::Tolerance(TopoDS::Vertex(ex.Current()));
if (eTol<cTol) {
// Update can only increase tolerance, so if the vertex
// has a greater tolerance thanits edges it is not touched
BB.UpdateVertex(TopoDS::Vertex(ex.Current()), cTol);
}
}
}
}
}
Standard_Real maxTol = RealLast(); // MSV: unlimit tolerance
TopOpeBRepBuild_Tools::CorrectTolerances(myShape,maxTol);
TopExp_Explorer ex1, ex2, ex3;
TopTools_ListOfShape theOldShell, theNewShell;
Standard_Boolean modif =Standard_False;
#ifdef OCCT_DEBUG
Standard_Boolean nosew = TopOpeBRepTool_GetcontextNOSEW();
if (nosew) sewing = Standard_False;
#endif
if (sewing) {
topToSew.Clear();
for (ex1.Init(myShape, TopAbs_SHELL); ex1.More(); ex1.Next()) {
BRepCheck_Shell bcs(TopoDS::Shell(ex1.Current()));
if (bcs.Closed()==BRepCheck_NotClosed) {
// it is required to add them face by face to avoid IsModified on faces
BRepBuilderAPI_Sewing brts;
for (ex3.Init(ex1.Current(), TopAbs_FACE); ex3.More(); ex3.Next()) {
brts.Add(ex3.Current());
}
brts.Perform();
ex2.Init(brts.SewedShape(), TopAbs_SHELL);
if (ex2.More()) {
ex2.Next();
if (!ex2.More()) {
ex2.Init(brts.SewedShape(), TopAbs_SHELL);
theOldShell.Append(ex1.Current());
theNewShell.Append(ex2.Current());
modif =Standard_True;
for (ex3.Init(ex1.Current(), TopAbs_EDGE); ex3.More(); ex3.Next()) {
const TopoDS_Edge& ledg = TopoDS::Edge(ex3.Current());
if (brts.IsSectionBound(ledg)) {
topToSew.Bind(ledg, brts.SectionToBoundary(ledg));
if (!BRep_Tool::SameParameter(brts.SectionToBoundary(ledg))) {
BRepLib::SameParameter(ledg, BRep_Tool::Tolerance(brts.SectionToBoundary(ledg)));
}
}
}
for (ex3.Init(ex1.Current(), TopAbs_FACE); ex3.More(); ex3.Next()) {
if (brts.IsModified(ex3.Current())) {
topToSew.Bind(ex3.Current(), brts.Modified(ex3.Current()));
}
}
}
}
}
}
} // sewing
if (modif) {
BRepTools_Substitution bsub;
TopTools_ListIteratorOfListOfShape itl(theOldShell);
TopTools_ListOfShape forSub;
for (; itl.More();itl.Next()) {
forSub.Append(theNewShell.First());
bsub.Substitute(itl.Value(), forSub);
theNewShell.RemoveFirst();
forSub.Clear();
}
bsub.Build(myShape);
if (bsub.IsCopied(myShape)) {
myShape=(bsub.Copy(myShape)).First();
}
}
Done();
}
//=======================================================================
//function : Builder
//purpose :
//=======================================================================
Handle(TopOpeBRepBuild_HBuilder) BRepAlgo_BooleanOperation::Builder()const
{
return myHBuilder;
}
//=======================================================================
//function : TopoDS_Shape&
//purpose :
//=======================================================================
const TopoDS_Shape& BRepAlgo_BooleanOperation::Shape1() const
{
return myS1;
}
//=======================================================================
//function : TopoDS_Shape&
//purpose :
//=======================================================================
const TopoDS_Shape& BRepAlgo_BooleanOperation::Shape2() const
{
return myS2;
}
//=======================================================================
//function : BuilderCanWork
//purpose :
//=======================================================================
void BRepAlgo_BooleanOperation::BuilderCanWork(const Standard_Boolean Val)
{
myBuilderCanWork = Val;
}
//=======================================================================
//function : BuilderCanWork
//purpose :
//=======================================================================
Standard_Boolean BRepAlgo_BooleanOperation::BuilderCanWork() const
{
return myBuilderCanWork;
}
void Sub_Classify(TopExp_Explorer& Ex,
const TopAbs_State St1,
TopTools_ListOfShape& Solids2,
BRep_Builder& BB,
TopTools_ListIteratorOfListOfShape& LIter,
TopoDS_Shape& myShape) {
Ex.Init(LIter.Value(),TopAbs_VERTEX);
if(Ex.More()) {
if(St1 == TopAbs_IN) {
Standard_Boolean keep = Standard_False;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(Ex.Current());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids2);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() == TopAbs_IN) {
ok=Standard_False;
keep = Standard_True;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
else {
if(St1 == TopAbs_OUT) {
Standard_Boolean keep = Standard_True;
Standard_Boolean ok = Standard_True;
const TopoDS_Vertex& V=TopoDS::Vertex(Ex.Current());
gp_Pnt P=BRep_Tool::Pnt(V);
Standard_Real Tol = BRep_Tool::Tolerance(V);
TopTools_ListIteratorOfListOfShape SIter;
for(SIter.Initialize(Solids2);
SIter.More() && ok==Standard_True;
SIter.Next()) {
BRepClass3d_SolidClassifier SolClass(SIter.Value());
SolClass.Perform(P,Tol);
if(SolClass.State() != TopAbs_OUT) {
keep = Standard_False;
ok = Standard_False;
}
}
if(keep) {
BB.Add(myShape,LIter.Value());
}
}
}
}
}
//=======================================================================
//function : InitParameters
//purpose : Info on geometry : PCurve, Approx, ...
//=======================================================================
void BRepAlgo_BooleanOperation::InitParameters()
{
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
GTofBTofBuilder.Define(TopOpeBRepTool_APPROX);
GTofBTofBuilder.DefineCurves(Standard_True);
GTofBTofBuilder.DefinePCurves1(Standard_True);
GTofBTofBuilder.DefinePCurves2(Standard_True);
}
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgo_BooleanOperation::Modified(const TopoDS_Shape& S)
{
myGenerated.Clear();
TopTools_MapOfShape aMap; // to check if shape can be added in list more then one time
aMap.Clear();
if (myHBuilder->IsSplit(S, TopAbs_OUT)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Splits(S, TopAbs_OUT));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
if (myHBuilder->IsSplit(S, TopAbs_IN)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Splits(S, TopAbs_IN));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
if (myHBuilder->IsSplit(S, TopAbs_ON)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Splits(S, TopAbs_ON));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
if (myHBuilder->IsMerged(S, TopAbs_OUT)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Merged(S, TopAbs_OUT));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
if (myHBuilder->IsMerged(S, TopAbs_IN)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Merged(S, TopAbs_IN));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
if (myHBuilder->IsMerged(S, TopAbs_ON)) {
TopTools_ListIteratorOfListOfShape It(myHBuilder->Merged(S, TopAbs_ON));
for(;It.More();It.Next()) {
if (topToSew.IsBound(It.Value()))
{if(aMap.Add(topToSew.Find(It.Value()))) myGenerated.Append(topToSew.Find(It.Value()));}
else
{if(aMap.Add(It.Value())) myGenerated.Append(It.Value());}
}
}
return myGenerated;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepAlgo_BooleanOperation::IsDeleted(const TopoDS_Shape& S)
{
Standard_Boolean Deleted = Standard_True;
if (myMap.Contains(S) ||
myHBuilder->IsMerged(S, TopAbs_OUT) ||
myHBuilder->IsMerged(S, TopAbs_IN) ||
myHBuilder->IsMerged(S, TopAbs_ON) ||
myHBuilder->IsSplit (S, TopAbs_OUT) ||
myHBuilder->IsSplit (S, TopAbs_IN) ||
myHBuilder->IsSplit (S, TopAbs_ON))
return Standard_False;
return Deleted;
}

View File

@ -1,108 +0,0 @@
// Created on: 1993-10-14
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_BooleanOperation_HeaderFile
#define _BRepAlgo_BooleanOperation_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <Standard_Boolean.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
#include <TopAbs_State.hxx>
#include <TopTools_ListOfShape.hxx>
class TopOpeBRepBuild_HBuilder;
class TopoDS_Shape;
//! The abstract class BooleanOperation is the root
//! class of Boolean operations.
//! A BooleanOperation object stores the two shapes in
//! preparation for the Boolean operation specified in
//! one of the classes inheriting from this one. These include:
//! - Common
//! - Cut
//! - Fuse
//! - Section.
class BRepAlgo_BooleanOperation : public BRepBuilderAPI_MakeShape
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT virtual ~BRepAlgo_BooleanOperation();
Standard_EXPORT void PerformDS();
Standard_EXPORT void Perform (const TopAbs_State St1, const TopAbs_State St2);
Standard_EXPORT Handle(TopOpeBRepBuild_HBuilder) Builder() const;
//! Returns the first shape involved in this Boolean operation.
Standard_EXPORT const TopoDS_Shape& Shape1() const;
//! Returns the second shape involved in this Boolean operation.
Standard_EXPORT const TopoDS_Shape& Shape2() const;
//! Returns the list of shapes modified from the shape
//! <S>.
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& S) Standard_OVERRIDE;
protected:
//! Prepares the operations for S1 and S2.
Standard_EXPORT BRepAlgo_BooleanOperation(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
Standard_EXPORT void BuilderCanWork (const Standard_Boolean B);
Standard_EXPORT Standard_Boolean BuilderCanWork() const;
Standard_EXPORT virtual void InitParameters();
Handle(TopOpeBRepBuild_HBuilder) myHBuilder;
TopoDS_Shape myS1;
TopoDS_Shape myS2;
private:
TopTools_MapOfShape myMap;
Standard_Boolean myBuilderCanWork;
TopTools_DataMapOfShapeShape topToSew;
};
#endif // _BRepAlgo_BooleanOperation_HeaderFile

View File

@ -1,27 +0,0 @@
// Created on: 1997-01-17
// Created by: Didier PIFFAULT
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_CheckStatus_HeaderFile
#define _BRepAlgo_CheckStatus_HeaderFile
enum BRepAlgo_CheckStatus
{
BRepAlgo_OK,
BRepAlgo_NOK
};
#endif // _BRepAlgo_CheckStatus_HeaderFile

View File

@ -1,36 +0,0 @@
// Created on: 1993-10-15
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepAlgo_Common.hxx>
#include <TopoDS_Shape.hxx>
Standard_DISABLE_DEPRECATION_WARNINGS
//=======================================================================
//function : BRepAlgo_Common
//purpose :
//=======================================================================
BRepAlgo_Common::BRepAlgo_Common(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: BRepAlgo_BooleanOperation(S1,S2)
{
InitParameters();
PerformDS();
Perform(TopAbs_IN,TopAbs_IN);
}
Standard_ENABLE_DEPRECATION_WARNINGS

View File

@ -1,68 +0,0 @@
// Created on: 1993-10-14
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_Common_HeaderFile
#define _BRepAlgo_Common_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BRepAlgo_BooleanOperation.hxx>
class TopoDS_Shape;
//! Describes functions for performing a topological
//! common operation (Boolean intersection).
//! A Common object provides the framework for:
//! - defining the construction of a common shape,
//! - implementing the construction algorithm, and
//! - consulting the result.
class Standard_DEPRECATED("This class is deprecated - BRepAlgoAPI_Common should be used instead")
BRepAlgo_Common : public BRepAlgo_BooleanOperation
{
public:
DEFINE_STANDARD_ALLOC
//! Constructs the common part of shapes S1 and S2.
Standard_EXPORT BRepAlgo_Common(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
protected:
private:
};
#endif // _BRepAlgo_Common_HeaderFile

View File

@ -1,36 +0,0 @@
// Created on: 1993-10-15
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepAlgo_Cut.hxx>
#include <TopoDS_Shape.hxx>
Standard_DISABLE_DEPRECATION_WARNINGS
//=======================================================================
//function : BRepAlgo_Cut
//purpose :
//=======================================================================
BRepAlgo_Cut::BRepAlgo_Cut(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: BRepAlgo_BooleanOperation(S1,S2)
{
InitParameters();
PerformDS();
Perform(TopAbs_OUT,TopAbs_IN);
}
Standard_ENABLE_DEPRECATION_WARNINGS

View File

@ -1,68 +0,0 @@
// Created on: 1993-10-14
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_Cut_HeaderFile
#define _BRepAlgo_Cut_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BRepAlgo_BooleanOperation.hxx>
class TopoDS_Shape;
//! Describes functions for performing a topological cut
//! operation (Boolean subtraction).
//! A Cut object provides the framework for:
//! - defining the construction of a cut shape,
//! - implementing the construction algorithm, and
//! - consulting the result.
class Standard_DEPRECATED("This class is deprecated - BRepAlgoAPI_Cut should be used instead")
BRepAlgo_Cut : public BRepAlgo_BooleanOperation
{
public:
DEFINE_STANDARD_ALLOC
//! Cuts the shape S2 from the shape S1.
Standard_EXPORT BRepAlgo_Cut(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
protected:
private:
};
#endif // _BRepAlgo_Cut_HeaderFile

View File

@ -1,36 +0,0 @@
// Created on: 1993-10-15
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepAlgo_Fuse.hxx>
#include <TopoDS_Shape.hxx>
Standard_DISABLE_DEPRECATION_WARNINGS
//=======================================================================
//function : BRepAlgo_Fuse
//purpose :
//=======================================================================
BRepAlgo_Fuse::BRepAlgo_Fuse(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: BRepAlgo_BooleanOperation(S1,S2)
{
InitParameters();
PerformDS();
Perform(TopAbs_OUT,TopAbs_OUT);
}
Standard_ENABLE_DEPRECATION_WARNINGS

View File

@ -1,68 +0,0 @@
// Created on: 1993-10-14
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_Fuse_HeaderFile
#define _BRepAlgo_Fuse_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BRepAlgo_BooleanOperation.hxx>
class TopoDS_Shape;
//! Describes functions for performing a topological
//! fusion operation (Boolean union).
//! A Fuse object provides the framework for:
//! - defining the construction of a fused shape,
//! - implementing the construction algorithm, and
//! - consulting the result.
class Standard_DEPRECATED("This class is deprecated - BRepAlgoAPI_Fuse should be used instead")
BRepAlgo_Fuse : public BRepAlgo_BooleanOperation
{
public:
DEFINE_STANDARD_ALLOC
//! Fuse S1 and S2.
Standard_EXPORT BRepAlgo_Fuse(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
protected:
private:
};
#endif // _BRepAlgo_Fuse_HeaderFile

View File

@ -1,358 +0,0 @@
// Created on: 1994-02-18
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAlgo_Section.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeShell.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pln.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopOpeBRepBuild_HBuilder.hxx>
#include <TopOpeBRepBuild_Tools.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <TopOpeBRepDS_HDataStructure.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& );
Standard_DISABLE_DEPRECATION_WARNINGS
//=======================================================================
//function : BRepAlgo_Section
//purpose :
//=======================================================================
BRepAlgo_Section::BRepAlgo_Section(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const Standard_Boolean PerformNow)
: BRepAlgo_BooleanOperation(S1, S2)
{
InitParameters();
myS1Changed = Standard_True;
myS2Changed = Standard_True;
if(myS1.IsNull() || S2.IsNull()) {
myshapeisnull = Standard_True;
}
if (PerformNow)
Build();
}
//=======================================================================
//function : BRepAlgo_Section
//purpose :
//=======================================================================
BRepAlgo_Section::BRepAlgo_Section(const TopoDS_Shape& S1,
const gp_Pln& Pl,
const Standard_Boolean PerformNow)
: BRepAlgo_BooleanOperation(S1, MakeShape(new Geom_Plane(Pl)))
{
InitParameters();
myS1Changed = Standard_True;
myS2Changed = Standard_True;
if(S1.IsNull() || myS2.IsNull()) {
myshapeisnull = Standard_True;
}
if (PerformNow)
Build();
}
//=======================================================================
//function : BRepAlgo_Section
//purpose :
//=======================================================================
BRepAlgo_Section::BRepAlgo_Section(const TopoDS_Shape& S1,
const Handle(Geom_Surface)& Sf,
const Standard_Boolean PerformNow)
: BRepAlgo_BooleanOperation(S1, MakeShape(Sf))
{
InitParameters();
myS1Changed = Standard_True;
myS2Changed = Standard_True;
if(S1.IsNull() || myS2.IsNull()) {
myshapeisnull = Standard_True;
}
if (PerformNow)
Build();
}
//=======================================================================
//function : BRepAlgo_Section
//purpose :
//=======================================================================
BRepAlgo_Section::BRepAlgo_Section(const Handle(Geom_Surface)& Sf,
const TopoDS_Shape& S2,
const Standard_Boolean PerformNow)
: BRepAlgo_BooleanOperation(MakeShape(Sf), S2)
{
InitParameters();
myS1Changed = Standard_True;
myS2Changed = Standard_True;
if(myS1.IsNull() || S2.IsNull()) {
myshapeisnull = Standard_True;
}
if (PerformNow)
Build();
}
//=======================================================================
//function : BRepAlgo_Section
//purpose :
//=======================================================================
BRepAlgo_Section::BRepAlgo_Section(const Handle(Geom_Surface)& Sf1,
const Handle(Geom_Surface)& Sf2,
const Standard_Boolean PerformNow)
: BRepAlgo_BooleanOperation(MakeShape(Sf1), MakeShape(Sf2))
{
InitParameters();
myS1Changed = Standard_True;
myS2Changed = Standard_True;
if(myS1.IsNull() || myS2.IsNull()) {
myshapeisnull = Standard_True;
}
if (PerformNow)
Build();
}
//=======================================================================
//function : Init1
//purpose : initialize the first Shape
//=======================================================================
void BRepAlgo_Section::Init1(const TopoDS_Shape& S1)
{
if(!S1.IsNull()) {
if (!S1.IsEqual(myS1)) {
myS1 = S1;
myS1Changed = Standard_True;
}
} else {
if(!myS1.IsNull()) {
myS1 = S1;
myS1Changed = Standard_True;
}
}
if (myS1Changed || myS2Changed)
NotDone();
}
//=======================================================================
//function : Init1
//purpose : initialize the first Shape
//=======================================================================
void BRepAlgo_Section::Init1(const gp_Pln& Pl)
{
Init1(MakeShape(new Geom_Plane(Pl)));
}
//=======================================================================
//function : Init1
//purpose : initialize the first Shape
//=======================================================================
void BRepAlgo_Section::Init1(const Handle(Geom_Surface)& Sf)
{
Init1(MakeShape(Sf));
}
//=======================================================================
//function : Init2
//purpose : initialize the second Shape
//=======================================================================
void BRepAlgo_Section::Init2(const TopoDS_Shape& S2)
{
if(!S2.IsNull()) {
if (!S2.IsEqual(myS2)) {
myS2 = S2;
myS2Changed = Standard_True;
}
} else {
if(!myS2.IsNull()) {
myS2 = S2;
myS2Changed = Standard_True;
}
}
if (myS1Changed || myS2Changed)
NotDone();
}
//=======================================================================
//function : Init2
//purpose : initialize the second Shape
//=======================================================================
void BRepAlgo_Section::Init2(const gp_Pln& Pl)
{
Init2(MakeShape(new Geom_Plane(Pl)));
}
//=======================================================================
//function : Init2
//purpose : initialize the second Shape
//=======================================================================
void BRepAlgo_Section::Init2(const Handle(Geom_Surface)& Sf)
{
Init2(MakeShape(Sf));
}
//=======================================================================
//function : Approximation
//purpose : To learn if an approximation of the geometry is calculated
//=======================================================================
void BRepAlgo_Section::Approximation(const Standard_Boolean Approx)
{
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
TopOpeBRepTool_OutCurveType OCT =
(Approx) ? TopOpeBRepTool_APPROX :TopOpeBRepTool_BSPLINE1;
if (GTofBTofBuilder.TypeC3D() != OCT) {
myApproxChanged = Standard_True;
GTofBTofBuilder.Define(OCT);
}
if (myApproxChanged)
NotDone();
}
//=======================================================================
//function : ComputePCurveOn1
//purpose : To learn if PCurves are calculated on the faces of the 1st Shape
//=======================================================================
void BRepAlgo_Section::ComputePCurveOn1(const Standard_Boolean ComputePCurve1)
{
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
if( GTofBTofBuilder.CompPC1() != ComputePCurve1) {
GTofBTofBuilder.DefinePCurves1(ComputePCurve1);
myPCurve1Changed = Standard_True;
}
if(myPCurve1Changed)
NotDone();
}
//=======================================================================
//function : ComputePCurve2
//purpose : To learn if PCurves are calculated on the faces of the 2nd Shape
//=======================================================================
void BRepAlgo_Section::ComputePCurveOn2(const Standard_Boolean ComputePCurve2)
{
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
if( GTofBTofBuilder.CompPC2() != ComputePCurve2) {
GTofBTofBuilder.DefinePCurves2(ComputePCurve2);
myPCurve2Changed = Standard_True;
}
if(myPCurve2Changed)
NotDone();
}
//=======================================================================
//function : Build
//purpose : compute the section
//=======================================================================
void BRepAlgo_Section::Build(const Message_ProgressRange& /*theRange*/)
{
if (myS1Changed ||
myS2Changed ||
myApproxChanged ||
myPCurve1Changed ||
myPCurve2Changed) {
PerformDS();
Standard_Boolean bcw = BuilderCanWork();
if ( ! bcw || myshapeisnull) return;
BRep_Builder BB;
BB.MakeCompound(TopoDS::Compound(myShape));
Handle(TopOpeBRepBuild_HBuilder) HB = Builder();
TopTools_ListIteratorOfListOfShape itloe = HB->Section();
for(; itloe.More(); itloe.Next()) BB.Add(myShape,itloe.Value());
TopOpeBRepBuild_Tools::CorrectTolerances(myShape);
Done();
}
}
//=======================================================================
//function : HasAncestorFaceOn1
//purpose :
//=======================================================================
Standard_Boolean BRepAlgo_Section::HasAncestorFaceOn1(const TopoDS_Shape& E,
TopoDS_Shape& F)const
{
TopoDS_Shape F1,F2; Standard_Integer iC;
Standard_Boolean res = myHBuilder->EdgeCurveAncestors(E,F1,F2,iC);
if ( res ) F = F1;
return res;
}
//=======================================================================
//function : HasAncestorFaceOn2
//purpose :
//=======================================================================
Standard_Boolean BRepAlgo_Section::HasAncestorFaceOn2(const TopoDS_Shape& E,
TopoDS_Shape& F)const
{
TopoDS_Shape F1,F2; Standard_Integer iC;
Standard_Boolean res = myHBuilder->EdgeCurveAncestors(E,F1,F2,iC);
if ( res ) F = F2;
return res;
}
//=======================================================================
//function : InitParameters
//purpose : initialize the fields of the class
//=======================================================================
void BRepAlgo_Section::InitParameters()
{
TopOpeBRepDS_BuildTool& BTofBuilder = myHBuilder->ChangeBuildTool();
TopOpeBRepTool_GeomTool& GTofBTofBuilder = BTofBuilder.ChangeGeomTool();
GTofBTofBuilder.Define(TopOpeBRepTool_BSPLINE1);
GTofBTofBuilder.DefineCurves(Standard_True);
GTofBTofBuilder.DefinePCurves1(Standard_False);
GTofBTofBuilder.DefinePCurves2(Standard_False);
myS1Changed = Standard_False;
myS2Changed = Standard_False;
//
myApproxChanged = Standard_False;
//
myPCurve1Changed = Standard_False;
//
myPCurve2Changed = Standard_False;
myshapeisnull = Standard_False;
}
//=======================================================================
//function : MakeShape
//purpose :
//=======================================================================
TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
{
GeomAbs_Shape c = S->Continuity();
if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S, Precision::Confusion());
else return BRepBuilderAPI_MakeShell(S);
}
Standard_ENABLE_DEPRECATION_WARNINGS

View File

@ -1,355 +0,0 @@
// Created on: 1994-02-18
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_Section_HeaderFile
#define _BRepAlgo_Section_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Boolean.hxx>
#include <BRepAlgo_BooleanOperation.hxx>
class TopoDS_Shape;
class gp_Pln;
class Geom_Surface;
//! Construction of the section lines between two shapes.
//! For this Boolean operation, each face of the first
//! shape is intersected by each face of the second
//! shape. The resulting intersection edges are brought
//! together into a compound object, but not chained or
//! grouped into wires.
//! Computation of the intersection of two Shapes or Surfaces
//! The two parts involved in this Boolean operation may
//! be defined from geometric surfaces: the most common
//! use is the computation of the planar section of a shape.
//! A Section object provides the framework for:
//! - defining the shapes to be intersected, and the
//! computation options,
//! - implementing the construction algorithm, and
//! - consulting the result.
//! 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.
class Standard_DEPRECATED("This class is deprecated - BRepAlgoAPI_Section should be used instead")
BRepAlgo_Section : public BRepAlgo_BooleanOperation
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT BRepAlgo_Section(const TopoDS_Shape& Sh1, const TopoDS_Shape& Sh2, const Standard_Boolean PerformNow = Standard_True);
Standard_EXPORT BRepAlgo_Section(const TopoDS_Shape& Sh, const gp_Pln& Pl, const Standard_Boolean PerformNow = Standard_True);
Standard_EXPORT BRepAlgo_Section(const TopoDS_Shape& Sh, const Handle(Geom_Surface)& Sf, const Standard_Boolean PerformNow = Standard_True);
Standard_EXPORT BRepAlgo_Section(const Handle(Geom_Surface)& Sf, const TopoDS_Shape& Sh, const Standard_Boolean PerformNow = Standard_True);
//! This and the above algorithms construct a framework for computing the section lines of
//! - the two shapes Sh1 and Sh2, or
//! - the shape Sh and the plane Pl, or
//! - the shape Sh and the surface Sf, or
//! - the surface Sf and the shape Sh, or
//! - the two surfaces Sf1 and Sf2,
//! and builds the 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.
//! Note that as a result, pcurves will only be added on
//! edges built on new intersection lines.
//! 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 shape S1,
//! - no pcurve in the parametric space of the shape S2.
//! // TopoDS_Shape S1 = ... , S2 = ... ;
//! Standard_Boolean PerformNow = Standard_False;
//! BRepAlgo_Section S ( S1, S2, PerformNow );
//! S.ComputePCurveOn1 (Standard_True);
//! S.Approximation (Standard_True);
//! S.Build();
//! TopoDS_Shape R = S.Shape();
Standard_EXPORT BRepAlgo_Section(const Handle(Geom_Surface)& Sf1, const Handle(Geom_Surface)& Sf2, const Standard_Boolean PerformNow = Standard_True);
//! Initializes the first part
Standard_EXPORT void Init1 (const TopoDS_Shape& S1);
//! Initializes the first part
Standard_EXPORT void Init1 (const gp_Pln& Pl);
//! Initializes the first part
Standard_EXPORT void Init1 (const Handle(Geom_Surface)& Sf);
//! initialize second part
Standard_EXPORT void Init2 (const TopoDS_Shape& S2);
//! Initializes the second part
Standard_EXPORT void Init2 (const gp_Pln& Pl);
//! This and the above algorithms
//! reinitialize 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.
Standard_EXPORT void Init2 (const Handle(Geom_Surface)& Sf);
//! 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.
Standard_EXPORT void Approximation (const Standard_Boolean B);
//! Indicates if the Pcurve must be (or not) performed on first part.
Standard_EXPORT void ComputePCurveOn1 (const Standard_Boolean B);
//! 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.
//! Note that as a result, pcurves will only be added onto
//! edges built on new intersection lines.
Standard_EXPORT void ComputePCurveOn2 (const Standard_Boolean B);
//! Performs the computation of the section lines
//! between the 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 the 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.
//! Note that as a result, pcurves are added on edges
//! built on new intersection lines only.
//! 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.
Standard_EXPORT void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
//! Identifies the ancestor faces of the new
//! 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
//! 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
//! three 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,
//! - the edge E is built on an intersection curve. In
//! other words, E is a new edge built on the
//! intersection curve, not on edges belonging to the
//! intersecting shapes.
//! 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.
Standard_EXPORT Standard_Boolean HasAncestorFaceOn1 (const TopoDS_Shape& E, TopoDS_Shape& F) const;
//! Identifies the ancestor faces of the new
//! 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:
//! - 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
//! three 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,
//! - the edge E is built on an intersection curve. In
//! other words, E is a new edge built on the
//! intersection curve, not on edges belonging to the
//! intersecting shapes.
//! 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.
Standard_EXPORT Standard_Boolean HasAncestorFaceOn2 (const TopoDS_Shape& E, TopoDS_Shape& F) const;
protected:
private:
Standard_EXPORT virtual void InitParameters() Standard_OVERRIDE;
Standard_Boolean myS1Changed;
Standard_Boolean myS2Changed;
Standard_Boolean myApproxChanged;
Standard_Boolean myPCurve1Changed;
Standard_Boolean myPCurve2Changed;
Standard_Boolean myshapeisnull;
};
#endif // _BRepAlgo_Section_HeaderFile

View File

@ -1,104 +0,0 @@
// Created on: 1995-10-23
// Created by: Yves FRICAUD
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAlgo_Tool.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
//=======================================================================
//function : Deboucle3D
//purpose :
//=======================================================================
TopoDS_Shape BRepAlgo_Tool::Deboucle3D(const TopoDS_Shape& S,
const TopTools_MapOfShape& Boundary)
{
TopoDS_Shape SS;
switch ( S.ShapeType()) {
case TopAbs_FACE:
{
}
break;
case TopAbs_SHELL:
{
// if the shell contains free borders that do not belong to the
// free borders of caps ( Boundary) it is removed.
TopTools_IndexedDataMapOfShapeListOfShape Map;
TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,Map);
Standard_Boolean JeGarde = Standard_True;
for ( Standard_Integer i = 1; i <= Map.Extent() && JeGarde; i++) {
const TopTools_ListOfShape& aLF = Map(i);
if (aLF.Extent() < 2) {
const TopoDS_Edge& anEdge = TopoDS::Edge(Map.FindKey(i));
if (anEdge.Orientation() == TopAbs_INTERNAL) {
const TopoDS_Face& aFace = TopoDS::Face(aLF.First());
if (aFace.Orientation() != TopAbs_INTERNAL) {
continue;
}
}
if (!Boundary.Contains(anEdge) &&
!BRep_Tool::Degenerated(anEdge) )
JeGarde = Standard_False;
}
}
if ( JeGarde) SS = S;
}
break;
case TopAbs_COMPOUND:
case TopAbs_SOLID:
{
// iterate on sub-shapes and add non-empty.
TopoDS_Iterator it(S);
TopoDS_Shape SubShape;
Standard_Integer NbSub = 0;
BRep_Builder B;
if (S.ShapeType() == TopAbs_COMPOUND) {
B.MakeCompound(TopoDS::Compound(SS));
}
else {
B.MakeSolid(TopoDS::Solid(SS));
}
for ( ; it.More(); it.Next()) {
const TopoDS_Shape& CurS = it.Value();
SubShape = Deboucle3D(CurS,Boundary);
if ( !SubShape.IsNull()) {
B.Add(SS, SubShape);
NbSub++;
}
}
if (NbSub == 0)
{
#ifdef OCCT_DEBUG
std::cout << "No subhape in shape!" << std::endl;
#endif
SS = TopoDS_Shape();
}
}
break;
default:
break;
}
return SS;
}

View File

@ -1,67 +0,0 @@
// Created on: 1995-10-23
// Created by: Yves FRICAUD
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepAlgo_Tool_HeaderFile
#define _BRepAlgo_Tool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopTools_MapOfShape.hxx>
class TopoDS_Shape;
class BRepAlgo_Tool
{
public:
DEFINE_STANDARD_ALLOC
//! Remove the non valid part of an offsetshape
//! 1 - Remove all the free boundary and the faces
//! connex to such edges.
//! 2 - Remove all the shapes not valid in the result
//! (according to the side of offsetting)
//! in this version only the first point is implemented.
Standard_EXPORT static TopoDS_Shape Deboucle3D (const TopoDS_Shape& S, const TopTools_MapOfShape& Boundary);
protected:
private:
};
#endif // _BRepAlgo_Tool_HeaderFile

View File

@ -3,24 +3,11 @@ BRepAlgo.hxx
BRepAlgo_1.cxx
BRepAlgo_AsDes.cxx
BRepAlgo_AsDes.hxx
BRepAlgo_BooleanOperation.cxx
BRepAlgo_BooleanOperation.hxx
BRepAlgo_CheckStatus.hxx
BRepAlgo_Common.cxx
BRepAlgo_Common.hxx
BRepAlgo_Cut.cxx
BRepAlgo_Cut.hxx
BRepAlgo_FaceRestrictor.cxx
BRepAlgo_FaceRestrictor.hxx
BRepAlgo_Fuse.cxx
BRepAlgo_Fuse.hxx
BRepAlgo_Image.cxx
BRepAlgo_Image.hxx
BRepAlgo_Loop.cxx
BRepAlgo_Loop.hxx
BRepAlgo_NormalProjection.cxx
BRepAlgo_NormalProjection.hxx
BRepAlgo_Section.cxx
BRepAlgo_Section.hxx
BRepAlgo_Tool.cxx
BRepAlgo_Tool.hxx

View File

@ -32,7 +32,6 @@
#include <BRepAdaptor_Surface.hxx>
#include <BRepAlgo_AsDes.hxx>
#include <BRepAlgo_Image.hxx>
#include <BRepAlgo_Tool.hxx>
#include <BRepBndLib.hxx>
#include <BRepLib.hxx>
#include <BRepLib_MakeEdge.hxx>
@ -3901,11 +3900,73 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F,
//function : Deboucle3D
//purpose :
//=======================================================================
TopoDS_Shape BRepOffset_Tool::Deboucle3D(const TopoDS_Shape& S,
const TopTools_MapOfShape& Boundary)
const TopTools_MapOfShape& Boundary)
{
return BRepAlgo_Tool::Deboucle3D(S,Boundary);
TopoDS_Shape SS;
switch (S.ShapeType())
{
case TopAbs_SHELL:
{
// if the shell contains free borders that do not belong to the
// free borders of caps ( Boundary) it is removed.
TopTools_IndexedDataMapOfShapeListOfShape Map;
TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, Map);
Standard_Boolean JeGarde = Standard_True;
for (Standard_Integer i = 1; i <= Map.Extent() && JeGarde; i++) {
const TopTools_ListOfShape& aLF = Map(i);
if (aLF.Extent() < 2) {
const TopoDS_Edge& anEdge = TopoDS::Edge(Map.FindKey(i));
if (anEdge.Orientation() == TopAbs_INTERNAL) {
const TopoDS_Face& aFace = TopoDS::Face(aLF.First());
if (aFace.Orientation() != TopAbs_INTERNAL) {
continue;
}
}
if (!Boundary.Contains(anEdge) &&
!BRep_Tool::Degenerated(anEdge))
JeGarde = Standard_False;
}
}
if (JeGarde) SS = S;
}
break;
case TopAbs_COMPOUND:
case TopAbs_SOLID:
{
// iterate on sub-shapes and add non-empty.
TopoDS_Iterator it(S);
TopoDS_Shape SubShape;
Standard_Integer NbSub = 0;
BRep_Builder B;
if (S.ShapeType() == TopAbs_COMPOUND) {
B.MakeCompound(TopoDS::Compound(SS));
}
else {
B.MakeSolid(TopoDS::Solid(SS));
}
for (; it.More(); it.Next()) {
const TopoDS_Shape& CurS = it.Value();
SubShape = Deboucle3D(CurS, Boundary);
if (!SubShape.IsNull()) {
B.Add(SS, SubShape);
NbSub++;
}
}
if (NbSub == 0)
{
SS = TopoDS_Shape();
}
}
break;
default:
break;
}
return SS;
}
//=======================================================================

View File

@ -22,11 +22,6 @@
#include <Draw_Appli.hxx>
#include <BRep_Builder.hxx>
#include <BRepAlgo_Fuse.hxx>
#include <BRepAlgo_Common.hxx>
#include <BRepAlgo_Cut.hxx>
#include <BRepAlgo_Section.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepPrimAPI_MakeHalfSpace.hxx>
@ -42,123 +37,9 @@
#include <TopOpeBRepDS_HDataStructure.hxx>
#include <gp.hxx>
#include <gp_Pln.hxx>
#include <Message.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
Standard_DISABLE_DEPRECATION_WARNINGS
//=======================================================================
// topop
//=======================================================================
static Standard_Integer topop(Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n < 4) return 1;
TopoDS_Shape s1 = DBRep::Get(a[2]);
TopoDS_Shape s2 = DBRep::Get(a[3]);
if (s1.IsNull() || s2.IsNull()) return 1;
TopoDS_Shape res;
if (*a[0] == 'f')
res = BRepAlgo_Fuse(s1,s2);
else if (*(a[0]+1) == 'o')
res = BRepAlgo_Common(s1,s2);
else
res = BRepAlgo_Cut(s1,s2);
DBRep::Set(a[1],res);
return 0;
}
//=======================================================================
// section
//=======================================================================
static Standard_Integer section(Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n < 4) return 1;
TopoDS_Shape s1 = DBRep::Get(a[2]);
TopoDS_Shape s2 = DBRep::Get(a[3]);
if (s1.IsNull() || s2.IsNull())
return 1;
BRepAlgo_Section Sec(s1, s2, Standard_False);
TopoDS_Shape res;
for (int i=4; i < n; i++) {
if (!strcasecmp(a[i], "-2d"))
{
Sec.ComputePCurveOn1(Standard_True);
Sec.ComputePCurveOn2(Standard_True);
}
else if (!strcasecmp(a[i], "-2d1"))
{
Sec.ComputePCurveOn1(Standard_True);
Sec.ComputePCurveOn2(Standard_False);
}
else if (!strcasecmp(a[i], "-2d2"))
{
Sec.ComputePCurveOn1(Standard_False);
Sec.ComputePCurveOn2(Standard_True);
}
else if (!strcasecmp(a[i], "-no2d"))
{
Sec.ComputePCurveOn1(Standard_False);
Sec.ComputePCurveOn2(Standard_False);
}
else if (!strcasecmp(a[i], "-a"))
Sec.Approximation(Standard_True);
else if (strcasecmp(a[i], "-p"))
{
Message::SendFail() << "Unknown option: " << a[i];
return 1;
}
}
res = Sec.Shape();
DBRep::Set(a[1],res);
return 0;
}
//=======================================================================
// psection
//=======================================================================
static Standard_Integer psection(Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n < 4) return 1;
TopoDS_Shape s = DBRep::Get(a[2]);
if (s.IsNull()) return 1;
Handle(Geom_Surface) ps = DrawTrSurf::GetSurface(a[3]);
if (ps.IsNull()) return 1;
Handle(Geom_Plane) pg = Handle(Geom_Plane)::DownCast(ps);
if (pg.IsNull()) return 1;
const gp_Pln& p = pg->Pln();
TopoDS_Shape res = BRepAlgo_Section(s,p);
DBRep::Set(a[1],res);
return 0;
}
Standard_ENABLE_DEPRECATION_WARNINGS
static Standard_Integer halfspace(Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
@ -247,11 +128,6 @@ void BRepTest::TopologyCommands(Draw_Interpretor& theCommands)
const char* g = "TOPOLOGY Topological operation commands";
theCommands.Add("fuse","fuse result s1 s2",__FILE__,topop,g);
theCommands.Add("common","common result s1 s2",__FILE__,topop,g);
theCommands.Add("cut","cut result part tool",__FILE__,topop,g);
theCommands.Add("section","section result s1 s2 [-no2d/-2d/-2d1/-2d2] [-p/-a]",__FILE__,section,g);
theCommands.Add("psection","psection result s plane",__FILE__,psection,g);
theCommands.Add("halfspace","halfspace result face/shell x y z",__FILE__,halfspace,g);
theCommands.Add("buildfaces","buildfaces result faceReference wire1 wire2 ...",__FILE__,buildfaces,g);
}

View File

@ -11,7 +11,7 @@ proc store_part {nx ny dx dy dz entry} {
global D0
box b1 0 0 0 [expr $nx + .5] [expr $ny + .5] 1
box b2 0.5 0.5 0 [expr $nx - .5] [expr $nx - .5] 0.4
cut base b1 b2
bcut base b1 b2
set command "compound"
for {set x 0} {$x < $nx} {incr x} {

View File

@ -6,8 +6,9 @@ puts "========================"
restore [locate_data_file buc60585a.brep] s
checkshape s
plane ps 2036.25 -97.5 -1460.499755859375 0.0 -0.75103523489975432 -0.66026212668838646 1.0 0.0 0.0
mkface fs ps
psection result s ps
bsection result s fs
checkprops result -l 117.81
checkshape result

View File

@ -6,8 +6,9 @@ puts "========================"
restore [locate_data_file buc60585b.brep] t
checkshape t
plane pt 2036.25 -97.5 -1460.499755859375 0.0 -1.0 0.0 1.0 0.0 0.0
mkface ft pt
psection result t pt
bsection result t ft
checkprops result -l 22.0446
checkshape result

View File

@ -13,17 +13,20 @@ restore [locate_data_file OCC592.brep] a
set Z 67.599311020481764
plane p 0 0 $Z
psection r1 a p
mkface f p
bsection r1 a f
if ![regexp VERTEX [statshape r1]] {puts [format "OCC526 FAULTY Z=%f" $Z ] }
set Z 66.599311020481764
plane p 0 0 $Z
psection r2 a p
mkface f p
bsection r2 a f
if ![regexp VERTEX [statshape r2]] {puts [format "OCC526 FAULTY Z=%f" $Z ] }
set Z 65.599311020481764
plane p 0 0 $Z
psection result a p
mkface f p
bsection result a f
if ![regexp VERTEX [statshape result]] {puts [format "OCC526 FAULTY Z=%f" $Z ] }
checkprops result -l 27.8021

View File

@ -1,5 +1,3 @@
puts "TODO OCC82 ALL: Error : Incomplete section of shell by plane"
puts "====="
puts "OCC82"
puts "====="
@ -16,14 +14,14 @@ set length 113.703
set nbshapes_expected "
Number of shapes in shape
VERTEX : 44
VERTEX : 42
EDGE : 41
"
plane f 0 14.8053 0 0 1 0
mkface f f
section result sh f
bsection result sh f
checkshape result

View File

@ -8,4 +8,14 @@ puts ""
psphere s1 10
psphere s2 10
common result s1 s2
bcommon result s1 s2
explode result so
checkshape result
checknbshapes result_1 -ref [nbshapes s1]
checknbshapes result_1 -ref [nbshapes s2]
checkprops result_1 -equal s1
checkprops result_1 -equal s2

View File

@ -8,4 +8,9 @@ puts ""
restore [locate_data_file bug24463_TK0000000000480_109.brep] a
plane p 0 7000 0 0 -1 0 0 0 -1
psection r a p
mkface f p
bsection r a f
checkprops r -l 61.6434
checksection r -r 2

View File

@ -9,19 +9,12 @@ puts ""
restore [locate_data_file bug24519_cylinder.brep] cy
restore [locate_data_file bug24519_plane.brep] pl
bsection r1 cy pl
section r2 cy pl
set exp1 [explode r1]
set exp2 [explode r2]
bsection r cy pl
set exp [explode r]
if { $exp1 != "r1_1" } {
if { $exp != "r_1" } {
puts "Error: First intersection is not returned"
}
if { $exp2 != "r2_1" } {
puts "Error: Second intersection is not returned"
}
checksection r1
checksection r2
checkprops r1 -l 3.83537
checkprops r2 -l 3.83537
checksection r -r 2
checkprops r -l 3.83537

View File

@ -35,9 +35,10 @@ bcommon teeth teeth outer
tcopy inner profile
set nbteeths 25
for {set i 0} {$i < $nbteeths} {incr i} {
fuse profile profile teeth
bfuse profile profile teeth
trotate teeth 0 0 0 0 0 1 360./$nbteeths
}
unifysamedom profile profile
# sweep profile along curved shape
polyline sp 0 0 0 0 0 H

View File

@ -42,8 +42,8 @@ mkface circle1 p0 circle1
mkface circle2 p0 circle2
bcommon sec rectangle1 circle1
# note use of 'fuse' instead of 'bfuse' -- we need to get single face
fuse sec sec circle2
bfuse sec sec circle2
unifysamedom sec sec
# Construct flute profile so as to have cutting lip straight after sharpening.
# Here we need to take into account spiral shift of the flute edge

View File

@ -8,4 +8,6 @@ puts ""
restore [locate_data_file OCC25766_surface1.brep] b1
restore [locate_data_file OCC25766_surface2.brep] b2
section r b1 b2
bsection r b1 b2
checkprops r -l 950.001
checksection r -r 2

View File

@ -42,16 +42,4 @@ if { [llength $rfaces] != 1 } {
puts "Result is as expected"
}
# Do the same using cut
puts "Now running old cut"
cut rcut face tool
# Evaluate result by number of faces (cut)
set rcfaces [explode rcut f]
if { [llength $rcfaces] != 1 } {
puts "Error: [llength $rcfaces] faces instead of 1"
} else {
puts "Result is as expected"
}
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@ -17,12 +17,12 @@ mkface f f -11 11 -11 11
puts "Info: perform section with plane"
chrono h1 reset; chrono h1 start
section r1 f pr
bsection r1 f pr
chrono h1 stop counter "CPU section r1"
puts "Info: perform section with planar BSpline surface"
chrono h2 reset; chrono h2 start
section r2 sh pr
bsection r2 sh pr
chrono h2 stop counter "CPU section r2"
regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono h1 show] full h1_Hours h1_Minutes h1_Seconds

View File

@ -15,7 +15,7 @@ wire ell_w ell_e
mkplane ell_f ell_w 1
box ell_t -10 -110 140 20 110 460
cut ell_d ell_f ell_t
bcut ell_d ell_f ell_t
revol ell_z ell_d 0 0 0 0 0 1 360
explode ell_z F

View File

@ -8,9 +8,19 @@ puts ""
restore [locate_data_file OCC22194-sh.brep] s
restore [locate_data_file OCC22194-pl.brep] pl
section r s pl
explode r
explode s F
splitshape result s s_1 r_1 s_5 r_2 s_13 r_3 s_22 r_4 s_31 r_5 s_39 r_6 s_46 r_7 s_51 r_8 s_68 r_9 s_90 r_10 s_112 r_11 s_133 r_12 s_143 r_13 s_146 r_14 s_151 r_15 s_161 r_16 s_176 r_17 s_183 r_18 s_201 r_19 s_213 r_20 s_213 r_21 s_235 r_22 s_257 r_23 s_270 r_24 s_285 r_25 s_300 r_26 s_314 r_27
bsection r s pl
savehistory sec_hist
set sections {}
foreach f [explode s f] {
if {![regexp "No shapes" [generated g_$f sec_hist $f]]} {
puts "$f g_$f"
lappend sections $f g_$f
}
}
eval splitshape result s $sections
checkprops result -s 24041.4
checknbshapes result -face 352
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@ -9,7 +9,7 @@ checkshape shape1
restore [locate_data_file OCC254-3.brep] shape3
checkshape shape3
common result shape1 shape3
bsection result shape1 shape3
checkshape result
checkprops result -l 1194.29

View File

@ -60,7 +60,7 @@ for {set a 1} {$a <= 6} {incr a} {
BuildNamedShape D [set TestLab]:3:$a PRIMITIVE b_$a
}
cut c p b
bcut c p b
BuildNamedShape D [set TestLab]:4 MODIFY p c
explode c F
set needgenerate ""
@ -92,7 +92,7 @@ BuildNamedShape D [set TestLab]:4:1 MODIFY [lindex $needgenerate 0] [lindex $nee
BuildNamedShape D [set TestLab]:4:2 GENERATED [lindex $needmodify 0] [lindex $needmodify 1] [lindex $needmodify 2] [lindex $needmodify 3] b_1 b_1
#################### test TNamig_Tool::NamedShape command ####################
set names "e1 e2 e3 p p_1 p_2 p_3 p_5 b b_1 b_2 b_3 b_4 b_5 b_6 c c_1 c_2 c_3 c_5 c_6 c_7 c_8 c_9 c_10"
set names "e1 e2 e3 p p_1 p_2 p_3 p_5 b b_1 b_2 b_3 b_4 b_5 b_6 c c_1 c_5 c_4 c_3 c_6 c_10 c_7 c_9 c_8"
set entities "1:1 1:2 1:3 2 2:1 2:1 2:1 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:1 4:2 4:1 4:1 4:1 4:2 2:3 4:1"
for {set i 0} {[string compare [lindex $names $i] ""] != 0} {incr i} {
@ -106,8 +106,8 @@ for {set i 0} {[string compare [lindex $names $i] ""] != 0} {incr i} {
}
#################### test TNaming_Tool::CurrentShape command ####################
set entities "1 1:1 1:2 1:3 2 2:1 2:2 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:2"
# rem: f p_4 c_4 are same, p_5 c_9 are same
set names "c_4 e1 e2 e3 c # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #"
# rem: f p_4 c_2 are same, p_5 c_9 are same
set names "c_2 e1 e2 e3 c # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #"
for {set i 0} {[string compare [lindex $entities $i] ""] != 0} {incr i} {
CurrentShape D "[set TestLab]:[lindex $entities $i]" r
@ -127,8 +127,8 @@ for {set i 0} {[string compare [lindex $entities $i] ""] != 0} {incr i} {
#################### test TNaming_Tool::GetShape command ####################
set entities "1 1:1 1:2 1:3 2 2:1 2:2 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:2"
# rem: f p_4 c_4 are same, p_5 c_9 are same
set names "c_4 e1 e2 e3 p # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #"
# rem: f p_4 c_2 are same, p_5 c_9 are same
set names "c_2 e1 e2 e3 p # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #"
for {set i 0} {[string compare [lindex $entities $i] ""] != 0} {incr i} {
GetShape D "[set TestLab]:[lindex $entities $i]" r

View File

@ -6,7 +6,7 @@ puts ""
pload MODELING VISUALIZATION
box b -5 -5 -5 10 10 10
psphere s 6
fuse res2 s b
bfuse res2 s b
nurbsconvert result res2
vinit View1