Blender  V3.3
PSStrokeRenderer.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include "PSStrokeRenderer.h"
9 #include "Canvas.h"
10 
11 namespace Freestyle {
12 
13 PSStrokeRenderer::PSStrokeRenderer(const char *iFileName)
14 {
15  if (!iFileName) {
16  iFileName = "freestyle.ps";
17  }
18  // open the stream:
19  _ofstream.open(iFileName, ios::out);
20  if (!_ofstream.is_open()) {
21  cerr << "couldn't open the output file " << iFileName << endl;
22  }
23  _ofstream << "%!PS-Adobe-2.0 EPSF-2.0" << endl;
24  _ofstream << "%%Creator: Freestyle (http://artis.imag.fr/Software/Freestyle)" << endl;
25  _ofstream << "%%BoundingBox: " << 0 << " " << 0 << " " << Canvas::getInstance()->width() << " "
26  << Canvas::getInstance()->height() << endl;
27  _ofstream << "%%EndComments" << endl;
28 }
29 
31 {
32  RenderStrokeRepBasic(iStrokeRep);
33 }
34 
36 {
37  vector<Strip *> &strips = iStrokeRep->getStrips();
38  Strip::vertex_container::iterator v[3];
39  StrokeVertexRep *svRep[3];
40  Vec3r color[3];
41  for (vector<Strip *>::iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
42  Strip::vertex_container &vertices = (*s)->vertices();
43  v[0] = vertices.begin();
44  v[1] = v[0];
45  ++(v[1]);
46  v[2] = v[1];
47  ++(v[2]);
48 
49  while (v[2] != vertices.end()) {
50  svRep[0] = *(v[0]);
51  svRep[1] = *(v[1]);
52  svRep[2] = *(v[2]);
53 
54  color[0] = svRep[0]->color();
55  // color[1] = svRep[1]->color();
56  // color[2] = svRep[2]->color();
57 
58  _ofstream << "newpath" << endl;
59  _ofstream << (color[0])[0] << " " << (color[0])[1] << " " << (color[0])[2] << " setrgbcolor"
60  << endl;
61  _ofstream << svRep[0]->point2d()[0] << " " << svRep[0]->point2d()[1] << " moveto" << endl;
62  _ofstream << svRep[1]->point2d()[0] << " " << svRep[1]->point2d()[1] << " lineto" << endl;
63  _ofstream << svRep[2]->point2d()[0] << " " << svRep[2]->point2d()[1] << " lineto" << endl;
64  _ofstream << "closepath" << endl;
65  _ofstream << "fill" << endl;
66 
67  ++v[0];
68  ++v[1];
69  ++v[2];
70  }
71  }
72 }
73 
74 } /* namespace Freestyle */
Class to define a canvas designed to draw style modules.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
Class to define the Postscript rendering of a stroke.
ATTR_WARN_UNUSED_RESULT const BMVert * v
static Canvas * getInstance()
Definition: Canvas.h:55
virtual int height() const =0
virtual int width() const =0
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
PSStrokeRenderer(const char *iFileName=NULL)
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
std::vector< StrokeVertexRep * > vertex_container
Definition: StrokeRep.h:125
vector< Strip * > & getStrips()
Definition: StrokeRep.h:223
inherits from class Rep
Definition: AppCanvas.cpp:18
static const pxr::TfToken out("out", pxr::TfToken::Immortal)