1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESH_TypeDefs.hxx
23 // Created : Thu Jan 27 18:38:33 2011
24 // Author : Edward AGAPOV (eap)
27 #ifndef __SMESH_TypeDefs_HXX__
28 #define __SMESH_TypeDefs_HXX__
30 #include "SMESH_Utils.hxx"
32 #include <SMDS_MeshNode.hxx>
41 typedef std::map<const SMDS_MeshElement*,
42 std::list<const SMDS_MeshElement*> > TElemOfElemListMap;
43 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
45 //!< Set of elements sorted by ID, to be used to assure predictability of edition
46 typedef std::set< const SMDS_MeshElement*, TIDCompare > TIDSortedElemSet;
47 typedef std::set< const SMDS_MeshNode*, TIDCompare > TIDSortedNodeSet;
49 typedef std::pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
51 struct faceQuadStruct; // defined in StdMeshers_Quadrangle_2D.hxx
52 typedef boost::shared_ptr<faceQuadStruct> TFaceQuadStructPtr;
58 * \brief Enforce freeing memory allocated by std::vector
60 template <class TVECTOR>
61 void FreeVector(TVECTOR& vec)
66 template <class TVECTOR>
67 void CompactVector(TVECTOR& vec)
74 //=======================================================================
76 * \brief A sorted pair of nodes
78 //=======================================================================
80 struct SMESH_TLink: public NLink
82 SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
83 { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
84 SMESH_TLink(const NLink& link ):NLink( link )
85 { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
86 const SMDS_MeshNode* node1() const { return first; }
87 const SMDS_MeshNode* node2() const { return second; }
90 //=======================================================================
92 * \brief SMESH_TLink knowing its orientation
94 //=======================================================================
96 struct SMESH_OrientedLink: public SMESH_TLink
99 SMESH_OrientedLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 )
100 : SMESH_TLink( n1, n2 ), _reversed( n1 != node1() ) {}
103 //------------------------------------------
105 * \brief SMDS_MeshNode -> gp_XYZ convertor
107 //------------------------------------------
108 struct SMESH_TNodeXYZ : public gp_XYZ
110 const SMDS_MeshNode* _node;
112 SMESH_TNodeXYZ( const SMDS_MeshElement* e=0):gp_XYZ(0,0,0),_node(0) {
114 assert( e->GetType() == SMDSAbs_Node );
115 _node = static_cast<const SMDS_MeshNode*>(e);
116 _node->GetXYZ(_xyz); // - thread safe getting coords
117 SetCoord( _xyz[0], _xyz[1], _xyz[2] );
120 double Distance(const SMDS_MeshNode* n) const { return (SMESH_TNodeXYZ( n )-*this).Modulus(); }
121 double SquareDistance(const SMDS_MeshNode* n) const { return (SMESH_TNodeXYZ( n )-*this).SquareModulus(); }
122 bool operator==(const SMESH_TNodeXYZ& other) const { return _node == other._node; }
125 //--------------------------------------------------
127 * \brief Data of a node generated on FACE boundary
129 //--------------------------------------------------
130 typedef struct uvPtStruct
134 double u, v; // original 2d parameter
135 double x, y; // 2d parameter, normalized [0,1]
136 const SMDS_MeshNode * node;
138 struct NodeAccessor // accessor to iterate on nodes in UVPtStructVec
140 static const SMDS_MeshNode* value(std::vector< uvPtStruct >::const_iterator it)
145 typedef std::vector< UVPtStruct > UVPtStructVec;
147 // --------------------------------------------------------------------------------
148 // class SMESH_SequenceOfElemPtr
149 #include <NCollection_DefineSequence.hxx>
151 class SMDS_MeshElement;
153 typedef const SMDS_MeshElement* SMDS_MeshElementPtr;
155 DEFINE_BASECOLLECTION (SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
156 DEFINE_SEQUENCE (SMESH_SequenceOfElemPtr, SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)
159 // --------------------------------------------------------------------------------
160 // class SMESH_SequenceOfNode
161 typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
163 DEFINE_BASECOLLECTION (SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
164 DEFINE_SEQUENCE(SMESH_SequenceOfNode,
165 SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr)
167 // --------------------------------------------------------------------------------
168 // #include "SMESHDS_DataMapOfShape.hxx"
170 // #include <NCollection_DefineIndexedMap.hxx>
172 // #include <TopoDS_Shape.hxx>
174 /// Class SMESH_IndexedMapOfShape
176 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionShape, TopoDS_Shape)
177 // DEFINE_INDEXEDMAP (SMESH_IndexedMapOfShape, SMESH_BaseCollectionShape, TopoDS_Shape)
179 /// Class SMESH_IndexedDataMapOfShapeIndexedMapOfShape
181 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionIndexedMapOfShape, SMESH_IndexedMapOfShape)
182 // DEFINE_INDEXEDDATAMAP (SMESH_IndexedDataMapOfShapeIndexedMapOfShape,
183 // SMESH_BaseCollectionIndexedMapOfShape, TopoDS_Shape,
184 // SMESH_IndexedMapOfShape)
186 // --------------------------------------------------------------------------------
187 // class SMESH_DataMapOfElemPtrSequenceOfElemPtr
190 // inline Standard_Integer HashCode(SMDS_MeshElementPtr theElem,
191 // const Standard_Integer theUpper)
193 // void* anElem = (void*) theElem;
194 // return HashCode(anElem,theUpper);
198 // inline Standard_Boolean IsEqual(SMDS_MeshElementPtr theOne,
199 // SMDS_MeshElementPtr theTwo)
201 // return theOne == theTwo;
204 // DEFINE_BASECOLLECTION (SMESH_BaseCollectionSequenceOfElemPtr, SMESH_SequenceOfElemPtr)
205 // DEFINE_DATAMAP (SMESH_DataMapOfElemPtrSequenceOfElemPtr,
206 // SMESH_BaseCollectionSequenceOfElemPtr,
207 // SMDS_MeshElementPtr, SMESH_SequenceOfElemPtr)