Salome HOME
0021330: EDF 1919 SMESH: Convert to quadratic gives wrong elements
authoreap <eap@opencascade.com>
Thu, 3 Nov 2011 13:45:33 +0000 (13:45 +0000)
committereap <eap@opencascade.com>
Thu, 3 Nov 2011 13:45:33 +0000 (13:45 +0000)
      Fix GetMediumPos()

src/SMESH/SMESH_MesherHelper.cxx
src/SMESH/SMESH_MesherHelper.hxx

index eba6db261caa420e17a105739efdee79334505a4..34cef148deca4712e7e86afcb159b758061a334c 100644 (file)
@@ -895,7 +895,8 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge&   E,
 
 //=======================================================================
 //function : GetMediumPos
-//purpose  : Return index and type of the shape to set a medium node on
+//purpose  : Return index and type of the shape  (EDGE or FACE only) to
+//          set a medium node on
 //=======================================================================
 
 std::pair<int, TopAbs_ShapeEnum> SMESH_MesherHelper::GetMediumPos(const SMDS_MeshNode* n1,
@@ -910,42 +911,40 @@ std::pair<int, TopAbs_ShapeEnum> SMESH_MesherHelper::GetMediumPos(const SMDS_Mes
     shapeType = myShape.ShapeType();
     shapeID   = myShapeID;
   }
+  else if ( n1->getshapeId() == n2->getshapeId() )
+  {
+    shapeID = n2->getshapeId();
+    shape = GetSubShapeByNode( n1, GetMeshDS() );
+  }
   else
   {
-    const SMDS_PositionPtr Pos1 = n1->GetPosition();
-    const SMDS_PositionPtr Pos2 = n2->GetPosition();
+    const SMDS_TypeOfPosition Pos1 = n1->GetPosition()->GetTypeOfPosition();
+    const SMDS_TypeOfPosition Pos2 = n2->GetPosition()->GetTypeOfPosition();
 
-    if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE )
-    {
-      shapeType = TopAbs_FACE;
-      shapeID   = n1->getshapeId();
-    }
-    else if( Pos2->GetTypeOfPosition()==SMDS_TOP_FACE )
+    if ( Pos1 == SMDS_TOP_3DSPACE || Pos2 == SMDS_TOP_3DSPACE )
     {
-      shapeType = TopAbs_FACE;
-      shapeID   = n2->getshapeId();
     }
-    else if (Pos1->GetTypeOfPosition()==SMDS_TOP_3DSPACE ||
-             Pos2->GetTypeOfPosition()==SMDS_TOP_3DSPACE )
+    else if ( Pos1 == SMDS_TOP_FACE || Pos2 == SMDS_TOP_FACE )
     {
-    }
-    else if ( Pos1->GetTypeOfPosition()==SMDS_TOP_EDGE &&
-              Pos2->GetTypeOfPosition()==SMDS_TOP_EDGE )
-    {
-      if ( n1->getshapeId() == n2->getshapeId() )
+      if ( Pos1 != SMDS_TOP_FACE || Pos2 != SMDS_TOP_FACE )
       {
-        shapeType = TopAbs_EDGE;
-        shapeID   = n1->getshapeId();
-      }
-      else
-      {
-        TopoDS_Shape E1 = GetSubShapeByNode( n1, GetMeshDS() );
-        TopoDS_Shape E2 = GetSubShapeByNode( n2, GetMeshDS() );
-        shape = GetCommonAncestor( E1, E2, *myMesh, TopAbs_FACE );
+        if ( Pos1 != SMDS_TOP_FACE ) std::swap( n1,n2 );
+        TopoDS_Shape F = GetSubShapeByNode( n1, GetMeshDS() );
+        TopoDS_Shape S = GetSubShapeByNode( n2, GetMeshDS() );
+        if ( IsSubShape( S, F ))
+        {
+          shapeType = TopAbs_FACE;
+          shapeID   = n1->getshapeId();
+        }
       }
     }
-    else if ( Pos1->GetTypeOfPosition()==SMDS_TOP_VERTEX &&
-              Pos2->GetTypeOfPosition()==SMDS_TOP_VERTEX )
+    else if ( Pos1 == SMDS_TOP_EDGE && Pos2 == SMDS_TOP_EDGE )
+    {
+      TopoDS_Shape E1 = GetSubShapeByNode( n1, GetMeshDS() );
+      TopoDS_Shape E2 = GetSubShapeByNode( n2, GetMeshDS() );
+      shape = GetCommonAncestor( E1, E2, *myMesh, TopAbs_FACE );
+    }
+    else if ( Pos1 == SMDS_TOP_VERTEX && Pos2 == SMDS_TOP_VERTEX )
     {
       TopoDS_Shape V1 = GetSubShapeByNode( n1, GetMeshDS() );
       TopoDS_Shape V2 = GetSubShapeByNode( n2, GetMeshDS() );
@@ -954,7 +953,7 @@ std::pair<int, TopAbs_ShapeEnum> SMESH_MesherHelper::GetMediumPos(const SMDS_Mes
     }
     else // VERTEX and EDGE
     {
-      if ( Pos1->GetTypeOfPosition()!=SMDS_TOP_VERTEX ) std::swap( n1,n2 );
+      if ( Pos1 != SMDS_TOP_VERTEX ) std::swap( n1,n2 );
       TopoDS_Shape V = GetSubShapeByNode( n1, GetMeshDS() );
       TopoDS_Shape E = GetSubShapeByNode( n2, GetMeshDS() );
       if ( IsSubShape( V, E ))
@@ -963,9 +962,11 @@ std::pair<int, TopAbs_ShapeEnum> SMESH_MesherHelper::GetMediumPos(const SMDS_Mes
         shape = GetCommonAncestor( V, E, *myMesh, TopAbs_FACE );
     }
   }
+
   if ( !shape.IsNull() )
   {
-    shapeID = GetMeshDS()->ShapeToIndex( shape );
+    if ( shapeID < 1 )
+      shapeID = GetMeshDS()->ShapeToIndex( shape );
     shapeType = shape.ShapeType();
   }
   return make_pair( shapeID, shapeType );
@@ -999,9 +1000,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
 
   // get type of shape for the new medium node
   int faceID = -1, edgeID = -1;
-  const SMDS_PositionPtr Pos1 = n1->GetPosition();
-  const SMDS_PositionPtr Pos2 = n2->GetPosition();
-
   TopoDS_Edge E; double u [2];
   TopoDS_Face F; gp_XY  uv[2];
   bool uvOK[2] = { false, false };
@@ -1017,10 +1015,11 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
   }
   else if ( pos.second == TopAbs_EDGE )
   {
-    if ( Pos1->GetTypeOfPosition()==SMDS_TOP_EDGE &&
-         Pos2->GetTypeOfPosition()==SMDS_TOP_EDGE &&
-         n1->getshapeId() != n2->getshapeId() ) // issue 0021006
-    return getMediumNodeOnComposedWire(n1,n2,force3d);
+    if ( n1->GetPosition()->GetTypeOfPosition()==SMDS_TOP_EDGE &&
+         n2->GetPosition()->GetTypeOfPosition()==SMDS_TOP_EDGE &&
+         n1->getshapeId() != n2->getshapeId() )
+      // issue 0021006
+      return getMediumNodeOnComposedWire(n1,n2,force3d);
     
     E = TopoDS::Edge(meshDS->IndexToShape( edgeID = pos.first ));
     u[0] = GetNodeU(E,n1,n2, force3d ? 0 : &uvOK[0]);
index 676cbf2e44773fd967f0989eee90452d793d4cee..e5ec87a14f5bcb64381cbd825b1aa0ba67623294 100644 (file)
@@ -461,7 +461,7 @@ public:
                                      const SMDS_MeshNode* n2,
                                      const bool force3d);
   /*!
-   * \brief Return index and type of the shape to set a medium node on
+   * \brief Return index and type of the shape (EDGE or FACE only) to set a medium node on
    */
   std::pair<int, TopAbs_ShapeEnum> GetMediumPos(const SMDS_MeshNode* n1,
                                                 const SMDS_MeshNode* n2);