-
Notifications
You must be signed in to change notification settings - Fork 39
GoTools g2 file format
For the geometric entities in GoTools with read and write functionality in the GoTools file format, this page describes the form this file format takes. Note that the GoTools file format is a simple format that does not support pointers. Thus, duplication of information may occur.
Each geometric entity is represented by an entity code, as listed below. The file splits into an object header that takes the same form for all geometric entities, and an object body that has a specific form for each geometric entitity. Values are either separated by a blank space or a new line. Both separators are equivalent, but the latter is used to improve readability. It is not possible to write comments in g2-files.
- 100:
SplineCurve
- 110:
CurveOnSurface
- 120:
Line
- 130:
Circle
- 140:
Ellipse
- 150:
BoundedCurve
- 160:
Hyperbola
- 170:
Parabola
- 200:
SplineSurface
- 210:
BoundedSurface
- 211:
SurfaceOnVolume
- 220:
GoBaryPolSurface
- 230:
GoHBSplineParamSurface
- 240:
CompositeSurface
- 250:
Plane
- 260:
Cylinder
- 270:
Sphere
- 280:
Cone
- 290:
Torus
- 291:
SurfaceOfRevolution
- 292:
Disc
- 293:
LRSplineSurface
- 294:
TSplineSurface
- 300:
Go3dsObject
- 310:
GoHeTriang
- 320:
GoSdTriang
- 330:
GoQuadMesh
- 340:
GoHybridMesh
- 350:
ParamTriang
- 360:
GoVrmlGeometry
- 400:
PointCloud
- 410:
LineCloud
- 500:
GoTriangleSets
- 510:
RectGrid
- 700:
SplineVolume
- 720:
Parallelepiped
- 721:
SphereVolume
- 722:
CylinderVolume
- 723:
ConeVolume
- 724:
TorusVolume
All geometry entities are preceeded by the object ObjectHeader
in a stream, which contains information about the class type of the geometry object to follow and the version number of the file format.
The format of the header is as follows:
- class type. The entity code given in the list above.
- major version. Always 1.
- minor version. Always 0.
- auxiliary data. 0 if the default colour is chosen, 4 if the rgb-colour code is chosen. In the latter case, the entity is followed by 4 integer digits between 0 and 255 giving the colours red, green, blue, and the alpha (blending) value.
130 1 0 0
The object body of SplineCurve
takes the following format:
- dimension of geometry space, whether or not the curve is rational: 1=rational, 0=non-rational
- the number of coefficients, the polynomial order (i.e., degree + 1)
- the knot vector; multiple knots are represented by giving the knot value several times
- the curve coefficients
The curve coefficients are given continuously, normally divided by a carriage return for each coefficient. The sequence is, in the non-rational case,
Including the header, a linear non-rational spline curve in the parameter interval
100 1 0 0
3 0
2 2
0 0 1 1
0 0 0
1 0 0
The object body of CurveOnSurface
takes the following format:
- whether or not the parameter space curve is the master information (1=parameter curve is master, 0=space curve is master), the entity type of the parameter curve (0 if no such curve exists), the entity type of the space curve (0 if no such curve exists)
- the description of the parameter curve according to the rules for that curve type
- the description of the space curve according to the rules for that curve type
Either the parameter curve, the space curve or both are given. Information regarding constant parameter information for the curve on the surface is not covered by the file format.
Note that CurveOnSurface
also contains information about a ParamSurface
. Thus, the g2-representation of CurveOnSurface
is not stand-alone. It needs to be combined with BoundedSurface
; see the example in this section of how CurveOnSurface
is used in this context.
The object body of Line
takes the following format:
- the dimension of the geometry space
- a point on the line
- the direction of the line
- a flag, 0 or 1, for unbounded or bounded
- if the line is bounded, the start and end parameters
The object body of Circle
takes the following format:
- the dimension of the geometry space
- the radius of the circle
- the centre of the circle
- the normal of the plane in which the circle lies
- the vector from the centre of the circle towards the "x-axis" --- the start point of the default parametrization of the circle
- the start and end parameters
The circle has a default implicit parametrization from 0 to
130 1 0 0
dim
rad
c_x c_y c_z
n_x n_y n_z
v_x v_y v_z
The object body of Ellipse
takes the following format:
- the dimension of the geometry space
- the major radius of the ellipse
- the minor radius of the ellipse
- the centre of the ellipse
- the normal of the plane in which the ellipse lies
- the vector from the centre of the ellipse towards the "x-axis" --- the start point of the default parametrization
A BoundedCurve
is expected to be bounded both parametrically and geometrically. Thus, a flag describing whether or not
the restriction in the parameter space or in geometry space is preferred is included in the format.
The object body takes the following format:
- Whether the restriction in the parameter space is the master (1 if true)
- The start parameter of the bounded curve, the end parameter of the bounded curve
- The start point of the bounded curve in geometry space
- The end point of the bounded curve in geometry space
- The underlying curve described according to its entity type
We define a bounded line from the point (0,0,0) to (1,0,0), where the position in space is the master regarding the bounding points:
150 1 0 0
120 0
0 1
3
0 0 0
1 0 0
3
0 0 0
1 0 0
Here 120 denotes the entity number for a line and the dimension of the geometry space is 3.
The object body of a SplineSurface
takes the following format:
- dimension of the geometry space, whether or not the surface is rational: 1=rational, 0=non-rational
- the number of coefficients in the first parameter direction, the polynomial order in this direction (i.e., degree+1)
- the knot vector in the first parameter direction, multiple knots are represented by giving the knot value several times
- the number of coefficients in the second parameter direction, the polynomial order in this direction (i.e., degree+1)
- the knot vector in the second parameter direction
- the surface coefficients
The surface coefficients are provided in a sequence, row-wise and from top to bottom in the reflected lexicographic order,
Here
As for spline curves, in the rational case the coefficients are multiplied by the weights and an extra entry (from the homogenization) is given for each coefficient.
A simple non-rational, bilinear surface with no inner knots is represented as:
200 1 0 0
3 0
2 2
0 0 1 1
2 2
0 0 1 1
0 0 0
1 0 0
0 1 0
1 1 0
A BoundedSurface
consists of an underlying rectangular parametric surface and one or more trimming loops. The object body takes the following format:
- The entity code of the underlying surface
- The number of trimming loops
- For each trimming loop
- The number of curves in the current trimming loop
- The tolerance within which the loop is found to be continuous
- The curves in the trimming loop, one by one
The trimming curves are of type ParamCurve
, but in most cases they will be represented as a CurveOnSurface
.
The following example illustrates the format of a BoundedSurface
. The underlying surface is a Plane
, as can be seen from the entity number 250 on line two. The 3 curves in the trimming loop are all of type CurveOnSurface
. Note that the entity number of CurveOnSurface
does not appear. The space curve corresponding to the CurveOnSurface
is the master, and the only curve describing the trimming curve. This is given by the line 0 0 100
, which occurs for every curve and should be interpreted as: the space curve is the master, the parameter curve does not exist, the space curve is a spline curve. Following this line is the body of a spline curve in the g2-format.
210 1 0 0
250
3
0 0 0
0 0 1
1 0 0
1
-3 3
-3 3
0
1
3 0.0001
0 0 100
3 0
2 2
0 0 1 1
-1 0 0
0 -1 0
0 0 100
3 0
2 2
0 0 1 1
0 -1 0
-0.5 2 0
0 0 100
3 0
4 3
0 0 0 0.5 1 1 1
-0.5 2 0
-1 2 0
-2 1 0
-1 0 0
In this case the two first trimming curves are linear spline curves while the last one is of order 3 (degree 2) and has one inner knot. All the curves are non-rational.
The object body of a Plane
takes the following format:
- The dimension of the geometry space
- A point in the plane
- The normal of the plane
- One vector in the set of vectors spanning the plane
- A flag, 0 or 1, for unbounded or bounded
- If the plane is bounded, the four bounds
umin
,umax
,vmin
,vmax
describing a bounding box in the parameter domain - A flag, 0 or 1, indicating whether or not the
u
- andv
-parameter directions are swapped.
The plane used as the underlying surface in the previous example has the format:
250 1 0 0
3
0 0 0
0 0 1
1 0 0
1
-3 3
-3 3
0
The object body of a Cylinder
takes the following format:
- The dimension of the geometry space
- The cylinder radius
- A point on the cylinder axis
- The cylinder axis
- The vector from the cylinder axis towards the cylinder surface giving the start point of the default parametrization
- A flag, 0 or 1, for unbounded or bounded in the linear direction
- If unbounded, the bounding parameters:
umin
,umax
- If bounded, the bounding parameters:
umin
,umax
,vmin
,vmax
- A flag, 0 or 1, indicating whether or not the
u
- andv
-parameter directions are swapped
The object body of a Sphere
takes the following format:
- The dimension of the geometry space
- The radius of the sphere
- The centre of the sphere
- The axis on which the degeneracies of a NURBS representation of the sphere will lie, i.e., the sphere axis
- The vector from the sphere axis towards the sphere surface giving the start point of the default parametrization
- The bounding parameters:
umin
,umax
,vmin
,vmax
- A flag, 0 or 1, indicating whether or not the
u
- andv
-parameter directions are swapped
A sphere with centre (1.5, 0, 0) and radius 1.5 is represented in the g2-format as
270 1 0 0
3
1.5
1.5 0 0
0 0 1
1 0 0
0 6.283185307179586
-1.5707963267948966 1.5707963267948966
0
The object body of a Cone
takes the following format:
- The dimension of the geometry space
- The cone radius at the position of the point on the cone axis
- A point on the cone axis
- The cone axis
- The vector from the cone axis towards the cone surface giving the start point of the default parametrization
- The opening angle of the cone
- A flag, 0 or 1, for unbounded or bounded in the linear direction
- If unbounded, the bounding parameters:
umin
,umax
- If bounded, the bounding parameters:
umin
,umax
,vmin
,vmax
- A flag, 0 or 1, indicating whether or not the
u
- andv
-parameter directions are swapped
The object body of a Torus
takes the following format:
- The dimension of the geometry space
- The major radius of the torus
- The minor radius of the torus
- The torus centre
- The mid axis of the torus
- The vector from the torus centre to the torus surface giving the start point of the default parametrization
- Select outer (1=yes, 0=no): Defines the parameter domain of the torus in degenerate cases.
- A flag, 0 or 1, for unbounded or bounded in the linear direction
- If unbounded, the bounding parameters:
umin
,umax
- If bounded, the bounding parameters:
umin
,umax
,vmin
,vmax
- A flag, 0 or 1, indicating whether or not the
u
- andv
-parameter directions are swapped
The object body of a SurfaceOfRevolution
takes the following format:
- The dimension of the geometry space
- A point on the axis of revolution
- The direction of the axis of revolution
- The body of the spline curve to rotate around this axis
291 1 0 0
3
0 0 0
0 0 1
3 0
2 2
0 0 1 1
1 0 0
3 0 0
The object body of a Disc
takes the following format:
- The dimension of the geometry space
- The centre of the disc
- The disc radius
- The normal to the disc surface
- A vector from the disc centre to the disc boundary to give a start point for the parametrization
- Whether a NURBS representation should have a degeneracy in the centre (=1) or have degenerate corners (=0)
- The angles giving the four degeneracy points at the boundary. Not used if the flag for centre degeneracy is false.
The object body of a PointCloud
takes the following format:
- Number of points
- The coordinates of each point.
The points are given one by one, and the dimension of a point in a point cloud is 3 by default.
An example of a point cloud with 3 points is:
400 1 0 0
3
0 0 0
1 0 0
1 1 0
The object body of a LineCloud
takes the following format:
- Number of line segments
- The coordinates of the endpoints of each line segments. The lines are given one by one.
The dimension of a line in a line cloud is 3 by default.
The following is an example of a line cloud with 3 lines:
410 1 0 0
3
0 0 0 0 0 1
1 0 0 1 0 1
1 1 0 1 1 1
The SplineVolume
entity is placed in the module trivariate
, and its object body takes the following format:
- dimension of the geometry space, whether or not the volume is rational: 1=rational, 0=non-rational
- the number of coefficients in the first parameter direction, the polynomial order in this direction (i.e., degree+1)
- the knot vector in the first parameter direction, multiple knots are represented by repeating the knot values
- the number of coefficients in the second parameter direction, the polynomial order in this direction (i.e., degree+1)
- the knot vector in the second parameter direction
- the number of coefficients in the third parameter direction, the polynomial order in this direction (i.e., degree+1)
- the knot vector in the third parameter direction
- the volume coefficients
The volume coefficients are provided in a sequence as in the reflected lexicographic order, i.e.,
As for spline curves and spline surfaces, in the rational case the coefficients are multiplied by the weights and an extra entry (from the homogenization) is given for each coefficient.
A simple non-rational, trilinear volume with no inner knots is represented as:
700 1 0 0
3 0
2 2
0 0 1 1
2 2
0 0 1 1
2 2
0 0 1 1
0 0 0
1 0 0
0 1 0
1 1 1
0 0 1
1 0 1
0 1 1
1 1 1
The object body of a Parallelepiped
takes the following format:
- Dimension of the geometry space
- Lower right corner
- Unit vector in geometry space representing the first parameter direction
- Length of parallelepiped in the first direction
- Unit vector in geometry space representing the second parameter direction
- Length of parallelepiped in the second direction
- Unit vector in geometry space representing the third parameter direction
- Length of parallelepiped in the third direction
The object body of a SphereVolume
takes the following format:
- Dimension of the geometry space
- Sphere radius
- Centre of sphere
- Axis of sphere, i.e., the vector along which the degeneracies of a NURBS representation of the sphere will lie
- Vector from the centre to the outer surface giving input to the sphere parametrization
The object body of a CylinderVolume
takes the following format:
- Dimension of the geometry space
- Cylinder centre
- Cylinder axis
- Vector from the centre to the outer surface giving input to the parametrization of the cylinder
- Minimum cylinder radius. If this number is larger than 0, the cylinder will have a hole along the axis
- Maximum radius, the radius of the outer cylinder surface
- Minimum height, =1: the cylinder is infinite, =0: the cylinder is finite and the distance from the centre to the bottom of the cylinder folllows (positive or negative number)
- Maximum height, =1: the cylinder is infinite, =0: the cylinder is finite and the total height of the cylinder follows
- Whether a NURBS representation should have a degeneracy in the centre (=1) or have degenerate corners (=0)
- The angles giving the four degeneracy points at the boundary. Not used if the flag for centre degeneracy is false.
The object body of a ConeVolume
takes the following format:
- Dimension of the geometry space
- Radius of the cone at the centre
- A point at the cone axis (the centre)
- Cone axis
- The vector from the cone axis towards the boundary surface of the cone, giving the start point of the cone parametrization
- The opening angle of the cone
- Minimum height, the distance from the centre to the smallest end disc of the cone (positive or negative number)
- Maximum height, =1: the cone is infinite, =0: the cone is finite and the cone height follows
- Whether a NURBS representation should have a degeneracy in the centre (=1) or have degenerate corners (=0)
- The angles giving the four degeneracy points at the boundary. Not used if the flag for centre degeneracy is false.
The object body of a TorusVolume
takes the following format:
- Dimension of the geometry space
- The torus centre
- The normal to the plane through the large circle of the torus
- A vector from the torus centre to the torus surface giving the parametrization
- The major radius
- The minor radius
- Angle of revolution for the small circle
- Angle of revolution for the large circle
- Whether a NURBS representation should have a degeneracy in the centre (=1) or have degenerate corners (=0)
- The angles giving the four degeneracy points at the boundary. Not used if the flag for centre degeneracy is false.
Getting started
Miscellaneous
Functionality
- Modules
- gotools-core
- compositemodel
- implicitization
- igeslib
- intersections
- isogeometric_model
- lrsplines2D
- parametrization
- qualitymodule
- topology
- trivariate
- trivariatemodel
- viewlib
Dependencies