6namespace ProjectionWriterImplementation {
8template<
unsigned s
ide,
typename Coordinate,
typename Corners>
11 using namespace ProjectionImplementation;
13 const unsigned other_side = 1 - side;
15 for (
const auto& c : get<side>(corners))
18 for (
const auto& i : get<side>(projection.
images())) {
19 const auto global =
interpolate(i, get<other_side>(corners));
20 out << global <<
"\n";
24template<
unsigned s
ide,
typename Coordinate,
typename Normals>
27 using namespace ProjectionImplementation;
29 const unsigned other_side = 1 - side;
31 for (
const auto& n : get<side>(normals))
34 for (
const auto& x : get<side>(projection.
images())) {
40template<
typename Coordinate,
typename Corners>
43 using namespace ProjectionImplementation;
48 out << interpolate(local[0], get<0>(corners)) <<
"\n"
53template<
typename Coordinate,
typename Normals>
56 using namespace ProjectionImplementation;
69template<
unsigned s
ide,
typename Coordinate>
76 const auto& success = get<side>(projection.
success());
77 for (std::size_t i = 0; i < success.size(); ++i)
78 out << (success[i] ?
"1\n" :
"0\n");
83template<
typename Coordinate,
typename Corners,
typename Normals>
85 const Corners& corners,
86 const Normals& normals,
89 using namespace ProjectionWriterImplementation;
92 const auto nPoints = 12 + 2 * numberOfEdgeIntersections;
94 out <<
"# vtk DataFile Version2.0\n"
95 <<
"Filename: projection\n"
97 <<
"DATASET UNSTRUCTURED_GRID\n"
98 <<
"POINTS " << nPoints <<
" double\n";
99 write_points<0>(projection, corners, out);
100 write_points<1>(projection, corners, out);
102 out <<
"CELLS " << (8 + numberOfEdgeIntersections) <<
" " << (26 + 3 * numberOfEdgeIntersections) <<
"\n";
103 out <<
"3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n"
104 <<
"3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n";
105 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
106 out <<
"2 " << (12 + 2*i) <<
" " << (12 + 2*i + 1) <<
"\n";
107 out <<
"CELL_TYPES " << (8 + numberOfEdgeIntersections) <<
"\n" "5\n3\n3\n3\n" "5\n3\n3\n3\n";
108 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
110 out <<
"CELL_DATA " << (8 + numberOfEdgeIntersections) <<
"\n";
111 out <<
"SCALARS success int 1\n"
112 <<
"LOOKUP_TABLE success\n";
113 write_success<0>(projection, out);
114 write_success<1>(projection, out);
115 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
117 out <<
"LOOKUP_TABLE success 2\n"
118 <<
"1.0 0.0 0.0 1.0\n"
119 <<
"0.0 1.0 0.0 1.0\n";
120 out <<
"POINT_DATA " << nPoints <<
"\n"
121 <<
"NORMALS normals double\n";
122 write_normals<0>(projection, normals, out);
123 write_normals<1>(projection, normals, out);
127template<
typename Coordinate,
typename Corners,
typename Normals>
129 const Corners& corners,
130 const Normals& normals,
131 const std::string& filename)
133 std::ofstream out(filename.c_str());
134 write(projection, corners, normals, out);
137template<
typename Coordinate,
typename Corners,
typename Normals>
139 const Corners& corners,
140 const Normals& normals)
142 using namespace ProjectionWriterImplementation;
144 std::cout <<
"Side 0 corners and images:\n";
145 write_points<0>(projection, corners, std::cout);
146 std::cout <<
"Side 0 success:\n";
147 write_success<0>(projection, std::cout);
148 std::cout <<
"Side 1 corners and images:\n";
149 write_points<1>(projection, corners, std::cout);
150 std::cout <<
"Side 1 success:\n";
151 write_success<1>(projection, std::cout);
152 std::cout <<
"Side 0 normals and projected normals:\n";
153 write_normals<0>(projection, normals, std::cout);
154 std::cout <<
"Side 1 normals and projected normals:\n";
155 write_normals<1>(projection, normals, std::cout);
Definition: gridglue.hh:35
void write(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
write projection in VTK format
Definition: projectionwriter_impl.hh:84
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:138
Corners::value_type interpolate(const Coordinate &x, const Corners &corners)
Definition: projection_impl.hh:68
Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals &normals)
Definition: projection_impl.hh:89
void write_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:25
void write_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:9
void write_success(const Projection< Coordinate > &projection, std::ostream &out)
Definition: projectionwriter_impl.hh:70
void write_edge_intersection_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:41
void write_edge_intersection_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:54
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:19
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:250
unsigned numberOfEdgeIntersections() const
Number of edge intersections.
Definition: projection.hh:260
const std::tuple< Images, Preimages > & images() const
Images and preimages of corners.
Definition: projection.hh:233
const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections() const
Edge-edge intersections.
Definition: projection.hh:271