Salome HOME
Compilation error on Mageia 5
authoreap <eap@opencascade.com>
Wed, 25 Nov 2015 10:53:04 +0000 (13:53 +0300)
committereap <eap@opencascade.com>
Wed, 25 Nov 2015 10:53:04 +0000 (13:53 +0300)
   (DriverMED_W_SMESHDS_Mesh.cxx)

+ small changes for 23190: EDF 11636 - Problem of viscous layer
   (not yet fixed)

src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx
src/SMESH/SMESH_subMesh.cxx
src/SMESH/SMESH_subMesh.hxx
src/SMESHDS/SMESHDS_SubMesh.cxx
src/SMESHDS/SMESHDS_SubMesh.hxx
src/SMESHUtils/SMESH_MeshAlgos.cxx

index b4ab8dbe401b4a8caf9d5649d61359ea9f110ea3..cee3e1b09f1c43971dcb4bb3d52128c11cce9b4a 100644 (file)
@@ -525,7 +525,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
     const SMDS_MeshInfo& nbElemInfo = myMesh->GetMeshInfo();
 
     // poly elements are not supported by med-2.1
-    bool polyTypesSupported = myMed->CrPolygoneInfo(aMeshInfo,eMAILLE,ePOLYGONE,0,0);
+    bool polyTypesSupported = ( myMed->CrPolygoneInfo(aMeshInfo,eMAILLE,ePOLYGONE,0,0).get() != 0 );
     TInt nbPolygonNodes = 0, nbPolyhedronNodes = 0, nbPolyhedronFaces = 0;
 
     // nodes on VERTEXes where 0D elements are absent
index 5bb65b5b325498ddaaa33977bcf70b8c317a530b..57a401df93e39f33c1a86c14bea38a286afd5db8 100644 (file)
@@ -457,14 +457,17 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
 
 namespace
 {
-  int dependsOnMapKey( const SMESH_subMesh* sm )
+  int dependsOnMapKey( TopAbs_ShapeEnum type, int shapeID )
   {
-    int type = sm->GetSubShape().ShapeType();
-    int ordType = 9 - type;               // 2 = Vertex, 8 = CompSolid
-    int cle = sm->GetId();
+    int ordType = 9 - int(type);               // 2 = Vertex, 8 = CompSolid
+    int     cle = shapeID;
     cle += 10000000 * ordType;    // sort map by ordType then index
     return cle;
   }
+  int dependsOnMapKey( const SMESH_subMesh* sm )
+  {
+    return dependsOnMapKey( sm->GetSubShape().ShapeType(), sm->GetId() );
+  }
 }
 
 //=============================================================================
@@ -503,6 +506,17 @@ bool SMESH_subMesh::DependsOn( const SMESH_subMesh* other ) const
   return other ? _mapDepend.count( dependsOnMapKey( other )) : false;
 }
 
+//================================================================================
+/*!
+ * \brief Return \c true if \a this sub-mesh depends on a \a shape
+ */
+//================================================================================
+
+bool SMESH_subMesh::DependsOn( const int shapeID ) const
+{
+  return DependsOn( _father->GetSubMeshContaining( shapeID ));
+}
+
 //=============================================================================
 /*!
  * Return a shape of \a this sub-mesh
index 249784c081196746c632c475cf01e1e9ebf0a650..24152268d2cf593e54c4cb9c5bba92b2ca39553b 100644 (file)
@@ -81,6 +81,7 @@ class SMESH_EXPORT SMESH_subMesh
 
   const std::map < int, SMESH_subMesh * >& DependsOn();
   bool DependsOn( const SMESH_subMesh* other ) const;
+  bool DependsOn( const int shapeID ) const;
   /*!
    * \brief Return iterator on the sub-meshes this one depends on. By default
    *        most simple sub-meshes go first.
index 04a0021fc0fc2ef501ec1209d7c075c485fe3e8f..32f89c9a62983ed7a61ef996cef37494967aec95 100644 (file)
@@ -89,7 +89,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
         MESSAGE("add element in subshape already belonging to that subshape "
                 << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
         // check if ok: do nothing if ok
-        if (idInSubShape >= myElements.size())
+        if (idInSubShape >= (int)myElements.size())
         {
           throw SALOME_Exception(LOCALIZED("out of bounds"));
         }
@@ -128,7 +128,7 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele
     SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
     elem->setShapeId(0);
     elem->setIdInShape(-1);
-    if ((idInSubShape >= 0) && (idInSubShape < myElements.size()))
+    if ((idInSubShape >= 0) && (idInSubShape < (int) myElements.size()))
     {
       myElements[idInSubShape] = 0; // this vector entry is no more used
       if ( ++myUnusedIdElements == (int) myElements.size() )
@@ -160,7 +160,7 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
       if ( shapeId != myIndex )
         throw SALOME_Exception
           (LOCALIZED("a node being in sub-mesh is added to another sub-mesh"));
-      if ( idInSubShape >= myNodes.size() || myNodes[ idInSubShape ] != N )
+      if ( idInSubShape >= (int)myNodes.size() || myNodes[ idInSubShape ] != N )
         throw SALOME_Exception
           (LOCALIZED("a node with wrong idInSubShape is re-added to the same sub-mesh"));
       return; // already in
@@ -187,7 +187,7 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
     SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
     node->setShapeId(0);
     node->setIdInShape(-1);
-    if ((idInSubShape >= 0) && (idInSubShape < myNodes.size()))
+    if ((idInSubShape >= 0) && (idInSubShape < (int) myNodes.size()))
     {
       myNodes[idInSubShape] = 0; // this vector entry is no more used
       if ( ++myUnusedIdNodes == (int) myNodes.size() )
@@ -284,7 +284,7 @@ template<typename VALUE> class MyIterator : public SMDS_Iterator<VALUE>
 {
  public:
   MyIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes)
-    : mySubIt( theSubMeshes.begin() ), mySubEnd( theSubMeshes.end() ), myMore(false)
+    : myMore(false), mySubIt( theSubMeshes.begin() ), mySubEnd( theSubMeshes.end() )
     {}
   bool more()
   {
@@ -388,14 +388,14 @@ bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
   if (ME->GetType() == SMDSAbs_Node)
   {
     int idInShape = ME->getIdInShape();
-    if ((idInShape >= 0) && (idInShape < myNodes.size()))
+    if ((idInShape >= 0) && (idInShape < (int) myNodes.size()))
       if (myNodes[idInShape] == ME)
         return true;
   }
   else
   {
     int idInShape = ME->getIdInShape();
-    if ((idInShape >= 0) && (idInShape < myElements.size()))
+    if ((idInShape >= 0) && (idInShape < (int) myElements.size()))
       if (myElements[idInShape] == ME)
         return true;
   }
@@ -539,3 +539,23 @@ void SMESHDS_SubMesh::compactList()
     myUnusedIdNodes = 0;
   }
 }
+
+//=======================================================================
+//function : GetElement
+//purpose  : Return an element by its IdInShape
+//=======================================================================
+
+const SMDS_MeshElement* SMESHDS_SubMesh::GetElement( size_t idInShape ) const
+{
+  return ( !IsComplexSubmesh() && idInShape < myElements.size() ) ? myElements[idInShape] : 0;
+}
+
+//=======================================================================
+//function : GetElement
+//purpose  : Return a node by its IdInShape
+//=======================================================================
+
+const SMDS_MeshNode* SMESHDS_SubMesh::GetNode( size_t idInShape ) const
+{
+  return ( !IsComplexSubmesh() && idInShape < myNodes.size() ) ? myNodes[idInShape] : 0;
+}
index c70857c6028dbb30952e6fa6671643a764a11e23..4eab3aa4470bf87057ffea6c53fee0d8a83f106b 100644 (file)
@@ -52,6 +52,8 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
   virtual bool RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted); // ret true if ME was in
   virtual void AddNode(const SMDS_MeshNode * ME);
   virtual bool RemoveNode(const SMDS_MeshNode * ME, bool isNodeDeleted);       // ret true if ME was in
+  virtual const SMDS_MeshElement* GetElement( size_t idInShape ) const;
+  virtual const SMDS_MeshNode*    GetNode   ( size_t idInShape ) const;
 
   // if IsComplexSubmesh()
   void AddSubMesh( const SMESHDS_SubMesh* theSubMesh );
index dc29b8be2021398f22f1d80546b32ceec2a0e08d..c42f020236e096a1744df1235270a1d0f3d4661b 100644 (file)
@@ -1433,9 +1433,35 @@ double SMESH_MeshAlgos::GetDistance( const SMDS_MeshFace* face,
  */
 //=======================================================================
 
-double SMESH_MeshAlgos::GetDistance( const SMDS_MeshEdge* edge, const gp_Pnt& point )
+double SMESH_MeshAlgos::GetDistance( const SMDS_MeshEdge* seg, const gp_Pnt& point )
 {
-  throw SALOME_Exception(LOCALIZED("not implemented so far"));
+  double dist = Precision::Infinite();
+  if ( !seg ) return dist;
+
+  int i = 0, nbNodes = seg->NbNodes();
+
+  vector< SMESH_TNodeXYZ > xyz( nbNodes );
+  SMDS_ElemIteratorPtr nodeIt = seg->interlacedNodesElemIterator();
+  while ( nodeIt->more() )
+    xyz[ i++ ].Set( nodeIt->next() );
+
+  for ( i = 1; i < nbNodes; ++i )
+  {
+    gp_Vec edge( xyz[i-1], xyz[i] );
+    gp_Vec n1p ( xyz[i-1], point  );
+    double u = ( edge * n1p ) / edge.SquareMagnitude(); // param [0,1] on the edge
+    if ( u <= 0. ) {
+      dist = Min( dist, n1p.SquareMagnitude() );
+    }
+    else if ( u >= 1. ) {
+      dist = Min( dist, point.SquareDistance( xyz[i] ));
+    }
+    else {
+      gp_XYZ proj = ( 1. - u ) * xyz[i-1] + u * xyz[i]; // projection of the point on the edge
+      dist = Min( dist, point.SquareDistance( proj ));
+    }
+  }
+  return Sqrt( dist );
 }
 
 //=======================================================================