From 25b7d7ffe76e153c93cb67055192b11b16c3d0e2 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 25 Nov 2015 13:53:04 +0300 Subject: [PATCH] Compilation error on Mageia 5 (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 | 2 +- src/SMESH/SMESH_subMesh.cxx | 22 +++++++++++--- src/SMESH/SMESH_subMesh.hxx | 1 + src/SMESHDS/SMESHDS_SubMesh.cxx | 34 +++++++++++++++++----- src/SMESHDS/SMESHDS_SubMesh.hxx | 2 ++ src/SMESHUtils/SMESH_MeshAlgos.cxx | 30 +++++++++++++++++-- 6 files changed, 77 insertions(+), 14 deletions(-) diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index b4ab8dbe4..cee3e1b09 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -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 diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 5bb65b5b3..57a401df9 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -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 diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 249784c08..24152268d 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -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. diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 04a0021fc..32f89c9a6 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -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 class MyIterator : public SMDS_Iterator { public: MyIterator (const set& 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; +} diff --git a/src/SMESHDS/SMESHDS_SubMesh.hxx b/src/SMESHDS/SMESHDS_SubMesh.hxx index c70857c60..4eab3aa44 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.hxx +++ b/src/SMESHDS/SMESHDS_SubMesh.hxx @@ -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 ); diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index dc29b8be2..c42f02023 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -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 ); } //======================================================================= -- 2.39.2