Geom Software - C++ Programming and Geometry Libraries
Fade2.5D Documentation pages v1.74
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 class ConstraintSegment2; // FWD
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<ConstraintSegment2*>& vConstraintSegments,const Color& c);
97 
100  CLASS_DECLSPEC
101  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
102 
103 
106  CLASS_DECLSPEC
107  void addObject(const std::vector<Triangle2>& vT,const Color& c);
108 
111  CLASS_DECLSPEC
112  void addObject(const Circle2& circ,const Color& c);
115  CLASS_DECLSPEC
116  void addObject(const Point2& pnt,const Color& c);
119  CLASS_DECLSPEC
120  void addObject(const Triangle2& tri,const Color& c);
121 
124  CLASS_DECLSPEC
125  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
126 
129  CLASS_DECLSPEC
130  void addObject(const Label& lab,const Color& c);
131 
134  CLASS_DECLSPEC
135  void addHeaderLine(const std::string& s);
136 
137 
142  CLASS_DECLSPEC
143  void writeFile();
144 
145 protected:
146  std::ofstream outFile;
147  std::vector<std::pair<Segment2,Color> > vSegments;
148  std::vector<std::pair<Circle2,Color> > vCircles;
149  std::vector<std::pair<Point2,Color> > vPoints;
150  std::vector<std::pair<Triangle2,Color> > vTriangles;
151  std::vector<std::pair<Label,Color> > vLabels;
152  void writeHeaderLines();
153 
154  int updateCtr;
155  Bbox2 bbox;
156  bool bFill;
157 
158  Point2 scaledPoint(const Point2 &p);
159  double scaledDouble(const double &d);
160  void changeColor(float r,float g,float b,float linewidth,bool bFill);
161  void changeColor(const Color& c);
162  void writeHeader(const std::string& title);
163  void writeFooter();
164  void writeLabel(Label l);
165  void writeLine(const Point2& pSource,const Point2& pTarget);
166  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
167  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
168  void writePoint(Point2& p1_,float size);
169  void writeCircle(const Point2& p1_,double radius,bool bFill);
170  void periodicStroke();
171  void setRange();
172  Color lastColor;
173  std::string filename;
174  std::vector<std::string> vHeaderLines;
175  bool bFileClosed;
176 };
177 
178 
179 } // (namespace)
Color.
Definition: Color.h:58
Bbox2 is an axis aligned bounding box.
Definition: Bbox2.h:36
Triangle.
Definition: Triangle2.h:48
Circle.
Definition: Circle2.h:36
Segment.
Definition: Segment2.h:38
Definition: Bbox2.h:23
Text-Label.
Definition: Label.h:36
Directed Edge.
Definition: Edge2.h:33
Point.
Definition: Point2.h:39
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2, Triangle2, Circle2 and Label.
Definition: Visualizer2.h:51