~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
//
 
3
//  Copyright (C) : Please refer to the COPYRIGHT file distributed 
 
4
//   with this source distribution. 
 
5
//
 
6
//  This program is free software; you can redistribute it and/or
 
7
//  modify it under the terms of the GNU General Public License
 
8
//  as published by the Free Software Foundation; either version 2
 
9
//  of the License, or (at your option) any later version.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
//
 
20
///////////////////////////////////////////////////////////////////////////////
 
21
 
 
22
# include "TextStrokeRenderer.h"
 
23
# include "Canvas.h"
 
24
# include "StrokeIterators.h"
 
25
 
 
26
namespace Freestyle {
 
27
 
 
28
TextStrokeRenderer::TextStrokeRenderer(const char *iFileName)
 
29
:StrokeRenderer()
 
30
{
 
31
        if (!iFileName)
 
32
                iFileName = "freestyle.txt";
 
33
        // open the stream:
 
34
        _ofstream.open(iFileName, ios::out);
 
35
        if (!_ofstream.is_open()) {
 
36
                cerr << "couldn't open the output file " << iFileName << endl;
 
37
        }
 
38
        _ofstream << "%!FREESTYLE" << endl;
 
39
        _ofstream << "%Creator: Freestyle (http://artis.imag.fr/Software/Freestyle)" << endl;
 
40
        // Bounding box
 
41
        _ofstream << 0 << " "<< 0 << " " << Canvas::getInstance()->width() << " " << Canvas::getInstance()->height() <<
 
42
                     endl;
 
43
        _ofstream << "%u x y z tleft tright r g b ..." << endl;
 
44
}
 
45
 
 
46
TextStrokeRenderer::~TextStrokeRenderer()
 
47
{
 
48
        Close();
 
49
}
 
50
 
 
51
void TextStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
 
52
{
 
53
        RenderStrokeRepBasic(iStrokeRep);
 
54
}
 
55
 
 
56
void TextStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
 
57
{
 
58
        Stroke *stroke = iStrokeRep->getStroke();
 
59
        if (!stroke) {
 
60
                cerr << "no stroke associated with Rep" << endl;
 
61
                return;
 
62
        }
 
63
 
 
64
        StrokeInternal::StrokeVertexIterator v = stroke->strokeVerticesBegin();
 
65
        StrokeAttribute att;
 
66
        while (!v.isEnd()) {
 
67
                att = v->attribute();
 
68
                _ofstream << v->u() << " " << v->getProjectedX() << " " << v->getProjectedY() << " " << v->getProjectedZ() <<
 
69
                             " " << att.getThicknessL() << " " << att.getThicknessR() << " " <<
 
70
                             att.getColorR() << " " << att.getColorG() << " " << att.getColorB() << " ";
 
71
                ++v;
 
72
        }
 
73
        _ofstream << endl;
 
74
}
 
75
 
 
76
void TextStrokeRenderer::Close()
 
77
{
 
78
        if (_ofstream.is_open())
 
79
                _ofstream.close();
 
80
}
 
81
 
 
82
} /* namespace Freestyle */