diff options
-rw-r--r-- | lib/include/graph.hpp | 1 | ||||
-rw-r--r-- | lib/src/graph.cpp | 39 | ||||
-rw-r--r-- | src/sample.cpp | 8 | ||||
-rw-r--r-- | src/sample_fracture.cpp | 7 |
4 files changed, 49 insertions, 6 deletions
diff --git a/lib/include/graph.hpp b/lib/include/graph.hpp index 032a4d1..1714dc2 100644 --- a/lib/include/graph.hpp +++ b/lib/include/graph.hpp @@ -42,5 +42,6 @@ class graph { graph(unsigned n, double a, std::mt19937& rng); void helper(unsigned n, std::mt19937& rng); + graph const rotate(); }; diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp index 364f339..974d3b3 100644 --- a/lib/src/graph.cpp +++ b/lib/src/graph.cpp @@ -157,9 +157,8 @@ graph::graph(unsigned n, double a, std::mt19937& rng) { this->helper(n, rng); } -void graph::helper(unsigned n, std::mt19937& rng) { +void graph::helper(unsigned nv, std::mt19937& rng) { std::uniform_real_distribution<double> d(0.0, 1.0); - unsigned nv = n; vertices.resize(nv); // the coordinates of the lattice, from which a delaunay triangulation @@ -363,3 +362,39 @@ void graph::helper(unsigned n, std::mt19937& rng) { jcv_diagram_free(&diagram); } +graph::coordinate reverse(const graph::coordinate &x) { + return {x.y, x.x}; +} + +graph const graph::rotate() { + graph g2(*this); + + for (graph::vertex &v : g2.vertices) { + v.r = reverse(v.r); + for (graph::coordinate &r : v.polygon) { + r = reverse(r); + } + } + + for (graph::edge &e : g2.edges) { + e.r = reverse(e.r); + e.crossings = {e.crossings[1], e.crossings[0]}; + } + + for (graph::vertex &v : g2.dual_vertices) { + v.r = reverse(v.r); + for (graph::coordinate &r : v.polygon) { + r = reverse(r); + } + } + + for (graph::edge &e : g2.dual_edges) { + e.r = reverse(e.r); + e.crossings = {e.crossings[1], e.crossings[0]}; + } + + g2.L = reverse(g2.L); + + return g2; +} + diff --git a/src/sample.cpp b/src/sample.cpp index b8af937..488d20d 100644 --- a/src/sample.cpp +++ b/src/sample.cpp @@ -16,25 +16,25 @@ void sample::pre_fracture(const network& n) { sample_file << "<|"; sample_file << "\"vr\"->{"; for (const graph::vertex &v : n.G.vertices) { - sample_file << "{" << v.r.x << "," << v.r.y << "},"; + sample_file <<std::fixed<< "{" << v.r.x << "," << v.r.y << "},"; } sample_file << "},\"vp\"->{"; for (const graph::vertex &v : n.G.vertices) { sample_file << "{"; for (const graph::coordinate &r : v.polygon) { - sample_file << "{" << r.x << "," << r.y << "},"; + sample_file <<std::fixed<< "{" << r.x << "," << r.y << "},"; } sample_file << "},"; } sample_file << "},\"ur\"->{"; for (const graph::vertex &v : n.G.dual_vertices) { - sample_file << "{" << v.r.x << "," << v.r.y << "},"; + sample_file <<std::fixed<< "{" << v.r.x << "," << v.r.y << "},"; } sample_file << "},\"up\"->{"; for (const graph::vertex &v : n.G.dual_vertices) { sample_file << "{"; for (const graph::coordinate &r : v.polygon) { - sample_file << "{" << r.x << "," << r.y << "},"; + sample_file <<std::fixed<< "{" << r.x << "," << r.y << "},"; } sample_file << "},"; } diff --git a/src/sample_fracture.cpp b/src/sample_fracture.cpp index 42a6a5a..782b3e4 100644 --- a/src/sample_fracture.cpp +++ b/src/sample_fracture.cpp @@ -47,6 +47,7 @@ int main(int argc, char* argv[]) { CHOL_F(start)(&c); sample meas(Lx, Ly, beta); + //sample meas2(Ly, Lx, beta); randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; @@ -56,6 +57,12 @@ int main(int argc, char* argv[]) { network network(G, &c); network.set_thresholds(beta, rng); network.fracture(meas); + + /*graph G2 = G.rotate(); + class network network2(G2, &c); + network2.thresholds = network.thresholds; + network2.fracture(meas2); + */ } CHOL_F(finish)(&c); |