Commit 5e041bc3 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

some updates

Retrieval of elements by markers;
Introduced options for loading of files;
Fixed issues saving vtk format when not all topological tests are
active;
Introduced Connect / Disconnect functions for manipulations with mesh;
DrawGrid example can now visualize array of entered cells/faces for
debug purposes;
OldDrawGrid example demonstrates fast interactive mesh slicing and
onscreen element picking.
parent b8d47cc5
......@@ -54,19 +54,19 @@ namespace INMOST
}
adjacent<Node> Cell::getNodes(MIDType mask)
adjacent<Node> Cell::getNodes(MIDType mask, bool invert)
{
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));
if( invert ^ (*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));
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
......@@ -169,7 +169,7 @@ namespace INMOST
}
adjacent<Edge> Cell::getEdges(MIDType mask)
adjacent<Edge> Cell::getEdges(MIDType mask, bool invert)
{
adjacent<Edge> aret;
if( !GetMeshLink()->HideMarker() )
......@@ -179,8 +179,8 @@ namespace INMOST
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
if( invert ^ q->low_conn[0]->GetMarker(mask) ) aret.push_back(q->low_conn[0]); //node 0
if( invert ^ 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
......@@ -200,12 +200,12 @@ namespace INMOST
if( last == (*it)->low_conn[0] )
{
last = (*it)->low_conn[1];
if( last->GetMarker(mask) ) aret.push_back(last);
if( invert ^ last->GetMarker(mask) ) aret.push_back(last);
}
else
{
last = (*it)->low_conn[0];
if( last->GetMarker(mask) ) aret.push_back(last);
if( invert ^ last->GetMarker(mask) ) aret.push_back(last);
}
++it;
}
......@@ -216,7 +216,7 @@ namespace INMOST
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))
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk))
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -239,10 +239,10 @@ namespace INMOST
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
if( invert ^ 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
if( invert ^ 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
......@@ -267,12 +267,12 @@ namespace INMOST
if( last == (*it)->low_conn[k1] )
{
last = (*it)->low_conn[k2];
if( last->GetMarker(mask) ) aret.push_back(last);
if( invert ^ last->GetMarker(mask) ) aret.push_back(last);
}
else
{
last = (*it)->low_conn[k1];
if( last->GetMarker(mask) ) aret.push_back(last);
if( invert ^ last->GetMarker(mask) ) aret.push_back(last);
}
++it;
}
......@@ -283,7 +283,7 @@ namespace INMOST
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))
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk))
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -311,19 +311,19 @@ namespace INMOST
}
adjacent<Face> Cell::getFaces(MIDType mask)
adjacent<Face> Cell::getFaces(MIDType mask, bool invert)
{
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));
if( invert ^ (*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));
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
......
......@@ -1833,6 +1833,8 @@ namespace INMOST
}
}
public:
element * data() {return pbegin;}
const element * data() const {return pbegin;}
void report_addr()
{
std::cout << "stack: " << &stack << std::endl;
......
......@@ -84,19 +84,19 @@ namespace INMOST
}
}
adjacent<Node> Edge::getNodes(MIDType mask)
adjacent<Node> Edge::getNodes(MIDType mask, bool invert)
{
adjacent<Node> aret;
if( !GetMeshLink()->HideMarker() )
{
for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) aret.push_back((*it));
if( invert ^ (*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));
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
......@@ -116,19 +116,19 @@ namespace INMOST
}
adjacent<Face> Edge::getFaces(MIDType mask)
adjacent<Face> Edge::getFaces(MIDType mask, bool invert)
{
adjacent<Face> aret;
if( !GetMeshLink()->HideMarker() )
{
for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) aret.push_back((*it));
if( (invert ^ (*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));
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
}
return aret;
}
......@@ -165,7 +165,7 @@ namespace INMOST
return aret;
}
adjacent<Cell> Edge::getCells(MIDType mask)
adjacent<Cell> Edge::getCells(MIDType mask, bool invert)
{
adjacent<Cell> aret;
Mesh * m = GetMeshLink();
......@@ -174,7 +174,7 @@ namespace INMOST
{
for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) //faces
for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) //cels
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -185,7 +185,7 @@ namespace INMOST
MIDType hm = GetMeshLink()->HideMarker();
for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) if( !(*it)->GetMarker(hm) ) //faces
for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) if( !(*jt)->GetMarker(hm) ) //cels
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
aret.push_back(*jt);
(*jt)->SetMarker(mrk);
......
......@@ -232,7 +232,7 @@ namespace INMOST
}
INMOST_DATA_ENUM_TYPE Element::nbAdjElements(ElementType _etype, MIDType mask)const
INMOST_DATA_ENUM_TYPE Element::nbAdjElements(ElementType _etype, MIDType mask, bool invert)const
{
assert( !(_etype & MESH) );
assert( !(_etype & ESET) );
......@@ -252,17 +252,17 @@ namespace INMOST
{
if( i == myconn )
{
if( GetMarker(mask) ) ret += 1;
if( invert ^ GetMarker(mask) ) ret += 1;
}
else if( i == (myconn + 1 + 4)%4 )
{
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) ret++;
if( invert ^ (*it)->GetMarker(mask) ) ret++;
}
else if( i == (myconn - 1 + 4)%4 )
{
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) ret++;
if( invert ^ (*it)->GetMarker(mask) ) ret++;
}
else if( i == (myconn - 2 + 4)%4 )
{
......@@ -272,7 +272,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); it++)
for(adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++)
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -290,7 +290,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); it++)
for(adj_iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++)
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -311,17 +311,17 @@ namespace INMOST
{
if( i == myconn )
{
if( !GetMarker(hm) && GetMarker(mask) ) ret ++;
if( !GetMarker(hm) && (invert ^ GetMarker(mask)) ) ret ++;
}
else if( i == (myconn + 1 + 4)%4 )
{
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( !(*it)->GetMarker(hm) && (*it)->GetMarker(mask) ) ret++;
if( !(*it)->GetMarker(hm) && (invert ^ (*it)->GetMarker(mask)) ) ret++;
}
else if( i == (myconn - 1 + 4)%4 )
{
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( !(*it)->GetMarker(hm) && (*it)->GetMarker(mask) ) ret++;
if( !(*it)->GetMarker(hm) && (invert ^ (*it)->GetMarker(mask)) ) ret++;
}
else if( i == (myconn - 2 + 4)%4 )
{
......@@ -331,7 +331,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); it++) if( !(*it)->GetMarker(hm) )
for(adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) if( !(*jt)->GetMarker(hm) )
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -349,7 +349,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); it++) if( !(*it)->GetMarker(hm) )
for(adj_iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++) if( !(*jt)->GetMarker(hm) )
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -492,7 +492,7 @@ namespace INMOST
return result;
}
adjacent<Element> Element::getAdjElements(ElementType _etype, MIDType mask) const
adjacent<Element> Element::getAdjElements(ElementType _etype, MIDType mask, bool invert) const
{
assert( !(_etype & MESH) );
assert( !(_etype & ESET) );
......@@ -513,18 +513,18 @@ namespace INMOST
{
if( i == myconn )
{
if( GetMarker(mask) ) result.push_back(const_cast<Element *>(this));
if( invert ^ GetMarker(mask) ) result.push_back(const_cast<Element *>(this));
}
else if( i == (myconn + 1 + 4)%4 )
{
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) result.push_back(*it);
if( invert ^ (*it)->GetMarker(mask) ) result.push_back(*it);
}
else if( i == (myconn - 1 + 4)%4 )
{
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) ) result.push_back(*it);
if( invert ^ (*it)->GetMarker(mask) ) result.push_back(*it);
}
else if( i == (myconn - 2 + 4)%4 )
{
......@@ -534,7 +534,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); it++)
for(adj_type::iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++)
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -549,7 +549,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); it++)
for(adj_type::iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++)
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -568,19 +568,19 @@ namespace INMOST
{
if( i == myconn )
{
if( !GetMarker(hm) && GetMarker(mask) )
if( !GetMarker(hm) && (invert ^ GetMarker(mask)) )
result.push_back(const_cast<Element *>(this));
}
else if( i == (myconn + 1 + 4)%4 )
{
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
if( (*it)->GetMarker(mask) && !(*it)->GetMarker(hm) ) result.push_back(*it);
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) result.push_back(*it);
}
else if( i == (myconn - 1 + 4)%4 )
{
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
if( (*it)->GetMarker(mask) && !(*it)->GetMarker(hm) ) result.push_back(*it);
if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) result.push_back(*it);
}
else if( i == (myconn - 2 + 4)%4 )
{
......@@ -590,7 +590,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = high_conn.begin(); it != high_conn.end(); it++) if( !(*it)->GetMarker(hm) )
for(adj_type::iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) if( !(*jt)->GetMarker(hm) )
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -605,7 +605,7 @@ namespace INMOST
MIDType mrk = m->CreateMarker();
for(adj_type::const_iterator it = low_conn.begin(); it != low_conn.end(); it++) if( !(*it)->GetMarker(hm) )
for(adj_type::iterator jt = (*it)->low_conn.begin(); jt != (*it)->low_conn.end(); jt++) if( !(*jt)->GetMarker(hm) )
if( (*jt)->GetMarker(mask) && !(*jt)->GetMarker(mrk) )
if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk) )
{
result.push_back(*jt);
(*jt)->SetMarker(mrk);
......@@ -657,28 +657,28 @@ namespace INMOST
return ret; //this operation will be virtualized by proper algorithm
}
adjacent<Node> Element::getNodes(MIDType mask)
adjacent<Node> Element::getNodes(MIDType mask,bool invert)
{
adjacent<Node> ret;
if( GetMarker(mask) ) ret.push_back(this);
if( invert ^ GetMarker(mask) ) ret.push_back(this);
return ret; //this operation will be virtualized by proper algorithm
}
adjacent<Edge> Element::getEdges(MIDType mask)
adjacent<Edge> Element::getEdges(MIDType mask,bool invert)
{
adjacent<Edge> ret;
if( GetMarker(mask) ) ret.push_back(this);
if( invert ^ GetMarker(mask) ) ret.push_back(this);
return ret; //this operation will be virtualized by proper algorithm
}
adjacent<Face> Element::getFaces(MIDType mask)
adjacent<Face> Element::getFaces(MIDType mask,bool invert)
{
adjacent<Face> ret;
if( GetMarker(mask) ) ret.push_back(this);
if( invert ^ GetMarker(mask) ) ret.push_back(this);
return ret; //this operation will be virtualized by proper algorithm
}
adjacent<Cell> Element::getCells(MIDType mask)
adjacent<Cell> Element::getCells(MIDType mask,bool invert)
{
adjacent<Cell> ret;
if( GetMarker(mask) ) ret.push_back(this);
if( invert ^ GetMarker(mask) ) ret.push_back(this);
return ret; //this operation will be virtualized by proper algorithm
}
......@@ -810,7 +810,7 @@ namespace INMOST
adjacent<Element> Element::BridgeAdjacencies(ElementType Bridge, ElementType Dest, MIDType mask)
adjacent<Element> Element::BridgeAdjacencies(ElementType Bridge, ElementType Dest, MIDType mask, bool invert)
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
......@@ -822,7 +822,7 @@ namespace INMOST
{
adjacent<Element> sub = it->getAdjElements(Dest);
for(adjacent<Element>::iterator jt = sub.begin(); jt != sub.end(); jt++)
if( !jt->GetMarker(mrk) && (mask == 0 || jt->GetMarker(mask)) )
if( !jt->GetMarker(mrk) && (mask == 0 || (invert ^ jt->GetMarker(mask))) )
{
adjcells.push_back(&*jt);
jt->SetMarker(mrk);
......@@ -835,7 +835,7 @@ namespace INMOST
}
adjacent<Node> Element::BridgeAdjacencies2Node(ElementType Bridge, MIDType mask)
adjacent<Node> Element::BridgeAdjacencies2Node(ElementType Bridge, MIDType mask, bool invert)
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
......@@ -847,7 +847,7 @@ namespace INMOST
{
adjacent<Node> sub = it->getNodes();
for(adjacent<Node>::iterator jt = sub.begin(); jt != sub.end(); jt++)
if( !jt->GetMarker(mrk) && (mask == 0 || jt->GetMarker(mask)) )
if( !jt->GetMarker(mrk) && (mask == 0 || (invert ^ jt->GetMarker(mask))) )
{
adjcells.push_back(&*jt);
jt->SetMarker(mrk);
......@@ -859,7 +859,7 @@ namespace INMOST
return adjcells;
}
adjacent<Edge> Element::BridgeAdjacencies2Edge(ElementType Bridge, MIDType mask)
adjacent<Edge> Element::BridgeAdjacencies2Edge(ElementType Bridge, MIDType mask, bool invert)
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
......@@ -871,7 +871,7 @@ namespace INMOST
{
adjacent<Edge> sub = it->getEdges();
for(adjacent<Edge>::iterator jt = sub.begin(); jt != sub.end(); jt++)
if( !jt->GetMarker(mrk) && (mask == 0 || jt->GetMarker(mask)) )
if( !jt->GetMarker(mrk) && (mask == 0 || (invert ^ jt->GetMarker(mask))) )
{
adjcells.push_back(&*jt);
jt->SetMarker(mrk);
......@@ -883,7 +883,7 @@ namespace INMOST
return adjcells;
}
adjacent<Face> Element::BridgeAdjacencies2Face(ElementType Bridge, MIDType mask)
adjacent<Face> Element::BridgeAdjacencies2Face(ElementType Bridge, MIDType mask, bool invert)
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
......@@ -895,7 +895,7 @@ namespace INMOST
{
adjacent<Face> sub = it->getFaces();
for(adjacent<Face>::iterator jt = sub.begin(); jt != sub.end(); jt++)
if( !jt->GetMarker(mrk) && (mask == 0 || jt->GetMarker(mask)) )
if( !jt->GetMarker(mrk) && (mask == 0 || (invert ^ jt->GetMarker(mask))) )
{
adjcells.push_back(&*jt);
jt->SetMarker(mrk);
......@@ -907,7 +907,7 @@ namespace INMOST
return adjcells;
}
adjacent<Cell> Element::BridgeAdjacencies2Cell(ElementType Bridge, MIDType mask)
adjacent<Cell> Element::BridgeAdjacencies2Cell(ElementType Bridge, MIDType mask, bool invert)
{
Mesh * m = GetMeshLink();
MIDType mrk = m->CreateMarker();
......@@ -919,7 +919,7 @@ namespace INMOST
{
adjacent<Cell> sub = it->getCells();
for(adjacent<Cell>::iterator jt = sub.begin(); jt != sub.end(); jt++)
if( !jt->GetMarker(mrk) && (mask == 0 || jt->GetMarker(mask)) )
if( !jt->GetMarker(mrk) && (mask == 0 || (invert ^ jt->GetMarker(mask))) )
{
adjcells.push_back(&*jt);
jt->SetMarker(mrk);
......
......@@ -241,6 +241,7 @@ void keyboard2(unsigned char key, int x, int y)
int matfilter = 0;
int show_cell = -1, show_face = -1;
int parentfilter = -1;
std::vector<int> show_cells, show_faces;
void keyboard(unsigned char key, int x, int y)
{
......@@ -348,7 +349,9 @@ void keyboard(unsigned char key, int x, int y)
}
else if( key == ' ')
{
mesh->Save("out.vtk");
show_cells.clear();
show_faces.clear();
//mesh->Save("out.vtk");
//drawgrid = (drawgrid+1)%2;
//glutPostRedisplay();
}
......@@ -376,20 +379,12 @@ void keyboard(unsigned char key, int x, int y)
}
else if( key == 'c' )
{
if( show_cell == -1 )
{
if( CommonInput == NULL ) CommonInput = new Input(&show_cell);
}
else show_cell = -1;
if( CommonInput == NULL ) CommonInput = new Input(&show_cell);
glutPostRedisplay();
}
else if( key == 'f' )
{
if( show_face == -1 )
{
if( CommonInput == NULL ) CommonInput = new Input(&show_face);
}
else show_face = -1;
if( CommonInput == NULL ) CommonInput = new Input(&show_face);
glutPostRedisplay();
}
else if( key == 'z' )
......@@ -736,285 +731,302 @@ void draw()
//glColor3f(0,0,0);
if( show_cell != -1 )
if( !show_cells.empty() )
{
Element * it = mesh->ElementByLocalID(CELL,show_cell);
if( it == NULL )
show_cell = -1;
else
for(int qq = 0; qq < show_cells.size(); qq++)
{
Storage::integer_array mats;
adjacent<Edge> edges = it->getEdges();
Storage::real cnt[3];
for(unsigned k = 0; k < edges.size(); k++)
if( show_cells[qq] < 0 || show_cells[qq] >= mesh->MaxLocalIDCELL() ) continue;
Element * it = mesh->ElementByLocalID(CELL,show_cells[qq]);
if( it != NULL )
{
edges[k].Centroid(cnt);
if( mats_tag.isValid() )mats = edges[k].IntegerArray(mats_tag);
Storage::integer_array mats;
adjacent<Edge> edges = it->getEdges();
Storage::real cnt[3];
for(unsigned k = 0; k < edges.size(); k++)
{
edges[k].Centroid(cnt);
if( mats_tag.isValid() )mats = edges[k].IntegerArray(mats_tag);
adjacent<Node> nodes = edges[k].getNodes();
adjacent<Node> nodes = edges[k].getNodes();
if( matfilter == 0 || (mats_tag.isValid() && std::binary_search(mats.begin(),mats.end(),matfilter-1)) )
{
if( mats_tag.isValid() ) fill_mat_str(edges[k].LocalID(), mats,str);
else fill_str(edges[k].LocalID(),str);
glColor3f(0,0,1);
glRasterPos3dv(cnt);
if( text == 2 || text == 5 ) if(text) printtext(str);
glColor3f(0,0,0);