]> OCCT Git - occt-copy.git/commitdiff
0029701: BRepTools::Update(Face) unexpectedly updates UV points of pcurve
authoremv <emv@opencascade.com>
Thu, 19 Apr 2018 13:31:19 +0000 (16:31 +0300)
committerabv <abv@opencascade.com>
Wed, 23 May 2018 03:39:49 +0000 (06:39 +0300)
The method *BRepTools::UpdateFaceUVPoints* has been modified to resets the UV points of the edge to the bounding points of the parametric curve of the edge on the face.

Test cases for the issue.

Adjust test cases heal split_angle_advanced ZC3, ZE6, ZE9 for current behavior as they show less faulty shapes now.
Adjust test case bugs modalg_6 bug21246 as it works correctly now.

src/BRepTools/BRepTools.cxx
src/BRepTools/BRepTools.hxx
tests/bugs/modalg_6/bug21246
tests/bugs/modalg_7/bug29701_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug29701_2 [new file with mode: 0644]
tests/bugs/modalg_7/bug29701_3 [new file with mode: 0644]
tests/heal/data/advanced/ZC3
tests/heal/data/advanced/ZE6
tests/heal/data/advanced/ZE9

index 5a707a0da12677ce00e514b645d689ba2b6d6033..6a1096fa792173c6b4d755af6958fa502ff83879 100644 (file)
@@ -19,7 +19,8 @@
 #include <BndLib_Add2dCurve.hxx>
 #include <BRep_Builder.hxx>
 #include <BRep_CurveRepresentation.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+#include <BRep_ListOfCurveRepresentation.hxx>
 #include <BRep_TEdge.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepTools.hxx>
@@ -548,132 +549,45 @@ void BRepTools::Update(const TopoDS_Shape& S)
   }
 }
 
-
 //=======================================================================
 //function : UpdateFaceUVPoints
-//purpose  : reset the UV points of a  Face
+//purpose  : Reset the UV points of edges on the Face
 //=======================================================================
-
-void  BRepTools::UpdateFaceUVPoints(const TopoDS_Face& F)
+void  BRepTools::UpdateFaceUVPoints(const TopoDS_Face& theF)
 {
-  // Recompute for each edge the two UV points in order to have the same
-  // UV point on connected edges.
-
-  // First edge loop, store the vertices in a Map with their 2d points
-
-  BRepTools_MapOfVertexPnt2d theVertices;
-  TopoDS_Iterator expE,expV;
-  TopoDS_Iterator EdgeIt,VertIt;
-  TColStd_SequenceOfReal aFSeq, aLSeq;
-  TColGeom2d_SequenceOfCurve aCSeq;
-  TopTools_SequenceOfShape aShSeq;
-  gp_Pnt2d P;
-  Standard_Integer i;
-  // a 3d tolerance for UV !!
-  Standard_Real tolerance = BRep_Tool::Tolerance(F);
-  TColgp_SequenceOfPnt2d emptySequence;
-  
-  for (expE.Initialize(F); expE.More(); expE.Next()) {
-    if(expE.Value().ShapeType() != TopAbs_WIRE)
-      continue;
-    
-    EdgeIt.Initialize(expE.Value());
-    for( ; EdgeIt.More(); EdgeIt.Next())
-    {
-      const TopoDS_Edge& E = TopoDS::Edge(EdgeIt.Value());
-      Standard_Real f,l;
-      Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,f,l);
-
-      aFSeq.Append(f);
-      aLSeq.Append(l);
-      aCSeq.Append(C);
-      aShSeq.Append(E);
-
-      if (C.IsNull()) continue;
-
-      for (expV.Initialize(E.Oriented(TopAbs_FORWARD)); 
-           expV.More(); expV.Next()) {
-        
-        const TopoDS_Vertex& V = TopoDS::Vertex(expV.Value());
-        
-        TopAbs_Orientation Vori = V.Orientation();
-        if ( Vori == TopAbs_INTERNAL ) {
-          continue;
-        }
-        
-        Standard_Real p = BRep_Tool::Parameter(V,E,F);
-        C->D0(p,P);
-        if (!theVertices.IsBound(V)) 
-          theVertices.Bind(V,emptySequence);
-        TColgp_SequenceOfPnt2d& S = theVertices(V);
-        for (i = 1; i <= S.Length(); i++) {
-          if (P.Distance(S(i)) < tolerance) break;
-        }
-        if (i > S.Length())
-          S.Append(P);
-      }
-    }
-  }
-  // second edge loop, update the edges 2d points
-  TopoDS_Vertex Vf,Vl;
-  gp_Pnt2d Pf,Pl;
+  // For each edge of the face <F> reset the UV points to the bounding
+  // points of the parametric curve of the edge on the face.
 
-  for(Standard_Integer j = 1; j <= aShSeq.Length(); j++)
+  // Get surface of the face
+  TopLoc_Location aLoc;
+  const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(theF, aLoc);
+  // Iterate on edges and reset UV points
+  TopExp_Explorer anExpE(theF, TopAbs_EDGE);
+  for (; anExpE.More(); anExpE.Next())
   {
-    const TopoDS_Edge& E = TopoDS::Edge(aShSeq.Value(j));
-    const Handle(Geom2d_Curve)& C = aCSeq.Value(j);
-    if (C.IsNull()) continue;
-    
-    TopExp::Vertices(E,Vf,Vl);
-    if (Vf.IsNull()) {
-      Pf.SetCoord(RealLast(),RealLast());
-    }
-    else {
-      if ( Vf.Orientation() == TopAbs_INTERNAL ) {
-        continue;
-      }
-      const TColgp_SequenceOfPnt2d& seqf = theVertices(Vf);
-      if (seqf.Length() == 1) 
-        Pf = seqf(1);
-      else {
-        C->D0(aFSeq.Value(j),Pf);
-        for (i = 1; i <= seqf.Length(); i++) {
-          if (Pf.Distance(seqf(i)) <= tolerance) {
-            Pf = seqf(i);
-            break;
-          }
-        }
-      }
-    }
-    if (Vl.IsNull()) {
-      Pl.SetCoord(RealLast(),RealLast());
-    }
-    else {
-      if ( Vl.Orientation() == TopAbs_INTERNAL ) {
-        continue;
-      }
-      const TColgp_SequenceOfPnt2d& seql = theVertices(Vl);
-      if (seql.Length() == 1) 
-        Pl = seql(1);
-      else {
-        C->D0(aLSeq.Value(j),Pl);
-        for (i = 1; i <= seql.Length(); i++) {
-          if (Pl.Distance(seql(i)) <= tolerance) {
-            Pl = seql(i);
-            break;
-          }
-        }
+    const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current());
+
+    const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape());
+    if (TE->Locked())
+      return;
+
+    const TopLoc_Location aELoc = aLoc.Predivided(aE.Location());
+    // Edge representations
+    BRep_ListOfCurveRepresentation& aLCR = TE->ChangeCurves();
+    BRep_ListIteratorOfListOfCurveRepresentation itLCR(aLCR);
+    for (; itLCR.More(); itLCR.Next())
+    {
+      Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itLCR.Value());
+      if (!GC.IsNull() && GC->IsCurveOnSurface(aSurf, aELoc))
+      {
+        // Update UV points
+        GC->Update();
+        break;
       }
     }
-
-    // set the correct points
-    BRep_Tool::SetUVPoints(E,F,Pf,Pl);
   }
 }
 
-
-
 //=======================================================================
 //function : Compare
 //purpose  : 
index fb0ff959a2c722139e6ac81cdff14e5550beb776..b5113a97ea479b6f8e5a6ba74a7fb77d3d87d000 100644 (file)
@@ -73,10 +73,8 @@ class Geom_Surface;
 //! *  Update : Methods  to call when   a topology has
 //! been created to compute all missing data.
 //!
-//! * UpdateFaceUVPoints  :  Method to  update  the UV
-//! points stored   with  the edges   on a face.  This
-//! method ensure that connected  edges  have the same
-//! UV point on their common extremity.
+//! * UpdateFaceUVPoints: Method to update the UV points
+//! stored with the edges on a face.
 //!
 //! * Compare : Method to compare two vertices.
 //!
@@ -147,10 +145,10 @@ public:
   //! Update a shape, call the corect update.
   Standard_EXPORT static void Update (const TopoDS_Shape& S);
   
-  //! For  all the edges  of the face  <F> reset  the UV
-  //! points to  ensure that  connected  faces  have the
-  //! same point at there common extremity.
-  Standard_EXPORT static void UpdateFaceUVPoints (const TopoDS_Face& F);
+  //! For each edge of the face <F> reset the UV points
+  //! to the bounding points of the parametric curve of the
+  //! edge on the face.
+  Standard_EXPORT static void UpdateFaceUVPoints (const TopoDS_Face& theF);
   
   //! Removes all the triangulations of the faces of <S>
   //! and removes all polygons on triangulations of the
index 97ee7e4ad478de667a852e0b0eef79ce87144793..3b50b6da8b6606461897f6efa3ab4ac4176f6b72 100644 (file)
@@ -1,4 +1,4 @@
-puts "REQUIRED ALL: Faulty shapes in variables faulty_1 to faulty_1"
+puts "REQUIRED ALL: Faulty shapes in variables faulty_1 to faulty_2"
 
 puts "========"
 puts "OCC21246"
diff --git a/tests/bugs/modalg_7/bug29701_1 b/tests/bugs/modalg_7/bug29701_1
new file mode 100644 (file)
index 0000000..35c5dd1
--- /dev/null
@@ -0,0 +1,34 @@
+puts "========"
+puts "OCC29701"
+puts "========"
+puts ""
+#################################################
+# BRepTools::Update(Face) unexpectedly updates UV points of pcurve
+#################################################
+
+brestore [locate_data_file bug29701_brepmesh_triangle_bad_collapsed.brep] s
+
+# mesh the face
+repeat 2 {
+  if {![regexp "NoError" [incmesh s 0.1]]} {
+    puts "Error: Unable to build triangulation"
+  }
+}
+
+tcopy s copy
+
+# mesh the copy face
+repeat 2 {
+  if {![regexp "NoError" [incmesh copy 0.1]]} {
+    puts "Error: Unable to build triangulation on copy shape"
+  }
+}
+
+fixshape fixed s
+
+# mesh the fixed face
+repeat 2 {
+  if {![regexp "NoError" [incmesh fixed 0.1]]} {
+    puts "Error: Unable to build triangulation on fixed shape"
+  }
+}
diff --git a/tests/bugs/modalg_7/bug29701_2 b/tests/bugs/modalg_7/bug29701_2
new file mode 100644 (file)
index 0000000..f179c21
--- /dev/null
@@ -0,0 +1,34 @@
+puts "========"
+puts "OCC29701"
+puts "========"
+puts ""
+#################################################
+# BRepTools::Update(Face) unexpectedly updates UV points of pcurve
+#################################################
+
+brestore [locate_data_file bug29701_hullshape.brep] s
+
+# mesh the face
+repeat 2 {
+  if {![regexp "NoError" [incmesh s 0.1]]} {
+    puts "Error: Unable to build triangulation"
+  }
+}
+
+tcopy s copy
+
+# mesh the copy face
+repeat 2 {
+  if {![regexp "NoError" [incmesh copy 0.1]]} {
+    puts "Error: Unable to build triangulation on copy shape"
+  }
+}
+
+fixshape fixed s
+
+# mesh the fixed face
+repeat 2 {
+  if {![regexp "NoError" [incmesh fixed 0.1]]} {
+    puts "Error: Unable to build triangulation on fixed shape"
+  }
+}
diff --git a/tests/bugs/modalg_7/bug29701_3 b/tests/bugs/modalg_7/bug29701_3
new file mode 100644 (file)
index 0000000..cdcdfa9
--- /dev/null
@@ -0,0 +1,34 @@
+puts "========"
+puts "OCC29701"
+puts "========"
+puts ""
+#################################################
+# BRepTools::Update(Face) unexpectedly updates UV points of pcurve
+#################################################
+
+brestore [locate_data_file bug29701_Plate_B.brep] s
+
+# mesh the face
+repeat 2 {
+  if {![regexp "NoError" [incmesh s 0.1]]} {
+    puts "Error: Unable to build triangulation"
+  }
+}
+
+tcopy s copy
+
+# mesh the copy face
+repeat 2 {
+  if {![regexp "NoError" [incmesh copy 0.1]]} {
+    puts "Error: Unable to build triangulation on copy shape"
+  }
+}
+
+fixshape fixed s
+
+# mesh the fixed face
+repeat 2 {
+  if {![regexp "NoError" [incmesh fixed 0.1]]} {
+    puts "Error: Unable to build triangulation on fixed shape"
+  }
+}
index feabedf40ca69172edad1e9a09a757e55d969eb7..24b5cf71b874fa959fb5f4f4a54e8f3f66622f1a 100644 (file)
@@ -1,5 +1,5 @@
 if {[string compare $command "SplitAngle"] == 0 } {
-    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_38 "
+    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_ "
 }
 restore [locate_data_file CED_PIEUSI.brep] a
 
index c68c5730f272038cb10266ef55573bdf6e96378f..8c37d2a7ecaad44254072e75239c37678832069a 100644 (file)
@@ -1,5 +1,5 @@
 if {[string compare $command "SplitAngle"] == 0 } {
-    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_6 "
+    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_ "
 }
 restore [locate_data_file SOLMIR.brep] a
 
index 627c0372806a1280a5c40352de0728711d7de7cc..9d40d6df5dd1362cd17bc6ee9d5c9d62b50f2f89 100644 (file)
@@ -1,5 +1,5 @@
 if {[string compare $command "SplitAngle"] == 0 } {
-    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_28 "
+    puts "TODO OCC23127 ALL: Faulty shapes in variables faulty_1 to faulty_ "
 }
 
 restore [locate_data_file BPLSEITRE.brep] a