Blender  V2.93
TextStrokeRenderer.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include "TextStrokeRenderer.h"
18 #include "Canvas.h"
19 #include "StrokeIterators.h"
20 
21 namespace Freestyle {
22 
24 {
25  if (!iFileName) {
26  iFileName = "freestyle.txt";
27  }
28  // open the stream:
29  _ofstream.open(iFileName, ios::out);
30  if (!_ofstream.is_open()) {
31  cerr << "couldn't open the output file " << iFileName << endl;
32  }
33  _ofstream << "%!FREESTYLE" << endl;
34  _ofstream << "%Creator: Freestyle (http://artis.imag.fr/Software/Freestyle)" << endl;
35  // Bounding box
36  _ofstream << 0 << " " << 0 << " " << Canvas::getInstance()->width() << " "
37  << Canvas::getInstance()->height() << endl;
38  _ofstream << "%u x y z tleft tright r g b ..." << endl;
39 }
40 
42 {
43  RenderStrokeRepBasic(iStrokeRep);
44 }
45 
47 {
48  Stroke *stroke = iStrokeRep->getStroke();
49  if (!stroke) {
50  cerr << "no stroke associated with Rep" << endl;
51  return;
52  }
53 
55  StrokeAttribute att;
56  while (!v.isEnd()) {
57  att = v->attribute();
58  _ofstream << v->u() << " " << v->getProjectedX() << " " << v->getProjectedY() << " "
59  << v->getProjectedZ() << " " << att.getThicknessL() << " " << att.getThicknessR()
60  << " " << att.getColorR() << " " << att.getColorG() << " " << att.getColorB() << " ";
61  ++v;
62  }
63  _ofstream << endl;
64 }
65 
66 } /* namespace Freestyle */
Class to define a canvas designed to draw style modules.
Iterators used to iterate over the elements of the Stroke.
ATTR_WARN_UNUSED_RESULT const BMVert * v
static Canvas * getInstance()
Definition: Canvas.h:69
virtual int height() const =0
virtual int width() const =0
const float getThicknessR() const
Definition: Stroke.h:154
const float getColorR() const
Definition: Stroke.h:115
const float getColorB() const
Definition: Stroke.h:127
const float getThicknessL() const
Definition: Stroke.h:160
const float getColorG() const
Definition: Stroke.h:121
Stroke * getStroke()
Definition: StrokeRep.h:247
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t=0.0f)
Definition: Stroke.cpp:764
TextStrokeRenderer(const char *iFileName=NULL)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
inherits from class Rep
Definition: AppCanvas.cpp:32