Salome HOME
fix failure of non-regression test SMESH_TEST/Grids/smesh/mesh_Projection_2D/A1
authoreap <eap@opencascade.com>
Fri, 1 Mar 2013 14:37:03 +0000 (14:37 +0000)
committereap <eap@opencascade.com>
Fri, 1 Mar 2013 14:37:03 +0000 (14:37 +0000)
 Let the helper set nodes on shape to avoid the pb with a medium nodes
 set by mistake to EDGE instead of FACE.
 The case is a triangle whose 3 nodes are on the same EDGE. The worst
 is that in this case the medium node which is logically on FACE falls
 to a straight EDGE, as the triangle is of zero area.

src/StdMeshers/StdMeshers_MEFISTO_2D.cxx

index 55091c7f9c598ba557cd8dcdf28890af4a7e16ba..150197a5152d26cb62c50463322332c0874433a2 100644 (file)
@@ -780,8 +780,7 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust,
                                         vector< const SMDS_MeshNode*>&mefistoToDS,
                                         double scalex, double scaley)
 {
-  SMESHDS_Mesh * meshDS = _helper->GetMeshDS();
-  int faceID = _helper->GetSubShapeID();
+  _helper->SetElementsOnShape( true );
 
   TopoDS_Face F = TopoDS::Face( _helper->GetSubShape() );
   Handle(Geom_Surface) S = BRep_Tool::Surface( F );
@@ -796,12 +795,7 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust,
       double v = uvst[n][1] / scaley;
       gp_Pnt P = S->Value(u, v);
 
-      SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
-      meshDS->SetNodeOnFace(node, faceID, u, v);
-
-      //MESSAGE(P.X()<<" "<<P.Y()<<" "<<P.Z());
-      mefistoToDS[n] = node;
-      //MESSAGE("NEW: "<<n<<" "<<mefistoToDS[n+1]);
+      mefistoToDS[n] = _helper->AddNode( P.X(), P.Y(), P.Z(), 0, u, v );
     }
   }
 
@@ -810,26 +804,23 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust,
   // triangle points must be in trigonometric order if face is Forward
   // else they must be put clockwise
 
-  bool triangleIsWellOriented = ( F.Orientation() == TopAbs_FORWARD );
+  int i1 = 1, i2 = 2;
+  if ( F.Orientation() != TopAbs_FORWARD )
+    std::swap( i1, i2 );
 
+  const SMDS_MeshNode * nn[3];
   for (n = 1; n <= nbt; n++)
   {
-    const SMDS_MeshNode * n1 = mefistoToDS[ nust[m++] - 1 ];
-    const SMDS_MeshNode * n2 = mefistoToDS[ nust[m++] - 1 ];
-    const SMDS_MeshNode * n3 = mefistoToDS[ nust[m++] - 1 ];
+    nn[ 0 ] = mefistoToDS[ nust[m++] - 1 ];
+    nn[ 1 ] = mefistoToDS[ nust[m++] - 1 ];
+    nn[ 2 ] = mefistoToDS[ nust[m++] - 1 ];
+    m++;
 
     // avoid creating degenetrated faces
-    bool isDegen = ( _helper->HasDegeneratedEdges() && ( n1 == n2 || n1 == n3 || n2 == n3 ));
+    bool isDegen = ( _helper->HasDegeneratedEdges() &&
+                     ( nn[0] == nn[1] || nn[1] == nn[2] || nn[2] == nn[0] ));
     if ( !isDegen )
-    {
-      SMDS_MeshElement * elt;
-      if (triangleIsWellOriented)
-        elt = _helper->AddFace(n1, n2, n3);
-      else
-        elt = _helper->AddFace(n1, n3, n2);
-      meshDS->SetMeshElementOnShape(elt, faceID);
-    }
-    m++;
+      _helper->AddFace( nn[0], nn[i1], nn[i2] );
   }
 
   // remove bad elements built on vertices shared by wires
@@ -849,7 +840,7 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust,
           nbSame++;
       if (nbSame > 1) {
         MESSAGE( "RM bad element " << elem->GetID());
-        meshDS->RemoveElement( elem );
+        _helper->GetMeshDS()->RemoveElement( elem );
       }
     }
   }