Salome HOME
Added support for polygones and polyhedres
authorenk <enk@opencascade.com>
Fri, 18 Feb 2005 07:42:46 +0000 (07:42 +0000)
committerenk <enk@opencascade.com>
Fri, 18 Feb 2005 07:42:46 +0000 (07:42 +0000)
idl/SMESH_Mesh.idl
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH/SMESH_subMesh.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index c7de9ac081188d75e4b7cb6a3b7408cc1f92348b..1456a3d6b74e15596a0de17579972fbd17335b8e 100644 (file)
@@ -58,14 +58,17 @@ module SMESH
       ADD_EDGE,
       ADD_TRIANGLE,
       ADD_QUADRANGLE,
       ADD_EDGE,
       ADD_TRIANGLE,
       ADD_QUADRANGLE,
+      ADD_POLYGON,
       ADD_TETRAHEDRON,
       ADD_PYRAMID,
       ADD_PRISM,
       ADD_HEXAHEDRON,
       ADD_TETRAHEDRON,
       ADD_PYRAMID,
       ADD_PRISM,
       ADD_HEXAHEDRON,
+      ADD_POLYHEDRON,
       REMOVE_NODE,
       REMOVE_ELEMENT,
       MOVE_NODE,
       CHANGE_ELEMENT_NODES,
       REMOVE_NODE,
       REMOVE_ELEMENT,
       MOVE_NODE,
       CHANGE_ELEMENT_NODES,
+      CHANGE_POLYHEDRON_NODES,
       RENUMBER
     };
 
       RENUMBER
     };
 
@@ -375,6 +378,9 @@ module SMESH
     long NbQuadrangles()
       raises (SALOME::SALOME_Exception);
 
     long NbQuadrangles()
       raises (SALOME::SALOME_Exception);
 
+    long NbPolygones()
+      raises (SALOME::SALOME_Exception);
+
     long NbVolumes()
       raises (SALOME::SALOME_Exception);
 
     long NbVolumes()
       raises (SALOME::SALOME_Exception);
 
@@ -390,6 +396,9 @@ module SMESH
     long NbPrisms()
       raises (SALOME::SALOME_Exception);
 
     long NbPrisms()
       raises (SALOME::SALOME_Exception);
 
+    long NbPolyhedrones()
+      raises (SALOME::SALOME_Exception);
+
     long NbSubMesh()
       raises (SALOME::SALOME_Exception);
 
     long NbSubMesh()
       raises (SALOME::SALOME_Exception);
 
@@ -461,7 +470,7 @@ module SMESH
       raises (SALOME::SALOME_Exception);
   };
   
       raises (SALOME::SALOME_Exception);
   };
   
-  /* 
+  /*!
    * This interface makes modifications on the Mesh - removing elements and nodes etc.
    */
   interface NumericalFunctor;
    * This interface makes modifications on the Mesh - removing elements and nodes etc.
    */
   interface NumericalFunctor;
@@ -480,6 +489,25 @@ module SMESH
 
     boolean AddVolume(in long_array IDsOfNodes);
 
 
     boolean AddVolume(in long_array IDsOfNodes);
 
+    //boolean AddPolygonalFace (in long_array IdsOfNodes);
+
+    /*!
+     *  Create volume of many faces, giving nodes for each face.
+     *  \param IdsOfNodes List of node IDs for volume creation face by face.
+     *  \param Quantities List of integer values, Quantities[i]
+     *         gives quantity of nodes in face number i.
+     */
+    boolean AddPolyhedralVolume (in long_array IdsOfNodes,
+                                in long_array Quantities);
+
+    /*!
+     *  Create volume of many faces, giving IDs of existing faces.
+     *  \param IdsOfFaces List of face IDs for volume creation.
+     *  \note The created volume will refer only to nodes
+     *        of the given faces, not to the faces itself.
+     */
+    boolean AddPolyhedralVolumeByFaces (in long_array IdsOfFaces);
+
     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
 
     boolean InverseDiag(in long NodeID1, in long NodeID2);
     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
 
     boolean InverseDiag(in long NodeID1, in long NodeID2);
index db8bc5f78301499b2ca2c044bd45a726364ea9c0..db0c31ba115ccaa80feb5801d1dcfa3f3528aa7f 100644 (file)
@@ -850,6 +850,19 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
   return Nb;
 }
 
   return Nb;
 }
 
+///////////////////////////////////////////////////////////////////////////////
+/// Return the number of polygone faces in the mesh. This method run in O(n)
+///////////////////////////////////////////////////////////////////////////////
+int SMESH_Mesh::NbPolygones() throw(SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+  int Nb = 0;
+  
+  SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
+  while(itFaces->more()) if(itFaces->next()->IsPoly()) Nb++;
+  return Nb;
+}
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
@@ -897,6 +910,15 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
   return Nb;
 }
 
   return Nb;
 }
 
+int SMESH_Mesh::NbPolyhedrones() throw(SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+  int Nb = 0;
+  SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+  while(itVolumes->more()) if(itVolumes->next()->IsPoly()) Nb++;
+  return Nb;
+}
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
index 2864deade7a565b904604cc8e02f82e38d94a2e8..782be9360f8db85bab94a4ca9f761c28d4d53366 100644 (file)
@@ -165,6 +165,8 @@ public:
   int NbTriangles() throw(SALOME_Exception);
   
   int NbQuadrangles() throw(SALOME_Exception);
   int NbTriangles() throw(SALOME_Exception);
   
   int NbQuadrangles() throw(SALOME_Exception);
+
+  int NbPolygones() throw(SALOME_Exception);
   
   int NbVolumes() throw(SALOME_Exception);
   
   
   int NbVolumes() throw(SALOME_Exception);
   
@@ -173,6 +175,8 @@ public:
   int NbHexas() throw(SALOME_Exception);
   
   int NbPyramids() throw(SALOME_Exception);
   int NbHexas() throw(SALOME_Exception);
   
   int NbPyramids() throw(SALOME_Exception);
+
+  int NbPolyhedrones() throw(SALOME_Exception);
   
   int NbPrisms() throw(SALOME_Exception);
   
   
   int NbPrisms() throw(SALOME_Exception);
   
index ce4e8ee23507f7fbf1ea5a3c330c57b2e62dac5b..9d6418ddf2ff982405b3954c6743deea01665742 100644 (file)
@@ -792,17 +792,20 @@ SMESH_Hypothesis::Hypothesis_Status
       ASSERT(algo);
       if (!algo->CheckHypothesis((*_father),_subShape, ret ))
       {
       ASSERT(algo);
       if (!algo->CheckHypothesis((*_father),_subShape, ret ))
       {
+        //two applying algo on the same shape not allowed
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
         if ( !SMESH_Hypothesis::IsStatusFatal( ret ))
           // ret should be fatal: anHyp was not added
           ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
       }
         if ( !SMESH_Hypothesis::IsStatusFatal( ret ))
           // ret should be fatal: anHyp was not added
           ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
       }
+      else if (SMESH_Hypothesis::IsStatusFatal( ret ))
+      {
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+      }
       else if (!_father->IsUsedHypothesis(  anHyp, _subShape ))
       else if (!_father->IsUsedHypothesis(  anHyp, _subShape ))
-        ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
-
-      if (SMESH_Hypothesis::IsStatusFatal( ret ))
       {
       {
-        MESSAGE("do not add extra hypothesis");
         _meshDS->RemoveHypothesis(_subShape, anHyp);
         _meshDS->RemoveHypothesis(_subShape, anHyp);
+        ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
       }
       else
       {
       }
       else
       {
@@ -812,19 +815,11 @@ SMESH_Hypothesis::Hypothesis_Status
     }
     case ADD_ALGO: {           //already existing algo : on father ?
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
     }
     case ADD_ALGO: {           //already existing algo : on father ?
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) {
-        // check if algo changes
-        SMESH_HypoFilter f;
-        f.Init(   SMESH_HypoFilter::IsAlgo() );
-        f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
-        f.AndNot( SMESH_HypoFilter::Is( algo ));
-        const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
-        if (prevAlgo && 
-            string(algo->GetName()) != string(prevAlgo->GetName()) )
-          modifiedHyp = true;
-      }
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
       else
         SetAlgoState(MISSING_HYP);
       else
         SetAlgoState(MISSING_HYP);
+      modifiedHyp = true;
       break;
     }
     case REMOVE_HYP: {
       break;
     }
     case REMOVE_HYP: {
@@ -845,13 +840,13 @@ SMESH_Hypothesis::Hypothesis_Status
       }
       else
       {
       }
       else
       {
-        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) {
-          // check if algo remains
-          if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
-            modifiedHyp = true;
-        }
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
         else
           SetAlgoState(MISSING_HYP);
         else
           SetAlgoState(MISSING_HYP);
+        // check if same algo remains
+        if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
+          modifiedHyp = true;
       }
       break;
     }
       }
       break;
     }
@@ -860,6 +855,7 @@ SMESH_Hypothesis::Hypothesis_Status
       ASSERT(algo);
       if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
       {
       ASSERT(algo);
       if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
       {
+        SetAlgoState(HYP_OK);
         if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
           modifiedHyp = true;
       }
         if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
           modifiedHyp = true;
       }
@@ -867,35 +863,27 @@ SMESH_Hypothesis::Hypothesis_Status
         SetAlgoState(MISSING_HYP);
       break;
     }
         SetAlgoState(MISSING_HYP);
       break;
     }
-    case ADD_FATHER_ALGO: {
+    case ADD_FATHER_ALGO: {    // a new algo on father
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-      if ( algo == anHyp ) { // a new algo on father
-        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) {
-          // check if algo changes
-          SMESH_HypoFilter f;
-          f.Init(   SMESH_HypoFilter::IsAlgo() );
-          f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
-          f.AndNot( SMESH_HypoFilter::Is( algo ));
-          const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
-          if (prevAlgo && 
-              string(algo->GetName()) != string(prevAlgo->GetName()) )
-            modifiedHyp = true;
-        }
+      if ( algo == anHyp ) {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
         else
           SetAlgoState(MISSING_HYP);
         else
           SetAlgoState(MISSING_HYP);
+        modifiedHyp = true;
       }
       break;
     }
     case REMOVE_FATHER_HYP: {
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
       ASSERT(algo);
       }
       break;
     }
     case REMOVE_FATHER_HYP: {
       SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
       ASSERT(algo);
-      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) {
-        // is there the same local hyp or maybe a new father algo applied?
-        if ( !GetSimilarAttached( _subShape, anHyp ) )
-          modifiedHyp = true;
-      }
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
       else
         SetAlgoState(MISSING_HYP);
       else
         SetAlgoState(MISSING_HYP);
+      // is there the same local hyp or maybe a new father algo applied?
+      if ( !GetSimilarAttached( _subShape, anHyp ) )
+        modifiedHyp = true;
       break;
     }
     case REMOVE_FATHER_ALGO: {
       break;
     }
     case REMOVE_FATHER_ALGO: {
@@ -906,13 +894,13 @@ SMESH_Hypothesis::Hypothesis_Status
       }
       else
       {
       }
       else
       {
-        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) {
-          // check if algo changes
-          if ( string(algo->GetName()) != string( anHyp->GetName()) )
-            modifiedHyp = true;
-        }
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
         else
           SetAlgoState(MISSING_HYP);
         else
           SetAlgoState(MISSING_HYP);
+        // is there the same local algo or maybe a new father algo applied?
+        if ( !GetSimilarAttached( _subShape, anHyp ))
+          modifiedHyp = true;
       }
       break;
     }
       }
       break;
     }
@@ -1497,21 +1485,21 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent)
 
 void SMESH_subMesh::CleanDependants()
 {
 
 void SMESH_subMesh::CleanDependants()
 {
+  //MESSAGE("SMESH_subMesh::CleanDependants: shape type " << _subShape.ShapeType() );
+
   TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
   for (; it.More(); it.Next())
   {
     const TopoDS_Shape& ancestor = it.Value();
   TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
   for (; it.More(); it.Next())
   {
     const TopoDS_Shape& ancestor = it.Value();
-    // PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEANDEP)
-    // will erase mesh on other shapes in a compound
-    if ( ancestor.ShapeType() >= TopAbs_SOLID ) {
-      SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
-      if (aSubMesh)
-        aSubMesh->ComputeStateEngine(CLEANDEP);
-    }
+    //MESSAGE("ancestor shape type " << ancestor.ShapeType() );
+    SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
+    if (aSubMesh)
+      aSubMesh->ComputeStateEngine(CLEANDEP);
   }
   ComputeStateEngine(CLEAN);
 }
 
   }
   ComputeStateEngine(CLEAN);
 }
 
+
 //=============================================================================
 /*!
  *
 //=============================================================================
 /*!
  *
index a908b3d1441408fcb5fa1379a7220ef060fe90d1..0f46b537eecdf5808bb48321f6d58a095823ec50 100644 (file)
@@ -124,24 +124,36 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *  
+ *  AddFace
  */
 //=============================================================================
 
 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
 {
  */
 //=============================================================================
 
 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
 {
-       int NbNodes = IDsOfNodes.length();
-       const SMDS_MeshNode* nodes[4];
-       for(int i=0;i<NbNodes;i++) nodes[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
-       if (NbNodes == 3)
-       {
-               GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
-       }
-       else if (NbNodes == 4)
-       {
-               GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
-       }
-       return true;
+  int NbNodes = IDsOfNodes.length();
+  if (NbNodes < 3)
+  {
+    return false;
+  }
+
+  std::vector<const SMDS_MeshNode*> nodes (NbNodes);
+  //const SMDS_MeshNode* nodes [NbNodes];
+  for (int i = 0; i < NbNodes; i++)
+    nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
+
+  if (NbNodes == 3)
+  {
+    GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
+  }
+  else if (NbNodes == 4)
+  {
+    GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
+  }
+  else
+  {
+    GetMeshDS()->AddPolygonalFace(nodes);
+  }
+  return true;
 };
 
 //=============================================================================
 };
 
 //=============================================================================
@@ -167,6 +179,49 @@ CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
        return true;
 };
 
        return true;
 };
 
+//=============================================================================
+/*!
+ *  AddPolyhedralVolume
+ */
+//=============================================================================
+CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
+                                   (const SMESH::long_array & IDsOfNodes,
+                                    const SMESH::long_array & Quantities)
+{
+  int NbNodes = IDsOfNodes.length();
+  std::vector<const SMDS_MeshNode*> n (NbNodes);
+  //const SMDS_MeshNode* n [NbNodes];
+  for (int i = 0; i < NbNodes; i++)
+    n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
+
+  int NbFaces = Quantities.length();
+  std::vector<int> q (NbFaces);
+  //int q [NbFaces];
+  for (int j = 0; j < NbFaces; j++)
+    q[j] = Quantities[j];
+
+  GetMeshDS()->AddPolyhedralVolume(n, q);
+  return true;
+};
+
+//=============================================================================
+/*!
+ *  AddPolyhedralVolumeByFaces
+ */
+//=============================================================================
+CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
+                                   (const SMESH::long_array & IdsOfFaces)
+{
+  int NbFaces = IdsOfFaces.length();
+  std::vector<const SMDS_MeshFace*> faces (NbFaces);
+  for (int i = 0; i < NbFaces; i++)
+    faces[i] = (SMDS_MeshFace *)GetMeshDS()->FindElement(IdsOfFaces[i]);
+
+  //GetMeshDS()->AddPolyhedralVolumeByFaces(faces);
+  //return true;
+  return false;
+};
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
index 9a2ced6bf60cad7603450d28808b63802e419f20..7325f53e4590fab1e28544438ec7ebcfb5a39858 100644 (file)
@@ -51,6 +51,11 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
   CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes);
   CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes);
   CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes);
   CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes);
   CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes);
   CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes);
+
+  CORBA::Boolean AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
+                                     const SMESH::long_array & Quantities);
+  CORBA::Boolean AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
+
   CORBA::Boolean MoveNode(CORBA::Long NodeID,
                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
 
   CORBA::Boolean MoveNode(CORBA::Long NodeID,
                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
 
index d0da172ba0941f13d5cb04e258c9d273cd2e330a..c9a347c3bbaa2144c42ba41c0ba88b6d22bae7ee 100644 (file)
@@ -1193,6 +1193,12 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
   return _impl->NbQuadrangles();
 }
 
   return _impl->NbQuadrangles();
 }
 
+CORBA::Long SMESH_Mesh_i::NbPolygones()throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  return _impl->NbPolygones();
+}
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
@@ -1228,6 +1234,12 @@ CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
   return _impl->NbPrisms();
 }
 
   return _impl->NbPrisms();
 }
 
+CORBA::Long SMESH_Mesh_i::NbPolyhedrones()throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  return _impl->NbPolyhedrones();
+}
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
index 3035c1ad3df6539d1ed84c1af6e3e03a886f6e11..0988218ed6c772976e75db6d51feed4752b4f6ff 100644 (file)
@@ -182,6 +182,9 @@ public:
 
   CORBA::Long NbQuadrangles()
     throw (SALOME::SALOME_Exception);
 
   CORBA::Long NbQuadrangles()
     throw (SALOME::SALOME_Exception);
+
+  CORBA::Long NbPolygones()
+    throw (SALOME::SALOME_Exception);
   
   CORBA::Long NbVolumes()
     throw (SALOME::SALOME_Exception);
   
   CORBA::Long NbVolumes()
     throw (SALOME::SALOME_Exception);
@@ -197,6 +200,9 @@ public:
   
   CORBA::Long NbPrisms()
     throw (SALOME::SALOME_Exception);
   
   CORBA::Long NbPrisms()
     throw (SALOME::SALOME_Exception);
+
+  CORBA::Long NbPolyhedrones()
+    throw (SALOME::SALOME_Exception);
   
   CORBA::Long NbSubMesh()
     throw (SALOME::SALOME_Exception);
   
   CORBA::Long NbSubMesh()
     throw (SALOME::SALOME_Exception);