8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
26 template <
class Glue,
int s
ide>
27 static void writeIntersections(
const Glue& glue,
const std::string& filename)
29 static_assert((side==0 || side==1),
"'side' can only be 0 or 1");
33 fgrid.open(filename.c_str());
35 using GridView =
typename Glue::template GridView<side>;
36 const int dim = GridView::dimension;
37 const int domdimw = GridView::dimensionworld;
40 std::string coordinatePadding;
41 for (
int i=domdimw; i<3; i++)
42 coordinatePadding +=
" 0";
44 int overlaps = glue.size();
48 fgrid <<
"# HyperSurface 0.1 ASCII \n" << std::endl;
50 fgrid<<
"Parameters {\n";
51 fgrid<<
" Materials {\n";
52 fgrid<<
" outside {\n";
67 fgrid<<
"\nVertices "<< overlaps*(dim)<<
"\n";
68 auto isEnd = glue.template iend<side>();
69 for (
auto isIt = glue.template ibegin<side>(); isIt != isEnd; ++isIt)
71 const auto& geometry = isIt->geometry();
72 for (
int i = 0; i < geometry.corners(); ++i)
73 fgrid << geometry.corner(i) << coordinatePadding << std::endl;
80 fgrid<<
"NBranchingPoints 0\n";
81 fgrid<<
"NVerticesOnCurves 0\n";
82 fgrid<<
"BoundaryCurves 0\n";
85 fgrid<<
"InnerRegion inside\n";
86 fgrid<<
"OuterRegion outside\n";
87 fgrid<<
"BoundaryID 0\n";
88 fgrid<<
"BranchingPoints 0";
91 fgrid<<
"Triangles "<<overlaps<<std::endl;
93 for (
int i=0;i<overlaps; i++)
94 fgrid<<i*dim+1<<
" "<<i*dim+2<<
" "<<i*dim+3<<std::endl;
99 fgrid <<
"# AmiraMesh 3D ASCII 2.0 \n";
101 fgrid<<
"define Lines "<<3*overlaps<<
"\n";
102 fgrid<<
"nVertices "<<2*overlaps<<
"\n";
104 fgrid<<
"Parameters {\n";
105 fgrid<<
" ContentType \"HxLineSet\" \n";
108 fgrid<<
"Lines { int LineIdx } @1\n";
109 fgrid<<
"Vertices { float[3] Coordinates } @2\n";
111 fgrid<<
"# Data section follows\n";
113 for (
int i=0; i<overlaps;i++)
114 fgrid<<2*i<<
"\n"<<2*i+1<<
"\n"<<-1<<
"\n";
118 auto isEnd = glue.template iend<side>();
119 for (
auto isIt = glue.template ibegin<side>(); isIt != isEnd; ++isIt) {
120 const auto& geometry = isIt->geometry();
121 for (
int i = 0; i <2; ++i)
122 fgrid << geometry.corner(i) <<
" "<<0<<
"\n";
130 template<
typename Glue>
131 static void write(
const Glue& glue,
const std::string& path,
int appendix=1)
133 std::ostringstream name0;
135 name0 <<
"/domain.surf" << std::setw(3) << std::setfill(
'0') << appendix;
138 writeIntersections<Glue,0>(glue,name0.str());
140 std::ostringstream name1;
142 name1 <<
"/target.surf" << std::setw(3) << std::setfill(
'0') << appendix;
144 writeIntersections<Glue,1>(glue, name1.str());
Write remote intersections to a AmiraMesh file for debugging purposes.
Definition: gridglueamirawriter.hh:21