Commit 3c529ab7 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

Finalize tikz output

parent 2f6cbb5f
......@@ -31,7 +31,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
parallel_manager para;
para.init();
#ifndef LET
constexpr int dimension = 3;
constexpr int dimension = 2;
constexpr int nb_inputs_near = 1;
constexpr int nb_outputs_near = 1;
constexpr int nb_inputs_far = 1;
......
......@@ -14,42 +14,76 @@
namespace scalfmm::tools::io {
template <class TREE>
void exportTIKZ(std::string& filename, const TREE& tree) {
///
/// \brief export in TIKZ the leaves and their morton index
///
/// Generate a tikz pictures od the non empty leaves and the
/// grid full parent grig
///
/// \param filename name to store the tikz command
/// \param tree to drow the leaf level
///
void exportTIKZ(const std::string& filename, const TREE& tree,
const bool plot_parent = true) {
std::cout << "Write tikz in " << filename << std::endl;
std::ofstream out(filename);
out << "\\begin{tikzpicture}[help lines/.style={blue!50,very thin}] "
<< std::endl;
{
auto center = tree.box_center();
auto corner_l = center - tree.box_width()*0.5;
auto corner_u = center + tree.box_width()*0.5;
out << "\\draw[very thin, gray] ( (" << corner_l[0] << ","
<< corner_l[1] << ") rectangle (" << corner_u[0] << "," << corner_u[1]
<< " );" << std::endl;
}
auto half_width = tree.leaf_width()/2.0;
component::for_each(
std::get<0>(tree.begin()), std::get<0>(tree.end()),
[&half_width, &out](auto& group) {
// std::size_t index_in_group{0};
component::for_each(
std::begin(*group), std::end(*group), [&half_width, &out](auto& leaf) {
auto& leaf_symbolics = leaf.symbolics();
auto center = leaf.center();
auto corner_l = center - half_width;
auto corner_u = center + half_width;
out << "\\filldraw[fill=black!40!white] (" << corner_l[0]
<< "," << corner_l[1] << ") rectangle (" << corner_u[0] << ","
<< corner_u[1] << " );" << std::endl;
out << "\\node[scale=0.8] at (" << center[0] << "," << center[1]
<< ") {\\textbf{" << leaf.index() << "}};" << std::endl;
auto half_width = tree.leaf_width() / 2.0;
component::for_each(std::get<0>(tree.begin()), std::get<0>(tree.end()),
[&half_width, &out](auto& group) {
// std::size_t index_in_group{0};
component::for_each(
std::begin(*group), std::end(*group),
[&half_width, &out](auto& leaf) {
auto& leaf_symbolics = leaf.symbolics();
auto center = leaf.center();
auto corner_l = center - half_width;
auto corner_u = center + half_width;
out << "\\filldraw[fill=black!40!white] ("
<< corner_l[0] << "," << corner_l[1]
<< ") rectangle (" << corner_u[0] << ","
<< corner_u[1] << " );" << std::endl;
out << "\\node[scale=0.8] at (" << center[0]
<< "," << center[1] << ") {\\textbf{"
<< leaf.index() << "}};" << std::endl;
});
});
if (plot_parent) {
///
auto cell_level_it = std::get<1>(tree.begin()) + tree.leaf_level() - 1;
auto group_of_cell_begin = std::begin(*cell_level_it);
auto group_of_cell_end = std::end(*cell_level_it);
});
});
component::for_each(
group_of_cell_begin, group_of_cell_end, [&out](auto& group) {
component::for_each(
std::begin(*group), std::end(*group), [&out](auto& cell) {
auto& cell_symbolics = cell.symbolics();
auto center = cell.center();
auto corner_l = center - cell.width() * 0.5;
auto corner_u = center + cell.width() * 0.5;
out
<< "\\draw[thick, blue] (" << corner_l[0]
<< "," << corner_l[1] << ") rectangle ("
<< corner_u[0] << "," << corner_u[1] << " );"
<< std::endl;
out << "\\node[scale=1.1, blue] at (" << center[0] << "," << center[1]
<< ") {\\textbf{" << cell.index() << "}};" << std::endl;
});
});
}
// {
// auto center = tree.box_center();
// auto corner_l = center - tree.box_width() * 0.5;
// auto corner_u = center + tree.box_width() * 0.5;
// out << "\\draw[ thick, blue, step="<< half_width*4.0 <<"] ( (" << corner_l[0] << ","
// << corner_l[1] << ") grid (" << corner_u[0] << "," << corner_u[1]
// << " );" << std::endl;
// }
out << "\\end{tikzpicture}";
out.close();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment