1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMDS_MapOfMeshOrientedElement.cxx
25 // Author : Jean-Michel BOULCOURT
29 #include "SMDS_MapOfMeshOrientedElement.ixx"
30 #include <Standard_NoSuchObject.hxx>
33 #ifndef _Standard_DomainError_HeaderFile
34 #include <Standard_DomainError.hxx>
36 #ifndef _SMDS_MeshElement_HeaderFile
37 #include "SMDS_MeshElement.hxx"
39 #ifndef _SMDS_MeshElementMapHasher_HeaderFile
40 #include "SMDS_MeshElementMapHasher.hxx"
42 #ifndef _SMDS_StdMapNodeOfExtendedOrientedMap_HeaderFile
43 #include "SMDS_StdMapNodeOfExtendedOrientedMap.hxx"
45 #ifndef _SMDS_MapIteratorOfExtendedOrientedMap_HeaderFile
46 #include "SMDS_MapIteratorOfExtendedOrientedMap.hxx"
50 #define TheKey Handle_SMDS_MeshElement
51 #define TheKey_hxx <SMDS_MeshElement.hxx>
52 #define Hasher SMDS_MeshElementMapHasher
53 #define Hasher_hxx <SMDS_MeshElementMapHasher.hxx>
54 #define TCollection_StdMapNode SMDS_StdMapNodeOfExtendedOrientedMap
55 #define TCollection_StdMapNode_hxx <SMDS_StdMapNodeOfExtendedOrientedMap.hxx>
56 #define TCollection_MapIterator SMDS_MapIteratorOfExtendedOrientedMap
57 #define TCollection_MapIterator_hxx <SMDS_MapIteratorOfExtendedOrientedMap.hxx>
58 #define Handle_TCollection_StdMapNode Handle_SMDS_StdMapNodeOfExtendedOrientedMap
59 #define TCollection_StdMapNode_Type_() SMDS_StdMapNodeOfExtendedOrientedMap_Type_()
60 #define TCollection_Map SMDS_ExtendedOrientedMap
61 #define TCollection_Map_hxx <SMDS_ExtendedOrientedMap.hxx>
65 //=======================================================================
68 //=======================================================================
70 const Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::Find(const TheKey& K) const
73 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
75 // Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::Find");
76 TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
77 TCollection_StdMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
79 if (Hasher::IsEqual(p->Key(),K)) {
82 p = (TCollection_StdMapNode*) p->Next();
84 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
88 //=======================================================================
89 //function : ChangeFind
91 //=======================================================================
93 Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::ChangeFind(const TheKey& K)
96 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::ChangeFind");
98 //Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::ChangeFind");
99 TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
100 TCollection_StdMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
102 if (Hasher::IsEqual(p->Key(),K)) {
105 p = (TCollection_StdMapNode*) p->Next();
107 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::ChangeFind");
112 //=======================================================================
115 //=======================================================================
117 const Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::FindID(const Standard_Integer ID) const
120 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::FindID");
122 // Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::Find");
123 TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
124 TCollection_StdMapNode* p = data[ID % NbBuckets()];
126 if (p->Key()->GetID() == ID) {
129 p = (TCollection_StdMapNode*) p->Next();
131 Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
135 //=======================================================================
136 //function : ContainsID
138 //=======================================================================
140 Standard_Boolean SMDS_MapOfMeshOrientedElement::ContainsID(const Standard_Integer ID) const
142 if (IsEmpty()) return Standard_False;
143 TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
144 TCollection_StdMapNode* p = data[ID % NbBuckets()];
146 if (p->Key()->GetID() == ID) {
147 return Standard_True;
149 p = (TCollection_StdMapNode*)p->Next();
151 return Standard_False;