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

0028591: BOP Cut creates wrong result

The Face/Face intersection procedure has been changed in Boolean Operations algorithm.
Previously, the intersection tolerance for all section curves between pair of faces has been calculated
as the maximal tolerance among all curves. Now, each curve has its own valid tolerance calculated
as the maximal deviation of the 3D curve from its 2D curves on faces or surfaces in case there are no 2D curves.

Thus, such methods of IntTools_FaceFace algorithm as TolReached3d(), TolReal() and TolReached2d() have been removed.
Now the tolerances of the curve can be obtained from the curve itself (IntTools_Curve - result of intersection):
- IntTools_Curve::Tolerance() - returns the valid tolerance for the curve;
- IntTools_Curve::TangentialTolerance() - returns the tangential tolerance, which depends on the size of the common
  between faces. Currently, this tolerance is computed for Plane/Plane cases only. For other case, the value
  of the tangential tolerance is the maximal tolerance of faces.

2D intersection tolerance (IntTools_FaceFace::TolReached2d()) has been completely removed from the algorithm as unused.
This commit is contained in:
emv 2017-03-29 08:46:31 +03:00 committed by bugmaster
parent 769a2e88e0
commit 5652dc6272
16 changed files with 512 additions and 861 deletions

View File

@ -1237,4 +1237,14 @@ The following Grid management methods within class V3d_Viewer do not implicitly
@subsection upgrade_720_Removal_Of_Old_Boolean_Operations_Draw Removal of the Draw commands based on old Boolean operations
* The commands *fubl* and *cubl* have been removed. The alternative for these commands are the commands *bfuseblend* and *bcutblend* respectively.
* The command *ksection* has been removed. The alternative for this command is the command *bsection*.
* The command *ksection* has been removed. The alternative for this command is the command *bsection*.
@subsection upgrade_720_Change_Of_FaceFace_Intersection Change of Face/Face intersection in Boolean operations
* Previously, the intersection tolerance for all section curves between pair of faces has been calculated as the maximal tolerance among all curves.
Now, each curve has its own valid tolerance calculated as the maximal deviation of the 3D curve from its 2D curves or surfaces in case there are no 2D curves.
* The methods *IntTools_FaceFace::TolReached3d()*, *IntTools_FaceFace::TolReal()* and *IntTools_FaceFace::TolReached2d()* have been removed.
* Intersection tolerances of the curve can be obtained from the curve itself:
- *IntTools_Curve::Tolerance()* - returns the valid tolerance for the curve;
- *IntTools_Curve::TangentialTolerance()* - returns the tangential tolerance, which reflects the size of the common between faces.
* 2d tolerance (*IntTools_FaceFace::TolReached2d()*) has been completely removed from the algorithm as unused.

View File

@ -189,7 +189,6 @@ protected:
//! Checks and puts paves from <theMVOn> on the curve <theNC>.
Standard_EXPORT void PutPavesOnCurve (const BOPCol_MapOfInteger& theMVOn,
const Standard_Real theTolR3D,
BOPDS_Curve& theNC,
const Standard_Integer nF1,
const Standard_Integer nF2,
@ -198,8 +197,7 @@ protected:
BOPCol_DataMapOfIntegerReal& theMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV);
Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
const Standard_Real theTolR3D);
Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC);
//! Depending on the parameter aType it checks whether
//! the vertex nV was created in EE or EF intersections.
@ -211,7 +209,10 @@ protected:
//! other - checks both types of intersections.
Standard_EXPORT Standard_Boolean ExtendedTolerance (const Standard_Integer nV, const BOPCol_MapOfInteger& aMI, Standard_Real& aTolVExt, const Standard_Integer aType = 0);
Standard_EXPORT void PutBoundPaveOnCurve (const TopoDS_Face& theF1, const TopoDS_Face& theF2, const Standard_Real theTolR3D, BOPDS_Curve& theNC, BOPCol_ListOfInteger& theLBV);
Standard_EXPORT void PutBoundPaveOnCurve(const TopoDS_Face& theF1,
const TopoDS_Face& theF2,
BOPDS_Curve& theNC,
BOPCol_ListOfInteger& theLBV);
Standard_EXPORT Standard_Boolean IsExistingPaveBlock
(const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC,

View File

@ -79,9 +79,8 @@
#include <TopoDS_Vertex.hxx>
//
static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2,
Standard_Real& aTolFF);
static Standard_Real ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2);
/////////////////////////////////////////////////////////////////////////
//=======================================================================
@ -173,33 +172,30 @@ typedef BOPCol_Cnt
//=======================================================================
void BOPAlgo_PaveFiller::PerformFF()
{
Standard_Integer iSize;
Standard_Boolean bValid;
//
myErrorStatus=0;
myErrorStatus = 0;
//
myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
iSize=myIterator->ExpectedLength();
Standard_Integer iSize = myIterator->ExpectedLength();
if (!iSize) {
return;
}
//
Standard_Boolean bApp, bCompC2D1, bCompC2D2, bIsDone;
Standard_Boolean bToSplit, bTangentFaces;
Standard_Integer nF1, nF2, aNbCurves, aNbPoints, i, aNbLP;
Standard_Integer aNbFaceFace, k;
Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF, aTolReal;
BOPCol_MapOfInteger aMI;
BOPAlgo_VectorOfFaceFace aVFaceFace;
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
aFFs.SetIncrement(iSize);
//
bApp=mySectionAttribute.Approximation();
bCompC2D1=mySectionAttribute.PCurveOnS1();
bCompC2D2=mySectionAttribute.PCurveOnS2();
aApproxTol=1.e-7;
bToSplit = Standard_False;
// Options for the intersection algorithm
Standard_Boolean bApprox = mySectionAttribute.Approximation(),
bCompC2D1 = mySectionAttribute.PCurveOnS1(),
bCompC2D2 = mySectionAttribute.PCurveOnS2();
Standard_Real anApproxTol = 1.e-7;
// Post-processing options
Standard_Boolean bSplitCurve = Standard_False;
//
// Fence map to store faces with updated FaceInfo structure
BOPCol_MapOfInteger aMIFence;
// Prepare the pairs of faces for intersection
BOPAlgo_VectorOfFaceFace aVFaceFace;
Standard_Integer nF1, nF2;
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nF1, nF2);
@ -207,11 +203,11 @@ void BOPAlgo_PaveFiller::PerformFF()
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
if (aMI.Add(nF1)) {
if (aMIFence.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
if (aMI.Add(nF2)) {
if (aMIFence.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
@ -220,9 +216,8 @@ void BOPAlgo_PaveFiller::PerformFF()
const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(aF2);
if (aBAS1.GetType() == GeomAbs_Plane &&
aBAS2.GetType() == GeomAbs_Plane) {
Standard_Boolean bToIntersect;
//
bToIntersect = CheckPlanes(nF1, nF2);
// Check if the planes are really interfering
Standard_Boolean bToIntersect = CheckPlanes(nF1, nF2);
if (!bToIntersect) {
BOPDS_InterfFF& aFF=aFFs.Append1();
aFF.SetIndices(nF1, nF2);
@ -231,23 +226,23 @@ void BOPAlgo_PaveFiller::PerformFF()
}
}
//
ToleranceFF(aBAS1, aBAS2, aTolFF);
//
if (myGlue == BOPAlgo_GlueOff) {
BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1();
//
aFaceFace.SetIndices(nF1, nF2);
aFaceFace.SetFaces(aF1, aF2);
// compute minimal tolerance for the curves
Standard_Real aTolFF = ToleranceFF(aBAS1, aBAS2);
aFaceFace.SetTolFF(aTolFF);
//
IntSurf_ListOfPntOn2S aListOfPnts;
GetEFPnts(nF1, nF2, aListOfPnts);
aNbLP = aListOfPnts.Extent();
Standard_Integer aNbLP = aListOfPnts.Extent();
if (aNbLP) {
aFaceFace.SetList(aListOfPnts);
}
//
aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol);
aFaceFace.SetParameters(bApprox, bCompC2D1, bCompC2D2, anApproxTol);
aFaceFace.SetFuzzyValue(myFuzzyValue);
aFaceFace.SetProgressIndicator(myProgressIndicator);
}
@ -255,111 +250,84 @@ void BOPAlgo_PaveFiller::PerformFF()
// for the Glue mode just add all interferences of that type
BOPDS_InterfFF& aFF = aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aFF.SetTolR3D(Precision::Confusion());
aFF.SetTolR2D(Precision::PConfusion());
aFF.SetTolReal(Precision::Confusion());
aFF.SetTangentFaces(Standard_False);
aFF.Init(0, 0);
}
}//for (; myIterator->More(); myIterator->Next()) {
//
aNbFaceFace=aVFaceFace.Extent();
//======================================================
// Perform intersection
BOPAlgo_FaceFaceCnt::Perform(myRunParallel, aVFaceFace);
//======================================================
//
for (k=0; k < aNbFaceFace; ++k) {
BOPAlgo_FaceFace& aFaceFace=aVFaceFace(k);
//
// Treatment of the results
Standard_Integer k, aNbFaceFace = aVFaceFace.Extent();
for (k = 0; k < aNbFaceFace; ++k) {
BOPAlgo_FaceFace& aFaceFace = aVFaceFace(k);
aFaceFace.Indices(nF1, nF2);
aTolFF=aFaceFace.TolFF();
//
bIsDone=aFaceFace.IsDone();
if (bIsDone) {
aTolR3D=aFaceFace.TolReached3d();
aTolR2D=aFaceFace.TolReached2d();
aTolReal = aFaceFace.TolReal();
bTangentFaces=aFaceFace.TangentFaces();
//
if (aTolR3D < aTolFF){
aTolR3D=aTolFF;
}
if (aTolReal < aTolFF) {
aTolReal = aTolFF;
}
if (aTolR2D < 1.e-7){
aTolR2D=1.e-7;
}
//
aFaceFace.PrepareLines3D(bToSplit);
//
const IntTools_SequenceOfCurves& aCvsX=aFaceFace.Lines();
const IntTools_SequenceOfPntOn2Faces& aPntsX=aFaceFace.Points();
//
aNbCurves=aCvsX.Length();
aNbPoints=aPntsX.Length();
//
if (aNbCurves || aNbPoints) {
myDS->AddInterf(nF1, nF2);
}
//
BOPDS_InterfFF& aFF=aFFs.Append1();
if (!aFaceFace.IsDone()) {
BOPDS_InterfFF& aFF = aFFs.Append1();
aFF.SetIndices(nF1, nF2);
//
aFF.SetTolR3D(aTolR3D);
aFF.SetTolR2D(aTolR2D);
aFF.SetTolReal(aTolReal);
aFF.SetTangentFaces(bTangentFaces);
//
// Curves, Points
aFF.Init(aNbCurves, aNbPoints);
//
// Curves
// Fix bounding box expanding coefficient.
Standard_Real aBoxExpandValue = aTolR3D;
if (aNbCurves > 0)
{
// Modify geometric expanding coefficient by topology value,
// since this bounging box used in sharing (vertex or edge).
Standard_Real aMaxVertexTol = Max (BRep_Tool::MaxTolerance(aFaceFace.Face1(), TopAbs_VERTEX),
BRep_Tool::MaxTolerance(aFaceFace.Face2(), TopAbs_VERTEX));
aBoxExpandValue += aMaxVertexTol;
}
BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
for (i=1; i<=aNbCurves; ++i) {
Bnd_Box aBox;
//
const IntTools_Curve& aIC=aCvsX(i);
const Handle(Geom_Curve)& aC3D= aIC.Curve();
bValid=IntTools_Tools::CheckCurve(aC3D, aBoxExpandValue, aBox);
if (bValid) {
BOPDS_Curve& aNC=aVNC.Append1();
aNC.SetCurve(aIC);
aNC.SetBox(aBox);
}
}
//
// Points
BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
for (i=1; i<=aNbPoints; ++i) {
const IntTools_PntOn2Faces& aPi=aPntsX(i);
const gp_Pnt& aP=aPi.P1().Pnt();
//
BOPDS_Point& aNP=aVNP.Append1();
aNP.SetPnt(aP);
}
//}// if (aNbCs || aNbPs)
}// if (bIsDone) {
else {// 904/L1
BOPDS_InterfFF& aFF=aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aNbCurves=0;
aNbPoints=0;
aFF.Init(aNbCurves, aNbPoints);
aFF.Init(0, 0);
continue;
}
}// for (k=0; k < aNbFaceFace; ++k) {
//
Standard_Boolean bTangentFaces = aFaceFace.TangentFaces();
Standard_Real aTolFF = aFaceFace.TolFF();
//
aFaceFace.PrepareLines3D(bSplitCurve);
//
const IntTools_SequenceOfCurves& aCvsX = aFaceFace.Lines();
const IntTools_SequenceOfPntOn2Faces& aPntsX = aFaceFace.Points();
//
Standard_Integer aNbCurves = aCvsX.Length();
Standard_Integer aNbPoints = aPntsX.Length();
//
if (aNbCurves || aNbPoints) {
myDS->AddInterf(nF1, nF2);
}
//
BOPDS_InterfFF& aFF = aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aFF.SetTangentFaces(bTangentFaces);
aFF.Init(aNbCurves, aNbPoints);
//
// Curves
// Fix bounding box expanding coefficient.
Standard_Real aBoxExpandValue = aTolFF;
if (aNbCurves > 0)
{
// Modify geometric expanding coefficient by topology value,
// since this bounding box used in sharing (vertex or edge).
Standard_Real aMaxVertexTol = Max(BRep_Tool::MaxTolerance(aFaceFace.Face1(), TopAbs_VERTEX),
BRep_Tool::MaxTolerance(aFaceFace.Face2(), TopAbs_VERTEX));
aBoxExpandValue += aMaxVertexTol;
}
//
BOPDS_VectorOfCurve& aVNC = aFF.ChangeCurves();
for (Standard_Integer i = 1; i <= aNbCurves; ++i) {
Bnd_Box aBox;
const IntTools_Curve& aIC = aCvsX(i);
Standard_Boolean bIsValid = IntTools_Tools::CheckCurve(aIC, aBox);
if (bIsValid) {
BOPDS_Curve& aNC = aVNC.Append1();
aNC.SetCurve(aIC);
// make sure that the bounding box has the maximal gap
aBox.Enlarge(aBoxExpandValue);
aNC.SetBox(aBox);
aNC.SetTolerance(Max(aIC.Tolerance(), aTolFF));
}
}
//
// Points
BOPDS_VectorOfPoint& aVNP = aFF.ChangePoints();
for (Standard_Integer i = 1; i <= aNbPoints; ++i) {
const IntTools_PntOn2Faces& aPi = aPntsX(i);
const gp_Pnt& aP = aPi.P1().Pnt();
//
BOPDS_Point& aNP = aVNP.Append1();
aNP.SetPnt(aP);
}
}
}
//=======================================================================
//function : MakeBlocks
@ -384,7 +352,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
Standard_Boolean bExist, bValid2D;
Standard_Integer i, nF1, nF2, aNbC, aNbP, j;
Standard_Integer nV1, nV2;
Standard_Real aTolR3D, aT1, aT2;
Standard_Real aT1, aT2;
Handle(NCollection_BaseAllocator) aAllocator;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
TopoDS_Edge aES;
@ -395,7 +363,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
NCollection_BaseAllocator::CommonBaseAllocator();
//
BOPCol_ListOfInteger aLSE(aAllocator), aLBV(aAllocator);
BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator),
BOPCol_MapOfInteger aMVOnIn(100, aAllocator),
aMVStick(100,aAllocator), aMVEF(100, aAllocator),
aMI(100, aAllocator), aMVBounds(100, aAllocator);
BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
@ -429,20 +397,10 @@ void BOPAlgo_PaveFiller::MakeBlocks()
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
aTolR3D=aFF.TolR3D();
Standard_Real aTolFF = Max(BRep_Tool::Tolerance(aF1), BRep_Tool::Tolerance(aF2));
//
// Update face info
if (aMF.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
if (aMF.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
//
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
//
aMVOnIn.Clear();
aMPBOnIn.Clear();
@ -463,9 +421,9 @@ void BOPAlgo_PaveFiller::MakeBlocks()
BOPDS_Point& aNP=aVP.ChangeValue(j);
const gp_Pnt& aP=aNP.Pnt();
//
bExist=IsExistingVertex(aP, aTolR3D, aMVOnIn);
bExist=IsExistingVertex(aP, aTolFF, aMVOnIn);
if (!bExist) {
BOPTools_AlgoTools::MakeNewVertex(aP, aTolR3D, aV);
BOPTools_AlgoTools::MakeNewVertex(aP, aTolFF, aV);
//
aCPB.SetIndexInterf(i);
aCPB.SetIndex(j);
@ -483,13 +441,13 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// DEBt
aNC.InitPaveBlock1();
//
PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol, aDMVLV);
PutPavesOnCurve(aMVOnIn, aNC, nF1, nF2, aMI, aMVEF, aMVTol, aDMVLV);
}
// if some E-F vertex was put on a curve due to large E-F intersection range,
// and it also was put on another curve correctly then remove this vertex from
// the first curve. Detect such case if the distance to curve exceeds aTolR3D.
FilterPavesOnCurves(aVC, aTolR3D);
FilterPavesOnCurves(aVC);
for (j = 0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC.ChangeValue(j);
@ -504,7 +462,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
if (aIC.HasBounds()) {
aLBV.Clear();
//
PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aLBV);
PutBoundPaveOnCurve(aF1, aF2, aNC, aLBV);
//
if (!aLBV.IsEmpty()) {
aDMBV.Bind(j, aLBV);
@ -526,6 +484,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
for (j=0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC.ChangeValue(j);
const IntTools_Curve& aIC=aNC.Curve();
Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
//
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
Handle(BOPDS_PaveBlock)& aPB1=aNC.ChangePaveBlock1();
@ -587,8 +546,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
nE = aPBOut->Edge();
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aTolE = BRep_Tool::Tolerance(aE);
if (aTolNew < aFF.TolReal())
aTolNew = aFF.TolReal(); // use real tolerance of intersection
if (aTolNew < aNC.Tolerance())
aTolNew = aNC.Tolerance(); // use real tolerance of intersection
if (aTolNew > aTolE) {
UpdateEdgeTolerance(nE, aTolNew);
}
@ -702,7 +661,6 @@ void BOPAlgo_PaveFiller::MakeBlocks()
PutSEInOtherFaces();
//
//-----------------------------------------------------scope t
aMF.Clear();
aMVStick.Clear();
aMPBOnIn.Clear();
aMVOnIn.Clear();
@ -1035,8 +993,8 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
if (aPDS->IsCommonBlock(aPBRx)) {
const Handle(BOPDS_CommonBlock)& aCB = aPDS->CommonBlock(aPBRx);
Standard_Real aTol = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, aPDS, aPF.Context());
if (aFF.TolReal() < aTol) {
aFF.SetTolReal(aTol);
if (aNC.Tolerance() < aTol) {
aNC.SetTolerance(aTol);
}
}
}
@ -1425,7 +1383,6 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
//=======================================================================
void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
BOPCol_ListOfInteger& aLVB)
{
@ -1441,6 +1398,7 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
//
const IntTools_Curve& aIC=aNC.Curve();
aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
//
Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
const BOPDS_ListOfPave& aLP=aPB->ExtPaves();
@ -1528,7 +1486,6 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
//=======================================================================
void BOPAlgo_PaveFiller::PutPavesOnCurve
(const BOPCol_MapOfInteger& aMVOnIn,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
const Standard_Integer nF1,
const Standard_Integer nF2,
@ -1542,6 +1499,7 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
BOPCol_MapIteratorOfMapOfInteger aIt;
//
const Bnd_Box& aBoxC=aNC.Box();
Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
//
//Put EF vertices first
aIt.Initialize(aMVEF);
@ -1590,13 +1548,11 @@ namespace {
Standard_Real Dist; // square distance from vertex to the paveblock
Standard_Real SinAngle; // sinus of angle between projection vector
// and tangent at projection point
Standard_Real Tolerance; // tolerance of the section curve
};
}
void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
const Standard_Real theTolR3D)
void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
{
Standard_Real aSqTol = theTolR3D * theTolR3D;
// For each vertex found in ExtPaves of pave blocks of section curves
// collect list of pave blocks with distance to the curve
NCollection_IndexedDataMap<Standard_Integer,NCollection_List<PaveBlockDist> > aIDMVertPBs;
@ -1606,6 +1562,7 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
{
const BOPDS_Curve& aNC = theVNC(i);
const IntTools_Curve& aIC = aNC.Curve();
const Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
GeomAdaptor_Curve aGAC(aIC.Curve());
const Handle(BOPDS_PaveBlock)& aPB = aNC.PaveBlocks().First();
const BOPDS_ListOfPave& aPaves = aPB->ExtPaves();
@ -1630,7 +1587,7 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
NCollection_List<PaveBlockDist>* pList = aIDMVertPBs.ChangeSeek(nV);
if (!pList)
pList = &aIDMVertPBs.ChangeFromIndex(aIDMVertPBs.Add(nV, NCollection_List<PaveBlockDist>()));
PaveBlockDist aPBD = { aPB, aSqDist, aSin };
PaveBlockDist aPBD = { aPB, aSqDist, aSin, aTolR3D };
pList->Append(aPBD);
}
}
@ -1658,10 +1615,10 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
// and there are other pave blocks for which the distance is less than the current.
// Do not remove a vertex if it is projected on the curve with quite large angle
// (see test bugs modalg_6 bug27761).
Standard_Real aCheckDist = 100. * Max(aSqTol, aMinDist);
for (itL.Init(aList); itL.More(); itL.Next())
{
const PaveBlockDist& aPBD = itL.Value();
Standard_Real aCheckDist = 100. * Max(aPBD.Tolerance*aPBD.Tolerance, aMinDist);
if (aPBD.Dist > aCheckDist && aPBD.SinAngle < aSinAngleMin)
{
aPBD.PB->RemoveExtPave(nV);
@ -2667,23 +2624,19 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const BOPCol_MapOfInteger theEdges)
}
}
}
//=======================================================================
//function : ToleranceFF
//purpose : Computes the TolFF according to the tolerance value and
// types of the faces.
//=======================================================================
void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2,
Standard_Real& aTolFF)
Standard_Real ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2)
{
Standard_Real aTol1, aTol2;
Standard_Real aTol1 = aBAS1.Tolerance();
Standard_Real aTol2 = aBAS2.Tolerance();
Standard_Real aTolFF = Max(aTol1, aTol2);
//
Standard_Boolean isAna1, isAna2;
//
aTol1 = aBAS1.Tolerance();
aTol2 = aBAS2.Tolerance();
aTolFF = Max(aTol1, aTol2);
//
isAna1 = (aBAS1.GetType() == GeomAbs_Plane ||
aBAS1.GetType() == GeomAbs_Cylinder ||
aBAS1.GetType() == GeomAbs_Cone ||
@ -2699,6 +2652,7 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const BOPCol_MapOfInteger theEdges)
if (!isAna1 || !isAna2) {
aTolFF = Max(aTolFF, 5.e-6);
}
return aTolFF;
}
//=======================================================================
//function : UpdateBlocksWithSharedVertices
@ -2722,7 +2676,7 @@ void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
//
Standard_Boolean bOnCurve, bHasShapeSD;
Standard_Integer i, nF1, nF2, aNbC, j, nV, nVSD;
Standard_Real aTolR3D, aTolV;
Standard_Real aTolV;
BOPCol_MapOfInteger aMF;
//
for (i=0; i<aNbFF; ++i) {
@ -2735,7 +2689,6 @@ void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
}
//
aFF.Indices(nF1, nF2);
aTolR3D=aFF.TolR3D();
//
if (aMF.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
@ -2773,7 +2726,7 @@ void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
// Try to put vertices aMI on curves
for (j=0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC.ChangeValue(j);
//const IntTools_Curve& aIC=aNC.Curve();
Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
//
aItMI.Initialize(aMI);
for (; aItMI.More(); aItMI.Next()) {
@ -2832,10 +2785,7 @@ void BOPAlgo_PaveFiller::CorrectToleranceOfSE()
Standard_Integer aNb = aFFs.Extent(), i;
for (i = 0; i < aNb; ++i) {
BOPDS_InterfFF& aFF = aFFs(i);
Standard_Real aTolR3D = aFF.TolR3D();
Standard_Real aTolReal = aFF.TolReal();
Standard_Boolean bToReduce = aTolReal < aTolR3D;
// tolerance of intersection has been increased, so process this intersection
//
BOPDS_VectorOfCurve& aVNC = aFF.ChangeCurves();
Standard_Integer aNbC = aVNC.Extent(), k;
for (k = 0; k < aNbC; ++k) {
@ -2851,13 +2801,25 @@ void BOPAlgo_PaveFiller::CorrectToleranceOfSE()
}
//
Standard_Boolean bIsReduced = Standard_False;
if (bToReduce && (aPB->OriginalEdge() < 0)) {
const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
Standard_Real aTolE = BRep_Tool::Tolerance(aE);
if (aTolReal < aTolE) {
// reduce edge tolerance
reinterpret_cast<BRep_TEdge*>(aE.TShape().operator->())->Tolerance(aTolReal);
bIsReduced = Standard_True;
if (aPB->OriginalEdge() < 0) {
// It is possible that due to small angle between faces the
// common zone between faces can be large and the tangential
// tolerance of the curve will be large as well.
// Here we're trying to reduce the tolerance of the section
// edge using the valid tolerance of the edge.
// Note, that if the pave block has created common block with
// other edges its valid tolerance could have been changed to
// cover all edges in common block (see PostTreatFF() method).
Standard_Real aTolC = aNC.Tolerance();
Standard_Real aTolTang = aNC.TangentialTolerance();
if (aTolC < aTolTang) {
const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
Standard_Real aTolE = BRep_Tool::Tolerance(aE);
if (aTolC < aTolE) {
// reduce edge tolerance
reinterpret_cast<BRep_TEdge*>(aE.TShape().operator->())->Tolerance(aTolC);
bIsReduced = Standard_True;
}
}
}
//

View File

@ -118,33 +118,37 @@ virtual ~BOPDS_Curve();
//! has edge
Standard_Boolean HasEdge() const;
//! Sets the tolerance for the curve.
void SetTolerance(const Standard_Real theTol)
{
myTolerance = theTol;
}
//! Returns the tolerance of the curve
Standard_Real Tolerance() const
{
return myTolerance;
}
//! Returns the tangential tolerance of the curve
Standard_Real TangentialTolerance() const
{
return myCurve.TangentialTolerance();
}
protected:
BOPCol_BaseAllocator myAllocator;
IntTools_Curve myCurve;
BOPDS_ListOfPaveBlock myPaveBlocks;
BOPCol_ListOfInteger myTechnoVertices;
Bnd_Box myBox;
Standard_Real myTolerance;
private:
};
#include <BOPDS_Curve.lxx>
#endif // _BOPDS_Curve_HeaderFile

View File

@ -22,7 +22,8 @@
:
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
myPaveBlocks(myAllocator),
myTechnoVertices(myAllocator)
myTechnoVertices(myAllocator),
myTolerance(0.)
{
}
//=======================================================================
@ -33,7 +34,8 @@
:
myAllocator(theAllocator),
myPaveBlocks(myAllocator),
myTechnoVertices(myAllocator)
myTechnoVertices(myAllocator),
myTolerance(0.)
{
}
//=======================================================================

View File

@ -494,9 +494,6 @@ class BOPDS_InterfFF : public BOPDS_Interf {
:
BOPDS_Interf(),
myTangentFaces(Standard_False),
myTolR3D(1.e-7),
myTolR2D(1.e-7),
myTolReal(1.e-7),
myCurves(0, myAllocator),
myPoints(0, myAllocator)
{
@ -518,26 +515,12 @@ class BOPDS_InterfFF : public BOPDS_Interf {
void Init(const Standard_Integer theNbCurves,
const Standard_Integer theNbPoints) {
//modified by NIZNHY-PKV Mon Jan 26 09:01:06 2015f
if (theNbCurves>0) {
myCurves.SetIncrement(theNbCurves);
}
if (theNbPoints>0) {
myPoints.SetIncrement(theNbPoints);
}
/*
if (theNbCurves>0) {
myCurves.SetStartSize(theNbCurves);
myCurves.SetIncrement(theNbCurves);
myCurves.Init();
}
if (theNbPoints>0) {
myPoints.SetStartSize(theNbPoints);
myPoints.SetIncrement(theNbPoints);
myPoints.Init();
}
*/
//modified by NIZNHY-PKV Mon Jan 26 09:01:12 2015t
}
/**
* Modifier
@ -557,64 +540,6 @@ class BOPDS_InterfFF : public BOPDS_Interf {
Standard_Boolean TangentFaces()const {
return myTangentFaces;
}
/**
* Modifier
* Sets the value of 3D tolerance
* @param theTol
* 3D tolerance
*/
void SetTolR3D(const Standard_Real theTol) {
myTolR3D=theTol;
}
//
/**
* Selector
* Returns the value of 3D tolerance
* @return
* 3D tolerance
*/
Standard_Real TolR3D()const {
return myTolR3D;
}
//
/**
* Modifier
* Sets the value of 2D tolerance
* @param theTol
* 2D tolerance
*/
void SetTolR2D(const Standard_Real theTol) {
myTolR2D=theTol;;
}
//
/**
* Selector
* Returns the value of 2D tolerance
* @return
* 2D tolerance
*/
Standard_Real TolR2D()const {
return myTolR2D;
}
/**
* Modifier
* Sets the value of real not increased 3D tolerance
* @param theTol
* 3D tolerance
*/
void SetTolReal(const Standard_Real theTol) {
myTolReal = theTol;
}
//
/**
* Selector
* Returns the value of real not increased 3D tolerance
* @return
* 3D tolerance
*/
Standard_Real TolReal()const {
return myTolReal;
}
//
/**
* Selector
@ -658,9 +583,6 @@ class BOPDS_InterfFF : public BOPDS_Interf {
//
protected:
Standard_Boolean myTangentFaces;
Standard_Real myTolR3D;
Standard_Real myTolR2D;
Standard_Real myTolReal;
BOPDS_VectorOfCurve myCurves;
BOPDS_VectorOfPoint myPoints;
};

View File

@ -104,7 +104,8 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
theCommands.Add("bsection", "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] [-p u1 v1 u2 v2]",
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]",
__FILE__, bopcurves, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-ai]",
__FILE__, mkvolume , g);
@ -544,7 +545,8 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const char** a)
{
if (n<3) {
di << " use bopcurves F1 F2 [-2d/-2d1/-2d2]\n";
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]\n";
return 1;
}
//
@ -553,7 +555,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
TopAbs_ShapeEnum aType;
//
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
di << " Null shapes are not allowed \n";
return 1;
}
//
@ -573,7 +575,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
//
Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
Standard_Integer aNbCurves, aNbPoints;
Standard_Real anAppTol, aTolR;
Standard_Real anAppTol;
IntSurf_ListOfPntOn2S aListOfPnts;
TCollection_AsciiString aNm("c_"), aNp("p_");
//
@ -583,6 +585,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
aToApproxC2dOnS2 = Standard_False;
//
Standard_Boolean bExtOut = Standard_False;
for(Standard_Integer i = 3; i < n; i++)
{
if (!strcasecmp(a[i],"-2d")) {
@ -605,13 +608,17 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
aPt.SetValue(aU1, aV1, aU2, aV2);
aListOfPnts.Append(aPt);
}
else if (!strcasecmp(a[i],"-v")) {
bExtOut = Standard_True;
}
else {
di << "Wrong key. To build 2d curves use: bopcurves F1 F2 [-2d/-2d1/-2d2] [-p u1 v1 u2 v2]\n";
di << "Wrong key.\n";
di << "To build 2d curves use one of the following keys: -2d/-2d1/-2d2\n";
di << "To add start points use the following key: -p u1 v1 u2 v2\n";
di << "For extended output use the following key: -v\n";
return 1;
}
}
//
IntTools_FaceFace aFF;
//
@ -625,7 +632,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
//
anIsDone=aFF.IsDone();
if (!anIsDone) {
di << "Error: anIsDone=" << (Standard_Integer) anIsDone << "\n";
di << "Error: Intersection failed\n";
return 0;
}
//
@ -641,11 +648,20 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
return 0;
}
//
aTolR=aFF.TolReached3d();
di << "Tolerance Reached=" << aTolR << "\n";
//
// curves
if (aNbCurves) {
Standard_Real aTolR = 0.;
if (!bExtOut) {
// find maximal tolerance
for (Standard_Integer i = 1; i <= aNbCurves; i++) {
const IntTools_Curve& anIC = aSCs(i);
if (aTolR < anIC.Tolerance()) {
aTolR = anIC.Tolerance();
}
}
di << "Tolerance Reached=" << aTolR << "\n";
}
//
di << aNbCurves << " curve(s) found.\n";
//
for (Standard_Integer i=1; i<=aNbCurves; i++) {
@ -695,8 +711,16 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
}
di << ") ";
}
//
if (bExtOut) {
di << "\nTolerance: " << anIC.Tolerance() << "\n";
di << "Tangential tolerance: " << anIC.TangentialTolerance() << "\n";
di << "\n";
}
}
if (!bExtOut) {
di << "\n";
}
di << "\n";
}
//
// points

View File

@ -20,7 +20,6 @@ IntTools_Context.cxx
IntTools_Context.hxx
IntTools_Curve.cxx
IntTools_Curve.hxx
IntTools_Curve.lxx
IntTools_CurveRangeLocalizeData.cxx
IntTools_CurveRangeLocalizeData.hxx
IntTools_CurveRangeLocalizeData.lxx

View File

@ -12,105 +12,91 @@
// commercial license or contractual agreement.
#include <IntTools_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_BoundedCurve.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Pnt.hxx>
#include <IntTools_Curve.hxx>
//=======================================================================
//function : IntTools_Curve::IntTools_Curve
//purpose :
//=======================================================================
IntTools_Curve::IntTools_Curve()
:
myTolerance(0.0),
myTangentialTolerance(0.0)
{
}
//=======================================================================
//function : IntTools_Curve::IntTools_Curve
//purpose :
//=======================================================================
IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& Curve3d,
const Handle(Geom2d_Curve)& FirstCurve2d,
const Handle(Geom2d_Curve)& SecondCurve2d)
IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& the3dCurve,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2,
const Standard_Real theTolerance,
const Standard_Real theTangentialTolerance)
:
myTolerance(theTolerance),
myTangentialTolerance(theTangentialTolerance)
{
SetCurves(Curve3d, FirstCurve2d, SecondCurve2d);
SetCurves(the3dCurve, the2dCurve1, the2dCurve2);
}
//=======================================================================
//function : SetCurves
//purpose :
//=======================================================================
void IntTools_Curve::SetCurves(const Handle(Geom_Curve)& Curve3d,
const Handle(Geom2d_Curve)& FirstCurve2d,
const Handle(Geom2d_Curve)& SecondCurve2d)
{
SetCurve(Curve3d);
SetFirstCurve2d(FirstCurve2d);
SetSecondCurve2d(SecondCurve2d);
}
//=======================================================================
//function : HasBounds
//purpose :
//=======================================================================
Standard_Boolean IntTools_Curve::HasBounds() const
{
Standard_Boolean bBounded;
Handle(Geom_BoundedCurve) aC3DBounded =
Handle(Geom_BoundedCurve)::DownCast(my3dCurve);
bBounded=!aC3DBounded.IsNull();
return bBounded ;
Standard_Boolean bIsBounded = !aC3DBounded.IsNull();
return bIsBounded;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void IntTools_Curve::Bounds(Standard_Real& aT1,
Standard_Real& aT2,
gp_Pnt& aP1,
gp_Pnt& aP2) const
Standard_Boolean IntTools_Curve::Bounds(Standard_Real& theFirst,
Standard_Real& theLast,
gp_Pnt& theFirstPnt,
gp_Pnt& theLastPnt) const
{
aT1=0.;
aT2=0.;
aP1.SetCoord(0.,0.,0.);
aP2.SetCoord(0.,0.,0.);
if (HasBounds()) {
aT1=my3dCurve->FirstParameter();
aT2=my3dCurve->LastParameter();
my3dCurve->D0(aT1, aP1);
my3dCurve->D0(aT2, aP2);
Standard_Boolean bIsBounded = HasBounds();
if (bIsBounded) {
theFirst = my3dCurve->FirstParameter();
theLast = my3dCurve->LastParameter();
my3dCurve->D0(theFirst, theFirstPnt);
my3dCurve->D0(theLast, theLastPnt);
}
return bIsBounded;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
Standard_Boolean IntTools_Curve::D0(Standard_Real& aT,
gp_Pnt& aP) const
Standard_Boolean IntTools_Curve::D0(const Standard_Real& thePar,
gp_Pnt& thePnt) const
{
Standard_Real aF, aL;
aF=my3dCurve->FirstParameter();
aL=my3dCurve->LastParameter();
if (aT<aF || aT>aL) {
return Standard_False;
Standard_Boolean bInside = !(thePar < my3dCurve->FirstParameter() &&
thePar > my3dCurve->LastParameter());
if (bInside) {
my3dCurve->D0(thePar, thePnt);
}
my3dCurve->D0(aT, aP);
return Standard_True;
return bInside;
}
//=======================================================================
//function : D0
//function : Type
//purpose :
//=======================================================================
GeomAbs_CurveType IntTools_Curve::Type() const
GeomAbs_CurveType IntTools_Curve::Type() const
{
GeomAdaptor_Curve aGAC(my3dCurve);
GeomAbs_CurveType aType=aGAC.GetType();
GeomAbs_CurveType aType = aGAC.GetType();
return aType;
}

View File

@ -27,103 +27,133 @@ class Geom_Curve;
class Geom2d_Curve;
class gp_Pnt;
//! class is a container of
//! one 3d curve
//! two 2d curves
class IntTools_Curve
//! The class is a container of one 3D curve, two 2D curves and two Tolerance values.<br>
//! It is used in the Face/Face intersection algorithm to store the results
//! of intersection. In this context:<br>
//! **the 3D curve** is the intersection curve;<br>
//! **the 2D curves** are the PCurves of the 3D curve on the intersecting faces;<br>
//! **the tolerance** is the valid tolerance for 3D curve computed as
//! maximal deviation between 3D curve and 2D curves (or surfaces in case there are no 2D curves);<br>
//! **the tangential tolerance** is the maximal distance from 3D curve to the
//! end of the tangential zone between faces in terms of their tolerance values.
class IntTools_Curve
{
public:
DEFINE_STANDARD_ALLOC
//! Empty constructor
Standard_EXPORT IntTools_Curve();
//! Initializes me by a 3d curve
//! and two 2d curves
Standard_EXPORT IntTools_Curve(const Handle(Geom_Curve)& Curve3d, const Handle(Geom2d_Curve)& FirstCurve2d, const Handle(Geom2d_Curve)& SecondCurve2d);
//! Constructor taking 3d curve, two 2d curves and two tolerance values
Standard_EXPORT IntTools_Curve(const Handle(Geom_Curve)& the3dCurve3d,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2,
const Standard_Real theTolerance = 0.0,
const Standard_Real theTangentialTolerance = 0.0);
//! Modifier
Standard_EXPORT void SetCurves (const Handle(Geom_Curve)& Curve3d, const Handle(Geom2d_Curve)& FirstCurve2d, const Handle(Geom2d_Curve)& SecondCurve2d);
//! Sets the curves
void SetCurves(const Handle(Geom_Curve)& the3dCurve,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2)
{
my3dCurve = the3dCurve;
my2dCurve1 = the2dCurve1;
my2dCurve2 = the2dCurve2;
}
//! Modifier
void SetCurve (const Handle(Geom_Curve)& Curve3d);
//! Sets the 3d curve
void SetCurve(const Handle(Geom_Curve)& the3dCurve)
{
my3dCurve = the3dCurve;
}
//! Modifier
void SetFirstCurve2d (const Handle(Geom2d_Curve)& FirstCurve2d);
//! Sets the first 2d curve
void SetFirstCurve2d(const Handle(Geom2d_Curve)& the2dCurve1)
{
my2dCurve1 = the2dCurve1;
}
//! Modifier
void SetSecondCurve2d (const Handle(Geom2d_Curve)& SecondCurve2d);
//! Sets the second 2d curve
void SetSecondCurve2d(const Handle(Geom2d_Curve)& the2dCurve2)
{
my2dCurve2 = the2dCurve2;
}
//! Selector
const Handle(Geom_Curve)& Curve() const;
//! Sets the tolerance for the curve
void SetTolerance(const Standard_Real theTolerance)
{
myTolerance = theTolerance;
}
//! Selector
const Handle(Geom2d_Curve)& FirstCurve2d() const;
//! Sets the tangential tolerance
void SetTangentialTolerance(const Standard_Real theTangentialTolerance)
{
myTangentialTolerance = theTangentialTolerance;
}
//! Selector
const Handle(Geom2d_Curve)& SecondCurve2d() const;
//! Returns 3d curve
const Handle(Geom_Curve)& Curve() const
{
return my3dCurve;
}
//! Returns true if 3d curve is BoundedCurve from Geom
//! Returns first 2d curve
const Handle(Geom2d_Curve)& FirstCurve2d() const
{
return my2dCurve1;
}
//! Returns second 2d curve
const Handle(Geom2d_Curve)& SecondCurve2d() const
{
return my2dCurve2;
}
//! Returns the tolerance
Standard_Real Tolerance() const
{
return myTolerance;
}
//! Returns the tangential tolerance
Standard_Real TangentialTolerance() const
{
return myTangentialTolerance;
}
//! Returns TRUE if 3d curve is BoundedCurve
Standard_EXPORT Standard_Boolean HasBounds() const;
//! Returns boundary parameters
//! and corresponded 3d point.
//!
//! Warning:
//! If HasBounds returns false
//! the returned parameters are equal
//! to zero.
Standard_EXPORT void Bounds (Standard_Real& aT1, Standard_Real& aT2, gp_Pnt& aP1, gp_Pnt& aP2) const;
//! If the 3d curve is bounded curve the method will return TRUE
//! and modify the output parameters with boundary parameters of
//! the curve and corresponded 3d points.<br>
//! If the curve does not have bounds, the method will return false
//! and the output parameters will stay untouched.
Standard_EXPORT Standard_Boolean Bounds(Standard_Real& theFirst,
Standard_Real& theLast,
gp_Pnt& theFirstPnt,
gp_Pnt& theLastPnt) const;
//! Computes 3d point corresponded to parameter aT1
//! Returns true if given parameter aT1
//! is inside the boundaries of the curve
Standard_EXPORT Standard_Boolean D0 (Standard_Real& aT1, gp_Pnt& aP1) const;
//! Computes 3d point corresponded to the given parameter if this
//! parameter is inside the boundaries of the curve.
//! Returns TRUE in this case. <br>
//! Otherwise, the point will not be computed and the method will return FALSE.
Standard_EXPORT Standard_Boolean D0(const Standard_Real& thePar,
gp_Pnt& thePnt) const;
//! Returns the type of 3d curve
//! Returns the type of the 3d curve
Standard_EXPORT GeomAbs_CurveType Type() const;
protected:
private:
Handle(Geom_Curve) my3dCurve;
Handle(Geom2d_Curve) my2dCurve1;
Handle(Geom2d_Curve) my2dCurve2;
Standard_Real myTolerance;
Standard_Real myTangentialTolerance;
};
#include <IntTools_Curve.lxx>
#endif // _IntTools_Curve_HeaderFile

View File

@ -1,66 +0,0 @@
// 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.
//=======================================================================
//function : SetCurve
//purpose :
//=======================================================================
inline void IntTools_Curve::SetCurve(const Handle(Geom_Curve)& Curve3d)
{
my3dCurve = Curve3d;
}
//=======================================================================
//function : SetFirstCurve2d
//purpose :
//=======================================================================
inline void IntTools_Curve::SetFirstCurve2d(const Handle(Geom2d_Curve)& FirstCurve2d)
{
my2dCurve1 = FirstCurve2d;
}
//=======================================================================
//function : SetSecondCurve2d
//purpose :
//=======================================================================
inline void IntTools_Curve::SetSecondCurve2d(const Handle(Geom2d_Curve)& SecondCurve2d)
{
my2dCurve2 = SecondCurve2d;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
inline const Handle(Geom_Curve)& IntTools_Curve::Curve() const
{
return my3dCurve;
}
//=======================================================================
//function : FirstCurve2d
//purpose :
//=======================================================================
inline const Handle(Geom2d_Curve)& IntTools_Curve::FirstCurve2d() const
{
return my2dCurve1;
}
//=======================================================================
//function : SecondCurve2d
//purpose :
//=======================================================================
inline const Handle(Geom2d_Curve)& IntTools_Curve::SecondCurve2d() const
{
return my2dCurve2;
}

View File

@ -55,11 +55,6 @@
#include <TopoDS_Edge.hxx>
#include <gp_Elips.hxx>
static
void TolR3d(const Standard_Real aTolF1,
const Standard_Real aTolF2,
Standard_Real& myTolReached3d);
static
void Parameters(const Handle(GeomAdaptor_HSurface)&,
const Handle(GeomAdaptor_HSurface)&,
@ -95,17 +90,16 @@ static
Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
const gp_Sphere& theSph);
static void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
static void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
const Standard_Real TolF1,
const Standard_Real TolF2,
const Standard_Real TolAng,
const Standard_Real TolTang,
const Standard_Real TolAng,
const Standard_Real TolTang,
const Standard_Boolean theApprox1,
const Standard_Boolean theApprox2,
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces,
Standard_Real& TolReached3d);
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces);
static Standard_Boolean ClassifyLin2d(const Handle(GeomAdaptor_HSurface)& theS,
const gp_Lin2d& theLin2d,
@ -173,9 +167,6 @@ IntTools_FaceFace::IntTools_FaceFace()
//
myHS1 = new GeomAdaptor_HSurface ();
myHS2 = new GeomAdaptor_HSurface ();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
myTolF1 = 0.;
myTolF2 = 0.;
myTol = 0.;
@ -239,22 +230,6 @@ Standard_Boolean IntTools_FaceFace::IsDone() const
return myIsDone;
}
//=======================================================================
//function : TolReached3d
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::TolReached3d() const
{
return myTolReached3d;
}
//=======================================================================
//function : TolReal
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::TolReal() const
{
return myTolReal;
}
//=======================================================================
//function : Lines
//purpose : return lines of intersection
//=======================================================================
@ -265,14 +240,6 @@ const IntTools_SequenceOfCurves& IntTools_FaceFace::Lines() const
"IntTools_FaceFace::Lines() => myIntersector NOT DONE");
return mySeqOfCurve;
}
//=======================================================================
//function : TolReached2d
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::TolReached2d() const
{
return myTolReached2d;
}
// =======================================================================
// function: SetParameters
//
@ -398,9 +365,6 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
}
mySeqOfCurve.Clear();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
myIsDone = Standard_False;
myNbrestr=0;//?
@ -472,38 +436,24 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
//
Standard_Real TolAng = 1.e-8;
//
PerformPlanes(myHS1, myHS2,
myTolF1, myTolF2, TolAng, TolTang,
myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces, myTolReached3d);
PerformPlanes(myHS1, myHS2,
myTolF1, myTolF2, TolAng, TolTang,
myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces);
//
myIsDone = Standard_True;
if(!myTangentFaces) {
//
if (!myTangentFaces) {
const Standard_Integer NbLinPP = mySeqOfCurve.Length();
if(NbLinPP) {
Standard_Real aTolFMax;
aTolFMax=Max(myTolF1, myTolF2);
myTolReal = Precision::Confusion();
if (aTolFMax > myTolReal) {
myTolReal = aTolFMax;
}
if (aTolFMax > myTolReached3d) {
myTolReached3d = aTolFMax;
}
//
myTolReached2d = myTolReal;
if (bReverse) {
Handle(Geom2d_Curve) aC2D1, aC2D2;
const Standard_Integer aNbLin = mySeqOfCurve.Length();
for (Standard_Integer i = 1; i <= aNbLin; ++i) {
IntTools_Curve& aIC=mySeqOfCurve(i);
aC2D1=aIC.FirstCurve2d();
aC2D2=aIC.SecondCurve2d();
aIC.SetFirstCurve2d(aC2D2);
aIC.SetSecondCurve2d(aC2D1);
}
if (NbLinPP && bReverse) {
Handle(Geom2d_Curve) aC2D1, aC2D2;
const Standard_Integer aNbLin = mySeqOfCurve.Length();
for (Standard_Integer i = 1; i <= aNbLin; ++i) {
IntTools_Curve& aIC = mySeqOfCurve(i);
aC2D1 = aIC.FirstCurve2d();
aC2D2 = aIC.SecondCurve2d();
aIC.SetFirstCurve2d(aC2D2);
aIC.SetSecondCurve2d(aC2D1);
}
}
}
@ -712,121 +662,78 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
}
//=======================================================================
//function : ComputeTolerance
//function :ComputeTolReached3d
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::ComputeTolerance()
void IntTools_FaceFace::ComputeTolReached3d()
{
Standard_Integer i, j, aNbLin;
Standard_Real aFirst, aLast, aD, aDMax, aT;
Handle(Geom_Surface) aS1, aS2;
Standard_Integer i, j, aNbLin = mySeqOfCurve.Length();
if (!aNbLin) {
return;
}
//
aDMax = 0;
aNbLin = mySeqOfCurve.Length();
// Minimal tangential tolerance for the curve
Standard_Real aTolFMax = Max(myTolF1, myTolF2);
//
aS1 = myHS1->ChangeSurface().Surface();
aS2 = myHS2->ChangeSurface().Surface();
const Handle(Geom_Surface)& aS1 = myHS1->ChangeSurface().Surface();
const Handle(Geom_Surface)& aS2 = myHS2->ChangeSurface().Surface();
//
for (i = 1; i <= aNbLin; ++i)
{
const IntTools_Curve& aIC = mySeqOfCurve(i);
IntTools_Curve& aIC = mySeqOfCurve(i);
const Handle(Geom_Curve)& aC3D = aIC.Curve();
if (aC3D.IsNull())
{
continue;
}
//
aFirst = aC3D->FirstParameter();
aLast = aC3D->LastParameter();
Standard_Real aTolC = aIC.Tolerance();
Standard_Real aFirst = aC3D->FirstParameter();
Standard_Real aLast = aC3D->LastParameter();
//
// Compute the tolerance for the curve
const Handle(Geom2d_Curve)& aC2D1 = aIC.FirstCurve2d();
const Handle(Geom2d_Curve)& aC2D2 = aIC.SecondCurve2d();
//
for (j = 0; j < 2; ++j)
{
const Handle(Geom2d_Curve)& aC2D = !j ? aC2D1 : aC2D2;
const Handle(Geom_Surface)& aS = !j ? aS1 : aS2;
//
if (!aC2D.IsNull())
{
// Look for the maximal deviation between 3D and 2D curves
Standard_Real aD, aT;
const Handle(Geom_Surface)& aS = !j ? aS1 : aS2;
if (IntTools_Tools::ComputeTolerance
(aC3D, aC2D, aS, aFirst, aLast, aD, aT))
{
if (aD > aDMax)
if (aD > aTolC)
{
aDMax = aD;
aTolC = aD;
}
}
}
else
{
// Look for the maximal deviation between 3D curve and surface
const TopoDS_Face& aF = !j ? myFace1 : myFace2;
aD = FindMaxDistance(aC3D, aFirst, aLast, aF, myContext);
if (aD > aDMax)
Standard_Real aD = FindMaxDistance(aC3D, aFirst, aLast, aF, myContext);
if (aD > aTolC)
{
aDMax = aD;
aTolC = aD;
}
}
}
}
//
return aDMax;
}
//=======================================================================
//function :ComputeTolReached3d
//purpose :
//=======================================================================
void IntTools_FaceFace::ComputeTolReached3d()
{
Standard_Integer aNbLin;
GeomAbs_SurfaceType aType1, aType2;
//
aNbLin=myIntersector.NbLines();
if (!aNbLin) {
return;
}
//
aType1=myHS1->Surface().GetType();
aType2=myHS2->Surface().GetType();
//
if (aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder)
{
if (aNbLin==2)
{
Handle(IntPatch_Line) aIL1, aIL2;
IntPatch_IType aTL1, aTL2;
//
aIL1=myIntersector.Line(1);
aIL2=myIntersector.Line(2);
aTL1=aIL1->ArcType();
aTL2=aIL2->ArcType();
if (aTL1==IntPatch_Lin && aTL2==IntPatch_Lin) {
Standard_Real aD, aDTresh, dTol;
gp_Lin aL1, aL2;
//
dTol=1.e-8;
aDTresh=1.5e-6;
//
aL1=Handle(IntPatch_GLine)::DownCast(aIL1)->Line();
aL2=Handle(IntPatch_GLine)::DownCast(aIL2)->Line();
aD=aL1.Distance(aL2);
aD=0.5*aD;
if (aD<aDTresh)
{//In order to avoid creation too thin face
myTolReached3d=aD+dTol;
}
}
// Set the valid tolerance for the curve
aIC.SetTolerance(aTolC);
//
// Set the tangential tolerance for the curve.
// Note, that, currently, computation of the tangential tolerance is
// implemented for the Plane/Plane case only.
// Thus, set the tangential tolerance equal to maximal tolerance of faces.
if (aIC.TangentialTolerance() < aTolFMax) {
aIC.SetTangentialTolerance(aTolFMax);
}
}// if (aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder) {
//
Standard_Real aDMax = ComputeTolerance();
if (aDMax > myTolReached3d)
{
myTolReached3d = aDMax;
}
myTolReal = myTolReached3d;
}
//=======================================================================
@ -931,11 +838,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
new Geom_Hyperbola (Handle(IntPatch_GLine)::DownCast(L)->Hyperbola());
}
//
// myTolReached3d
if (typl == IntPatch_Lin) {
TolR3d (myTolF1, myTolF2, myTolReached3d);
}
//
aNbParts=myLConstruct.NbParts();
for (i=1; i<=aNbParts; i++) {
Standard_Boolean bFNIt, bLPIt;
@ -952,7 +854,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle(Geom_TrimmedCurve) aCT3D=new Geom_TrimmedCurve(newc, fprm, lprm);
aCurve.SetCurve(aCT3D);
if (typl == IntPatch_Parabola) {
myTolReached3d=IntTools_Tools::CurveTolerance(aCT3D, myTol);
Standard_Real aTolC = IntTools_Tools::CurveTolerance(aCT3D, myTol);
aCurve.SetTolerance(aTolC);
}
//
aCurve.SetCurve(new Geom_TrimmedCurve(newc, fprm, lprm));
@ -960,33 +863,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0.) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
}
aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm));
}
//
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS2->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0.) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetSecondCurve2d(H1);
aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm));
}
//
mySeqOfCurve.Append(aCurve);
} //if (!bFNIt && !bLPIt) {
else {
@ -1053,9 +939,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
(Handle(IntPatch_GLine)::DownCast(L)->Ellipse());
}
//
// myTolReached3d
TolR3d (myTolF1, myTolF2, myTolReached3d);
//
aNbParts=myLConstruct.NbParts();
//
Standard_Real aPeriod, aNul;
@ -1079,10 +962,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else {
gp_Pnt P1 = newc->Value(fprm);
gp_Pnt P2 = newc->Value(aPeriod);
Standard_Real aTolDist = myTol;
aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
if(P1.Distance(P2) > aTolDist) {
if(P1.Distance(P2) > myTol) {
Standard_Real anewpar = fprm;
if(ParameterOutOfBoundary(fprm, newc, myFace1, myFace2,
@ -1102,10 +983,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else {
gp_Pnt P1 = newc->Value(aNul);
gp_Pnt P2 = newc->Value(lprm);
Standard_Real aTolDist = myTol;
aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
if(P1.Distance(P2) > aTolDist) {
if(P1.Distance(P2) > myTol) {
Standard_Real anewpar = lprm;
if(ParameterOutOfBoundary(lprm, newc, myFace1, myFace2,
@ -1123,7 +1002,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
aSeqLprm.Append(lprm);
}
}
//
aNbParts=aSeqFprm.Length();
for (i=1; i<=aNbParts; i++) {
@ -1145,39 +1023,17 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else { ////
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS2->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
aCurve.SetSecondCurve2d(H1);
}
//
mySeqOfCurve.Append(aCurve);
//==============================================
} //if (Abs(fprm) > RealEpsilon() || Abs(lprm-2.*M_PI) > RealEpsilon())
@ -1198,31 +1054,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS1->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else { ////
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS2->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
//
mySeqOfCurve.Append(aCurve);
break;
}
@ -1251,40 +1092,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS2->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
}// end of if (typl == IntPatch_Circle || typl == IntPatch_Ellipse)
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
aCurve.SetSecondCurve2d(H1);
}
//==============================================
//
mySeqOfCurve.Append(aCurve);
@ -1410,14 +1227,13 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
aSeqOfL,
aReachedTol,
myContext);
if ( bIsDecomposited && ( myTolReached3d < aReachedTol ) ) {
myTolReached3d = aReachedTol;
}
//
aNbSeqOfL=aSeqOfL.Length();
//
Standard_Real aTolC = 0.;
if (bIsDecomposited) {
nbiter=aNbSeqOfL;
aTolC = aReachedTol;
}
else {
nbiter=1;
@ -1495,27 +1311,22 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
IntTools_Curve aIC(aBSp, H1, H2);
mySeqOfCurve.Append(aIC);
}
else {
if(myApprox1 || myApprox2 || (typs1==GeomAbs_Plane || typs2==GeomAbs_Plane)) {
if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0.) {
myTolReached2d = theapp3d.TolReached2d();
if (typs1 == GeomAbs_Plane || typs2 == GeomAbs_Plane) {
if (aTolC < theapp3d.TolReached2d()) {
aTolC = theapp3d.TolReached2d();
}
}
if(typs1==GeomAbs_Plane || typs2==GeomAbs_Plane) {
myTolReached3d = myTolReached2d;
//
if (typs1==GeomAbs_Torus || typs2==GeomAbs_Torus) {
if (myTolReached3d<1.e-6) {
myTolReached3d = theapp3d.TolReached3d();
myTolReached3d=1.e-6;
if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) {
if (aTolC < 1.e-6) {
aTolC = 1.e-6;
}
}
}
else if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0.) {
myTolReached3d = theapp3d.TolReached3d();
else if (aTolC < theapp3d.TolReached3d()) {
aTolC = theapp3d.TolReached3d();
}
//
Standard_Integer aNbMultiCurves, nbpoles;
aNbMultiCurves=theapp3d.NbMultiCurves();
for (j=1; j<=aNbMultiCurves; j++) {
@ -1568,10 +1379,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
// ############################################
aCurve.SetFirstCurve2d(BS1);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
mbspc.Curve(2, tpoles2d);
@ -1595,11 +1402,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//
aCurve.SetSecondCurve2d(BS2);
}
else {
Handle(Geom2d_BSplineCurve) H2;
//
aCurve.SetSecondCurve2d(H2);
}
//
aCurve.SetTolerance(aTolC);
//
mySeqOfCurve.Append(aCurve);
@ -1633,6 +1437,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//
IntTools_Curve aCurve;
aCurve.SetCurve(BS);
aCurve.SetTolerance(aTolC);
if(myApprox2) {
Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
@ -1654,11 +1459,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
bPCurvesOk = CheckPCurve(BS1, myFace2, myContext);
aCurve.SetSecondCurve2d(BS1);
}
else {
Handle(Geom2d_BSplineCurve) H2;
aCurve.SetSecondCurve2d(H2);
}
if(myApprox1) {
mbspc.Curve(1,tpoles2d);
Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
@ -1680,11 +1481,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
bPCurvesOk = bPCurvesOk && CheckPCurve(BS2, myFace1, myContext);
aCurve.SetFirstCurve2d(BS2);
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
}
//
//if points of the pcurves are out of the faces bounds
//create 3d and 2d curves without approximation
@ -1707,7 +1503,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//if pcurves created without approximation are out of the
//faces bounds, use approximated 3d and 2d curves
if (bPCurvesOk) {
IntTools_Curve aIC(aBSp, H1, H2);
IntTools_Curve aIC(aBSp, H1, H2, aTolC);
mySeqOfCurve.Append(aIC);
} else {
mySeqOfCurve.Append(aCurve);
@ -1721,8 +1517,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else { //typs2 != GeomAbs_Plane && typs1 != GeomAbs_Plane
Standard_Boolean bIsValid1, bIsValid2;
Handle(Geom_BSplineCurve) BS;
Handle(Geom2d_BSplineCurve) aH2D;
IntTools_Curve aCurve;
IntTools_Curve aCurve;
//
bIsValid1=Standard_True;
bIsValid2=Standard_True;
@ -1737,10 +1532,9 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
mbspc.Degree());
GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
Check.FixTangent(Standard_True,Standard_True);
//
//
aCurve.SetCurve(BS);
aCurve.SetFirstCurve2d(aH2D);
aCurve.SetSecondCurve2d(aH2D);
aCurve.SetTolerance(aTolC);
//
if(myApprox1) {
if(anApprox1) {
@ -1749,9 +1543,9 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
mbspc.Curve(2,tpoles2d);
//
BS1=new Geom2d_BSplineCurve(tpoles2d,
mbspc.Knots(),
mbspc.Multiplicities(),
mbspc.Degree());
mbspc.Knots(),
mbspc.Multiplicities(),
mbspc.Degree());
GeomLib_Check2dBSplineCurve newCheck(BS1,TOLCHECK,TOLANGCHECK);
newCheck.FixTangent(Standard_True,Standard_True);
//
@ -2241,24 +2035,6 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL,
}
}
//=======================================================================
//function : TolR3d
//purpose :
//=======================================================================
void TolR3d(const Standard_Real aTolF1,
const Standard_Real aTolF2,
Standard_Real& myTolReached3d)
{
Standard_Real aTolFMax, aTolTresh;
aTolTresh=2.999999e-3;
aTolFMax=Max(aTolF1, aTolF2);
if (aTolFMax>aTolTresh) {
myTolReached3d=aTolFMax;
}
}
// ------------------------------------------------------------------------------------------------
// static function: ParameterOutOfBoundary
// purpose: Computes a new parameter for given curve. The corresponding 2d points
@ -2443,17 +2219,16 @@ Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
//function : PerformPlanes
//purpose :
//=======================================================================
void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
const Standard_Real TolF1,
const Standard_Real TolF2,
const Standard_Real TolAng,
const Standard_Real TolTang,
void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
const Standard_Real TolF1,
const Standard_Real TolF2,
const Standard_Real TolAng,
const Standard_Real TolTang,
const Standard_Boolean theApprox1,
const Standard_Boolean theApprox2,
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces,
Standard_Real& TolReached3d)
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces)
{
gp_Pln aPln1 = theS1->Surface().Plane();
@ -2534,10 +2309,13 @@ void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
Handle(Geom2d_Curve) H1;
aCurve.SetFirstCurve2d(H1);
}
theSeqOfCurve.Append(aCurve);
//
// computation of the tolerance reached
// Valid tolerance for the intersection curve between planar faces
// is the maximal tolerance between tolerances of faces
Standard_Real aTolC = Max(TolF1, TolF2);
aCurve.SetTolerance(aTolC);
//
// Computation of the tangential tolerance
Standard_Real anAngle, aDt;
gp_Dir aD1, aD2;
//
@ -2546,7 +2324,11 @@ void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
anAngle = aD1.Angle(aD2);
//
aDt = IntTools_Tools::ComputeIntRange(TolF1, TolF2, anAngle);
TolReached3d = sqrt(aDt*aDt + TolF1*TolF1);
Standard_Real aTangTol = sqrt(aDt*aDt + TolF1*TolF1);
//
aCurve.SetTangentialTolerance(aTangTol);
//
theSeqOfCurve.Append(aCurve);
}
//=======================================================================

View File

@ -70,21 +70,6 @@ public:
//! Returns sequence of 3d curves as result of intersection
Standard_EXPORT const IntTools_SequenceOfPntOn2Faces& Points() const;
//! Returns tolerance reached during approximation,
//! and possibly increased to cover more area due to a small angle between surfaces.
//! If approximation was not done, returns zero.
Standard_EXPORT Standard_Real TolReached3d() const;
//! Returns tolerance reached during approximation, without any increase.
//! If approximation was not done, returns zero.
Standard_EXPORT Standard_Real TolReal() const;
//! Returns tolerance reached during approximation.
//! If approximation was not done, returns zero.
Standard_EXPORT Standard_Real TolReached2d() const;
//! Returns first of processed faces
Standard_EXPORT const TopoDS_Face& Face1() const;
@ -121,37 +106,28 @@ public:
//! Gets the intersecton context
Standard_EXPORT const Handle(IntTools_Context)& Context() const;
protected:
//! Creates curves from the IntPatch_Line.
Standard_EXPORT void MakeCurve (const Standard_Integer Index,
const Handle(Adaptor3d_TopolTool)& D1,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real theToler);
//! Computes the valid tolerance for the intersection curves
//! as a maximal deviation between 3D curve and 2D curves on faces.<br>
//! If there are no 2D curves the maximal deviation between 3D curves
//! and surfaces is computed.
Standard_EXPORT void ComputeTolReached3d();
Standard_EXPORT Standard_Real ComputeTolerance();
private:
Standard_Boolean myIsDone;
IntPatch_Intersection myIntersector;
GeomInt_LineConstructor myLConstruct;
Handle(GeomAdaptor_HSurface) myHS1;
Handle(GeomAdaptor_HSurface) myHS2;
Standard_Integer myNbrestr;
Standard_Real myTolReached2d;
Standard_Real myTolReached3d;
Standard_Real myTolReal;
Standard_Boolean myApprox;
Standard_Boolean myApprox1;
Standard_Boolean myApprox2;
@ -168,13 +144,6 @@ private:
IntSurf_ListOfPntOn2S myListOfPnts;
Handle(IntTools_Context) myContext;
};
#endif // _IntTools_FaceFace_HeaderFile

View File

@ -252,10 +252,9 @@ static
aC2D2F=new Geom2d_TrimmedCurve (aC2D2, aF, aMid);
aC2D2L=new Geom2d_TrimmedCurve (aC2D2, aMid, aL);
}
//
IntTools_Curve aIC1(aC3DNewF, aC2D1F, aC2D2F);
IntTools_Curve aIC2(aC3DNewL, aC2D1L, aC2D2L);
//
IntTools_Curve aIC1(aC3DNewF, aC2D1F, aC2D2F, IC.Tolerance(), IC.TangentialTolerance());
IntTools_Curve aIC2(aC3DNewL, aC2D1L, aC2D2L, IC.Tolerance(), IC.TangentialTolerance());
//
aCvs.Append(aIC1);
//
@ -587,27 +586,32 @@ void ParabolaTolerance(const Handle(Geom_Curve)& aC3D,
//function : CheckCurve
//purpose :
//=======================================================================
Standard_Boolean IntTools_Tools::CheckCurve(const Handle (Geom_Curve)& aC3D,
const Standard_Real aTolR3D,
Bnd_Box& aBox)
Standard_Boolean IntTools_Tools::CheckCurve(const IntTools_Curve& theCurve,
Bnd_Box& theBox)
{
Standard_Boolean bRet;
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dX, dY, dZ;
Standard_Real dS, aTol;
GeomAdaptor_Curve aGAC;
const Handle(Geom_Curve)& aC3D = theCurve.Curve();
Standard_Boolean bValid = !aC3D.IsNull();
if (!bValid) {
return bValid;
}
//
aGAC.Load(aC3D);
BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBox);
// 910/B1
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
dX=aXmax-aXmin;
dY=aYmax-aYmin;
dZ=aZmax-aZmin;
dS=1.e-12;
aTol=2.*aTolR3D+dS;
bRet=(dX>aTol || dY>aTol || dZ>aTol);
// Build bounding box for the curve
BndLib_Add3dCurve::Add(GeomAdaptor_Curve(aC3D),
Max(theCurve.Tolerance(), theCurve.TangentialTolerance()),
theBox);
//
return bRet;
// Estimate the bounding box of the curve comparing it with the
// minimal length for the curve from which the valid edge can be built -
// 3*Precision::Confusion():
// - 2 vertices with the Precision::Confusion() tolerance;
// - plus Precision::Confusion() as the minimal distance between vertices.
Standard_Real aTolCmp = 3*Precision::Confusion();
//
// Check the size of the box using the Bnd_Box::IsThin() method
// which does not use the gap of the box.
bValid = !theBox.IsThin(aTolCmp);
//
return bValid;
}
//=======================================================================
//function : IsOnPave

View File

@ -142,8 +142,11 @@ public:
//! if aC is trimmed curve and basis curve is parabola,
//! otherwise returns value of aTolBase
Standard_EXPORT static Standard_Real CurveTolerance (const Handle(Geom_Curve)& aC, const Standard_Real aTolBase);
Standard_EXPORT static Standard_Boolean CheckCurve (const Handle(Geom_Curve)& theC, const Standard_Real theTol, Bnd_Box& theBox);
//! Checks if the curve is not covered by the default tolerance (confusion).<br>
//! Builds bounding box for the curve and stores it into <theBox>.
Standard_EXPORT static Standard_Boolean CheckCurve(const IntTools_Curve& theCurve,
Bnd_Box& theBox);
Standard_EXPORT static Standard_Boolean IsOnPave (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);

View File

@ -0,0 +1,19 @@
puts "========"
puts "OCC28591"
puts "========"
puts ""
##########################################
## BOP Cut creates wrong result
##########################################
restore [locate_data_file bug28591_ToCut.brep] b1
restore [locate_data_file bug28591_vol_neg.brep] b2
bcut result b1 b2
checkshape result
checknbshapes result -face 38 -shell 9 -solid 9
checkprops result -s 0.0165593 -v 2.65628e-005
checkview -display result -2d -path ${imagedir}/${test_image}.png