Patch for 6.7.1 version of OCCT.
RunParallel(me)
returns Boolean from Standard;
---Purpose: Returns the flag of parallel processing
-
+
fields
myAllocator : BaseAllocator from BOPCol is protected;
myErrorStatus : Integer from Standard is protected;
-- commercial license or contractual agreement.
class ArgumentAnalyzer from BOPAlgo
+ inherits Algo from BOPAlgo
---Purpose: check the validity of argument(s) for Boolean Operations
uses
Operation from BOPAlgo,
CheckStatus from BOPAlgo,
ShapeEnum from TopAbs,
- ListOfCheckResult from BOPAlgo
-
+ ListOfCheckResult from BOPAlgo,
+ DataMapOfShapeReal from BOPCol
+
is
Create
returns ArgumentAnalyzer;
+ ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_ArgumentAnalyzer();"
---Purpose: empty constructor
SetShape1(me: in out; TheShape: Shape from TopoDS);
-- TestMergeFace(me: out)
-- is protected;
+
+ SetFuzzyValue(me:out;
+ theFuzz : Real from Standard);
+ ---C++: inline
+ ---Purpose: Sets the additional tolerance
+
+ FuzzyValue(me)
+ returns Real from Standard;
+ ---C++: inline
+ ---Purpose: Returns the additional tolerance
+ UpdateTolerances(me:out);
+ ---Purpose: Updates the shapes tolerance values.
+
+ SetDefaultTolerances(me:out);
+ ---Purpose: Reverts the tolerance values for all entities to default values.
fields
myContinuityMode : Boolean from Standard;
myEmpty1,myEmpty2 : Boolean from Standard;
myResult : ListOfCheckResult from BOPAlgo;
-
-
+ myFuzzyValue : Real from Standard is protected;
+ myToleranceMap : DataMapOfShapeReal from BOPCol;
+
end ArgumentAnalyzer;
#include <Standard_Failure.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
+
+#include <BRep_TVertex.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BOPInt_Context.hxx>
+#include <BOPTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_ListOfShape.hxx>
// purpose:
// ================================================================================
BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() :
+BOPAlgo_Algo(),
myStopOnFirst(Standard_False),
myOperation(BOPAlgo_UNKNOWN),
myArgumentTypeMode(Standard_False),
myMergeEdgeMode(Standard_False),
myContinuityMode(Standard_False),
myEmpty1(Standard_False),
-myEmpty2(Standard_False)
+myEmpty2(Standard_False),
+myFuzzyValue(0.)
// myMergeFaceMode(Standard_False)
{
}
+//=======================================================================
+// function: ~
+// purpose:
+//=======================================================================
+BOPAlgo_ArgumentAnalyzer::~BOPAlgo_ArgumentAnalyzer()
+{
+ myResult.Clear();
+ myToleranceMap.Clear();
+}
// ================================================================================
// function: SetShape1
Prepare();
+ UpdateTolerances();
+
if(myArgumentTypeMode) {
TestTypes();
}
aResult.SetCheckStatus(BOPAlgo_CheckUnknown);
myResult.Append(aResult);
}
+ //
+ SetDefaultTolerances();
}
// ================================================================================
// {
// not implemented
// }
+
+// ================================================================================
+// function: UpdateTolerances
+// purpose:
+// ================================================================================
+void BOPAlgo_ArgumentAnalyzer::UpdateTolerances()
+{
+ if (myFuzzyValue == 0.) {
+ return;
+ }
+ //
+ BOPCol_MapOfShape aMapShapes;
+ //
+ if (!myShape1.IsNull()) {
+ BOPTools::MapShapes(myShape1, aMapShapes);
+ }
+ if (!myShape2.IsNull()) {
+ BOPTools::MapShapes(myShape2, aMapShapes);
+ }
+ //
+ if (aMapShapes.IsEmpty()) {
+ return;
+ }
+ //
+ Standard_Real aTol, aFuzz;
+ TopAbs_ShapeEnum aType;
+ BOPCol_MapIteratorOfMapOfShape aIt;
+ //
+ aFuzz = myFuzzyValue / 2.;
+ aIt.Initialize(aMapShapes);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS = aIt.Value();
+ aType = aS.ShapeType();
+ //
+ switch (aType) {
+ case TopAbs_VERTEX: {
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
+ const Handle(BRep_TVertex)& TV =
+ *((Handle(BRep_TVertex)*)&aV.TShape());
+ aTol = TV->Tolerance();
+ myToleranceMap.Bind(aS, aTol);
+ TV->Tolerance(aTol + aFuzz);
+ break;
+ }
+ case TopAbs_EDGE: {
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
+ const Handle(BRep_TEdge)& TE =
+ *((Handle(BRep_TEdge)*)&aE.TShape());
+ aTol = TE->Tolerance();
+ myToleranceMap.Bind(aS, aTol);
+ TE->Tolerance(aTol + aFuzz);
+ break;
+ }
+ case TopAbs_FACE: {
+ const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
+ const Handle(BRep_TFace)& TF =
+ *((Handle(BRep_TFace)*)&aF.TShape());
+ aTol = TF->Tolerance();
+ myToleranceMap.Bind(aS, aTol);
+ TF->Tolerance(aTol + aFuzz);
+ break;
+ }
+ default:
+ break;
+ } // switch (aType) {
+ } // for (; aIt.More(); aIt.Next()) {
+}
+
+// ================================================================================
+// function: SetDefaultTolerances
+// purpose:
+// ================================================================================
+void BOPAlgo_ArgumentAnalyzer::SetDefaultTolerances()
+{
+ if (myFuzzyValue == 0.) {
+ return;
+ }
+ //
+ if (myToleranceMap.IsEmpty()) {
+ return;
+ }
+ //
+ Standard_Real aTol;
+ TopAbs_ShapeEnum aType;
+ BOPCol_DataMapIteratorOfDataMapOfShapeReal aIt;
+ //
+ aIt.Initialize(myToleranceMap);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS = aIt.Key();
+ aTol = aIt.Value();
+ aType = aS.ShapeType();
+ //
+ switch (aType) {
+ case TopAbs_VERTEX: {
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
+ const Handle(BRep_TVertex)& TV =
+ *((Handle(BRep_TVertex)*)&aV.TShape());
+ TV->Tolerance(aTol);
+ break;
+ }
+ case TopAbs_EDGE: {
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
+ const Handle(BRep_TEdge)& TE =
+ *((Handle(BRep_TEdge)*)&aE.TShape());
+ TE->Tolerance(aTol);
+ break;
+ }
+ case TopAbs_FACE: {
+ const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
+ const Handle(BRep_TFace)& TF =
+ *((Handle(BRep_TFace)*)&aF.TShape());
+ TF->Tolerance(aTol);
+ break;
+ }
+ default:
+ break;
+ } // switch (aType) {
+ } // for (; aIt.More(); aIt.Next()) {
+}
return myContinuityMode;
}
+//=======================================================================
+//function : SetFuzzyValue
+//purpose :
+//=======================================================================
+inline void BOPAlgo_ArgumentAnalyzer::SetFuzzyValue(const Standard_Real theFuzz)
+{
+ if (theFuzz > 0.) {
+ myFuzzyValue = theFuzz;
+ }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose :
+//=======================================================================
+inline Standard_Real BOPAlgo_ArgumentAnalyzer::FuzzyValue() const
+{
+ return myFuzzyValue;
+}
// inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode()
// {
// return myMergeFaceMode;
returns DataMapOfShapeListOfShape from BOPCol;
---C++: return const &
---Purpose: Returns mySplits.
+
+ SetFuzzyValue(me:out;
+ theFuzz : Real from Standard);
+ ---Purpose: Sets the additional tolerance
+
+ FuzzyValue(me)
+ returns Real from Standard;
+ ---Purpose: Returns the additional tolerance
fields
myArguments : ListOfShape from BOPCol is protected;
--
mySplits : DataMapOfShapeListOfShape from BOPCol is protected;
myOrigins : DataMapOfShapeShape from BOPCol is protected;
+
+ myFuzzyValue : Real from Standard is protected;
end Builder;
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
- myOrigins(100, myAllocator)
+ myOrigins(100, myAllocator),
+ myFuzzyValue(0.)
{
}
//=======================================================================
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
- myOrigins(100, myAllocator)
+ myOrigins(100, myAllocator),
+ myFuzzyValue(0.)
{
}
//=======================================================================
return myDS;
}
//=======================================================================
+//function : SetFuzzyValue
+//purpose :
+//=======================================================================
+void BOPAlgo_Builder::SetFuzzyValue(const Standard_Real theFuzz)
+{
+ if (theFuzz > 0.) {
+ myFuzzyValue = theFuzz;
+ }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose :
+//=======================================================================
+Standard_Real BOPAlgo_Builder::FuzzyValue() const
+{
+ return myFuzzyValue;
+}
+//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
//
pPF->SetArguments(myArguments);
+ pPF->SetFuzzyValue(myFuzzyValue);
//
pPF->Perform();
//
// 1. myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
+ myDS->SetFuzzyValue(myFuzzyValue);
myDS->Init();
//
// 2.myIterator
theSecAttr : SectionAttribute from BOPAlgo);
Perform(me:out)
- is redefined;
+ is redefined;
+
+ PerformInternal (me:out)
+ is virtual protected;
--
-- protected methods
--
---Purpose:
-- Updates pave blocks which have the paves with indices contained
-- in the map <theDMI>.
-
+
+ SetFuzzyValue(me:out;
+ theFuzz : Real from Standard);
+ ---Purpose: Sets the additional tolerance
+
+ FuzzyValue(me)
+ returns Real from Standard;
+ ---Purpose: Returns the additional tolerance
+
fields
myArguments : ListOfShape from BOPCol is protected;
myDS : PDS from BOPDS is protected;
myIterator : PIterator from BOPDS is protected;
myContext : Context from BOPInt is protected;
mySectionAttribute : SectionAttribute from BOPAlgo is protected;
+ myFuzzyValue : Real from Standard is protected;
end PaveFiller;
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
:
- BOPAlgo_Algo()
+ BOPAlgo_Algo(),
+ myFuzzyValue(0.)
{
myDS=NULL;
myIterator=NULL;
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
- BOPAlgo_Algo(theAllocator)
+ BOPAlgo_Algo(theAllocator),
+ myFuzzyValue(0.)
{
myDS=NULL;
myIterator=NULL;
return myArguments;
}
//=======================================================================
+//function : SetFuzzyValue
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::SetFuzzyValue(const Standard_Real theFuzz)
+{
+ if (theFuzz > 0.) {
+ myFuzzyValue = theFuzz;
+ }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose :
+//=======================================================================
+Standard_Real BOPAlgo_PaveFiller::FuzzyValue() const
+{
+ return myFuzzyValue;
+}
+//=======================================================================
// function: Init
// purpose:
//=======================================================================
// 1.myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
+ myDS->SetFuzzyValue(myFuzzyValue);
myDS->Init();
//
// 2.myIterator
try {
OCC_CATCH_SIGNALS
//
- Init();
- if (myErrorStatus) {
- return;
- }
- // 00
- PerformVV();
- if (myErrorStatus) {
- return;
- }
- // 01
- PerformVE();
- if (myErrorStatus) {
- return;
- }
- //
- myDS->UpdatePaveBlocks();
- // 11
- PerformEE();
- if (myErrorStatus) {
- return;
- }
- // 02
- PerformVF();
- if (myErrorStatus) {
- return;
- }
- // 12
- PerformEF();
- if (myErrorStatus) {
- return;
- }
- //
- MakeSplitEdges();
- if (myErrorStatus) {
- return;
- }
- //
- // 22
- PerformFF();
- if (myErrorStatus) {
- return;
- }
- //
- MakeBlocks();
- if (myErrorStatus) {
- return;
- }
- //
- RefineFaceInfoOn();
- //
- MakePCurves();
- if (myErrorStatus) {
- return;
- }
- //
- ProcessDE();
- if (myErrorStatus) {
- return;
- }
- } // try {
+ PerformInternal();
+ }
+ //
catch (Standard_Failure) {
myErrorStatus=11;
- }
+ }
+ //
+ myDS->SetDefaultTolerances();
+}
+//=======================================================================
+// function: PerformInternal
+// purpose:
+//=======================================================================
+void BOPAlgo_PaveFiller::PerformInternal()
+{
+ myErrorStatus=0;
+ //
+ Init();
+ if (myErrorStatus) {
+ return;
+ }
+ // 00
+ PerformVV();
+ if (myErrorStatus) {
+ return;
+ }
+ // 01
+ PerformVE();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ myDS->UpdatePaveBlocks();
+ // 11
+ PerformEE();
+ if (myErrorStatus) {
+ return;
+ }
+ // 02
+ PerformVF();
+ if (myErrorStatus) {
+ return;
+ }
+ // 12
+ PerformEF();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ MakeSplitEdges();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ // 22
+ PerformFF();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ MakeBlocks();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ RefineFaceInfoOn();
+ //
+ MakePCurves();
+ if (myErrorStatus) {
+ return;
+ }
+ //
+ ProcessDE();
+ if (myErrorStatus) {
+ return;
+ }
}
is
imported BaseAllocator from BOPCol;
- imported DataMapOfShapeInteger from BOPCol;
+ imported DataMapOfShapeInteger from BOPCol;
+ imported DataMapOfShapeReal from BOPCol;
imported MapOfInteger from BOPCol;
imported ListOfInteger from BOPCol;
imported PInteger from BOPCol;
--- /dev/null
+// Created by: Peter KURNEV
+// 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 BOPCol_DataMapOfShapeReal_HeaderFile
+#define BOPCol_DataMapOfShapeReal_HeaderFile
+
+#include <TopoDS_Shape.hxx>
+#include <TopTools_ShapeMapHasher.hxx>
+
+#include <NCollection_DataMap.hxx>
+
+typedef NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> BOPCol_DataMapOfShapeReal;
+typedef BOPCol_DataMapOfShapeReal::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeReal;
+
+#endif
BOPCol_BoxBndTree.cxx
BOPCol_Box2DBndTree.hxx
BOPCol_Box2DBndTree.cxx
+BOPCol_DataMapOfShapeReal.hxx
--
ListOfShape from BOPCol,
DataMapOfIntegerInteger from BOPCol,
+ DataMapOfIntegerReal from BOPCol,
DataMapOfShapeInteger from BOPCol,
ListOfInteger from BOPCol,
MapOfInteger from BOPCol,
---
BuildBndBoxSolid (me:out;
- theIndex:Integer from Standard;
- theBox:out Box from Bnd)
- is protected;
- ---Purpose:
- --- Computes bouding box <theBox> for the solid with DS-index <theIndex>
- ---
-
+ theIndex:Integer from Standard;
+ theBox:out Box from Bnd)
+ is protected;
+ ---Purpose:
+ -- Computes bouding box <theBox> for the solid with DS-index <theIndex>
+ SetFuzzyValue(me:out;
+ theFuzz : Real from Standard);
+ ---C++: inline
+ ---Purpose: Sets the extended tolerance
+
+ FuzzyValue(me)
+ returns Real from Standard;
+ ---C++: inline
+ ---Purpose: Returns the extended tolerance
+
+ SetDefaultTolerances(me:out);
+ ---Purpose: Reverts the tolerance values of unchanged entities to default values.
fields
myAllocator : BaseAllocator from BOPCol is protected;
myInterfEZ : VectorOfInterfEZ from BOPDS is protected;
myInterfFZ : VectorOfInterfFZ from BOPDS is protected;
myInterfZZ : VectorOfInterfZZ from BOPDS is protected;
+ --
+ -- extended tolerance for intersection
+ myFuzzyValue : Real from Standard is protected;
+ myToleranceMap : DataMapOfIntegerReal from BOPCol is protected;
+
end DS;
#include <gp_Pnt.hxx>
#include <Bnd_Box.hxx>
//
+#include <BRep_TVertex.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
+#include <BRep_Tool.hxx>
+//
#include <TopoDS_Shape.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
-#include <BRep_Tool.hxx>
//
#include <BRepBndLib.hxx>
//
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_DataMapOfShapeInteger.hxx>
+#include <BOPDS_PDS.hxx>
+#include <BOPCol_DataMapOfIntegerMapOfInteger.hxx>
//
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_ShapeInfo.hxx>
static
void SortShell(const int n, BOPDS_Pave *a);
+static
+ void AddShapeAndSubShapes(const Standard_Integer nS,
+ const BOPDS_ShapeInfo& theSI,
+ BOPCol_MapOfInteger& theMI);
+
+static
+ void CollectEdges(const BOPDS_PDS& pDS,
+ const Standard_Integer nF,
+ BOPCol_MapOfInteger& theMI);
+
//=======================================================================
//function :
//purpose :
myInterfVZ(myAllocator),
myInterfEZ(myAllocator),
myInterfFZ(myAllocator),
- myInterfZZ(myAllocator)
+ myInterfZZ(myAllocator),
+ myFuzzyValue(0.),
+ myToleranceMap(100, myAllocator)
{
myNbShapes=0;
myNbSourceShapes=0;
myInterfVZ(myAllocator),
myInterfEZ(myAllocator),
myInterfFZ(myAllocator),
- myInterfZZ(myAllocator)
+ myInterfZZ(myAllocator),
+ myFuzzyValue(0.),
+ myToleranceMap(100, myAllocator)
{
myNbShapes=0;
myNbSourceShapes=0;
{
myNbShapes=0;
myNbSourceShapes=0;
+ myFuzzyValue=0.;
//
myArguments.Clear();
myRanges.Clear();
myInterfEZ.Clear();
myInterfFZ.Clear();
myInterfZZ.Clear();
+ myToleranceMap.Clear();
}
//=======================================================================
//function : SetArguments
Bnd_Box& aBox=aSI.ChangeBox();
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
const gp_Pnt& aP=BRep_Tool::Pnt(aV);
- aTol=BRep_Tool::Tolerance(aV);
+ //
+ const Handle(BRep_TVertex)& TV =
+ *((Handle(BRep_TVertex)*)&aV.TShape());
+ aTol = TV->Tolerance();
+ //
+ myToleranceMap.Bind(j, aTol);
+ aTol += myFuzzyValue;
+ TV->Tolerance(aTol);
+ //
aBox.SetGap(aTol);
aBox.Add(aP);
}
if (aTS==TopAbs_EDGE) {
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
- aTol=BRep_Tool::Tolerance(aE);
+ //
+ const Handle(BRep_TEdge)& TE =
+ *((Handle(BRep_TEdge)*)&aE.TShape());
+ aTol = TE->Tolerance();
+ //
+ myToleranceMap.Bind(j, aTol);
+ aTol += myFuzzyValue;
+ TE->Tolerance(aTol);
//
if (!BRep_Tool::Degenerated(aE)) {
Standard_Boolean bInf1, bInf2;
if (aTS==TopAbs_FACE) {
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
- aTol=BRep_Tool::Tolerance(aF);
+ //
+ const Handle(BRep_TFace)& TF =
+ *((Handle(BRep_TFace)*)&aF.TShape());
+ aTol = TF->Tolerance();
+ //
+ myToleranceMap.Bind(j, aTol);
+ aTol += myFuzzyValue;
+ TF->Tolerance(aTol);
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aS, aBox);
}
}
}
+
+//=======================================================================
+//function : DefaultTolerances
+//purpose :
+//=======================================================================
+void BOPDS_DS::SetDefaultTolerances()
+{
+ if (myFuzzyValue == 0.) {
+ return;
+ }
+ //
+ Standard_Boolean bAdd;
+ Standard_Integer i, j, n1, n2, nS, nSOp, nSs;
+ Standard_Integer anIntType, aNbFF, aNbFIn;
+ Standard_Real aTolDef;
+ TopAbs_ShapeEnum aTS1, aTS2;
+ BOPCol_MapOfInteger aMICh;
+ BOPCol_DataMapOfIntegerMapOfInteger aDMI;
+ BOPCol_ListIteratorOfListOfInteger aItLI;
+ BOPDS_MapIteratorMapOfPassKey aItPK;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+ BOPCol_MapIteratorOfMapOfInteger aItMI;
+ BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItDMIR;
+ //
+ // 1. Collect interfered shapes
+ // 1.1. Interferences V/V, V/E, V/F, E/E and E/F
+ aItPK.Initialize(myInterfTB);
+ for (; aItPK.More(); aItPK.Next()) {
+ const BOPDS_PassKey& aPK = aItPK.Value();
+ aPK.Ids(n1, n2);
+ //
+ const BOPDS_ShapeInfo& aSI1 = ShapeInfo(n1);
+ const BOPDS_ShapeInfo& aSI2 = ShapeInfo(n2);
+ //
+ aTS1 = aSI1.ShapeType();
+ aTS2 = aSI2.ShapeType();
+ //
+ anIntType = BOPDS_Tools::TypeToInteger(aTS1, aTS2);
+ if (anIntType < 5) {
+ AddShapeAndSubShapes(n1, aSI1, aMICh);
+ AddShapeAndSubShapes(n2, aSI2, aMICh);
+ } // if (anIntType < 5) {
+ } // for (; aIt.More(); aIt.Next()) {
+ //
+ // 1.2 FaceInfo information
+ aNbFF = myFaceInfoPool.Extent();
+ for (i = 0; i < aNbFF; ++i) {
+ const BOPDS_FaceInfo& aFI = myFaceInfoPool(i);
+ nS = aFI.Index();
+ if (aMICh.Contains(nS)) {
+ continue;
+ }
+ //
+ aNbFIn = (aFI.PaveBlocksIn().Extent() +
+ aFI.VerticesIn().Extent() +
+ aFI.PaveBlocksSc().Extent() +
+ aFI.VerticesSc().Extent());
+ if (aNbFIn > 0) {
+ AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
+ } // if (aNbFIn > 0) {
+ } // for (i = 0; i < aNbFF; ++i) {
+ //
+ // 1.3. Empty F/F interferences
+ aNbFF = myInterfFF.Extent();
+ for (i = 0; i < aNbFF; ++i) {
+ BOPDS_InterfFF& aFF = myInterfFF(i);
+ if ((aFF.Curves().Extent() == 0) &&
+ (aFF.Points().Extent() == 0)) {
+ aFF.Indices(n1, n2);
+ for (j = 0; j < 2; ++j) {
+ nS = !j ? n1 : n2;
+ if (aMICh.Contains(nS)) {
+ continue;
+ }
+ nSOp = !j ? n2 : n1;
+ //
+ BOPCol_MapOfInteger aME, aMEOp;
+ //
+ if (aDMI.IsBound(nS)) {
+ aME = aDMI.Find(nS);
+ } else {
+ CollectEdges(this, nS, aME);
+ aDMI.Bind(nS, aME);
+ }
+ //
+ if (aDMI.IsBound(nSOp)) {
+ aMEOp = aDMI.Find(nSOp);
+ } else {
+ CollectEdges(this, nSOp, aMEOp);
+ aDMI.Bind(nSOp, aMEOp);
+ }
+ //
+ bAdd = Standard_True;
+ aItMI.Initialize(aME);
+ for (; aItMI.More(); aItMI.Next()) {
+ nSs = aItMI.Value();
+ if (!aMEOp.Contains(nSs)) {
+ bAdd = Standard_False;
+ break;
+ }
+ }
+ //
+ if (bAdd) {
+ AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
+ if (j == 0) {
+ AddShapeAndSubShapes(nSOp, ShapeInfo(nSOp), aMICh);
+ }
+ } // if (bAdd) {
+ } // for (j = 0; j < 2; ++j) {
+ } //if ((aFF.Curves().Extent() == 0) &&
+ } // for (i = 0; i < aNbFF; ++i) {
+ //
+ // 2. Back to default tolerance values
+ aItDMIR.Initialize(myToleranceMap);
+ for (; aItDMIR.More(); aItDMIR.Next()) {
+ i = aItDMIR.Key();
+ //
+ if (aMICh.Contains(i)) {
+ continue;
+ }
+ //
+ const BOPDS_ShapeInfo& aSI = ShapeInfo(i);
+ aTolDef = aItDMIR.Value();
+ aTS1 = aSI.ShapeType();
+ switch (aTS1) {
+ case TopAbs_VERTEX: {
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSI.Shape();
+ const Handle(BRep_TVertex)& aTV =
+ *((Handle(BRep_TVertex)*)&aV.TShape());
+ aTV->Tolerance(aTolDef);
+ break;
+ }
+ case TopAbs_EDGE: {
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSI.Shape();
+ const Handle(BRep_TEdge)& aTE =
+ *((Handle(BRep_TEdge)*)&aE.TShape());
+ aTE->Tolerance(aTolDef);
+ //
+ const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(i);
+ aItPB.Initialize(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
+ nS = aPB->Edge();
+ const TopoDS_Edge& aEIm = *(TopoDS_Edge*)&Shape(nS);
+ const Handle(BRep_TEdge)& aTEIm =
+ *((Handle(BRep_TEdge)*)&aEIm.TShape());
+ aTEIm->Tolerance(aTolDef);
+ }
+ break;
+ }
+ case TopAbs_FACE: {
+ const TopoDS_Face& aF = *(TopoDS_Face*)&aSI.Shape();
+ const Handle(BRep_TFace)& aTF =
+ *((Handle(BRep_TFace)*)&aF.TShape());
+ aTF->Tolerance(aTolDef);
+ break;
+ }
+ default:
+ break;
+ } // switch (aTS1) {
+ } // for (; aItDMIR.More(); aItDMIR.Next()) {
+}
+
+//=======================================================================
+//function : AddShapeAndSubShapes
+//purpose :
+//=======================================================================
+void AddShapeAndSubShapes(const Standard_Integer nS,
+ const BOPDS_ShapeInfo& theSI,
+ BOPCol_MapOfInteger& theMI)
+{
+ Standard_Integer nSs;
+ if (theMI.Add(nS)) {
+ const BOPCol_ListOfInteger& aLI = theSI.SubShapes();
+ BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
+ for (; aItLI.More(); aItLI.Next()) {
+ nSs = aItLI.Value();
+ theMI.Add(nSs);
+ }
+ }
+}
+
+//=======================================================================
+//function : CollectEdges
+//purpose :
+//=======================================================================
+void CollectEdges(const BOPDS_PDS& pDS,
+ const Standard_Integer nF,
+ BOPCol_MapOfInteger& theMI)
+{
+ Standard_Integer i, j, aNbPB, nE, nEIm;
+ BOPCol_ListIteratorOfListOfInteger aItLI;
+ BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
+ //
+ // ON edges
+ const BOPDS_ShapeInfo& aSI = pDS->ShapeInfo(nF);
+ const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
+ aItLI.Initialize(aLI);
+ for (; aItLI.More(); aItLI.Next()) {
+ nE = aItLI.Value();
+ const BOPDS_ShapeInfo& aSIE = pDS->ShapeInfo(nE);
+ if (aSIE.ShapeType() != TopAbs_EDGE) {
+ continue;
+ }
+ //
+ if (!aSIE.HasReference()) {
+ theMI.Add(nE);
+ continue;
+ }
+ //
+ const BOPDS_ListOfPaveBlock& aLPB = pDS->PaveBlocks(nE);
+ aItLPB.Initialize(aLPB);
+ for (; aItLPB.More(); aItLPB.Next()) {
+ const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
+ nEIm = aPB->Edge();
+ theMI.Add(nEIm);
+ }
+ }
+ // IN and SC edges
+ const BOPDS_FaceInfo& aFI = pDS->FaceInfo(nF);
+ const BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.PaveBlocksIn();
+ const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
+ //
+ for (i = 0; i < 2; ++i) {
+ const BOPDS_IndexedMapOfPaveBlock& aMPB = !i ? aMPBIn : aMPBSc;
+ aNbPB = aMPB.Extent();
+ for (j = 1; j <= aNbPB; ++j) {
+ const Handle(BOPDS_PaveBlock)& aPB = aMPB(j);
+ nE = aPB->Edge();
+ theMI.Add(nE);
+ }
+ }
+}
//purpose :
//=======================================================================
inline void BOPDS_DS::AddInterf(const Standard_Integer theI1,
- const Standard_Integer theI2)
+ const Standard_Integer theI2)
{
BOPDS_PassKey aPK;
//
{
return myInterfTB;
}
+//=======================================================================
+//function : SetFuzzyValue
+//purpose :
+//=======================================================================
+inline void BOPDS_DS::SetFuzzyValue(const Standard_Real theFuzz)
+{
+ if (theFuzz > 0.) {
+ myFuzzyValue = theFuzz / 2.;
+ }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose :
+//=======================================================================
+inline Standard_Real BOPDS_DS::FuzzyValue() const
+{
+ return 2 * myFuzzyValue;
+}
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Section.hxx>
+#include <TopoDS_Iterator.hxx>
//
static BOPAlgo_PaveFiller* pPF=NULL;
const char* g = "BOP commands";
// Commands
- theCommands.Add("bop" , "use bop s1 s2" , __FILE__, bop, g);
+ theCommands.Add("bop" , "use bop s1 s2 [tol]" , __FILE__, bop, g);
theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g);
theCommands.Add("bopfuse" , "use bopfuse r" , __FILE__,bopfuse, g);
- theCommands.Add("bopcut" , "use bopcut" , __FILE__,bopcut, g);
- theCommands.Add("boptuc" , "use boptuc" , __FILE__,boptuc, g);
- theCommands.Add("bopsection", "use bopsection" , __FILE__,bopsection, g);
- //
- theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g);
- theCommands.Add("bfuse" , "use bfuse r s1 s2" , __FILE__,bfuse, g);
- theCommands.Add("bcut" , "use bcut r s1 s2" , __FILE__,bcut, g);
- theCommands.Add("btuc" , "use btuc r s1 s2" , __FILE__,btuc, g);
- theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]",
+ theCommands.Add("bopcut" , "use bopcut r" , __FILE__,bopcut, g);
+ theCommands.Add("boptuc" , "use boptuc r" , __FILE__,boptuc, g);
+ theCommands.Add("bopsection", "use bopsection r" , __FILE__,bopsection, g);
+ //
+ theCommands.Add("bcommon" , "use bcommon r s1 s2 [tol]" , __FILE__,bcommon, g);
+ theCommands.Add("bfuse" , "use bfuse r s1 s2 [tol]" , __FILE__,bfuse, g);
+ theCommands.Add("bcut" , "use bcut r s1 s2 [tol]" , __FILE__,bcut, g);
+ theCommands.Add("btuc" , "use btuc r s1 s2 [tol]" , __FILE__,btuc, g);
+ theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d]", __FILE__, bopcurves, g);
{
char buf[32];
Standard_Integer iErr;
+ Standard_Real aTol;
TopoDS_Shape aS1, aS2;
BOPCol_ListOfShape aLC;
//
- if (n!=3) {
- di << " use bop Shape1 Shape2\n";
+ if (n < 3 || n > 4) {
+ di << " use bop Shape1 Shape2 [tol]\n";
return 1;
}
//
return 1;
}
//
+ aTol = 0.;
+ if (n == 4) {
+ aTol = Draw::Atof(a[3]);
+ }
+ //
aLC.Append(aS1);
aLC.Append(aS2);
//
pPF=new BOPAlgo_PaveFiller(aAL);
//
pPF->SetArguments(aLC);
+ pPF->SetFuzzyValue(aTol);
//
pPF->Perform();
iErr=pPF->ErrorStatus();
const BOPAlgo_Operation aOp)
{
if (n<2) {
- di << " use bopsmt r\n";
+ di << " use bopsmt r\n [tol]";
return 0;
}
//
Standard_Integer n,
const char** a)
{
- const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na]\n";
+ const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n";
if (n < 4) {
di << usage;
return 1;
}
-
+ //
TopoDS_Shape aS1 = DBRep::Get(a[2]);
TopoDS_Shape aS2 = DBRep::Get(a[3]);
-
+ //
if (aS1.IsNull() || aS2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
-
+ //
Standard_Boolean bApp, bPC1, bPC2;
+ Standard_Integer i;
+ Standard_Real aTol;
//
bApp = Standard_True;
bPC1 = Standard_True;
bPC2 = Standard_True;
-
- Standard_Boolean isbadparameter = Standard_False;
-
- if(n > 4) {
- const char* key1 = a[4];
- const char* key2 = (n > 5) ? a[5] : NULL;
- const char* pcurveconf = NULL;
-
- if (key1 && (!strcasecmp(key1,"-n2d") || !strcasecmp(key1,"-n2d1") || !strcasecmp(key1,"-n2d2"))) {
- pcurveconf = key1;
+ aTol = 0.;
+ //
+ for (i = 4; i < n; ++i) {
+ if (!strcmp(a[i], "-n2d")) {
+ bPC1 = Standard_False;
+ bPC2 = Standard_False;
}
- else {
- if (!strcasecmp(key1,"-na")) {
- bApp = Standard_False;
- }
- else {
- isbadparameter = Standard_True;
- }
+ else if (!strcmp(a[i], "-n2d1")) {
+ bPC1 = Standard_False;
}
- if (key2) {
- if(!strcasecmp(key2,"-na")) {
- bApp = Standard_False;
- }
- else {
- isbadparameter = Standard_True;
- }
+ else if (!strcmp(a[i], "-n2d2")) {
+ bPC2 = Standard_False;
}
-
- if(!isbadparameter && pcurveconf) {
- if (!strcasecmp(pcurveconf, "-n2d1")) {
- bPC1 = Standard_False;
+ else if (!strcmp(a[i], "-na")) {
+ bApp = Standard_False;
}
else {
- if (!strcasecmp(pcurveconf, "-n2d2")) {
- bPC2 = Standard_False;
- }
- else {
- if (!strcasecmp(pcurveconf, "-n2d")) {
- bPC1 = Standard_False;
- bPC2 = Standard_False;
- }
- }
+ aTol = Draw::Atof(a[i]);
}
}
- }
-
- if(!isbadparameter) {
- Standard_Integer iErr;
- char buf[80];
- //
- BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
- aSec.Approximation(bApp);
- aSec.ComputePCurveOn1(bPC1);
- aSec.ComputePCurveOn2(bPC2);
- //
- aSec.Build();
- iErr=aSec.ErrorStatus();
- if (!aSec.IsDone()) {
- Sprintf(buf, " ErrorStatus : %d\n", iErr);
- di << buf;
- return 0;
- }
- //
- const TopoDS_Shape& aR=aSec.Shape();
- if (aR.IsNull()) {
- di << " null shape\n";
- return 0;
- }
- DBRep::Set(a[1], aR);
+ //
+ Standard_Integer iErr;
+ char buf[80];
+ //
+ BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
+ aSec.Approximation(bApp);
+ aSec.ComputePCurveOn1(bPC1);
+ aSec.ComputePCurveOn2(bPC2);
+ aSec.SetFuzzyValue(aTol);
+ //
+ aSec.Build();
+ iErr=aSec.ErrorStatus();
+ if (!aSec.IsDone()) {
+ Sprintf(buf, " ErrorStatus : %d\n", iErr);
+ di << buf;
return 0;
}
- else {
- di << usage;
- return 1;
+ //
+ const TopoDS_Shape& aR=aSec.Shape();
+ if (aR.IsNull()) {
+ di << " null shape\n";
+ return 0;
}
+ DBRep::Set(a[1], aR);
+ return 0;
}
+
//=======================================================================
//function : bsmt
//purpose :
Standard_Integer iErr;
TopoDS_Shape aS1, aS2;
BOPCol_ListOfShape aLC;
+ Standard_Real aTol;
//
- if (n!=4) {
- di << " use bx r s1 s2\n";
+ if (n < 4 || n > 5) {
+ di << " use bx r s1 s2 [tol]\n";
return 1;
}
//
di << " null shapes are not allowed \n";
return 1;
}
+ //
+ aTol = 0.;
+ if (n == 5) {
+ aTol = Draw::Atof(a[4]);
+ }
+ //
aLC.Append(aS1);
aLC.Append(aS2);
//
BOPAlgo_PaveFiller aPF(aAL);
//
aPF.SetArguments(aLC);
+ aPF.SetFuzzyValue(aTol);
//
aPF.Perform();
iErr=aPF.ErrorStatus();
(Draw_Interpretor& di, Standard_Integer n, const char** a )
{
if (n<2) {
- di << " Use >bopcheck Shape [level of check: 0 - 9" << "\n";
+ di << " Use >bopcheck Shape [level of check: 0 - 9] [-tol tol]" << "\n";
di << " The level of check defines ";
di << " which interferences will be checked:\n";
di << " 0 - V/V only\n";
return 1;
}
//
- Standard_Integer theLevelOfCheck, aNbInterfTypes;
+ Standard_Integer theLevelOfCheck, aNbInterfTypes, iTol;
+ Standard_Boolean bLevel;
+ Standard_Real aTolerance;
//
aNbInterfTypes=BOPDS_DS::NbInterfTypes();
//
- theLevelOfCheck = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1;
- if (theLevelOfCheck > aNbInterfTypes-1) {
+ aTolerance = 0.;
+ bLevel = Standard_False;
+ theLevelOfCheck = aNbInterfTypes-1;
+ if (n > 2) {
+ if (a[2][0] != '-') {
+ theLevelOfCheck = Draw::Atoi(a[2]);
+ bLevel = Standard_True;
+ }
+ //
+ iTol = bLevel ? 3 : 2;
+ if (iTol + 1 < n) {
+ if (!strcmp(a[iTol], "-tol")) {
+ aTolerance = Draw::Atof(a[iTol+1]);
+ }
+ }
+ }
+ if (theLevelOfCheck < 0 || theLevelOfCheck > aNbInterfTypes-1) {
di << "Invalid level";
return 1;
}
anArgs.Append(aS);
aChecker.SetArguments(anArgs);
aChecker.SetLevelOfCheck(theLevelOfCheck);
+ aChecker.SetFuzzyValue(aTolerance);
//
aChecker.Perform();
iErr = aChecker.ErrorStatus();
if (n<2) {
di << "\n";
di << " Use >bopargcheck Shape1 [[Shape2] ";
- di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n";
+ di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF] [-tol tol]" << "\n" << "\n";
di << " -<Boolean Operation>" << "\n";
di << " F (fuse)" << "\n";
di << " O (common)" << "\n";
Standard_Integer indxAD = 0;
Standard_Boolean isS2 = Standard_False;
Standard_Integer indxS2 = 0;
+ Standard_Real aTolerance = 0;
if(n >= 3) {
Standard_Integer iIndex = 0;
for(iIndex = 2; iIndex < n; iIndex++) {
- if(a[iIndex][0] == '-')
+ if(!strcmp(a[iIndex], "-tol"))
+ {
+ if ((iIndex+1) < n) {
+ ++iIndex;
+ aTolerance = Draw::Atof(a[iIndex]);
+ }
+ }
+ else if(a[iIndex][0] == '-')
{
isBO = Standard_True;
indxBO = iIndex;
// init checker
BOPAlgo_ArgumentAnalyzer aChecker;
+ aChecker.SetFuzzyValue(aTolerance);
aChecker.SetShape1(aS1);
// set default options (always tested!) for single and couple shapes
// Chapter's name
const char* g = "Partition commands";
// Commands
- theCommands.Add("bfillds" , "use bfillds [-s -t]" , __FILE__, bfillds, g);
- theCommands.Add("bbuild" , "use bbuild r [-s -t]", __FILE__, bbuild, g);
- theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
- theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
+ theCommands.Add("bfillds" , "use bfillds [-s -t] [tol]" , __FILE__, bfillds, g);
+ theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
+ theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
+ theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
}
//=======================================================================
Standard_Integer n,
const char** a)
{
- if (n>3) {
- di << " use bfillds [-s -t]\n";
+ if (n > 4) {
+ di << " use bfillds [-s -t] [tol]\n";
return 0;
}
//
char buf[32];
Standard_Boolean bRunParallel, bShowTime;
Standard_Integer i, aNbS, iErr;
+ Standard_Real aTol;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_ListOfShape aLC;
BOPTime_Chronometer aChrono;
return 0;
}
//
- bShowTime=Standard_False;
- bRunParallel=Standard_True;
+ bShowTime = Standard_False;
+ bRunParallel = Standard_True;
+ aTol = 0.;
for (i=1; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
else if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
+ else {
+ aTol = Draw::Atof(a[i]);
+ }
}
//
BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
//
aPF.SetArguments(aLC);
aPF.SetRunParallel(bRunParallel);
+ aPF.SetFuzzyValue(aTol);
//
aChrono.Start();
//
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+
+#include <Geom2dAdaptor.hxx>
#include <Geom_Curve.hxx>
-#include <GeomAdaptor_HCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_HCurve.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <GeomProjLib.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <BRep_Tool.hxx>
-#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+
#include <BRepAdaptor_HSurface.hxx>
+
#include <BRepAdaptor_Curve.hxx>
-#include <BRep_Builder.hxx>
#include <BRepAdaptor_Surface.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <BRep_Builder.hxx>
-#include <Geom_Surface.hxx>
-#include <BOPCol_IndexedMapOfShape.hxx>
-#include <BOPTools.hxx>
#include <BRepClass_FaceClassifier.hxx>
+#include <BRepTools.hxx>
+
+#include <BOPCol_IndexedMapOfShape.hxx>
+
+#include <BOPTools.hxx>
+#include <IntTools_Tools.hxx>
+#include <gp_Cylinder.hxx>
+#include <TopExp_Explorer.hxx>
+#include <GeomInt.hxx>
static
- Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E);
+ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
+
+static
+ Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& ,
+ const TopoDS_Face& ,
+ Standard_Real& ,
+ Standard_Real& ,
+ Standard_Boolean& );
+static
+ Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& ,
+ const Handle(Geom_Surface)& ,
+ const TopLoc_Location& ,
+ Standard_Real& ,
+ Standard_Real& ,
+ Standard_Boolean& );
+static
+ Standard_Real MaxToleranceEdge (const TopoDS_Face& );
//=======================================================================
//function : BuildPCurveForEdgeOnFace
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF)
{
BRep_Builder aBB;
Handle(Geom2d_Curve) aC2D;
Standard_Real aTolPC, aTolFact, aTolEdge, aFirst, aLast;
Standard_Boolean aHasOld;
- aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, aC2D, aFirst, aLast, aTolEdge);
+ aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, aC2D,
+ aFirst, aLast,
+ aTolEdge);
if (aHasOld) {
return;
}
//function : EdgeTangent
//purpose :
//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent(const TopoDS_Edge& anEdge,
- const Standard_Real aT,
- gp_Vec& aTau)
+Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent
+ (const TopoDS_Edge& anEdge,
+ const Standard_Real aT,
+ gp_Vec& aTau)
{
Standard_Boolean isdgE;
Standard_Real first, last;
//function : PointOnOnSurface
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- const Standard_Real aParameter,
- Standard_Real& U,
- Standard_Real& V)
+void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF,
+ const Standard_Real aParameter,
+ Standard_Real& U,
+ Standard_Real& V)
{
gp_Pnt2d aP2D;
Handle(Geom2d_Curve) aC2D;
Standard_Real aToler, aFirst, aLast;
- BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler);
+ BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D,
+ aFirst, aLast, aToler);
aC2D->D0(aParameter, aP2D);
U=aP2D.X();
V=aP2D.Y();
//function : CurveOnSurface
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& aToler)
{
Standard_Real aFirst, aLast;
-
- BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler);
-
+ //
+ BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D,
+ aFirst, aLast, aToler);
+ //
return;
}
//=======================================================================
//function : CurveOnSurface
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aFirst,
- Standard_Real& aLast,
- Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& aFirst,
+ Standard_Real& aLast,
+ Standard_Real& aToler)
{
Standard_Boolean aHasOld;
Handle(Geom2d_Curve) C2D;
- aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, C2D, aFirst, aLast, aToler);
+ aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, C2D,
+ aFirst, aLast,
+ aToler);
if (aHasOld) {
aC2D=C2D;
return;
aC2D=C2D;
return;
}
-
//=======================================================================
//function : HasCurveOnSurface
//purpose :
//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aFirst,
- Standard_Real& aLast,
- Standard_Real& aToler)
+Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface
+ (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& aFirst,
+ Standard_Real& aLast,
+ Standard_Real& aToler)
{
Standard_Boolean aHasOld;
return Standard_False;
}
- aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+ aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
aHasOld=!aC2D.IsNull();
return aHasOld;
}
//function : HasCurveOnSurface
//purpose :
//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
+Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface
+ (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF)
{
- Standard_Boolean aHasOld;
+ Standard_Boolean bHasOld;
Handle(Geom2d_Curve) aC2D;
Standard_Real aFirst, aLast;
+ //
BRep_Tool::Range(aE, aFirst, aLast);
-
+ //
if((aLast - aFirst) < Precision::PConfusion()) {
return Standard_False;
}
-
- aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
- aHasOld=!aC2D.IsNull();
- return aHasOld;
+ //
+ aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+ bHasOld=!aC2D.IsNull();
+ //
+ return bHasOld;
}
-
//=======================================================================
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
- const Handle(Geom_Curve)& aC3D,
- const Handle(Geom2d_Curve)& aC2D,
- Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace
+ (const TopoDS_Face& aF,
+ const Handle(Geom_Curve)& aC3D,
+ const Handle(Geom2d_Curve)& aC2D,
+ Handle(Geom2d_Curve)& aC2DA)
{
Standard_Real first, last;
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
- const Standard_Real aFirst,
- const Standard_Real aLast,
- const Handle(Geom2d_Curve)& aC2D,
- Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace
+ (const TopoDS_Face& aF,
+ const Standard_Real aFirst,
+ const Standard_Real aLast,
+ const Handle(Geom2d_Curve)& aC2D,
+ Handle(Geom2d_Curve)& aC2DA)
{
- Standard_Boolean mincond, maxcond, decalu, decalv;
- Standard_Integer k, iCnt;
+ Standard_Boolean mincond, maxcond;
Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta;
- Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx;
+ Standard_Real aUPeriod;
//
aDelta=Precision::PConfusion();
u2 = pC2D.X();
v2 = pC2D.Y();
-
+ //
+ // du
du = 0.;
if (aBAS.IsUPeriodic()) {
- aUPeriod=aBAS.UPeriod();
- mincond = (u2 < UMin-aDelta);
- maxcond = (u2 > UMax+aDelta);
-
- decalu = mincond || maxcond;
- if (decalu) {
- //du = ( mincond ) ? UPeriod : -UPeriod;
- //
- iCnt=1;
- aUP2=aUPeriod+aUPeriod+aDelta;
- aUP1=aUPeriod+aDelta;
- //
- if (u2 > aUP2) {
- k=1;
- do {
- aUx=u2-k*aUPeriod;
- iCnt = k++;
- } while (aUx >= aUP1);
- }
- else if (u2 < -aUP2) {
- k=1;
- do {
- aUx=u2+k*aUPeriod;
- iCnt = (k++) + 1;
- } while (aUx <= -aUP1);
- }
- du = ( mincond ) ? aUPeriod : -aUPeriod;
- du=iCnt*du;
+ aUPeriod = aBAS.UPeriod();
+ //
+ // a. try to clarify u2 using the precision (aDelta)
+ if (fabs(u2-UMin) < aDelta) {
+ u2=UMin;
}
+ else if (fabs(u2-UMin-aUPeriod) < aDelta) {
+ u2=UMin+aUPeriod;
+ }
+ // b. compute du again using clarified value of u2
+ GeomInt::AdjustPeriodic(u2, UMin, UMax, aUPeriod, u2, du, 0.);
//
- aUNew=u2+du;
- if (aUNew<(UMin-aDelta) ||
- aUNew>(UMax+aDelta)) {
- // So previous correction was wrong.
- // Try to be closer to UMin or UMax.
- du=0.;
- if (u2>UMax){
- aDif=u2-UMax;
- if (aDif < 4.e-7) {
- du=-aDif;
+ if (du==0.) {
+ if (aBAS.GetType()==GeomAbs_Cylinder) {
+ Standard_Real aR, dFi, aTol;
+ //
+ gp_Cylinder aCylinder=aBAS.Cylinder();
+ aR=aCylinder.Radius();
+ aTol=MaxToleranceEdge(aF);
+ dFi=aTol/aR;
+ if (dFi<aDelta) {
+ dFi=aDelta;
+ }
+ //
+ mincond = (UMin - u2 > dFi);
+ maxcond = (u2 - UMax > dFi);
+ if (mincond || maxcond) {
+ du = ( mincond ) ? aUPeriod : -aUPeriod;
}
}
- }
- } // if (BAHS->IsUPeriodic())
- //
+ }
+ }
+
// dv
dv = 0.;
if (aBAS.IsVPeriodic()) {
Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr;
//
- aVPeriod=aBAS.VPeriod();
+ aVPeriod = aBAS.VPeriod();
mincond = (VMin - v2 > aDelta);
maxcond = (v2 - VMax > aDelta);
- decalv = mincond || maxcond;
- if (decalv) {
+ //
+ if (mincond || maxcond) {
dv = ( mincond ) ? aVPeriod : -aVPeriod;
}
//
- //xf
if ((VMax-VMin<aVPeriod) && dv) {
aVm=v2;
aVr=v2+dv;
dv=0.;
}
}
- //xt
}
//
{
//function : IntermediatePoint
//purpose :
//=======================================================================
- Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const Standard_Real aFirst,
- const Standard_Real aLast)
+Standard_Real BOPTools_AlgoTools2D::IntermediatePoint
+ (const Standard_Real aFirst,
+ const Standard_Real aLast)
{
//define parameter division number as 10*e^(-PI) = 0.43213918
const Standard_Real PAR_T = 0.43213918;
//function : IntermediatePoint
//purpose :
//=======================================================================
- Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const TopoDS_Edge& aE)
+Standard_Real BOPTools_AlgoTools2D::IntermediatePoint
+ (const TopoDS_Edge& aE)
{
Standard_Real aT, aT1, aT2;
//function : BuildPCurveForEdgeOnPlane
//purpose :
//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
-{
- Standard_Real aTolE;
- TopLoc_Location aLoc;
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane
+ (const TopoDS_Edge& aE,
+ const TopoDS_Face& aF)
+{
+ Standard_Boolean bToUpdate;
+ Standard_Real aTolE, aT1, aT2;
Handle(Geom2d_Curve) aC2D;
- Handle(Geom_Plane) aGP;
- Handle(Geom_RectangularTrimmedSurface) aGRTS;
BRep_Builder aBB;
//
- const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aF, aLoc);
- aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
- if(!aGRTS.IsNull()){
- aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
- }
- else {
- aGP=Handle(Geom_Plane)::DownCast(aS);
+ aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
+ if (bToUpdate) {
+ aTolE=BRep_Tool::Tolerance(aE);
+ aBB.UpdateEdge(aE, aC2D, aF, aTolE);
}
- //
- if (aGP.IsNull()) {
- return;
- }
- //
- BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolE);
- aBB.UpdateEdge(aE, aC2D, aF, aTolE);
- //
- return;
}
//=======================================================================
// function: BuildPCurveForEdgesOnPlane
// purpose:
//=======================================================================
void BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane
- (const BOPCol_ListOfShape& aEdges,
- const TopoDS_Face& aFace)
+ (const BOPCol_ListOfShape& aLE,
+ const TopoDS_Face& aF)
{
-
- TopLoc_Location aLoc;
- Handle(Geom2d_Curve) aC2D;
- Handle(Geom_Plane) aGP;
- Handle(Geom_RectangularTrimmedSurface) aGRTS;
- //
- const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aFace, aLoc);
- aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
- if(!aGRTS.IsNull()){
- aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
- }
- else {
- aGP=Handle(Geom_Plane)::DownCast(aS);
- }
- //
- if (aGP.IsNull()) {
- return;
- }
- //
- Standard_Boolean bHasOld;
- Standard_Real aTolE, aT1, aT2;
BOPCol_ListIteratorOfListOfShape aIt;
- BRep_Builder aBB;
//
- aIt.Initialize(aEdges);
+ aIt.Initialize(aLE);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
- bHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface
- (aE, aFace, aC2D, aT1, aT2, aTolE);
- if (!bHasOld) {
- BOPTools_AlgoTools2D::CurveOnSurface(aE, aFace, aC2D, aTolE);
- aBB.UpdateEdge(aE, aC2D, aFace, aTolE);
- }
+ BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (aE, aF);
}
}
-
//=======================================================================
//function : Make2D
//purpose :
//=======================================================================
void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aFirst,
- Standard_Real& aLast,
- Standard_Real& aToler)
+ const TopoDS_Face& aF,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& aFirst,
+ Standard_Real& aLast,
+ Standard_Real& aToler)
{
Standard_Boolean aLocIdentity;
Standard_Real f3d, l3d;
//function : MakePCurveOnFace
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
- const Handle(Geom_Curve)& aC3D,
- Handle(Geom2d_Curve)& aC2D, //->
- Standard_Real& TolReached2d)
+void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
+ const Handle(Geom_Curve)& aC3D,
+ Handle(Geom2d_Curve)& aC2D, //->
+ Standard_Real& TolReached2d)
{
Standard_Real aFirst, aLast;
//
TolReached2d=0.;
//
- BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, aLast, aC2D, TolReached2d);
+ BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst,
+ aLast, aC2D, TolReached2d);
}
//=======================================================================
//function : MakePCurveOnFace
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
- const Handle(Geom_Curve)& aC3D,
- const Standard_Real aFirst,
- const Standard_Real aLast,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& TolReached2d)
+void BOPTools_AlgoTools2D::MakePCurveOnFace
+ (const TopoDS_Face& aF,
+ const Handle(Geom_Curve)& aC3D,
+ const Standard_Real aFirst,
+ const Standard_Real aLast,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& TolReached2d)
{
Standard_Real aTolR;
Handle(Geom2d_Curve) aC2DA;
-
- BRepAdaptor_Surface aBAS(aF, Standard_False);
- Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS);
- Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
+ //
+ Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
+ GeomAdaptor_Surface aGAS(aS);
+ Handle(GeomAdaptor_HSurface) aBAHS=
+ new GeomAdaptor_HSurface(aGAS);
+ Handle(GeomAdaptor_HCurve) aBAHC =
+ new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
//when the type of surface is GeomAbs_SurfaceOfRevolution
- if (aBAS.GetType() == GeomAbs_SurfaceOfRevolution) {
+ if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) {
Standard_Real aTR = 1.e-7;
ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
}
TolReached2d=aTolR;
- BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA);
+ BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast,
+ aC2D, aC2DA);
aC2D=aC2DA;
}
//function : MakePCurveOfType
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC,
- Handle(Geom2d_Curve)& C2D)
+void BOPTools_AlgoTools2D::MakePCurveOfType
+ (const ProjLib_ProjectedCurve& PC,
+ Handle(Geom2d_Curve)& C2D)
{
switch (PC.GetType()) {
case GeomAbs_BezierCurve :
case GeomAbs_OtherCurve :
default :
- Standard_NotImplemented::Raise("BOPTools_AlgoTools2D::MakePCurveOfType");
+ Standard_NotImplemented::Raise
+ ("BOPTools_AlgoTools2D::MakePCurveOfType");
break;
}
}
-
//=======================================================================
//function : CheckEdgeLength
//purpose :
ln+=d;
p1=p2;
}
-
+ //
return (ln > Precision::Confusion());
}
-
-
-
-
-
-
-
-
-/*
//=======================================================================
-//function : FaceNormal
+//function : BRep_Tool_CurveOnSurface
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::FaceNormal (const TopoDS_Face& aF,
- const Standard_Real U,
- const Standard_Real V,
- gp_Vec& aN)
+Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& E,
+ const TopoDS_Face& F,
+ Standard_Real& First,
+ Standard_Real& Last,
+ Standard_Boolean& bToUpdate)
{
- gp_Pnt aPnt ;
- gp_Vec aD1U, aD1V;
- Handle(Geom_Surface) aSurface;
-
- aSurface=BRep_Tool::Surface(aF);
- aSurface->D1 (U, V, aPnt, aD1U, aD1V);
- aN=aD1U.Crossed(aD1V);
- aN.Normalize();
- if (aF.Orientation() == TopAbs_REVERSED){
- aN.Reverse();
+ TopLoc_Location l;
+ const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
+ TopoDS_Edge aLocalEdge = E;
+ if (F.Orientation() == TopAbs_REVERSED) {
+ aLocalEdge.Reverse();
}
- return;
+ //
+ return BRep_Tool_CurveOnSurface(aLocalEdge,S,l,First,Last,bToUpdate);
}
//=======================================================================
-//function : RemovePCurveForEdgeOnFace
+//function : BRep_Tool_CurveOnSurface
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::RemovePCurveForEdgeOnFace (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
+Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface
+ (const TopoDS_Edge& E,
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last,
+ Standard_Boolean& bToUpdate)
{
- BRep_Builder aBB;
- Handle(Geom2d_Curve) aC2D;
- Standard_Real aTol;
+ static const Handle(Geom2d_Curve) nullPCurve;
+ bToUpdate=Standard_False;
+ TopLoc_Location loc = L.Predivided(E.Location());
+ Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
+
+ // find the representation
+ BRep_ListIteratorOfListOfCurveRepresentation itcr
+ ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
+
+ while (itcr.More()) {
+ const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ if (cr->IsCurveOnSurface(S,loc)) {
+ const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
+ GC->Range(First,Last);
+ if (GC->IsCurveOnClosedSurface() && Eisreversed)
+ return GC->PCurve2();
+ else
+ return GC->PCurve();
+ }
+ itcr.Next();
+ }
- aTol=BRep_Tool::Tolerance(aE);
- aBB.UpdateEdge(aE, aC2D, aF, aTol);
-}
-//=======================================================================
-//function : MakeCurveOnSurface
-//purpose :
-//=======================================================================
- void BOPTools_AlgoTools2D::MakeCurveOnSurface (const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aFirst,
- Standard_Real& aLast,
- Standard_Real& aToler)
-{
- BOPTools_AlgoTools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler);
-}
+ // for planar surface and 3d curve try a projection
+ // modif 21-05-97 : for RectangularTrimmedSurface, try a projection
+ Handle(Geom_Plane) GP;
+ Handle(Geom_RectangularTrimmedSurface) GRTS;
+ GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
+ if(!GRTS.IsNull())
+ GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
+ else
+ GP = Handle(Geom_Plane)::DownCast(S);
+ //fin modif du 21-05-97
-//=======================================================================
-//function : TangentOnEdge
-//purpose :
-//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::TangentOnEdge(const Standard_Real par,
- const TopoDS_Edge& E,
- gp_Vec& Tg)
-{
- Standard_Boolean isdgE;
-
- isdgE = BRep_Tool::Degenerated(E);
- if (isdgE) {
- return Standard_False;
- }
- if (!CheckEdgeLength(E)) {
- return Standard_False;
- }
+ if (!GP.IsNull()) {
- BRepAdaptor_Curve BC(E);
- //
- // Body
- Standard_Real f, l, tolE, tolp;
- Standard_Boolean onf, onl, inbounds;
+ Handle(GeomAdaptor_HCurve) HC;
+ Handle(GeomAdaptor_HSurface) HS;
- f = BC.FirstParameter();
- l = BC.LastParameter();
- tolE = BC.Tolerance();
- tolp = BC.Resolution(tolE);
-
- onf = Abs(f-par)<tolp;
- onl = Abs(l-par)<tolp;
- inbounds = (f<par) && (par<l);
+ HC = new GeomAdaptor_HCurve();
+ HS = new GeomAdaptor_HSurface();
- if ((!inbounds) && (!onf) && (!onl)) {
- return Standard_False;
- }
-
-
- gp_Pnt aP;
+ TopLoc_Location LC;
- BC.D1(par, aP, Tg);
- Tg.Normalize();
-
- return Standard_True;
-}
-//=======================================================================
-//function : TangentOnEdge
-//purpose :
-//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::TangentOnEdge(const TopoDS_Edge& aE,
- gp_Dir& DTg)
-{
- Standard_Real aT;
- gp_Vec aTg;
+ Standard_Real f, l;// for those who call with (u,u).
+ Handle(Geom_Curve) C3d =
+ BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
+ // we can loose scale factor of Curve transformation (eap 13 May 2002)
+
+ LC = L/*.Predivided(LC)*/;
- DTg.SetCoord(1.,0.,0.);
+ if (C3d.IsNull()) return nullPCurve;
- aT= BOPTools_AlgoTools2D::IntermediatePoint (aE);
- Standard_Boolean bIsFound=BOPTools_AlgoTools2D::TangentOnEdge(aT, aE, aTg);
- if (bIsFound) {
- gp_Dir aDTmp(aTg);
- DTg=aDTmp;
+ Handle(Geom_Plane) Plane = GP;
+ if (!LC.IsIdentity()) {
+ const gp_Trsf& T = LC.Transformation();
+ Handle(Geom_Geometry) GPT = GP->Transformed(T);
+ Plane = *((Handle(Geom_Plane)*)&GPT);
+ }
+ GeomAdaptor_Surface& GAS = HS->ChangeSurface();
+ GAS.Load(Plane);
+
+ Handle(Geom_Curve) ProjOnPlane =
+ GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
+ Plane,
+ Plane->Position().Direction(),
+ Standard_True);
+
+ GeomAdaptor_Curve& GAC = HC->ChangeCurve();
+ GAC.Load(ProjOnPlane);
+
+ ProjLib_ProjectedCurve Proj(HS,HC);
+ Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
+
+ if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
+ Handle(Geom2d_TrimmedCurve) TC =
+ (*((Handle(Geom2d_TrimmedCurve)*)&pc));
+ pc = TC->BasisCurve();
+ }
+ First = f; Last = l;
+ //
+ bToUpdate=Standard_True;
+ //
+ return pc;
}
- return bIsFound;
-}
-//=======================================================================
-//function : TangentOnVertex
-//purpose :
-//=======================================================================
- Standard_Boolean BOPTools_AlgoTools2D::TangentOnVertex (const TopoDS_Vertex& v,
- const TopoDS_Vertex& vl,
- const TopoDS_Edge& e,
- gp_Vec& aVec)
-// tg oriented INSIDE 1d(e)
-// vl : last vertex of e
-{
- Standard_Boolean ok;
- Standard_Real par;
- gp_Vec tg;
-
- par = BRep_Tool::Parameter(v, e);
- ok =BOPTools_AlgoTools2D::TangentOnEdge (par, e, tg);
- if (!ok) {
- return ok;
- }
- if (v.IsSame(vl)) {
- tg.Reverse();
- }
- aVec=tg;
-
- return ok;
+ return nullPCurve;
}
-
//=======================================================================
-//function : EdgeBounds
+//function : MaxToleranceEdge
//purpose :
//=======================================================================
- void BOPTools_AlgoTools2D::EdgeBounds (const TopoDS_Edge& aE,
- Standard_Real& aFirst,
- Standard_Real& aLast)
+Standard_Real MaxToleranceEdge (const TopoDS_Face& aF)
{
- BRepAdaptor_Curve aBC(aE);
- aFirst= aBC.FirstParameter();
- aLast = aBC.LastParameter();
+ Standard_Real aTol, aTolMax;
+ TopExp_Explorer aExp;
+ //
+ aTolMax=0.;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ const TopoDS_Edge& aE=*((TopoDS_Edge *)&aExp.Current());
+ aTol=BRep_Tool::Tolerance(aE);
+ if (aTol>aTolMax) {
+ aTolMax=aTol;
+ }
+ }
+ return aTolMax;
}
-
-
-*/
is
- Initialize (S1 :Shape from TopoDS;
- S2 :Shape from TopoDS;
- anOperation:Operation from BOPAlgo);
- ---Purpose: Prepares the operations for S1 and S2.
+ Initialize (
+ theS1 : Shape from TopoDS;
+ theS2 : Shape from TopoDS;
+ anOperation : Operation from BOPAlgo;
+ theFuzz : Real from Standard = 0.0);
+ ---Purpose: Prepares the operations for S1 and S2.
- Initialize (S1 :Shape from TopoDS;
- S2 :Shape from TopoDS;
- aDSF :PaveFiller from BOPAlgo;
- anOperation:Operation from BOPAlgo);
- ---Purpose: Prepares the operations for S1 and S2.
+ Initialize (
+ theS1 : Shape from TopoDS;
+ theS2 : Shape from TopoDS;
+ theDSF : PaveFiller from BOPAlgo;
+ anOperation : Operation from BOPAlgo);
+ ---Purpose: Prepares the operations for S1 and S2.
SetOperation (me:out;
anOp: Operation from BOPAlgo);
---Purpose: Returns the list of shapes generated from the shape <S>.
--- For use in BRepNaming.
---C++: return const &
+ SetFuzzyValue(me:out;
+ theFuzz : Real from Standard);
+ ---Purpose: Sets the extended tolerance
+
+ FuzzyValue(me)
+ returns Real from Standard;
+ ---Purpose: Returns the extended tolerance
fields
myS1 : Shape from TopoDS is protected;
myFuseEdges : Boolean from Standard ;
myModifFaces : DataMapOfShapeShape from TopTools;
myEdgeMap : DataMapOfShapeShape from TopTools;
+ --
+ -- extended tolerance for Boolean Operation
+ myFuzzyValue : Real from Standard is protected;
end BooleanOperation;
//function : BRepAlgoAPI_BooleanOperation
//purpose :
//=======================================================================
- BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1,
- const TopoDS_Shape& aS2,
- const BOPAlgo_Operation anOp)
+BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
+ (const TopoDS_Shape& aS1,
+ const TopoDS_Shape& aS2,
+ const BOPAlgo_Operation anOp,
+ const Standard_Real theFuzz)
:
myS1(aS1),
myS2(aS2),
myDSFiller(NULL),
myBuilder(NULL),
myEntryType(1),
- myFuseEdges(Standard_False)
+ myFuseEdges(Standard_False),
+ myFuzzyValue(theFuzz)
{
}
//=======================================================================
//function : BRepAlgoAPI_BooleanOperation
//purpose :
//=======================================================================
- BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1,
- const TopoDS_Shape& aS2,
- const BOPAlgo_PaveFiller& aDSFiller,
- const BOPAlgo_Operation anOp)
+BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
+ (const TopoDS_Shape& aS1,
+ const TopoDS_Shape& aS2,
+ const BOPAlgo_PaveFiller& aDSFiller,
+ const BOPAlgo_Operation anOp)
:
myS1(aS1),
myS2(aS2),
myDSFiller(NULL),
myBuilder(NULL),
myEntryType(0),
- myFuseEdges(Standard_False)
+ myFuseEdges(Standard_False),
+ myFuzzyValue(0.)
{
if ((Standard_Address) &aDSFiller!=NULL) {
myDSFiller=(BOPAlgo_PaveFiller*)&aDSFiller;
+ myFuzzyValue = myDSFiller->FuzzyValue();
}
}
//=======================================================================
return myErrorStatus;
}
//=======================================================================
+//function : SetFuzzyValue
+//purpose :
+//=======================================================================
+ void BRepAlgoAPI_BooleanOperation::SetFuzzyValue(const Standard_Real theFuzz)
+{
+ if (theFuzz > 0.) {
+ myFuzzyValue = theFuzz;
+ }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose :
+//=======================================================================
+ Standard_Real BRepAlgoAPI_BooleanOperation::FuzzyValue() const
+{
+ return myFuzzyValue;
+}
+//=======================================================================
//function : Modified
//purpose :
//=======================================================================
aLS.Append(myS2);
//
myDSFiller->SetArguments(aLS);
+ myDSFiller->SetFuzzyValue(myFuzzyValue);
}
return bIsNewFiller;
---Purpose: Empty constructor.
Create(
- theS : Shape from TopoDS;
+ theS : Shape from TopoDS;
bTestSE : Boolean from Standard = Standard_True;
- bTestSI : Boolean from Standard = Standard_True)
+ bTestSI : Boolean from Standard = Standard_True;
+ theFuzz : Real from Standard = 0.0)
returns Check from BRepAlgoAPI;
---Purpose: Constructor for checking single shape.
-- It calls methods
-- bTestSE - flag that specifies whether check on small edges
-- should be performed; by default it is set to TRUE;
-- bTestSI - flag that specifies whether check on self-interference
- -- should be performed; by default it is set to TRUE;
+ -- should be performed; by default it is set to TRUE;
+ -- theFuzz - The extended tolerance for the check;
Create(
theS1 : Shape from TopoDS;
theS2 : Shape from TopoDS;
theOp : Operation from BOPAlgo = BOPAlgo_UNKNOWN;
bTestSE : Boolean from Standard = Standard_True;
- bTestSI : Boolean from Standard = Standard_True)
+ bTestSI : Boolean from Standard = Standard_True;
+ theFuzz : Real from Standard = 0.0)
returns Check from BRepAlgoAPI;
---Purpose: Constructor for couple of shapes.
-- It calls methods
-- bTestSE - flag that specifies whether check on small edges
-- should be performed; by default it is set to TRUE;
-- bTestSI - flag that specifies whether check on self-interference
- -- should be performed; by default it is set to TRUE;
+ -- should be performed; by default it is set to TRUE;
+ -- theFuzz - The extended tolerance for the check;
Init(me:out;
theS1 : Shape from TopoDS;
theS2 : Shape from TopoDS;
theOp : Operation from BOPAlgo;
bTestSE : Boolean from Standard;
- bTestSI : Boolean from Standard)
+ bTestSI : Boolean from Standard;
+ theFuzz : Real from Standard)
is protected;
---Purpose: Initialyzes data.
SetData(me:out;
- theS : Shape from TopoDS;
+ theS : Shape from TopoDS;
bTestSE : Boolean from Standard = Standard_True;
- bTestSI : Boolean from Standard = Standard_True);
+ bTestSI : Boolean from Standard = Standard_True;
+ theFuzz : Real from Standard = 0.0);
---Purpose: Sets data for check by Init method.
-- The method provides alternative way for checking single shape.
theS2 : Shape from TopoDS;
theOp : Operation from BOPAlgo = BOPAlgo_UNKNOWN;
bTestSE : Boolean from Standard = Standard_True;
- bTestSI : Boolean from Standard = Standard_True);
+ bTestSI : Boolean from Standard = Standard_True;
+ theFuzz : Real from Standard = 0.0);
---Purpose: Sets data for check by Init method.
-- The method provides alternative way for checking couple of shapes.
---Purpose: Returns faulty shapes.
fields
- myS1, myS2 : Shape from TopoDS is protected;
- myAnalyzer : PArgumentAnalyzer from BOPAlgo is protected;
- myResult : ListOfCheckResult from BOPAlgo is protected;
+ myS1, myS2 : Shape from TopoDS is protected;
+ myAnalyzer : PArgumentAnalyzer from BOPAlgo is protected;
+ myFuzzyValue : Real from Standard is protected;
+ myResult : ListOfCheckResult from BOPAlgo is protected;
end BooleanOperation;
//purpose :
//=======================================================================
BRepAlgoAPI_Check::BRepAlgoAPI_Check()
-: myAnalyzer(NULL)
+:
+ myAnalyzer(NULL),
+ myFuzzyValue(0.0)
{
}
//=======================================================================
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
- const Standard_Boolean bTestSI)
+ const Standard_Boolean bTestSI,
+ const Standard_Real theFuzz)
{
- Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
+ Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI, theFuzz);
//
Perform();
}
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
- const Standard_Boolean bTestSI)
+ const Standard_Boolean bTestSI,
+ const Standard_Real theFuzz)
{
- Init(theS1, theS2, theOp, bTestSE, bTestSI);
+ Init(theS1, theS2, theOp, bTestSE, bTestSI, theFuzz);
//
Perform();
}
//=======================================================================
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
- const Standard_Boolean bTestSI)
+ const Standard_Boolean bTestSI,
+ const Standard_Real theFuzz)
{
- Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
+ Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI, theFuzz);
}
//=======================================================================
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
- const Standard_Boolean bTestSI)
+ const Standard_Boolean bTestSI,
+ const Standard_Real theFuzz)
{
- Init(theS1, theS2, theOp, bTestSE, bTestSI);
+ Init(theS1, theS2, theOp, bTestSE, bTestSI, theFuzz);
}
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
- const Standard_Boolean bTestSI)
+ const Standard_Boolean bTestSI,
+ const Standard_Real theFuzz)
{
myResult.Clear();
myS1 = theS1.IsNull() ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
myAnalyzer->ArgumentTypeMode() = Standard_True;
myAnalyzer->SmallEdgeMode() = bTestSE;
myAnalyzer->SelfInterMode() = bTestSI;
+ myAnalyzer->SetFuzzyValue(theFuzz);
}
//=======================================================================
class Common from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
- ---Purpose: The class Common provides a
- -- Boolean common operation on a pair of arguments (Boolean Intersection).
- -- The class Common provides a framework for:
- -- - Defining the construction of a common shape;
- -- - Implementing the building algorithm
- -- - Consulting the result.
+ ---Purpose: The class Common provides a
+ -- Boolean common operation on a pair of arguments (Boolean Intersection).
+ -- The class Common provides a framework for:
+ -- - Defining the construction of a common shape;
+ -- - Implementing the building algorithm
+ -- - Consulting the result.
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
- Create (S1,S2 : Shape from TopoDS)
- returns Common from BRepAlgoAPI;
- ---Purpose: Constructs a common part for shapes aS1 and aS2 .
+ Create (S1,S2 : Shape from TopoDS;
+ theFuzz : Real from Standard = 0.0)
+ returns Common from BRepAlgoAPI;
+ ---Purpose: Constructs a common part for shapes aS1 and aS2 .
Create (S1,S2 : Shape from TopoDS;
- aDSF:PaveFiller from BOPAlgo)
- returns Common from BRepAlgoAPI;
+ aDSF : PaveFiller from BOPAlgo)
+ returns Common from BRepAlgoAPI;
end Common;
--- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller
//purpose :
//=======================================================================
BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
- const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON)
+ const TopoDS_Shape& S2,
+ const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON, theFuzz)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
-- commercial license or contractual agreement.
class Cut from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
- ---Purpose: The class Cut provides a Boolean
- -- cut operation on a pair of arguments (Boolean Subtraction).
- -- The class Cut provides a framework for:
- -- - Defining the construction of a cut shape
- -- - Implementing the building algorithm
- -- - Consulting the result
+ ---Purpose: The class Cut provides a Boolean
+ -- cut operation on a pair of arguments (Boolean Subtraction).
+ -- The class Cut provides a framework for:
+ -- - Defining the construction of a cut shape
+ -- - Implementing the building algorithm
+ -- - Consulting the result
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
- Create (S1,S2 : Shape from TopoDS)
- returns Cut from BRepAlgoAPI;
- ---Purpose: Shape aS2 cuts shape aS1. The
- -- resulting shape is a new shape produced by the cut operation.
-
+ Create (S1, S2 : Shape from TopoDS;
+ theFuzz : Real from Standard = 0.0)
+ returns Cut from BRepAlgoAPI;
+ ---Purpose: Shape aS2 cuts shape aS1. The
+ -- resulting shape is a new shape produced by the cut operation.
+
Create (S1,S2 : Shape from TopoDS;
- aDSF : PaveFiller from BOPAlgo;
- bFWD : Boolean from Standard=Standard_True)
- returns Cut from BRepAlgoAPI;
- --- Purpose: Constructs a new shape cut from
- -- shape aS1 by shape aS2 using aDSFiller (see
- -- BRepAlgoAPI_BooleanOperation Constructor).
+ aDSF : PaveFiller from BOPAlgo;
+ bFWD : Boolean from Standard=Standard_True)
+ returns Cut from BRepAlgoAPI;
+ --- Purpose: Constructs a new shape cut from
+ -- shape aS1 by shape aS2 using aDSFiller (see
+ -- BRepAlgoAPI_BooleanOperation Constructor).
end Cut;
//purpose :
//=======================================================================
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
- const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
+ const TopoDS_Shape& S2,
+ const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT, theFuzz)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
const TopoDS_Shape& S2,
const BOPAlgo_PaveFiller& aDSF,
const Standard_Boolean bFWD)
-: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
+: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, bFWD ? BOPAlgo_CUT : BOPAlgo_CUT21)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
class Fuse from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
- ---Purpose: The class Fuse provides a
- -- Boolean fusion operation on a pair of arguments (Boolean Union).
- -- The class Fuse provides a framework for:
- -- - Defining the construction of a fused shape;
- -- - Implementing the building algorithm
- -- - Consulting the result.
+ ---Purpose: The class Fuse provides a
+ -- Boolean fusion operation on a pair of arguments (Boolean Union).
+ -- The class Fuse provides a framework for:
+ -- - Defining the construction of a fused shape;
+ -- - Implementing the building algorithm
+ -- - Consulting the result.
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
- Create (S1,S2 : Shape from TopoDS)
- returns Fuse from BRepAlgoAPI;
- ---Purpose: Constructs a fuse of shapes aS1 and aS2.
-
+ Create (S1, S2 : Shape from TopoDS;
+ theFuzz : Real from Standard = 0.0)
+ returns Fuse from BRepAlgoAPI;
+ ---Purpose: Constructs a fuse of shapes aS1 and aS2.
+
Create (S1,S2 : Shape from TopoDS;
- aDSF:PaveFiller from BOPAlgo)
- returns Fuse from BRepAlgoAPI;
-
- ---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller.
+ aDSF : PaveFiller from BOPAlgo)
+ returns Fuse from BRepAlgoAPI;
+ ---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller.
end Fuse;
//purpose :
//=======================================================================
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
- const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
+ const TopoDS_Shape& S2,
+ const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE, theFuzz)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
class Section from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
- ---Purpose: Computes the intersection of two shapes or geometries.
- -- Geometries can be surfaces of planes.
- -- Geometries are converted to faces
- -- When a geometry has been converted to
- -- topology the created shape can be found using
- -- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
- -- The result (Shape() method) is a compound containing
- -- edges built on intersection curves.
- -- By default, the section is performed immediatly in
- -- class constructors, with default values :
- -- - geometries built are NOT approximated.
- -- - PCurves are NOT computed on both parts.
- -- Example : giving two shapes S1,S2 accessing faces,
- -- let compute the section edges R on S1,S2,
- -- performing approximation on new curves,
- -- performing PCurve on part 1 but not on part 2 :
- -- Standard_Boolean PerformNow = Standard_False;
- -- BRepBoolAPI_Section S(S1,S2,PerformNow);
- -- S.ComputePCurveOn1(Standard_True);
- -- S.Approximation(Standard_True);
- -- S.Build();
- -- TopoDS_Shape R = S.Shape();
- -- On Null Shapes of geometries, NotDone() is called.
+ ---Purpose: Computes the intersection of two shapes or geometries.
+ -- Geometries can be surfaces of planes.
+ -- Geometries are converted to faces
+ -- When a geometry has been converted to
+ -- topology the created shape can be found using
+ -- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
+ -- The result (Shape() method) is a compound containing
+ -- edges built on intersection curves.
+ -- By default, the section is performed immediatly in
+ -- class constructors, with default values :
+ -- - geometries built are NOT approximated.
+ -- - PCurves are NOT computed on both parts.
+ -- Example : giving two shapes S1,S2 accessing faces,
+ -- let compute the section edges R on S1,S2,
+ -- performing approximation on new curves,
+ -- performing PCurve on part 1 but not on part 2 :
+ -- Standard_Boolean PerformNow = Standard_False;
+ -- BRepBoolAPI_Section S(S1,S2,PerformNow);
+ -- S.ComputePCurveOn1(Standard_True);
+ -- S.Approximation(Standard_True);
+ -- S.SetFuzzyValue(theFuzz);
+ -- S.Build();
+ -- TopoDS_Shape R = S.Shape();
+ -- On Null Shapes of geometries, NotDone() is called.
uses
Pln from gp,
ListOfShape from TopTools
is
- Create (S1,S2 : Shape from TopoDS;
- aDSF:PaveFiller from BOPAlgo;
- PerformNow : Boolean = Standard_True)
- returns Section from BRepAlgoAPI;
+ Create (S1,S2 : Shape from TopoDS;
+ aDSF:PaveFiller from BOPAlgo;
+ PerformNow : Boolean = Standard_True)
+ returns Section from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section(){}"
Create(Sh1,Sh2 : Shape from TopoDS;
- PerformNow : Boolean = Standard_True)
- ---Purpose: see upper
- ---Level: Public
- returns Section from BRepAlgoAPI;
+ PerformNow : Boolean = Standard_True)
+ ---Purpose: see upper
+ ---Level: Public
+ returns Section from BRepAlgoAPI;
Create(Sh : Shape from TopoDS; Pl : Pln from gp;
- PerformNow : Boolean = Standard_True)
- ---Purpose: see upper
- ---Level: Public
- returns Section from BRepAlgoAPI;
+ PerformNow : Boolean = Standard_True)
+ ---Purpose: see upper
+ ---Level: Public
+ returns Section from BRepAlgoAPI;
Create(Sh : Shape from TopoDS; Sf : Surface from Geom;
- PerformNow : Boolean = Standard_True)
- ---Purpose: see upper
- ---Level: Public
- returns Section from BRepAlgoAPI;
+ PerformNow : Boolean = Standard_True)
+ ---Purpose: see upper
+ ---Level: Public
+ returns Section from BRepAlgoAPI;
Create(Sf : Surface from Geom; Sh : Shape from TopoDS;
- PerformNow : Boolean = Standard_True)
- ---Purpose: see upper
- ---Level: Public
- returns Section from BRepAlgoAPI;
+ PerformNow : Boolean = Standard_True)
+ ---Purpose: see upper
+ ---Level: Public
+ returns Section from BRepAlgoAPI;
Create(Sf1 : Surface from Geom; Sf2 : Surface from Geom;
- PerformNow : Boolean = Standard_True)
- ---Purpose: This and the above classes construct a framework for
- -- computing the section lines of:
- -- - two shapes Sh1 and Sh2, or
- -- - shape Sh and plane Pl, or
- -- - shape Sh and surface Sf, or
- -- - surface Sf and shape Sh, or
- -- - two surfaces Sf1 and Sf2,
- -- and builds a result if PerformNow equals true, its
- -- default value. If PerformNow equals false, the intersection
- -- will be computed later by the function Build.
- -- The constructed shape will be returned by the function Shape.
- -- This is a compound object composed of edges. These
- -- intersection edges may be built:
- -- - on new intersection lines, or
- -- - on coincident portions of edges in the two intersected shapes.
- -- These intersection edges are independent: they are not
- -- chained or grouped in wires. If no intersection edge exists, the
- -- result is an empty compound object.
- -- Note that other objects than TopoDS_Shape shapes involved in
- -- these syntaxes are converted into faces or shells before
- -- performing the computation of the intersection. A shape
- -- resulting from this conversion can be retrieved with the
- -- function Shape1 or Shape2.
- -- Parametric 2D curves on intersection edges
- -- No parametric 2D curve (pcurve) is defined for each elementary
- -- edge of the result. To attach such parametric curves to the
- -- constructed edges you may use a constructor with the PerformNow
- -- flag equal to false; then you use:
- -- - the function ComputePCurveOn1 to ask for
- -- the additional computation of a pcurve in the parametric
- -- space of the first shape,
- -- - the function ComputePCurveOn2 to ask for
- -- the additional computation of a pcurve in the parametric
- -- space of the second shape, in the end,
- -- - the function Build to construct the result.
- -- Approximation of intersection edges
- -- The underlying 3D geometry attached to each elementary edge
- -- of the result is:
- -- - analytic where possible, provided the corresponding
- -- geometry corresponds to a type of analytic curve
- -- defined in the Geom package; for example, the intersection
- -- of a cylindrical shape with a plane gives an ellipse or a circle;
- -- - or elsewhere, given as a succession of points grouped
- -- together in a BSpline curve of degree 1.
- -- If you prefer to have an attached 3D geometry which is a
- -- BSpline approximation of the computed set of points on
- -- computed elementary intersection edges whose underlying geometry
- -- is not analytic, you may use a constructor with the PerformNow
- -- flag equal to false. Then you use:
- -- - the function Approximation to ask for this
- -- computation option, and
- -- - the function Build to construct the result.
- -- - Note that as a result, approximations will only be
- -- computed on edges built on new intersection lines.
- -- - Example
- -- You may also combine these computation options. In the following example:
- -- - each elementary edge of the computed intersection,
- -- built on a new intersection line, which does not
- -- correspond to an analytic Geom curve, will be approximated by
- -- a BSpline curve whose degree is not greater than 8.
- -- - each elementary edge built on a new intersection line, will have:
- -- - a pcurve in the parametric space of the intersected face of shape S1,
- -- - no pcurve in the parametric space of the intersected face of shape S2.
- -- // TopoDS_Shape S1 = ... , S2 = ... ;
- -- Standard_Boolean PerformNow = Standard_False;
- -- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
- -- S.ComputePCurveOn1 (Standard_True);
- -- S.Approximation (Standard_True);
- -- S.Build();
- -- TopoDS_Shape R = S.Shape();
- returns Section from BRepAlgoAPI;
+ PerformNow : Boolean = Standard_True)
+ ---Purpose: This and the above classes construct a framework for
+ -- computing the section lines of:
+ -- - two shapes Sh1 and Sh2, or
+ -- - shape Sh and plane Pl, or
+ -- - shape Sh and surface Sf, or
+ -- - surface Sf and shape Sh, or
+ -- - two surfaces Sf1 and Sf2,
+ -- and builds a result if PerformNow equals true, its
+ -- default value. If PerformNow equals false, the intersection
+ -- will be computed later by the function Build.
+ -- The constructed shape will be returned by the function Shape.
+ -- This is a compound object composed of edges. These
+ -- intersection edges may be built:
+ -- - on new intersection lines, or
+ -- - on coincident portions of edges in the two intersected shapes.
+ -- These intersection edges are independent: they are not
+ -- chained or grouped in wires. If no intersection edge exists, the
+ -- result is an empty compound object.
+ -- Note that other objects than TopoDS_Shape shapes involved in
+ -- these syntaxes are converted into faces or shells before
+ -- performing the computation of the intersection. A shape
+ -- resulting from this conversion can be retrieved with the
+ -- function Shape1 or Shape2.
+ -- Parametric 2D curves on intersection edges
+ -- No parametric 2D curve (pcurve) is defined for each elementary
+ -- edge of the result. To attach such parametric curves to the
+ -- constructed edges you may use a constructor with the PerformNow
+ -- flag equal to false; then you use:
+ -- - the function ComputePCurveOn1 to ask for
+ -- the additional computation of a pcurve in the parametric
+ -- space of the first shape,
+ -- - the function ComputePCurveOn2 to ask for
+ -- the additional computation of a pcurve in the parametric
+ -- space of the second shape, in the end,
+ -- - the function Build to construct the result.
+ -- Approximation of intersection edges
+ -- The underlying 3D geometry attached to each elementary edge
+ -- of the result is:
+ -- - analytic where possible, provided the corresponding
+ -- geometry corresponds to a type of analytic curve
+ -- defined in the Geom package; for example, the intersection
+ -- of a cylindrical shape with a plane gives an ellipse or a circle;
+ -- - or elsewhere, given as a succession of points grouped
+ -- together in a BSpline curve of degree 1.
+ -- If you prefer to have an attached 3D geometry which is a
+ -- BSpline approximation of the computed set of points on
+ -- computed elementary intersection edges whose underlying geometry
+ -- is not analytic, you may use a constructor with the PerformNow
+ -- flag equal to false. Then you use:
+ -- - the function Approximation to ask for this
+ -- computation option, and
+ -- - the function Build to construct the result.
+ -- - Note that as a result, approximations will only be
+ -- computed on edges built on new intersection lines.
+ -- - Example
+ -- You may also combine these computation options. In the following example:
+ -- - each elementary edge of the computed intersection,
+ -- built on a new intersection line, which does not
+ -- correspond to an analytic Geom curve, will be approximated by
+ -- a BSpline curve whose degree is not greater than 8.
+ -- - each elementary edge built on a new intersection line, will have:
+ -- - a pcurve in the parametric space of the intersected face of shape S1,
+ -- - no pcurve in the parametric space of the intersected face of shape S2.
+ -- // TopoDS_Shape S1 = ... , S2 = ... ;
+ -- Standard_Boolean PerformNow = Standard_False;
+ -- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
+ -- S.ComputePCurveOn1 (Standard_True);
+ -- S.Approximation (Standard_True);
+ -- S.Build();
+ -- TopoDS_Shape R = S.Shape();
+ returns Section from BRepAlgoAPI;
Init1(me : out;S1 : Shape from TopoDS);
- ---Purpose: initialize first part
- ---Level: Public
+ ---Purpose: initialize first part
+ ---Level: Public
Init1(me : out;Pl : Pln from gp);
- ---Purpose: initialize first part
- ---Level: Public
+ ---Purpose: initialize first part
+ ---Level: Public
Init1(me : out;Sf : Surface from Geom);
- ---Purpose: initialize first part
- ---Level: Public
+ ---Purpose: initialize first part
+ ---Level: Public
Init2(me : out;S2 : Shape from TopoDS);
- ---Purpose: initialize second part
- ---Level: Public
+ ---Purpose: initialize second part
+ ---Level: Public
Init2(me : out;Pl : Pln from gp);
- ---Purpose: initialize second part
- ---Level: Public
+ ---Purpose: initialize second part
+ ---Level: Public
Init2(me : out;Sf : Surface from Geom);
- ---Purpose: Reinitializes the first and the
- -- second parts on which this algorithm is going to perform
- -- the intersection computation. This is done with either: the
- -- surface Sf, the plane Pl or the shape Sh.
- -- You use the function Build to construct the result.
+ ---Purpose: Reinitializes the first and the
+ -- second parts on which this algorithm is going to perform
+ -- the intersection computation. This is done with either: the
+ -- surface Sf, the plane Pl or the shape Sh.
+ -- You use the function Build to construct the result.
Approximation(me : out;B : Boolean);
- ---Level: Public
- ---Purpose: Defines an option for computation
- -- of further intersections. This computation will be performed by
- -- the function Build in this framework.
- -- By default, the underlying 3D geometry attached to each
- -- elementary edge of the result of a computed intersection is:
- -- - analytic where possible, provided the corresponding
- -- geometry corresponds to a type of analytic curve defined in
- -- the Geom package; for example the intersection of a
- -- cylindrical shape with a plane gives an ellipse or a circle;
- -- - or elsewhere, given as a succession of points grouped
- -- together in a BSpline curve of degree 1. If Approx equals
- -- true, when further computations are performed in this framework
- -- with the function Build, these edges will have an attached 3D
- -- geometry which is a BSpline approximation of the computed
- -- set of points.
- -- Note that as a result, approximations will be computed
- -- on edges built only on new intersection lines.
+ ---Level: Public
+ ---Purpose: Defines an option for computation
+ -- of further intersections. This computation will be performed by
+ -- the function Build in this framework.
+ -- By default, the underlying 3D geometry attached to each
+ -- elementary edge of the result of a computed intersection is:
+ -- - analytic where possible, provided the corresponding
+ -- geometry corresponds to a type of analytic curve defined in
+ -- the Geom package; for example the intersection of a
+ -- cylindrical shape with a plane gives an ellipse or a circle;
+ -- - or elsewhere, given as a succession of points grouped
+ -- together in a BSpline curve of degree 1. If Approx equals
+ -- true, when further computations are performed in this framework
+ -- with the function Build, these edges will have an attached 3D
+ -- geometry which is a BSpline approximation of the computed
+ -- set of points.
+ -- Note that as a result, approximations will be computed
+ -- on edges built only on new intersection lines.
ComputePCurveOn1(me : out;B : Boolean);
- ---Level: Public
- ---Purpose:
- -- Indicates if the Pcurve must be (or not) performed on first part.
+ ---Level: Public
+ ---Purpose:
+ -- Indicates if the Pcurve must be (or not) performed on first part.
ComputePCurveOn2(me : out;B : Boolean);
- ---Level: Public
- ---Purpose: Define options for the computation of further
- -- intersections, which will be performed by the function Build
- -- in this framework.
- -- By default, no parametric 2D curve (pcurve) is defined for the
- -- elementary edges of the result. If ComputePCurve1 equals true,
- -- further computations performed in this framework with the function
- -- Build will attach an additional pcurve in the parametric space of
- -- the first shape to the constructed edges.
- -- If ComputePCurve2 equals true, the additional pcurve will be
- -- attached to the constructed edges in the parametric space of the
- -- second shape.
- -- These two functions may be used together.
+ ---Level: Public
+ ---Purpose: Define options for the computation of further
+ -- intersections, which will be performed by the function Build
+ -- in this framework.
+ -- By default, no parametric 2D curve (pcurve) is defined for the
+ -- elementary edges of the result. If ComputePCurve1 equals true,
+ -- further computations performed in this framework with the function
+ -- Build will attach an additional pcurve in the parametric space of
+ -- the first shape to the constructed edges.
+ -- If ComputePCurve2 equals true, the additional pcurve will be
+ -- attached to the constructed edges in the parametric space of the
+ -- second shape.
+ -- These two functions may be used together.
Build(me : in out)
- ---Purpose: Performs the computation of
- -- section lines between two parts defined at the time of
- -- construction of this framework or reinitialized with the Init1 and
- -- Init2 functions.
- -- The constructed shape will be returned by the function Shape.
- -- This is a compound object composed of edges. These
- -- intersection edges may be built:
- -- - on new intersection lines, or
- -- - on coincident portions of edges in the two intersected shapes.
- -- These intersection edges are independent: they are not chained
- -- or grouped into wires.
- -- If no intersection edge exists, the result is an empty compound object.
- -- The shapes involved in the construction of section lines can
- -- be retrieved with the function Shape1 or Shape2. Note that other
- -- objects than TopoDS_Shape shapes given as arguments at the
- -- construction time of this framework, or to the Init1 or
- -- Init2 function, are converted into faces or shells before
- -- performing the computation of the intersection.
- -- Parametric 2D curves on intersection edges
- -- No parametric 2D curve (pcurve) is defined for the elementary
- -- edges of the result. To attach parametric curves like this to
- -- the constructed edges you have to use:
- -- - the function
- -- ComputePCurveOn1 to ask for the additional computation of a
- -- pcurve in the parametric space of the first shape,
- -- - the function
- -- ComputePCurveOn2 to ask for the additional computation of a
- -- pcurve in the parametric space of the second shape.
- -- This must be done before calling this function.
- -- Approximation of intersection edges
- -- The underlying 3D geometry attached to each elementary edge of the result is:
- -- - analytic (where possible) provided the corresponding
- -- geometry corresponds to a type of analytic curve defined in
- -- the Geom package; for example, the intersection of a
- -- cylindrical shape with a plane gives an ellipse or a circle; or
- -- - elsewhere, given as a succession of points grouped
- -- together in a BSpline curve of degree 1.
- -- If, on computed elementary intersection edges whose
- -- underlying geometry is not analytic, you prefer to have an
- -- attached 3D geometry which is a Bspline approximation of the
- -- computed set of points, you have to use the function Approximation
- -- to ask for this computation option before calling this function.
- -- You may also have combined these computation options: look at the
- -- example given above to illustrate the use of the constructors.
- is redefined static;
+ ---Purpose: Performs the computation of
+ -- section lines between two parts defined at the time of
+ -- construction of this framework or reinitialized with the Init1 and
+ -- Init2 functions.
+ -- The constructed shape will be returned by the function Shape.
+ -- This is a compound object composed of edges. These
+ -- intersection edges may be built:
+ -- - on new intersection lines, or
+ -- - on coincident portions of edges in the two intersected shapes.
+ -- These intersection edges are independent: they are not chained
+ -- or grouped into wires.
+ -- If no intersection edge exists, the result is an empty compound object.
+ -- The shapes involved in the construction of section lines can
+ -- be retrieved with the function Shape1 or Shape2. Note that other
+ -- objects than TopoDS_Shape shapes given as arguments at the
+ -- construction time of this framework, or to the Init1 or
+ -- Init2 function, are converted into faces or shells before
+ -- performing the computation of the intersection.
+ -- Parametric 2D curves on intersection edges
+ -- No parametric 2D curve (pcurve) is defined for the elementary
+ -- edges of the result. To attach parametric curves like this to
+ -- the constructed edges you have to use:
+ -- - the function
+ -- ComputePCurveOn1 to ask for the additional computation of a
+ -- pcurve in the parametric space of the first shape,
+ -- - the function
+ -- ComputePCurveOn2 to ask for the additional computation of a
+ -- pcurve in the parametric space of the second shape.
+ -- This must be done before calling this function.
+ -- Approximation of intersection edges
+ -- The underlying 3D geometry attached to each elementary edge of the result is:
+ -- - analytic (where possible) provided the corresponding
+ -- geometry corresponds to a type of analytic curve defined in
+ -- the Geom package; for example, the intersection of a
+ -- cylindrical shape with a plane gives an ellipse or a circle; or
+ -- - elsewhere, given as a succession of points grouped
+ -- together in a BSpline curve of degree 1.
+ -- If, on computed elementary intersection edges whose
+ -- underlying geometry is not analytic, you prefer to have an
+ -- attached 3D geometry which is a Bspline approximation of the
+ -- computed set of points, you have to use the function Approximation
+ -- to ask for this computation option before calling this function.
+ -- You may also have combined these computation options: look at the
+ -- example given above to illustrate the use of the constructors.
+ is redefined static;
HasAncestorFaceOn1(me; E : Shape from TopoDS;
- F : out Shape from TopoDS)
- returns Boolean;
- ---Level: Public
- ---Purpose:
- -- get the face of the first part giving section edge <E>.
- -- Returns True on the 3 following conditions :
- -- 1/ <E> is an edge returned by the Shape() method.
- -- 2/ First part of section performed is a shape.
- -- 3/ <E> is built on a intersection curve (i.e <E>
- -- is not the result of common edges)
- -- When False, F remains untouched.
+ F : out Shape from TopoDS)
+ returns Boolean;
+ ---Level: Public
+ ---Purpose:
+ -- get the face of the first part giving section edge <E>.
+ -- Returns True on the 3 following conditions :
+ -- 1/ <E> is an edge returned by the Shape() method.
+ -- 2/ First part of section performed is a shape.
+ -- 3/ <E> is built on a intersection curve (i.e <E>
+ -- is not the result of common edges)
+ -- When False, F remains untouched.
HasAncestorFaceOn2(me; E : Shape from TopoDS;
- F : out Shape from TopoDS)
- returns Boolean;
- ---Purpose: Identifies the ancestor faces of
- -- the intersection edge E resulting from the last
- -- computation performed in this framework, that is, the faces of
- -- the two original shapes on which the edge E lies:
- -- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and
- -- - HasAncestorFaceOn2 gives the ancestor face in the second shape.
- -- These functions return true if an ancestor face F is found, or false if not.
- -- An ancestor face is identifiable for the edge E if the following
- -- conditions are satisfied:
- -- - the first part on which this algorithm performed its
- -- last computation is a shape, that is, it was not given as
- -- a surface or a plane at the time of construction of this
- -- algorithm or at a later time by the Init1 function,
- -- - E is one of the elementary edges built by the
- -- last computation of this section algorithm.
- -- To use these functions properly, you have to test the returned
- -- Boolean value before using the ancestor face: F is significant
- -- only if the returned Boolean value equals true.
+ F : out Shape from TopoDS)
+ returns Boolean;
+ ---Purpose: Identifies the ancestor faces of
+ -- the intersection edge E resulting from the last
+ -- computation performed in this framework, that is, the faces of
+ -- the two original shapes on which the edge E lies:
+ -- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and
+ -- - HasAncestorFaceOn2 gives the ancestor face in the second shape.
+ -- These functions return true if an ancestor face F is found, or false if not.
+ -- An ancestor face is identifiable for the edge E if the following
+ -- conditions are satisfied:
+ -- - the first part on which this algorithm performed its
+ -- last computation is a shape, that is, it was not given as
+ -- a surface or a plane at the time of construction of this
+ -- algorithm or at a later time by the Init1 function,
+ -- - E is one of the elementary edges built by the
+ -- last computation of this section algorithm.
+ -- To use these functions properly, you have to test the returned
+ -- Boolean value before using the ancestor face: F is significant
+ -- only if the returned Boolean value equals true.
InitParameters(me: out)
- ---Level: Private
- is private;
+ ---Level: Private
+ is private;
fields
myshapeisnull : Boolean from Standard;
Quadric from IntSurf,
QuadricTool from IntSurf,
WLine from IntPatch);
-
+
private class ParameterAndOrientation;
private class SequenceOfParameterAndOrientation instantiates
Sequence from TCollection(ParameterAndOrientation);
+ AdjustPeriodic(thePar : Real from Standard;
+ theParMin : Real from Standard;
+ theParMax : Real from Standard;
+ thePeriod : Real from Standard;
+ theNewPar : out Real from Standard;
+ theOffset : out Real from Standard;
+ theEps : Real from Standard = 0.0)
+ returns Boolean from Standard;
+ ---Purpose: Adjusts the parameter <thePar> to the range [theParMin, theParMax]
+
end GeomInt;
--- /dev/null
+
+// Created on: 25.08.14 17:59:59
+// Created by: jgv@VIVEX
+// 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 <GeomInt.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+//=======================================================================
+//function : AdjustPeriodic
+//purpose :
+//=======================================================================
+Standard_Boolean GeomInt::AdjustPeriodic(const Standard_Real thePar,
+ const Standard_Real theParMin,
+ const Standard_Real theParMax,
+ const Standard_Real thePeriod,
+ Standard_Real &theNewPar,
+ Standard_Real &theOffset,
+ const Standard_Real theEps)
+{
+ Standard_Boolean bMin, bMax;
+ //
+ theOffset = 0.;
+ theNewPar = thePar;
+ bMin = theParMin - thePar > theEps;
+ bMax = thePar - theParMax > theEps;
+ //
+ if (bMin || bMax) {
+ Standard_Real dp, aNbPer;
+ //
+ dp = (bMin) ? (theParMax - thePar) : (theParMin - thePar);
+ modf(dp / thePeriod, &aNbPer);
+ //
+ theOffset = aNbPer * thePeriod;
+ theNewPar += theOffset;
+ }
+ //
+ return (theOffset > 0.);
+}