Fade2.5D Documentation pages v2.14
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 #include "Point2.h"
21 #include "Circle2.h"
22 #include "PShape.h"
23 #include "Segment2.h"
24 #include "Color.h"
25 #include "Label.h"
26 #include "Bbox2.h"
27 #include "Edge2.h"
28 
29 
30 #include "common.h"
31 #if GEOM_PSEUDO3D==GEOM_TRUE
32  namespace GEOM_FADE25D {
33 #elif GEOM_PSEUDO3D==GEOM_FALSE
34  namespace GEOM_FADE2D {
35 #else
36  #error GEOM_PSEUDO3D is not defined
37 #endif
38 class ConstraintSegment2; // FWD
39 class ConstraintGraph2; // FWD
40 class VoroCell2; // FWD
41 struct Dat; // FWD
42 class SegmentChecker; // FWD
43 
54 {
55 public:
60  CLASS_DECLSPEC
61  explicit Visualizer2(const char* filename_);
62 
63  CLASS_DECLSPEC
64  ~Visualizer2();
70  CLASS_DECLSPEC
71  void addObject(const std::vector<VoroCell2*>& vC,const Color& c);
72 
78  CLASS_DECLSPEC
79  void addObject(const std::vector<PShape>& vPolygonalShapes,const Color& c);
80 
86  CLASS_DECLSPEC
87  void addObject(const PShape& polygonalShape,const Color& c);
88 
94  CLASS_DECLSPEC
95  void addObject(VoroCell2* pVoroCell,const Color& c);
96 
103  CLASS_DECLSPEC
104  void addObject(const Segment2& seg,const Color& c);
105 
112  CLASS_DECLSPEC
113  void addObject(ConstraintGraph2* pCG,const Color& c);
114 
115 
121  CLASS_DECLSPEC
122  void addObject(const Edge2& edge,const Color& c);
123 
129  CLASS_DECLSPEC
130  void addObject(const std::vector<Point2>& vPoints,const Color& c);
131 
137  CLASS_DECLSPEC
138  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
139 
140 
146  CLASS_DECLSPEC
147  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
148 
156  CLASS_DECLSPEC
157  void addObject(const std::vector<ConstraintSegment2*>& vConstraintSegments,const Color& c);
158 
164  CLASS_DECLSPEC
165  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
166 
167 
173  CLASS_DECLSPEC
174  void addObject(const std::vector<Triangle2>& vT,const Color& c);
175 
181  CLASS_DECLSPEC
182  void addObject(const Circle2& circ,const Color& c);
183  CLASS_DECLSPEC
189  void addObject(const Point2& pnt,const Color& c);
190 
196  CLASS_DECLSPEC
197  void addObject(const Triangle2& tri,const Color& c);
198 
204  CLASS_DECLSPEC
205  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
206 
212  CLASS_DECLSPEC
213  void addObject(const Label& lab,const Color& c);
214 
219  CLASS_DECLSPEC
220  void addHeaderLine(const char* s);
221 
222 
227  CLASS_DECLSPEC
228  void writeFile();
229 
230 
233  CLASS_DECLSPEC
234  void setLimit(const Bbox2& bbx);
235 
243  Bbox2 computeRange(bool bWithVoronoi);
244 protected:
245  Visualizer2(const Visualizer2& );
246  Visualizer2& operator=(const Visualizer2&);
247  // Helpers
248  Point2 scaledPoint(const Point2 &p);
249  double scaledDouble(const double &d);
250  void changeColor(float r,float g,float b,float linewidth,bool bFill);
251  void changeColor(const Color& c);
252  // Write Header/Footer
253  void writeHeader(const char* title);
254  void writeFooter();
255  void writeHeaderLines();
256  // Write Objects
257  void writeLabel(Label l);
258  void writeLine(const Point2& pSource,const Point2& pTarget);
259  void writePolygon(PShape& pshape,bool bFill,double width);
260  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
261  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
262  void writeVoroCell(VoroCell2* pVoroCell,bool bFill,double width);
263  void writePoint(const Point2& p1_,float size);
264  void writeMark(const Point2& p1_,float size);
265  void writeCircle(const Point2& p1_,double radius,bool bFill);
266  void periodicStroke();
267 
268  // DATA
269  bool bTypePS;
270  Dat* pDat;
271  int updateCtr;
272  bool bFill;
273  Color lastColor;
274  bool bFileClosed;
275  Bbox2 bbox;
276  std::ofstream outFile;
277  std::vector<std::pair<Segment2,Color> > vSegments;
278  std::vector<std::pair<Circle2,Color> > vCircles;
279  std::vector<std::pair<Point2,Color> > vPoints;
280  std::vector<std::pair<Triangle2,Color> > vTriangles;
281  std::vector<std::pair<Label,Color> > vLabels;
282  std::vector<std::pair<VoroCell2*,Color> > vVoroCells;
283  std::vector<std::pair<PShape,Color> > vPolygons;
284 };
285 
286 
287 } // (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
ConstraintGraph2 is a set of Constraint Edges (ConstraintSegment2)
Definition: ConstraintGraph2.h:52
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:53
Segment.
Definition: Segment2.h:39
Triangle.
Definition: Triangle2.h:60
Visualizer2 is a PDF- and Postscript writer.
Definition: Visualizer2.h:54
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 output 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 pointers 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 pointers to the visualization.
void addObject(const std::vector< PShape > &vPolygonalShapes, const Color &c)
Add polygonal shapes.
void addObject(ConstraintGraph2 *pCG, const Color &c)
Add a ConstraintGraph2 object to the visualization.
void addObject(const std::vector< VoroCell2 * > &vC, const Color &c)
Add a vector of Voronoi Cells to the visualization.
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< Triangle2 * > &vT, const Color &c)
Add a vector of Triangle2 pointers 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.