Go to the documentation of this file.
25 #include "libmesh/postscript_io.h"
26 #include "libmesh/mesh_tools.h"
27 #include "libmesh/elem.h"
28 #include "libmesh/int_range.h"
37 {-1.f/6.f, 1.f/6.f, 1.},
38 {-1.f/6.f, 0.5, 1.f/6.f},
50 _current_point(0., 0.)
53 libmesh_experimental();
78 if (this->
mesh().processor_id() == 0)
88 _out.open(fname.c_str());
92 libmesh_file_error(fname.c_str());
100 const Real percent_padding = 0.01;
101 const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0);
102 const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0);
104 const Real x_min = bbox.first(0) - percent_padding*dx;
105 const Real y_min = bbox.first(1) - percent_padding*dy;
106 const Real x_max = bbox.second(0) + percent_padding*dx;
107 const Real y_max = bbox.second(1) + percent_padding*dy;
112 const Real width = 300;
113 _scale = width / (x_max-x_min);
118 std::time_t time1= std::time (0);
119 std::tm * time = std::localtime(&time1);
120 _out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
122 <<
"%%Filename: " << fname <<
'\n'
123 <<
"%%Title: LibMesh Output" <<
'\n'
124 <<
"%%Creator: LibMesh: A C++ finite element library" <<
'\n'
125 <<
"%%Creation Date: "
126 << time->tm_year+1900 <<
"/"
127 << time->tm_mon+1 <<
"/"
128 << time->tm_mday <<
" - "
129 << time->tm_hour <<
":"
130 << std::setw(2) << time->tm_min <<
":"
131 << std::setw(2) << time->tm_sec <<
'\n'
136 << static_cast<unsigned int>( rint(
double((x_max-x_min) *
_scale )))
138 << static_cast<unsigned int>( rint(
double((y_max-y_min) *
_scale )))
149 _out <<
"/m {moveto} bind def" <<
'\n'
150 <<
"/l {lineto} bind def" <<
'\n'
151 <<
"/s {setrgbcolor} bind def" <<
'\n'
152 <<
"/sg {setgray} bind def" <<
'\n'
153 <<
"/cs {curveto stroke} bind def" <<
'\n'
154 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
155 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
157 _out <<
"%%EndProlog" <<
'\n';
164 _out <<
"1 setlinecap" <<
'\n';
165 _out <<
"1 setlinejoin" <<
'\n';
170 _out << std::setprecision (5);
181 _out <<
"showpage" << std::endl;
211 for (
unsigned int v=1; v<nv-1; ++v)
242 libmesh_assert_equal_to ( side->type(),
EDGE3 );
268 libmesh_assert_equal_to (elem->
type(),
EDGE3);
272 float phys_coords[3] = {0., 0., 0.};
273 float bez_coords[3] = {0., 0., 0.};
275 for (
unsigned int i=0; i<2; ++i)
279 for (
unsigned int j=0; j<3; ++j)
281 phys_coords[j] = static_cast<float>
287 for (
unsigned int j=0; j<3; ++j)
288 for (
unsigned int k=0; k<3; ++k)
292 for (
unsigned int j=0; j<3; ++j)
virtual ~PostscriptIO()
Destructor.
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy=true)=0
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file.
Defines a Cartesian bounding box by the two corner extremum.
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
The libMesh namespace provides an interface to certain functionality in the library.
void plot_linear_elem(const Elem *elem)
Draws an element with straight lines.
unsigned int mesh_dimension() const
PostscriptIO(const MeshBase &mesh)
Constructor.
const Point & point(const unsigned int i) const
Real shade_value
Controls greyscale shading of cells.
This is the MeshBase class.
void plot_quadratic_elem(const Elem *elem)
Draws an element with Bezier curves.
Temporarily serialize a DistributedMesh for output; a distributed mesh is allgathered by the MeshSeri...
Point _offset
Amount to add to every (x,y) point to place it in Postscript coordinates.
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
void _compute_edge_bezier_coeffs(const Elem *elem)
Given a quadratic edge Elem which lies in the x-y plane, computes the Bezier coefficients.
virtual unsigned int n_vertices() const =0
Point _current_point
A point object used for temporary calculations.
static const float _bezier_transform[3][3]
Coefficients of the transformation from physical-space edge coordinates to Bezier basis coefficients.
std::vector< Point > _bezier_coeffs
Vector containing 3 points corresponding to Bezier coefficients, as computed by _compute_edge_bezier_...
This class defines an abstract interface for Mesh output.
const MeshBase & mesh() const
IntRange< unsigned short > side_index_range() const
Real _scale
Amount by which to stretch each point to place it in Postscript coordinates.
This is the base class from which all geometric element types are derived.
Real line_width
Control the thickness of the lines used.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::ofstream _out
Output file stream which will be opened when the file name is known.
virtual ElemType type() const =0
std::ostringstream _cell_string
Drawing style-independent data for a single cell.