Wildmeshing Toolkit
Loading...
Searching...
No Matches
test_component_procedural.cpp
Go to the documentation of this file.
1#include <catch2/catch_test_macros.hpp>
2#include <nlohmann/json.hpp>
3#include <wmtk/components/procedural/procedural.hpp>
4#include <wmtk/components/utils/Paths.hpp>
5#include <wmtk/io/Cache.hpp>
7
8using namespace wmtk::components::utils;
9using json = nlohmann::json;
10
11const std::filesystem::path data_dir = WMTK_DATA_DIR;
12
13TEST_CASE("component_procedural_nocoord", "[components][procedural][.]")
14{
15 wmtk::io::Cache cache("wmtk_cache", ".");
16
17 // SECTION("grid2")
18 {
19 json component_json = {
20 {"name", "grid2"},
21 {"type", "grid"},
22 {"grid",
23 {{"tiling", "diagonal"},
24 {"dimensions", {5, 5}},
25 {"cycles", {false, false}},
26 {"coordinates", nullptr}}}};
27
28
29 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
30 }
31 // SECTION("grid3")
32 {
33 json component_json = {
34 {"name", "grid3"},
35 {"type", "grid"},
36 {"grid",
37 {{"tiling", "freudenthal"},
38 {"dimensions", {5, 5, 5}},
39 {"cycles", {false, false, false}},
40 {"coordinates", nullptr}}}};
41
42
43 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
44 }
45 // SECTION("triangle_fan")
46 {
47 json component_json = {
48 {"name", "triangle_fan"},
49 {"type", "fan"},
50 {"fan", {{"size", 10}, {"coordinates", nullptr}}}};
51
52
53 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
54 }
55 // SECTION("disk")
56 {
57 json component_json = {
58 {"type", "procedural"},
59 {"name", "disk"},
60 {"type", "disk"},
61 {"disk", {{"size", 10}, {"coordinates", nullptr}}}};
62
63
64 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
65 }
66}
67TEST_CASE("component_procedural_coords", "[components][procedural][.]")
68{
69 wmtk::io::Cache cache("wmtk_cache", ".");
70
71 // SECTION("grid2")
72 {
73 json component_json = {
74 {"name", "grid2"},
75 {"type", "grid"},
76 {"grid",
77 {{"tiling", "diagonal"},
78 {"dimensions", {5, 5}},
79 {"cycles", {false, false}},
80 {"coordinates", {{"name", "vertices"}, {"spacing", {0.2, 0.2}}}}}}};
81
82
83 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
84 }
85 // SECTION("grid3")
86 {
87 json component_json = {
88 {"name", "grid3"},
89 {"type", "grid"},
90 {"grid",
91 {{"tiling", "freudenthal"},
92 {"dimensions", {5, 5, 5}},
93 {"cycles", {false, false, false}},
94 {"coordinates", {{"name", "vertices"}, {"spacing", {0.2, 0.2, 0.2}}}}}}};
95
96
97 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
98 }
99 // SECTION("triangle_fan")
100 {
101 json component_json = {
102 {"name", "triangle_fan"},
103 {"type", "fan"},
104 {"fan",
105 {{"size", 10},
106 {"coordinates",
107 {{"name", "vertices"},
108 {"radius", 0.2},
109 {"center", {.5, .5}},
110 {"degrees", {0, 180}}}}}}};
111
112
113 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
114 }
115 // SECTION("disk")
116 {
117 json component_json = {
118 {"name", "disk"},
119 {"type", "disk"},
120 {"disk",
121 {{"size", 10},
122 {"coordinates",
123 {{"name", "vertices"},
124 {"radius", 0.2},
125 {"center", {.5, .5}},
126 {"degree_offset", 0.0}}}}}};
127
128
129 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
130 }
131}
132TEST_CASE("component_procedural_cyclic_grids", "[components][procedural]")
133{
134 wmtk::io::Cache cache("wmtk_cache", ".");
135
136 // SECTION("grid2")
137 {
138 json component_json = {
139 {"name", "grid2"},
140 {"type", "grid"},
141 {"grid",
142 {{"tiling", "diagonal"},
143 {"dimensions", {5, 5}},
144 {"cycles", {true, true}},
145 {"coordinates", {{"name", "vertices"}, {"spacing", {0.2, 0.2}}}}}}};
146
147
148 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
149 }
150 // SECTION("grid3")
151 {
152 json component_json = {
153 {"name", "grid3"},
154 {"type", "grid"},
155 {"grid",
156 {{"tiling", "freudenthal"},
157 {"dimensions", {5, 5, 5}},
158 {"cycles", {true, true, true}},
159 {"coordinates", {{"name", "vertices"}, {"spacing", {0.2, 0.2, 0.2}}}}}}};
160
161
162 CHECK_NOTHROW(wmtk::components::procedural(Paths(), component_json, cache));
163 }
164}
const std::filesystem::path data_dir
TEST_CASE("component_procedural_nocoord", "[components][procedural][.]")
nlohmann::json json
Definition input.cpp:9