8namespace ProjectionWriterImplementation {
10template<
unsigned s
ide,
typename Coordinate,
typename Corners>
13 using namespace ProjectionImplementation;
15 const unsigned other_side = 1 - side;
17 for (
const auto& c : get<side>(corners))
20 for (
const auto& i : get<side>(projection.
images())) {
21 const auto global = interpolate(i, get<other_side>(corners));
22 out << global <<
"\n";
26template<
unsigned s
ide,
typename Coordinate,
typename Normals>
29 using namespace ProjectionImplementation;
31 const unsigned other_side = 1 - side;
33 for (
const auto& n : get<side>(normals))
36 for (
const auto& x : get<side>(projection.
images())) {
37 const auto n = interpolate_unit_normals(x, get<other_side>(normals));
42template<
typename Coordinate,
typename Corners>
45 using namespace ProjectionImplementation;
50 out << interpolate(local[0], get<0>(corners)) <<
"\n"
51 << interpolate(local[1], get<1>(corners)) <<
"\n";
55template<
typename Coordinate,
typename Normals>
58 using namespace ProjectionImplementation;
63 const auto n0 = interpolate_unit_normals(local[0], get<0>(normals));
64 const auto n1 = interpolate_unit_normals(local[1], get<1>(normals));
71template<
unsigned s
ide,
typename Coordinate>
78 const auto& success = get<side>(projection.
success());
79 for (std::size_t i = 0; i < success.size(); ++i)
80 out << (success[i] ?
"1\n" :
"0\n");
85template<
typename Coordinate,
typename Corners,
typename Normals>
87 const Corners& corners,
88 const Normals& normals,
91 using namespace ProjectionWriterImplementation;
94 const auto nPoints = 12 + 2 * numberOfEdgeIntersections;
96 out <<
"# vtk DataFile Version2.0\n"
97 <<
"Filename: projection\n"
99 <<
"DATASET UNSTRUCTURED_GRID\n"
100 <<
"POINTS " << nPoints <<
" double\n";
101 write_points<0>(projection, corners, out);
102 write_points<1>(projection, corners, out);
103 write_edge_intersection_points(projection, corners, out);
104 out <<
"CELLS " << (8 + numberOfEdgeIntersections) <<
" " << (26 + 3 * numberOfEdgeIntersections) <<
"\n";
105 out <<
"3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n"
106 <<
"3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n";
107 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
108 out <<
"2 " << (12 + 2*i) <<
" " << (12 + 2*i + 1) <<
"\n";
109 out <<
"CELL_TYPES " << (8 + numberOfEdgeIntersections) <<
"\n" "5\n3\n3\n3\n" "5\n3\n3\n3\n";
110 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
112 out <<
"CELL_DATA " << (8 + numberOfEdgeIntersections) <<
"\n";
113 out <<
"SCALARS success int 1\n"
114 <<
"LOOKUP_TABLE success\n";
115 write_success<0>(projection, out);
116 write_success<1>(projection, out);
117 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
119 out <<
"LOOKUP_TABLE success 2\n"
120 <<
"1.0 0.0 0.0 1.0\n"
121 <<
"0.0 1.0 0.0 1.0\n";
122 out <<
"POINT_DATA " << nPoints <<
"\n"
123 <<
"NORMALS normals double\n";
124 write_normals<0>(projection, normals, out);
125 write_normals<1>(projection, normals, out);
126 write_edge_intersection_normals(projection, normals, out);
129template<
typename Coordinate,
typename Corners,
typename Normals>
131 const Corners& corners,
132 const Normals& normals,
133 const std::string& filename)
135 std::ofstream out(filename.c_str());
136 write(projection, corners, normals, out);
139template<
typename Coordinate,
typename Corners,
typename Normals>
141 const Corners& corners,
142 const Normals& normals)
144 using namespace ProjectionWriterImplementation;
146 std::cout <<
"Side 0 corners and images:\n";
147 write_points<0>(projection, corners, std::cout);
148 std::cout <<
"Side 0 success:\n";
149 write_success<0>(projection, std::cout);
150 std::cout <<
"Side 1 corners and images:\n";
151 write_points<1>(projection, corners, std::cout);
152 std::cout <<
"Side 1 success:\n";
153 write_success<1>(projection, std::cout);
154 std::cout <<
"Side 0 normals and projected normals:\n";
155 write_normals<0>(projection, normals, std::cout);
156 std::cout <<
"Side 1 normals and projected normals:\n";
157 write_normals<1>(projection, normals, std::cout);
159 write_edge_intersection_points(projection, corners, std::cout);
Definition gridglue.hh:37
void write(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
write projection in VTK format
Definition projectionwriter_impl.hh:86
void print(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
Print information about the projection to std::cout stream.
Definition projectionwriter_impl.hh:140
void write_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition projectionwriter_impl.hh:27
void write_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition projectionwriter_impl.hh:11
void write_success(const Projection< Coordinate > &projection, std::ostream &out)
Definition projectionwriter_impl.hh:72
void write_edge_intersection_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition projectionwriter_impl.hh:43
void write_edge_intersection_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition projectionwriter_impl.hh:56
Projection of a line (triangle) on another line (triangle).
Definition projection.hh:21
const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const
Indicate whether projection (inverse projection) is valid for each corner or not.
Definition projection.hh:252
unsigned numberOfEdgeIntersections() const
Number of edge intersections.
Definition projection.hh:262
const std::tuple< Images, Preimages > & images() const
Images and preimages of corners.
Definition projection.hh:235
const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections() const
Edge-edge intersections.
Definition projection.hh:273