Salome HOME
Merge branch 'master' into V7_5_BR
authorvsr <vsr@opencascade.com>
Mon, 12 Jan 2015 10:24:59 +0000 (13:24 +0300)
committervsr <vsr@opencascade.com>
Mon, 12 Jan 2015 10:24:59 +0000 (13:24 +0300)
1  2 
src/SMESH/SMESH_MeshEditor.cxx

index a625ba50a2d6297c4ab3cfc364b5ba0f3d40a7d6,d334c7d5c40e60433ecc64879680d7621372b3a3..7083261a9226c5625629d12ffd14c0b1a06e74b5
@@@ -50,7 -50,6 +50,7 @@@
  #include <Basics_OCCTVersion.hxx>
  
  #include "utilities.h"
 +#include "chrono.hxx"
  
  #include <BRepAdaptor_Surface.hxx>
  #include <BRepBuilderAPI_MakeEdge.hxx>
@@@ -10229,6 -10228,7 +10229,7 @@@ bool SMESH_MeshEditor::doubleNodes( SME
        {
          // duplicate node
          aNewNode = theMeshDS->AddNode( aCurrNode->X(), aCurrNode->Y(), aCurrNode->Z() );
+         copyPosition( aCurrNode, aNewNode );
          theNodeNodeMap[ aCurrNode ] = aNewNode;
          myLastCreatedNodes.Append( aNewNode );
        }
      if ( theIsDoubleElem )
        AddElement(newNodes, anElem->GetType(), anElem->IsPoly());
      else
-       {
-       MESSAGE("ChangeElementNodes");
        theMeshDS->ChangeElementNodes( anElem, &newNodes[ 0 ], anElem->NbNodes() );
-       }
      res = true;
    }
    return res;
    \brief Creates a hole in a mesh by doubling the nodes of some particular elements
    \param theNodes - identifiers of nodes to be doubled
    \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
-          nodes. If list of element identifiers is empty then nodes are doubled but
-          they not assigned to elements
+   nodes. If list of element identifiers is empty then nodes are doubled but
+   they not assigned to elements
    \return TRUE if operation has been completed successfully, FALSE otherwise
  */
  //================================================================================
@@@ -10292,6 -10290,7 +10291,7 @@@ bool SMESH_MeshEditor::DoubleNodes( con
      const SMDS_MeshNode* aNewNode = aMeshDS->AddNode( aNode->X(), aNode->Y(), aNode->Z() );
      if ( aNewNode )
      {
+       copyPosition( aNode, aNewNode );
        anOldNodeToNewNode[ aNode ] = aNewNode;
        myLastCreatedNodes.Append( aNewNode );
      }
@@@ -10910,6 -10909,7 +10910,7 @@@ bool SMESH_MeshEditor::DoubleNodesOnGro
                          }
                        double *coords = grid->GetPoint(oldId);
                        SMDS_MeshNode *newNode = meshDS->AddNode(coords[0], coords[1], coords[2]);
+                       copyPosition( meshDS->FindNodeVtk( oldId ), newNode );
                        int newId = newNode->getVtkId();
                        nodeDomains[oldId][idom] = newId; // cloned node for other domains
                        //MESSAGE("-+-+-c     oldNode " << oldId << " domain " << idomain << " newNode " << newId << " domain " << idom << " size=" <<nodeDomains[oldId].size());
          }
      }
  
+   // Remove empty groups (issue 0022812)
+   std::map<std::string, SMESH_Group*>::iterator name_group = mapOfJunctionGroups.begin();
+   for ( ; name_group != mapOfJunctionGroups.end(); ++name_group )
+   {
+     if ( name_group->second && name_group->second->GetGroupDS()->IsEmpty() )
+       myMesh->RemoveGroup( name_group->second->GetGroupDS()->GetID() );
+   }
    meshDS->CleanDownWardConnectivity(); // Mesh has been modified, downward connectivity is no more usable, free memory
    grid->BuildLinks();
  
@@@ -11315,6 -11323,7 +11324,7 @@@ bool SMESH_MeshEditor::CreateFlatElemen
                if (!clonedNodes.count(node))
                  {
                    clone = meshDS->AddNode(node->X(), node->Y(), node->Z());
+                   copyPosition( node, clone );
                    clonedNodes[node] = clone;
                  }
                else
                    if (!intermediateNodes.count(node))
                      {
                        inter = meshDS->AddNode(node->X(), node->Y(), node->Z());
+                       copyPosition( node, inter );
                        intermediateNodes[node] = inter;
                      }
                    else
@@@ -12275,3 -12285,45 +12286,45 @@@ int SMESH_MeshEditor::MakeBoundaryMesh(
    }
    return nbAddedBnd;
  }
+ //================================================================================
+ /*!
+  * \brief Copy node position and set \a to node on the same geometry
+  */
+ //================================================================================
+ void SMESH_MeshEditor::copyPosition( const SMDS_MeshNode* from,
+                                      const SMDS_MeshNode* to )
+ {
+   if ( !from || !to ) return;
+   SMDS_PositionPtr pos = from->GetPosition();
+   if ( !pos || from->getshapeId() < 1 ) return;
+   switch ( pos->GetTypeOfPosition() )
+   {
+   case SMDS_TOP_3DSPACE: break;
+   case SMDS_TOP_FACE:
+   {
+     const SMDS_FacePosition* fPos = static_cast< const SMDS_FacePosition* >( pos );
+     GetMeshDS()->SetNodeOnFace( to, from->getshapeId(),
+                                 fPos->GetUParameter(), fPos->GetVParameter() );
+     break;
+   }
+   case SMDS_TOP_EDGE:
+   {
+     // WARNING: it is dangerous to set equal nodes on one EDGE!!!!!!!!
+     const SMDS_EdgePosition* ePos = static_cast< const SMDS_EdgePosition* >( pos );
+     GetMeshDS()->SetNodeOnEdge( to, from->getshapeId(), ePos->GetUParameter() );
+     break;
+   }
+   case SMDS_TOP_VERTEX:
+   {
+     GetMeshDS()->SetNodeOnVertex( to, from->getshapeId() );
+     break;
+   }
+   case SMDS_TOP_UNSPEC:
+   default:;
+   }
+ }