1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-10 12:25:50 +03:00

0022804: Sewing increases tolerance of vertices for redundant value.

This commit is contained in:
GKA 2011-11-25 12:02:09 +00:00 committed by bugmaster
parent b485ee79ca
commit 67ffcad070

View File

@ -490,7 +490,6 @@ static inline Standard_Real ComputeToleranceVertex(const Standard_Real dist, con
{ {
return (dist * 0.5 + Tol1 + Tol2); return (dist * 0.5 + Tol1 + Tol2);
} }
TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirst, TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirst,
const TopoDS_Edge& edgeLast, const TopoDS_Edge& edgeLast,
const TopTools_ListOfShape& listFacesFirst, const TopTools_ListOfShape& listFacesFirst,
@ -574,7 +573,8 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
TopExp::Vertices(edge1,V11,V12); TopExp::Vertices(edge1,V11,V12);
TopExp::Vertices(edge2,V21,V22); TopExp::Vertices(edge2,V21,V22);
// Check that edges are merged correctly (for edges having length less than specified tolerance) //check that edges merged valid way (for edges having length less than specified
//tolerance
if(secForward) if(secForward)
{ {
if( V11.IsSame(V22) || V12.IsSame(V21) ) if( V11.IsSame(V22) || V12.IsSame(V21) )
@ -647,43 +647,56 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
// both edges are open // both edges are open
gp_Pnt plast; gp_Pnt plast;
Standard_Real Tol2 = 0.; Standard_Real Tol2 = 0.;
Standard_Boolean isOldFirst = ( secForward ? V11.IsSame(V21) : V11.IsSame(V22) );
Standard_Boolean isOldLast = ( secForward ? V12.IsSame(V22) : V12.IsSame(V21)) ;
if (secForward) { if (secForward) {
//case if vertices already sewed
if(!isOldFirst)
{
pfirst.SetXYZ(0.5*(p11.XYZ() + p21.XYZ())); pfirst.SetXYZ(0.5*(p11.XYZ() + p21.XYZ()));
plast.SetXYZ(0.5*(p12.XYZ() + p22.XYZ()));
gp_Vec v1 = p21.XYZ() - p11.XYZ(); gp_Vec v1 = p21.XYZ() - p11.XYZ();
Standard_Real d1 = v1.Magnitude(); Standard_Real d1 = v1.Magnitude();
Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V21));
}
if(!isOldLast)
{
plast.SetXYZ(0.5*(p12.XYZ() + p22.XYZ()));
gp_Vec v2 = p22.XYZ() - p12.XYZ(); gp_Vec v2 = p22.XYZ() - p12.XYZ();
Standard_Real d2 = v2.Magnitude(); Standard_Real d2 = v2.Magnitude();
Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V21));
Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V22));
// Tol1 = Max(Max(pfirst.Distance(p11),pfirst.Distance(p21)), Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V22));
// Max(BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V21))); }
// Tol2 = Max(Max(plast.Distance(p12),plast.Distance(p22)),
// Max(BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V22)));
} }
else { else {
if(!isOldFirst)
{
pfirst.SetXYZ(0.5*(p11.XYZ() + p22.XYZ())); pfirst.SetXYZ(0.5*(p11.XYZ() + p22.XYZ()));
plast.SetXYZ(0.5*(p12.XYZ() + p21.XYZ()));
gp_Vec v1 = p22.XYZ() - p11.XYZ(); gp_Vec v1 = p22.XYZ() - p11.XYZ();
Standard_Real d1 = v1.Magnitude(); Standard_Real d1 = v1.Magnitude();
Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V22));
}
if(!isOldLast)
{
plast.SetXYZ(0.5*(p12.XYZ() + p21.XYZ()));
gp_Vec v2 = p21.XYZ() - p12.XYZ(); gp_Vec v2 = p21.XYZ() - p12.XYZ();
Standard_Real d2 = v2.Magnitude(); Standard_Real d2 = v2.Magnitude();
Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V22));
Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V21)); Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V21));
// Tol1 = Max(Max(pfirst.Distance(p11),pfirst.Distance(p22)),
// Max(BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V22)));
// Tol2 = Max(Max(plast.Distance(p12),plast.Distance(p21)),
// Max(BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V21)));
} }
//gp_Pnt pcu;
///c3d->D0(first3d,pcu); }
//Tol1 = Max(pfirst.Distance(pcu) + Max(BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V22)); if(!isOldFirst)
aBuilder.MakeVertex(V1New,pfirst,Tol1); aBuilder.MakeVertex(V1New,pfirst,Tol1);
//c3d->D0(last3d,pcu); else
//Tol2 = plast.Distance(pcu); V1New = V11;
if(!isOldLast)
aBuilder.MakeVertex(V2New,plast,Tol2); aBuilder.MakeVertex(V2New,plast,Tol2);
else
V2New = V12;
} }
// Add the vertices in the good sense // Add the vertices in the good sense
@ -745,8 +758,8 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
if (!secForward) { if (!secForward) {
if (c2d2->IsKind(STANDARD_TYPE(Geom2d_Line))) if (c2d2->IsKind(STANDARD_TYPE(Geom2d_Line)))
c2d2 = new Geom2d_TrimmedCurve(c2d2, firstOld, lastOld); c2d2 = new Geom2d_TrimmedCurve(c2d2, firstOld, lastOld);
Standard_Real first2d = firstOld; //c2dTmp->FirstParameter(); BUG USA60321 Standard_Real first2d = firstOld;
Standard_Real last2d = lastOld; //c2dTmp->LastParameter(); Standard_Real last2d = lastOld;
firstOld = c2d2->ReversedParameter(last2d); firstOld = c2d2->ReversedParameter(last2d);
lastOld = c2d2->ReversedParameter(first2d); lastOld = c2d2->ReversedParameter(first2d);
c2d2->Reverse(); c2d2->Reverse();
@ -791,9 +804,6 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
if (c2d1.IsNull() && c2d11.IsNull()) continue; if (c2d1.IsNull() && c2d11.IsNull()) continue;
//Ori = edge1.Orientation();
//if (fac1.Orientation() == TopAbs_REVERSED) TopAbs::Reverse(Ori);
if (surf2 == surf1) { if (surf2 == surf1) {
// Merge sections which are on the same face // Merge sections which are on the same face
if (!loc2.IsDifferent(loc1)) { if (!loc2.IsDifferent(loc1)) {
@ -1004,7 +1014,7 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequence
Handle(Geom_Curve) c3dRef; Handle(Geom_Curve) c3dRef;
Standard_Real firstRef=0., lastRef=0.; Standard_Real firstRef=0., lastRef=0.;
Standard_Integer nbFound = 0;
for (i = indRef; i <= lengSec; i++) { for (i = indRef; i <= lengSec; i++) {
// reading of the edge (attention for the first one: reference) // reading of the edge (attention for the first one: reference)
@ -1027,7 +1037,8 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequence
Standard_Real T, deltaT = (last - first) / (npt - 1); Standard_Real T, deltaT = (last - first) / (npt - 1);
Standard_Real aLenSec2 = 0.; Standard_Real aLenSec2 = 0.;
Standard_Boolean isFound = (indRef == i);
Standard_Integer nbFound = 0;
for (j = 1; j <= npt; j++) { for (j = 1; j <= npt; j++) {
// Uniform parameter on curve // Uniform parameter on curve