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

Sync current updates

parent f531fdce
......@@ -42,11 +42,7 @@ namespace INMOST
adjacent<Node> Cell::getNodes()
{
if( !GetMeshLink()->HideMarker() )
{
adjacent<Node> ret(high_conn.begin(),high_conn.end());
assert(high_conn.size() == ret.size());
return ret;
}
return adjacent<Node>(high_conn.begin(),high_conn.end());
else
{
MIDType hm = GetMeshLink()->HideMarker();
......@@ -56,6 +52,25 @@ namespace INMOST
return aret;
}
}
adjacent<Node> Cell::getNodes(MIDType mask)
{
adjacent<Node> aret;
if( !GetMeshLink()->HideMarker() )
{
for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) aret.push_back((*it));
}
else
{
MIDType hm = GetMeshLink()->HideMarker();
for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
adjacent<Edge> Cell::getEdges()
{
adjacent<Edge> aret;
......@@ -152,6 +167,135 @@ namespace INMOST
}
return aret;
}
adjacent<Edge> Cell::getEdges(MIDType mask)
{
adjacent<Edge> aret;
if( !GetMeshLink()->HideMarker() )
{
if( GetElementDimension() == 2 ) // This cell is 2d face
{
aret.reserve(low_conn.size());
Element * last, * first;
Element * q = low_conn[0]; //edge 0
if( q->low_conn[0]->GetMarker(mask) ) aret.push_back(q->low_conn[0]); //node 0
if( q->low_conn[1]->GetMarker(mask) ) aret.push_back(q->low_conn[1]); //node 1
first = q->low_conn[0];
last = q->low_conn[1];
Element * r = low_conn[1]; //edge 1
if( first == r->low_conn[0] || first == r->low_conn[1] )
{
last = first;
if( aret.size() > 1 )
{
Edge * temp = aret.data()[0];
aret.data()[0] = aret.data()[1];
aret.data()[1] = temp;
}
}
adj_iterator it = low_conn.begin()+1, iend = low_conn.end()-1;
while(it != iend) //loop over edges
{
if( last == (*it)->low_conn[0] )
{
last = (*it)->low_conn[1];
if( last->GetMarker(mask) ) aret.push_back(last);
}
else
{
last = (*it)->low_conn[0];
if( last->GetMarker(mask) ) aret.push_back(last);
}
++it;
}
}
else
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
for(Element::adj_iterator it = low_conn.begin(); it != low_conn.end(); it++) //faces
for(Element::adj_iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++) //edges
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk))
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
}
for(adjacent<Edge>::iterator it = aret.begin(); it != aret.end(); it++)
it->RemMarker(mrk);
m->ReleaseMarker(mrk);
}
}
else
{
MIDType hm = GetMeshLink()->HideMarker();
if( GetElementDimension() == 2 ) // This cell is 2d face
{
INMOST_DATA_ENUM_TYPE i = static_cast<INMOST_DATA_ENUM_TYPE>(-1),
k = static_cast<INMOST_DATA_ENUM_TYPE>(-1),
k1 = static_cast<INMOST_DATA_ENUM_TYPE>(-1), k2;
Element * last, * first;
aret.reserve(low_conn.size());
i = Mesh::getNext(&low_conn[0],low_conn.size(),i,hm);
Element * q = low_conn[i]; //edge 0
k = Mesh::getNext(&q->low_conn[0],q->low_conn.size(),k,hm);
if( q->low_conn[k]->GetMarker(mask) ) aret.push_back(q->low_conn[k]); //node 0
first = q->low_conn[k];
k = Mesh::getNext(&q->low_conn[0],q->low_conn.size(),k,hm);
if( q->low_conn[k]->GetMarker(mask) ) aret.push_back(q->low_conn[k]); //node 1
last = q->low_conn[k];
i = Mesh::getNext(&low_conn[0],low_conn.size(),i,hm);
Element * r = low_conn[i]; //edge 1
k1 = Mesh::getNext(&q->low_conn[0],q->low_conn.size(),k1,hm);
k2 = Mesh::getNext(&q->low_conn[0],q->low_conn.size(),k1,hm);
if( first == r->low_conn[k1] || first == r->low_conn[k2] )
{
last = first;
if( aret.size() > 1 )
{
Edge * temp = aret.data()[0];
aret.data()[0] = aret.data()[1];
aret.data()[1] = temp;
}
}
adj_iterator it = low_conn.begin()+1, iend = low_conn.end()-1;
while(it != iend) if( !(*it)->GetMarker(hm) ) //loop over edges
{
k1 = static_cast<INMOST_DATA_ENUM_TYPE>(-1);
k1 = Mesh::getNext(&(*it)->low_conn[0],(*it)->low_conn.size(),k1,hm);
k2 = Mesh::getNext(&(*it)->low_conn[0],(*it)->low_conn.size(),k1,hm);
if( last == (*it)->low_conn[k1] )
{
last = (*it)->low_conn[k2];
if( last->GetMarker(mask) ) aret.push_back(last);
}
else
{
last = (*it)->low_conn[k1];
if( last->GetMarker(mask) ) aret.push_back(last);
}
++it;
}
}
else
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
for(Element::adj_iterator it = low_conn.begin(); it != low_conn.end(); it++) if( !(*it)->GetMarker(hm) ) //faces
for(Element::adj_iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++) if( !(*jt)->GetMarker(hm) )//edges
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk))
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
}
for(adjacent<Edge>::iterator it = aret.begin(); it != aret.end(); it++)
it->RemMarker(mrk);
m->ReleaseMarker(mrk);
}
}
return aret;
}
adjacent<Face> Cell::getFaces()
{
if( !GetMeshLink()->HideMarker() )
......@@ -165,6 +309,25 @@ namespace INMOST
return aret;
}
}
adjacent<Face> Cell::getFaces(MIDType mask)
{
adjacent<Face> aret;
if( !GetMeshLink()->HideMarker() )
{
for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) aret.push_back((*it));
}
else
{
MIDType hm = GetMeshLink()->HideMarker();
for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
......
......@@ -388,13 +388,14 @@ namespace INMOST
etype & operator *() { return *e; }
etype * operator ->() { return e; }
_iterator & operator =(_iterator const & other) { e = other.e; return *this; }
bool operator ==(const _iterator & other) { return e == other.e;}
bool operator !=(const _iterator & other) { return e != other.e;}
bool operator <(const _iterator & other) { return e < other.e;}
bool operator >(const _iterator & other) { return e > other.e;}
bool operator <=(const _iterator & other) { return e <= other.e;}
bool operator >=(const _iterator & other) { return e >= other.e;}
bool operator ==(const _iterator & other) const { return e == other.e;}
bool operator !=(const _iterator & other) const { return e != other.e;}
bool operator <(const _iterator & other) const { return e < other.e;}
bool operator >(const _iterator & other) const { return e > other.e;}
bool operator <=(const _iterator & other) const { return e <= other.e;}
bool operator >=(const _iterator & other) const { return e >= other.e;}
operator void *() {return static_cast<void *> (e);}
operator const void *() {return const_cast<const void *> (e);}
};
typedef _iterator<element> iterator;
typedef _iterator<const element> const_iterator;
......@@ -425,12 +426,12 @@ namespace INMOST
etype & operator *() { return *e; }
etype * operator ->() { return e; }
_reverse_iterator & operator =(_reverse_iterator const & other) { e = other.e; return *this;}
bool operator ==(const _reverse_iterator & other) { return e == other.e;}
bool operator !=(const _reverse_iterator & other) { return e != other.e;}
bool operator <(const _reverse_iterator & other) { return e < other.e;}
bool operator >(const _reverse_iterator & other) { return e > other.e;}
bool operator <=(const _reverse_iterator & other) { return e <= other.e;}
bool operator >=(const _reverse_iterator & other) { return e >= other.e;}
bool operator ==(const _reverse_iterator & other) const { return e == other.e;}
bool operator !=(const _reverse_iterator & other) const { return e != other.e;}
bool operator <(const _reverse_iterator & other) const { return e < other.e;}
bool operator >(const _reverse_iterator & other) const { return e > other.e;}
bool operator <=(const _reverse_iterator & other) const { return e <= other.e;}
bool operator >=(const _reverse_iterator & other) const { return e >= other.e;}
operator void *() {return static_cast<void *> (e);}
};
typedef _reverse_iterator<element> reverse_iterator;
......
This diff is collapsed.
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