1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/**
*
* This file is part of Tulip (https://tulip.labri.fr)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*/
#include <ogdf/planarity/PlanarizationLayout.h>
#include <ogdf/planarity/EmbedderMaxFace.h>
#include <ogdf/planarity/EmbedderMaxFaceLayers.h>
#include <ogdf/planarity/EmbedderMinDepth.h>
#include <ogdf/planarity/EmbedderMinDepthMaxFace.h>
#include <ogdf/planarity/EmbedderMinDepthMaxFaceLayers.h>
#include <ogdf/planarity/EmbedderMinDepthPiTa.h>
#include <ogdf/planarity/EmbedderOptimalFlexDraw.h>
#include <ogdf/planarity/SimpleEmbedder.h>
#include <tulip2ogdf/OGDFLayoutPluginBase.h>
#include <tulip/StringCollection.h>
#define EMBEDDER "Embedder"
#define EMBEDDER_LIST \
"simple;max face;max face layers;min depth;min depth max face;" \
"min depth max face layers;min depth PiTa;optimal FlexDraw"
#define EMBEDDER_MAXFACE 1
#define EMBEDDER_MAXFACELAYERS 2
#define EMBEDDER_MINDEPTH 3
#define EMBEDDER_MINDEPTHMAXFACE 4
#define EMBEDDER_MINDEPTHMAXFACELAYERS 5
#define EMBEDDER_MINDEPTHPITA 6
#define EMBEDDER_OPTIMALFLEXDRAW 7
using namespace tlp;
using namespace ogdf;
static const char *embedderValuesDescription =
"simple <i>(embedding from the algorithm of Boyer and Myrvold)</i><br>"
"max face <i>(embedding with maximum external face)</i><br>"
"max face layers <i>(embedding with maximum external face, plus layers "
"approach)</i><br>"
"min depth <i>(embedding with minimum block-nesting depth)</i><br>"
"min depth max face <i>(embedding with minimum block-nesting depth and "
"maximum external face)</i><br>"
"min depth max face layers <i>(embedding with minimum block-nesting depth and "
"maximum external face, plus layers approach)</i><br>"
"min depth PiTa <i>(embedding with minimum block-nesting depth for given "
"embedded blocks)</i>"
"optimal FlexDraw <i>(Planar graph embedding with minimum cost)</i>";
static const char *paramHelp[] = {
// page ratio
"Sets the option page ratio.",
// min clique size
"If preprocessing of cliques is considered, this option determines the minimum size of cliques "
"to search for",
// Embedder
"The result of the crossing minimization step is a planar graph, in which crossings are "
"replaced by dummy nodes. The embedder then computes a planar embedding of this planar graph.",
// crossings
"Returns the number of crossings in the computed layout."};
class OGDFPlanarizationLayout : public OGDFLayoutPluginBase {
ogdf::PlanarizationLayout *pl;
public:
PLUGININFORMATION("Planarization Layout (OGDF)", "Carsten Gutwenger", "12/11/2007",
"The planarization approach for drawing graphs.", "1.1", "Planar")
OGDFPlanarizationLayout(const tlp::PluginContext *context)
: OGDFLayoutPluginBase(context, context ? new ogdf::PlanarizationLayout() : nullptr),
pl(static_cast<ogdf::PlanarizationLayout *>(ogdfLayoutAlgo)) {
addInParameter<double>("page ratio", paramHelp[0], "1.1");
addInParameter<int>("min clique size", paramHelp[1], "3");
addInParameter<StringCollection>("embedder", paramHelp[2], EMBEDDER_LIST, true,
embedderValuesDescription);
addOutParameter<int>("number of crossings", paramHelp[3]);
}
~OGDFPlanarizationLayout() override {}
void beforeCall() override {
if (dataSet != nullptr) {
double dval = 0;
int clique_size = 3;
StringCollection sc;
if (dataSet->get("page ratio", dval))
pl->pageRatio(dval);
if (dataSet->get("min clique size", clique_size))
pl->minCliqueSize(clique_size);
if (dataSet->get("embedder", sc)) {
switch (sc.getCurrent()) {
case EMBEDDER_MAXFACE:
pl->setEmbedder(new ogdf::EmbedderMaxFace());
break;
case EMBEDDER_MAXFACELAYERS:
pl->setEmbedder(new ogdf::EmbedderMaxFaceLayers());
break;
case EMBEDDER_MINDEPTH:
pl->setEmbedder(new ogdf::EmbedderMinDepth());
break;
case EMBEDDER_MINDEPTHMAXFACE:
pl->setEmbedder(new ogdf::EmbedderMinDepthMaxFace());
break;
case EMBEDDER_MINDEPTHMAXFACELAYERS:
pl->setEmbedder(new ogdf::EmbedderMinDepthMaxFaceLayers());
break;
case EMBEDDER_MINDEPTHPITA:
pl->setEmbedder(new ogdf::EmbedderMinDepthPiTa());
break;
case EMBEDDER_OPTIMALFLEXDRAW:
pl->setEmbedder(new ogdf::EmbedderOptimalFlexDraw());
break;
default:
pl->setEmbedder(new ogdf::SimpleEmbedder());
}
}
}
}
void afterCall() override {
dataSet->set("number of crossings", pl->numberOfCrossings());
}
};
PLUGIN(OGDFPlanarizationLayout)
|