Fade2.5D Documentation pages v2.12
Delaunay Features
Visualizer2.h
Go to the documentation of this file.
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 
19 #pragma once
20 
21 
22 #include "Point2.h"
23 #include "Circle2.h"
24 #include "PShape.h"
25 #include "Segment2.h"
26 #include "Color.h"
27 #include "Label.h"
28 #include "Bbox2.h"
29 #include "Edge2.h"
30 
31 
32 #include "common.h"
33 #if GEOM_PSEUDO3D==GEOM_TRUE
34  namespace GEOM_FADE25D {
35 #elif GEOM_PSEUDO3D==GEOM_FALSE
36  namespace GEOM_FADE2D {
37 #else
38  #error GEOM_PSEUDO3D is not defined
39 #endif
40 class ConstraintSegment2; // FWD
41 class VoroCell2; // FWD
42 struct Dat; // FWD
43 class SegmentChecker; // FWD
44 
45 
57 {
58 public:
59 
60 
65  CLASS_DECLSPEC
66  explicit Visualizer2(const char* filename_);
67 
68  CLASS_DECLSPEC
69  ~Visualizer2();
72  CLASS_DECLSPEC
73  void addObject(const std::vector<VoroCell2*>& vT,const Color& c);
74 
77  CLASS_DECLSPEC
78  void addObject(const std::vector<PShape>& vPolygonalShapes,const Color& c);
79 
82  CLASS_DECLSPEC
83  void addObject(const PShape& polygonalShape,const Color& c);
84 
87  CLASS_DECLSPEC
88  void addObject(VoroCell2* pVoroCell,const Color& c);
89 
92  CLASS_DECLSPEC
93  void addObject(const Segment2& seg,const Color& c);
94 
97  CLASS_DECLSPEC
98  void addObject(const Edge2& edge,const Color& c);
99 
102  CLASS_DECLSPEC
103  void addObject(const std::vector<Point2>& vPoints,const Color& c);
104 
107  CLASS_DECLSPEC
108  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
109 
110 
113  CLASS_DECLSPEC
114  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
115 
118  CLASS_DECLSPEC
119  void addObject(const std::vector<ConstraintSegment2*>& vConstraintSegments,const Color& c);
120 
123  CLASS_DECLSPEC
124  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
125 
126 
129  CLASS_DECLSPEC
130  void addObject(const std::vector<Triangle2>& vT,const Color& c);
131 
134  CLASS_DECLSPEC
135  void addObject(const Circle2& circ,const Color& c);
138  CLASS_DECLSPEC
139  void addObject(const Point2& pnt,const Color& c);
142  CLASS_DECLSPEC
143  void addObject(const Triangle2& tri,const Color& c);
144 
147  CLASS_DECLSPEC
148  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
149 
152  CLASS_DECLSPEC
153  void addObject(const Label& lab,const Color& c);
154 
157  CLASS_DECLSPEC
158  void addHeaderLine(const char* s);
159 
160 
165  CLASS_DECLSPEC
166  void writeFile();
167 
170  CLASS_DECLSPEC
171  void setLimit(const Bbox2& bbx);
172 
180  Bbox2 computeRange(bool bWithVoronoi);
181 protected:
182  Visualizer2(const Visualizer2& );
183  Visualizer2& operator=(const Visualizer2&);
184 
185  Dat* pDat;
186  std::ofstream outFile;
187  std::vector<std::pair<Segment2,Color> > vSegments;
188  std::vector<std::pair<Circle2,Color> > vCircles;
189  std::vector<std::pair<Point2,Color> > vPoints;
190  std::vector<std::pair<Triangle2,Color> > vTriangles;
191  std::vector<std::pair<Label,Color> > vLabels;
192  std::vector<std::pair<VoroCell2*,Color> > vVoroCells;
193  std::vector<std::pair<PShape,Color> > vPolygons;
194  void writeHeaderLines();
195  int updateCtr;
196  Bbox2 bbox;
197  bool bFill;
198  Point2 scaledPoint(const Point2 &p);
199  double scaledDouble(const double &d);
200  void changeColor(float r,float g,float b,float linewidth,bool bFill);
201  void changeColor(const Color& c);
202  void writeHeader(const char* title);
203  void writeFooter();
204  void writeLabel(Label l);
205  void writeLine(const Point2& pSource,const Point2& pTarget);
206  void writePolygon(PShape& pshape,bool bFill,double width);
207  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
208  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
209  void writeVoroCell(VoroCell2* pVoroCell,bool bFill,double width);
210  void writePoint(const Point2& p1_,float size);
211  void writeMark(const Point2& p1_,float size);
212  void writeCircle(const Point2& p1_,double radius,bool bFill);
213  void periodicStroke();
214 
215  Color lastColor;
216  //const char* filename;
217  //std::vector<const char*> vHeaderLines;
218  bool bFileClosed;
219 };
220 
221 
222 } // (namespace)
Bbox2 is an axis aligned 2D bounding box.
Definition: Bbox2.h:37
Circle for visualization.
Definition: Circle2.h:38
Color for visualization.
Definition: Color.h:59
Edge2 is a directed edge.
Definition: Edge2.h:34
Label is a Text-Label for Visualization.
Definition: Label.h:41
Polygonal Shape for Visualization.
Definition: PShape.h:37
Point.
Definition: Point2.h:52
Segment.
Definition: Segment2.h:39
Triangle.
Definition: Triangle2.h:60
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2,...
Definition: Visualizer2.h:57
void addObject(const std::vector< Point2 > &vPoints, const Color &c)
Add a vector of Point2 objects to the visualization.
void addHeaderLine(const char *s)
Add a header line to the visualization.
void writeFile()
Finish and write the postscript file.
void addObject(VoroCell2 *pVoroCell, const Color &c)
Add a Voronoi cell to the visualization.
Visualizer2(const char *filename_)
Constructor.
void addObject(const std::vector< Triangle2 > &vT, const Color &c)
Add a vector of Triangle2 objects to the visualization.
void addObject(const std::vector< ConstraintSegment2 * > &vConstraintSegments, const Color &c)
Add a vector of ConstraintSegment2 objects to the visualization.
void addObject(const Circle2 &circ, const Color &c)
Add a Circle2 object to the visualization.
void addObject(const Segment2 &seg, const Color &c)
Add a Segment2 object to the visualization.
void addObject(const std::vector< Point2 * > &vPoints, const Color &c)
Add a vector of Point2* to the visualization.
void addObject(const std::vector< PShape > &vPolygonalShapes, const Color &c)
Add polygonal shapes.
void addObject(const Edge2 &edge, const Color &c)
Add an Edge2 object to the visualization.
void addObject(const std::vector< Edge2 > &vSegments, const Color &c)
Add a vector of Edge2 objects to the visualization.
Bbox2 computeRange(bool bWithVoronoi)
Compute the range.
void addObject(const std::vector< Segment2 > &vSegments, const Color &c)
Add a vector of Segment2 objects to the visualization.
void addObject(const Label &lab, const Color &c)
Add a Label object to the visualization.
void addObject(const std::vector< VoroCell2 * > &vT, const Color &c)
Add a vector of Voronoi Cells to the visualization.
void addObject(const std::vector< Triangle2 * > &vT, const Color &c)
Add a Triangle2* vector to the visualization.
void addObject(const PShape &polygonalShape, const Color &c)
Add a polygonal shape.
void addObject(const Point2 &pnt, const Color &c)
Add a Point2 object to the visualization.
void addObject(const Triangle2 &tri, const Color &c)
Add a Triangle2 object to the visualization.