Commit e529f35d authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Removed ComposeHandle function overloading to avoid confusion

parent bee269a9
...@@ -137,7 +137,7 @@ namespace INMOST ...@@ -137,7 +137,7 @@ namespace INMOST
__INLINE INMOST_DATA_INTEGER_TYPE GetHandleElementNum (HandleType h) {return h >> handle_etype_shift;} __INLINE INMOST_DATA_INTEGER_TYPE GetHandleElementNum (HandleType h) {return h >> handle_etype_shift;}
__INLINE ElementType GetHandleElementType (HandleType h) {return 1 << GetHandleElementNum(h);} __INLINE ElementType GetHandleElementType (HandleType h) {return 1 << GetHandleElementNum(h);}
__INLINE HandleType ComposeHandle (ElementType etype, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((ElementNum(etype) << handle_etype_shift) + (1+ID));} __INLINE HandleType ComposeHandle (ElementType etype, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((ElementNum(etype) << handle_etype_shift) + (1+ID));}
__INLINE HandleType ComposeHandle (INMOST_DATA_INTEGER_TYPE etypenum, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((etypenum << handle_etype_shift) + (1+ID));} __INLINE HandleType ComposeHandleNum (INMOST_DATA_INTEGER_TYPE etypenum, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((etypenum << handle_etype_shift) + (1+ID));}
__INLINE bool isValidHandle (HandleType h) {return h != 0;} __INLINE bool isValidHandle (HandleType h) {return h != 0;}
...@@ -2933,7 +2933,7 @@ namespace INMOST ...@@ -2933,7 +2933,7 @@ namespace INMOST
void EndSequentialCode (); void EndSequentialCode ();
//iterator.cpp:::::::::::::::::::::::::::::::::::::::::::::::::: //iterator.cpp::::::::::::::::::::::::::::::::::::::::::::::::::
public: public:
Element ElementByLocalID (integer etypenum, integer lid) {assert(etypenum < 5 && (lid >= 0 && lid < static_cast<integer>(links[etypenum].size())) || (etypenum == 5 && lid == 0)); return Element(this,ComposeHandle(etypenum,lid));} Element ElementByLocalID (integer etypenum, integer lid) {assert(etypenum < 5 && (lid >= 0 && lid < static_cast<integer>(links[etypenum].size())) || (etypenum == 5 && lid == 0)); return Element(this,ComposeHandleNum(etypenum,lid));}
Element ElementByLocalID (ElementType etype, integer lid) {return ElementByLocalID(ElementNum(etype),lid);} Element ElementByLocalID (ElementType etype, integer lid) {return ElementByLocalID(ElementNum(etype),lid);}
Element ElementByHandle (HandleType h) {return Element(this,h);} Element ElementByHandle (HandleType h) {return Element(this,h);}
...@@ -2941,16 +2941,16 @@ namespace INMOST ...@@ -2941,16 +2941,16 @@ namespace INMOST
HandleType PrevHandle (HandleType h) const; //returns InvalidHandle() when go beyond first element HandleType PrevHandle (HandleType h) const; //returns InvalidHandle() when go beyond first element
HandleType NextHandle (HandleType h, ElementType mask) const; HandleType NextHandle (HandleType h, ElementType mask) const;
HandleType PrevHandle (HandleType h, ElementType mask) const; //returns InvalidHandle() when go beyond first element HandleType PrevHandle (HandleType h, ElementType mask) const; //returns InvalidHandle() when go beyond first element
HandleType FirstHandle () const {return ComposeHandle(ElementNum(NODE),0);} HandleType FirstHandle () const {return ComposeHandleNum(ElementNum(NODE),0);}
HandleType LastHandle () const {return ComposeHandle(ElementNum(MESH),1);} HandleType LastHandle () const {return ComposeHandleNum(ElementNum(MESH),1);}
HandleType FirstHandle (ElementType etype) const {return ComposeHandle(ElementNum(etype),0);} HandleType FirstHandle (ElementType etype) const {return ComposeHandleNum(ElementNum(etype),0);}
HandleType LastHandle (ElementType etype) const {integer num = ElementNum(etype); return ComposeHandle(num,static_cast<integer>(links[num].size()));} HandleType LastHandle (ElementType etype) const {integer num = ElementNum(etype); return ComposeHandleNum(num,static_cast<integer>(links[num].size()));}
Node NodeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[0].size())); return Node(this,ComposeHandle(0,lid)); } Node NodeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[0].size())); return Node(this,ComposeHandleNum(0,lid)); }
Edge EdgeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[1].size())); return Edge(this,ComposeHandle(1,lid)); } Edge EdgeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[1].size())); return Edge(this,ComposeHandleNum(1,lid)); }
Face FaceByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[2].size())); return Face(this,ComposeHandle(2,lid));} Face FaceByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[2].size())); return Face(this,ComposeHandleNum(2,lid));}
Cell CellByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[3].size())); return Cell(this,ComposeHandle(3,lid)); } Cell CellByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[3].size())); return Cell(this,ComposeHandleNum(3,lid)); }
ElementSet EsetByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[4].size())); return ElementSet(this,ComposeHandle(4,lid)); } ElementSet EsetByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[4].size())); return ElementSet(this,ComposeHandleNum(4,lid)); }
integer NodeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[0].size()) && links[0][lid] == -1) ++lid; return lid;} integer NodeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[0].size()) && links[0][lid] == -1) ++lid; return lid;}
integer EdgeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[1].size()) && links[1][lid] == -1) ++lid; return lid;} integer EdgeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[1].size()) && links[1][lid] == -1) ++lid; return lid;}
......
...@@ -50,7 +50,7 @@ namespace INMOST ...@@ -50,7 +50,7 @@ namespace INMOST
else break; else break;
} }
if( num == 5 && id > 0 ) id = 1; if( num == 5 && id > 0 ) id = 1;
return ComposeHandle(num,id); return ComposeHandleNum(num,id);
} }
HandleType Mesh::PrevHandle(HandleType h) const HandleType Mesh::PrevHandle(HandleType h) const
...@@ -61,7 +61,7 @@ namespace INMOST ...@@ -61,7 +61,7 @@ namespace INMOST
{ {
if( id < 0 ) if( id < 0 )
num = 4; num = 4;
else return ComposeHandle(ElementNum(MESH),0); else return ComposeHandleNum(ElementNum(MESH),0);
} }
while( num >= 0 ) while( num >= 0 )
{ {
...@@ -74,7 +74,7 @@ namespace INMOST ...@@ -74,7 +74,7 @@ namespace INMOST
else break; else break;
} }
if( num < 0 ) return InvalidHandle(); if( num < 0 ) return InvalidHandle();
return ComposeHandle(num,id); return ComposeHandleNum(num,id);
} }
HandleType Mesh::NextHandle(HandleType h, ElementType etype) const HandleType Mesh::NextHandle(HandleType h, ElementType etype) const
...@@ -102,7 +102,7 @@ namespace INMOST ...@@ -102,7 +102,7 @@ namespace INMOST
else break; else break;
} }
if( num == 5 && id > 0 ) id = 1; if( num == 5 && id > 0 ) id = 1;
return ComposeHandle(num,id); return ComposeHandleNum(num,id);
} }
HandleType Mesh::PrevHandle(HandleType h, ElementType etype) const HandleType Mesh::PrevHandle(HandleType h, ElementType etype) const
...@@ -127,7 +127,7 @@ namespace INMOST ...@@ -127,7 +127,7 @@ namespace INMOST
} }
if( stop ) return InvalidHandle(); if( stop ) return InvalidHandle();
} }
else return ComposeHandle(ElementNum(MESH),0); else return ComposeHandleNum(ElementNum(MESH),0);
} }
while( num >= 0 ) while( num >= 0 )
{ {
...@@ -150,7 +150,7 @@ namespace INMOST ...@@ -150,7 +150,7 @@ namespace INMOST
else break; else break;
} }
if( num < 0 ) return InvalidHandle(); if( num < 0 ) return InvalidHandle();
return ComposeHandle(num,id); return ComposeHandleNum(num,id);
} }
Storage::integer Mesh::FirstLocalID(ElementType etype) const Storage::integer Mesh::FirstLocalID(ElementType etype) const
......
...@@ -862,7 +862,7 @@ namespace INMOST ...@@ -862,7 +862,7 @@ namespace INMOST
Node Mesh::CreateNode(const real * coords) Node Mesh::CreateNode(const real * coords)
{ {
integer id = TieElement(0); integer id = TieElement(0);
HandleType h = ComposeHandle(0,id); HandleType h = ComposeHandleNum(0,id);
SetGeometricType(h,Element::Vertex); SetGeometricType(h,Element::Vertex);
real * v = static_cast<Storage::real *>(MGetDenseLink(h,CoordsTag())); real * v = static_cast<Storage::real *>(MGetDenseLink(h,CoordsTag()));
for(integer i = 0; i < dim; i++) v[i] = coords[i]; for(integer i = 0; i < dim; i++) v[i] = coords[i];
...@@ -912,7 +912,7 @@ namespace INMOST ...@@ -912,7 +912,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Edge(this,test),false); if (test != InvalidHandle()) return std::make_pair(Edge(this,test),false);
} }
integer id = TieElement(1); integer id = TieElement(1);
he = ComposeHandle(1,id); he = ComposeHandleNum(1,id);
for(ElementArray<Node>::size_type i = 0; i < nodes.size(); i++) for(ElementArray<Node>::size_type i = 0; i < nodes.size(); i++)
{ {
Element::adj_type & hc = HighConn(nodes.at(i)); Element::adj_type & hc = HighConn(nodes.at(i));
...@@ -1004,7 +1004,7 @@ namespace INMOST ...@@ -1004,7 +1004,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Face(this,test),false); if (test != InvalidHandle()) return std::make_pair(Face(this,test),false);
} }
integer id = TieElement(2); integer id = TieElement(2);
he = ComposeHandle(2,id); he = ComposeHandleNum(2,id);
for(ElementArray<Edge>::size_type i = 0; i < f_edges.size(); i++) for(ElementArray<Edge>::size_type i = 0; i < f_edges.size(); i++)
{ {
Element::adj_type & hc = HighConn(f_edges.at(i)); Element::adj_type & hc = HighConn(f_edges.at(i));
...@@ -1374,7 +1374,7 @@ namespace INMOST ...@@ -1374,7 +1374,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Cell(this,test),false); if (test != InvalidHandle()) return std::make_pair(Cell(this,test),false);
} }
integer id = TieElement(3); integer id = TieElement(3);
he = ComposeHandle(3,id); he = ComposeHandleNum(3,id);
for(ElementArray<Face>::size_type i = 0; i < c_faces.size(); i++) for(ElementArray<Face>::size_type i = 0; i < c_faces.size(); i++)
{ {
Element::adj_type & hc = HighConn(c_faces.at(i)); Element::adj_type & hc = HighConn(c_faces.at(i));
...@@ -1476,7 +1476,7 @@ namespace INMOST ...@@ -1476,7 +1476,7 @@ namespace INMOST
if( e->GetName() == name ) if( e->GetName() == name )
return std::make_pair(e->self(),false); return std::make_pair(e->self(),false);
} }
HandleType he = ComposeHandle(4,TieElement(4)); HandleType he = ComposeHandleNum(4,TieElement(4));
bulk_array set_name = BulkArrayDV(he,SetNameTag()); bulk_array set_name = BulkArrayDV(he,SetNameTag());
set_name.resize(static_cast<bulk_array::size_type>(name.size())); set_name.resize(static_cast<bulk_array::size_type>(name.size()));
memcpy(set_name.data(),name.c_str(),name.size()); memcpy(set_name.data(),name.c_str(),name.size());
...@@ -1498,7 +1498,7 @@ namespace INMOST ...@@ -1498,7 +1498,7 @@ namespace INMOST
Storage::integer j = 0; Storage::integer j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) ) for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
{ {
memcpy(temp.data()+j,MGetDenseLink(ComposeHandle(0,k),CoordsTag()),sizeof(Storage::real)*dims); memcpy(temp.data()+j,MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),sizeof(Storage::real)*dims);
j+=dims; j+=dims;
} }
...@@ -1507,7 +1507,7 @@ namespace INMOST ...@@ -1507,7 +1507,7 @@ namespace INMOST
j = 0; j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) ) for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
{ {
memcpy(MGetDenseLink(ComposeHandle(0,k),CoordsTag()),temp.data()+j,sizeof(Storage::real)*dims); memcpy(MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),temp.data()+j,sizeof(Storage::real)*dims);
j+=dims; j+=dims;
} }
dim = dims; dim = dims;
...@@ -1536,7 +1536,7 @@ namespace INMOST ...@@ -1536,7 +1536,7 @@ namespace INMOST
back_links[etypenum][ADDR] = -1; back_links[etypenum][ADDR] = -1;
empty_space[etypenum].push_back(ADDR); empty_space[etypenum].push_back(ADDR);
empty_links[etypenum].push_back(ID); empty_links[etypenum].push_back(ID);
//REPORT_VAL("destroyed",ComposeHandle(etypenum,ID) << " " << etypenum << " " << ADDR << " " << ID); //REPORT_VAL("destroyed",ComposeHandleNum(etypenum,ID) << " " << etypenum << " " << ADDR << " " << ID);
} }
} }
...@@ -1576,7 +1576,7 @@ namespace INMOST ...@@ -1576,7 +1576,7 @@ namespace INMOST
new_size = GetArrayCapacity(etypenum); new_size = GetArrayCapacity(etypenum);
if( new_size != old_size ) ReallocateData(etypenum,new_size); if( new_size != old_size ) ReallocateData(etypenum,new_size);
back_links[etypenum][ADDR] = ID; back_links[etypenum][ADDR] = ID;
last_created = ComposeHandle(etypenum,ID); last_created = ComposeHandleNum(etypenum,ID);
//REPORT_VAL("created",last_created << " " << etypenum << " " << ADDR << " " << ID); //REPORT_VAL("created",last_created << " " << etypenum << " " << ADDR << " " << ID);
} }
return ID; return ID;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment