- v2n = v2Node.insert( make_pair( bndSegs[i]._edge->vertex0(), v2Node.size() + 1 )).first;
- int n0 = v2n->second;
- if ( n0 == v2Node.size() )
- text << "n" << n0 << " = m.AddNode( "
- << bndSegs[i]._edge->vertex0()->x() / theScale[0] << ", "
- << bndSegs[i]._edge->vertex0()->y() / theScale[1] << ", 0 )\n";
-
- v2n = v2Node.insert( make_pair( bndSegs[i]._edge->vertex1(), v2Node.size() + 1 )).first;
- int n1 = v2n->second;
- if ( n1 == v2Node.size() )
- text << "n" << n1 << " = m.AddNode( "
- << bndSegs[i]._edge->vertex1()->x() / theScale[0] << ", "
- << bndSegs[i]._edge->vertex1()->y() / theScale[1] << ", 0 )\n";
-
- text << "e" << i << " = m.AddEdge([ n" << n0 << ", n" << n1 << " ])\n";
+ if ( !bndSegs[i]._edge )
+ text << "# E=" << iE << " i=" << i << " NULL edge\n";
+ else if ( !bndSegs[i]._edge->vertex0() ||
+ !bndSegs[i]._edge->vertex1() )
+ text << "# E=" << iE << " i=" << i << " INFINITE edge\n";
+ else if ( addedEdges.insert( bndSegs[i]._edge ).second &&
+ addedEdges.insert( bndSegs[i]._edge->twin() ).second )
+ {
+ v2n = v2Node.insert( make_pair( bndSegs[i]._edge->vertex0(), v2Node.size() + 1 )).first;
+ size_t n0 = v2n->second;
+ if ( n0 == v2Node.size() )
+ text << "n" << n0 << " = m.AddNode( "
+ << bndSegs[i]._edge->vertex0()->x() / theScale[0] << ", "
+ << bndSegs[i]._edge->vertex0()->y() / theScale[1] << ", 0 )\n";
+
+ v2n = v2Node.insert( make_pair( bndSegs[i]._edge->vertex1(), v2Node.size() + 1 )).first;
+ size_t n1 = v2n->second;
+ if ( n1 == v2Node.size() )
+ text << "n" << n1 << " = m.AddNode( "
+ << bndSegs[i]._edge->vertex1()->x() / theScale[0] << ", "
+ << bndSegs[i]._edge->vertex1()->y() / theScale[1] << ", 0 )\n";
+
+ text << "e" << i << " = m.AddEdge([ n" << n0 << ", n" << n1 << " ])\n";
+ }