Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / SMESH / SMESH_TypeDefs.hxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File      : SMESH_TypeDefs.hxx
23 // Created   : Thu Jan 27 18:38:33 2011
24 // Author    : Edward AGAPOV (eap)
25
26
27 #ifndef __SMESH_TypeDefs_HXX__
28 #define __SMESH_TypeDefs_HXX__
29
30 #include "SMESH_SMESH.hxx"
31
32 #include <SMDS_MeshNode.hxx>
33
34 #include <gp_XYZ.hxx>
35
36 #include <map>
37 #include <list>
38 #include <set>
39
40 typedef std::map<const SMDS_MeshElement*,
41                  std::list<const SMDS_MeshElement*> >        TElemOfElemListMap;
42 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
43
44 //!< Set of elements sorted by ID, to be used to assure predictability of edition
45 typedef std::set< const SMDS_MeshElement*, TIDCompare >      TIDSortedElemSet;
46 typedef std::set< const SMDS_MeshNode*,    TIDCompare >      TIDSortedNodeSet;
47
48 typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* >   NLink;
49
50
51 //=======================================================================
52 /*!
53  * \brief A sorted pair of nodes
54  */
55 //=======================================================================
56
57 struct SMESH_TLink: public NLink
58 {
59   SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
60   { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
61   SMESH_TLink(const NLink& link ):NLink( link )
62   { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
63   const SMDS_MeshNode* node1() const { return first; }
64   const SMDS_MeshNode* node2() const { return second; }
65 };
66
67 //=======================================================================
68 /*!
69  * \brief SMESH_TLink knowing its orientation
70  */
71 //=======================================================================
72
73 struct SMESH_OrientedLink: public SMESH_TLink
74 {
75   bool _reversed;
76   SMESH_OrientedLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 )
77     : SMESH_TLink( n1, n2 ), _reversed( n1 != node1() ) {}
78 };
79
80 //------------------------------------------
81 /*!
82  * \brief SMDS_MeshNode -> gp_XYZ convertor
83  */
84 //------------------------------------------
85 struct SMESH_TNodeXYZ : public gp_XYZ
86 {
87   const SMDS_MeshNode* _node;
88   SMESH_TNodeXYZ( const SMDS_MeshElement* e):gp_XYZ(0,0,0),_node(0) {
89     if (e) {
90       assert( e->GetType() == SMDSAbs_Node );
91       _node = static_cast<const SMDS_MeshNode*>(e);
92       SetCoord( _node->X(), _node->Y(), _node->Z() );
93     }
94   }
95   double Distance(const SMDS_MeshNode* n)       const { return (SMESH_TNodeXYZ( n )-*this).Modulus(); }
96   double SquareDistance(const SMDS_MeshNode* n) const { return (SMESH_TNodeXYZ( n )-*this).SquareModulus(); }
97   bool operator==(const SMESH_TNodeXYZ& other) const { return _node == other._node; }
98 };
99
100 // --------------------------------------------------------------------------------
101 // class SMESH_SequenceOfElemPtr
102 #include <NCollection_DefineSequence.hxx>
103
104 class SMDS_MeshElement;
105
106 typedef const SMDS_MeshElement* SMDS_MeshElementPtr;
107
108 DEFINE_BASECOLLECTION (SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
109 DEFINE_SEQUENCE (SMESH_SequenceOfElemPtr, SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
110
111
112 // --------------------------------------------------------------------------------
113 // class SMESH_SequenceOfNode
114 typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
115
116 DEFINE_BASECOLLECTION (SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
117 DEFINE_SEQUENCE(SMESH_SequenceOfNode,
118                 SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
119
120 // --------------------------------------------------------------------------------
121 // #include "SMESHDS_DataMapOfShape.hxx"
122
123 // #include <NCollection_DefineIndexedMap.hxx>
124
125 // #include <TopoDS_Shape.hxx>
126
127 ///  Class SMESH_IndexedMapOfShape
128
129 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionShape, TopoDS_Shape)
130 // DEFINE_INDEXEDMAP (SMESH_IndexedMapOfShape, SMESH_BaseCollectionShape, TopoDS_Shape)
131
132 ///  Class SMESH_IndexedDataMapOfShapeIndexedMapOfShape
133
134 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionIndexedMapOfShape, SMESH_IndexedMapOfShape)
135 // DEFINE_INDEXEDDATAMAP (SMESH_IndexedDataMapOfShapeIndexedMapOfShape,
136 //                        SMESH_BaseCollectionIndexedMapOfShape, TopoDS_Shape,
137 //                        SMESH_IndexedMapOfShape)
138
139 // --------------------------------------------------------------------------------
140 // class SMESH_DataMapOfElemPtrSequenceOfElemPtr
141
142 // SMESH_EXPORT 
143 // inline Standard_Integer HashCode(SMDS_MeshElementPtr theElem,
144 //                                  const Standard_Integer theUpper)
145 // {
146 //   void* anElem = (void*) theElem;
147 //   return HashCode(anElem,theUpper);
148 // }
149
150 // SMESH_EXPORT 
151 // inline Standard_Boolean IsEqual(SMDS_MeshElementPtr theOne,
152 //                                 SMDS_MeshElementPtr theTwo)
153 // {
154 //   return theOne == theTwo;
155 // }
156
157 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionSequenceOfElemPtr, SMESH_SequenceOfElemPtr)
158 // DEFINE_DATAMAP (SMESH_DataMapOfElemPtrSequenceOfElemPtr,
159 //                 SMESH_BaseCollectionSequenceOfElemPtr,
160 //                 SMDS_MeshElementPtr, SMESH_SequenceOfElemPtr)
161
162 #endif