mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0032581: Modelling Algorithms - UnifySameDomain produces invalid result
1. Correct local function TransformPCurves of ShapeUpgrade_UnifySameDomain: take into account the case of seam edge. 2. Correct local function ReconstructMissedSeam of ShapeUpgrade_UnifySameDomain: use previously stored seam edge in some cases.
This commit is contained in:
parent
f2aa215e29
commit
1e74e3eacd
@ -689,43 +689,67 @@ static void ReconstructMissedSeam(const TopTools_SequenceOfShape& theEdges,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TopoDS_Edge aSeam = aRemovedEdge;
|
MissedSeam = aRemovedEdge;
|
||||||
aSeam.Orientation(TopAbs_FORWARD);
|
MissedSeam.Orientation(TopAbs_FORWARD);
|
||||||
Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface(aSeam, theFrefFace, Param1, Param2);
|
if (!theCurVertex.IsSame(V1))
|
||||||
aSeam.Reverse();
|
MissedSeam.Reverse();
|
||||||
Handle(Geom2d_Curve) PC2 = BRep_Tool::CurveOnSurface(aSeam, theFrefFace, Param1, Param2);
|
}
|
||||||
Standard_Boolean IsSeam = (PC1 != PC2);
|
|
||||||
if (!IsSeam) //it was not a seam
|
if (!BRep_Tool::IsClosed (MissedSeam, theFrefFace))
|
||||||
|
{
|
||||||
|
//make edge a real seam edge with 2 pcurves on ref face
|
||||||
|
Handle(Geom2d_Curve) aPC = BRep_Tool::CurveOnSurface (MissedSeam, theFrefFace, Param1, Param2);
|
||||||
|
gp_Pnt2d aP2d = aPC->Value(Param1);
|
||||||
|
if (Abs(aP2d.Coord(IndCoord) - theCurPoint.Coord(IndCoord)) > thePeriod/2)
|
||||||
{
|
{
|
||||||
aCoord = theCurPoint.Coord(IndCoord);
|
Standard_Real anOffset = 0.;
|
||||||
gp_Pnt2d PointOnRemovedEdge = PC1->Value(Param1);
|
if (aP2d.Coord(IndCoord) < theCurPoint.Coord(IndCoord))
|
||||||
Standard_Real CoordOfRemovededge = PointOnRemovedEdge.Coord(IndCoord);
|
anOffset = thePeriod;
|
||||||
if (Abs(aCoord - CoordOfRemovededge) > thePeriod/2)
|
|
||||||
{
|
|
||||||
Standard_Real Sign = (aCoord > CoordOfRemovededge)? 1 : -1;
|
|
||||||
Offset *= Sign;
|
|
||||||
PC1 = Handle(Geom2d_Curve)::DownCast(PC2->Copy());
|
|
||||||
PC1->Translate(Offset);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
anOffset = -thePeriod;
|
||||||
if (SeamDir > 0)
|
|
||||||
Offset *= -1;
|
if (theIsU)
|
||||||
PC2 = Handle(Geom2d_Curve)::DownCast(PC1->Copy());
|
Offset.SetCoord (anOffset, 0.);
|
||||||
PC2->Translate(Offset);
|
else
|
||||||
}
|
Offset.SetCoord (0., anOffset);
|
||||||
|
|
||||||
|
aPC->Translate(Offset);
|
||||||
|
}
|
||||||
|
gp_Pnt2d aFirstP2d, aLastP2d;
|
||||||
|
if (MissedSeam.Orientation() == TopAbs_FORWARD)
|
||||||
|
{
|
||||||
|
aFirstP2d = aPC->Value(Param1);
|
||||||
|
aLastP2d = aPC->Value(Param2);
|
||||||
}
|
}
|
||||||
if (theCurVertex.IsSame(V1))
|
|
||||||
BB.UpdateEdge(MissedSeam, PC1, PC2, theFrefFace, 0.);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsSeam)
|
aFirstP2d = aPC->Value(Param2);
|
||||||
BB.UpdateEdge(MissedSeam, PC1, PC2, theFrefFace, 0.);
|
aLastP2d = aPC->Value(Param1);
|
||||||
else
|
|
||||||
BB.UpdateEdge(MissedSeam, PC2, PC1, theFrefFace, 0.);
|
|
||||||
|
|
||||||
MissedSeam.Reverse();
|
|
||||||
}
|
}
|
||||||
|
if (theIsU)
|
||||||
|
{
|
||||||
|
if (aFirstP2d.Y() < aLastP2d.Y())
|
||||||
|
Offset.SetCoord (-thePeriod, 0.);
|
||||||
|
else
|
||||||
|
Offset.SetCoord (thePeriod, 0.);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (aFirstP2d.X() < aLastP2d.X())
|
||||||
|
Offset.SetCoord (0., thePeriod);
|
||||||
|
else
|
||||||
|
Offset.SetCoord (0., -thePeriod);
|
||||||
|
}
|
||||||
|
Handle(Geom2d_Curve) AnotherPC = Handle(Geom2d_Curve)::DownCast(aPC->Copy());
|
||||||
|
AnotherPC->Translate(Offset);
|
||||||
|
TopoDS_Edge F_MissedSeam = MissedSeam;
|
||||||
|
F_MissedSeam.Orientation (TopAbs_FORWARD);
|
||||||
|
Handle(Geom2d_Curve) NullPC;
|
||||||
|
BB.UpdateEdge (F_MissedSeam, NullPC, theFrefFace, 0.);
|
||||||
|
if (MissedSeam.Orientation() == TopAbs_FORWARD)
|
||||||
|
BB.UpdateEdge (F_MissedSeam, aPC, AnotherPC, theFrefFace, 0.);
|
||||||
|
else
|
||||||
|
BB.UpdateEdge (F_MissedSeam, AnotherPC, aPC, theFrefFace, 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
BB.Continuity(MissedSeam, theFrefFace, theFrefFace, aContinuity);
|
BB.Continuity(MissedSeam, theFrefFace, theFrefFace, aContinuity);
|
||||||
@ -957,12 +981,17 @@ static void TransformPCurves(const TopoDS_Face& theRefFace,
|
|||||||
|
|
||||||
BRep_Builder BB;
|
BRep_Builder BB;
|
||||||
TopExp_Explorer Explo(theFace, TopAbs_EDGE);
|
TopExp_Explorer Explo(theFace, TopAbs_EDGE);
|
||||||
|
TopTools_MapOfShape aEmap;
|
||||||
for (; Explo.More(); Explo.Next())
|
for (; Explo.More(); Explo.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
|
TopoDS_Edge anEdge = TopoDS::Edge(Explo.Current());
|
||||||
if (BRep_Tool::Degenerated(anEdge) && ToModify)
|
if (BRep_Tool::Degenerated(anEdge) && ToModify)
|
||||||
continue;
|
continue;
|
||||||
if (BRepTools::IsReallyClosed(anEdge, theFace))
|
|
||||||
|
if (ToProject && BRep_Tool::IsClosed(anEdge, theFace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!aEmap.Add(anEdge))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Standard_Real fpar, lpar;
|
Standard_Real fpar, lpar;
|
||||||
@ -970,36 +999,51 @@ static void TransformPCurves(const TopoDS_Face& theRefFace,
|
|||||||
if (!PCurveOnRef.IsNull() && !(ToModify || ToProject))
|
if (!PCurveOnRef.IsNull() && !(ToModify || ToProject))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
|
Handle(Geom2d_Curve) PCurves [2], NewPCurves [2];
|
||||||
Handle(Geom2d_Curve) aNewPCurve;
|
anEdge.Orientation (TopAbs_FORWARD);
|
||||||
if (ToProject)
|
PCurves[0] = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
|
||||||
{
|
anEdge.Reverse();
|
||||||
Handle(Geom_Curve) aC3d = BRep_Tool::Curve(anEdge, fpar, lpar);
|
PCurves[1] = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, fpar, lpar);
|
|
||||||
Standard_Real tol = BRep_Tool::Tolerance(anEdge);
|
|
||||||
tol = Min(tol, Precision::Approximation());
|
|
||||||
aNewPCurve =
|
|
||||||
GeomProjLib::Curve2d(aC3d, RefSurf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aNewPCurve = Handle(Geom2d_Curve)::DownCast(aPCurve->Copy());
|
|
||||||
}
|
|
||||||
if (ToTranslate)
|
|
||||||
aNewPCurve->Translate(gp_Vec2d(0., aTranslation));
|
|
||||||
if (Y_Reverse)
|
|
||||||
aNewPCurve->Mirror(gp::OX2d());
|
|
||||||
if (X_Reverse)
|
|
||||||
{
|
|
||||||
aNewPCurve->Mirror(gp::OY2d());
|
|
||||||
aNewPCurve->Translate(gp_Vec2d(2*M_PI, 0.));
|
|
||||||
}
|
|
||||||
if (ToRotate)
|
|
||||||
aNewPCurve->Translate(gp_Vec2d(anAngle, 0.));
|
|
||||||
|
|
||||||
theMapEdgesWithTemporaryPCurves.Add(anEdge);
|
Standard_Integer NbPcurves = (PCurves[0] == PCurves[1])? 1 : 2;
|
||||||
|
|
||||||
|
for (Standard_Integer ii = 0; ii < NbPcurves; ii++)
|
||||||
|
{
|
||||||
|
if (ToProject)
|
||||||
|
{
|
||||||
|
Handle(Geom_Curve) aC3d = BRep_Tool::Curve(anEdge, fpar, lpar);
|
||||||
|
aC3d = new Geom_TrimmedCurve(aC3d, fpar, lpar);
|
||||||
|
Standard_Real tol = BRep_Tool::Tolerance(anEdge);
|
||||||
|
tol = Min(tol, Precision::Approximation());
|
||||||
|
NewPCurves[ii] =
|
||||||
|
GeomProjLib::Curve2d(aC3d, RefSurf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NewPCurves[ii] = Handle(Geom2d_Curve)::DownCast(PCurves[ii]->Copy());
|
||||||
|
}
|
||||||
|
if (ToTranslate)
|
||||||
|
NewPCurves[ii]->Translate(gp_Vec2d(0., aTranslation));
|
||||||
|
if (Y_Reverse)
|
||||||
|
NewPCurves[ii]->Mirror(gp::OX2d());
|
||||||
|
if (X_Reverse)
|
||||||
|
{
|
||||||
|
NewPCurves[ii]->Mirror(gp::OY2d());
|
||||||
|
NewPCurves[ii]->Translate(gp_Vec2d(2*M_PI, 0.));
|
||||||
|
}
|
||||||
|
if (ToRotate)
|
||||||
|
NewPCurves[ii]->Translate(gp_Vec2d(anAngle, 0.));
|
||||||
|
}
|
||||||
|
|
||||||
|
anEdge.Orientation (TopAbs_FORWARD);
|
||||||
|
|
||||||
|
theMapEdgesWithTemporaryPCurves.Add(anEdge);
|
||||||
|
|
||||||
|
if (NbPcurves == 1)
|
||||||
|
BB.UpdateEdge(anEdge, NewPCurves[0], theRefFace, 0.);
|
||||||
|
else
|
||||||
|
BB.UpdateEdge(anEdge, NewPCurves[0], NewPCurves[1], theRefFace, 0.);
|
||||||
|
|
||||||
BB.UpdateEdge(anEdge, aNewPCurve, theRefFace, 0.);
|
|
||||||
BB.Range(anEdge, fpar, lpar);
|
BB.Range(anEdge, fpar, lpar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
tests/bugs/heal/bug32581
Normal file
20
tests/bugs/heal/bug32581
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
puts "================================================="
|
||||||
|
puts "OCC32581: UnifySameDomain produces invalid result"
|
||||||
|
puts "================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
restore [locate_data_file bug32581.brep] a
|
||||||
|
|
||||||
|
unifysamedom result a
|
||||||
|
|
||||||
|
checkshape result
|
||||||
|
|
||||||
|
checknbshapes result -t -solid 3 -shell 3 -face 14 -wire 16 -edge 31 -vertex 20
|
||||||
|
|
||||||
|
set tolres [checkmaxtol result]
|
||||||
|
|
||||||
|
if { ${tolres} > 2.e-7} {
|
||||||
|
puts "Error: bad tolerance of result"
|
||||||
|
}
|
||||||
|
|
||||||
|
checkprops result -s 63178.1 -v 1e+06
|
Loading…
x
Reference in New Issue
Block a user