Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
complexplayground.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __COMPLEXPLAYGROUND_H
25 #define __COMPLEXPLAYGROUND_H
26 
27 #include "mathutils.h"
28 #include "abstractground.h"
29 #include "pos.h"
30 
31 namespace lpzrobots {
32 
33 // Taken from XFIG documentation
34 // .....
35 // (2) The first non-comment line consists of the following:
36 
37 // string orientation ("Landscape" or "Portrait")
38 // string justification ("Center" or "Flush Left")
39 // string units ("Metric" or "Inches")
40 // string papersize ("Letter", "Legal", "Ledger", "Tabloid",
41 // "A", "B", "C", "D", "E",
42 // "A4", "A3", "A2", "A1", "A0" and "B5")
43 // float magnification (export and print magnification, %)
44 // string multiple-page ("Single" or "Multiple" pages)
45 // int transparent color (color number for transparent color for GIF
46 // export. -3=background, -2=None, -1=Default,
47 // 0-31 for standard colors or 32- for user colors)
48 // # optional comment (An optional set of comments may be here,
49 // which are associated with the whole figure)
50 // int resolution coord_system (Fig units/inch and coordinate system:
51 // 1: origin at lower left corner (NOT USED)
52 // 2: upper left)
53 
54 // Fig_resolution is the resolution of the figure in the file.
55 // Xfig will always write the file with a resolution of 1200ppi so it
56 // will scale the figure upon reading it in if its resolution is different
57 // from 1200ppi. Pixels are assumed to be square.
58 
59 // Xfig will read the orientation string and change the canvas to match
60 // either the Landscape or Portrait mode of the figure file.
61 
62 // The units specification is self-explanatory.
63 
64 // The coordinate_system variable is ignored - the origin is ALWAYS the
65 // upper-left corner.
66 
67 // ** Coordinates are given in "fig_resolution" units.
68 // ** Line thicknesses are given in 1/80 inch (0.3175mm) or 1 screen pixel.
69 // When exporting to EPS, PostScript or any bitmap format (e.g. GIF), the
70 // line thickness is reduced to 1/160 inch (0.159mm) to "lighten" the look.
71 // ** dash-lengths/dot-gaps are given in 80-ths of an inch.
72 
73 
74 
75 
76 // (3) The rest of the file contains various objects. An object can be one
77 // of six classes (or types).
78 
79 // 0) Color pseudo-object.
80 // 1) Ellipse which is a generalization of circle.
81 // 2) Polyline which includes polygon and box.
82 // 3) Spline which includes
83 // closed/open approximated/interpolated/x-spline spline.
84 // 4) Text.
85 // 5) Arc.
86 // 6) Compound object which is composed of one or more objects.
87 // ........
88 // (3.5) POLYLINE
89 
90 // First line:
91 // type name (brief description)
92 // ---- ---- -------------------
93 // int object_code (always 2)
94 // int sub_type (1: polyline
95 // 2: box
96 // 3: polygon
97 // 4: arc-box)
98 // 5: imported-picture bounding-box)
99 // int line_style (enumeration type)
100 // int thickness (1/80 inch)
101 // int pen_color (enumeration type, pen color)
102 // int fill_color (enumeration type, fill color)
103 // int depth (enumeration type)
104 // int pen_style (pen style, not used)
105 // int area_fill (enumeration type, -1 = no fill)
106 // float style_val (1/80 inch)
107 // int join_style (enumeration type)
108 // int cap_style (enumeration type, only used for POLYLINE)
109 // int radius (1/80 inch, radius of arc-boxes)
110 // int forward_arrow (0: off, 1: on)
111 // int backward_arrow (0: off, 1: on)
112 // int npoints (number of points in line)
113 
114 // Forward arrow line: same as ARC object
115 
116 // Backward arrow line: same as ARC object
117 
118 // For picture (type 5) the following line follows:
119 // type name (brief description)
120 // ---- ---- -------------------
121 // boolean flipped orientation = normal (0) or flipped (1)
122 // char file[] name of picture file to import
123 
124 // Points line(s). The x,y coordinates follow, any number to a line, with
125 // as many lines as are necessary:
126 // type name (brief description)
127 // ---- ---- -------------------
128 // int x1, y1 (Fig units)
129 // int x2, y2 (Fig units)
130 // .
131 // .
132 // int xnpoints ynpoints (this will be the same as the 1st
133 // point for polygon and box)
134 
135  class PolyLine {
136  public:
138  object_code = 0;
139  sub_type = 0;
140  line_style = 0;
141  thickness = 0;
142  depth = 0; // (multiple of height)
143  };
144  /** try to parses a PolyLine at the start of the list of lines and returns the consumed lines
145  1: no success; >=2 success
146  */
147  int parse(std::list<char*> lines);
148  void print();
149 
150  int object_code; // (always 2)
151  int sub_type; // (we require 1: polyline)
152  int line_style; // (0: normal wall, 1: border, rest ignored)
153  int thickness; // (1/80 inch means factor of .3175 )
154  int depth; // (multiple of height)
155  std::list<Pos> points;
156  };
157 
158  /** Playground that uses an xfig file with polylines
159  linetype 0 is normal wall
160  linetype 1 is border
161  thickness is used as well, thickness is multiplied with wallthickness.
162  depth is used as a height value and is multiplied with heightfactor.
163  The entire size can be scaled with a global factor
164  */
166 
167  protected:
168 
169  std::string filename;
171 
172  std::list<PolyLine> polylines;
173 
174  public:
175  /**
176  @param factor global factor for the entire playground
177  @heightfactor factor for depth value of xfig line to determine wall height
178  */
180  const std::string& filename,
181  double factor = 1, double heightfactor=0.02, bool createGround=true);
182 
183  void createPolyline(const PolyLine&);
184 
185  protected:
186  virtual void create();
187 
188  };
189 
190 }
191 
192 #endif
int depth
Definition: complexplayground.h:154
Data structure for accessing the ODE.
Definition: odehandle.h:44
OsgHandle osgHandle
Definition: abstractobstacle.h:174
int thickness
Definition: complexplayground.h:153
int sub_type
Definition: complexplayground.h:151
int object_code
Definition: complexplayground.h:150
double heightfactor
Definition: complexplayground.h:170
int parse(std::list< char * > lines)
try to parses a PolyLine at the start of the list of lines and returns the consumed lines 1: no succe...
Definition: complexplayground.cpp:37
OdeHandle odeHandle
Definition: abstractobstacle.h:173
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
virtual void createGround()
Definition: abstractground.cpp:123
double factor
Definition: complexplayground.h:170
Playground that uses an xfig file with polylines linetype 0 is normal wall linetype 1 is border thick...
Definition: complexplayground.h:165
std::string filename
Definition: complexplayground.h:169
void print()
Definition: complexplayground.cpp:72
PolyLine()
Definition: complexplayground.h:137
std::list< PolyLine > polylines
Definition: complexplayground.h:172
Definition: complexplayground.h:135
virtual void create()
overload this function to create the obstactle. All primitives should go into the list "obst" ...
Definition: complexplayground.cpp:119
ComplexPlayground(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const std::string &filename, double factor=1, double heightfactor=0.02, bool createGround=true)
Definition: complexplayground.cpp:83
void createPolyline(const PolyLine &)
Definition: complexplayground.cpp:153
Definition: abstractground.h:36
std::list< Pos > points
Definition: complexplayground.h:155
int line_style
Definition: complexplayground.h:152