0023409: Tricheck command doesn't report problem when triangulation has unexpected...
authoroan <oan@opencascade.com>
Fri, 7 Sep 2012 09:58:12 +0000 (13:58 +0400)
committeroan <oan@opencascade.com>
Fri, 7 Sep 2012 09:58:12 +0000 (13:58 +0400)
Tricheck command improvement for checking triangulation holes on free links
More obvious error message
Added test case bugs demo CR23409
Modified test case offset wire_closed_outside_0_005 G7

src/BRepMesh/BRepMesh_Edge.cdl
src/BRepMesh/BRepMesh_Edge.lxx
src/MeshTest/MeshTest_PluginCommands.cxx
tests/bugs/demo/CR23409 [new file with mode: 0755]
tests/offset/wire_closed_outside_0_005/G7 [changed mode: 0644->0755]

index 83b1d7ad5589a6332b9fb31bb0ea2d1f6f0e67ea..4d6c88d6a991ec83c524d32a79c15b20889a9019 100755 (executable)
@@ -30,7 +30,11 @@ uses    Boolean from Standard,
         DegreeOfFreedom from BRepMesh
 
 
-is          Create         (vDebut    : Integer from Standard;
+is            Create
+              returns Edge from BRepMesh;
+                 ---C++: inline
+                 
+              Create       (vDebut    : Integer from Standard;
                             vFin      : Integer from Standard;
                             canMove   : DegreeOfFreedom from BRepMesh)
               ---Purpose: Contructs a link beetween to vertices.
index 3f726aea70468541b45a529545e5a5f12c6ed14c..ebfe78d068ff7330ac033adb1cec6bf6ec99dd40 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
+inline BRepMesh_Edge::BRepMesh_Edge()
+: myFirstNode(-1),
+  myLastNode(-1),
+  myMovability(BRepMesh_Deleted)
+{
+}
 
 inline Standard_Integer  BRepMesh_Edge::FirstNode()const 
 {
index 98051763e41ab9eb2ee15b09a8eb5bddd292adf2..93ab93639066450ef01f22f4bc7c72d5b914d43b 100755 (executable)
 #include <Poly_Polygon3D.hxx>
 #include <Poly_Polygon2D.hxx>
 #include <Standard.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <Poly_PolygonOnTriangulation.hxx>
+#include <TopoDS_Face.hxx>
+#include <BRepMesh_Edge.hxx>
+#include <NCollection_Map.hxx>
 
 static Standard_Integer mpnames           (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer mpsetdefaultname  (Draw_Interpretor& , Standard_Integer , const char** );
@@ -330,6 +336,11 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
 }
 
 //#######################################################################
+Standard_Boolean IsEqual(const BRepMesh_Edge& theFirst, const BRepMesh_Edge& theSecond) 
+{
+  return theFirst.IsEqual(theSecond);
+}
+
 static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
 {
   if (n < 2) return 1;
@@ -354,12 +365,15 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       Standard_Integer iF = aCheck.GetFaceNumWithFL(k);
       nbFree += nbEdge;
       di << "free links of face " << iF << "\n";
-      const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iF));
+
+      const TopoDS_Shape& aShape = aMapF.FindKey(iF);
+      const TopoDS_Face& aFace = TopoDS::Face(aShape);
       TopLoc_Location aLoc;
       Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
       const TColgp_Array1OfPnt& aPoints = aT->Nodes();
       const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
       const gp_Trsf& trsf = aLoc.Transformation();
+
       TColgp_Array1OfPnt pnts(1,2);
       TColgp_Array1OfPnt2d pnts2d(1,2);
       for (i=1; i <= nbEdge; i++) {
@@ -420,11 +434,87 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
   }
 
   // output errors summary to DRAW
-  if ( nbFree > 0 || nbErr > 0 || nbAsync > 0 || nbFreeNodes > 0 )
+  if ( nbFree > 0 || nbErr > 0 || nbAsync > 0 || nbFreeNodes > 0)
     di << "Free_links " << nbFree
        << " Cross_face_errors " << nbErr
        << " Async_edges " << nbAsync 
        << " Free_nodes " << nbFreeNodes << "\n";
+
+
+  Standard_Integer aFaceId = 1;
+  TopExp_Explorer aFaceExp(shape, TopAbs_FACE);
+  for ( ; aFaceExp.More(); aFaceExp.Next(), ++aFaceId)
+  {
+    const TopoDS_Shape& aShape = aFaceExp.Current();
+    const TopoDS_Face& aFace = TopoDS::Face(aShape);
+
+    TopLoc_Location aLoc;
+    Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
+
+    // Iterate boundary edges
+    NCollection_Map<BRepMesh_Edge> aBoundaryEdgeMap;
+    TopExp_Explorer anExp(aShape, TopAbs_EDGE);
+    for ( ; anExp.More(); anExp.Next() )
+    {
+      TopLoc_Location anEdgeLoc;
+      const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
+      Handle(Poly_PolygonOnTriangulation) aPoly = BRep_Tool::PolygonOnTriangulation(anEdge, aT, aLoc);
+      if (aPoly.IsNull())
+      {
+        continue;
+      }
+
+      const TColStd_Array1OfInteger& anIndices = aPoly->Nodes();
+      Standard_Integer aLower  = anIndices.Lower(); 
+      Standard_Integer anUpper = anIndices.Upper();
+
+      Standard_Integer aPrevNode = -1;
+      for (Standard_Integer i = aLower; i <= anUpper; ++i)
+      {
+        Standard_Integer aNodeIdx = anIndices.Value(i);
+        if (i != aLower)
+        {
+          BRepMesh_Edge aLink(aPrevNode, aNodeIdx, BRepMesh_Frontier);
+          aBoundaryEdgeMap.Add(aLink);
+        }
+        aPrevNode = aNodeIdx;
+      }
+    }
+
+    if (aBoundaryEdgeMap.Size() == 0)
+    {
+      break;
+    }
+
+    const Poly_Array1OfTriangle& aTris = aT->Triangles();
+    NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
+    Standard_Integer aTriNum = aTris.Length();
+    for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
+    {
+      const Poly_Triangle& aTri = aTris(aTriIndx);
+      Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
+
+      for (Standard_Integer i = 1; i <= 3; ++i)
+      {
+        Standard_Integer aLastId  = aTriNodes[i % 3];
+        Standard_Integer aFirstId = aTriNodes[i - 1];
+
+        BRepMesh_Edge aLink(aFirstId, aLastId, BRepMesh_Free);
+        if (!aBoundaryEdgeMap.Contains(aLink))
+        {
+          if (!aFreeEdgeMap.Add(aLink))
+          {
+            aFreeEdgeMap.Remove(aLink);
+          }
+        }
+      }
+    }
+
+    if (aFreeEdgeMap.Size() != 0)
+    {
+      di << "Not connected mesh inside face " << aFaceId << "\n";
+    }
+  }
   return 0;
 }
 
diff --git a/tests/bugs/demo/CR23409 b/tests/bugs/demo/CR23409
new file mode 100755 (executable)
index 0000000..378d4bd
--- /dev/null
@@ -0,0 +1,34 @@
+puts "============"
+puts "CR23409"
+puts "============"
+puts ""
+###################################################################################
+# Tricheck command doesn't report problem when triangulation has unexpected holes
+###################################################################################
+
+restore [locate_data_file bug23167_f397.brep] result
+vinit
+vsetdispmode 1
+vdisplay result
+axo
+fit
+isos result 0
+triangles result
+set info_bad [tricheck result]
+if { [regexp "Not connected mesh inside face 1" $info_bad] != 1 } {
+    puts "Error : Tricheck command doesn't report message"
+}
+
+tclean result
+incmesh result 0.01
+set info_good [tricheck result]
+if { [string compare $info_good "" ] != 0 } {
+    puts "Error : Tricheck command works incorrect when shape looks good"
+}
+
+set 3dviewer 1
+
+
+
+
+
old mode 100644 (file)
new mode 100755 (executable)
index 500f77f..ad511a2
@@ -1,3 +1,5 @@
+puts "TODO ?OCC23068 ALL: Error : result is not a topological shape!!!"
+puts "TODO ?OCC23068 ALL: Error : The offset can not be build."
 restore [locate_data_file offset_wire_084.brep] s
 
 set length 18.1766