Blender
V2.93
source
blender
freestyle
intern
stroke
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
23
TextStrokeRenderer::TextStrokeRenderer
(
const
char
*iFileName)
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
41
void
TextStrokeRenderer::RenderStrokeRep
(
StrokeRep
*iStrokeRep)
const
42
{
43
RenderStrokeRepBasic
(iStrokeRep);
44
}
45
46
void
TextStrokeRenderer::RenderStrokeRepBasic
(
StrokeRep
*iStrokeRep)
const
47
{
48
Stroke
*stroke = iStrokeRep->
getStroke
();
49
if
(!stroke) {
50
cerr <<
"no stroke associated with Rep"
<< endl;
51
return
;
52
}
53
54
StrokeInternal::StrokeVertexIterator
v
= stroke->
strokeVerticesBegin
();
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 */
Canvas.h
Class to define a canvas designed to draw style modules.
StrokeIterators.h
Iterators used to iterate over the elements of the Stroke.
TextStrokeRenderer.h
v
ATTR_WARN_UNUSED_RESULT const BMVert * v
Definition:
bmesh_query_inline.h:29
Freestyle::Canvas::getInstance
static Canvas * getInstance()
Definition:
Canvas.h:69
Freestyle::Canvas::height
virtual int height() const =0
Freestyle::Canvas::width
virtual int width() const =0
Freestyle::StrokeAttribute
Definition:
Stroke.h:58
Freestyle::StrokeAttribute::getThicknessR
const float getThicknessR() const
Definition:
Stroke.h:154
Freestyle::StrokeAttribute::getColorR
const float getColorR() const
Definition:
Stroke.h:115
Freestyle::StrokeAttribute::getColorB
const float getColorB() const
Definition:
Stroke.h:127
Freestyle::StrokeAttribute::getThicknessL
const float getThicknessL() const
Definition:
Stroke.h:160
Freestyle::StrokeAttribute::getColorG
const float getColorG() const
Definition:
Stroke.h:121
Freestyle::StrokeInternal::StrokeVertexIterator
Definition:
StrokeIterators.h:47
Freestyle::StrokeRep
Definition:
StrokeRep.h:180
Freestyle::StrokeRep::getStroke
Stroke * getStroke()
Definition:
StrokeRep.h:247
Freestyle::Stroke
Definition:
Stroke.h:501
Freestyle::Stroke::strokeVerticesBegin
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t=0.0f)
Definition:
Stroke.cpp:764
Freestyle::TextStrokeRenderer::TextStrokeRenderer
TextStrokeRenderer(const char *iFileName=NULL)
Definition:
TextStrokeRenderer.cpp:23
Freestyle::TextStrokeRenderer::_ofstream
ofstream _ofstream
Definition:
TextStrokeRenderer.h:62
Freestyle::TextStrokeRenderer::RenderStrokeRep
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
Definition:
TextStrokeRenderer.cpp:41
Freestyle::TextStrokeRenderer::RenderStrokeRepBasic
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
Definition:
TextStrokeRenderer.cpp:46
Freestyle
inherits from class Rep
Definition:
AppCanvas.cpp:32
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1