31 #define __PointSet_H 1
40 namespace ublas = boost::numeric::ublas;
53 template<
class Convex,
typename T>
56 typedef VisitableBase<> super;
67 typedef ublas::matrix<value_type, ublas::column_major> nodes_type;
74 M_points_face( Convex::numTopologicalFaces )
80 M_npoints( P.nPoints() ),
81 M_points( P.points() ),
82 M_points_face( P.M_points_face )
89 M_points( Convex::nDim, Npoints ),
90 M_points_face( Convex::numTopologicalFaces )
93 PointSet( uint32_type Npoints, uint16_type Dim )
97 M_points( Dim, Npoints ),
98 M_points_face( Convex::numTopologicalFaces )
101 PointSet( nodes_type
const& SomePoints )
104 M_npoints( SomePoints.size2() ),
105 M_points( SomePoints ),
106 M_points_face( Convex::numTopologicalFaces )
116 M_npoints = p.M_npoints;
117 M_points = p.M_points;
118 M_points_face = p.M_points_face;
125 uint32_type nPoints()
const
129 nodes_type
const& points()
const
133 ublas::matrix_column<nodes_type const> point( uint32_type __i )
const
135 return ublas::column( M_points, __i );
137 ublas::matrix_column<nodes_type> point( uint32_type __i )
139 return ublas::column( M_points, __i );
143 nodes_type
const& points( uint16_type f )
const
145 return M_points_face[f];
147 ublas::matrix_column<nodes_type const> point( uint16_type f, uint32_type __i )
const
149 return ublas::column( M_points_face[f], __i );
151 ublas::matrix_column<nodes_type> point( uint16_type f, uint32_type __i )
153 return ublas::column( M_points_face[f], __i );
156 void setName( std::string name, uint32_type order )
158 std::ostringstream ostr;
162 <<
"_" << Convex::nRealDim;
164 pointsInfo = ostr.str();
169 std::string getName()
174 std::string getPointsInfo()
183 std::ostringstream ostr;
185 ostr << getName() <<
"_" << getPointsInfo() <<
".py";
187 std::ofstream ofs( ostr.str().c_str() );
189 ofs <<
"from pyx import *\n";
191 ofs <<
"p=path.path(";
193 for ( uint16_type i = 0; i < Convex::numEdges; ++i )
195 for ( uint16_type j = 0; j < 2; ++j )
199 if ( Convex::nRealDim == 1 )
201 x( 0 ) = RefConv.edgeVertex( i,j )( 0 );
202 x( 1 ) = value_type( 0 );
205 if ( Convex::nRealDim == 2 )
207 x = RefConv.edgeVertex( i, j );
210 if ( Convex::nRealDim == 3 )
212 x( 0 ) = RefConv.edgeVertex( i, j )( 0 )+RefConv.edgeVertex( i, j )( 1 )*std::cos( M_PI/4 );
213 x( 1 ) = RefConv.edgeVertex( i, j )( 2 )+RefConv.edgeVertex( i, j )( 1 )*std::sin( M_PI/4 );
217 ofs <<
"path.moveto(" << double( x( 0 ) )<<
"," << double( x( 1 ) ) <<
"),\n";
220 ofs <<
"path.lineto(" << double( x( 0 ) )<<
"," << double( x( 1 ) ) <<
"),\n";
224 ofs <<
"path.closepath() )\n";
226 ofs <<
"text.set(mode=\"latex\")\n"
227 <<
"c = canvas.canvas()\n"
228 <<
"c.stroke(p, [style.linewidth.Thin])\n";
230 for ( uint16_type i = 0; i < nPoints(); ++i )
234 if ( Convex::nRealDim == 1 )
236 x( 0 ) = this->point( i )( 0 );
237 x( 1 ) = value_type( 0 );
240 if ( Convex::nRealDim == 2 )
242 x = this->point( i );
245 if ( Convex::nRealDim == 3 )
247 x( 0 ) = this->point( i )( 0 ) + this->point( i )( 1 )*std::cos( M_PI/4 );
248 x( 1 ) = this->point( i )( 2 ) + this->point( i )( 1 )*std::sin( M_PI/4 );
252 ofs <<
"c.fill ( path.circle(" << double( x( 0 ) ) <<
"," << double( x( 1 ) )<<
", 0.02 ),[deco.filled([color.rgb.red])])\n";
253 ofs <<
"c.text( " << double( x( 0 )+0.025 ) <<
"," << double( x( 1 )+0.025 )<<
", r\"{\\scriptsize " << i <<
"}\")\n";
256 ofs <<
"c.writeEPSfile(\"" << getName() <<
"_" << getPointsInfo()
257 <<
"\", document.paperformat.A4)\n";
260 FEELPP_DEFINE_VISITABLE();
270 M_npoints = pts.size2();
278 M_points_face[f] = n;
282 uint32_type M_npoints;
284 std::vector<nodes_type> M_points_face;
287 std::string pointsName;
290 std::string pointsInfo;
Convex base class.
Definition: convex.hpp:43
void setPoints(nodes_type const &pts)
Definition: pointset.hpp:267
Reference convex.
Definition: refentity.hpp:58
void setPoints(uint16_type f, nodes_type const &n)
Definition: pointset.hpp:276
Class of all PointSet on a Convex.
Definition: pointset.hpp:54