| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>Microstation DGN Feature Representation</title> |
| 4 |
</head> |
| 5 |
<body bgcolor="#ffffff"> |
| 6 |
|
| 7 |
<h1>Microstation DGN Feature Representation</h1> |
| 8 |
|
| 9 |
This document addresses how DGN features should be drawn to match the |
| 10 |
behavior of Microstation as closely as possible. It is written for |
| 11 |
users of the <a href="index.html">dgnlib</a> reader code, but the information |
| 12 |
should be applicable to anyone working with DGN.<p> |
| 13 |
|
| 14 |
The information is based on the ISFF.TXT document, supposition, and |
| 15 |
review of display effects in various viewers. It is incomplete, and at times |
| 16 |
likely incorrect. I would appreciate feedback at |
| 17 |
<a href="mailto:[email protected]">[email protected]</a>.<p> |
| 18 |
|
| 19 |
<h2>General Symbology Information</h2> |
| 20 |
|
| 21 |
All graphical elements contain a set of common information, represented by |
| 22 |
the following fields in DGNElemCore.<p> |
| 23 |
|
| 24 |
<ol> |
| 25 |
<li> <b>int color</b> |
| 26 |
<li> <b>int weight</b> |
| 27 |
<li> <b>int style</b> |
| 28 |
<li> <b>int properties</b> |
| 29 |
</ol> |
| 30 |
|
| 31 |
<h3>Color</h3> |
| 32 |
|
| 33 |
The color field of the DGNElemCore is a color index number (0-255), |
| 34 |
referencing a color from the appropriate color table. This is normally |
| 35 |
translated into an |
| 36 |
RGB color for use using DGNLookupColor(). The returned color should be |
| 37 |
considered the foreground color for drawing the element.<p> |
| 38 |
|
| 39 |
<i>NOTE: There can be more than one color table in a DGN file, and |
| 40 |
currently on the first is utilized. In theory the screen or view value from |
| 41 |
the colormap should be used to establish which is to be used but this doesn't |
| 42 |
seem to be an issue in any sample data I have encountered.</i><p> |
| 43 |
|
| 44 |
<h3>Weight</h3> |
| 45 |
|
| 46 |
This is a value between 0 and 31 which is supposed to establish the weight, or |
| 47 |
thickness of lines for this element. It is unclear how this should be |
| 48 |
utilized. Geographic Explorer treats it as a line width in pixels.<p> |
| 49 |
|
| 50 |
<h3>Style</h3> |
| 51 |
|
| 52 |
The style field has one of the following values, with 0 (Solid) being |
| 53 |
the default. Presumably this only affects drawing of line segments. There |
| 54 |
is no information on appropriate sizing information for dashes or dots, or |
| 55 |
relative guidelines implicit in the names.<p> |
| 56 |
|
| 57 |
<ul> |
| 58 |
<li> DGNS_SOLID (0) |
| 59 |
<li> DGNS_DOTTED (1) |
| 60 |
<li> DGNS_MEDIUM_DASH (2) |
| 61 |
<li> DGNS_LONG_DASH (3) |
| 62 |
<li> DGNS_DOT_DASH (4) |
| 63 |
<li> DGNS_SHORT_DASH (5) |
| 64 |
<li> DGNS_DASH_DOUBLE_DOT (6) |
| 65 |
<li> DGNS_LONG_DASH_SHORT_DASH (7) |
| 66 |
</ul> |
| 67 |
|
| 68 |
<h3>Properties</h3> |
| 69 |
|
| 70 |
The properties bitfield in DGNElemCore contains various possible values, but |
| 71 |
only a few affect drawing.<p> |
| 72 |
|
| 73 |
The <b>DGNPF_ORIENTATION</b> flag is set an element is to be oriented relative |
| 74 |
to the screen, instead of relative to the design plane. It isn't clear what |
| 75 |
all properties this affects, perhaps the orientation of text in a viewer |
| 76 |
that can rotate the view of the file as a whole. No examples of this being |
| 77 |
used have been found.<p> |
| 78 |
|
| 79 |
If used with a line element, the <b>DBNPF_HOLE</b> flag indicates that |
| 80 |
the line should be treated as infinite, while it is otherwise just a segment |
| 81 |
between the two provided points. If used with a closed element (shape, |
| 82 |
complex shape, ellipse, ...) it indicates that shape is a hole (unfilled) while |
| 83 |
by default such elements are filled.<p> |
| 84 |
|
| 85 |
<h2>Element Types</h2> |
| 86 |
|
| 87 |
<h3>DGNT_LINE</h3> |
| 88 |
|
| 89 |
Single line segment. Use color, weight and line |
| 90 |
style.<p> |
| 91 |
|
| 92 |
<h3>DGNT_LINESTRING</h3> |
| 93 |
|
| 94 |
Polyline. Use color, weight, and line style.<p> |
| 95 |
|
| 96 |
<h3>DGNT_SHAPE</h3> |
| 97 |
|
| 98 |
Polygon. Use color for edge color. If the polygon is supposed to be filled |
| 99 |
the <a href="dgn.html#ul0x0041">0x0041</a> fill information attribute |
| 100 |
linkage will also be included. The fill color may differ from the element |
| 101 |
color in which case the element should be filled with the fill color, and |
| 102 |
then the boundary drawn in the element (outline) color.<p> |
| 103 |
|
| 104 |
If the DGNPF_HOLE flag is set the shape is really a hole within another |
| 105 |
element and should be "cleared". The exact semantics are unclear. The |
| 106 |
first and last vertices of a shape are always the same.<p> |
| 107 |
|
| 108 |
<h3>DGNT_CURVE</h3> |
| 109 |
|
| 110 |
The curve (type 11) element is a 2D or 3D parametric spline curve completely defined by a set of n points. The first two and last two points define |
| 111 |
endpoint derivatives and do not display. The interpolated curve passes through all other points.<p> |
| 112 |
|
| 113 |
A curve with n points defines n-1 line segments; interpolation occurs over the middle n-5 segments. Each segment has its own parametric cubic |
| 114 |
interpolation polynomial for the x and y (and z in 3D) dimensions. The parameter for each of these polynomials is the length along the line segment. |
| 115 |
Thus, for a segment k, the interpolated points P are expressed as a function of the distance d along the segment as follows:<p> |
| 116 |
<pre> |
| 117 |
Pk(d) = {Fk,x(d), Fk,y(d), Fk,z(d)} with 0 <= d <= Dk |
| 118 |
</pre> |
| 119 |
|
| 120 |
Fk,x, Fk,y, and Fk,z are cubic polynomials and Dk is the length of segment k. |
| 121 |
In addition, the polynomial coefficients are functions of the segment |
| 122 |
length and the endpoint derivatives of Fk,x, Fk,y, and Fk,z. The subscript k |
| 123 |
is merely a reminder that these functions depend on the segment.<p> |
| 124 |
|
| 125 |
The cubic polynomials are defined as follows:<p> |
| 126 |
<pre> |
| 127 |
Fk,x = axd3 + bxd2 + cxd + Xk |
| 128 |
cx = tk |
| 129 |
bx = [3(Xk+1-Xk)/Dk - 2tk,x - tk+1,x] / Dk |
| 130 |
ax = [tk,x + tk+1,x - 2(xk+1-xk)/Dk] / Dk2 |
| 131 |
</pre> |
| 132 |
The m variable is analogous to the slope of the segment.<p> |
| 133 |
|
| 134 |
<pre> |
| 135 |
If (|mk+1,x-mk,x| + |mk-1,x-mk-2,x|) <> 0, then: |
| 136 |
tk,x = (mk-1,x|mk+1,x-mk,x| + mk,x|mk-1,x-mk-2,x|)/(|mk+1,x-mk,x| + |
| 137 |
|mk-1,x-mk-2,x|) |
| 138 |
else: |
| 139 |
tk,x = (mk+1,x+mk,x) / 2 |
| 140 |
mk,x = (Xk+1 - Xk) / Dk |
| 141 |
</pre> |
| 142 |
Fk,y(d) and Fk,z(d) are defined analogously.<p> |
| 143 |
|
| 144 |
<h3>DGNT_BSPLINE</h3> |
| 145 |
|
| 146 |
<i>Fill in later.</i> |
| 147 |
|
| 148 |
<h3>DGNT_ELLIPSE</h3> |
| 149 |
|
| 150 |
Ellipse. See DGNT_ARC for details of geometry. The DGNPF_HOLE and |
| 151 |
fill color information are applied to ellipses in the same manner as |
| 152 |
they are applied to the Shape. <p> |
| 153 |
|
| 154 |
<h3>DGNT_ARC</h3> |
| 155 |
|
| 156 |
Arc (portion of ellipse). Draw line with color, line style and weight.<p> |
| 157 |
|
| 158 |
The DGNElemArc (also used for ellipses) looks like this: |
| 159 |
<pre> |
| 160 |
typedef struct { |
| 161 |
DGNElemCore core; |
| 162 |
DGNPoint origin; |
| 163 |
double primary_axis; |
| 164 |
double secondary_axis; |
| 165 |
double rotation; |
| 166 |
long quat[4]; |
| 167 |
double startang; |
| 168 |
double sweepang; |
| 169 |
} DGNElemArc; |
| 170 |
</pre> |
| 171 |
|
| 172 |
The origin is the center of rotation for the ellipse or arc.<P> |
| 173 |
|
| 174 |
The primary_axis and secondary_axis define the distance from the origin to |
| 175 |
the ellipse edge on the primary (horizontal) and secondary (vertical) axis.<P> |
| 176 |
|
| 177 |
The rotation indicates the counterclockwise (or clockwise if negative) |
| 178 |
rotation in degrees of the defined ellipse around the origin. <p> |
| 179 |
|
| 180 |
The startang indicates the start angle (degrees, counterclockwise) of the |
| 181 |
arc. For ellipses this is always 0.<p> |
| 182 |
|
| 183 |
The sweepang indicates the angle through which the arc sweeps (counterclockwise |
| 184 |
in degrees, clockwise if negative). For ellipses this is always 360.<p> |
| 185 |
|
| 186 |
The DGNStrokeArc() function can be used to approximate arcs and ellipses as |
| 187 |
a polyline.<p> |
| 188 |
|
| 189 |
<h3>DGNT_TEXT</h3> |
| 190 |
|
| 191 |
Text. Should be drawn using color. The text structure looks like:<p> |
| 192 |
|
| 193 |
<pre> |
| 194 |
typedef struct { |
| 195 |
DGNElemCore core; |
| 196 |
|
| 197 |
int font_id; |
| 198 |
int justification; |
| 199 |
long length_mult; |
| 200 |
long height_mult; |
| 201 |
double rotation; |
| 202 |
DGNPoint origin; |
| 203 |
char string[1]; |
| 204 |
} DGNElemText; |
| 205 |
</pre> |
| 206 |
|
| 207 |
The font_id is a value from 0-255 for the to use. It is unclear to me at |
| 208 |
this time how this can be related to a non-microstation specific font. <p> |
| 209 |
|
| 210 |
The justification is generally ignored, since the provided origin is always |
| 211 |
at the bottom left of the text to be placed. The justification relates to |
| 212 |
how the user originally placed the text.<p> |
| 213 |
|
| 214 |
The rotation indicates the rotation in degrees counterclockwise of the |
| 215 |
text (zero is horizontal, left to right). <p> |
| 216 |
|
| 217 |
The origin is position where the bottom left corner of the text is placed.<p> |
| 218 |
|
| 219 |
The height_mult field gives the height of the text in master coordinates. |
| 220 |
This appears to be the height of a line, measuring distance from the baseline |
| 221 |
of one line to the next, and is usually a bit more than the height of the text |
| 222 |
itself. <p> |
| 223 |
|
| 224 |
If length_mult is different than height_mult, it means the aspect ratio of |
| 225 |
the text has been adjusted from the default.<P> |
| 226 |
|
| 227 |
<h2>Level Symbology</h2> |
| 228 |
|
| 229 |
<i>Fill in later.</i><p> |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
</BODY> |
| 234 |
</html> |