示例#1
0
void simplifyPFBlock(const Edges& toUnlink, const PFBlock& block, Blocks& simplifiedBlocks, Nodes& history) {
  // take a block, unlink some of the edges and
  // create smaller blocks or a simplified blocks
  // or if nothing has changed take a copy of the original block
  if (toUnlink.size() == 0) {
    // no change needed, just make a copy of block
    PFBlock newblock(block.elementIds(), block.edges(), simplifiedBlocks.size(), 's');  // will copy edges and ids
    PDebug::write("Made {}", newblock);
    auto id = newblock.id();
    simplifiedBlocks.emplace(id, std::move(newblock));
    // update history
    makeHistoryLinks(block.elementIds(), {id}, history);
  } else {
    Edges modifiedEdges;
    for (auto edge : block.edges()) {  // copying edges
      Edge e = edge.second;
      if (toUnlink.find(edge.first) != toUnlink.end()) {
        e.setLinked(false);
      }
      modifiedEdges.emplace(e.key(), e);
    }
    // create new blocks and add into simplifiedBlocks
    buildPFBlocks(block.elementIds(), modifiedEdges, 's', simplifiedBlocks, history);
  }
}
示例#2
0
BlockSplitter::BlockSplitter(const Edges& unlinkEdges, PFBlock& block, Nodes& historynodes) : m_blocks() {
  Edges modifiedEdges;
  for (auto edge : block.edges()) {  // copy edges
    Edge e = edge.second;
    if (unlinkEdges.find(edge.first) != unlinkEdges.end()) {
      e.setLinked(false);
    }
    modifiedEdges.emplace(e.key(), std::move(e));
  }

  BlockBuilder bbuilder{block.elementIds(), std::move(modifiedEdges), historynodes};
  m_blocks = bbuilder.moveBlocks();
  block.setActive(false);
}