Compilation error on Mageia 5

(DriverMED_W_SMESHDS_Mesh.cxx)

+ small changes for 23190: EDF 11636 - Problem of viscous layer
   (not yet fixed)
This commit is contained in:
eap 2015-11-25 13:53:04 +03:00
parent 831ca6c828
commit 25b7d7ffe7
6 changed files with 77 additions and 14 deletions

View File

@ -525,7 +525,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
const SMDS_MeshInfo& nbElemInfo = myMesh->GetMeshInfo(); const SMDS_MeshInfo& nbElemInfo = myMesh->GetMeshInfo();
// poly elements are not supported by med-2.1 // 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; TInt nbPolygonNodes = 0, nbPolyhedronNodes = 0, nbPolyhedronFaces = 0;
// nodes on VERTEXes where 0D elements are absent // nodes on VERTEXes where 0D elements are absent

View File

@ -457,14 +457,17 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
namespace namespace
{ {
int dependsOnMapKey( const SMESH_subMesh* sm ) int dependsOnMapKey( TopAbs_ShapeEnum type, int shapeID )
{ {
int type = sm->GetSubShape().ShapeType(); int ordType = 9 - int(type); // 2 = Vertex, 8 = CompSolid
int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid int cle = shapeID;
int cle = sm->GetId();
cle += 10000000 * ordType; // sort map by ordType then index cle += 10000000 * ordType; // sort map by ordType then index
return cle; 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; 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 * Return a shape of \a this sub-mesh

View File

@ -81,6 +81,7 @@ class SMESH_EXPORT SMESH_subMesh
const std::map < int, SMESH_subMesh * >& DependsOn(); const std::map < int, SMESH_subMesh * >& DependsOn();
bool DependsOn( const SMESH_subMesh* other ) const; 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 * \brief Return iterator on the sub-meshes this one depends on. By default
* most simple sub-meshes go first. * most simple sub-meshes go first.

View File

@ -89,7 +89,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
MESSAGE("add element in subshape already belonging to that subshape " MESSAGE("add element in subshape already belonging to that subshape "
<< ME->GetID() << " " << oldShapeId << " " << idInSubShape); << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
// check if ok: do nothing if ok // check if ok: do nothing if ok
if (idInSubShape >= myElements.size()) if (idInSubShape >= (int)myElements.size())
{ {
throw SALOME_Exception(LOCALIZED("out of bounds")); 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); SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(0); elem->setShapeId(0);
elem->setIdInShape(-1); 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 myElements[idInSubShape] = 0; // this vector entry is no more used
if ( ++myUnusedIdElements == (int) myElements.size() ) if ( ++myUnusedIdElements == (int) myElements.size() )
@ -160,7 +160,7 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
if ( shapeId != myIndex ) if ( shapeId != myIndex )
throw SALOME_Exception throw SALOME_Exception
(LOCALIZED("a node being in sub-mesh is added to another sub-mesh")); (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 throw SALOME_Exception
(LOCALIZED("a node with wrong idInSubShape is re-added to the same sub-mesh")); (LOCALIZED("a node with wrong idInSubShape is re-added to the same sub-mesh"));
return; // already in return; // already in
@ -187,7 +187,7 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
SMDS_MeshNode* node = (SMDS_MeshNode*) (N); SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
node->setShapeId(0); node->setShapeId(0);
node->setIdInShape(-1); 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 myNodes[idInSubShape] = 0; // this vector entry is no more used
if ( ++myUnusedIdNodes == (int) myNodes.size() ) if ( ++myUnusedIdNodes == (int) myNodes.size() )
@ -284,7 +284,7 @@ template<typename VALUE> class MyIterator : public SMDS_Iterator<VALUE>
{ {
public: public:
MyIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes) 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() bool more()
{ {
@ -388,14 +388,14 @@ bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
if (ME->GetType() == SMDSAbs_Node) if (ME->GetType() == SMDSAbs_Node)
{ {
int idInShape = ME->getIdInShape(); int idInShape = ME->getIdInShape();
if ((idInShape >= 0) && (idInShape < myNodes.size())) if ((idInShape >= 0) && (idInShape < (int) myNodes.size()))
if (myNodes[idInShape] == ME) if (myNodes[idInShape] == ME)
return true; return true;
} }
else else
{ {
int idInShape = ME->getIdInShape(); int idInShape = ME->getIdInShape();
if ((idInShape >= 0) && (idInShape < myElements.size())) if ((idInShape >= 0) && (idInShape < (int) myElements.size()))
if (myElements[idInShape] == ME) if (myElements[idInShape] == ME)
return true; return true;
} }
@ -539,3 +539,23 @@ void SMESHDS_SubMesh::compactList()
myUnusedIdNodes = 0; 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;
}

View 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 bool RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted); // ret true if ME was in
virtual void AddNode(const SMDS_MeshNode * ME); virtual void AddNode(const SMDS_MeshNode * ME);
virtual bool RemoveNode(const SMDS_MeshNode * ME, bool isNodeDeleted); // ret true if ME was in 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() // if IsComplexSubmesh()
void AddSubMesh( const SMESHDS_SubMesh* theSubMesh ); void AddSubMesh( const SMESHDS_SubMesh* theSubMesh );

View 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 );
} }
//======================================================================= //=======================================================================