Commit a8ce70b5 authored by Pietro Incardona's avatar Pietro Incardona

added vector grid visualization

parent dc6d2ab5
......@@ -558,7 +558,7 @@ class GraphMLWriter
vn.new_node(nc);
// 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
vn.end_node();
......
......@@ -94,14 +94,22 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
n1.get_i() = 6.0;
n1.get_str() = std::string("test");
g_csr2.addVertex(n1);
n1.get_str() = std::string("tes2");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test3");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test4");
g_csr2.addVertex(n1);
n1.get_str() = std::string("test5");
g_csr2.addEdge(0,1,n1);
n1.get_str() = std::string("test6");
g_csr2.addEdge(2,1,n1);
n1.get_str() = std::string("test7");
g_csr2.addEdge(3,1,n1);
n1.get_str() = std::string("test8");
g_csr2.addEdge(2,0,n1);
n1.get_str() = std::string("test9");
g_csr2.addEdge(3,2,n1);
// Create a graph ML
......
......@@ -109,11 +109,10 @@ struct vtk_vertex_node
* \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]) :
x(x), vo(n_obj), v_node(v_node), z_set(false)
vtk_vertex_node(std::string & v_node, typename G::V_container & n_obj, s_type (&x)[3])
:z_set(false),x(x),vo(n_obj),v_node(v_node)
{
}
;
//! \brief Write collected information
void write()
......@@ -473,7 +472,7 @@ public:
// Check if T is a supported format
// 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
type = getType<typename std::remove_all_extents<T>::type>();
......
......@@ -69,26 +69,40 @@ public:
//! vertex node output string
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
// 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
// if the type is not supported return
if (type.size() == 0)
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
// Create point data properties
v_out += "VECTORS " + get_attributes("") + " " + type + "\n";
}
else
{
std::string type = getType<ctype>();
// Create point data properties
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// if the type is not supported return
if (type.size() == 0)
return v_out;
// Default lookup table
v_out += "LOOKUP_TABLE default\n";
// Create point data properties
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// Default lookup table
v_out += "LOOKUP_TABLE default\n";
}
// return the vertex list
return v_out;
......@@ -134,26 +148,40 @@ public:
//! vertex node output string
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
// 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;
typedef typename std::remove_all_extents<ctype>::type vttype;
std::string type = getType<vttype>();
// 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
if (type.size() == 0)
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(ctype).name()) << " is not supported by vtk\n";
return "";
// Create point data properties
v_out += "VECTORS " + get_attributes("") + " " + type + "\n";
}
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
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// Create point data properties
v_out += "SCALARS " + get_attributes(oprp) + " " + type + "\n";
// Default lookup table
v_out += "LOOKUP_TABLE default\n";
// Default lookup table
v_out += "LOOKUP_TABLE default\n";
}
// return the vertex list
return v_out;
......@@ -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)
{
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
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));
// 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("");
// If the output has changed, we have to write the properties
if (v_out.size() != sz)
// If the output has changed, we have to write the properties
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
auto it = vg.get(k).g.getIterator();
// if there is the next element
while (it.isNext())
// Print the properties
for (size_t i1 = 0 ; i1 < N1 ; i1++)
{
// Print the property
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;
v_out += std::to_string(vg.get(k).g.get_o(it.get()).template get<I::value>()[i1]) + " ";
}
if (N1 == 2)
{
v_out += "0.0";
}
v_out += "\n";
// increment the iterator and counter
++it;
}
}
}
......
......@@ -31,7 +31,7 @@
<data key="vk3">4.000000</data>
<data key="vk4">5</data>
<data key="vk5">6</data>
<data key="vk6">test</data>
<data key="vk6">tes2</data>
</node>
<node id="n2">
<data key="vk0">1.000000</data>
......@@ -40,7 +40,7 @@
<data key="vk3">4.000000</data>
<data key="vk4">5</data>
<data key="vk5">6</data>
<data key="vk6">test</data>
<data key="vk6">test3</data>
</node>
<node id="n3">
<data key="vk0">1.000000</data>
......@@ -49,7 +49,7 @@
<data key="vk3">4.000000</data>
<data key="vk4">5</data>
<data key="vk5">6</data>
<data key="vk6">test</data>
<data key="vk6">test4</data>
</node>
<edge id="e0" source="n0" target="n1">
<data key="ek0">1.000000</data>
......@@ -58,7 +58,7 @@
<data key="ek3">4.000000</data>
<data key="ek4">5</data>
<data key="ek5">6</data>
<data key="ek6">test</data>
<data key="ek6">test5</data>
</edge>
<edge id="e1" source="n2" target="n1">
<data key="ek0">1.000000</data>
......@@ -67,7 +67,7 @@
<data key="ek3">4.000000</data>
<data key="ek4">5</data>
<data key="ek5">6</data>
<data key="ek6">test</data>
<data key="ek6">test6</data>
</edge>
<edge id="e2" source="n2" target="n0">
<data key="ek0">1.000000</data>
......@@ -76,7 +76,7 @@
<data key="ek3">4.000000</data>
<data key="ek4">5</data>
<data key="ek5">6</data>
<data key="ek6">test</data>
<data key="ek6">test8</data>
</edge>
<edge id="e3" source="n3" target="n1">
<data key="ek0">1.000000</data>
......@@ -85,7 +85,7 @@
<data key="ek3">4.000000</data>
<data key="ek4">5</data>
<data key="ek5">6</data>
<data key="ek6">test</data>
<data key="ek6">test7</data>
</edge>
<edge id="e4" source="n3" target="n2">
<data key="ek0">1.000000</data>
......@@ -94,7 +94,7 @@
<data key="ek3">4.000000</data>
<data key="ek4">5</data>
<data key="ek5">6</data>
<data key="ek6">test</data>
<data key="ek6">test9</data>
</edge>
</graph>
</graphml>
\ No newline at end of file
......@@ -6157,3084 +6157,1031 @@ LOOKUP_TABLE default
1.000000
1.000000
1.000000
SCALARS attr4_0 float
LOOKUP_TABLE default
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
16.000000
17.000000
18.000000
19.000000
20.000000
21.000000
22.000000
23.000000
24.000000
25.000000
26.000000
27.000000
28.000000
29.000000
30.000000
31.000000
32.000000
33.000000
34.000000
35.000000
36.000000
37.000000
38.000000
39.000000
40.000000
41.000000
42.000000
43.000000
44.000000
45.000000
46.000000
47.000000
48.000000
49.000000
50.000000
51.000000
52.000000
53.000000
54.000000
55.000000
56.000000
57.000000
58.000000
59.000000
60.000000
61.000000
62.000000
63.000000
64.000000
65.000000
66.000000
67.000000
68.000000
69.000000
70.000000
71.000000
72.000000
73.000000
74.000000
75.000000
76.000000
77.000000
78.000000
79.000000
80.000000
81.000000
82.000000
83.000000
84.000000
85.000000
86.000000
87.000000
88.000000
89.000000
90.000000
91.000000
92.000000
93.000000
94.000000
95.000000
96.000000
97.000000
98.000000
99.000000
100.000000
101.000000
102.000000
103.000000
104.000000
105.000000
106.000000
107.000000
108.000000
109.000000
110.000000
111.000000
112.000000
113.000000
114.000000
115.000000
116.000000
117.000000
118.000000
119.000000
120.000000
121.000000
122.000000
123.000000
124.000000
125.000000
126.000000
127.000000
128.000000
129.000000
130.000000
131.000000
132.000000
133.000000
134.000000
135.000000
136.000000
137.000000
138.000000
139.000000
140.000000
141.000000
142.000000
143.000000
144.000000
145.000000
146.000000
147.000000
148.000000
149.000000
150.000000
151.000000
152.000000
153.000000
154.000000
155.000000
156.000000
157.000000
158.000000
159.000000
160.000000
161.000000
162.000000
163.000000
164.000000
165.000000
166.000000
167.000000
168.000000
169.000000
170.000000
171.000000
172.000000
173.000000
174.000000
175.000000
176.000000
177.000000
178.000000
179.000000
180.000000
181.000000
182.000000
183.000000
184.000000
185.000000
186.000000
187.000000
188.000000
189.000000
190.000000
191.000000
192.000000
193.000000
194.000000
195.000000
196.000000
197.000000
198.000000
199.000000
200.000000
201.000000
202.000000
203.000000
204.000000
205.000000
206.000000
207.000000
208.000000
209.000000
210.000000
211.000000
212.000000
213.000000
214.000000
215.000000
216.000000
217.000000
218.000000
219.000000
220.000000
221.000000
222.000000
223.000000
224.000000
225.000000
226.000000
227.000000
228.000000
229.000000
230.000000
231.000000
232.000000
233.000000
234.000000
235.000000
236.000000
237.000000
238.000000
239.000000
240.000000
241.000000
242.000000
243.000000
244.000000
245.000000
246.000000
247.000000
248.000000
249.000000
250.000000
251.000000
252.000000
253.000000
254.000000
255.000000
0.000000
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
16.000000
17.000000
18.000000
19.000000
20.000000
21.000000
22.000000
23.000000
24.000000
25.000000
26.000000
27.000000
28.000000
29.000000
30.000000
31.000000
32.000000
33.000000
34.000000
35.000000
36.000000
37.000000
38.000000
39.000000
40.000000
41.000000
42.000000
43.000000
44.000000
45.000000
46.000000
47.000000
48.000000
49.000000
50.000000
51.000000
52.000000
53.000000
54.000000
55.000000
56.000000
57.000000
58.000000
59.000000
60.000000
61.000000
62.000000
63.000000
64.000000
65.000000
66.000000
67.000000
68.000000
69.000000
70.000000
71.000000
72.000000
73.000000
74.000000
75.000000
76.000000
77.000000
78.000000
79.000000
80.000000
81.000000
82.000000
83.000000
84.000000
85.000000
86.000000
87.000000
88.000000
89.000000
90.000000
91.000000
92.000000
93.000000
94.000000
95.000000
96.000000
97.000000
98.000000
99.000000
100.000000
101.000000
102.000000
103.000000
104.000000
105.000000
106.000000