Geom Software - C++ Programming and Geometry Libraries
Fade2D Documentation pages v1.58
Visualizer2.h
1 // Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
2 //
3 // This file is part of the Fade2D library. The student license is free
4 // of charge and covers personal non-commercial research. Licensees
5 // holding a commercial license may use this file in accordance with
6 // the Commercial License Agreement.
7 //
8 // This software is provided AS IS with NO WARRANTY OF ANY KIND,
9 // INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
10 // FOR A PARTICULAR PURPOSE.
11 //
12 // Please contact the author if any conditions of this licensing are
13 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
19 #pragma once
20 
21 
22 #include "Point2.h"
23 #include "Circle2.h"
24 #include "Segment2.h"
25 #include "Color.h"
26 #include "Label.h"
27 #include "Bbox2.h"
28 #include "Edge2.h"
29 
30 
31 #include "common.h"
32 #if GEOM_PSEUDO3D==GEOM_TRUE
33  namespace GEOM_FADE25D {
34 #elif GEOM_PSEUDO3D==GEOM_FALSE
35  namespace GEOM_FADE2D {
36 #else
37  #error GEOM_PSEUDO3D is not defined
38 #endif
39 
40 
52 {
53 public:
54 
55 
60  CLASS_DECLSPEC
61  explicit Visualizer2(const std::string& filename_);
62 
63  CLASS_DECLSPEC
64  ~Visualizer2();
65 
66 
69  CLASS_DECLSPEC
70  void addObject(const Segment2& seg,const Color& c);
71 
74  CLASS_DECLSPEC
75  void addObject(const Edge2& edge,const Color& c);
76 
79  CLASS_DECLSPEC
80  void addObject(const std::vector<Point2>& vPoints,const Color& c);
81 
84  CLASS_DECLSPEC
85  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
86 
87 
90  CLASS_DECLSPEC
91  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
92 
95  CLASS_DECLSPEC
96  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
97 
98 
101  CLASS_DECLSPEC
102  void addObject(const std::vector<Triangle2>& vT,const Color& c);
103 
106  CLASS_DECLSPEC
107  void addObject(const Circle2& circ,const Color& c);
110  CLASS_DECLSPEC
111  void addObject(const Point2& pnt,const Color& c);
114  CLASS_DECLSPEC
115  void addObject(const Triangle2& tri,const Color& c);
116 
119  CLASS_DECLSPEC
120  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
121 
124  CLASS_DECLSPEC
125  void addObject(const Label& lab,const Color& c);
126 
129  CLASS_DECLSPEC
130  void addHeaderLine(const std::string& s);
131 
132 
137  CLASS_DECLSPEC
138  void writeFile();
139 
140 protected:
141  std::ofstream outFile;
142  std::vector<std::pair<Segment2,Color> > vSegments;
143  std::vector<std::pair<Circle2,Color> > vCircles;
144  std::vector<std::pair<Point2,Color> > vPoints;
145  std::vector<std::pair<Triangle2,Color> > vTriangles;
146  std::vector<std::pair<Label,Color> > vLabels;
147  void writeHeaderLines();
148 
149  int updateCtr;
150  Bbox2 bbox;
151  bool bFill;
152 
153  Point2 scaledPoint(const Point2 &p);
154  double scaledDouble(const double &d);
155  void changeColor(float r,float g,float b,float linewidth,bool bFill);
156  void changeColor(const Color& c);
157  void writeHeader(const std::string& title);
158  void writeFooter();
159  void writeLabel(Label l);
160  void writeLine(const Point2& pSource,const Point2& pTarget);
161  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
162  void writePoint(Point2& p1_,float size);
163  void writeCircle(const Point2& p1_,double radius,bool bFill);
164  void periodicStroke();
165  void setRange();
166  Color lastColor;
167  std::string filename;
168  std::vector<std::string> vHeaderLines;
169  bool bFileClosed;
170 };
171 
172 
173 } // (namespace)
Point.
Definition: Point2.h:39
Circle.
Definition: Circle2.h:36
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2, Triangle2, Circle2 and Label.
Definition: Visualizer2.h:51
Color.
Definition: Color.h:58
Segment.
Definition: Segment2.h:38
Text-Label.
Definition: Label.h:36
Directed Edge.
Definition: Edge2.h:33
Bbox2 is an axis aligned bounding box.
Definition: Bbox2.h:36
Triangle.
Definition: Triangle2.h:48
Definition: Bbox2.h:25