Fade2D Documentation pages v2.16.7
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
60 {
61 public:
70  CLASS_DECLSPEC
71  explicit Visualizer2(const char* filename_);
72 
74  CLASS_DECLSPEC
83  CLASS_DECLSPEC
84  void addObject(const std::vector<VoroCell2*>& vC,const Color& c);
85 
93  CLASS_DECLSPEC
94  void addObject(const std::vector<PShape>& vPolygonalShapes,const Color& c);
95 
103  CLASS_DECLSPEC
104  void addObject(const PShape& polygonalShape,const Color& c);
105 
112  CLASS_DECLSPEC
113  void addObject(VoroCell2* pVoroCell,const Color& c);
114 
122  CLASS_DECLSPEC
123  void addObject(const Segment2& seg,const Color& c);
124 
132  CLASS_DECLSPEC
133  void addObject(ConstraintGraph2* pCG,const Color& c);
134 
135 
141  CLASS_DECLSPEC
142  void addObject(const Edge2& edge,const Color& c);
143 
149  CLASS_DECLSPEC
150  void addObject(const std::vector<Point2>& vPoints,const Color& c);
151 
157  CLASS_DECLSPEC
158  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
159 
160 
166  CLASS_DECLSPEC
167  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
168 
174  CLASS_DECLSPEC
175  void addObject(const std::vector<VertexPair2>& vVertexPairs,const Color& c);
176 
182  CLASS_DECLSPEC
183  void addObject(const std::vector<ConstraintSegment2*>& vConstraintSegments,const Color& c);
184 
190  CLASS_DECLSPEC
191  void addObject(const std::vector<Edge2>& vEdges,const Color& c);
192 
193 
199  CLASS_DECLSPEC
200  void addObject(const std::vector<Triangle2>& vT,const Color& c);
201 
207  CLASS_DECLSPEC
208  void addObject(const Circle2& circ,const Color& c);
209 
215  CLASS_DECLSPEC
216  void addObject(const Point2& pnt,const Color& c);
217 
223  CLASS_DECLSPEC
224  void addObject(const Triangle2& tri,const Color& c);
225 
231  CLASS_DECLSPEC
232  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
233 
239  CLASS_DECLSPEC
240  void addObject(const Label& lab,const Color& c);
241 
246  CLASS_DECLSPEC
247  void addHeaderLine(const char* s);
248 
249 
254  CLASS_DECLSPEC
255  void writeFile();
256 
257 
260  CLASS_DECLSPEC
261  void setLimit(const Bbox2& bbx);
262 
270  Bbox2 computeRange(bool bWithVoronoi);
271 protected:
272  Visualizer2(const Visualizer2& );
273  Visualizer2& operator=(const Visualizer2&);
274  // Helpers
275  Point2 scaledPoint(const Point2 &p);
276  double scaledDouble(const double &d);
277  void changeColor(float r,float g,float b,float linewidth,bool bFill);
278  void changeColor(const Color& c);
279  // Write Header/Footer
280  void writeHeader(const char* title);
281  void writeFooter();
282  void writeHeaderLines();
283  // Write Objects
284  void writeLabel(Label l);
285  void writeLine(const Point2& pSource,const Point2& pTarget);
286  void writePolygon(PShape& pshape,bool bFill,double width);
287  void writeTriangle(const Point2& p0_,const Point2& p1_,const Point2& p2_,bool bFill,double width);
288  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
289  void writeVoroCell(VoroCell2* pVoroCell,bool bFill,double width);
290  void writePoint(const Point2& p1_,float size);
291  void writeMark(const Point2& p1_,float size);
292  void writeCircle(const Point2& p1_,double radius,bool bFill);
293  void periodicStroke();
294 
295  // DATA
296  bool bTypePS;
297  Dat* pDat;
298  int updateCtr;
299  bool bFill;
300  Color lastColor;
301  bool bFileClosed;
302  Bbox2 bbox;
303  std::ofstream outFile;
304  std::vector<std::pair<Segment2,Color> > vSegments;
305  std::vector<std::pair<Circle2,Color> > vCircles;
306  std::vector<std::pair<Point2,Color> > vPoints;
307  std::vector<std::pair<Triangle2,Color> > vTriangles;
308  std::vector<std::pair<Label,Color> > vLabels;
309  std::vector<std::pair<VoroCell2*,Color> > vVoroCells;
310  std::vector<std::pair<PShape,Color> > vPolygons;
311 };
312 
313 
314 } // (namespace)
A 2D axis-aligned bounding box.
Definition: Bbox2.h:39
Circle class for visualization.
Definition: Circle2.h:41
Color for visualization.
Definition: Color.h:61
A constraint graph is a collection of constraint edges (ConstraintSegment2).
Definition: ConstraintGraph2.h:56
Represents a directed edge in a triangulation.
Definition: Edge2.h:46
Represents a text label for visualization.
Definition: Label.h:44
Polygonal Shape for Visualization.
Definition: PShape.h:39
Represents a 2D point.
Definition: Point2.h:61
Represents a line segment between two points.
Definition: Segment2.h:41
Represents a triangle in a triangulation.
Definition: Triangle2.h:59
A PDF and Postscript Writer for 2D Visualization.
Definition: Visualizer2.h:60
CLASS_DECLSPEC void addObject(const std::vector< Point2 * > &vPoints, const Color &c)
Add a vector of Point2 pointers to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< Triangle2 * > &vT, const Color &c)
Add a vector of Triangle2 pointers to the visualization.
CLASS_DECLSPEC ~Visualizer2()
Destructor.
CLASS_DECLSPEC void addObject(const PShape &polygonalShape, const Color &c)
Add a single polygonal shape to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< Point2 > &vPoints, const Color &c)
Add a vector of Point2 objects to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< Edge2 > &vEdges, const Color &c)
Add a vector of Edge2 objects to the visualization.
CLASS_DECLSPEC void addObject(VoroCell2 *pVoroCell, const Color &c)
Add a Voronoi cell to the visualization.
CLASS_DECLSPEC void addHeaderLine(const char *s)
Add a header line to the visualization.
CLASS_DECLSPEC void addObject(const Segment2 &seg, const Color &c)
Add a Segment2 object to the visualization.
CLASS_DECLSPEC void addObject(const Triangle2 &tri, const Color &c)
Add a Triangle2 object to the visualization.
CLASS_DECLSPEC void addObject(const Edge2 &edge, const Color &c)
Add an Edge2 object to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< VertexPair2 > &vVertexPairs, const Color &c)
Add a vector of VertexPair2 objects defining segments to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< Segment2 > &vSegments, const Color &c)
Add a vector of Segment2 objects to the visualization.
CLASS_DECLSPEC void addObject(const Circle2 &circ, const Color &c)
Add a Circle2 object to the visualization.
CLASS_DECLSPEC void addObject(const Label &lab, const Color &c)
Add a Label object to the visualization.
CLASS_DECLSPEC void addObject(const Point2 &pnt, const Color &c)
Add a Point2 object to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< ConstraintSegment2 * > &vConstraintSegments, const Color &c)
Add a vector of ConstraintSegment2 pointers to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< PShape > &vPolygonalShapes, const Color &c)
Add polygonal shapes to the visualization.
CLASS_DECLSPEC void addObject(ConstraintGraph2 *pCG, const Color &c)
Add a ConstraintGraph2 object to the visualization.
CLASS_DECLSPEC void addObject(const std::vector< Triangle2 > &vT, const Color &c)
Add a vector of Triangle2 objects to the visualization.
CLASS_DECLSPEC Visualizer2(const char *filename_)
Constructor for Visualizer2.
CLASS_DECLSPEC void addObject(const std::vector< VoroCell2 * > &vC, const Color &c)
Add Voronoi cells to the visualization.
CLASS_DECLSPEC void writeFile()
Finish and write the output file.
Voronoi cell.
Definition: VoroCell2.h:45