00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef FEM_GIO_H
00010 #define FEM_GIO_H
00011
00012 #include <graphics/GraphicsInterface.hpp>
00013 #include <fem/Grid.hpp>
00014
00015 namespace imaging
00016 {
00017 template <class fem_types>
00018 GraphicsInterface & operator<<(GraphicsInterface & out, const Grid<fem_types> & grid)
00019 {
00020 GraphicsInterface::StreamStatus stream_status_backup = out.get_stream_status();
00021
00022 out << GraphicsInterface::set_color(Color::RED);
00023
00024 for(int i = 0; i < grid.n_elements(); ++i)
00025 {
00026 std::vector< ublas::fixed_vector<float_t, fem_types::data_dimension> > element_vertices(fem_types::transform_t::n_element_vertices);
00027
00028 for(size_t j = 0; j < fem_types::shape_function_t::n_element_nodes; ++j)
00029 element_vertices[j] = grid.vertex(i, j);
00030
00031 out.polygon(element_vertices);
00032
00033 out << GraphicsInterface::offset_z_layer(2);
00034
00035 for(size_t j = 0; j < fem_types::shape_function_t::n_element_nodes; ++j)
00036 {
00037 if(grid.is_boundary_node(i, j))
00038 {
00039 out << GraphicsInterface::set_color(Color::BLUE);
00040
00041 out.arrow(grid.vertex(i, j), grid.boundary_normal(i, j));
00042 out << GraphicsInterface::set_color(Color::RED);
00043 }
00044 }
00045
00046 out << GraphicsInterface::offset_z_layer(-2);
00047 }
00048
00049 out << GraphicsInterface::offset_z_layer(1);
00050
00051 out << GraphicsInterface::set_color(Color::BLUE);
00052
00053 for(int i = 0; i < grid.n_boundary_elements(); ++i)
00054 {
00055 size_t parent_element = grid.parent_element(i);
00056 size_t element_face = grid.parent_element_face(i);
00057 ublas::fixed_vector<size_t, 2> local_vertex_indices(fem_types::transform_t::face_vertex(element_face, 0),
00058 fem_types::transform_t::face_vertex(element_face, 1));
00059 out.line_segment(grid.vertex(parent_element, local_vertex_indices(0)),
00060 grid.vertex(parent_element, local_vertex_indices(1)));
00061 }
00062
00063 out << GraphicsInterface::offset_z_layer(-1);
00064
00065 out << stream_status_backup;
00066
00067 return out;
00068 }
00069
00070 }
00071
00072
00073 #endif