Back to index

salome-smesh  6.5.0
SMESH_TypeDefs.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 // File      : SMESH_TypeDefs.hxx
00023 // Created   : Thu Jan 27 18:38:33 2011
00024 // Author    : Edward AGAPOV (eap)
00025 
00026 
00027 #ifndef __SMESH_TypeDefs_HXX__
00028 #define __SMESH_TypeDefs_HXX__
00029 
00030 #include "SMESH_Utils.hxx"
00031 
00032 #include <SMDS_MeshNode.hxx>
00033 
00034 #include <gp_XYZ.hxx>
00035 
00036 #include <map>
00037 #include <list>
00038 #include <set>
00039 #include <cassert>
00040 
00041 typedef std::map<const SMDS_MeshElement*,
00042                  std::list<const SMDS_MeshElement*> >        TElemOfElemListMap;
00043 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
00044 
00046 typedef std::set< const SMDS_MeshElement*, TIDCompare >      TIDSortedElemSet;
00047 typedef std::set< const SMDS_MeshNode*,    TIDCompare >      TIDSortedNodeSet;
00048 
00049 typedef std::pair< const SMDS_MeshNode*, const SMDS_MeshNode* >   NLink;
00050 
00051 
00052 namespace SMESHUtils
00053 {
00057   template <class TVECTOR>
00058   void FreeVector(TVECTOR& vec)
00059   {
00060     TVECTOR v2;
00061     vec.swap( v2 );
00062   }
00063 }
00064 
00065 //=======================================================================
00069 //=======================================================================
00070 
00071 struct SMESH_TLink: public NLink
00072 {
00073   SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
00074   { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
00075   SMESH_TLink(const NLink& link ):NLink( link )
00076   { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
00077   const SMDS_MeshNode* node1() const { return first; }
00078   const SMDS_MeshNode* node2() const { return second; }
00079 };
00080 
00081 //=======================================================================
00085 //=======================================================================
00086 
00087 struct SMESH_OrientedLink: public SMESH_TLink
00088 {
00089   bool _reversed;
00090   SMESH_OrientedLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 )
00091     : SMESH_TLink( n1, n2 ), _reversed( n1 != node1() ) {}
00092 };
00093 
00094 //------------------------------------------
00098 //------------------------------------------
00099 struct SMESH_TNodeXYZ : public gp_XYZ
00100 {
00101   const SMDS_MeshNode* _node;
00102   SMESH_TNodeXYZ( const SMDS_MeshElement* e):gp_XYZ(0,0,0),_node(0) {
00103     if (e) {
00104       assert( e->GetType() == SMDSAbs_Node );
00105       _node = static_cast<const SMDS_MeshNode*>(e);
00106       double xyz[3];
00107       _node->GetXYZ(xyz); // - thread safe gatting coords
00108       SetCoord( xyz[0], xyz[1], xyz[2] );
00109     }
00110   }
00111   double Distance(const SMDS_MeshNode* n)       const { return (SMESH_TNodeXYZ( n )-*this).Modulus(); }
00112   double SquareDistance(const SMDS_MeshNode* n) const { return (SMESH_TNodeXYZ( n )-*this).SquareModulus(); }
00113   bool operator==(const SMESH_TNodeXYZ& other) const { return _node == other._node; }
00114 };
00115 
00116 // --------------------------------------------------------------------------------
00117 // class SMESH_SequenceOfElemPtr
00118 #include <NCollection_DefineSequence.hxx>
00119 
00120 class SMDS_MeshElement;
00121 
00122 typedef const SMDS_MeshElement* SMDS_MeshElementPtr;
00123 
00124 DEFINE_BASECOLLECTION (SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
00125 DEFINE_SEQUENCE (SMESH_SequenceOfElemPtr, SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
00126 
00127 
00128 // --------------------------------------------------------------------------------
00129 // class SMESH_SequenceOfNode
00130 typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
00131 
00132 DEFINE_BASECOLLECTION (SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
00133 DEFINE_SEQUENCE(SMESH_SequenceOfNode,
00134                 SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
00135 
00136 // --------------------------------------------------------------------------------
00137 // #include "SMESHDS_DataMapOfShape.hxx"
00138 
00139 // #include <NCollection_DefineIndexedMap.hxx>
00140 
00141 // #include <TopoDS_Shape.hxx>
00142 
00144 
00145 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionShape, TopoDS_Shape)
00146 // DEFINE_INDEXEDMAP (SMESH_IndexedMapOfShape, SMESH_BaseCollectionShape, TopoDS_Shape)
00147 
00149 
00150 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionIndexedMapOfShape, SMESH_IndexedMapOfShape)
00151 // DEFINE_INDEXEDDATAMAP (SMESH_IndexedDataMapOfShapeIndexedMapOfShape,
00152 //                        SMESH_BaseCollectionIndexedMapOfShape, TopoDS_Shape,
00153 //                        SMESH_IndexedMapOfShape)
00154 
00155 // --------------------------------------------------------------------------------
00156 // class SMESH_DataMapOfElemPtrSequenceOfElemPtr
00157 
00158 // SMESHUtils_EXPORT 
00159 // inline Standard_Integer HashCode(SMDS_MeshElementPtr theElem,
00160 //                                  const Standard_Integer theUpper)
00161 // {
00162 //   void* anElem = (void*) theElem;
00163 //   return HashCode(anElem,theUpper);
00164 // }
00165 
00166 // SMESHUtils_EXPORT 
00167 // inline Standard_Boolean IsEqual(SMDS_MeshElementPtr theOne,
00168 //                                 SMDS_MeshElementPtr theTwo)
00169 // {
00170 //   return theOne == theTwo;
00171 // }
00172 
00173 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionSequenceOfElemPtr, SMESH_SequenceOfElemPtr)
00174 // DEFINE_DATAMAP (SMESH_DataMapOfElemPtrSequenceOfElemPtr,
00175 //                 SMESH_BaseCollectionSequenceOfElemPtr,
00176 //                 SMDS_MeshElementPtr, SMESH_SequenceOfElemPtr)
00177 
00178 #endif