X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshElement.cxx;h=a28aea08dd4ac0cb222d32e882e7a69ccc4ef53d;hp=df8be2d75dabe209ef8647dd40ad445d167d2451;hb=1fb3ff621ac19da15742a5e8b9253b594977d14a;hpb=c6248ade999eaffe5bbddbcaea61487811aa4e0c diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index df8be2d75..a28aea08d 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -1,177 +1,216 @@ -using namespace std; -// File: SMDS_MeshElement.cxx -// Created: Wed Jan 23 16:49:11 2002 -// Author: Jean-Michel BOULCOURT -// - - -#include "SMDS_MeshElement.ixx" +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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, or (at your option) any later version. +// +// 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 +// + +// SMESH SMDS : implementation of Salome mesh data structure +// +#ifdef _MSC_VER +#pragma warning(disable:4786) +#endif + +#include "SMDS_MeshElement.hxx" + +#include "SMDS_Mesh.hxx" +#include "SMDS_ElementFactory.hxx" + +#include "utilities.h" + +//================================================================================ +/*! + * \brief Constructor of a non-used element + */ +//================================================================================ + +SMDS_MeshElement::SMDS_MeshElement(): myHolder(0) +{ +} -//======================================================================= -//function : SMDS_MeshElement -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Check if a node is a medium node of a quadratic cell + */ +//================================================================================ -SMDS_MeshElement::SMDS_MeshElement(const Standard_Integer ID, const Standard_Integer nb,const SMDSAbs_ElementType Type) - :myID(ID),myNbNodes(nb),myType(Type) +bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const { + return !( GetNodeIndex( node ) < NbCornerNodes() ); } -//======================================================================= -//function : GetConnections -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return true if index of node is valid (0 <= ind < NbNodes()) + * \param ind - node index + * \retval bool - index check result + */ +//================================================================================ -Standard_Address SMDS_MeshElement::GetConnections() const +bool SMDS_MeshElement::IsValidIndex(const int ind) const { - return (Standard_Address)&myID; + return ( ind>-1 && ind= NbCornerNodes() ) return ind % NbCornerNodes(); + return ind; } +//================================================================================ +/*! + * \brief Check if a node belongs to the element + * \param node - the node to check + * \retval int - node index within the element, -1 if not found + */ +//================================================================================ -//======================================================================= -//function : InverseElements -//purpose : -//======================================================================= - -const SMDS_ListOfMeshElement& SMDS_MeshElement::InverseElements() const +int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const { - static SMDS_ListOfMeshElement empty; - return empty; + SMDS_ElemIteratorPtr nIt = nodesIterator(); + for ( int i = 0; nIt->more(); ++i ) + if ( nIt->next() == node ) + return i; + return -1; } -//======================================================================= -//function : ClearInverseElements -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return ID of an element + */ +//================================================================================ -void SMDS_MeshElement::ClearInverseElements() +int SMDS_MeshElement::GetID() const { + return myHolder ? myHolder->GetID( this ) : -1; } -//======================================================================= -//function : AddInverseElement -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Set ID of a shape this element was generated on + */ +//================================================================================ -void SMDS_MeshElement::AddInverseElement(const Handle(SMDS_MeshElement)& elem) +void SMDS_MeshElement::setShapeID( const int shapeID ) const { + const_cast( myHolder )->SetShapeID( this, shapeID ); } -//======================================================================= -//function : NbEdges -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return ID of a shape this element was generated on + */ +//================================================================================ -Standard_Integer SMDS_MeshElement::NbEdges() const +int SMDS_MeshElement::GetShapeID() const { - return 0; + return myHolder->GetShapeID( this ); } -//======================================================================= -//function : NbFaces -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return VTK ID of this element + */ +//================================================================================ -Standard_Integer SMDS_MeshElement::NbFaces() const +int SMDS_MeshElement::GetVtkID() const { - return 0; + return myHolder->GetVtkID( this ); } +//================================================================================ +/*! + * \brief Mark this element + */ +//================================================================================ -//======================================================================= -//function : GetEdgeDefinedByNodes -//purpose : -//======================================================================= - -void SMDS_MeshElement::GetEdgeDefinedByNodes(const Standard_Integer rank, - Standard_Integer& idnode1, - Standard_Integer& idnode2) const +void SMDS_MeshElement::setIsMarked( bool is ) const { - idnode1 = 0; - idnode2 = 0; + const_cast( myHolder )->SetIsMarked( this, is ); } -//======================================================================= -//function : GetFaceDefinedByNodes -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Check if this element is marked + */ +//================================================================================ -void SMDS_MeshElement::GetFaceDefinedByNodes(const Standard_Integer rank, - const Standard_Address idnode, - Standard_Integer& nb) const +bool SMDS_MeshElement::isMarked() const { - nb = 0; + return myHolder->IsMarked( this ); } -//======================================================================= -//function : SetNormal -//purpose : -//======================================================================= - -void SMDS_MeshElement::SetNormal(const Standard_Integer rank, - const Standard_Real vx, - const Standard_Real vy, - const Standard_Real vz) +//================================================================================ +/*! + * \brief Store VTK ID + */ +//================================================================================ +void SMDS_MeshElement::setVtkID( const int vtkID ) { - if (myNormals.IsNull()) { - myNormals = new TColgp_HArray1OfDir(1,NbNodes()); - } - myNormals->SetValue(rank, gp_Dir(vx,vy,vz)); + myHolder->SetVTKID( this, vtkID ); } -//======================================================================= -//function : SetNormal -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return the mesh this element belongs to + */ +//================================================================================ -void SMDS_MeshElement::SetNormal(const Standard_Integer rank, - const gp_Vec& V) +SMDS_Mesh* SMDS_MeshElement::GetMesh() const { - if (myNormals.IsNull()) { - myNormals = new TColgp_HArray1OfDir(1,NbNodes()); - } - myNormals->SetValue(rank, gp_Dir(V)); + return const_cast( myHolder )->GetMesh(); } -//======================================================================= -//function : GetNormal -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Return a SMDS_UnstructuredGrid + */ +//================================================================================ -gp_Dir SMDS_MeshElement::GetNormal(const Standard_Integer rank) +SMDS_UnstructuredGrid* SMDS_MeshElement::getGrid() const { - if (myNormals.IsNull()) { - myNormals = new TColgp_HArray1OfDir(1,NbNodes()); - } - return myNormals->Value(rank); + return const_cast( myHolder )->GetMesh()->GetGrid(); } -//======================================================================= -//function : Print -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Print self + */ +//================================================================================ -void SMDS_MeshElement::Print(Standard_OStream& OS) const +void SMDS_MeshElement::Print(ostream & OS) const { OS << "dump of mesh element" << endl; } - -Standard_OStream& operator << (Standard_OStream& OS - ,const Handle(SMDS_MeshElement)& ME) +ostream & operator <<(ostream & OS, const SMDS_MeshElement * e) { - ME->Print(OS); + e->Print(OS); return OS; }