1. Methods IntPolyh_MaillageAffinage::GetMinDeflection() and IntPolyh_MaillageAffinage::GetMaxDeflection() have been created (see cdl-file for more detail information).
2. Extended check, if starting point of WLine is a tangent point, has been implemented in IntWalk_PWalking::Perform(...) method.
Test cases for issue CR26151
//
anIsDone=aFF.IsDone();
if (!anIsDone) {
- di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
- return 1;
+ di << "Error: anIsDone=" << (Standard_Integer) anIsDone << "\n";
+ return 0;
}
//
aFF.PrepareLines3D(Standard_False);
aNbCurves=aSCs.Length();
if (!aNbCurves) {
di << " has no 3d curve\n";
- return 1;
+ return 0;
}
else
{
-- times.
class Intersection from IntPolyh
- ---Purpose: the main algorithm. Algorythm outputs are
- -- lines and points like discribe in the last
- -- paragraph. The Algorythm provides direct acces to
+ ---Purpose: the main algorithm. Algorithm outputs are
+ -- lines and points like describe in the last
+ -- paragraph. The Algorithm provides direct access to
-- the elements of those lines and points. Other
-- classes of this package are for internal use and
-- only concern the algorithmic part.
Standard_Integer MYPRINT = 0;
IntPolyh_Intersection::IntPolyh_Intersection(const Handle(Adaptor3d_HSurface)& S1,
- const Handle(Adaptor3d_HSurface)& S2)
+ const Handle(Adaptor3d_HSurface)& S2)
{
myNbSU1 = -1;
myNbSV1 = -1;
}
IntPolyh_Intersection::IntPolyh_Intersection(const Handle(Adaptor3d_HSurface)& S1,
- const Standard_Integer NbSU1,
- const Standard_Integer NbSV1,
- const Handle(Adaptor3d_HSurface)& S2,
- const Standard_Integer NbSU2,
- const Standard_Integer NbSV2)
+ const Standard_Integer NbSU1,
+ const Standard_Integer NbSV1,
+ const Handle(Adaptor3d_HSurface)& S2,
+ const Standard_Integer NbSU2,
+ const Standard_Integer NbSV2)
{
myNbSU1 = NbSU1;
myNbSV1 = NbSV1;
done = Standard_True;
- Standard_Boolean startFromAdvanced = Standard_False;
Standard_Boolean isStdDone = Standard_False;
Standard_Boolean isAdvDone = Standard_False;
Standard_Integer nbCouplesStd = 0;
Standard_Integer nbCouplesAdv = 0;
- //GeomAbs_SurfaceType ST1 = mySurf1->GetType();
- //GeomAbs_SurfaceType ST2 = mySurf2->GetType();
-
-// if(ST1 == GeomAbs_Torus || ST2 == GeomAbs_Torus)
-// startFromAdvanced = Standard_True;
-
IntPolyh_PMaillageAffinage aPMaillageStd = 0;
IntPolyh_PMaillageAffinage aPMaillageFF = 0;
IntPolyh_PMaillageAffinage aPMaillageFR = 0;
IntPolyh_PMaillageAffinage aPMaillageRF = 0;
IntPolyh_PMaillageAffinage aPMaillageRR = 0;
+ isStdDone = PerformStd(aPMaillageStd,nbCouplesStd);
- if(!startFromAdvanced) {
-
- isStdDone = PerformStd(aPMaillageStd,nbCouplesStd);
-
- // default interference done well, use it
- if(isStdDone && nbCouplesStd > 10) {
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
- // default interference done, but too few interferences foud;
- // use advanced interference
- else if(isStdDone && nbCouplesStd <= 10) {
- isAdvDone = PerformAdv(aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
-
- // advanced interference found
- if(isAdvDone && nbCouplesAdv > 10) {
- aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
- }
- else {
- // use result of default
- if(nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
- }
- // default interference faild, use advanced
- else {
-// isAdvDone = PerformAdv(aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
-
-// if(isAdvDone && nbCouplesAdv > 0) {cout << "4adv done, nbc: " << nbCouplesAdv << endl;
-// aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
-// aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
-// aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
-// aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
-// }
- }
- }// start from default
- else {
-
+ // default interference done well, use it
+ if(isStdDone && nbCouplesStd > 10) {
+ aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
+ }
+ // default interference done, but too few interferences foud;
+ // use advanced interference
+ else if(isStdDone && nbCouplesStd <= 10) {
isAdvDone = PerformAdv(aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
- // advanced done, interference found; use it
- if(isAdvDone) {
-
- if(nbCouplesAdv > 0) {
- aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
- }
- else {
- isStdDone = PerformStd(aPMaillageStd,nbCouplesStd);
- if(isStdDone && nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
+ // advanced interference found
+ if(isAdvDone && nbCouplesAdv > 10) {
+ aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
}
else {
- isStdDone = PerformStd(aPMaillageStd,nbCouplesStd);
- if(isStdDone && nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
+ // use result of default
+ if(nbCouplesStd > 0)
+ aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
}
- } // start from advanced
+ }
+ // default interference faild, use advanced
+ else {
+ // isAdvDone = PerformAdv(aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
+
+ // if(isAdvDone && nbCouplesAdv > 0) {cout << "4adv done, nbc: " << nbCouplesAdv << endl;
+ // aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
+ // aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
+ // aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
+ // aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
+ // }
+ }
// accept result
nbsectionlines = TSectionLines.NbItems();
//function : IntPolyh_Intersection
//purpose :
//=======================================================================
-
IntPolyh_Intersection::IntPolyh_Intersection(const Handle(Adaptor3d_HSurface)& S1,
- const TColStd_Array1OfReal& Upars1,
- const TColStd_Array1OfReal& Vpars1,
- const Handle(Adaptor3d_HSurface)& S2,
- const TColStd_Array1OfReal& Upars2,
- const TColStd_Array1OfReal& Vpars2)
+ const TColStd_Array1OfReal& Upars1,
+ const TColStd_Array1OfReal& Vpars1,
+ const Handle(Adaptor3d_HSurface)& S2,
+ const TColStd_Array1OfReal& Upars2,
+ const TColStd_Array1OfReal& Vpars2)
{
myNbSU1 = Upars1.Length();
myNbSV1 = Vpars1.Length();
done = Standard_True;
- Standard_Boolean startFromAdvanced = Standard_False;
Standard_Boolean isStdDone = Standard_False;
Standard_Boolean isAdvDone = Standard_False;
Standard_Integer nbCouplesStd = 0;
IntPolyh_PMaillageAffinage aPMaillageRF = 0;
IntPolyh_PMaillageAffinage aPMaillageRR = 0;
+ isStdDone = PerformStd( Upars1, Vpars1, Upars2, Vpars2,
+ aPMaillageStd,nbCouplesStd);
- if(!startFromAdvanced) {
-
- isStdDone = PerformStd(Upars1, Vpars1, Upars2, Vpars2,
- aPMaillageStd,nbCouplesStd);
-
- // default interference done well, use it
- if(isStdDone && nbCouplesStd > 10) {
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
- // default interference done, but too few interferences foud;
- // use advanced interference
- else if(isStdDone && nbCouplesStd <= 10) {
- isAdvDone = PerformAdv(Upars1, Vpars1, Upars2, Vpars2,
- aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
+ // default interference done well, use it
+ if(isStdDone && nbCouplesStd > 10) {
+ aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
+ }
+ // default interference done, but too few interferences foud;
+ // use advanced interference
+ else if(isStdDone && nbCouplesStd <= 10) {
+ isAdvDone = PerformAdv( Upars1, Vpars1, Upars2, Vpars2,
+ aPMaillageFF,aPMaillageFR,aPMaillageRF,
+ aPMaillageRR,nbCouplesAdv);
- // advanced interference found
- if(isAdvDone && nbCouplesAdv > 10) {
- aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
- }
- else {
- // use result of default
- if(nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
+ // advanced interference found
+ if(isAdvDone && nbCouplesAdv > 10) {
+ aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
+ aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
}
- // default interference faild, use advanced
else {
+ // use result of default
+ if(nbCouplesStd > 0)
+ aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
+ }
+ }
+ // default interference faild, use advanced
+ else {
// isAdvDone = PerformAdv(aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
// if(isAdvDone && nbCouplesAdv > 0) {cout << "4adv done, nbc: " << nbCouplesAdv << endl;
// aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
// aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
// }
- }
- }// start from default
- else {
-
- isAdvDone = PerformAdv(Upars1, Vpars1, Upars2, Vpars2,
- aPMaillageFF,aPMaillageFR,aPMaillageRF,aPMaillageRR,nbCouplesAdv);
-
- // advanced done, interference found; use it
- if(isAdvDone) {
-
- if(nbCouplesAdv > 0) {
- aPMaillageFF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageFR->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRF->StartPointsChain(TSectionLines,TTangentZones);
- aPMaillageRR->StartPointsChain(TSectionLines,TTangentZones);
- }
- else {
- isStdDone = PerformStd(aPMaillageStd,nbCouplesStd);
- if(isStdDone && nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
- }
- else {
- isStdDone = PerformStd(Upars1, Vpars1, Upars2, Vpars2,
- aPMaillageStd,nbCouplesStd);
- if(isStdDone && nbCouplesStd > 0)
- aPMaillageStd->StartPointsChain(TSectionLines, TTangentZones);
- }
- } // start from advanced
+ }
// accept result
nbsectionlines = TSectionLines.NbItems();
(FinTTC >= theMaillageS->GetArrayOfTriangles(1).NbTriangles() ||
FinTTC >= theMaillageS->GetArrayOfTriangles(2).NbTriangles()) ) {
return Standard_False;
- }
+}
*/
//IFV test for parallel surf
if(FinTTC > 200) {
const Standard_Real eps = .996; //~ cos of 5deg.
IntPolyh_ArrayOfCouples& Couples = theMaillageS->GetArrayOfCouples();
-
+
Standard_Integer i, npara = 0;
for(i = 0; i < FinTTC; ++i) {
Standard_Real cosa = Abs(Couples[i].AngleValue());
(FinTTC >= theMaillageS->GetArrayOfTriangles(1).NbTriangles() ||
FinTTC >= theMaillageS->GetArrayOfTriangles(2).NbTriangles()) ) {
return Standard_False;
- }
+}
*/
//IFV test for parallel surf
if(FinTTC > 200) {
const Standard_Real eps = .996; //~ cos of 5deg.
IntPolyh_ArrayOfCouples& Couples = theMaillageS->GetArrayOfCouples();
-
+
Standard_Integer i, npara = 0;
for(i = 0; i < FinTTC; ++i) {
Standard_Real cosa = Abs(Couples[i].AngleValue());
//function : PerformAdv
//purpose :
//=======================================================================
-
Standard_Boolean IntPolyh_Intersection::PerformAdv(const TColStd_Array1OfReal& Upars1,
const TColStd_Array1OfReal& Vpars1,
const TColStd_Array1OfReal& Upars2,
SetEnlargeZone(me: in out; EnlargeZone: in out Boolean from Standard);
GetEnlargeZone(me) returns Boolean from Standard;
-
+ GetMinDeflection(me; SurfID: Integer from Standard) returns Real from Standard;
+ --- Purpose: returns FlecheMin
+ GetMaxDeflection(me; SurfID: Integer from Standard) returns Real from Standard;
+ --- Purpose: returns FlecheMax
+
fields
NbSamplesV1 : Integer from Standard;
NbSamplesV2 : Integer from Standard;
+ -- Minimal and maximal distance between array of points in
+ -- the surface (MaSurface1 and MaSurface2 correspondingly) and
+ -- triangles on it.
FlecheMax1 : Real from Standard;
FlecheMax2 : Real from Standard;
FlecheMin1 : Real from Standard;
//
if (TriContact(P1, P2, P3, Q1, Q2, Q3, CoupleAngle)) {
if (CpteurTab >= NbTTC)
- {
- TTrianglesContacts.SetNbItems(CpteurTab);
- return(CpteurTab);
- }
+ {
+ TTrianglesContacts.SetNbItems(CpteurTab);
+ return(CpteurTab);
+ }
TTrianglesContacts[CpteurTab].SetCoupleValue(i_S1, i_S2);
TTrianglesContacts[CpteurTab].SetAngleValue(CoupleAngle);
//test TTrianglesContacts[CpteurTab].Dump(CpteurTab);
{
return myEnlargeZone;
}
+
+//=======================================================================
+//function : GetMinDeflection
+//purpose :
+//=======================================================================
+Standard_Real IntPolyh_MaillageAffinage::GetMinDeflection(const Standard_Integer SurfID) const
+{
+ return (SurfID==1)? FlecheMin1:FlecheMin2;
+}
+
+//=======================================================================
+//function : GetMaxDeflection
+//purpose :
+//=======================================================================
+Standard_Real IntPolyh_MaillageAffinage::GetMaxDeflection(const Standard_Integer SurfID) const
+{
+ return (SurfID==1)? FlecheMax1:FlecheMax2;
+}
+
//=======================================================================
//function : DegeneratedIndex
//purpose :
#include <Standard_Failure.hxx>
#include <gp_Pnt2d.hxx>
+#include <Extrema_GenLocateExtPS.hxx>
+
//==================================================================================
// function : IntWalk_PWalking::IntWalk_PWalking
// purpose :
close(Standard_False),
fleche(Deflection),
tolconf(Epsilon),
-sensCheminement(1),
+sensCheminement(1),
myIntersectionOn2S(Caro1,Caro2,TolTangency),
STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
STATIC_PRECEDENT_INFLEXION(0)
{
Perform(ParDep,Um1,Vm1,Um2,Vm2,UM1,VM1,UM2,VM2);
}
+
+//=======================================================================
+//function : SQDistPointSurface
+//purpose : Returns square distance between thePnt and theSurf.
+// (theU0, theV0) is initial point for extrema
+//=======================================================================
+static Standard_Real SQDistPointSurface(const gp_Pnt &thePnt,
+ const Adaptor3d_Surface& theSurf,
+ const Standard_Real theU0,
+ const Standard_Real theV0)
+{
+ const Extrema_GenLocateExtPS aExtPS(thePnt, theSurf, theU0, theV0,
+ Precision::PConfusion(), Precision::PConfusion());
+ if(!aExtPS.IsDone())
+ return RealLast();
+
+ return aExtPS.SquareDistance();
+}
+
+//==================================================================================
+// function : IsTangentExtCheck
+// purpose : Additional check if the surfaces are tangent.
+// Checks if any point in one surface lie in another surface
+// (with given tolerance)
+//==================================================================================
+static Standard_Boolean IsTangentExtCheck(const Handle(Adaptor3d_HSurface)& theSurf1,
+ const Handle(Adaptor3d_HSurface)& theSurf2,
+ const Standard_Real theU10,
+ const Standard_Real theV10,
+ const Standard_Real theU20,
+ const Standard_Real theV20,
+ const Standard_Real theArrStep[])
+{
+ {
+ gp_Pnt aPt;
+ gp_Vec aDu1, aDv1, aDu2, aDv2;
+ theSurf1->D1(theU10, theV10, aPt, aDu1, aDv1);
+ theSurf2->D1(theU20, theV20, aPt, aDu2, aDv2);
+
+ const gp_Vec aN1(aDu1.Crossed(aDv1)),
+ aN2(aDu2.Crossed(aDv2));
+ const Standard_Real aDP = aN1.Dot(aN2),
+ aSQ1 = aN1.SquareMagnitude(),
+ aSQ2 = aN2.SquareMagnitude();
+
+ if((aSQ1 < RealSmall()) || (aSQ2 < RealSmall()))
+ return Standard_True; //Tangent
+
+ if(aDP*aDP < 0.9998*aSQ1*aSQ2)
+ {//cos(ang N1<->N2) < 0.9999
+ return Standard_False; //Not tangent
+ }
+ }
+
+ const Standard_Real aSQToler = 4.0e-14;
+ const Standard_Integer aNbItems = 4;
+ const Standard_Real aParUS1[aNbItems] = { theU10 + theArrStep[0],
+ theU10 - theArrStep[0],
+ theU10, theU10};
+ const Standard_Real aParVS1[aNbItems] = { theV10, theV10,
+ theV10 + theArrStep[1],
+ theV10 - theArrStep[1]};
+ const Standard_Real aParUS2[aNbItems] = { theU20 + theArrStep[2],
+ theU20 - theArrStep[2],
+ theU20, theU20};
+ const Standard_Real aParVS2[aNbItems] = { theV20, theV20,
+ theV20 + theArrStep[3],
+ theV20 - theArrStep[3]};
+
+ for(Standard_Integer i = 0; i < aNbItems; i++)
+ {
+ gp_Pnt aP(theSurf1->Value(aParUS1[i], aParVS1[i]));
+ const Standard_Real aSqDist = SQDistPointSurface(aP, theSurf2->Surface(), theU20, theV20);
+ if(aSqDist > aSQToler)
+ return Standard_False;
+ }
+
+ for(Standard_Integer i = 0; i < aNbItems; i++)
+ {
+ gp_Pnt aP(theSurf2->Value(aParUS2[i], aParVS2[i]));
+ const Standard_Real aSqDist = SQDistPointSurface(aP, theSurf1->Surface(), theU10, theV10);
+ if(aSqDist > aSQToler)
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
//==================================================================================
// function : Perform
// purpose :
Standard_Boolean bTestFirstPoint = Standard_True;
previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+
+ if(IsTangentExtCheck(Caro1, Caro2, Param(1), Param(2), Param(3), Param(4), pasuv))
+ return;
+
AddAPoint(line,previousPoint);
//
IntWalk_StatusDeflection Status = IntWalk_OK;
restore [locate_data_file bug23732_fx2.brep] b2
mksurface s1 b1
-mksurface s2 b1
+mksurface s2 b2
intersect result s1 s2
--- /dev/null
+puts "============"
+puts "OCC26151"
+puts "============"
+puts ""
+###############################
+## Wrong result obtained by intersection algorithm.
+###############################
+
+restore [locate_data_file bug26132_shape.brep] q
+
+explode q
+copy q_1 b1
+copy q_2 b2
+
+explode b1 f
+explode b2
+explode b2_10 f
+
+set log [bopcurves b1_1 b2_10_4 -2d]
+
+#Faces almost coincide. Therefore, there is no point in
+#returning some intersection line.
+#Theoretically, the intersection result is some region (tangent zone).
+
+if { [regexp "has no 3d curve" ${log}] != 1 } {
+ puts "Error : Wrong result obtained by intersection algorithm"
+} else {
+ puts "OK : Good result obtained by intersection algorithm"
+}
+
+smallview
+fit
+xwd $imagedir/${test_image}.png
--- /dev/null
+puts "============"
+puts "OCC26151"
+puts "============"
+puts ""
+###############################
+## Wrong result obtained by intersection algorithm.
+###############################
+
+restore [locate_data_file bug26132_shape.brep] q
+
+explode q
+copy q_1 b1
+copy q_2 b2
+
+explode b1 f
+explode b2
+explode b2_11 f
+
+set log [bopcurves b1_1 b2_11_2 -2d]
+
+#Faces almost coincide. Therefore, there is no point in
+#returning some intersection line.
+#Theoretically, the intersection result is some region (tangent zone).
+
+if { [regexp "has no 3d curve" ${log}] != 1 } {
+ puts "Error : Wrong result obtained by intersection algorithm"
+} else {
+ puts "OK : Good result obtained by intersection algorithm"
+}
+
+smallview
+fit
+xwd $imagedir/${test_image}.png
#set i 1
#set shapes {}
foreach s1 $surfaces {
-# mkface f_$s1 $s1
-# lappend shapes f_$s1
- foreach s2 $surfaces {
- if { $s1 != $s2 } {
- intersect r $s1 $s2
-# if { [regexp {a 3d curve} [whatis r]] } {
-# mkedge e_$i r
-# lappend shapes e_$i
-# incr i
-# }
- }
+# mkface f_$s1 $s1
+# lappend shapes f_$s1
+ foreach s2 $surfaces {
+ if { $s1 != $s2 } {
+ if [catch {intersect r $s1 $s2}] {
+ continue
+ }
+ # if { [regexp {a 3d curve} [whatis r]] } {
+# mkedge e_$i r
+# lappend shapes e_$i
+# incr i
+# }
}
+ }
}
#eval vdisplay $shapes; vfit