From 4408d2b6b264dcef89bee515b9cdefb6a9c04e7d Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 13 Sep 2017 20:29:28 +0300 Subject: [PATCH] [GPUSPHGUI - Feature #267] 7.5.8. Tracking special boundaries --- src/SMDS/SMDS_Mesh.hxx | 2 +- src/SMDS/SMDS_SetIterator.hxx | 5 +++++ src/SMESH_I/SMESH_MeshPartDS.hxx | 13 +++++++++++++ src/SMESH_I/SMESH_Mesh_i.cxx | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 459befaa9..d8a669d7c 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -654,7 +654,7 @@ public: int idnode4, int idnode5, int idnode6) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) const; - const SMDS_MeshElement *FindElement(int IDelem) const; + virtual const SMDS_MeshElement *FindElement(int IDelem) const; static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n); static const SMDS_BallElement* FindBall(const SMDS_MeshNode * n); static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, diff --git a/src/SMDS/SMDS_SetIterator.hxx b/src/SMDS/SMDS_SetIterator.hxx index e0b3c8b08..3402cbf6a 100644 --- a/src/SMDS/SMDS_SetIterator.hxx +++ b/src/SMDS/SMDS_SetIterator.hxx @@ -51,6 +51,11 @@ namespace SMDS { static VALUE value(VALUE_SET_ITERATOR it) { return (VALUE) it->second; } }; + template + struct PointerAccessor { + static VALUE value(VALUE_SET_ITERATOR it) { return (VALUE) &(*it); } + }; + /////////////////////////////////////////////////////////////////////////////// /// Filters of value pointed by iterator /////////////////////////////////////////////////////////////////////////////// diff --git a/src/SMESH_I/SMESH_MeshPartDS.hxx b/src/SMESH_I/SMESH_MeshPartDS.hxx index 6d2c959ef..986ee3c06 100644 --- a/src/SMESH_I/SMESH_MeshPartDS.hxx +++ b/src/SMESH_I/SMESH_MeshPartDS.hxx @@ -56,6 +56,8 @@ public: virtual SMDS_ElemIteratorPtr elementGeomIterator(SMDSAbs_GeometryType type) const; virtual SMDS_ElemIteratorPtr elementEntityIterator(SMDSAbs_EntityType type) const; + virtual const SMDS_MeshElement *FindElement(int IDelem) const; + private: TIDSortedElemSet _elements[ SMDSAbs_NbElementTypes ]; SMESHDS_Mesh* _meshDS; @@ -66,6 +68,17 @@ private: { void Add(const SMDS_MeshElement* e) { SMDS_MeshInfo::addWithPoly( e ); } }; + /*! + * \brief Element holing its ID only + */ + struct TElemID : public SMDS_MeshElement + { + TElemID(int ID) : SMDS_MeshElement( ID ) {} + virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_All; } + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Last; } + virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_NONE; } + virtual vtkIdType GetVtkType() const { return -1; } + }; }; #endif diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index dc12084e7..4178c81ac 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -6137,6 +6137,21 @@ SMESH_MeshPartDS::SMESH_MeshPartDS(const std::list< const SMDS_MeshElement* > & myInfo = tmpInfo; } // ------------------------------------------------------------------------------------- +const SMDS_MeshElement * SMESH_MeshPartDS::FindElement(int IDelem) const +{ + if ( _meshDS ) return _meshDS->FindElement( IDelem ); + + TElemID elem( IDelem ); + for ( int iType = SMDSAbs_Edge; iType < SMDSAbs_NbElementTypes; ++iType ) + if ( !_elements[ iType ].empty() ) + { + TIDSortedElemSet::const_iterator it = _elements[ iType ].find( &elem ); + if ( it != _elements[ iType ].end() ) + return *it; + } + return 0; +} +// ------------------------------------------------------------------------------------- SMDS_ElemIteratorPtr SMESH_MeshPartDS::elementGeomIterator(SMDSAbs_GeometryType geomType) const { if ( _meshDS ) return _meshDS->elementGeomIterator( geomType ); -- 2.39.2