Salome HOME
Implementation of new pattern mapping algorthm (mesh refinement)
authorsan <san@opencascade.com>
Thu, 20 Jan 2005 14:44:17 +0000 (14:44 +0000)
committersan <san@opencascade.com>
Thu, 20 Jan 2005 14:44:17 +0000 (14:44 +0000)
idl/SMESH_Pattern.idl
src/SMDS/SMDS_Mesh.cxx
src/SMESH/SMESH_Pattern.cxx
src/SMESH/SMESH_Pattern.hxx
src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx
src/SMESH_I/SMESH_Pattern_i.cxx
src/SMESH_I/SMESH_Pattern_i.hxx

index f02fe432680749dff4870da88419de3490281c08..fa1d7dd119bba1b3159e12e7eb15d19664af21d3 100644 (file)
@@ -174,8 +174,9 @@ module SMESH
 
     /*!
      * Return nodal connectivity of the elements of the pattern
 
     /*!
      * Return nodal connectivity of the elements of the pattern
+     * or of all elements to be crated
      */
      */
-    array_of_long_array GetElementPoints();
+    array_of_long_array GetElementPoints(in boolean all);
   };
 };
 
   };
 };
 
index aeec4521f909d4aad0349f475cba71e36583eedd..763d61c47eb53d493a7a87c896eea73c3c86dd48 100644 (file)
@@ -1604,9 +1604,7 @@ static set<const SMDS_MeshElement*> * intersectionOfSets(
 static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
 {
        int numberOfSets=element->NbNodes();
 static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
 {
        int numberOfSets=element->NbNodes();
-       auto_ptr<set<const SMDS_MeshElement*> > pInitSet
-         (new set<const SMDS_MeshElement*>[numberOfSets]);
-       set<const SMDS_MeshElement*> *initSet = &(*pInitSet);
+       set<const SMDS_MeshElement*> *initSet = new set<const SMDS_MeshElement*>[numberOfSets];
 
        SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
 
 
        SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
 
@@ -1622,8 +1620,9 @@ static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement *
 
                i++;
        }
 
                i++;
        }
-       
-       return intersectionOfSets(initSet, numberOfSets);
+       set<const SMDS_MeshElement*> *retSet=intersectionOfSets(initSet, numberOfSets);
+        delete [] initSet;
+       return retSet;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index 86f1d52ab1688686683fce61988d215bd7a9e1f8..432e5416115ec9f4fe5cd3e141e12f8a09cd06e1 100644 (file)
@@ -3306,17 +3306,37 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh)
       }
     }
     // set element on a shape
       }
     }
     // set element on a shape
-    if ( elem && onMeshElements )
+    if ( elem && onMeshElements ) // applied to mesh elements
     {
       int elemIndex = iElem / nbElems;
     {
       int elemIndex = iElem / nbElems;
-      if ( shapeIDs[ elemIndex ] > 0 )
-        aMeshDS->SetMeshElementOnShape( elem, shapeIDs[ elemIndex ] );
+      int shapeID = shapeIDs[ elemIndex ];
+      if ( shapeID > 0 ) {
+        aMeshDS->SetMeshElementOnShape( elem, shapeID );
+        // set nodes on a shape
+        TopoDS_Shape S = aMeshDS->IndexToShape( shapeID );
+        if ( S.ShapeType() == TopAbs_SOLID ) {
+          TopoDS_Iterator shellIt( S );
+          if ( shellIt.More() )
+            shapeID = aMeshDS->ShapeToIndex( shellIt.Value() );
+        }
+        SMDS_ElemIteratorPtr noIt = elem->nodesIterator();
+        while ( noIt->more() ) {
+          SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>
+            ( static_cast<const SMDS_MeshNode*>( noIt->next() ));
+          if ( !node->GetPosition() || !node->GetPosition()->GetShapeId() ) {
+            if ( S.ShapeType() == TopAbs_FACE )
+              aMeshDS->SetNodeOnFace( node, shapeID );
+            else
+              aMeshDS->SetNodeInVolume( node, shapeID );
+          }
+        }
+      }
       // add elem in groups
       list< SMESHDS_Group* >::iterator g = groups[ elemIndex ].begin();
       for ( ; g != groups[ elemIndex ].end(); ++g )
         (*g)->SMDSGroup().Add( elem );
     }
       // add elem in groups
       list< SMESHDS_Group* >::iterator g = groups[ elemIndex ].begin();
       for ( ; g != groups[ elemIndex ].end(); ++g )
         (*g)->SMDSGroup().Add( elem );
     }
-    if ( elem && !myShape.IsNull() )
+    if ( elem && !myShape.IsNull() ) // applied to shape
       aMeshDS->SetMeshElementOnShape( elem, myShape );
   }
 
       aMeshDS->SetMeshElementOnShape( elem, myShape );
   }
 
@@ -3342,7 +3362,7 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh)
       }
       elemIDs.push_back( myElements[ i ]->GetID() );
     }
       }
       elemIDs.push_back( myElements[ i ]->GetID() );
     }
-    // remove refined elements and their nodes
+    // remove refined elements
     editor.Remove( elemIDs, false );
   }
 
     editor.Remove( elemIDs, false );
   }
 
@@ -3768,9 +3788,13 @@ bool SMESH_Pattern::GetMappedPoints ( list< const gp_XYZ * > & thePoints ) const
       thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
   }
   else { // applied to mesh elements
       thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
   }
   else { // applied to mesh elements
+    const gp_XYZ * definedXYZ = & myPoints[ myKeyPointIDs.front() ].myXYZ.XYZ();
     vector<gp_XYZ>::const_iterator xyz = myXYZ.begin();
     for ( ; xyz != myXYZ.end(); ++xyz )
     vector<gp_XYZ>::const_iterator xyz = myXYZ.begin();
     for ( ; xyz != myXYZ.end(); ++xyz )
-      thePoints.push_back( & (*xyz) );
+      if ( !isDefined( *xyz ))
+        thePoints.push_back( definedXYZ );
+      else
+        thePoints.push_back( & (*xyz) );
   }
   return !thePoints.empty();
 }
   }
   return !thePoints.empty();
 }
index 0a54cfa711b7dc4e07225f590e6fc4244bb39535..670578ce459d1e04bfb6eab8028309fb57c9d848 100644 (file)
@@ -190,8 +190,8 @@ class SMESH_Pattern {
   // Return indices of key-points within the sequences returned by
   // GetPoints() and GetMappedPoints()
   
   // Return indices of key-points within the sequences returned by
   // GetPoints() and GetMappedPoints()
   
-  const std::list< std::list< int > >& GetElementPointIDs () const
-  { return myElemXYZIDs.empty() ? myElemPointIDs : myElemXYZIDs; }
+  const std::list< std::list< int > >& GetElementPointIDs (bool applied) const
+  { return myElemXYZIDs.empty() || !applied ? myElemPointIDs : myElemXYZIDs; }
   // Return nodal connectivity of the elements of the pattern
 
   void DumpPoints() const;
   // Return nodal connectivity of the elements of the pattern
 
   void DumpPoints() const;
index 3e63d654f9b34945a32fc5fa50cd97a4defff4dd..fd903bbc62b8126813ed9a5d6388b611176b0402 100755 (executable)
@@ -677,7 +677,7 @@ void SMESHGUI_CreatePatternDlg::displayPreview()
     {\r
       SMESH::point_array_var pnts = myPattern->GetPoints();\r
       SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();\r
     {\r
       SMESH::point_array_var pnts = myPattern->GetPoints();\r
       SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();\r
-      SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints();\r
+      SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);\r
 \r
       if ( pnts->length()       == 0 ||\r
            keyPoints->length()  == 0 ||\r
 \r
       if ( pnts->length()       == 0 ||\r
            keyPoints->length()  == 0 ||\r
index fa664b4a83208e2f6e8bfd6f6468255b7dd44dec..d0b8bd2161188c900139d0b9ce6a5fee5d7a2963 100644 (file)
@@ -374,11 +374,11 @@ SMESH::long_array* SMESH_Pattern_i::GetKeyPoints()
 //purpose  : 
 //=======================================================================
 
 //purpose  : 
 //=======================================================================
 
-SMESH::array_of_long_array* SMESH_Pattern_i::GetElementPoints()
+SMESH::array_of_long_array* SMESH_Pattern_i::GetElementPoints(CORBA::Boolean applied)
 {
   SMESH::array_of_long_array_var arrayOfArray = new SMESH::array_of_long_array;
 
 {
   SMESH::array_of_long_array_var arrayOfArray = new SMESH::array_of_long_array;
 
-  const list< list< int > >& listOfIdList = myPattern.GetElementPointIDs();
+  const list< list< int > >& listOfIdList = myPattern.GetElementPointIDs(applied);
   arrayOfArray->length( listOfIdList.size() );
   list< list< int > >::const_iterator llIt = listOfIdList.begin();
   for ( int i = 0 ; llIt != listOfIdList.end(); llIt++, i++ )
   arrayOfArray->length( listOfIdList.size() );
   list< list< int > >::const_iterator llIt = listOfIdList.begin();
   for ( int i = 0 ; llIt != listOfIdList.end(); llIt++, i++ )
index 7bcbdff6634b6077c4c4f9be4c5931d133c017e6..d0a9656bd288b4de626bdee1a261c0b49b7e0cfd 100644 (file)
@@ -87,7 +87,7 @@ class SMESH_Pattern_i:
 
   SMESH::long_array* GetKeyPoints();
 
 
   SMESH::long_array* GetKeyPoints();
 
-  SMESH::array_of_long_array* GetElementPoints();
+  SMESH::array_of_long_array* GetElementPoints(CORBA::Boolean applied);
 
 
  private:
 
 
  private: