31 #define __RefEntity_H 1
34 #include <boost/numeric/ublas/matrix.hpp>
35 #include <boost/numeric/ublas/io.hpp>
37 #include <feel/feelcore/traits.hpp>
45 template<
size_type ShapeE,
typename T =
double>
57 template<
typename Geo, u
int16_type Dim = 1, u
int16_type Order = 1, u
int16_type RDim = Dim,
typename T =
double>
61 template<
typename Geo, u
int16_type Dim, u
int16_type Order, u
int16_type RDim,
typename T>
63 operator<<( std::ostream& os,
67 os <<
" Dimension: " << ref_type::nDim <<
"\n"
68 <<
" Order: " << ref_type::nOrder <<
"\n"
69 <<
"Real dimension: " << ref_type::nRealDim <<
"\n";
70 os <<
" Vertices: " << ref.vertices() <<
"\n";
71 os <<
" Normals: " << ref.normals() <<
"\n";
74 template<
typename RefEntity>
75 void toPython( RefEntity
const& e, std::string str =
"simplex" )
77 typedef typename RefEntity::value_type value_type;
78 typedef typename RefEntity::node_type node_type;
79 std::ostringstream ostr;
81 <<
"_" << RefEntity::nDim
82 <<
"_" << RefEntity::nOrder
83 <<
"_" << RefEntity::nRealDim
85 std::ofstream ofs( ostr.str().c_str() );
87 ofs <<
"from pyx import *\n";
88 ofs <<
"p=path.path(";
90 for (
int i = 0; i < RefEntity::numEdges; ++i )
92 for (
int j = 0; j < 2; ++j )
96 if ( RefEntity::nRealDim == 1 )
98 x( 0 ) = e.edgeVertex( i,j )( 0 );
99 x( 1 ) = value_type( 0 );
102 if ( RefEntity::nRealDim == 2 )
104 x = e.edgeVertex( i, j );
107 if ( RefEntity::nRealDim == 3 )
109 x( 0 ) = e.edgeVertex( i, j )( 0 )+e.edgeVertex( i, j )( 1 )*std::cos( M_PI/4 );
110 x( 1 ) = e.edgeVertex( i, j )( 2 )+e.edgeVertex( i, j )( 1 )*std::sin( M_PI/4 );
114 ofs <<
"path.moveto(" << double( x( 0 ) )<<
"," << double( x( 1 ) ) <<
"),\n";
117 ofs <<
"path.lineto(" << double( x( 0 ) )<<
"," << double( x( 1 ) ) <<
"),\n";
121 ofs <<
"path.closepath() )\n";
122 ofs <<
"c = canvas.canvas()\n"
123 <<
"c.stroke(p, [style.linewidth.Thin])\n";
125 for (
int i = 0; i < RefEntity::numPoints; ++i )
129 if ( RefEntity::nRealDim == 1 )
131 x( 0 ) = e.point( i )( 0 );
132 x( 1 ) = value_type( 0 );
135 if ( RefEntity::nRealDim == 2 )
140 if ( RefEntity::nRealDim == 3 )
142 x( 0 ) = e.point( i )( 0 )+e.point( i )( 1 )*std::cos( M_PI/4 );
143 x( 1 ) = e.point( i )( 2 )+e.point( i )( 1 )*std::sin( M_PI/4 );
146 ofs <<
"c.fill ( path.circle(" << double( x( 0 ) ) <<
"," << double( x( 1 ) )<<
", 0.05 ),[deco.filled([color.grey.black])])\n";
147 ofs <<
"c.text(" << double( x( 0 ) ) <<
"," << double( x( 1 ) ) <<
", \"" << i <<
"\")\n";
150 ofs <<
"c.writePDFfile(\"" << str <<
"_" << RefEntity::nDim
151 <<
"_" << RefEntity::nOrder
152 <<
"_" << RefEntity::nRealDim
153 <<
"\", paperformat=\"a4\")\n";