Fade2D Documentation pages v2.16.3
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 #include "VertexPair2.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 class ConstraintGraph2; // FWD
41 class VoroCell2; // FWD
42 struct Dat; // FWD
43 class SegmentChecker; // FWD
44 
55 {
56 public:
61  CLASS_DECLSPEC
62  explicit Visualizer2(const char* filename_);
63 
64  CLASS_DECLSPEC
65  ~Visualizer2();
71  CLASS_DECLSPEC
72  void addObject(const std::vector<VoroCell2*>& vC,const Color& c);
73 
79  CLASS_DECLSPEC
80  void addObject(const std::vector<PShape>& vPolygonalShapes,const Color& c);
81 
87  CLASS_DECLSPEC
88  void addObject(const PShape& polygonalShape,const Color& c);
89 
95  CLASS_DECLSPEC
96  void addObject(VoroCell2* pVoroCell,const Color& c);
97 
104  CLASS_DECLSPEC
105  void addObject(const Segment2& seg,const Color& c);
106 
113  CLASS_DECLSPEC
114  void addObject(ConstraintGraph2* pCG,const Color& c);
115 
116 
122  CLASS_DECLSPEC
123  void addObject(const Edge2& edge,const Color& c);
124 
130  CLASS_DECLSPEC
131  void addObject(const std::vector<Point2>& vPoints,const Color& c);
132 
138  CLASS_DECLSPEC
139  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
140 
141 
147  CLASS_DECLSPEC
148  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
149 
155  CLASS_DECLSPEC
156  void addObject(const std::vector<VertexPair2>& vVertexPairs,const Color& c);
157 
165  CLASS_DECLSPEC
166  void addObject(const std::vector<ConstraintSegment2*>& vConstraintSegments,const Color& c);
167 
173  CLASS_DECLSPEC
174  void addObject(const std::vector<Edge2>& vSegments,const Color& c);
175 
176 
182  CLASS_DECLSPEC
183  void addObject(const std::vector<Triangle2>& vT,const Color& c);
184 
190  CLASS_DECLSPEC
191  void addObject(const Circle2& circ,const Color& c);
192  CLASS_DECLSPEC
198  void addObject(const Point2& pnt,const Color& c);
199 
205  CLASS_DECLSPEC
206  void addObject(const Triangle2& tri,const Color& c);
207 
213  CLASS_DECLSPEC
214  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
215 
221  CLASS_DECLSPEC
222  void addObject(const Label& lab,const Color& c);
223 
228  CLASS_DECLSPEC
229  void addHeaderLine(const char* s);
230 
231 
236  CLASS_DECLSPEC
237  void writeFile();
238 
239 
242  CLASS_DECLSPEC
243  void setLimit(const Bbox2& bbx);
244 
252  Bbox2 computeRange(bool bWithVoronoi);
253 protected:
254  Visualizer2(const Visualizer2& );
255  Visualizer2& operator=(const Visualizer2&);
256  // Helpers
257  Point2 scaledPoint(const Point2 &p);
258  double scaledDouble(const double &d);
259  void changeColor(float r,float g,float b,float linewidth,bool bFill);
260  void changeColor(const Color& c);
261  // Write Header/Footer
262  void writeHeader(const char* title);
263  void writeFooter();
264  void writeHeaderLines();
265  // Write Objects
266  void writeLabel(Label l);
267  void writeLine(const Point2& pSource,const Point2& pTarget);
268  void writePolygon(PShape& pshape,bool bFill,double width);
269  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
270  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
271  void writeVoroCell(VoroCell2* pVoroCell,bool bFill,double width);
272  void writePoint(const Point2& p1_,float size);
273  void writeMark(const Point2& p1_,float size);
274  void writeCircle(const Point2& p1_,double radius,bool bFill);
275  void periodicStroke();
276 
277  // DATA
278  bool bTypePS;
279  Dat* pDat;
280  int updateCtr;
281  bool bFill;
282  Color lastColor;
283  bool bFileClosed;
284  Bbox2 bbox;
285  std::ofstream outFile;
286  std::vector<std::pair<Segment2,Color> > vSegments;
287  std::vector<std::pair<Circle2,Color> > vCircles;
288  std::vector<std::pair<Point2,Color> > vPoints;
289  std::vector<std::pair<Triangle2,Color> > vTriangles;
290  std::vector<std::pair<Label,Color> > vLabels;
291  std::vector<std::pair<VoroCell2*,Color> > vVoroCells;
292  std::vector<std::pair<PShape,Color> > vPolygons;
293 };
294 
295 
296 } // (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:55
void addObject(const Edge2 &edge, const Color &c)
Add an Edge2 object to the visualization.
void addObject(const std::vector< PShape > &vPolygonalShapes, const Color &c)
Add polygonal shapes.
void addObject(const Label &lab, const Color &c)
Add a Label object to the visualization.
void writeFile()
Finish and write the output file.
void addObject(const std::vector< Triangle2 > &vT, const Color &c)
Add a vector of Triangle2 objects to the visualization.
void addObject(const Point2 &pnt, const Color &c)
Add a Point2 object to the visualization.
void addObject(const std::vector< ConstraintSegment2 * > &vConstraintSegments, const Color &c)
Add a vector of ConstraintSegment2 pointers to the visualization.
void addObject(VoroCell2 *pVoroCell, const Color &c)
Add a Voronoi cell to the visualization.
void addObject(const std::vector< VertexPair2 > &vVertexPairs, const Color &c)
Add a vector of VertexPair2 objects as segments to the visualization.
void addObject(const Circle2 &circ, const Color &c)
Add a Circle2 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< Segment2 > &vSegments, const Color &c)
Add a vector of Segment2 objects to the visualization.
void addObject(const Triangle2 &tri, const Color &c)
Add a Triangle2 object to the visualization.
void addHeaderLine(const char *s)
Add a header line to the visualization.
Visualizer2(const char *filename_)
Constructor.
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 objects to the visualization.
void addObject(const PShape &polygonalShape, const Color &c)
Add a polygonal shape.
void addObject(const std::vector< VoroCell2 * > &vC, const Color &c)
Add a vector of Voronoi Cells to the visualization.
void addObject(ConstraintGraph2 *pCG, const Color &c)
Add a ConstraintGraph2 object to the visualization.
Bbox2 computeRange(bool bWithVoronoi)
Compute the range.
void addObject(const std::vector< Edge2 > &vSegments, const Color &c)
Add a vector of Edge2 objects to the visualization.
void addObject(const std::vector< Triangle2 * > &vT, const Color &c)
Add a vector of Triangle2 pointers to the visualization.
Voronoi cell.
Definition: VoroCell2.h:45