Commit a8ce70b5 authored by Pietro Incardona's avatar Pietro Incardona

added vector grid visualization

parent dc6d2ab5
...@@ -558,7 +558,7 @@ class GraphMLWriter ...@@ -558,7 +558,7 @@ class GraphMLWriter
vn.new_node(nc); vn.new_node(nc);
// Iterate through all the vertex and create the vertex list // Iterate through all the vertex and create the vertex list
boost::mpl::for_each< boost::mpl::range_c<int,0,Graph::V_type::max_prop> >(vn); boost::mpl::for_each_ref< boost::mpl::range_c<int,0,Graph::V_type::max_prop> >(vn);
// end node // end node
vn.end_node(); vn.end_node();
......
...@@ -94,14 +94,22 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use) ...@@ -94,14 +94,22 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
n1.get_i() = 6.0; n1.get_i() = 6.0;
n1.get_str() = std::string("test"); n1.get_str() = std::string("test");
g_csr2.addVertex(n1); g_csr2.addVertex(n1);
n1.get_str() = std::string("tes2");
g_csr2.addVertex(n1); g_csr2.addVertex(n1);
n1.get_str() = std::string("test3");
g_csr2.addVertex(n1); g_csr2.addVertex(n1);
n1.get_str() = std::string("test4");
g_csr2.addVertex(n1); g_csr2.addVertex(n1);
n1.get_str() = std::string("test5");
g_csr2.addEdge(0,1,n1); g_csr2.addEdge(0,1,n1);
n1.get_str() = std::string("test6");
g_csr2.addEdge(2,1,n1); g_csr2.addEdge(2,1,n1);
n1.get_str() = std::string("test7");
g_csr2.addEdge(3,1,n1); g_csr2.addEdge(3,1,n1);
n1.get_str() = std::string("test8");
g_csr2.addEdge(2,0,n1); g_csr2.addEdge(2,0,n1);
n1.get_str() = std::string("test9");
g_csr2.addEdge(3,2,n1); g_csr2.addEdge(3,2,n1);
// Create a graph ML // Create a graph ML
......
...@@ -109,11 +109,10 @@ struct vtk_vertex_node ...@@ -109,11 +109,10 @@ struct vtk_vertex_node
* \param n_obj object container to access its properties for example encapc<...> * \param n_obj object container to access its properties for example encapc<...>
* *
*/ */
vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3]) : vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
x(x), vo(n_obj), v_node(v_node), z_set(false) :z_set(false),x(x),vo(n_obj),v_node(v_node)
{ {
} }
;
//! \brief Write collected information //! \brief Write collected information
void write() void write()
...@@ -473,7 +472,7 @@ public: ...@@ -473,7 +472,7 @@ public:
// Check if T is a supported format // Check if T is a supported format
// for now we support only scalar of native type // for now we support only scalar of native type
if (std::is_array<T>::value == true && std::is_array<typename std::remove_extent<T>::type>::value == false) if (std::rank<T>::value == 1)
{ {
//Get type of the property //Get type of the property
type = getType<typename std::remove_all_extents<T>::type>(); type = getType<typename std::remove_all_extents<T>::type>();
......
...@@ -69,26 +69,40 @@ public: ...@@ -69,26 +69,40 @@ public:
//! vertex node output string //! vertex node output string
std::string v_out; std::string v_out;
typedef typename boost::fusion::result_of::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<i>>::type ctype; typedef typename boost::mpl::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<i>>::type ctype;
// Check if T is a supported format // Check if T is a supported format
// for now we support only scalar of native type // for now we support only scalar of native type
if (std::rank<ctype>::value == 1)
{
//Get type of the property
std::string type = getType<typename std::remove_all_extents<ctype>::type>();
std::string type = getType<ctype>(); // if the type is not supported skip-it
if (type.size() == 0)
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
}
// if the type is not supported return // Create point data properties
// if the type is not supported return v_out += "VECTORS " + get_attributes("") + " " + type + "\n";
if (type.size() == 0)
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
} }
else
{
std::string type = getType<ctype>();
// Create point data properties // if the type is not supported return
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n"; if (type.size() == 0)
return v_out;
// Default lookup table // Create point data properties
v_out += "LOOKUP_TABLE default\n"; v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// Default lookup table
v_out += "LOOKUP_TABLE default\n";
}
// return the vertex list // return the vertex list
return v_out; return v_out;
...@@ -134,26 +148,40 @@ public: ...@@ -134,26 +148,40 @@ public:
//! vertex node output string //! vertex node output string
std::string v_out; std::string v_out;
typedef typename boost::mpl::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<i>>::type ctype;
// Check if T is a supported format // Check if T is a supported format
// for now we support only scalar of native type // for now we support only scalar of native type
if (std::rank<ctype>::value == 1)
{
//Get type of the property
std::string type = getType<typename std::remove_all_extents<ctype>::type>();
typedef typename boost::mpl::at<typename ele_g::value_type::value_type::type,boost::mpl::int_<i>>::type ctype; // if the type is not supported skip-it
typedef typename std::remove_all_extents<ctype>::type vttype; if (type.size() == 0)
{
std::string type = getType<vttype>(); std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
}
// if the type is not supported return // Create point data properties
if (type.size() == 0) v_out += "VECTORS " + get_attributes("") + " " + type + "\n";
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
} }
else
{
std::string type = getType<typename std::remove_all_extents<ctype>::type>();
// if the type is not supported return
if (type.size() == 0)
return v_out;
// Create point data properties // Create point data properties
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n"; v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// Default lookup table // Default lookup table
v_out += "LOOKUP_TABLE default\n"; v_out += "LOOKUP_TABLE default\n";
}
// return the vertex list // return the vertex list
return v_out; return v_out;
...@@ -214,33 +242,38 @@ struct meta_prop<I, ele_g,St,T[N1]> ...@@ -214,33 +242,38 @@ struct meta_prop<I, ele_g,St,T[N1]>
{ {
inline meta_prop(const openfpm::vector< ele_g > & vg, std::string & v_out) inline meta_prop(const openfpm::vector< ele_g > & vg, std::string & v_out)
{ {
for (size_t i1 = 0 ; i1 < N1 ; i1++) // actual string size
{ size_t sz = v_out.size();
// actual string size
size_t sz = v_out.size();
// Produce the point properties header // Produce the point properties header
v_out += prop_output_g<has_attributes<typename ele_g::value_type::value_type>::value,St ,ele_g,I::value>::get_point_property_header("_" + std::to_string(i1)); v_out += prop_output_g<has_attributes<typename ele_g::value_type::value_type>::value,St ,ele_g,I::value>::get_point_property_header("");
// If the output has changed, we have to write the properties // If the output has changed, we have to write the properties
if (v_out.size() != sz) if (v_out.size() != sz)
{
// Produce point data
for (size_t k = 0 ; k < vg.size() ; k++)
{ {
// Produce point data //! Get a vertex iterator
auto it = vg.get(k).g.getIterator();
for (size_t k = 0 ; k < vg.size() ; k++) // if there is the next element
while (it.isNext())
{ {
//! Get a vertex iterator // Print the properties
auto it = vg.get(k).g.getIterator(); for (size_t i1 = 0 ; i1 < N1 ; i1++)
// if there is the next element
while (it.isNext())
{ {
// Print the property v_out += std::to_string(vg.get(k).g.get_o(it.get()).template get<I::value>()[i1]) + " ";
v_out += std::to_string(vg.get(k).g.get_o(it.get()).template get<I::value>()[i1]) + "\n";
// increment the iterator and counter
++it;
} }
if (N1 == 2)
{
v_out += "0.0";
}
v_out += "\n";
// increment the iterator and counter
++it;
} }
} }
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<data key="vk3">4.000000</data> <data key="vk3">4.000000</data>
<data key="vk4">5</data> <data key="vk4">5</data>
<data key="vk5">6</data> <data key="vk5">6</data>
<data key="vk6">test</data> <data key="vk6">tes2</data>
</node> </node>
<node id="n2"> <node id="n2">
<data key="vk0">1.000000</data> <data key="vk0">1.000000</data>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<data key="vk3">4.000000</data> <data key="vk3">4.000000</data>
<data key="vk4">5</data> <data key="vk4">5</data>
<data key="vk5">6</data> <data key="vk5">6</data>
<data key="vk6">test</data> <data key="vk6">test3</data>
</node> </node>
<node id="n3"> <node id="n3">
<data key="vk0">1.000000</data> <data key="vk0">1.000000</data>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<data key="vk3">4.000000</data> <data key="vk3">4.000000</data>
<data key="vk4">5</data> <data key="vk4">5</data>
<data key="vk5">6</data> <data key="vk5">6</data>
<data key="vk6">test</data> <data key="vk6">test4</data>
</node> </node>
<edge id="e0" source="n0" target="n1"> <edge id="e0" source="n0" target="n1">
<data key="ek0">1.000000</data> <data key="ek0">1.000000</data>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<data key="ek3">4.000000</data> <data key="ek3">4.000000</data>
<data key="ek4">5</data> <data key="ek4">5</data>
<data key="ek5">6</data> <data key="ek5">6</data>
<data key="ek6">test</data> <data key="ek6">test5</data>
</edge> </edge>
<edge id="e1" source="n2" target="n1"> <edge id="e1" source="n2" target="n1">
<data key="ek0">1.000000</data> <data key="ek0">1.000000</data>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<data key="ek3">4.000000</data> <data key="ek3">4.000000</data>
<data key="ek4">5</data> <data key="ek4">5</data>
<data key="ek5">6</data> <data key="ek5">6</data>
<data key="ek6">test</data> <data key="ek6">test6</data>
</edge> </edge>
<edge id="e2" source="n2" target="n0"> <edge id="e2" source="n2" target="n0">
<data key="ek0">1.000000</data> <data key="ek0">1.000000</data>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<data key="ek3">4.000000</data> <data key="ek3">4.000000</data>
<data key="ek4">5</data> <data key="ek4">5</data>
<data key="ek5">6</data> <data key="ek5">6</data>
<data key="ek6">test</data> <data key="ek6">test8</data>
</edge> </edge>
<edge id="e3" source="n3" target="n1"> <edge id="e3" source="n3" target="n1">
<data key="ek0">1.000000</data> <data key="ek0">1.000000</data>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<data key="ek3">4.000000</data> <data key="ek3">4.000000</data>
<data key="ek4">5</data> <data key="ek4">5</data>
<data key="ek5">6</data> <data key="ek5">6</data>
<data key="ek6">test</data> <data key="ek6">test7</data>
</edge> </edge>
<edge id="e4" source="n3" target="n2"> <edge id="e4" source="n3" target="n2">
<data key="ek0">1.000000</data> <data key="ek0">1.000000</data>
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<data key="ek3">4.000000</data> <data key="ek3">4.000000</data>
<data key="ek4">5</data> <data key="ek4">5</data>
<data key="ek5">6</data> <data key="ek5">6</data>
<data key="ek6">test</data> <data key="ek6">test9</data>
</edge> </edge>
</graph> </graph>
</graphml> </graphml>
\ No newline at end of file
This diff is collapsed.
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