Salome HOME
+ SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes,
authoreap <eap@opencascade.com>
Mon, 4 Oct 2010 11:25:52 +0000 (11:25 +0000)
committereap <eap@opencascade.com>
Mon, 4 Oct 2010 11:25:52 +0000 (11:25 +0000)
+  SMDS_MeshVolume* AddPolyhedralVolume (const std::vector<const SMDS_MeshNode*>& nodes,

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

index abc61c11483413f5547855cdfa7c9b67f1a4d2b5..0a3887f702fd5eec16baeb1b22b1573390d3d2ba 100644 (file)
@@ -1089,6 +1089,45 @@ SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1,
   return elem;
 }
 
+//=======================================================================
+//function : AddPolygonalFace
+//purpose  : Creates polygon, with additional nodes in quadratic mesh
+//=======================================================================
+
+SMDS_MeshFace* SMESH_MesherHelper::AddPolygonalFace (const vector<const SMDS_MeshNode*>& nodes,
+                                                     const int                           id,
+                                                     const bool                          force3d)
+{
+  SMESHDS_Mesh * meshDS = GetMeshDS();
+  SMDS_MeshFace* elem = 0;
+
+  if(!myCreateQuadratic) {
+    if(id)
+      elem = meshDS->AddPolygonalFaceWithID(nodes, id);
+    else
+      elem = meshDS->AddPolygonalFace(nodes);
+  }
+  else {
+    vector<const SMDS_MeshNode*> newNodes;
+    for ( int i = 0; i < nodes.size(); ++i )
+    {
+      const SMDS_MeshNode* n1 = nodes[i];
+      const SMDS_MeshNode* n2 = nodes[(i+1)/nodes.size()];
+      const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
+      newNodes.push_back( n1 );
+      newNodes.push_back( n12 );
+    }
+    if(id)
+      elem = meshDS->AddPolygonalFaceWithID(newNodes, id);
+    else
+      elem = meshDS->AddPolygonalFace(newNodes);
+  }
+  if ( mySetElemOnShape && myShapeID > 0 )
+    meshDS->SetMeshElementOnShape( elem, myShapeID );
+
+  return elem;
+}
+
 //=======================================================================
 //function : AddVolume
 //purpose  : Creates quadratic or linear prism
@@ -1279,6 +1318,62 @@ SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1,
   return elem;
 }
 
+//=======================================================================
+//function : AddPolyhedralVolume
+//purpose  : Creates polyhedron. In quadratic mesh, adds medium nodes
+//=======================================================================
+
+SMDS_MeshVolume*
+SMESH_MesherHelper::AddPolyhedralVolume (const std::vector<const SMDS_MeshNode*>& nodes,
+                                         const std::vector<int>&                  quantities,
+                                         const int                                id,
+                                         const bool                               force3d)
+{
+  SMESHDS_Mesh * meshDS = GetMeshDS();
+  SMDS_MeshVolume* elem = 0;
+  if(!myCreateQuadratic)
+  {
+    if(id)
+      elem = meshDS->AddPolyhedralVolumeWithID(nodes, quantities, id);
+    else
+      elem = meshDS->AddPolyhedralVolume(nodes, quantities);
+  }
+  else
+  {
+    vector<const SMDS_MeshNode*> newNodes;
+    vector<int> newQuantities;
+    for ( int iFace=0, iN=0; iFace < quantities.size(); ++iFace)
+    {
+      int nbNodesInFace = quantities[iFace];
+      newQuantities.push_back(0);
+      for ( int i = 0; i < nbNodesInFace; ++i )
+      {
+        const SMDS_MeshNode* n1 = nodes[ iN + i ];
+        newNodes.push_back( n1 );
+        newQuantities.back()++;
+        
+        const SMDS_MeshNode* n2 = nodes[ iN + ( i+1==nbNodesInFace ? 0 : i+1 )];
+//         if ( n1->GetPosition()->GetTypeOfPosition() != SMDS_TOP_3DSPACE &&
+//              n2->GetPosition()->GetTypeOfPosition() != SMDS_TOP_3DSPACE )
+        {
+          const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d);
+          newNodes.push_back( n12 );
+          newQuantities.back()++;
+        }
+      }
+      iN += nbNodesInFace;
+    }
+    if(id)
+      elem = meshDS->AddPolyhedralVolumeWithID( newNodes, newQuantities, id );
+    else
+      elem = meshDS->AddPolyhedralVolume( newNodes, newQuantities );
+  }
+  if ( mySetElemOnShape && myShapeID > 0 )
+    meshDS->SetMeshElementOnShape( elem, myShapeID );
+
+  return elem;
+}
+
 //=======================================================================
 //function : LoadNodeColumns
 //purpose  : Load nodes bound to face into a map of node columns
index b82e8439e06be32cb90d7f4e6af8f6082ea8b3b9..14d9225e6535bc38f732c78be76b0968edcb897f 100644 (file)
@@ -39,6 +39,7 @@
 #include <gp_Pnt2d.hxx>
 
 #include <map>
+#include <vector>
 
 class GeomAPI_ProjectPointOnSurf;
 
@@ -221,6 +222,13 @@ public:
                          const SMDS_MeshNode* n4,
                          const int id = 0,
                          const bool force3d = false);
+
+  /*!
+   * Creates polygon, with additional nodes in quadratic mesh
+   */
+  SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes,
+                                   const int id = 0,
+                                   const bool force3d = false);
   /*!
    * Creates quadratic or linear tetraahedron
    */
@@ -264,6 +272,14 @@ public:
                              const SMDS_MeshNode* n8,
                              const int id = 0, 
                              bool force3d = true);
+
+  /*!
+   * Creates polyhedron. In quadratic mesh, adds medium nodes
+   */
+  SMDS_MeshVolume* AddPolyhedralVolume (const std::vector<const SMDS_MeshNode*>& nodes,
+                                        const std::vector<int>&                  quantities,
+                                        const int                                ID=0,
+                                        const bool                               force3d = true);
   /*!
    * \brief Return U of the given node on the edge
    */