Fade2D Documentation pages v1.86
Delaunay Features
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 struct Dat; // FWD
41 
42 
43 
55 {
56 public:
57 
58 
63  CLASS_DECLSPEC
64  explicit Visualizer2(const char* filename_);
65 
66  CLASS_DECLSPEC
67  ~Visualizer2();
68 
69 
72  CLASS_DECLSPEC
73  void addObject(const Segment2& seg,const Color& c);
74 
77  CLASS_DECLSPEC
78  void addObject(const Edge2& edge,const Color& c);
79 
82  CLASS_DECLSPEC
83  void addObject(const std::vector<Point2>& vPoints,const Color& c);
84 
87  CLASS_DECLSPEC
88  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
89 
90 
93  CLASS_DECLSPEC
94  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
95 
98  CLASS_DECLSPEC
99  void addObject(const std::vector<ConstraintSegment2*>& vConstraintSegments,const Color& c);
100 
103  CLASS_DECLSPEC
104  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
105 
106 
109  CLASS_DECLSPEC
110  void addObject(const std::vector<Triangle2>& vT,const Color& c);
111 
114  CLASS_DECLSPEC
115  void addObject(const Circle2& circ,const Color& c);
118  CLASS_DECLSPEC
119  void addObject(const Point2& pnt,const Color& c);
122  CLASS_DECLSPEC
123  void addObject(const Triangle2& tri,const Color& c);
124 
127  CLASS_DECLSPEC
128  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
129 
132  CLASS_DECLSPEC
133  void addObject(const Label& lab,const Color& c);
134 
137  CLASS_DECLSPEC
138  void addHeaderLine(const char* s);
139 
140 
145  CLASS_DECLSPEC
146  void writeFile();
147 
148 protected:
149  Dat* pDat;
150  std::ofstream outFile;
151  std::vector<std::pair<Segment2,Color> > vSegments;
152  std::vector<std::pair<Circle2,Color> > vCircles;
153  std::vector<std::pair<Point2,Color> > vPoints;
154  std::vector<std::pair<Triangle2,Color> > vTriangles;
155  std::vector<std::pair<Label,Color> > vLabels;
156  void writeHeaderLines();
157 
158  int updateCtr;
159  Bbox2 bbox;
160  bool bFill;
161 
162  Point2 scaledPoint(const Point2 &p);
163  double scaledDouble(const double &d);
164  void changeColor(float r,float g,float b,float linewidth,bool bFill);
165  void changeColor(const Color& c);
166  void writeHeader(const char* title);
167  void writeFooter();
168  void writeLabel(Label l);
169  void writeLine(const Point2& pSource,const Point2& pTarget);
170  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
171  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
172  void writePoint(Point2& p1_,float size);
173  void writeCircle(const Point2& p1_,double radius,bool bFill);
174  void periodicStroke();
175  void setRange();
176  Color lastColor;
177  //const char* filename;
178  //std::vector<const char*> vHeaderLines;
179  bool bFileClosed;
180 };
181 
182 
183 } // (namespace)
GEOM_FADE2D::Triangle2
Triangle.
Definition: Triangle2.h:48
GEOM_FADE2D::Point2
Point.
Definition: Point2.h:40
GEOM_FADE2D::Visualizer2
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2,...
Definition: Visualizer2.h:54
GEOM_FADE2D::Circle2
Circle for visualization.
Definition: Circle2.h:37
GEOM_FADE2D::Color
Color for visualization.
Definition: Color.h:58
Bbox2.h
Color.h
GEOM_FADE2D::Label
Label is a Text-Label for Visualization.
Definition: Label.h:39
GEOM_FADE2D::Edge2
Edge2 is a directed edge.
Definition: Edge2.h:33
GEOM_FADE2D::Segment2
Segment.
Definition: Segment2.h:38
GEOM_FADE2D::Bbox2
Bbox2 is an axis aligned 2D bounding box.
Definition: Bbox2.h:36