X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Mesh_i.cxx;h=3de13f6f6a9433635af3d7b8f429a2d3a356f62f;hb=07ec002dfd20ec187228e11533e8e2135eca08fd;hp=2ebee967b349dd51be3955a617565978dd49d94c;hpb=ba46f82f7d8af8d1c794839dd12b1365243ae34b;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 2ebee967b..3de13f6f6 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -37,6 +37,7 @@ #include "SMESH_subMesh_i.hxx" #include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Mesh.h" #include "SMDS_VolumeTool.hxx" #include "SMESHDS_Command.hxx" #include "SMESHDS_CommandType.hxx" @@ -44,6 +45,8 @@ #include "SMESH_Group.hxx" #include "SMESH_MeshEditor.hxx" #include "SMESH_MesherHelper.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" #include "OpUtil.hxx" #include "SALOME_NamingService.hxx" @@ -54,14 +57,15 @@ // OCCT Includes #include -#include -#include #include +#include +#include #include -#include #include +#include #include #include +#include #include // STL Includes @@ -241,6 +245,19 @@ SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName ) return ConvertDriverMEDReadStatus(status); } +//================================================================================ +/*! + * \brief Return string representation of a MED file version comprising nbDigits + */ +//================================================================================ + +char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits) +{ + std::string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(MED::EVersion(version), + nbDigits); + return CORBA::string_dup( ver.c_str() ); +} + //============================================================================= /*! * ImportUNVFile @@ -1929,12 +1946,12 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID, CO SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS(); if(!SDSM) return aResult._retn(); - map theElems; - if( !all || (SDSM->NbElements()==0 && SDSM->NbNodes()==1) ) { + set theElems; + if( !all || (SDSM->NbElements()==0) ) { // internal nodes or vertex submesh SMDS_NodeIteratorPtr nIt = SDSM->GetNodes(); while ( nIt->more() ) { const SMDS_MeshNode* elem = nIt->next(); - theElems.insert( make_pair(elem->GetID(),elem) ); + theElems.insert( elem->GetID() ); } } else { // all nodes of submesh elements @@ -1944,16 +1961,16 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID, CO SMDS_ElemIteratorPtr nIt = anElem->nodesIterator(); while ( nIt->more() ) { const SMDS_MeshElement* elem = nIt->next(); - theElems.insert( make_pair(elem->GetID(),elem) ); + theElems.insert( elem->GetID() ); } } } aResult->length(theElems.size()); - map::iterator itElem; + set::iterator itElem; int i = 0; for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) - aResult[i++] = (*itElem).first; + aResult[i++] = *itElem; return aResult._retn(); } @@ -2060,6 +2077,56 @@ SMESH::long_array* SMESH_Mesh_i::GetNodeInverseElements(const CORBA::Long id) return aResult._retn(); } +//============================================================================= +/*! + * \brief Return position of a node on shape + */ +//============================================================================= + +SMESH::NodePosition* SMESH_Mesh_i::GetNodePosition(CORBA::Long NodeID) +{ + SMESH::NodePosition* aNodePosition = new SMESH::NodePosition(); + aNodePosition->shapeID = 0; + aNodePosition->shapeType = GEOM::SHAPE; + + SMESHDS_Mesh* mesh = _impl->GetMeshDS(); + if ( !mesh ) return aNodePosition; + + if ( const SMDS_MeshNode* aNode = mesh->FindNode(NodeID) ) + { + if ( SMDS_PositionPtr pos = aNode->GetPosition() ) + { + aNodePosition->shapeID = pos->GetShapeId(); + switch ( pos->GetTypeOfPosition() ) { + case SMDS_TOP_EDGE: + aNodePosition->shapeType = GEOM::EDGE; + aNodePosition->params.length(1); + aNodePosition->params[0] = + static_cast( pos.get() )->GetUParameter(); + break; + case SMDS_TOP_FACE: + aNodePosition->shapeType = GEOM::FACE; + aNodePosition->params.length(2); + aNodePosition->params[0] = + static_cast( pos.get() )->GetUParameter(); + aNodePosition->params[1] = + static_cast( pos.get() )->GetVParameter(); + break; + case SMDS_TOP_VERTEX: + aNodePosition->shapeType = GEOM::VERTEX; + break; + case SMDS_TOP_3DSPACE: + if ( TopExp_Explorer(_impl->GetShapeToMesh(), TopAbs_SOLID).More() ) + aNodePosition->shapeType = GEOM::SOLID; + else if ( TopExp_Explorer(_impl->GetShapeToMesh(), TopAbs_SHELL).More() ) + aNodePosition->shapeType = GEOM::SHELL; + break; + default:; + } + } + } + return aNodePosition; +} //============================================================================= /*!