smesh/src/SMESH/SMESH_ProxyMesh.hxx

184 lines
6.3 KiB
C++
Raw Normal View History

2013-04-01 13:05:47 +00:00
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
2012-08-09 10:03:55 +00:00
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : SMESH_ProxyMesh.hxx
// Created : Thu Dec 2 10:05:35 2010
// Author : Edward AGAPOV (eap)
#ifndef __SMESH_ProxyMesh_HXX__
#define __SMESH_ProxyMesh_HXX__
#include "SMESH_SMESH.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMESHDS_SubMesh.hxx"
2012-12-13 11:41:29 +00:00
#include "SMESH_TypeDefs.hxx"
2012-08-09 10:03:55 +00:00
#include <TopoDS_Shape.hxx>
#include <map>
#include <vector>
#include <boost/shared_ptr.hpp>
class SMDS_MeshNode;
class SMESHDS_Mesh;
class SMESH_Mesh;
/*!
2012-12-13 11:41:29 +00:00
* \brief Container of xD mesh elements substituting other ones in the
* input mesh of an (x+1)D algorithm
2012-08-09 10:03:55 +00:00
*/
class SMESH_EXPORT SMESH_ProxyMesh
{
public:
typedef boost::shared_ptr<SMESH_ProxyMesh> Ptr;
typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*, TIDCompare > TN2NMap;
//--------------------------------------------------------------------------------
/*!
* \brief Proxy sub-mesh
*/
2012-12-13 11:41:29 +00:00
class SMESH_EXPORT SubMesh : public SMESHDS_SubMesh
2012-08-09 10:03:55 +00:00
{
public:
2012-12-13 11:41:29 +00:00
const TN2NMap* GetNodeNodeMap() const { return _n2n; }
2012-08-09 10:03:55 +00:00
const SMDS_MeshNode* GetProxyNode( const SMDS_MeshNode* n ) const;
2012-12-13 11:41:29 +00:00
const UVPtStructVec& GetUVPtStructVec() const { return _uvPtStructVec; }
virtual void AddElement(const SMDS_MeshElement * e);
virtual int NbElements() const;
virtual int NbNodes() const;
2012-08-09 10:03:55 +00:00
virtual SMDS_ElemIteratorPtr GetElements() const;
2012-12-13 11:41:29 +00:00
virtual SMDS_NodeIteratorPtr GetNodes() const;
virtual void Clear();
virtual bool Contains(const SMDS_MeshElement * ME) const;
2012-08-09 10:03:55 +00:00
template< class ITERATOR >
void ChangeElements( ITERATOR it, ITERATOR end )
{
2012-12-13 11:41:29 +00:00
// change SubMesh contents without deleting tmp elements
2012-08-09 10:03:55 +00:00
// for which the caller is responsible
2012-12-13 11:41:29 +00:00
_elements.assign( it, end );
2012-08-09 10:03:55 +00:00
}
SubMesh(int index=0):SMESHDS_SubMesh(0,index),_n2n(0) {}
2012-12-13 11:41:29 +00:00
virtual ~SubMesh() { Clear(); }
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
protected:
2012-08-09 10:03:55 +00:00
std::vector<const SMDS_MeshElement *> _elements;
TN2NMap* _n2n;
2012-12-13 11:41:29 +00:00
UVPtStructVec _uvPtStructVec; // for SubMesh of EDGE
2012-08-09 10:03:55 +00:00
friend class SMESH_ProxyMesh;
};
//--------------------------------------------------------------------------------
// Public interface
SMESH_ProxyMesh();
SMESH_ProxyMesh(std::vector<SMESH_ProxyMesh::Ptr>& components);
SMESH_ProxyMesh(const SMESH_Mesh& mesh) { _mesh = &mesh; }
virtual ~SMESH_ProxyMesh();
2012-12-13 11:41:29 +00:00
// Returns the submesh of a shape; it can be a proxy sub-mesh
const SMESHDS_SubMesh* GetSubMesh(const TopoDS_Shape& shape) const;
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
// Returns the proxy sub-mesh of a shape; it can be NULL
const SubMesh* GetProxySubMesh(const TopoDS_Shape& shape) const;
2012-08-09 10:03:55 +00:00
// Returns the proxy node of a node; the input node is returned if no proxy exists
2012-12-13 11:41:29 +00:00
const SMDS_MeshNode* GetProxyNode( const SMDS_MeshNode* node ) const;
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
// Returns number of proxy sub-meshes
int NbProxySubMeshes() const;
// Returns iterator on all faces of the mesh taking into account substitutions.
2012-08-09 10:03:55 +00:00
// To be used in case of mesh without shape
2012-12-13 11:41:29 +00:00
SMDS_ElemIteratorPtr GetFaces() const;
2012-08-09 10:03:55 +00:00
// Returns iterator on all faces on the face taking into account substitutions
2012-12-13 11:41:29 +00:00
SMDS_ElemIteratorPtr GetFaces(const TopoDS_Shape& face) const;
2012-08-09 10:03:55 +00:00
// Return total nb of faces taking into account substitutions
2012-12-13 11:41:29 +00:00
int NbFaces() const;
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
bool IsTemporary(const SMDS_MeshElement* elem ) const;
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
SMESH_Mesh* GetMesh() const { return const_cast<SMESH_Mesh*>( _mesh ); }
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
SMESHDS_Mesh* GetMeshDS() const;
2012-08-09 10:03:55 +00:00
//--------------------------------------------------------------------------------
// Interface for descendants
protected:
2012-12-13 11:41:29 +00:00
void setMesh(const SMESH_Mesh& mesh) { _mesh = &mesh; }
int shapeIndex(const TopoDS_Shape& shape) const;
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
virtual SubMesh* newSubmesh(int index=0) const { return new SubMesh(index); }
2012-08-09 10:03:55 +00:00
// returns a proxy sub-mesh; zero index is for the case of mesh w/o shape
SubMesh* findProxySubMesh(int shapeIndex=0) const;
// returns a proxy sub-mesh; it is created if not yet exists
SubMesh* getProxySubMesh(int shapeIndex);
// returns a proxy sub-mesh; it is created if not yet exists
SubMesh* getProxySubMesh(const TopoDS_Shape& shape=TopoDS_Shape());
// move proxy sub-mesh from other proxy mesh to this, returns true if sub-mesh found
2012-12-13 11:41:29 +00:00
bool takeProxySubMesh( const TopoDS_Shape& shape, SMESH_ProxyMesh* proxyMesh );
2012-08-09 10:03:55 +00:00
// move tmp elements residing the _mesh from other proxy mesh to this
2012-12-13 11:41:29 +00:00
void takeTmpElemsInMesh( SMESH_ProxyMesh* proxyMesh );
2012-08-09 10:03:55 +00:00
2012-12-13 11:41:29 +00:00
// removes tmp element from the _mesh
void removeTmpElement( const SMDS_MeshElement* elem );
2012-08-09 10:03:55 +00:00
// stores tmp element residing the _mesh
2012-12-13 11:41:29 +00:00
void storeTmpElement( const SMDS_MeshElement* elem );
2012-08-09 10:03:55 +00:00
// store node-node correspondence
2012-12-13 11:41:29 +00:00
void setNode2Node(const SMDS_MeshNode* srcNode,
const SMDS_MeshNode* proxyNode,
const SubMesh* subMesh);
2012-08-09 10:03:55 +00:00
// types of elements needed to implement NbFaces() and GetFaces();
// if _allowedTypes is empty, only elements from _subMeshes are returned,
// else elements of _mesh filtered using allowedTypes are additionally returned
std::vector< SMDSAbs_EntityType> _allowedTypes;
private:
const SMESH_Mesh* _mesh;
// proxy sub-meshes; index in vector == shapeIndex(shape)
std::vector< SubMesh* > _subMeshes;
// tmp elements residing the _mesh, to be deleted at destruction
std::set< const SMDS_MeshElement* > _elemsInMesh;
// Complex submesh used to iterate over elements in other sub-meshes
mutable SubMesh _subContainer;
};
#endif