1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0026185: BRepOffsetAPI_MakeOffset: regressions on some customer's cases

Minor correction.

Test-cases for issue #26185

Modifications in test-cases according to developer's notes
This commit is contained in:
jgv 2015-05-28 15:25:42 +03:00 committed by bugmaster
parent a2ab27029b
commit 9eb68d382f
16 changed files with 230 additions and 77 deletions

View File

@ -900,6 +900,9 @@ void BRepFill_OffsetWire::PerformWithBiLo
// MapNodeVertex,VE); // MapNodeVertex,VE);
} }
if (myJoinType == GeomAbs_Intersection)
StartOnEdge = EndOnEdge = 0;
//--------------------------------------------- //---------------------------------------------
// Construction of geometries. // Construction of geometries.
//--------------------------------------------- //---------------------------------------------
@ -912,7 +915,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
// Construction of vertices on edges parallel to the spine. // Construction of vertices on edges parallel to the spine.
//----------------------------------------------------------- //-----------------------------------------------------------
Trim.IntersectWith(E [0], E [1], Params); Trim.IntersectWith(E [0], E [1], myJoinType, Params);
for (Standard_Integer s = 1; s <= Params.Length(); s++) { for (Standard_Integer s = 1; s <= Params.Length(); s++) {
TopoDS_Vertex VC; TopoDS_Vertex VC;

View File

@ -26,7 +26,8 @@ uses
Curve from Geom2d, Curve from Geom2d,
Geometry from Geom2d, Geometry from Geom2d,
SequenceOfPnt from TColgp, SequenceOfPnt from TColgp,
Curve from Geom2dAdaptor Curve from Geom2dAdaptor,
JoinType from GeomAbs
is is
Create Create
@ -39,6 +40,7 @@ is
IntersectWith( me : in out; IntersectWith( me : in out;
Edge1 , Edge2 : Edge from TopoDS; Edge1 , Edge2 : Edge from TopoDS;
theJoinType : JoinType from GeomAbs;
Params : in out SequenceOfPnt from TColgp) Params : in out SequenceOfPnt from TColgp)
is static; is static;

View File

@ -303,8 +303,9 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
//======================================================================= //=======================================================================
void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2, const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params) const GeomAbs_JoinType theJoinType,
TColgp_SequenceOfPnt& Params)
{ {
Params.Clear(); Params.Clear();
@ -553,6 +554,23 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
Points2.Remove(Params.Length()+1, Points2.Length()); Points2.Remove(Params.Length()+1, Points2.Length());
} }
NbPoints = Params.Length();
if (NbPoints > 0 && theJoinType == GeomAbs_Intersection)
{
//Remove all vertices with non-minimal parameter
Standard_Integer imin = 1;
for (i = 2; i <= NbPoints; i++)
if (Params(i).X() < Params(imin).X())
imin = i;
gp_Pnt Pnt1 = Params(imin);
gp_Pnt Pnt2 = Points2(imin);
Params.Clear();
Points2.Clear();
Params.Append(Pnt1);
Points2.Append(Pnt2);
}
NbPoints = Params.Length(); NbPoints = Params.Length();
for ( i = 1; i <= NbPoints; i++) { for ( i = 1; i <= NbPoints; i++) {
PSeq = Params(i); PSeq = Params(i);

View File

@ -45,20 +45,22 @@ uses
Point from Geom2d , Point from Geom2d ,
Pnt2d from gp , Pnt2d from gp ,
Vec2d from gp , Vec2d from gp ,
Integer from Standard Integer from Standard,
JoinType from GeomAbs
is is
Create returns Bisec from Bisector; Create returns Bisec from Bisector;
Perform(me : in out ; Perform(me : in out ;
Cu1 : Curve from Geom2d ; Cu1 : Curve from Geom2d ;
Cu2 : Curve from Geom2d ; Cu2 : Curve from Geom2d ;
P : Pnt2d from gp ; P : Pnt2d from gp ;
V1 : Vec2d from gp ; V1 : Vec2d from gp ;
V2 : Vec2d from gp ; V2 : Vec2d from gp ;
Sense : Real from Standard ; Sense : Real from Standard ;
Tolerance : Real from Standard ; ajointype : JoinType from GeomAbs ;
oncurve : Boolean from Standard = Standard_True ); Tolerance : Real from Standard ;
oncurve : Boolean from Standard = Standard_True );
--- Purpose : Performs the bisecting line between the curves --- Purpose : Performs the bisecting line between the curves
-- <Cu1> and <Cu2>. -- <Cu1> and <Cu2>.

View File

@ -73,13 +73,14 @@ Bisector_Bisec::Bisector_Bisec()
//=========================================================================== //===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve , void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Curve)& asecondcurve , const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint , const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector , const gp_Vec2d& asecondvector ,
const Standard_Real adirection , const Standard_Real adirection ,
const Standard_Real tolerance , const GeomAbs_JoinType ajointype ,
const Standard_Boolean oncurve ) const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{ {
Handle(Standard_Type) Type1 = afirstcurve ->DynamicType(); Handle(Standard_Type) Type1 = afirstcurve ->DynamicType();
Handle(Standard_Type) Type2 = asecondcurve->DynamicType(); Handle(Standard_Type) Type2 = asecondcurve->DynamicType();
@ -149,18 +150,19 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//------------------------------------------------------------------ //------------------------------------------------------------------
// Analytic Bissectrice. // Analytic Bissectrice.
//------------------------------------------------------------------ //------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna(); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve1 , BisAna->Perform(afirstcurve1 ,
asecondcurve1 , asecondcurve1 ,
apoint , apoint ,
afirstvector , afirstvector ,
asecondvector , asecondvector ,
adirection , adirection ,
tolerance , ajointype ,
oncurve ); tolerance ,
UFirst = BisAna->ParameterOfStartPoint(); oncurve );
ULast = BisAna->ParameterOfEndPoint(); UFirst = BisAna->ParameterOfStartPoint();
Bis = BisAna; ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
} }
else { else {
Standard_Boolean IsLine = Standard_False; Standard_Boolean IsLine = Standard_False;

View File

@ -27,6 +27,7 @@ inherits
uses uses
Shape from GeomAbs, Shape from GeomAbs,
CurveType from GeomAbs, CurveType from GeomAbs,
JoinType from GeomAbs,
Curve from Geom2d, Curve from Geom2d,
Geometry from Geom2d, Geometry from Geom2d,
TrimmedCurve from Geom2d, TrimmedCurve from Geom2d,
@ -43,14 +44,15 @@ is
Create returns BisecAna; Create returns BisecAna;
Perform(me : mutable ; Perform(me : mutable ;
Cu1 : Curve from Geom2d ; Cu1 : Curve from Geom2d ;
Cu2 : Curve from Geom2d ; Cu2 : Curve from Geom2d ;
P : Pnt2d from gp ; P : Pnt2d from gp ;
V1 : Vec2d from gp ; V1 : Vec2d from gp ;
V2 : Vec2d from gp ; V2 : Vec2d from gp ;
Sense : Real from Standard ; Sense : Real from Standard ;
Tolerance : Real from Standard ; jointype : JoinType from GeomAbs ;
oncurve : Boolean from Standard = Standard_True ); Tolerance : Real from Standard ;
oncurve : Boolean from Standard = Standard_True );
--- Purpose : Performs the bisecting line between the curves --- Purpose : Performs the bisecting line between the curves
-- <Cu1> and <Cu2>. -- <Cu1> and <Cu2>.
@ -125,7 +127,8 @@ is
Sense : Real from Standard ; Sense : Real from Standard ;
U : out Real from Standard ; U : out Real from Standard ;
sense : out Boolean from Standard ; sense : out Boolean from Standard ;
ok : out Boolean from Standard ) ok : out Boolean from Standard ;
IsBisecOfTwoLines : Boolean from Standard = Standard_False)
--- Purpose : Returns the distance between the point <P> and --- Purpose : Returns the distance between the point <P> and
-- the bisecting <Bis>. -- the bisecting <Bis>.

View File

@ -76,7 +76,8 @@ Standard_Real Bisector_BisecAna::Distance (
const Standard_Real adirection, const Standard_Real adirection,
Standard_Real& aparameter, Standard_Real& aparameter,
Standard_Boolean& asense, Standard_Boolean& asense,
Standard_Boolean& astatus) Standard_Boolean& astatus,
Standard_Boolean IsBisecOfTwoLines)
{ {
astatus = Standard_True; astatus = Standard_True;
@ -153,30 +154,36 @@ Standard_Real Bisector_BisecAna::Distance (
else { else {
asense = Standard_True; asense = Standard_True;
// Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 Begin if (!IsBisecOfTwoLines)
// Replacement of -1.E-8 for a tolerance 1.e-4 {
Standard_Real aTol = 1.e-4; // Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 Begin
// Replacement of -1.E-8 for a tolerance 1.e-4
if ((afirstdir^secdirrev)*adirection < -0.1) { // input Standard_Real aTol = 1.e-4;
if((afirstdir^tangdir)*adirection < aTol &&
(secdirrev^tangdir)*adirection < aTol) asense = Standard_False; if ((afirstdir^secdirrev)*adirection < -0.1) { // input
} if((afirstdir^tangdir)*adirection < aTol &&
else if((afirstdir^secdirrev)*adirection > 0.1) { // output (secdirrev^tangdir)*adirection < aTol)
if((afirstdir^tangdir)*adirection < aTol || asense = Standard_False;
(secdirrev^tangdir)*adirection < aTol) asense = Standard_False;
}
else { // flat
if (afirstdir.Dot(secdirrev) > 0.) { // tangent
if ((afirstdir^tangdir)*adirection < 0.) asense = Standard_False;
} }
else{ // turn back else if((afirstdir^secdirrev)*adirection > 0.1) { // output
// Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002 if((afirstdir^tangdir)*adirection < aTol ||
// if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = Standard_False; (secdirrev^tangdir)*adirection < aTol)
if (afirstdir.Dot(tangdir) < 0.) asense = Standard_False; asense = Standard_False;
// Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
} }
else { // flat
if (afirstdir.Dot(secdirrev) > 0.) { // tangent
if ((afirstdir^tangdir)*adirection < 0.)
asense = Standard_False;
}
else{ // turn back
// Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002
// if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = Standard_False;
if (afirstdir.Dot(tangdir) < 0.) asense = Standard_False;
// Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
}
}
// Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
} }
// Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
} }
return distance; return distance;
} }
@ -198,6 +205,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector , const gp_Vec2d& asecondvector ,
const Standard_Real adirection , const Standard_Real adirection ,
const GeomAbs_JoinType ajointype ,
const Standard_Real tolerance , const Standard_Real tolerance ,
const Standard_Boolean oncurve ) const Standard_Boolean oncurve )
{ {
@ -625,14 +633,26 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
} }
else if (type == GccInt_Par) { else if (type == GccInt_Par) {
bisectorcurve = new Geom2d_Parabola(TheSol->Parabola()); bisectorcurve = new Geom2d_Parabola(TheSol->Parabola());
Standard_Real FocalLength = ((Handle(Geom2d_Parabola)&)bisectorcurve)->Focal();
Standard_Real secondparameter = Precision::Infinite();
if (!thesense) if (!thesense)
{
if (ajointype == GeomAbs_Intersection &&
4.*FocalLength < firstparameter) //first parameter is too far from peak of parabola
secondparameter = 0.;
thebisector = new Geom2d_TrimmedCurve(bisectorcurve, thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
firstparameter, firstparameter,
- Precision::Infinite()); -secondparameter);
}
else else
{
if (ajointype == GeomAbs_Intersection &&
firstparameter < -4.*FocalLength) //first parameter is too far from peak of parabola
secondparameter = 0.;
thebisector = new Geom2d_TrimmedCurve(bisectorcurve, thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
firstparameter, firstparameter,
Precision::Infinite()); secondparameter);
}
} }
} }
} }
@ -714,7 +734,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
else else
distanceptsol = Distance(apoint,solution, distanceptsol = Distance(apoint,solution,
afirstvector,asecondvector, afirstvector,asecondvector,
adirection,parameter,sense,ok); adirection,parameter,sense,ok, Standard_True);
// Modified by skv - Tue Feb 15 17:51:29 2005 Integration End // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
if (ok || !oncurve) { if (ok || !oncurve) {
thesense = sense; thesense = sense;

View File

@ -351,12 +351,12 @@ void MAT2d_Tool2d::CreateBisector(const Handle(MAT_Bisector)& abisector)
#endif #endif
if(type1 != STANDARD_TYPE(Geom2d_CartesianPoint) && if(type1 != STANDARD_TYPE(Geom2d_CartesianPoint) &&
type2 != STANDARD_TYPE(Geom2d_CartesianPoint)) { type2 != STANDARD_TYPE(Geom2d_CartesianPoint)) {
bisector.Perform(item1,item2, bisector.Perform(item1,item2,
GeomPnt (abisector->IssuePoint()), GeomPnt (abisector->IssuePoint()),
GeomVec (abisector->FirstVector()), GeomVec (abisector->FirstVector()),
GeomVec (abisector->SecondVector()), GeomVec (abisector->SecondVector()),
theDirection,tolerance,ontheline); theDirection,theJoinType,tolerance,ontheline);
} }
else if(type1 == STANDARD_TYPE(Geom2d_CartesianPoint) && else if(type1 == STANDARD_TYPE(Geom2d_CartesianPoint) &&
type2 == STANDARD_TYPE(Geom2d_CartesianPoint)) { type2 == STANDARD_TYPE(Geom2d_CartesianPoint)) {
@ -721,10 +721,20 @@ Standard_Boolean MAT2d_Tool2d::IsSameDistance (
Standard_Real EpsDist = MAT2d_TOLCONF*300. ; Standard_Real EpsDist = MAT2d_TOLCONF*300. ;
Distance = Dist(1); Distance = Dist(1);
for (Standard_Integer i = 1; i <= 4; i++){
if (theJoinType == GeomAbs_Intersection && if (theJoinType == GeomAbs_Intersection &&
Precision::IsInfinite(Dist(i))) Precision::IsInfinite(Distance))
continue; {
for (Standard_Integer i = 2; i <= 4; i++)
if (!Precision::IsInfinite(Dist(i)))
{
Distance = Dist(i);
break;
}
}
for (Standard_Integer i = 1; i <= 4; i++){
if (theJoinType == GeomAbs_Intersection &&
Precision::IsInfinite(Dist(i)))
continue;
if (Abs(Dist(i) - Distance) > EpsDist) { if (Abs(Dist(i) - Distance) > EpsDist) {
Distance = Precision::Infinite(); Distance = Precision::Infinite();
return Standard_False; return Standard_False;
@ -1168,7 +1178,7 @@ void MAT2d_Tool2d::BisecFusion(const Standard_Integer I1,
Handle(Bisector_BisecCC) BCC1 = Handle(Bisector_BisecCC)::DownCast(Bisector1->BasisCurve()); Handle(Bisector_BisecCC) BCC1 = Handle(Bisector_BisecCC)::DownCast(Bisector1->BasisCurve());
Bis.Perform(BCC1->Curve(2), BCC1->Curve(1), P2, VBid, VBid, Bis.Perform(BCC1->Curve(2), BCC1->Curve(1), P2, VBid, VBid,
theDirection, Tolerance, Standard_False); theDirection, theJoinType, Tolerance, Standard_False);
Bisector1 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis.Value()); Bisector1 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis.Value());
BCC1 = Handle(Bisector_BisecCC) ::DownCast(Bisector1->BasisCurve()); BCC1 = Handle(Bisector_BisecCC) ::DownCast(Bisector1->BasisCurve());

View File

@ -17,7 +17,7 @@ if [catch { mkoffset resoffset pp 1 -1. i } ] {
} else { } else {
renamevar resoffset_1 result renamevar resoffset_1 result
set length 42 set length 39.5
set nb_v_good 6 set nb_v_good 6
set nb_e_good 7 set nb_e_good 7

View File

@ -0,0 +1,13 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_wrong2.brep] a
openoffset res a 1 -5. i
fit
set only_screen_axo 1

View File

@ -0,0 +1,13 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_newOffset_1.brep] a
openoffset res a 1 -0.6 i
fit
set only_screen_axo 1

View File

@ -0,0 +1,13 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_v6_Arcs.brep] a
mkoffset res a 1 -5. i
fit
set only_screen_axo 1

View File

@ -0,0 +1,14 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_wrong1.brep] a
mkoffset res_1 a 1 -5. i
mkoffset res_2 a 1 5. i
fit
set only_screen_axo 1

View File

@ -0,0 +1,13 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_offsetcircles.brep] a
mkoffset res a 2 -2. i
fit
set only_screen_axo 1

View File

@ -0,0 +1,13 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_linesSet.brep] a
openoffset res a 10 2. i
fit
set only_screen_axo 1

View File

@ -0,0 +1,14 @@
puts "========"
puts "OCC26185"
puts "========"
puts ""
##################################################################
# BRepOffsetAPI_MakeOffset: regressions on some customer's cases
##################################################################
smallview
restore [locate_data_file OCC26185_v6_LineArc.brep] a
mkoffset res_1 a 1 -5. i
mkoffset res_2 a 1 5. i
fit
set only_screen_axo 1