0023184: Bad face tessellation result
authoroan <oan@opencascade.com>
Fri, 22 Mar 2013 13:34:37 +0000 (17:34 +0400)
committeroan <oan@opencascade.com>
Fri, 22 Mar 2013 13:34:37 +0000 (17:34 +0400)
Consider BSplineKnots to achieve better tessellation result
Adding test cases for this fix

src/BRepMesh/BRepMesh_FastDiscret.cxx
tests/bugs/mesh/bug23184_1 [new file with mode: 0755]
tests/bugs/mesh/bug23184_2 [new file with mode: 0755]

index 1d4d927..a2e543a 100755 (executable)
@@ -990,8 +990,39 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge&                  theEdge,
 
       TopLoc_Location L;
       Standard_Integer nbpmin = 2;
-      if (cons.GetType() == GeomAbs_Circle) nbpmin = 4; //OCC287
-      BRepMesh_GeomTool GT(cons, wFirst, wLast, 0.5*myAngle, otherdefedge, nbpmin);
+      const GeomAbs_CurveType aCurveType = cons.GetType();
+      if ( aCurveType == GeomAbs_Circle )
+        nbpmin = 4; //OCC287
+
+      BRepMesh_GeomTool GT(cons, wFirst, wLast, 0.5 * myAngle, otherdefedge, nbpmin);
+
+      if ( aCurveType == GeomAbs_BSplineCurve )
+      {
+        const Standard_Integer aNbInt = cons.NbIntervals( GeomAbs_C1 );
+        if ( aNbInt > 0 )
+        {
+          TColStd_Array1OfReal anIntervals( 1, aNbInt + 1 );
+          cons.Intervals( anIntervals, GeomAbs_C1 );
+          for ( Standard_Integer aIntIt = 1; aIntIt <= aNbInt; ++aIntIt )
+          {
+            const Standard_Real& aStartInt = anIntervals.Value( aIntIt );
+            const Standard_Real& anEndInt  = anIntervals.Value( aIntIt + 1 );
+
+            BRepMesh_GeomTool aDetalizator( cons, aStartInt, anEndInt,
+              0.5 * myAngle, otherdefedge, nbpmin );
+
+            Standard_Integer aNbAddNodes = aDetalizator.NbPoints();
+            for ( Standard_Integer aNodeIt = 1; aNodeIt <= aNbAddNodes; ++aNodeIt )
+            {
+              Standard_Real aParam;
+              gp_Pnt        aPoint3d;
+              gp_Pnt2d      aPoint2d;
+              aDetalizator.Value( cons, theGFace, aNodeIt, aParam, aPoint3d, aPoint2d );
+              GT.AddPoint( aPoint3d, aParam, Standard_False );
+            }
+          }
+        }
+      }
 
       // PTv, chl/922/G9, Take into account internal vertices
       // it is necessary for internal edges, which do not split other edges, by their vertex
diff --git a/tests/bugs/mesh/bug23184_1 b/tests/bugs/mesh/bug23184_1
new file mode 100755 (executable)
index 0000000..e8b51c0
--- /dev/null
@@ -0,0 +1,24 @@
+puts "========================"
+puts "CR23184"
+puts "========================"
+puts ""
+#######################################################################
+# Bad face tessellation result
+#######################################################################
+
+brestore [locate_data_file bug23184_tessface2.brep] result
+
+checkshape result
+
+tclean result
+
+set Deflection 0.045
+
+incmesh result ${Deflection}
+
+vinit
+vsetdispmode 1
+vdisplay result
+vfit
+
+set only_screen 1
diff --git a/tests/bugs/mesh/bug23184_2 b/tests/bugs/mesh/bug23184_2
new file mode 100755 (executable)
index 0000000..0bc02eb
--- /dev/null
@@ -0,0 +1,24 @@
+puts "========================"
+puts "CR23184"
+puts "========================"
+puts ""
+#######################################################################
+# Bad face tessellation result
+#######################################################################
+
+brestore [locate_data_file bug23184_tessface.brep] result
+
+checkshape result
+
+tclean result
+
+set Deflection 0.045
+
+incmesh result ${Deflection}
+
+vinit
+vsetdispmode 1
+vdisplay result
+vfit
+
+set only_screen 1