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();
76 if (this->
mesh().processor_id() == 0)
86 _out.open(fname.c_str());
90 libmesh_file_error(fname.c_str());
98 const Real percent_padding = 0.01;
99 const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0);
100 const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0);
102 const Real x_min = bbox.first(0) - percent_padding*dx;
103 const Real y_min = bbox.first(1) - percent_padding*dy;
104 const Real x_max = bbox.second(0) + percent_padding*dx;
105 const Real y_max = bbox.second(1) + percent_padding*dy;
110 const Real width = 300;
111 _scale = width / (x_max-x_min);
116 std::time_t time1= std::time (0);
117 std::tm * time = std::localtime(&time1);
118 _out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n' 120 <<
"%%Filename: " << fname <<
'\n' 121 <<
"%%Title: LibMesh Output" <<
'\n' 122 <<
"%%Creator: LibMesh: A C++ finite element library" <<
'\n' 123 <<
"%%Creation Date: " 124 << time->tm_year+1900 <<
"/" 125 << time->tm_mon+1 <<
"/" 126 << time->tm_mday <<
" - " 127 << time->tm_hour <<
":" 128 << std::setw(2) << time->tm_min <<
":" 129 << std::setw(2) << time->tm_sec <<
'\n' 134 <<
static_cast<unsigned int>( rint(
double((x_max-x_min) *
_scale )))
136 << static_cast<unsigned int>( rint(
double((y_max-y_min) *
_scale )))
147 _out <<
"/m {moveto} bind def" <<
'\n' 148 <<
"/l {lineto} bind def" <<
'\n' 149 <<
"/s {setrgbcolor} bind def" <<
'\n' 150 <<
"/sg {setgray} bind def" <<
'\n' 151 <<
"/cs {curveto stroke} bind def" <<
'\n' 152 <<
"/lx {lineto closepath stroke} bind def" <<
'\n' 153 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
155 _out <<
"%%EndProlog" <<
'\n';
162 _out <<
"1 setlinecap" <<
'\n';
163 _out <<
"1 setlinejoin" <<
'\n';
168 _out << std::setprecision (5);
175 for (
const auto & elem : the_mesh.active_element_ptr_range())
179 _out <<
"showpage" << std::endl;
209 for (
unsigned int v=1; v<nv-1; ++v)
240 libmesh_assert_equal_to ( side->type(),
EDGE3 );
266 libmesh_assert_equal_to (elem->
type(),
EDGE3);
270 float phys_coords[3] = {0., 0., 0.};
271 float bez_coords[3] = {0., 0., 0.};
273 for (
unsigned int i=0; i<2; ++i)
277 for (
unsigned int j=0; j<3; ++j)
279 phys_coords[j] =
static_cast<float> 285 for (
unsigned int j=0; j<3; ++j)
286 for (
unsigned int k=0; k<3; ++k)
290 for (
unsigned int j=0; j<3; ++j)
const MeshBase & mesh() const
void plot_linear_elem(const Elem *elem)
Draws an element with straight lines.
virtual ~PostscriptIO()
Destructor.
std::ofstream _out
Output file stream which will be opened when the file name is known.
Point _offset
Amount to add to every (x,y) point to place it in Postscript coordinates.
IntRange< unsigned short > side_index_range() const
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
void _compute_edge_bezier_coeffs(const Elem *elem)
Given a quadratic edge Elem which lies in the x-y plane, computes the Bezier coefficients.
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
This is the base class from which all geometric element types are derived.
This class defines an abstract interface for Mesh output.
The libMesh namespace provides an interface to certain functionality in the library.
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...
This is the MeshBase class.
Real shade_value
Controls greyscale shading of cells.
PostscriptIO(const MeshBase &mesh)
Constructor.
Real line_width
Control the thickness of the lines used.
Real _scale
Amount by which to stretch each point to place it in Postscript coordinates.
std::vector< Point > _bezier_coeffs
Vector containing 3 points corresponding to Bezier coefficients, as computed by _compute_edge_bezier_...
std::ostringstream _cell_string
Drawing style-independent data for a single cell.
Defines a Cartesian bounding box by the two corner extremum.
virtual unsigned int n_vertices() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file.
void plot_quadratic_elem(const Elem *elem)
Draws an element with Bezier curves.
unsigned int mesh_dimension() const
virtual ElemType type() const =0
const Point & point(const unsigned int i) const
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...