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

0024639: Parallelization FillDS part of BO

The contents dealing with the parallel computation of Vertex/Face interferences.
This commit is contained in:
pkv
2014-04-08 12:22:16 +04:00
committed by apn
parent ba06f8bbee
commit e30616a780
3 changed files with 583 additions and 479 deletions

View File

@@ -18,24 +18,31 @@
#include <BOPAlgo_PaveFiller.ixx> #include <BOPAlgo_PaveFiller.ixx>
#include <NCollection_IncAllocator.hxx> #include <NCollection_IncAllocator.hxx>
//
#include <GeomAPI_ProjectPointOnSurf.hxx>
//
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
//
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepBndLib.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Builder.hxx>
//
#include <IntTools_EdgeFace.hxx> #include <IntTools_EdgeFace.hxx>
#include <IntTools_Range.hxx> #include <IntTools_Range.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx> #include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx> #include <IntTools_CommonPrt.hxx>
#include <BOPTools_AlgoTools.hxx> //
#include <BOPCol_MapOfInteger.hxx> #include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_TBB.hxx>
//
#include <BOPInt_Context.hxx> #include <BOPInt_Context.hxx>
#include <BOPInt_Tools.hxx>
//
#include <BOPDS_Interf.hxx> #include <BOPDS_Interf.hxx>
#include <BOPDS_Iterator.hxx> #include <BOPDS_Iterator.hxx>
#include <BOPDS_PaveBlock.hxx> #include <BOPDS_PaveBlock.hxx>
@@ -43,44 +50,104 @@
#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx> #include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
#include <BOPDS_CommonBlock.hxx> #include <BOPDS_CommonBlock.hxx>
#include <BOPDS_Pave.hxx> #include <BOPDS_Pave.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPDS_CoupleOfPaveBlocks.hxx> #include <BOPDS_CoupleOfPaveBlocks.hxx>
#include <BRepBndLib.hxx> //
#include <BOPTools_AlgoTools.hxx>
//
#include <BOPAlgo_Tools.hxx> #include <BOPAlgo_Tools.hxx>
#include <BOPInt_Tools.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Builder.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
//=======================================================================
//class : BOPAlgo_EdgeFace
//purpose :
//=======================================================================
class BOPAlgo_EdgeFace : public IntTools_EdgeFace {
public:
BOPAlgo_EdgeFace()
: IntTools_EdgeFace(), myIE(-1), myIF(-1) {
};
//
~BOPAlgo_EdgeFace(){
};
//
void SetIndices(const Standard_Integer nE,
const Standard_Integer nF) {
myIE=nE;
myIF=nF;
}
//
void Indices(Standard_Integer& nE,
Standard_Integer& nF) {
nE=myIE;
nF=myIF;
}
//
void SetNewSR(const IntTools_Range& aR){
myNewSR=aR;
}
//
IntTools_Range& NewSR(){
return myNewSR;
}
//
void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
myPB=aPB;
}
//
Handle(BOPDS_PaveBlock)& PaveBlock() {
return myPB;
}
//
protected:
Standard_Integer myIE;
Standard_Integer myIF;
IntTools_Range myNewSR;
Handle(BOPDS_PaveBlock) myPB;
};
//
//=======================================================================
typedef BOPCol_NCVector<BOPAlgo_EdgeFace> BOPAlgo_VectorOfEdgeFace;
//
typedef BOPCol_TBBContextFunctor
<BOPAlgo_EdgeFace,
BOPAlgo_VectorOfEdgeFace,
Handle_BOPInt_Context,
BOPInt_Context> BOPAlgo_EdgeFaceFunctor;
//
typedef BOPCol_TBBContextCnt
<BOPAlgo_EdgeFaceFunctor,
BOPAlgo_VectorOfEdgeFace,
Handle_BOPInt_Context> BOPAlgo_EdgeFaceCnt;
//
//======================================================================= //=======================================================================
//function : PerformEF //function : PerformEF
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_PaveFiller::PerformEF() void BOPAlgo_PaveFiller::PerformEF()
{ {
Standard_Integer iSize; Standard_Integer iSize;
// //
myErrorStatus=0; myErrorStatus=0;
// //
FillShrunkData(TopAbs_EDGE, TopAbs_FACE);
//
myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE); myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
iSize=myIterator->ExpectedLength(); iSize=myIterator->ExpectedLength();
if (!iSize) { if (!iSize) {
return; return;
} }
//---------------------------------------------------------------------- //
Standard_Boolean bJustAdd, bV[2]; Standard_Boolean bJustAdd, bV[2];
Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX, nV[2]; Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX, nV[2];
Standard_Integer aNbEdgeFace, k;
Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection; Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection;
Handle(NCollection_IncAllocator) aAllocator; Handle(NCollection_IncAllocator) aAllocator;
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
BOPDS_ListIteratorOfListOfPaveBlock aIt; BOPDS_ListIteratorOfListOfPaveBlock aIt;
BOPAlgo_VectorOfEdgeFace aVEdgeFace;
BRep_Builder aBB;
//-----------------------------------------------------scope f //-----------------------------------------------------scope f
// //
BRep_Builder aBB; ////aAllocator=new NCollection_IncAllocator();
//
aAllocator=new NCollection_IncAllocator();
BOPCol_MapOfInteger aMIEFC(100, aAllocator); BOPCol_MapOfInteger aMIEFC(100, aAllocator);
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
@@ -111,8 +178,6 @@
// //
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn(); const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
// //
aTolE=BRep_Tool::Tolerance(aE); aTolE=BRep_Tool::Tolerance(aE);
aTolF=BRep_Tool::Tolerance(aF); aTolF=BRep_Tool::Tolerance(aF);
@@ -128,10 +193,7 @@
} }
// //
if (!aPB->HasShrunkData()) { if (!aPB->HasShrunkData()) {
FillShrunkData(aPB); continue;
if (myWarningStatus) {
continue;
}
} }
// //
Bnd_Box aBBE; Bnd_Box aBBE;
@@ -141,8 +203,10 @@
continue; continue;
} }
// //
// -----------f BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace.Append1();
IntTools_EdgeFace aEdgeFace; //
aEdgeFace.SetIndices(nE, nF);
aEdgeFace.SetPaveBlock(aPB);
// //
aEdgeFace.SetEdge (aE); aEdgeFace.SetEdge (aE);
aEdgeFace.SetFace (aF); aEdgeFace.SetFace (aF);
@@ -150,45 +214,69 @@
aEdgeFace.SetTolF (aTolF); aEdgeFace.SetTolF (aTolF);
aEdgeFace.SetDiscretize (aDiscretize); aEdgeFace.SetDiscretize (aDiscretize);
aEdgeFace.SetDeflection (aDeflection); aEdgeFace.SetDeflection (aDeflection);
aEdgeFace.SetContext(myContext);
// //
IntTools_Range aSR(aTS1, aTS2); IntTools_Range aSR(aTS1, aTS2);
IntTools_Range anewSR=aSR; IntTools_Range anewSR=aSR;
BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR); BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR);
aEdgeFace.SetNewSR(anewSR);
// //
aPB->Range(aT1, aT2); aPB->Range(aT1, aT2);
IntTools_Range aPBRange(aT1, aT2); IntTools_Range aPBRange(aT1, aT2);
aSR = aPBRange; aSR = aPBRange;
BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange); BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange);
//
aEdgeFace.SetRange (aPBRange); aEdgeFace.SetRange (aPBRange);
// //
aEdgeFace.Perform(); }//for (; aIt.More(); aIt.Next()) {
if (!aEdgeFace.IsDone()) { }//for (; myIterator->More(); myIterator->Next()) {
continue; //
} aNbEdgeFace=aVEdgeFace.Extent();
// //=================================================================
aPB->Indices(nV[0], nV[1]); BOPAlgo_EdgeFaceCnt::Perform(myRunParallel, aVEdgeFace, myContext);
// //=================================================================
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts(); //
aNbCPrts=aCPrts.Length(); for (k=0; k < aNbEdgeFace; ++k) {
for (i=1; i<=aNbCPrts; ++i) { BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace(k);
const IntTools_CommonPrt& aCPart=aCPrts(i); if (!aEdgeFace.IsDone()) {
aType=aCPart.Type(); continue;
switch (aType) { }
//~~~
aEdgeFace.Indices(nE, nF);
//
const TopoDS_Edge& aE=aEdgeFace.Edge();
const TopoDS_Face& aF=aEdgeFace.Face();
//
aTolE=aEdgeFace.TolE();
aTolF=aEdgeFace.TolF();
const IntTools_Range& anewSR=aEdgeFace.NewSR();
Handle(BOPDS_PaveBlock)& aPB=aEdgeFace.PaveBlock();
//
aPB->Range(aT1, aT2);
aPB->Indices(nV[0], nV[1]);
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
////const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
//~~~
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts();
aNbCPrts=aCPrts.Length();
for (i=1; i<=aNbCPrts; ++i) {
const IntTools_CommonPrt& aCPart=aCPrts(i);
aType=aCPart.Type();
switch (aType) {
case TopAbs_VERTEX: { case TopAbs_VERTEX: {
Standard_Boolean bIsOnPave[2]; Standard_Boolean bIsOnPave[2];
Standard_Integer j; Standard_Integer j;
Standard_Real aT, aTolToDecide; Standard_Real aT, aTolToDecide;
TopoDS_Vertex aVnew; TopoDS_Vertex aVnew;
//
BOPInt_Tools::VertexParameter(aCPart, aT); BOPInt_Tools::VertexParameter(aCPart, aT);
BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew); BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew);
// //
const IntTools_Range& aR=aCPart.Range1(); const IntTools_Range& aR=aCPart.Range1();
aTolToDecide=5.e-8; aTolToDecide=5.e-8;
// //
IntTools_Range aR1(aT1, anewSR.First()), aR2(anewSR.Last(), aT2); IntTools_Range aR1(aT1,anewSR.First()),aR2(anewSR.Last(), aT2);
// //
bIsOnPave[0]=BOPInt_Tools::IsInRange(aR1, aR, aTolToDecide); bIsOnPave[0]=BOPInt_Tools::IsInRange(aR1, aR, aTolToDecide);
bIsOnPave[1]=BOPInt_Tools::IsInRange(aR2, aR, aTolToDecide); bIsOnPave[1]=BOPInt_Tools::IsInRange(aR2, aR, aTolToDecide);
@@ -213,7 +301,8 @@
if (bIsOnPave[j]) { if (bIsOnPave[j]) {
bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn); bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn);
if (bV[j]) { if (bV[j]) {
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV[j]))); const TopoDS_Vertex& aV=
(*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
BOPTools_AlgoTools::UpdateVertex(aE, aT, aV); BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]); BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]);
Bnd_Box& aBoxDS=aSIDS.ChangeBox(); Bnd_Box& aBoxDS=aSIDS.ChangeBox();
@@ -231,7 +320,9 @@
} }
// //
const gp_Pnt& aPnew = BRep_Tool::Pnt(aVnew); const gp_Pnt& aPnew = BRep_Tool::Pnt(aVnew);
if (!myContext->IsValidPointForFace(aPnew, aF, aTolE+aTolF)) { if (!myContext->IsValidPointForFace(aPnew,
aF,
aTolE+aTolF)) {
continue; continue;
} }
// //
@@ -283,11 +374,9 @@
break; break;
default: default:
break; break;
}//switch (aType) { }//switch (aType) {
}//for (i=1; i<=aNbCPrts; ++i) { }//for (i=1; i<=aNbCPrts; ++i) {
// -----------t }// for (k=0; k < aNbEdgeEdge; ++k) {
}//for (; aIt.More(); aIt.Next()) {
}//for (; myIterator->More(); myIterator->Next()) {
// //
//========================================= //=========================================
// post treatment // post treatment
@@ -309,17 +398,15 @@
aMIEFC.Clear(); aMIEFC.Clear();
aMVCPB.Clear(); aMVCPB.Clear();
aMPBLI.Clear(); aMPBLI.Clear();
aAllocator.Nullify(); ////aAllocator.Nullify();
//
} }
//======================================================================= //=======================================================================
//function : PerformVertices1 //function : PerformVertices1
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator) Handle(NCollection_BaseAllocator)& theAllocator)
{ {
Standard_Integer aNbV, iRet; Standard_Integer aNbV, iRet;
// //
@@ -452,9 +539,10 @@
// function: CheckFacePaves // function: CheckFacePaves
// purpose: // purpose:
//======================================================================= //=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const Standard_Integer nVx, Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
const BOPCol_MapOfInteger& aMIFOn, (const Standard_Integer nVx,
const BOPCol_MapOfInteger& aMIFIn) const BOPCol_MapOfInteger& aMIFOn,
const BOPCol_MapOfInteger& aMIFIn)
{ {
Standard_Boolean bRet; Standard_Boolean bRet;
Standard_Integer nV; Standard_Integer nV;
@@ -485,8 +573,9 @@
// function: CheckFacePaves // function: CheckFacePaves
// purpose: // purpose:
//======================================================================= //=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aVnew, Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
const BOPCol_MapOfInteger& aMIF) (const TopoDS_Vertex& aVnew,
const BOPCol_MapOfInteger& aMIF)
{ {
Standard_Boolean bRet; Standard_Boolean bRet;
Standard_Integer nV, iFlag; Standard_Integer nV, iFlag;
@@ -510,8 +599,9 @@
//function : ForceInterfVF //function : ForceInterfVF
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF(const Standard_Integer nV, Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF
const Standard_Integer nF) (const Standard_Integer nV,
const Standard_Integer nF)
{ {
Standard_Boolean bRet; Standard_Boolean bRet;
// //

View File

@@ -15,10 +15,9 @@
class EdgeFace from IntTools class EdgeFace from IntTools
---Purpose: The class provides Edge/Face algorithm to determine ---Purpose: The class provides Edge/Face algorithm to determine
--- common parts between edge and face in 3-d space. --- common parts between edge and face in 3-d space.
-- Common parts can be : Vertices or Edges. -- Common parts can be : Vertices or Edges.
---
uses uses
Pnt from gp, Pnt from gp,
@@ -39,197 +38,216 @@ uses
is is
Create Create
returns EdgeFace from IntTools; returns EdgeFace from IntTools;
---Purpose: ---Purpose:
--- Empty Constructor --- Empty Constructor
--- ---
SetEdge (me:out; anEdge:Edge from TopoDS); SetEdge (me:out;
---Purpose: anEdge:Edge from TopoDS);
--- Initializes algorithm by the edge anEdge ---Purpose:
--- --- Initializes algorithm by the edge anEdge
SetTolE (me:out; aTolEdge1:Real from Standard); SetTolE (me:out;
---Purpose: aTolEdge1:Real from Standard);
--- Initializes algorithm by edge tolerance ---Purpose:
--- --- Initializes algorithm by edge tolerance
SetFace (me:out; aFace:Face from TopoDS); SetFace(me:out;
---Purpose: aFace:Face from TopoDS);
--- Initializes algorithm by the face aFace ---Purpose:
--- --- Initializes algorithm by the face aFace
SetTolF (me:out; aTolFace:Real from Standard); SetTolF (me:out;
---Purpose: aTolFace:Real from Standard);
--- Initializes algorithm by face tolerance ---Purpose:
--- --- Initializes algorithm by face tolerance
SetDiscretize (me:out; aDiscret:Integer from Standard); Edge (me)
---Purpose: returns Edge from TopoDS;
--- Initializes algorithm by discretization value ---C++: return const &
--- ---Purpose:
--- Returns edge
SetDeflection (me:out; aDeflection:Real from Standard); Face(me)
---Purpose: returns Face from TopoDS;
--- Initializes algorithm by deflection value ---C++: return const &
--- ---Purpose:
--- Returns face
SetEpsilonT (me:out; anEpsT:Real from Standard); TolE (me)
---Purpose: returns Real from Standard;
--- Initializes algorithm by parameter tolerance ---Purpose:
--- --- Returns tolerance of the edge
SetEpsilonNull (me:out; anEpsNull:Real from Standard); TolF (me)
---Purpose: returns Real from Standard;
--- Initializes algorithm by distance tolerance ---Purpose:
--- --- Returns tolerance of the face
SetRange (me:out; aRange:Range from IntTools); SetDiscretize (me:out;
---Purpose: aDiscret:Integer from Standard);
--- Sets boundaries for edge. ---Purpose:
--- The algorithm processes edge inside these boundaries. --- Initializes algorithm by discretization value
---
SetRange (me:out; aFirst, aLast:Real from Standard); SetDeflection (me:out;
---Purpose: aDeflection:Real from Standard);
--- Sets boundaries for edge. ---Purpose:
--- The algorithm processes edge inside these boundaries. --- Initializes algorithm by deflection value
---
SetEpsilonT(me:out;
anEpsT:Real from Standard);
---Purpose:
--- Initializes algorithm by parameter tolerance
SetEpsilonNull (me:out;
anEpsNull:Real from Standard);
---Purpose:
--- Initializes algorithm by distance tolerance
SetRange (me:out;
aRange:Range from IntTools);
---Purpose:
--- Sets boundaries for edge.
--- The algorithm processes edge inside these boundaries.
SetRange (me:out;
aFirst, aLast:Real from Standard);
---Purpose:
--- Sets boundaries for edge.
--- The algorithm processes edge inside these boundaries.
SetContext (me: in out; SetContext (me: in out;
theContext: Context from BOPInt); theContext: Context from BOPInt);
---Purpose: ---Purpose:
--- Sets the intersecton context --- Sets the intersecton context
---
Context (me) Context (me)
returns Context from BOPInt; returns Context from BOPInt;
---C++:return const & ---C++:return const &
---Purpose: ---Purpose:
--- Gets the intersecton context --- Gets the intersecton context
---
Perform (me:out); Perform (me:out);
---Purpose: ---Purpose:
--- Launches the process --- Launches the process
---
IsDone (me) IsDone (me)
returns Boolean from Standard; returns Boolean from Standard;
---Purpose: ---Purpose:
--- Returns true if computation was done --- Returns true if computation was done
--- successfully, otherwise returns false --- successfully, otherwise returns false
---
ErrorStatus(me) ErrorStatus(me)
returns Integer from Standard; returns Integer from Standard;
---Purpose: ---Purpose:
--- Returns code of completion --- Returns code of completion
--- 0 - means successful completion --- 0 - means successful completion
--- 1 - the process was not started --- 1 - the process was not started
--- 2,3,4,5 - invalid source data for the algorithm --- 2,3,4,5 - invalid source data for the algorithm
--- 6 - discretization failed --- 6 - discretization failed
--- 7 - no projectable ranges found --- 7 - no projectable ranges found
--- 11 - distance computing error --- 11 - distance computing error
---
CommonParts(me) CommonParts (me)
returns SequenceOfCommonPrts from IntTools; returns SequenceOfCommonPrts from IntTools;
---C++: return const& ---C++: return const&
---Purpose: ---Purpose:
--- Returns results --- Returns results
---
Range (me) Range (me)
returns Range from IntTools; returns Range from IntTools;
---C++: return const& ---C++: return const&
---Purpose: ---Purpose:
--- Returns boundaries for edge --- Returns boundaries for edge
---
--
IsEqDistance(myclass; IsEqDistance(myclass;
aP: Pnt from gp; aP: Pnt from gp;
aS: Surface from BRepAdaptor; aS: Surface from BRepAdaptor;
aT: Real from Standard; aT: Real from Standard;
aD:out Real from Standard) aD:out Real from Standard)
returns Boolean from Standard; returns Boolean from Standard;
---Purpose:
---
---
--
----------------------------------------------------- -------------------------------------------------------
-- Block of private methods of the algorithm -- -- Block of protected methods of the algorithm --
----------------------------------------------------- -------------------------------------------------------
CheckData (me:out) is private; CheckData (me:out)
is protected;
Prepare (me:out) is private; Prepare (me:out)
is protected;
IsProjectable (me; t:Real from Standard) IsProjectable (me;
returns Boolean from Standard t:Real from Standard)
is private; returns Boolean from Standard
is protected;
FindProjectableRoot (me:out; FindProjectableRoot (me:out;
t1,t2:Real from Standard; t1,t2:Real from Standard;
f1,f2:Integer from Standard; f1,f2:Integer from Standard;
tRoot:out Real from Standard) tRoot:out Real from Standard)
is private; is protected;
DistanceFunction (me:out;t:Real from Standard) DistanceFunction (me:out;
returns Real from Standard t:Real from Standard)
is private; returns Real from Standard
is protected;
DerivativeFunction (me:out;t:Real from Standard) DerivativeFunction (me:out;
returns Real from Standard t:Real from Standard)
is private; returns Real from Standard
is protected;
PrepareArgsFuncArrays (me:out;t1,t2:Real from Standard) PrepareArgsFuncArrays (me:out;
is private; t1,t2:Real from Standard)
is protected;
AddDerivativePoints (me:out; t,f:CArray1OfReal from IntTools) AddDerivativePoints(me:out;
is private; t,f:CArray1OfReal from IntTools)
is protected;
FindSimpleRoot (me:out; IP:Integer from Standard; FindSimpleRoot (me:out;
ta, tb, fA:Real from Standard) IP:Integer from Standard;
returns Real from Standard ta, tb, fA:Real from Standard)
is private; returns Real from Standard
is protected;
FindGoldRoot (me:out; ta, tb, coeff:Real from Standard) FindGoldRoot (me:out;
returns Real from Standard ta, tb, coeff:Real from Standard)
is private; returns Real from Standard
is protected;
MakeType (me:out; MakeType (me:out;
aCP: out CommonPrt from IntTools) aCP: out CommonPrt from IntTools)
returns Integer from Standard returns Integer from Standard
is private; is protected;
IsIntersection (me:out; ta,tb:Real from Standard) IsIntersection (me:out;
is private; ta,tb:Real from Standard)
is protected;
FindDerivativeRoot (me:out;t,f:CArray1OfReal from IntTools) FindDerivativeRoot(me:out;
is private; t,f:CArray1OfReal from IntTools)
is protected;
-- RemoveIdenticalRoots(me:out)
RemoveIdenticalRoots(me:out) is protected;
is private;
CheckTouch (me: out; CheckTouch (me: out;
aCP: CommonPrt from IntTools; aCP: CommonPrt from IntTools;
aTX:out Real from Standard) aTX:out Real from Standard)
returns Boolean from Standard returns Boolean from Standard
is private; is protected;
CheckTouchVertex (me:out; CheckTouchVertex (me:out;
aCP: CommonPrt from IntTools; aCP: CommonPrt from IntTools;
aTX:out Real from Standard) aTX:out Real from Standard)
returns Boolean from Standard returns Boolean from Standard
is private; is protected;
--
fields fields
-- Data -- Data

View File

@@ -58,7 +58,7 @@
#include <Extrema_POnCurv.hxx> #include <Extrema_POnCurv.hxx>
#include <Extrema_POnSurf.hxx> #include <Extrema_POnSurf.hxx>
// modified by NIZHNY-MKK Thu Jul 21 11:35:59 2005
#include <IntCurveSurface_HInter.hxx> #include <IntCurveSurface_HInter.hxx>
#include <GeomAdaptor_HCurve.hxx> #include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx> #include <GeomAdaptor_HSurface.hxx>
@@ -70,14 +70,14 @@
static static
Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& , Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& ,
const BRepAdaptor_Surface& ); const BRepAdaptor_Surface& );
static static
Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve , Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve ,
const BRepAdaptor_Surface& aSurface); const BRepAdaptor_Surface& aSurface);
static static
Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret, Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret,
const BRepAdaptor_Curve& aCurve , const BRepAdaptor_Curve& aCurve ,
const BRepAdaptor_Surface& aSurface); const BRepAdaptor_Surface& aSurface);
//======================================================================= //=======================================================================
//function : IntTools_EdgeFace::IntTools_EdgeFace //function : IntTools_EdgeFace::IntTools_EdgeFace
@@ -117,25 +117,23 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetEdge //function : SetEdge
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetEdge(const TopoDS_Edge& anEdge) void IntTools_EdgeFace::SetEdge(const TopoDS_Edge& anEdge)
{ {
myEdge=anEdge; myEdge=anEdge;
} }
//======================================================================= //=======================================================================
//function : SetFace //function : SetFace
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetFace(const TopoDS_Face& aFace) void IntTools_EdgeFace::SetFace(const TopoDS_Face& aFace)
{ {
myFace=aFace; myFace=aFace;
} }
//======================================================================= //=======================================================================
//function : SetTolE //function : SetTolE
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetTolE(const Standard_Real aTol) void IntTools_EdgeFace::SetTolE(const Standard_Real aTol)
{ {
myTolE=aTol; myTolE=aTol;
} }
@@ -143,16 +141,47 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetTolF //function : SetTolF
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetTolF(const Standard_Real aTol) void IntTools_EdgeFace::SetTolF(const Standard_Real aTol)
{ {
myTolF=aTol; myTolF=aTol;
} }
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TopoDS_Edge& IntTools_EdgeFace::Edge()const
{
return myEdge;
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
const TopoDS_Face& IntTools_EdgeFace::Face()const
{
return myFace;
}
//=======================================================================
//function : TolE
//purpose :
//=======================================================================
Standard_Real IntTools_EdgeFace::TolE()const
{
return myTolE;
}
//=======================================================================
//function : TolF
//purpose :
//=======================================================================
Standard_Real IntTools_EdgeFace::TolF()const
{
return myTolF;
}
//======================================================================= //=======================================================================
//function : SetDiscretize //function : SetDiscretize
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetDiscretize(const Standard_Integer aDiscret) void IntTools_EdgeFace::SetDiscretize(const Standard_Integer aDiscret)
{ {
myDiscret=aDiscret; myDiscret=aDiscret;
} }
@@ -160,7 +189,7 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetDeflection //function : SetDeflection
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetDeflection(const Standard_Real aDefl) void IntTools_EdgeFace::SetDeflection(const Standard_Real aDefl)
{ {
myDeflection=aDefl; myDeflection=aDefl;
} }
@@ -168,7 +197,7 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetEpsilonT //function : SetEpsilonT
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetEpsilonT(const Standard_Real anEpsT) void IntTools_EdgeFace::SetEpsilonT(const Standard_Real anEpsT)
{ {
myEpsT=anEpsT; myEpsT=anEpsT;
} }
@@ -176,7 +205,7 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetEpsilonNull //function : SetEpsilonNull
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetEpsilonNull(const Standard_Real anEpsNull) void IntTools_EdgeFace::SetEpsilonNull(const Standard_Real anEpsNull)
{ {
myEpsNull=anEpsNull; myEpsNull=anEpsNull;
} }
@@ -185,8 +214,8 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetRange //function : SetRange
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetRange(const Standard_Real aFirst, void IntTools_EdgeFace::SetRange(const Standard_Real aFirst,
const Standard_Real aLast) const Standard_Real aLast)
{ {
myRange.SetFirst (aFirst); myRange.SetFirst (aFirst);
myRange.SetLast (aLast); myRange.SetLast (aLast);
@@ -196,7 +225,7 @@ const Handle(BOPInt_Context)& IntTools_EdgeFace::Context()const
//function : SetRange //function : SetRange
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::SetRange(const IntTools_Range& aRange) void IntTools_EdgeFace::SetRange(const IntTools_Range& aRange)
{ {
myRange.SetFirst (aRange.First()); myRange.SetFirst (aRange.First());
myRange.SetLast (aRange.Last()); myRange.SetLast (aRange.Last());
@@ -251,7 +280,7 @@ void IntTools_EdgeFace::CheckData()
//function : Prepare //function : Prepare
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::Prepare() void IntTools_EdgeFace::Prepare()
{ {
Standard_Integer pri; Standard_Integer pri;
IntTools_CArray1OfReal aPars; IntTools_CArray1OfReal aPars;
@@ -264,7 +293,7 @@ void IntTools_EdgeFace::CheckData()
// //
// 2.Prepare myCriteria // 2.Prepare myCriteria
if (aCurveType==GeomAbs_BSplineCurve|| if (aCurveType==GeomAbs_BSplineCurve||
aCurveType==GeomAbs_BezierCurve) { aCurveType==GeomAbs_BezierCurve) {
myCriteria=1.5*myTolE+myTolF; myCriteria=1.5*myTolE+myTolF;
} }
else { else {
@@ -282,7 +311,8 @@ void IntTools_EdgeFace::CheckData()
// //
// //
// 3.Prepare myPars // 3.Prepare myPars
pri = IntTools::PrepareArgs(myC, myTmax, myTmin, myDiscret, myDeflection, aPars); pri = IntTools::PrepareArgs(myC, myTmax, myTmin,
myDiscret, myDeflection, aPars);
if (pri) { if (pri) {
myErrorStatus=6; myErrorStatus=6;
return; return;
@@ -332,20 +362,20 @@ void IntTools_EdgeFace::CheckData()
if (i==(aNb-1)) { if (i==(aNb-1)) {
if (ind1 && ind0) { if (ind1 && ind0) {
aRange.SetLast(t1); aRange.SetLast(t1);
myProjectableRanges.Append(aRange); myProjectableRanges.Append(aRange);
} }
if (ind1 && !ind0) { if (ind1 && !ind0) {
FindProjectableRoot(t0, t1, ind0, ind1, tRoot); FindProjectableRoot(t0, t1, ind0, ind1, tRoot);
aRange.SetFirst(tRoot); aRange.SetFirst(tRoot);
aRange.SetLast(t1); aRange.SetLast(t1);
myProjectableRanges.Append(aRange); myProjectableRanges.Append(aRange);
} }
// //
if (ind0 && !ind1) { if (ind0 && !ind1) {
FindProjectableRoot(t0, t1, ind0, ind1, tRoot); FindProjectableRoot(t0, t1, ind0, ind1, tRoot);
aRange.SetLast(tRoot); aRange.SetLast(tRoot);
myProjectableRanges.Append(aRange); myProjectableRanges.Append(aRange);
} }
// //
break; break;
@@ -355,11 +385,11 @@ void IntTools_EdgeFace::CheckData()
FindProjectableRoot(t0, t1, ind0, ind1, tRoot); FindProjectableRoot(t0, t1, ind0, ind1, tRoot);
if (ind0 && !ind1) { if (ind0 && !ind1) {
aRange.SetLast(tRoot); aRange.SetLast(tRoot);
myProjectableRanges.Append(aRange); myProjectableRanges.Append(aRange);
} }
else { else {
aRange.SetFirst(tRoot); aRange.SetFirst(tRoot);
} }
} // if (ind0 != ind1) } // if (ind0 != ind1)
ind0=ind1; ind0=ind1;
@@ -370,11 +400,12 @@ void IntTools_EdgeFace::CheckData()
//function : FindProjectableRoot //function : FindProjectableRoot
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::FindProjectableRoot (const Standard_Real tt1, void IntTools_EdgeFace::FindProjectableRoot
const Standard_Real tt2, (const Standard_Real tt1,
const Standard_Integer ff1, const Standard_Real tt2,
const Standard_Integer ff2, const Standard_Integer ff1,
Standard_Real& tRoot) const Standard_Integer ff2,
Standard_Real& tRoot)
{ {
Standard_Real tm, t1, t2, aEpsT; Standard_Real tm, t1, t2, aEpsT;
Standard_Integer anIsProj1, anIsProj2, anIsProjm; Standard_Integer anIsProj1, anIsProj2, anIsProjm;
@@ -408,7 +439,8 @@ void IntTools_EdgeFace::CheckData()
//function : IsProjectable //function : IsProjectable
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IntTools_EdgeFace::IsProjectable(const Standard_Real aT) const Standard_Boolean IntTools_EdgeFace::IsProjectable
(const Standard_Real aT) const
{ {
Standard_Boolean bFlag; Standard_Boolean bFlag;
gp_Pnt aPC; gp_Pnt aPC;
@@ -422,7 +454,8 @@ Standard_Boolean IntTools_EdgeFace::IsProjectable(const Standard_Real aT) const
//function : DistanceFunction //function : DistanceFunction
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t) Standard_Real IntTools_EdgeFace::DistanceFunction
(const Standard_Real t)
{ {
Standard_Real aD; Standard_Real aD;
@@ -466,10 +499,11 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : IsEqDistance //function : IsEqDistance
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IntTools_EdgeFace::IsEqDistance(const gp_Pnt& aP, Standard_Boolean IntTools_EdgeFace::IsEqDistance
const BRepAdaptor_Surface& aBAS, (const gp_Pnt& aP,
const Standard_Real aTol, const BRepAdaptor_Surface& aBAS,
Standard_Real& aD) const Standard_Real aTol,
Standard_Real& aD)
{ {
Standard_Boolean bRetFlag=Standard_True; Standard_Boolean bRetFlag=Standard_True;
@@ -526,8 +560,8 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//purpose : Obtain //purpose : Obtain
// myFuncArray and myArgsArray for the interval [ta, tb] // myFuncArray and myArgsArray for the interval [ta, tb]
//======================================================================= //=======================================================================
void IntTools_EdgeFace::PrepareArgsFuncArrays(const Standard_Real ta, void IntTools_EdgeFace::PrepareArgsFuncArrays(const Standard_Real ta,
const Standard_Real tb) const Standard_Real tb)
{ {
IntTools_CArray1OfReal anArgs, aFunc; IntTools_CArray1OfReal anArgs, aFunc;
Standard_Integer i, aNb, pri; Standard_Integer i, aNb, pri;
@@ -568,14 +602,13 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
AddDerivativePoints(anArgs, aFunc); AddDerivativePoints(anArgs, aFunc);
} }
//======================================================================= //=======================================================================
//function : AddDerivativePoints //function : AddDerivativePoints
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::AddDerivativePoints(const IntTools_CArray1OfReal& t, void IntTools_EdgeFace::AddDerivativePoints
const IntTools_CArray1OfReal& f) (const IntTools_CArray1OfReal& t,
const IntTools_CArray1OfReal& f)
{ {
Standard_Integer i, j, n, k, nn=100; Standard_Integer i, j, n, k, nn=100;
Standard_Real fr, tr, tr1, dEpsNull=10.*myEpsNull; Standard_Real fr, tr, tr1, dEpsNull=10.*myEpsNull;
@@ -638,16 +671,16 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
if (fd1*fd2 < 0.) { if (fd1*fd2 < 0.) {
if (fabs(fd1) < myEpsNull) { if (fabs(fd1) < myEpsNull) {
tr=t1; tr=t1;
fr=DistanceFunction(tr);//fd1; fr=DistanceFunction(tr);//fd1;
} }
else if (fabs(fd2) < myEpsNull) { else if (fabs(fd2) < myEpsNull) {
tr=t2; tr=t2;
fr=DistanceFunction(tr); fr=DistanceFunction(tr);
} }
else { else {
tr=FindSimpleRoot(2, t1, t2, fd1); tr=FindSimpleRoot(2, t1, t2, fd1);
fr=DistanceFunction(tr); fr=DistanceFunction(tr);
} }
aTSeq.Append(tr); aTSeq.Append(tr);
@@ -661,11 +694,11 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
for (i=1; i<=aTSeq.Length(); i++) { for (i=1; i<=aTSeq.Length(); i++) {
tr=aTSeq(i); tr=aTSeq(i);
for (j=0; j<n; j++) { for (j=0; j<n; j++) {
tr1=t(j); tr1=t(j);
if (fabs (tr1-tr) < myEpsT) { if (fabs (tr1-tr) < myEpsT) {
aTSeq.Remove(i); aTSeq.Remove(i);
aFSeq.Remove(i); aFSeq.Remove(i);
} }
} }
} }
nn=aTSeq.Length(); nn=aTSeq.Length();
@@ -711,7 +744,8 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : DerivativeFunction //function : DerivativeFunction
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real IntTools_EdgeFace::DerivativeFunction(const Standard_Real t2) Standard_Real IntTools_EdgeFace::DerivativeFunction
(const Standard_Real t2)
{ {
Standard_Real t1, t3, aD1, aD2, aD3; Standard_Real t1, t3, aD1, aD2, aD3;
Standard_Real dt=1.e-9; Standard_Real dt=1.e-9;
@@ -728,10 +762,11 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : FindSimpleRoot //function : FindSimpleRoot
//purpose : [private] //purpose : [private]
//======================================================================= //=======================================================================
Standard_Real IntTools_EdgeFace::FindSimpleRoot (const Standard_Integer IP, Standard_Real IntTools_EdgeFace::FindSimpleRoot
const Standard_Real tA, (const Standard_Integer IP,
const Standard_Real tB, const Standard_Real tA,
const Standard_Real fA) const Standard_Real tB,
const Standard_Real fA)
{ {
Standard_Real r, a, b, y, x0, s; Standard_Real r, a, b, y, x0, s;
@@ -766,9 +801,10 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : FindGoldRoot //function : FindGoldRoot
//purpose : [private] //purpose : [private]
//======================================================================= //=======================================================================
Standard_Real IntTools_EdgeFace::FindGoldRoot (const Standard_Real tA, Standard_Real IntTools_EdgeFace::FindGoldRoot
const Standard_Real tB, (const Standard_Real tA,
const Standard_Real coeff) const Standard_Real tB,
const Standard_Real coeff)
{ {
Standard_Real gs=0.61803399; Standard_Real gs=0.61803399;
Standard_Real a, b, xp, xl, yp, yl; Standard_Real a, b, xp, xl, yp, yl;
@@ -808,7 +844,8 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : MakeType //function : MakeType
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer IntTools_EdgeFace::MakeType(IntTools_CommonPrt& aCommonPrt) Standard_Integer IntTools_EdgeFace::MakeType
(IntTools_CommonPrt& aCommonPrt)
{ {
Standard_Real af1, al1; Standard_Real af1, al1;
Standard_Real df1, tm; Standard_Real df1, tm;
@@ -839,65 +876,23 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
} }
else { else {
if(isWholeRange) { if(isWholeRange) {
tm = (af1 + al1) * 0.5; tm = (af1 + al1) * 0.5;
if(aPF.Distance(myC.Value(tm)) > myCriteria * 2.) { if(aPF.Distance(myC.Value(tm)) > myCriteria * 2.) {
aCommonPrt.SetType(TopAbs_EDGE); aCommonPrt.SetType(TopAbs_EDGE);
return 0; return 0;
} }
} }
if(!CheckTouch(aCommonPrt, tm)) { if(!CheckTouch(aCommonPrt, tm)) {
tm = (af1 + al1) * 0.5; tm = (af1 + al1) * 0.5;
} }
aCommonPrt.SetType(TopAbs_VERTEX); aCommonPrt.SetType(TopAbs_VERTEX);
aCommonPrt.SetVertexParameter1(tm); aCommonPrt.SetVertexParameter1(tm);
aCommonPrt.SetRange1 (af1, al1); aCommonPrt.SetRange1 (af1, al1);
} }
return 0;
} }
return 0;
/*
dt=al1-af1;
if (dt<1.e-5) {
gp_Pnt aPF, aPL;
myC.D0(af1, aPF);
myC.D0(al1, aPL);
df1=aPF.Distance(aPL);
if (df1<myCriteria) {
//
tm=.5*(af1+al1);
aCommonPrt.SetType(TopAbs_VERTEX);
aCommonPrt.SetVertexParameter1(tm);
aCommonPrt.SetRange1 (af1, al1);
return 0;
}
}
//
IsIntersection (af1, al1);
//
if (!myParallel) {
aCommonPrt.SetType(TopAbs_VERTEX);
aCommonPrt.SetVertexParameter1(myPar1);
aCommonPrt.SetRange1 (af1, al1);
}
else {
dt=al1-af1;
if (dt<1.e-5) {
df1=DistanceFunction(af1);
df2=DistanceFunction(al1);
tm=(df1 < df2) ? af1 : al1;
aCommonPrt.SetType(TopAbs_VERTEX);
aCommonPrt.SetVertexParameter1(tm);
aCommonPrt.SetRange1 (af1, al1);
}
else {
aCommonPrt.SetType(TopAbs_EDGE);
}
}
return 0;*/
} }
@@ -905,8 +900,8 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : IsIntersection //function : IsIntersection
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::IsIntersection (const Standard_Real ta, void IntTools_EdgeFace::IsIntersection (const Standard_Real ta,
const Standard_Real tb) const Standard_Real tb)
{ {
IntTools_CArray1OfReal anArgs, aFunc; IntTools_CArray1OfReal anArgs, aFunc;
Standard_Integer i, aNb, aCnt=0; Standard_Integer i, aNb, aCnt=0;
@@ -933,10 +928,10 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
// //
if (i) { if (i) {
if (aFunc(i)>aFunc(i-1)) { if (aFunc(i)>aFunc(i-1)) {
aCntIncreasing++; aCntIncreasing++;
} }
if (aFunc(i)<aFunc(i-1)) { if (aFunc(i)<aFunc(i-1)) {
aCntDecreasing++; aCntDecreasing++;
} }
} }
// //
@@ -952,15 +947,15 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
// //
if (myParallel) { if (myParallel) {
if (!(myC.GetType()==GeomAbs_Line if (!(myC.GetType()==GeomAbs_Line
&& &&
myS.GetType()==GeomAbs_Cylinder)) { myS.GetType()==GeomAbs_Cylinder)) {
if (aCntDecreasing==aNb) { if (aCntDecreasing==aNb) {
myPar1=anArgs(aNb-1); myPar1=anArgs(aNb-1);
myParallel=Standard_False; myParallel=Standard_False;
} }
if (aCntIncreasing==aNb) { if (aCntIncreasing==aNb) {
myPar1=anArgs(0); myPar1=anArgs(0);
myParallel=Standard_False; myParallel=Standard_False;
} }
} }
} }
@@ -972,8 +967,9 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : FindDerivativeRoot //function : FindDerivativeRoot
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::FindDerivativeRoot(const IntTools_CArray1OfReal& t, void IntTools_EdgeFace::FindDerivativeRoot
const IntTools_CArray1OfReal& f) (const IntTools_CArray1OfReal& t,
const IntTools_CArray1OfReal& f)
{ {
Standard_Integer i, n, k; Standard_Integer i, n, k;
Standard_Real tr; Standard_Real tr;
@@ -1049,7 +1045,7 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : RemoveIdenticalRoots //function : RemoveIdenticalRoots
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::RemoveIdenticalRoots() void IntTools_EdgeFace::RemoveIdenticalRoots()
{ {
Standard_Integer aNbRoots, j, k; Standard_Integer aNbRoots, j, k;
@@ -1070,8 +1066,8 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
aDistance=aPj.Distance(aPk); aDistance=aPj.Distance(aPk);
if (aDistance < myCriteria) { if (aDistance < myCriteria) {
mySequenceOfRoots.Remove(k); mySequenceOfRoots.Remove(k);
aNbRoots=mySequenceOfRoots.Length(); aNbRoots=mySequenceOfRoots.Length();
} }
} }
} }
@@ -1081,8 +1077,9 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : CheckTouch //function : CheckTouch
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IntTools_EdgeFace::CheckTouch(const IntTools_CommonPrt& aCP, Standard_Boolean IntTools_EdgeFace::CheckTouch
Standard_Real& aTx) (const IntTools_CommonPrt& aCP,
Standard_Real& aTx)
{ {
Standard_Real aTF, aTL, Tol, U1f, U1l, V1f, V1l, af, al,aDist2, aMinDist2; Standard_Real aTF, aTL, Tol, U1f, U1l, V1f, V1l, af, al,aDist2, aMinDist2;
Standard_Boolean theflag=Standard_False; Standard_Boolean theflag=Standard_False;
@@ -1123,42 +1120,42 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
aNbExt=anExtrema.NbExt(); aNbExt=anExtrema.NbExt();
if(aNbExt > 0) { if(aNbExt > 0) {
iLower=1; iLower=1;
for (i=1; i<=aNbExt; i++) { for (i=1; i<=aNbExt; i++) {
aDist2=anExtrema.SquareDistance(i); aDist2=anExtrema.SquareDistance(i);
if (aDist2 < aMinDist2) { if (aDist2 < aMinDist2) {
aMinDist2=aDist2; aMinDist2=aDist2;
iLower=i; iLower=i;
} }
} }
aDist2=anExtrema.SquareDistance(iLower); aDist2=anExtrema.SquareDistance(iLower);
Extrema_POnCurv aPOnC; Extrema_POnCurv aPOnC;
Extrema_POnSurf aPOnS; Extrema_POnSurf aPOnS;
anExtrema.Points(iLower, aPOnC, aPOnS); anExtrema.Points(iLower, aPOnC, aPOnS);
aTx=aPOnC.Parameter(); aTx=aPOnC.Parameter();
} }
else { else {
// modified by NIZHNY-MKK Thu Jul 21 11:35:32 2005.BEGIN // modified by NIZHNY-MKK Thu Jul 21 11:35:32 2005.BEGIN
IntCurveSurface_HInter anExactIntersector; IntCurveSurface_HInter anExactIntersector;
Handle(GeomAdaptor_HCurve) aCurve = new GeomAdaptor_HCurve(TheCurve); Handle(GeomAdaptor_HCurve) aCurve = new GeomAdaptor_HCurve(TheCurve);
Handle(GeomAdaptor_HSurface) aSurface = new GeomAdaptor_HSurface(TheSurface); Handle(GeomAdaptor_HSurface) aSurface = new GeomAdaptor_HSurface(TheSurface);
anExactIntersector.Perform(aCurve, aSurface); anExactIntersector.Perform(aCurve, aSurface);
if(anExactIntersector.IsDone()) { if(anExactIntersector.IsDone()) {
Standard_Integer i = 0; Standard_Integer i = 0;
for(i = 1; i <= anExactIntersector.NbPoints(); i++) { for(i = 1; i <= anExactIntersector.NbPoints(); i++) {
const IntCurveSurface_IntersectionPoint& aPoint = anExactIntersector.Point(i); const IntCurveSurface_IntersectionPoint& aPoint = anExactIntersector.Point(i);
if((aPoint.W() >= aTF) && (aPoint.W() <= aTL)) { if((aPoint.W() >= aTF) && (aPoint.W() <= aTL)) {
aDist2=0.; aDist2=0.;
aTx = aPoint.W(); aTx = aPoint.W();
} }
} }
} }
// modified by NIZHNY-MKK Thu Jul 21 11:35:40 2005.END // modified by NIZHNY-MKK Thu Jul 21 11:35:40 2005.END
} }
} }
else { else {
@@ -1205,13 +1202,11 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
return theflag; return theflag;
} }
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::Perform() void IntTools_EdgeFace::Perform()
{ {
Standard_Integer i, aNb; Standard_Integer i, aNb;
IntTools_CommonPrt aCommonPrt; IntTools_CommonPrt aCommonPrt;
@@ -1235,7 +1230,7 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
// //
// Prepare myCriteria // Prepare myCriteria
if (aCurveType==GeomAbs_BSplineCurve|| if (aCurveType==GeomAbs_BSplineCurve||
aCurveType==GeomAbs_BezierCurve) { aCurveType==GeomAbs_BezierCurve) {
//--- 5112 //--- 5112
Standard_Real diff1 = (myTolE/myTolF); Standard_Real diff1 = (myTolE/myTolF);
Standard_Real diff2 = (myTolF/myTolE); Standard_Real diff2 = (myTolF/myTolE);
@@ -1306,23 +1301,23 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
if (aCType==GeomAbs_Line && aSType==GeomAbs_Cylinder) { if (aCType==GeomAbs_Line && aSType==GeomAbs_Cylinder) {
for (i=1; i<=aNb; i++) { for (i=1; i<=aNb; i++) {
IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i); IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
aType=aCP.Type(); aType=aCP.Type();
if (aType==TopAbs_EDGE) { if (aType==TopAbs_EDGE) {
bIsTouch=CheckTouch (aCP, aTx); bIsTouch=CheckTouch (aCP, aTx);
if (bIsTouch) { if (bIsTouch) {
aCP.SetType(TopAbs_VERTEX); aCP.SetType(TopAbs_VERTEX);
aCP.SetVertexParameter1(aTx); aCP.SetVertexParameter1(aTx);
aCP.SetRange1 (aTx, aTx); aCP.SetRange1 (aTx, aTx);
} }
} }
if (aType==TopAbs_VERTEX) { if (aType==TopAbs_VERTEX) {
bIsTouch=CheckTouchVertex (aCP, aTx); bIsTouch=CheckTouchVertex (aCP, aTx);
if (bIsTouch) { if (bIsTouch) {
aCP.SetVertexParameter1(aTx); aCP.SetVertexParameter1(aTx);
aCP.SetRange1 (aTx, aTx); aCP.SetRange1 (aTx, aTx);
} }
} }
} }
} }
@@ -1333,18 +1328,18 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
bIsCoplanar=IsCoplanar(myC, myS); bIsCoplanar=IsCoplanar(myC, myS);
bIsRadius=IsRadius(myC, myS); bIsRadius=IsRadius(myC, myS);
if (!bIsCoplanar && !bIsRadius) { if (!bIsCoplanar && !bIsRadius) {
for (i=1; i<=aNb; i++) { for (i=1; i<=aNb; i++) {
IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i); IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
aType=aCP.Type(); aType=aCP.Type();
if (aType==TopAbs_EDGE) { if (aType==TopAbs_EDGE) {
bIsTouch=CheckTouch (aCP, aTx); bIsTouch=CheckTouch (aCP, aTx);
if (bIsTouch) { if (bIsTouch) {
aCP.SetType(TopAbs_VERTEX); aCP.SetType(TopAbs_VERTEX);
aCP.SetVertexParameter1(aTx); aCP.SetVertexParameter1(aTx);
aCP.SetRange1 (aTx, aTx); aCP.SetRange1 (aTx, aTx);
} }
} }
} }
} }
} }
} }
@@ -1365,8 +1360,9 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//function : CheckTouch //function : CheckTouch
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IntTools_EdgeFace::CheckTouchVertex (const IntTools_CommonPrt& aCP, Standard_Boolean IntTools_EdgeFace::CheckTouchVertex
Standard_Real& aTx) (const IntTools_CommonPrt& aCP,
Standard_Real& aTx)
{ {
Standard_Real aTF, aTL, Tol, U1f,U1l,V1f,V1l, af, al,aDist2, aMinDist2, aTm, aDist2New; Standard_Real aTF, aTL, Tol, U1f,U1l,V1f,V1l, af, al,aDist2, aMinDist2, aTm, aDist2New;
Standard_Real aEpsT; Standard_Real aEpsT;
@@ -1452,7 +1448,7 @@ Standard_Real IntTools_EdgeFace::DistanceFunction(const Standard_Real t)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& aCurve , Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& aCurve ,
const BRepAdaptor_Surface& aSurface) const BRepAdaptor_Surface& aSurface)
{ {
Standard_Boolean bFlag=Standard_False; Standard_Boolean bFlag=Standard_False;
@@ -1480,7 +1476,7 @@ Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& aCurve ,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve , Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve ,
const BRepAdaptor_Surface& aSurface) const BRepAdaptor_Surface& aSurface)
{ {
Standard_Boolean bFlag=Standard_False; Standard_Boolean bFlag=Standard_False;
@@ -1508,8 +1504,8 @@ Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve ,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret, Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret,
const BRepAdaptor_Curve& aCurve , const BRepAdaptor_Curve& aCurve ,
const BRepAdaptor_Surface& aSurface) const BRepAdaptor_Surface& aSurface)
{ {
Standard_Integer iDiscretNew; Standard_Integer iDiscretNew;