diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2019-08-26 19:34:11 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2019-09-13 11:36:05 +0300 |
commit | 57e55906f04a48a951fbbcfd7c197eef35ad4387 (patch) | |
tree | a4246ffdd501027a37d7329dca05de4d9ed19b15 /extern/quadriflow/3rd/lemon-1.3.1/demo | |
parent | 1c44d08a69eb3e66c7f942d748f549d6b8ca138f (diff) |
Add QuadriFlow remesher
Diffstat (limited to 'extern/quadriflow/3rd/lemon-1.3.1/demo')
5 files changed, 436 insertions, 0 deletions
diff --git a/extern/quadriflow/3rd/lemon-1.3.1/demo/CMakeLists.txt b/extern/quadriflow/3rd/lemon-1.3.1/demo/CMakeLists.txt new file mode 100644 index 00000000000..e0566f407f0 --- /dev/null +++ b/extern/quadriflow/3rd/lemon-1.3.1/demo/CMakeLists.txt @@ -0,0 +1,19 @@ +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} +) + +LINK_DIRECTORIES( + ${PROJECT_BINARY_DIR}/lemon +) + +SET(DEMOS + arg_parser_demo + graph_to_eps_demo + lgf_demo +) + +FOREACH(DEMO_NAME ${DEMOS}) + ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc) + TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon) +ENDFOREACH() diff --git a/extern/quadriflow/3rd/lemon-1.3.1/demo/arg_parser_demo.cc b/extern/quadriflow/3rd/lemon-1.3.1/demo/arg_parser_demo.cc new file mode 100644 index 00000000000..1bafac0c860 --- /dev/null +++ b/extern/quadriflow/3rd/lemon-1.3.1/demo/arg_parser_demo.cc @@ -0,0 +1,112 @@ +/* -*- mode: C++; indent-tabs-mode: nil; -*- + * + * This file is a part of LEMON, a generic C++ optimization library. + * + * Copyright (C) 2003-2010 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +///\ingroup demos +///\file +///\brief Argument parser demo +/// +/// This example shows how the argument parser can be used. +/// +/// \include arg_parser_demo.cc + +#include <lemon/arg_parser.h> + +using namespace lemon; +int main(int argc, char **argv) +{ + // Initialize the argument parser + ArgParser ap(argc, argv); + int i; + std::string s; + double d = 1.0; + bool b, nh; + bool g1, g2, g3; + + // Add a mandatory integer option with storage reference + ap.refOption("n", "An integer input.", i, true); + // Add a double option with storage reference (the default value is 1.0) + ap.refOption("val", "A double input.", d); + // Add a double option without storage reference (the default value is 3.14) + ap.doubleOption("val2", "A double input.", 3.14); + // Set synonym for -val option + ap.synonym("vals", "val"); + // Add a string option + ap.refOption("name", "A string input.", s); + // Add bool options + ap.refOption("f", "A switch.", b) + .refOption("nohelp", "", nh) + .refOption("gra", "Choice A", g1) + .refOption("grb", "Choice B", g2) + .refOption("grc", "Choice C", g3); + // Bundle -gr* options into a group + ap.optionGroup("gr", "gra") + .optionGroup("gr", "grb") + .optionGroup("gr", "grc"); + // Set the group mandatory + ap.mandatoryGroup("gr"); + // Set the options of the group exclusive (only one option can be given) + ap.onlyOneGroup("gr"); + // Add non-parsed arguments (e.g. input files) + ap.other("infile", "The input file.") + .other("..."); + + // Throw an exception when problems occurs. The default behavior is to + // exit(1) on these cases, but this makes Valgrind falsely warn + // about memory leaks. + ap.throwOnProblems(); + + // Perform the parsing process + // (in case of any error it terminates the program) + // The try {} construct is necessary only if the ap.trowOnProblems() + // setting is in use. + try { + ap.parse(); + } catch (ArgParserException &) { return 1; } + + // Check each option if it has been given and print its value + std::cout << "Parameters of '" << ap.commandName() << "':\n"; + + std::cout << " Value of -n: " << i << std::endl; + if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl; + if(ap.given("val2")) { + d = ap["val2"]; + std::cout << " Value of -val2: " << d << std::endl; + } + if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl; + if(ap.given("f")) std::cout << " -f is given\n"; + if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << nh << std::endl; + if(ap.given("gra")) std::cout << " -gra is given\n"; + if(ap.given("grb")) std::cout << " -grb is given\n"; + if(ap.given("grc")) std::cout << " -grc is given\n"; + + switch(ap.files().size()) { + case 0: + std::cout << " No file argument was given.\n"; + break; + case 1: + std::cout << " 1 file argument was given. It is:\n"; + break; + default: + std::cout << " " + << ap.files().size() << " file arguments were given. They are:\n"; + } + for(unsigned int i=0;i<ap.files().size();++i) + std::cout << " '" << ap.files()[i] << "'\n"; + + return 0; +} diff --git a/extern/quadriflow/3rd/lemon-1.3.1/demo/digraph.lgf b/extern/quadriflow/3rd/lemon-1.3.1/demo/digraph.lgf new file mode 100644 index 00000000000..83ba7da13c2 --- /dev/null +++ b/extern/quadriflow/3rd/lemon-1.3.1/demo/digraph.lgf @@ -0,0 +1,29 @@ +@nodes +label +0 +1 +2 +3 +4 +5 +6 +7 +@arcs + label capacity +0 1 0 16 +0 2 1 12 +0 3 2 20 +1 2 3 10 +1 4 4 10 +1 5 5 13 +2 3 6 10 +2 4 7 8 +2 6 8 8 +5 3 9 20 +3 6 10 25 +4 7 11 15 +5 7 12 15 +6 7 13 18 +@attributes +source 0 +target 7 diff --git a/extern/quadriflow/3rd/lemon-1.3.1/demo/graph_to_eps_demo.cc b/extern/quadriflow/3rd/lemon-1.3.1/demo/graph_to_eps_demo.cc new file mode 100644 index 00000000000..f2f55a92861 --- /dev/null +++ b/extern/quadriflow/3rd/lemon-1.3.1/demo/graph_to_eps_demo.cc @@ -0,0 +1,206 @@ +/* -*- mode: C++; indent-tabs-mode: nil; -*- + * + * This file is a part of LEMON, a generic C++ optimization library. + * + * Copyright (C) 2003-2009 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +/// \ingroup demos +/// \file +/// \brief Demo of the graph drawing function \ref graphToEps() +/// +/// This demo program shows examples how to use the function \ref +/// graphToEps(). It takes no input but simply creates seven +/// <tt>.eps</tt> files demonstrating the capability of \ref +/// graphToEps(), and showing how to draw directed graphs, +/// how to handle parallel egdes, how to change the properties (like +/// color, shape, size, title etc.) of nodes and arcs individually +/// using appropriate graph maps. +/// +/// \include graph_to_eps_demo.cc + +#include<lemon/list_graph.h> +#include<lemon/graph_to_eps.h> +#include<lemon/math.h> + +using namespace std; +using namespace lemon; + +int main() +{ + Palette palette; + Palette paletteW(true); + + // Create a small digraph + ListDigraph g; + typedef ListDigraph::Node Node; + typedef ListDigraph::NodeIt NodeIt; + typedef ListDigraph::Arc Arc; + typedef dim2::Point<int> Point; + + Node n1=g.addNode(); + Node n2=g.addNode(); + Node n3=g.addNode(); + Node n4=g.addNode(); + Node n5=g.addNode(); + + ListDigraph::NodeMap<Point> coords(g); + ListDigraph::NodeMap<double> sizes(g); + ListDigraph::NodeMap<int> colors(g); + ListDigraph::NodeMap<int> shapes(g); + ListDigraph::ArcMap<int> acolors(g); + ListDigraph::ArcMap<int> widths(g); + + coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0; + coords[n2]=Point(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2; + coords[n3]=Point(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0; + coords[n4]=Point(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1; + coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2; + + Arc a; + + a=g.addArc(n1,n2); acolors[a]=0; widths[a]=1; + a=g.addArc(n2,n3); acolors[a]=0; widths[a]=1; + a=g.addArc(n3,n5); acolors[a]=0; widths[a]=3; + a=g.addArc(n5,n4); acolors[a]=0; widths[a]=1; + a=g.addArc(n4,n1); acolors[a]=0; widths[a]=1; + a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2; + a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1; + + IdMap<ListDigraph,Node> id(g); + + // Create .eps files showing the digraph with different options + cout << "Create 'graph_to_eps_demo_out_1_pure.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_1_pure.eps"). + coords(coords). + title("Sample .eps figure"). + copyright("(C) 2003-2009 LEMON Project"). + run(); + + cout << "Create 'graph_to_eps_demo_out_2.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_2.eps"). + coords(coords). + title("Sample .eps figure"). + copyright("(C) 2003-2009 LEMON Project"). + absoluteNodeSizes().absoluteArcWidths(). + nodeScale(2).nodeSizes(sizes). + nodeShapes(shapes). + nodeColors(composeMap(palette,colors)). + arcColors(composeMap(palette,acolors)). + arcWidthScale(.4).arcWidths(widths). + nodeTexts(id).nodeTextSize(3). + run(); + + cout << "Create 'graph_to_eps_demo_out_3_arr.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_3_arr.eps"). + title("Sample .eps figure (with arrowheads)"). + copyright("(C) 2003-2009 LEMON Project"). + absoluteNodeSizes().absoluteArcWidths(). + nodeColors(composeMap(palette,colors)). + coords(coords). + nodeScale(2).nodeSizes(sizes). + nodeShapes(shapes). + arcColors(composeMap(palette,acolors)). + arcWidthScale(.4).arcWidths(widths). + nodeTexts(id).nodeTextSize(3). + drawArrows().arrowWidth(2).arrowLength(2). + run(); + + // Add more arcs to the digraph + a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1; + a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2; + + a=g.addArc(n1,n2); acolors[a]=1; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=2; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=3; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=4; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=5; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=6; widths[a]=1; + a=g.addArc(n1,n2); acolors[a]=7; widths[a]=1; + + cout << "Create 'graph_to_eps_demo_out_4_par.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_4_par.eps"). + title("Sample .eps figure (parallel arcs)"). + copyright("(C) 2003-2009 LEMON Project"). + absoluteNodeSizes().absoluteArcWidths(). + nodeShapes(shapes). + coords(coords). + nodeScale(2).nodeSizes(sizes). + nodeColors(composeMap(palette,colors)). + arcColors(composeMap(palette,acolors)). + arcWidthScale(.4).arcWidths(widths). + nodeTexts(id).nodeTextSize(3). + enableParallel().parArcDist(1.5). + run(); + + cout << "Create 'graph_to_eps_demo_out_5_par_arr.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_5_par_arr.eps"). + title("Sample .eps figure (parallel arcs and arrowheads)"). + copyright("(C) 2003-2009 LEMON Project"). + absoluteNodeSizes().absoluteArcWidths(). + nodeScale(2).nodeSizes(sizes). + coords(coords). + nodeShapes(shapes). + nodeColors(composeMap(palette,colors)). + arcColors(composeMap(palette,acolors)). + arcWidthScale(.3).arcWidths(widths). + nodeTexts(id).nodeTextSize(3). + enableParallel().parArcDist(1). + drawArrows().arrowWidth(1).arrowLength(1). + run(); + + cout << "Create 'graph_to_eps_demo_out_6_par_arr_a4.eps'" << endl; + graphToEps(g,"graph_to_eps_demo_out_6_par_arr_a4.eps"). + title("Sample .eps figure (fits to A4)"). + copyright("(C) 2003-2009 LEMON Project"). + scaleToA4(). + absoluteNodeSizes().absoluteArcWidths(). + nodeScale(2).nodeSizes(sizes). + coords(coords). + nodeShapes(shapes). + nodeColors(composeMap(palette,colors)). + arcColors(composeMap(palette,acolors)). + arcWidthScale(.3).arcWidths(widths). + nodeTexts(id).nodeTextSize(3). + enableParallel().parArcDist(1). + drawArrows().arrowWidth(1).arrowLength(1). + run(); + + // Create an .eps file showing the colors of a default Palette + ListDigraph h; + ListDigraph::NodeMap<int> hcolors(h); + ListDigraph::NodeMap<Point> hcoords(h); + + int cols=int(std::sqrt(double(palette.size()))); + for(int i=0;i<int(paletteW.size());i++) { + Node n=h.addNode(); + hcoords[n]=Point(1+i%cols,1+i/cols); + hcolors[n]=i; + } + + cout << "Create 'graph_to_eps_demo_out_7_colors.eps'" << endl; + graphToEps(h,"graph_to_eps_demo_out_7_colors.eps"). + scale(60). + title("Sample .eps figure (Palette demo)"). + copyright("(C) 2003-2009 LEMON Project"). + coords(hcoords). + absoluteNodeSizes().absoluteArcWidths(). + nodeScale(.45). + distantColorNodeTexts(). + nodeTexts(hcolors).nodeTextSize(.6). + nodeColors(composeMap(paletteW,hcolors)). + run(); + + return 0; +} diff --git a/extern/quadriflow/3rd/lemon-1.3.1/demo/lgf_demo.cc b/extern/quadriflow/3rd/lemon-1.3.1/demo/lgf_demo.cc new file mode 100644 index 00000000000..e2d31cdf440 --- /dev/null +++ b/extern/quadriflow/3rd/lemon-1.3.1/demo/lgf_demo.cc @@ -0,0 +1,70 @@ +/* -*- mode: C++; indent-tabs-mode: nil; -*- + * + * This file is a part of LEMON, a generic C++ optimization library. + * + * Copyright (C) 2003-2009 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +///\ingroup demos +///\file +///\brief Demonstrating graph input and output +/// +/// This program gives an example of how to read and write a digraph +/// and additional maps from/to a stream or a file using the +/// \ref lgf-format "LGF" format. +/// +/// The \c "digraph.lgf" file: +/// \include digraph.lgf +/// +/// And the program which reads it and prints the digraph to the +/// standard output: +/// \include lgf_demo.cc + +#include <iostream> +#include <lemon/smart_graph.h> +#include <lemon/lgf_reader.h> +#include <lemon/lgf_writer.h> + +using namespace lemon; + +int main() { + SmartDigraph g; + SmartDigraph::ArcMap<int> cap(g); + SmartDigraph::Node s, t; + + try { + digraphReader(g, "digraph.lgf"). // read the directed graph into g + arcMap("capacity", cap). // read the 'capacity' arc map into cap + node("source", s). // read 'source' node to s + node("target", t). // read 'target' node to t + run(); + } catch (Exception& error) { // check if there was any error + std::cerr << "Error: " << error.what() << std::endl; + return -1; + } + + std::cout << "A digraph is read from 'digraph.lgf'." << std::endl; + std::cout << "Number of nodes: " << countNodes(g) << std::endl; + std::cout << "Number of arcs: " << countArcs(g) << std::endl; + + std::cout << "We can write it to the standard output:" << std::endl; + + digraphWriter(g). // write g to the standard output + arcMap("capacity", cap). // write cap into 'capacity' + node("source", s). // write s to 'source' + node("target", t). // write t to 'target' + run(); + + return 0; +} |