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

0023360: Test cases for command mkoffset produce different results on different versions of OCCT

1. Function QuasiFleche(...) does not call for small edges.
2. Forbid to work with NULL-shapes in OffsetWire::FixHoles(...) function.
3. ProjOnCurve(...) function in Bisector_BisecCC.cxx file returns status (DONE or NOT DONE).
This commit is contained in:
nbv 2013-10-03 14:30:18 +04:00 committed by bugmaster
parent 3cb77da46e
commit 91bb31f35e
9 changed files with 478 additions and 423 deletions

View File

@ -500,10 +500,11 @@ GeomAbs_JoinType BRepFill_OffsetWire::JoinType() const
void BRepFill_OffsetWire::Perform (const Standard_Real Offset, void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
const Standard_Real Alt) const Standard_Real Alt)
{ {
// Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 Begin // Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 Begin
try { try
{
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
myCallGen = Standard_False; myCallGen = Standard_False;
if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return; if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return;
TopoDS_Face oldWorkSpain = myWorkSpine; TopoDS_Face oldWorkSpain = myWorkSpine;
@ -511,7 +512,8 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
TopTools_ListOfShape BadEdges; TopTools_ListOfShape BadEdges;
CheckBadEdges(myWorkSpine,Offset,myBilo,myLink,BadEdges); CheckBadEdges(myWorkSpine,Offset,myBilo,myLink,BadEdges);
if(!BadEdges.IsEmpty()) { if(!BadEdges.IsEmpty())
{
// Modification of myWorkSpine; // Modification of myWorkSpine;
//cout << "Modification of myWorkSpine : " << BadEdges.Extent() << endl; //cout << "Modification of myWorkSpine : " << BadEdges.Extent() << endl;
BRepTools_Substitution aSubst; BRepTools_Substitution aSubst;
@ -522,117 +524,120 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
TColgp_SequenceOfPnt Points; TColgp_SequenceOfPnt Points;
for(; it.More(); it.Next()) { for(; it.More(); it.Next()) {
aL.Clear(); aL.Clear();
Parameters.Clear(); Parameters.Clear();
Points.Clear(); Points.Clear();
const TopoDS_Shape& anE = it.Value(); const TopoDS_Shape& anE = it.Value();
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(anE), Vf, Vl);
Standard_Real f, l; TopoDS_Vertex Vf, Vl;
Handle(Geom_Curve) G3d = BRep_Tool::Curve(TopoDS::Edge(anE),f,l); TopExp::Vertices(TopoDS::Edge(anE), Vf, Vl);
GeomAdaptor_Curve AC(G3d,f,l);
PerformCurve(Parameters, Points, AC, aDefl, f, Standard_Real f, l;
l, Precision::Confusion(), 2); Handle(Geom_Curve) G3d = BRep_Tool::Curve(TopoDS::Edge(anE),f,l);
GeomAdaptor_Curve AC(G3d,f,l);
Standard_Integer NPnts = Points.Length(); PerformCurve(Parameters, Points, AC, aDefl, f,
if(NPnts > 2) { l, Precision::Confusion(), 2);
//cout << NPnts << " points " << endl;
TopoDS_Vertex FV = Vf; Standard_Integer NPnts = Points.Length();
TopoDS_Vertex LV; if(NPnts > 2)
TopoDS_Edge newE; {
Standard_Integer np; //cout << NPnts << " points " << endl;
for(np = 2; np < NPnts; np++) { TopoDS_Vertex FV = Vf;
gp_Pnt LP = Points(np); TopoDS_Vertex LV;
LV = BRepLib_MakeVertex(LP); TopoDS_Edge newE;
newE = BRepLib_MakeEdge(FV, LV); Standard_Integer np;
aL.Append(newE); for(np = 2; np < NPnts; np++) {
FV = LV; gp_Pnt LP = Points(np);
} LV = BRepLib_MakeVertex(LP);
LV = Vl; newE = BRepLib_MakeEdge(FV, LV);
newE = BRepLib_MakeEdge(FV, LV); aL.Append(newE);
aL.Append(newE); FV = LV;
} }
else { LV = Vl;
//cout << " 2 points " << endl; newE = BRepLib_MakeEdge(FV, LV);
TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl); aL.Append(newE);
aL.Append(newE); }
} else
//Update myMapSpine {
if (myMapSpine.IsBound( anE )) //cout << " 2 points " << endl;
{ TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl);
TopTools_ListIteratorOfListOfShape newit( aL ); aL.Append(newE);
for (; newit.More(); newit.Next()) }
{ //Update myMapSpine
TopoDS_Edge NewEdge = TopoDS::Edge( newit.Value() ); if (myMapSpine.IsBound( anE ))
myMapSpine.Bind( NewEdge, myMapSpine(anE) ); {
TopoDS_Vertex NewV1, NewV2; TopTools_ListIteratorOfListOfShape newit( aL );
EdgeVertices( NewEdge, NewV1, NewV2 ); for (; newit.More(); newit.Next())
if (!myMapSpine.IsBound(NewV1)) myMapSpine.Bind( NewV1, myMapSpine(anE) ); {
if (!myMapSpine.IsBound(NewV2)) myMapSpine.Bind( NewV2, myMapSpine(anE) ); TopoDS_Edge NewEdge = TopoDS::Edge( newit.Value() );
} myMapSpine.Bind( NewEdge, myMapSpine(anE) );
myMapSpine.UnBind( anE ); TopoDS_Vertex NewV1, NewV2;
} EdgeVertices( NewEdge, NewV1, NewV2 );
/////////////////// if (!myMapSpine.IsBound(NewV1)) myMapSpine.Bind( NewV1, myMapSpine(anE) );
aSubst.Substitute(anE, aL); if (!myMapSpine.IsBound(NewV2)) myMapSpine.Bind( NewV2, myMapSpine(anE) );
}
myMapSpine.UnBind( anE );
}
///////////////////
aSubst.Substitute(anE, aL);
} }
TopTools_DataMapOfShapeListOfShape wwmap; TopTools_DataMapOfShapeListOfShape wwmap;
TopoDS_Iterator itws( myWorkSpine ); TopoDS_Iterator itws( myWorkSpine );
for (; itws.More(); itws.Next()) for (; itws.More(); itws.Next())
{ {
TopoDS_Shape aWire = itws.Value(); TopoDS_Shape aWire = itws.Value();
aSubst.Build( aWire ); aSubst.Build( aWire );
if (aSubst.IsCopied(aWire)) if (aSubst.IsCopied(aWire))
{ {
TopoDS_Wire NewWire = TopoDS::Wire( aSubst.Copy(aWire).First() ); TopoDS_Wire NewWire = TopoDS::Wire( aSubst.Copy(aWire).First() );
NewWire.Closed( aWire.Closed() ); NewWire.Closed( aWire.Closed() );
TopTools_ListOfShape Lw; TopTools_ListOfShape Lw;
Lw.Append( NewWire ); Lw.Append( NewWire );
wwmap.Bind( aWire, Lw ); wwmap.Bind( aWire, Lw );
} }
} }
aSubst.Clear(); aSubst.Clear();
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap( wwmap ); TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap( wwmap );
for (; itmap.More(); itmap.Next()) for (; itmap.More(); itmap.Next())
aSubst.Substitute( itmap.Key(), itmap.Value() ); aSubst.Substitute( itmap.Key(), itmap.Value() );
aSubst.Build(myWorkSpine); aSubst.Build(myWorkSpine);
if(aSubst.IsCopied(myWorkSpine)) { if(aSubst.IsCopied(myWorkSpine)) {
myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First()); myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First());
//sprintf(name,"WS1"); //sprintf(name,"WS1");
//DBRep::Set(name,myWorkSpine); //DBRep::Set(name,myWorkSpine);
BRepMAT2d_Explorer newExp; BRepMAT2d_Explorer newExp;
newExp.Perform(myWorkSpine); newExp.Perform(myWorkSpine);
BRepMAT2d_BisectingLocus newBilo; BRepMAT2d_BisectingLocus newBilo;
BRepMAT2d_LinkTopoBilo newLink; BRepMAT2d_LinkTopoBilo newLink;
newBilo.Compute(newExp,1,MAT_Left); newBilo.Compute(newExp,1,MAT_Left);
if(!newBilo.IsDone()) if(!newBilo.IsDone())
{ {
myShape.Nullify(); myShape.Nullify();
myIsDone = Standard_False; myIsDone = Standard_False;
return; return;
} }
newLink.Perform(newExp,newBilo); newLink.Perform(newExp,newBilo);
PerformWithBiLo(myWorkSpine,Offset,newBilo,newLink,myJoinType,Alt); PerformWithBiLo(myWorkSpine,Offset,newBilo,newLink,myJoinType,Alt);
myWorkSpine = oldWorkSpain;
myWorkSpine = oldWorkSpain;
} }
else { else {
PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt); PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
} }
} }
else { else
{
PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt); PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
} }
} }
catch (...)//Every exception was caught. catch (...)//Every exception was caught.
{ {
myShape.Nullify(); myShape.Nullify();
myIsDone = Standard_False; myIsDone = Standard_False;
cout<<"An exception was caught in BRepFill_OffsetWire::Perform : "; cout<<"An exception was caught in BRepFill_OffsetWire::Perform : ";
@ -642,8 +647,8 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
return; return;
} }
// Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 End // Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 End
// Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin // Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin
TopExp_Explorer anExp(myShape, TopAbs_WIRE); TopExp_Explorer anExp(myShape, TopAbs_WIRE);
for (; anExp.More(); anExp.Next()) { for (; anExp.More(); anExp.Next()) {
@ -655,7 +660,7 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
Standard_ConstructionError::Raise("Offset wire is not closed."); Standard_ConstructionError::Raise("Offset wire is not closed.");
} }
} }
// Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End // Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End
} }
//======================================================================= //=======================================================================
@ -734,7 +739,8 @@ void BRepFill_OffsetWire::PerformWithBiLo
//******************************** //********************************
// Calculate for a non null offset // Calculate for a non null offset
//******************************** //********************************
if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return; if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone))
return;
BRep_Builder myBuilder; BRep_Builder myBuilder;
myBuilder.MakeCompound(TopoDS::Compound(myShape)); myBuilder.MakeCompound(TopoDS::Compound(myShape));
@ -1359,262 +1365,266 @@ void BRepFill_OffsetWire::FixHoles()
TopExp_Explorer Explo( mySpine, TopAbs_VERTEX ); TopExp_Explorer Explo( mySpine, TopAbs_VERTEX );
for (; Explo.More(); Explo.Next()) for (; Explo.More(); Explo.Next())
{ {
const TopoDS_Vertex& aVertex = TopoDS::Vertex( Explo.Current() ); const TopoDS_Vertex& aVertex = TopoDS::Vertex( Explo.Current() );
Standard_Real Tol = BRep_Tool::Tolerance(aVertex); Standard_Real Tol = BRep_Tool::Tolerance(aVertex);
if (Tol > MaxTol) if (Tol > MaxTol)
MaxTol = Tol; MaxTol = Tol;
} }
MaxTol *= 100.; MaxTol *= 100.;
Explo.Init( myShape, TopAbs_WIRE ); Explo.Init( myShape, TopAbs_WIRE );
for (; Explo.More(); Explo.Next()) for (; Explo.More(); Explo.Next())
{
TopoDS_Shape aWire = Explo.Current();
// Remove duplicated edges
TopTools_DataMapOfShapeListOfShape EEmap;
TopoDS_Iterator it( aWire );
for (; it.More(); it.Next())
{ {
TopoDS_Shape aWire = Explo.Current(); const TopoDS_Shape& anEdge = it.Value();
// Remove duplicated edges if (! EEmap.IsBound( anEdge ))
TopTools_DataMapOfShapeListOfShape EEmap; {
TopoDS_Iterator it( aWire ); TopTools_ListOfShape LE;
for (; it.More(); it.Next()) EEmap.Bind( anEdge, LE );
{ }
const TopoDS_Shape& anEdge = it.Value();
if (! EEmap.IsBound( anEdge ))
{
TopTools_ListOfShape LE;
EEmap.Bind( anEdge, LE );
}
else
EEmap(anEdge).Append( anEdge );
}
aWire.Free( Standard_True );
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape mapit( EEmap );
for (; mapit.More(); mapit.Next())
{
const TopTools_ListOfShape& LE = mapit.Value();
TopTools_ListIteratorOfListOfShape itl( LE );
for (; itl.More(); itl.Next())
BB.Remove( aWire, itl.Value() );
}
// Sorting
if (aWire.Closed())
ClosedWires.Append( aWire );
else else
UnclosedWires.Append( aWire ); EEmap(anEdge).Append( anEdge );
} }
aWire.Free( Standard_True );
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape mapit( EEmap );
for (; mapit.More(); mapit.Next())
{
const TopTools_ListOfShape& LE = mapit.Value();
TopTools_ListIteratorOfListOfShape itl( LE );
for (; itl.More(); itl.Next())
BB.Remove( aWire, itl.Value() );
}
// Sorting
if (aWire.Closed())
ClosedWires.Append( aWire );
else
UnclosedWires.Append( aWire );
}
while (!UnclosedWires.IsEmpty()) while (!UnclosedWires.IsEmpty())
{
TopoDS_Wire& Base = TopoDS::Wire( UnclosedWires(1) );
TopoDS_Vertex Vf, Vl;
TopExp::Vertices( Base, Vf, Vl );
if(Vf.IsNull() || Vl.IsNull())
Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
gp_Pnt Pf, Pl;
Pf = BRep_Tool::Pnt(Vf);
Pl = BRep_Tool::Pnt(Vl);
Standard_Real DistF = RealLast(), DistL = RealLast();
Standard_Integer IndexF = 1, IndexL = 1;
Standard_Boolean IsFirstF = Standard_False, IsFirstL = Standard_False;
for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++)
{ {
TopoDS_Wire& Base = TopoDS::Wire( UnclosedWires(1) ); TopoDS_Wire aWire = TopoDS::Wire( UnclosedWires(i) );
TopoDS_Vertex Vf, Vl; TopoDS_Vertex V1, V2;
TopExp::Vertices( Base, Vf, Vl ); TopExp::Vertices( aWire, V1, V2 );
if(Vf.IsNull() || Vl.IsNull())
if(V1.IsNull() || V2.IsNull())
Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire."); Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
gp_Pnt Pf, Pl;
gp_Pnt P1, P2;
P1 = BRep_Tool::Pnt(V1);
P2 = BRep_Tool::Pnt(V2);
Standard_Real dist = Pf.Distance( P1 );
if (dist < DistF)
{
DistF = dist;
IndexF = i;
IsFirstF = Standard_True;
}
dist = Pf.Distance( P2 );
if (dist < DistF)
{
DistF = dist;
IndexF = i;
IsFirstF = Standard_False;
}
dist = Pl.Distance( P1 );
if (dist < DistL)
{
DistL = dist;
IndexL = i;
IsFirstL = Standard_True;
}
dist = Pl.Distance( P2 );
if (dist < DistL)
{
DistL = dist;
IndexL = i;
IsFirstL = Standard_False;
}
}
TopoDS_Wire theWire;
TopoDS_Edge theEdge;
TopoDS_Vertex theVertex;
Standard_Real CommonTol;
Standard_Boolean TryToClose = Standard_True;
if (DistF <= MaxTol && DistL <= MaxTol && IndexF == IndexL && IsFirstF == IsFirstL)
{
if (DistF < DistL)
{
DistL = RealLast();
IndexL++;
}
else
{
DistF = RealLast();
IndexF++;
}
TryToClose = Standard_False;
}
if (DistF <= MaxTol)
{
theWire = TopoDS::Wire( UnclosedWires(IndexF) );
TopoDS_Vertex V1, V2;
TopExp::Vertices( theWire, V1, V2 );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
theEdge = (IsFirstF)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
TopoDS_Iterator it( theWire );
for (; it.More(); it.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
if (IsFirstF) anEdge.Reverse();
if (!anEdge.IsSame( theEdge ))
BB.Add( Base, anEdge );
}
theVertex = (IsFirstF)? V1 : V2;
CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex) );
if (DistF <= CommonTol)
{
theEdge.Free( Standard_True );
Vf.Orientation( theVertex.Orientation() );
BB.Remove( theEdge, theVertex );
BB.Add( theEdge, Vf );
BB.UpdateVertex( Vf, CommonTol );
if (IsFirstF) theEdge.Reverse();
BB.Add( Base, theEdge );
}
else
{
if (IsFirstF) theEdge.Reverse();
BB.Add( Base, theEdge );
// Creating new edge from theVertex to Vf
TopoDS_Edge NewEdge = BRepLib_MakeEdge( theVertex, Vf );
BB.Add( Base, NewEdge );
}
}
if (DistL <= MaxTol && IndexL != IndexF)
{
theWire = TopoDS::Wire( UnclosedWires(IndexL) );
TopoDS_Vertex V1, V2;
TopExp::Vertices( theWire, V1, V2 );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
theEdge = (IsFirstL)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
TopoDS_Iterator it( theWire );
for (; it.More(); it.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
if (!IsFirstL) anEdge.Reverse();
if (!anEdge.IsSame( theEdge ))
BB.Add( Base, anEdge );
}
theVertex = (IsFirstL)? V1 : V2;
CommonTol = Max( BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex) );
if (DistL <= CommonTol)
{
theEdge.Free( Standard_True );
Vl.Orientation( theVertex.Orientation() );
BB.Remove( theEdge, theVertex );
BB.Add( theEdge, Vl );
BB.UpdateVertex( Vl, CommonTol );
if (!IsFirstL) theEdge.Reverse();
BB.Add( Base, theEdge );
}
else
{
if (!IsFirstL) theEdge.Reverse();
BB.Add( Base, theEdge );
// Creating new edge from Vl to theVertex
TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vl, theVertex );
BB.Add( Base, NewEdge );
}
}
// Check if it is possible to close resulting wire
if (TryToClose)
{
TopExp::Vertices( Base, Vf, Vl );
CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(Vl) );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( Base, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
TopoDS_Edge Efirst, Elast;
Efirst = TopoDS::Edge(VEmap.FindFromKey( Vf ).First());
Elast = TopoDS::Edge(VEmap.FindFromKey( Vl ).First());
Pf = BRep_Tool::Pnt(Vf); Pf = BRep_Tool::Pnt(Vf);
Pl = BRep_Tool::Pnt(Vl); Pl = BRep_Tool::Pnt(Vl);
Standard_Real DistF = RealLast(), DistL = RealLast(); Standard_Real Dist = Pf.Distance(Pl);
Standard_Integer IndexF = 1, IndexL = 1; if (Dist <= CommonTol)
Standard_Boolean IsFirstF = Standard_False, IsFirstL = Standard_False; {
for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++) Elast.Free( Standard_True );
{ Vf.Orientation( Vl.Orientation() );
TopoDS_Wire aWire = TopoDS::Wire( UnclosedWires(i) ); BB.Remove( Elast, Vl );
TopoDS_Vertex V1, V2; BB.Add( Elast, Vf );
TopExp::Vertices( aWire, V1, V2 ); BB.UpdateVertex( Vf, CommonTol );
gp_Pnt P1, P2; Base.Closed( Standard_True );
P1 = BRep_Tool::Pnt(V1); }
P2 = BRep_Tool::Pnt(V2); else if (Dist <= MaxTol)
Standard_Real dist = Pf.Distance( P1 ); {
if (dist < DistF) // Creating new edge from Vl to Vf
{ TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vf, Vl );
DistF = dist; BB.Add( Base, NewEdge );
IndexF = i; Base.Closed( Standard_True );
IsFirstF = Standard_True; }
}
dist = Pf.Distance( P2 );
if (dist < DistF)
{
DistF = dist;
IndexF = i;
IsFirstF = Standard_False;
}
dist = Pl.Distance( P1 );
if (dist < DistL)
{
DistL = dist;
IndexL = i;
IsFirstL = Standard_True;
}
dist = Pl.Distance( P2 );
if (dist < DistL)
{
DistL = dist;
IndexL = i;
IsFirstL = Standard_False;
}
}
TopoDS_Wire theWire;
TopoDS_Edge theEdge;
TopoDS_Vertex theVertex;
Standard_Real CommonTol;
Standard_Boolean TryToClose = Standard_True;
if (DistF <= MaxTol && DistL <= MaxTol && IndexF == IndexL && IsFirstF == IsFirstL)
{
if (DistF < DistL)
{
DistL = RealLast();
IndexL++;
}
else
{
DistF = RealLast();
IndexF++;
}
TryToClose = Standard_False;
}
if (DistF <= MaxTol)
{
theWire = TopoDS::Wire( UnclosedWires(IndexF) );
TopoDS_Vertex V1, V2;
TopExp::Vertices( theWire, V1, V2 );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
theEdge = (IsFirstF)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
TopoDS_Iterator it( theWire );
for (; it.More(); it.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
if (IsFirstF) anEdge.Reverse();
if (!anEdge.IsSame( theEdge ))
BB.Add( Base, anEdge );
}
theVertex = (IsFirstF)? V1 : V2;
CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex) );
if (DistF <= CommonTol)
{
theEdge.Free( Standard_True );
Vf.Orientation( theVertex.Orientation() );
BB.Remove( theEdge, theVertex );
BB.Add( theEdge, Vf );
BB.UpdateVertex( Vf, CommonTol );
if (IsFirstF) theEdge.Reverse();
BB.Add( Base, theEdge );
}
else
{
if (IsFirstF) theEdge.Reverse();
BB.Add( Base, theEdge );
// Creating new edge from theVertex to Vf
TopoDS_Edge NewEdge = BRepLib_MakeEdge( theVertex, Vf );
BB.Add( Base, NewEdge );
}
}
if (DistL <= MaxTol && IndexL != IndexF)
{
theWire = TopoDS::Wire( UnclosedWires(IndexL) );
TopoDS_Vertex V1, V2;
TopExp::Vertices( theWire, V1, V2 );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
theEdge = (IsFirstL)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
TopoDS_Iterator it( theWire );
for (; it.More(); it.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
if (!IsFirstL) anEdge.Reverse();
if (!anEdge.IsSame( theEdge ))
BB.Add( Base, anEdge );
}
theVertex = (IsFirstL)? V1 : V2;
CommonTol = Max( BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex) );
if (DistL <= CommonTol)
{
theEdge.Free( Standard_True );
Vl.Orientation( theVertex.Orientation() );
BB.Remove( theEdge, theVertex );
BB.Add( theEdge, Vl );
BB.UpdateVertex( Vl, CommonTol );
if (!IsFirstL) theEdge.Reverse();
BB.Add( Base, theEdge );
}
else
{
if (!IsFirstL) theEdge.Reverse();
BB.Add( Base, theEdge );
// Creating new edge from Vl to theVertex
TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vl, theVertex );
BB.Add( Base, NewEdge );
}
}
// Check if it is possible to close resulting wire
if (TryToClose)
{
TopExp::Vertices( Base, Vf, Vl );
CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(Vl) );
TopTools_IndexedDataMapOfShapeListOfShape VEmap;
TopExp::MapShapesAndAncestors( Base, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
TopoDS_Edge Efirst, Elast;
Efirst = TopoDS::Edge(VEmap.FindFromKey( Vf ).First());
Elast = TopoDS::Edge(VEmap.FindFromKey( Vl ).First());
Pf = BRep_Tool::Pnt(Vf);
Pl = BRep_Tool::Pnt(Vl);
Standard_Real Dist = Pf.Distance(Pl);
if (Dist <= CommonTol)
{
Elast.Free( Standard_True );
Vf.Orientation( Vl.Orientation() );
BB.Remove( Elast, Vl );
BB.Add( Elast, Vf );
BB.UpdateVertex( Vf, CommonTol );
Base.Closed( Standard_True );
}
else if (Dist <= MaxTol)
{
// Creating new edge from Vl to Vf
TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vf, Vl );
BB.Add( Base, NewEdge );
Base.Closed( Standard_True );
}
}
// Updating sequences ClosedWires and UnclosedWires
if (DistF <= MaxTol)
UnclosedWires.Remove( IndexF );
if (DistL <= MaxTol && IndexL != IndexF)
{
if (DistF <= MaxTol && IndexL > IndexF)
IndexL--;
UnclosedWires.Remove( IndexL );
}
if (Base.Closed())
{
ClosedWires.Append( Base );
UnclosedWires.Remove( 1 );
}
else if (DistF > MaxTol && DistL > MaxTol)
{
IsolatedWires.Append( Base );
UnclosedWires.Remove( 1 );
}
} }
// Updating sequences ClosedWires and UnclosedWires
if (DistF <= MaxTol)
UnclosedWires.Remove( IndexF );
if (DistL <= MaxTol && IndexL != IndexF)
{
if (DistF <= MaxTol && IndexL > IndexF)
IndexL--;
UnclosedWires.Remove( IndexL );
}
if (Base.Closed())
{
ClosedWires.Append( Base );
UnclosedWires.Remove( 1 );
}
else if (DistF > MaxTol && DistL > MaxTol)
{
IsolatedWires.Append( Base );
UnclosedWires.Remove( 1 );
}
}
// Updating myShape // Updating myShape
if (ClosedWires.Length() + IsolatedWires.Length() == 1) if (ClosedWires.Length() + IsolatedWires.Length() == 1)
{ {
if (!ClosedWires.IsEmpty()) if (!ClosedWires.IsEmpty())
myShape = ClosedWires.First(); myShape = ClosedWires.First();
else else
myShape = IsolatedWires.First(); myShape = IsolatedWires.First();
} }
else else
{ {
TopoDS_Compound R; TopoDS_Compound R;
BB.MakeCompound( R ); BB.MakeCompound( R );
for (i = 1; i <= ClosedWires.Length(); i++) for (i = 1; i <= ClosedWires.Length(); i++)
BB.Add( R, ClosedWires(i) ); BB.Add( R, ClosedWires(i) );
for (i = 1; i <= IsolatedWires.Length(); i++) for (i = 1; i <= IsolatedWires.Length(); i++)
BB.Add( R, IsolatedWires(i) ); BB.Add( R, IsolatedWires(i) );
myShape = R; myShape = R;
} }
} }
//======================================================================= //=======================================================================
@ -2335,14 +2345,22 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
Points.Append(Pdeb); Points.Append(Pdeb);
C.D1(UU2,Pfin,Dfin); C.D1(UU2,Pfin,Dfin);
QuasiFleche(C,Deflection*Deflection,
UU1,Pdeb, const Standard_Real aDelta = UU2 - UU1;
Ddeb, const Standard_Real aDist = Pdeb.Distance(Pfin);
UU2,Pfin,
Dfin, if((aDelta/aDist) > 5.0e-14)
Nbmin, {
EPSILON*EPSILON, QuasiFleche(C,Deflection*Deflection,
Parameters,Points); UU1,Pdeb,
Ddeb,
UU2,Pfin,
Dfin,
Nbmin,
EPSILON*EPSILON,
Parameters,Points);
}
return Standard_True; return Standard_True;
} }
//======================================================================= //=======================================================================

View File

@ -50,8 +50,9 @@
#include <Standard_NotImplemented.hxx> #include <Standard_NotImplemented.hxx>
static Standard_Real ProjOnCurve (const gp_Pnt2d& P, static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C); const Handle(Geom2d_Curve)& C,
Standard_Real& theParam);
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C, static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U, Standard_Real U,
@ -125,8 +126,14 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
//--------------------------------------------- //---------------------------------------------
// Calculate first point of the polygon. // Calculate first point of the polygon.
//--------------------------------------------- //---------------------------------------------
U = ProjOnCurve (Origin,curve1); Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U);
P = ValueByInt (U,UC1,UC2,Dist); P = ValueByInt (U,UC1,UC2,Dist);
if(!isProjDone)
{
isEmpty = Standard_True;
return;
}
if (Dist < Precision::Infinite()) { if (Dist < Precision::Infinite()) {
//---------------------------------------------------- //----------------------------------------------------
@ -152,11 +159,11 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
for (Standard_Integer i = 1; i <= NbPnts - 1; i++) { for (Standard_Integer i = 1; i <= NbPnts - 1; i++) {
P = ValueByInt(U,UC1,UC2,Dist); P = ValueByInt(U,UC1,UC2,Dist);
if (Dist < Precision::Infinite()) { if (Dist < Precision::Infinite()) {
USol = SearchBound(U - dU,U); USol = SearchBound(U - dU,U);
P = ValueByInt(USol,UC1,UC2,Dist); P = ValueByInt(USol,UC1,UC2,Dist);
startIntervals.Append(USol); startIntervals.Append(USol);
myPolygon.Append(Bisector_PointOnBis(UC1,UC2,USol,Dist,P)); myPolygon.Append(Bisector_PointOnBis(UC1,UC2,USol,Dist,P));
break; break;
} }
U += dU; U += dU;
} }
@ -174,26 +181,26 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
dU = DU/(NbPnts - 1); dU = DU/(NbPnts - 1);
U += dU; U += dU;
// modified by NIZHNY-EAP Fri Jan 21 09:33:20 2000 ___BEGIN___ // modified by NIZHNY-EAP Fri Jan 21 09:33:20 2000 ___BEGIN___
// prevent addition of the same point // prevent addition of the same point
gp_Pnt2d prevPnt = P; gp_Pnt2d prevPnt = P;
for (Standard_Integer i = 1; i <= NbPnts - 1; i++) { for (Standard_Integer i = 1; i <= NbPnts - 1; i++) {
P = ValueByInt(U,UC1,UC2,Dist); P = ValueByInt(U,UC1,UC2,Dist);
if (Dist < Precision::Infinite()) { if (Dist < Precision::Infinite()) {
if (P.Distance (prevPnt) > Precision::Confusion()) if (P.Distance (prevPnt) > Precision::Confusion())
myPolygon.Append(Bisector_PointOnBis(UC1,UC2,U,Dist,P)); myPolygon.Append(Bisector_PointOnBis(UC1,UC2,U,Dist,P));
} }
else { else {
USol = SearchBound(U - dU,U); USol = SearchBound(U - dU,U);
P = ValueByInt(USol,UC1,UC2,Dist); P = ValueByInt(USol,UC1,UC2,Dist);
endIntervals.SetValue(1,USol); endIntervals.SetValue(1,USol);
if (P.Distance (prevPnt) > Precision::Confusion()) if (P.Distance (prevPnt) > Precision::Confusion())
myPolygon.Append(Bisector_PointOnBis(UC1,UC2,USol,Dist,P)); myPolygon.Append(Bisector_PointOnBis(UC1,UC2,USol,Dist,P));
break; break;
} }
U += dU; U += dU;
prevPnt=P; prevPnt=P;
// modified by NIZHNY-EAP Fri Jan 21 09:33:24 2000 ___END___ // modified by NIZHNY-EAP Fri Jan 21 09:33:24 2000 ___END___
} }
} }
else { else {
@ -249,19 +256,19 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
//------------------------------------------------------ //------------------------------------------------------
if (YaPoly) { if (YaPoly) {
if (extensionStart) { if (extensionStart) {
gp_Pnt2d P1 = myPolygon.First().Point(); gp_Pnt2d P1 = myPolygon.First().Point();
Standard_Real UFirst = startIntervals.First() - pointStart.Distance(P1); Standard_Real UFirst = startIntervals.First() - pointStart.Distance(P1);
startIntervals.InsertBefore(1,UFirst); startIntervals.InsertBefore(1,UFirst);
endIntervals .InsertBefore(1,startIntervals.Value(2)); endIntervals .InsertBefore(1,startIntervals.Value(2));
} }
if (extensionEnd) { if (extensionEnd) {
gp_Pnt2d P1; gp_Pnt2d P1;
Standard_Real UFirst,ULast; Standard_Real UFirst,ULast;
P1 = myPolygon.Last().Point(); P1 = myPolygon.Last().Point();
UFirst = endIntervals.Last(); UFirst = endIntervals.Last();
ULast = UFirst + pointEnd.Distance(P1); ULast = UFirst + pointEnd.Distance(P1);
startIntervals.Append(UFirst); startIntervals.Append(UFirst);
endIntervals .Append(ULast ); endIntervals .Append(ULast );
} }
} }
else { else {
@ -274,10 +281,10 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
} }
if (!YaPoly && !extensionStart && !extensionEnd) if (!YaPoly && !extensionStart && !extensionEnd)
isEmpty = Standard_True; isEmpty = Standard_True;
// modified by NIZHNY-EAP Mon Jan 17 17:32:40 2000 ___BEGIN___ // modified by NIZHNY-EAP Mon Jan 17 17:32:40 2000 ___BEGIN___
if (myPolygon.Length() <= 2) if (myPolygon.Length() <= 2)
isEmpty = Standard_True; isEmpty = Standard_True;
// modified by NIZHNY-EAP Mon Jan 17 17:32:42 2000 ___END___ // modified by NIZHNY-EAP Mon Jan 17 17:32:42 2000 ___END___
} }
//============================================================================= //=============================================================================
@ -1409,9 +1416,11 @@ Standard_Real Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const
else if (P.IsEqual(Value(LastParameter()),Precision::Confusion())) { else if (P.IsEqual(Value(LastParameter()),Precision::Confusion())) {
UOnCurve = LastParameter(); UOnCurve = LastParameter();
} }
else { else
UOnCurve = ProjOnCurve(P,curve1); {
ProjOnCurve(P, curve1, UOnCurve);
} }
return UOnCurve; return UOnCurve;
} }
@ -1623,42 +1632,56 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
//function : ProjOnCurve //function : ProjOnCurve
// purpose : // purpose :
//============================================================================= //=============================================================================
static Standard_Real ProjOnCurve (const gp_Pnt2d& P, static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C) const Handle(Geom2d_Curve)& C,
Standard_Real& theParam)
{ {
Standard_Real UOnCurve =0.; //Standard_Real UOnCurve =0.;
theParam = 0.0;
gp_Pnt2d PF,PL; gp_Pnt2d PF,PL;
gp_Vec2d TF,TL; gp_Vec2d TF,TL;
C->D1(C->FirstParameter(),PF,TF); C->D1(C->FirstParameter(),PF,TF);
C->D1(C->LastParameter() ,PL,TL); C->D1(C->LastParameter() ,PL,TL);
if (P.IsEqual(PF ,Precision::Confusion())) { if (P.IsEqual(PF ,Precision::Confusion()))
return C->FirstParameter(); {
theParam = C->FirstParameter();
return Standard_True;
} }
if (P.IsEqual(PL ,Precision::Confusion())) {
return C->LastParameter(); if (P.IsEqual(PL ,Precision::Confusion()))
{
theParam = C->LastParameter();
return Standard_True;
} }
gp_Vec2d PPF(PF.X() - P.X(), PF.Y() - P.Y()); gp_Vec2d PPF(PF.X() - P.X(), PF.Y() - P.Y());
TF.Normalize(); TF.Normalize();
if ( Abs (PPF.Dot(TF)) < Precision::Confusion()) {
return C->FirstParameter(); if ( Abs (PPF.Dot(TF)) < Precision::Confusion())
{
theParam = C->FirstParameter();
return Standard_True;
} }
gp_Vec2d PPL (PL.X() - P.X(), PL.Y() - P.Y()); gp_Vec2d PPL (PL.X() - P.X(), PL.Y() - P.Y());
TL.Normalize(); TL.Normalize();
if ( Abs (PPL.Dot(TL)) < Precision::Confusion()) { if ( Abs (PPL.Dot(TL)) < Precision::Confusion())
return C->LastParameter(); {
theParam = C->LastParameter();
return Standard_True;
} }
Geom2dAPI_ProjectPointOnCurve Proj(P,C, Geom2dAPI_ProjectPointOnCurve Proj(P,C,
C->FirstParameter(), C->FirstParameter(),
C->LastParameter()); C->LastParameter());
if (Proj.NbPoints() > 0) { if (Proj.NbPoints() > 0) {
UOnCurve = Proj.LowerDistanceParameter(); theParam = Proj.LowerDistanceParameter();
} }
else { else {
Standard_OutOfRange::Raise(); return Standard_False;
} }
return UOnCurve;
return Standard_True;
} }
//============================================================================= //=============================================================================

View File

@ -40,5 +40,13 @@ checkshape res5
renamevar res5 result renamevar res5 result
set square 1.21497e+7 set OCC62_square 1.23063e+7
puts "The expected square is ${OCC62_square}"
set sq_persent 0.03
regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m
if { (${OCC62_square} != 0 && [expr abs(${OCC62_square} - $m)/${OCC62_square}] > ${sq_persent}) || (${OCC62_square} == 0 && $m != 0) } {
puts "Error : The square of result shape is $m"
}
set 2dviewer 0 set 2dviewer 0

View File

@ -1,8 +1,10 @@
puts "TODO ?OCC23068 ALL: TEST INCOMPLETE" #puts "TODO ?OCC23068 ALL: TEST INCOMPLETE"
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." puts "TODO OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" puts "TODO OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!" #puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!"
puts "TODO OCC23068 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_074.brep] s restore [locate_data_file offset_wire_074.brep] s
set length 0 set length 0

View File

@ -1,7 +1,7 @@
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." #puts "TODO ?OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" #puts "TODO ?OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23748 ALL: Error: Offset is not done." #puts "TODO ?OCC23748 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_075.brep] s restore [locate_data_file offset_wire_075.brep] s

View File

@ -1,8 +1,10 @@
puts "TODO ?OCC23068 ALL: TEST INCOMPLETE" #puts "TODO ?OCC23068 ALL: TEST INCOMPLETE"
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." puts "TODO OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" puts "TODO OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!" #puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!"
puts "TODO OCC23068 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_074.brep] s restore [locate_data_file offset_wire_074.brep] s
set length 0 set length 0

View File

@ -1,7 +1,7 @@
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." #puts "TODO ?OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" #puts "TODO ?OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23748 ALL: Error: Offset is not done." #puts "TODO ?OCC23748 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_075.brep] s restore [locate_data_file offset_wire_075.brep] s

View File

@ -1,8 +1,10 @@
puts "TODO ?OCC23068 ALL: TEST INCOMPLETE" #puts "TODO ?OCC23068 ALL: TEST INCOMPLETE"
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." puts "TODO OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" puts "TODO OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!" #puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!"
puts "TODO OCC23068 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_074.brep] s restore [locate_data_file offset_wire_074.brep] s
set length 0 set length 0

View File

@ -1,7 +1,7 @@
puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." #puts "TODO ?OCC23068 ALL: Error : The offset cannot be built."
puts "TODO ?OCC23068 ALL: An exception was caught" #puts "TODO ?OCC23068 ALL: An exception was caught"
puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" #puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO ?OCC23748 ALL: Error: Offset is not done." #puts "TODO ?OCC23748 ALL: Error: Offset is not done."
restore [locate_data_file offset_wire_075.brep] s restore [locate_data_file offset_wire_075.brep] s