36#include "ImmersedBoundarySvgWriter.hpp"
37#include "ImmersedBoundaryMesh.hpp"
39template <
unsigned DIM>
42 mSamplingMultiple(100u),
50template <
unsigned DIM>
55template <
unsigned DIM>
64 std::stringstream time;
68 std::string full_file_name =
"results_" + time.str() +
".svg";
70 out_stream svg_file = results_handler.
OpenOutputFile(full_file_name);
72 (*svg_file) << mSvgHeader;
80 AddPointToSvgFile(svg_file, it->rGetLocation(), it->GetRegion(), node_rad);
83 (*svg_file) << mSvgFooter;
89template <
unsigned DIM>
92 std::string outputDirectory)
94 mOutputDirectory = outputDirectory;
97 std::string bg_col =
"darkgray";
98 std::string region0_col =
"#990000";
99 std::string region1_col =
"#cc0000";
100 std::string region2_col =
"#e68a00";
101 std::string region3_col =
"#ff9900";
102 std::string region4_col =
"#006666";
103 std::string region5_col =
"#009999";
104 std::string region6_col =
"#000099";
105 std::string region7_col =
"#0000cc";
106 std::string region8_col =
"#FFFFFF";
107 std::string glyph0_col =
"DarkRed";
108 std::string glyph1_col =
"DarkBlue";
109 std::string glyph2_col =
"DarkGreen";
111 std::stringstream header;
114 header << std::setprecision(5);
117 header <<
"<svg version=\"1.1\" baseProfile=\"full\" width=\""
118 << mSvgSize <<
"px\" height=\"" << mSvgSize <<
"px\" "
119 <<
"viewBox=\"0 0 " << mSvgSize <<
" " << mSvgSize <<
"\" "
120 <<
"xmlns=\"http://www.w3.org/2000/svg\">" <<
"\n";
123 header <<
"<style type=\"text/css\">" <<
"\n"
124 <<
"\t.bg_rect{fill:" << bg_col <<
";}" <<
"\n"
125 <<
"\t.node_0{fill:" << region0_col <<
";}" <<
"\n"
126 <<
"\t.node_1{fill:" << region1_col <<
";}" <<
"\n"
127 <<
"\t.node_2{fill:" << region2_col <<
";}" <<
"\n"
128 <<
"\t.node_3{fill:" << region3_col <<
";}" <<
"\n"
129 <<
"\t.node_4{fill:" << region4_col <<
";}" <<
"\n"
130 <<
"\t.node_5{fill:" << region5_col <<
";}" <<
"\n"
131 <<
"\t.node_6{fill:" << region6_col <<
";}" <<
"\n"
132 <<
"\t.node_7{fill:" << region7_col <<
";}" <<
"\n"
133 <<
"\t.node_8{fill:" << region8_col <<
";}" <<
"\n"
134 <<
"\t.glyph_0{fill:" << glyph0_col <<
";}" <<
"\n"
135 <<
"\t.glyph_1{fill:" << glyph1_col <<
";}" <<
"\n"
136 <<
"\t.glyph_2{fill:" << glyph2_col <<
";}" <<
"\n"
137 <<
"</style>" <<
"\n";
140 header <<
"<rect class=\"bg_rect\" width=\"" << mSvgSize <<
"\" height=\"" << mSvgSize <<
"\"/>" <<
"\n";
142 mSvgHeader = header.str();
143 mSvgFooter =
"</svg>\n";
146template <
unsigned DIM>
148 out_stream& rSvgFile,
149 c_vector<double, DIM> location,
153 double scaled_x = location[0] * mSvgSize;
154 double scaled_y = (1.0 - location[1]) * mSvgSize;
156 (*rSvgFile) <<
"<circle class=\"node_" << region <<
"\" "
157 <<
"cx=\"" << scaled_x <<
"\" "
158 <<
"cy=\"" << scaled_y <<
"\" "
159 <<
"r=\"" << rad <<
"\"/>" <<
"\n";
164 (*rSvgFile) <<
"<circle class=\"node_" << region <<
"\" "
165 <<
"cx=\"" << scaled_x + mSvgSize <<
"\" "
166 <<
"cy=\"" << scaled_y <<
"\" "
167 <<
"r=\"" << rad <<
"\"/>" <<
"\n";
169 else if (scaled_x > mSvgSize - rad)
171 (*rSvgFile) <<
"<circle class=\"node_" << region <<
"\" "
172 <<
"cx=\"" << scaled_x - mSvgSize <<
"\" "
173 <<
"cy=\"" << scaled_y <<
"\" "
174 <<
"r=\"" << rad <<
"\"/>" <<
"\n";
180 (*rSvgFile) <<
"<circle class=\"node_" << region <<
"\" "
181 <<
"cx=\"" << scaled_x <<
"\" "
182 <<
"cy=\"" << scaled_y + mSvgSize <<
"\" "
183 <<
"r=\"" << rad <<
"\"/>" <<
"\n";
185 else if (scaled_y > mSvgSize - rad)
187 (*rSvgFile) <<
"<circle class=\"node_" << region <<
"\" "
188 <<
"cx=\"" << scaled_x <<
"\" "
189 <<
"cy=\"" << scaled_y - mSvgSize <<
"\" "
190 <<
"r=\"" << rad <<
"\"/>" <<
"\n";
194template <
unsigned DIM>
196 out_stream& rParamsFile)
202template <
unsigned DIM>
205 return mSamplingMultiple;
208template <
unsigned DIM>
210 unsigned samplingMultiple)
212 mSamplingMultiple = samplingMultiple;
215template <
unsigned DIM>
221template <
unsigned DIM>
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)=0
AbstractMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
NodeIterator GetNodeIteratorEnd()
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
double GetAverageNodeSpacingOfElement(unsigned index, bool recalculate=true)
unsigned GetSamplingMultiple() const
void SetSvgSize(double svgSize)
ImmersedBoundarySvgWriter()
void AddPointToSvgFile(out_stream &rSvgFile, c_vector< double, DIM > location, unsigned region, double rad)
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
void SetSamplingMultiple(unsigned samplingMultiple)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
double GetSvgSize() const
virtual void UpdateAtEndOfTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual ~ImmersedBoundarySvgWriter()
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
static SimulationTime * Instance()
unsigned GetTimeStepsElapsed() const