mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +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:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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;
|
||||
}
|
@@ -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
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user