]> OCCT Git - occt.git/commitdiff
0027722: Data Exchange - STEP error for Ellipse revol shape CR27722_2
authoratychini <atychini@opencascade.com>
Thu, 18 Nov 2021 12:52:50 +0000 (15:52 +0300)
committeratychini <atychini@opencascade.com>
Fri, 3 Dec 2021 17:07:13 +0000 (20:07 +0300)
Bug was fixed by adding new constructor in ShapeAnalysis_Surface class. This constructor gets a TopoDS_Face as a parameter and bounds face with help of BRepTools:UVBounds().
Also I changed callable constructor in some places (where it looks more efficient) from ShapeAnalysis_Surface(const Handle(Geom_Surface)& S) to:
ShapeAnalysis_Surface(const TopoDS_Face& theFace)

12 files changed:
src/ShapeAnalysis/ShapeAnalysis_Surface.cxx
src/ShapeAnalysis/ShapeAnalysis_Surface.hxx
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx
src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
src/ShapeFix/ShapeFix_ComposeShell.cxx
src/ShapeFix/ShapeFix_EdgeProjAux.cxx
src/ShapeFix/ShapeFix_Face.cxx
src/ShapeFix/ShapeFix_IntersectionTool.cxx
src/ShapeUpgrade/ShapeUpgrade_ClosedFaceDivide.cxx
src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx
tests/bugs/step/bug27722 [new file with mode: 0644]
tests/bugs/xde/bug27722 [deleted file]

index 935e0436def080aab883fea892570097f9166850..cea532f1b921e0c194900e632cda0463aea4af85 100644 (file)
 #include <Adaptor3d_Curve.hxx>
 #include <Adaptor3d_IsoCurve.hxx>
 #include <Bnd_Box.hxx>
+#include <Bnd_Box2d.hxx>
 #include <BndLib_Add3dCurve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
 #include <ElSLib.hxx>
 #include <Geom_BezierSurface.hxx>
 #include <Geom_BoundedSurface.hxx>
@@ -108,6 +111,19 @@ ShapeAnalysis_Surface::ShapeAnalysis_Surface(const Handle(Geom_Surface)& S) :
   myAdSur = new GeomAdaptor_Surface(mySurf);
 }
 
+ShapeAnalysis_Surface::ShapeAnalysis_Surface(const TopoDS_Face& theFace) :
+  myFace(theFace),
+  mySurf(BRep_Tool::Surface(theFace)),
+  myExtOK(Standard_False), //:30
+  myNbDeg(-1),
+  myIsos(Standard_False),
+  myIsoBoxes(Standard_False),
+  myGap(0.), myUDelt(0.01), myVDelt(0.01), myUCloseVal(-1), myVCloseVal(-1)
+{
+  mySurf->Bounds(myUF, myUL, myVF, myVL);
+  myAdSur = new GeomAdaptor_Surface(mySurf);
+}
+
 //=======================================================================
 //function : Init
 //purpose  :
@@ -166,12 +182,12 @@ void ShapeAnalysis_Surface::ComputeSingularities()
   if (mySurf.IsNull())  return;
 
   Standard_Real   su1, sv1, su2, sv2;
-  //  mySurf->Bounds(su1, su2, sv1, sv2);
-  Bounds(su1, su2, sv1, sv2);//modified by rln on 12/11/97 mySurf-> is deleted
 
   myNbDeg = 0; //:r3
 
-  if (mySurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
+  if (mySurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface)))
+  {
+    Bounds(su1, su2, sv1, sv2);
     Handle(Geom_ConicalSurface) conicS =
       Handle(Geom_ConicalSurface)::DownCast(mySurf);
     Standard_Real vApex = -conicS->RefRadius() / Sin(conicS->SemiAngle());
@@ -184,7 +200,9 @@ void ShapeAnalysis_Surface::ComputeSingularities()
     myUIsoDeg[0] = Standard_False;
     myNbDeg = 1;
   }
-  else if (mySurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
+  else if (mySurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)))
+  {
+    Bounds(su1, su2, sv1, sv2);
     Handle(Geom_ToroidalSurface) toroidS =
       Handle(Geom_ToroidalSurface)::DownCast(mySurf);
     Standard_Real minorR = toroidS->MinorRadius();
@@ -203,7 +221,9 @@ void ShapeAnalysis_Surface::ComputeSingularities()
     myUIsoDeg[0] = myUIsoDeg[1] = Standard_False;
     myNbDeg = (majorR > minorR ? 1 : 2);
   }
-  else if (mySurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
+  else if (mySurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)))
+  {
+    Bounds(su1, su2, sv1, sv2);
     myPreci[0] = myPreci[1] = 0;
     myP3d[0] = mySurf->Value(su1, sv2); // Northern pole is first
     myP3d[1] = mySurf->Value(su1, sv1);
@@ -217,10 +237,20 @@ void ShapeAnalysis_Surface::ComputeSingularities()
     myNbDeg = 2;
   }
   else if ((mySurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) ||
-    (mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) || //:b2 abv 18 Feb 98
+    (mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) ||
     (mySurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface)))) { //rln S4135
 
-                                                           //rln S4135 //:r3
+    Bounds(su1, su2, sv1, sv2);
+    if (mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) && !myFace.IsNull())
+    {
+      Standard_Real aTmpU1 = 0, aTmpU2 = 0;
+      Bnd_Box2d B;
+      BRepTools::AddUVBounds(myFace, B);
+      if (!B.IsVoid())
+      {
+        B.Get(aTmpU1, myVF, aTmpU2, myVL);
+      }
+    }
     myP3d[0] = myAdSur->Value(su1, 0.5 * (sv1 + sv2));
     myFirstP2d[0].SetCoord(su1, sv2);
     myLastP2d[0].SetCoord(su1, sv1);
index e14e17454fa532f2ae95d6de6ace9a43fae8b635..534f3d9bef25abf62465113c22ef7741b3bdde15 100644 (file)
@@ -14,6 +14,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+
 #ifndef _ShapeAnalysis_Surface_HeaderFile
 #define _ShapeAnalysis_Surface_HeaderFile
 
@@ -24,6 +25,7 @@
 #include <Bnd_Box.hxx>
 #include <TColgp_SequenceOfPnt.hxx>
 #include <TColgp_SequenceOfPnt2d.hxx>
+#include <TopoDS_Face.hxx>
 
 class Geom_Surface;
 class Geom_Curve;
@@ -63,6 +65,9 @@ public:
   
   //! Creates an analyzer object on the basis of existing surface
   Standard_EXPORT ShapeAnalysis_Surface(const Handle(Geom_Surface)& S);
+
+  //! Creates an analyzer object on the basis of existing face
+  Standard_EXPORT ShapeAnalysis_Surface(const TopoDS_Face& theFace);
   
   //! Loads existing surface
   Standard_EXPORT void Init (const Handle(Geom_Surface)& S);
@@ -309,7 +314,7 @@ public:
 
 protected:
 
-
+  TopoDS_Face myFace;
   Handle(Geom_Surface) mySurf;
   Handle(GeomAdaptor_Surface) myAdSur;
   Extrema_ExtPS myExtPS;
index fe5e48351742b0f7f2e1b7e251255b1c3fe96872..2c4e203ca3057c802d8d0db9204148620b97c2ba 100644 (file)
@@ -682,8 +682,7 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex (const TopoDS_V
   }
   Standard_Real aTol = BRep_Tool::Tolerance(anewV);
   if(!hasRepr || (fromSurf != toSurf || fromLoc != toLoc)) {
-    Handle(Geom_Surface) aS = BRep_Tool::Surface(toFace);
-    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(aS);
+    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(toFace);
     gp_Pnt2d aP2d = aSurfTool->ValueOfUV(apv,Precision::Confusion());
     apar1 = aP2d.X();
     apar2 = aP2d.Y();
index 2500521779d7e1ca4bbfa7e4340a4ffb38d18b56..286b29ee5c050feb9e8a60309202ccccb12d9b68 100644 (file)
@@ -178,7 +178,7 @@ void ShapeAnalysis_Wire::SetFace(const TopoDS_Face& face)
 {
   myFace = face;
   if(!face.IsNull())
-    mySurf = new ShapeAnalysis_Surface ( BRep_Tool::Surface ( myFace ) );
+    mySurf = new ShapeAnalysis_Surface (myFace);
 }
 
 //=======================================================================
index 7feb87e3d35fb129364cbdc5dbaf6e34f94a5d07..3556e957396ff3814a5f5b8a5945674fa7ec59d9 100644 (file)
@@ -817,7 +817,7 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire (ShapeFix_WireSegment &wir
   BRep_Builder B;
   ShapeFix_WireSegment result;
   Handle(ShapeAnalysis_Surface) aSurfTool = 
-    new ShapeAnalysis_Surface ( BRep_Tool::Surface (myFace) );
+    new ShapeAnalysis_Surface ( myFace );
   Standard_Integer nbSplits = indexes.Length();
   ShapeAnalysis_Edge sae;
   Standard_Integer start = 1;
@@ -1210,7 +1210,7 @@ Standard_Boolean ShapeFix_ComposeShell::SplitByLine (ShapeFix_WireSegment &wire,
   Standard_Boolean isnonmanifold = (wire.Orientation() == TopAbs_INTERNAL);
   //gka correction for non-manifold vertices SAMTECH
   if(wire.IsVertex()) {
-    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface ( BRep_Tool::Surface (myFace) );
+    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface ( myFace );
     TopoDS_Vertex aVert = wire.GetVertex();
     gp_Pnt aP3d = BRep_Tool::Pnt(aVert);
     gp_Pnt2d aP2d =  aSurfTool->ValueOfUV(aP3d,Precision::Confusion());
@@ -2339,8 +2339,7 @@ static gp_Pnt2d GetMiddlePoint (const ShapeFix_WireSegment wire,
   if(wire.IsVertex()) {
     TopoDS_Vertex aV = wire.GetVertex();
     gp_Pnt aP3D = BRep_Tool::Pnt(aV );
-    Handle(Geom_Surface) surf = BRep_Tool::Surface(face);
-    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(surf);
+    Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(face);
     return aSurfTool->ValueOfUV(aP3D,Precision::Confusion());
   }
   Bnd_Box2d box;
@@ -2402,9 +2401,8 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch (TopTools_SequenceOfShape &faces,
   // make pseudo-face,
   TopoDS_Face pf;
   B.MakeFace ( pf, surf, myLoc, ::Precision::Confusion() );
-  Handle(Geom_Surface) atSurf = BRep_Tool::Surface(pf);
 
-  Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(atSurf);
+  Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(pf);
   TopTools_SequenceOfShape roots;
   Standard_Integer i; // svv #1
   for ( i = 1; i <= loops.Length(); i++ ) {
index 2c3100198e3457d8e3ef46dd73abf345670ce58d..f6c71dbc99fc75896d8281014a6f7c897678e6fa 100644 (file)
@@ -255,7 +255,7 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci)
   //:S4136  Standard_Real preci = BRepAPI::Precision();
   //pdn to manage degenerated case
   if (V1.IsSame(V2)) {
-    Handle(ShapeAnalysis_Surface) stsu = new ShapeAnalysis_Surface (theSurface);
+    Handle(ShapeAnalysis_Surface) stsu = new ShapeAnalysis_Surface (myFace);
     gp_Pnt2d aPt1,aPt2;
     Standard_Real firstpar,lastpar;
     if (stsu->DegeneratedValues(Pt1,preci,aPt1,aPt2,firstpar,lastpar)){
index 71b46ebee3ed8acb91ef87166af2f2fcdad98b05..8fb8f17960aa55843ff67fb24c516cfd2cbc7a11 100644 (file)
@@ -254,7 +254,7 @@ void ShapeFix_Face::Init (const Handle(ShapeAnalysis_Surface)& surf,
 void ShapeFix_Face::Init (const TopoDS_Face& face) 
 {
   myStatus = 0;
-  mySurf = new ShapeAnalysis_Surface ( BRep_Tool::Surface (face) );
+  mySurf = new ShapeAnalysis_Surface ( face );
   myFwd = ( face.Orientation() != TopAbs_REVERSED );
   myFace = face;
   myShape = myFace;
index e5f268724a2288b8939df29d454bb5b7fae6742f..521d9a0c6b7f283a79a27f7b501cb39af67cd729 100644 (file)
@@ -800,7 +800,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FindVertAndSplitEdge
 {
   // find needed vertex from edge2 and split edge1 using it
   ShapeAnalysis_Edge sae;
-  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(BRep_Tool::Surface(face));
+  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(face);
   gp_Pnt pi1 = GetPointOnEdge(edge1,sas,Crv1,param1);
   BRep_Builder B;
   TopoDS_Vertex V;
@@ -869,7 +869,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FixSelfIntersectWire
   // step 2 : intersection of non-adjacent edges
   ShapeFix_DataMapOfShapeBox2d boxes;
   (void)CreateBoxes2d(sewd,face,boxes);
-  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(BRep_Tool::Surface(face));
+  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(face);
 
   NbSplit=0;
   NbCut=0;
@@ -1488,7 +1488,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires
   }
   Standard_Boolean isDone = Standard_False; //gka 06.09.04
   ShapeAnalysis_Edge sae;
-  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (BRep_Tool::Surface (face));
+  Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (face);
 
   // precompute edge boxes for all wires
   NCollection_Sequence<ShapeFix_DataMapOfShapeBox2d> aSeqWirEdgeBoxes;
index 07b335441efeaaeda33a66dd0dfc4e673cc616ba..532ae878c2faa2a238bf5b0dc3b45668a6ec3110 100644 (file)
@@ -159,7 +159,7 @@ Standard_Boolean ShapeUpgrade_ClosedFaceDivide::SplitSurface()
   
   if(!doSplit) {
     //pdn try to define geometric closure.
-    Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface( surf );
+    Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface( face );
     Standard_Boolean uclosed = sas->IsUClosed(Precision());
     Standard_Boolean vclosed = sas->IsVClosed(Precision());
     Standard_Real U1, U2, V1, V2;
index f9185088b202e25ea005f29fd26868a259efe934..53369801bd621a4e87721036f518d3d6a394ec10 100644 (file)
@@ -1793,8 +1793,7 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const TopTools_SequenceOfShape&
     for (Standard_Integer ii = 1; ii <= ResPCurves.Length(); ii++)
     {
       const TopoDS_Face& aFace = TopoDS::Face (aFaceSeq(ii));
-      Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace);
-      Handle(ShapeAnalysis_Surface) aSAS = new ShapeAnalysis_Surface (aSurf);
+      Handle(ShapeAnalysis_Surface) aSAS = new ShapeAnalysis_Surface (aFace);
       ShapeConstruct_ProjectCurveOnSurface aToolProj;
       aToolProj.Init (aSAS, Precision::Confusion());
       Handle(Geom2d_Curve) aNewPCurve;
diff --git a/tests/bugs/step/bug27722 b/tests/bugs/step/bug27722
new file mode 100644 (file)
index 0000000..4ffa1e8
--- /dev/null
@@ -0,0 +1,28 @@
+puts "==================================================="
+puts "0027722: Data Exchange - STEP er-ror for Ellipse revol shape"
+puts "==================================================="
+puts ""
+
+pload MODELING XDE VISUALIZATION
+
+ellipse ge 0 0 20 10
+mkedge te ge 0 pi/2.0
+revol re te 0 0 0 0 1 0 360
+
+# save to STEP in mode: As Is.
+stepwrite a re ${imagedir}/${casename}.stp
+
+# read STEP
+stepread ${imagedir}/${casename}.stp sr *
+ttranslate sr_1 50 0 0
+checkshape sr_1
+checkprops sr_1 -equal re
+
+vinit view1
+vclear
+vdisplay -dispmode 1 -3d sr_1 re
+vtrihedron vt
+vfit
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+
+file delete ${imagedir}/orig.stp
diff --git a/tests/bugs/xde/bug27722 b/tests/bugs/xde/bug27722
deleted file mode 100644 (file)
index f586f3f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-puts "TODO OCC27722 ALL: Faulty shapes in variables faulty_1 to faulty_"
-puts "TODO OCC27722 ALL: Error :  is WRONG because number of "
-
-puts "========"
-puts "OCC27722"
-puts "========"
-puts ""
-######################################
-# STEP error for Ellipse revol shape
-######################################
-
-catch {exec rm ${imagedir}/bug27722.stp}
-
-ellipse ge 0 0 20 10
-mkedge te ge 0 pi/2.0
-revol re te 0 0 0 0 1 0 360
-
-set i_Vertex   0
-set i_Edge     0
-set i_Wire     0
-set i_Face     0
-set i_Shell    0
-set i_Solid    0
-set i_CSolid   0
-set i_Compound 0
-set i_Shape    0
-set bug_info [string trim [checkshape re]]
-if {$bug_info == "This shape seems to be valid"} {
-  set nb_info [string trim [nbshapes re]]
-  set i_Vertex   [string trim [lindex $nb_info 7]]
-  set i_Edge     [string trim [lindex $nb_info 10]]
-  set i_Wire     [string trim [lindex $nb_info 13]]
-  set i_Face     [string trim [lindex $nb_info 16]]
-  set i_Shell    [string trim [lindex $nb_info 19]]
-  set i_Solid    [string trim [lindex $nb_info 22]]
-  set i_CSolid   [string trim [lindex $nb_info 25]]
-  set i_Compound [string trim [lindex $nb_info 28]]
-  set i_Shape    [string trim [lindex $nb_info 31]]
-} else {
-  puts "ERROR: Problem of test case functionality. Should be additionally investigated."
-}
-
-stepwrite a re ${imagedir}/bug27722.stp
-
-stepread ${imagedir}/bug27722.stp sr *
-checkshape sr_1
-checknbshapes sr_1 -vertex ${i_Vertex} -edge ${i_Edge} -wire ${i_Wire} -face ${i_Face} -shell ${i_Shell} -solid ${i_Solid} -compsolid ${i_CSolid} -compound ${i_Compound} -shape ${i_Shape}