VisuSurface

VisuSurface — Supports loading of .surf files and drawing of surfaces through OpenGL.

Functions

Properties

VisuSurfaceResource * resource Read / Write

Signals

Types and Values

Object Hierarchy

    GBoxed
    ╰── VisuSurfaceDefinition
    GObject
    ╰── ToolDbgObj
        ╰── VisuSurface

Implemented Interfaces

VisuSurface implements VisuBoxed.

Description

Originally written by Luc Billard for his Visualize program. This module allows loading of .surf files to draw scalar fields on top of the current display scene. .surf files are text files which specs are the following :

  • 1st line is arbitrary

  • 2nd line must contain 3 real (float) values: dxx dyx dyy

  • 3rd line must contain 3 real (float) values: dzx dzy dzz

  • 4th line must contain 3 positive integers which represents respectively the number of surfaces, the total number of polys, and the total number of points

  • Then, for each of these surfaces :

    • next line must contain the name of the surface : it is a string which should match the pattern surface_*

    • next line must contain 2 positive integer values: the number of polys (num_polys) and the number of points (num_points) used by the surface

    • each of the following num_polys lines must match the pattern [n i_1 i_2 i_3 ... i_n] where n is the number of vertices in the poly (n >= 3) and [i_1 i_2 i_3 ... i_n] are the numbering of these vertices (vertices numbered from 1 to num_points)

    • each of the following num_points lines must contain 6 real values for the successive (1 to num_points) points : [x y z nx ny nz], where x y z are the coordinates of the point and nx ny nz are the coordinates of the unit normal at the point

It is the responsibility of the user to guarantee that dxx, dyx, dyy, dzx, dzy, dzz match the one currently loaded in V_Sim's current context. Though if you use panelSurfaces you can ask to resize the surfaces so that they fit in the current loaded box.

Functions

visu_surface_getErrorQuark ()

GQuark
visu_surface_getErrorQuark (void);

Internal routine for error handling.

Returns

the GQuark associated to errors related to surface files.


visu_surface_new ()

VisuSurface *
visu_surface_new (const gchar *label,
                  const GArray *points,
                  const GArray *polys);

Create a new VisuSurface object as defined by points and polys .

Parameters

label

a string.

 

points

a set of point coordinates.

[element-type VisuSurfacePoint]

polys

a set of polygons.

[element-type VisuSurfacePoly]

Returns

a newly allocated VisuSurface structure.


visu_surface_new_fromDefinition ()

VisuSurface *
visu_surface_new_fromDefinition (const gchar *label,
                                 const VisuSurfaceDefinition *definition);

Same as visu_surface_new(), mainly for language bindings.

Parameters

label

a string.

 

definition

Some points and polys.

 

Returns

a newly allocated VisuSurface structure.

Since: 3.8


visu_surface_loadFile ()

gboolean
visu_surface_loadFile (const char *file,
                       GList **surf,
                       GError **error);

This loads a surface file and set default material properties for it. See surf file specifications.

Parameters

file

target file to load ;

 

surf

a set of surfaces (location) ;.

[out][transfer full][element-type VisuSurface*]

error

a location to store errors.

 

Returns

TRUE in case of success, FALSE otherwise. Even in case of success error may have been set.


visu_surface_getResource ()

VisuSurfaceResource *
visu_surface_getResource (VisuSurface *surf);

This returns the resource of the surf .

Parameters

surf

the surface object ;

 

Returns

the resource of the surface or NULL, if i is invalid.

[transfer none]

Since: 3.7


visu_surface_setResource ()

gboolean
visu_surface_setResource (VisuSurface *surf,
                          VisuSurfaceResource *res);

This method is used to change the resource of a surface.

Parameters

surf

the surface object ;

 

res

the new resource.

 

Returns

TRUE if the resource is changed.


visu_surface_setMask ()

gboolean
visu_surface_setMask (VisuSurface *surface,
                      VisuPlaneSet *mask);

Use mask to hide portion of surface (when maskable, depending on their resources). Set mask to NULL to remove the mask.

Parameters

surface

a VisuSurface object.

 

mask

a VisuPlaneSet object.

[allow-none]

Returns

TRUE if mask is changed.

Since: 3.8


visu_surface_iter_poly_new ()

void
visu_surface_iter_poly_new (VisuSurface *surf,
                            VisuSurfaceIterPoly *iter);

Setup a new iter to iterate on drawn polygons of surf .

Parameters

surf

a VisuSurface object.

 

iter

a VisuSurfaceIterPoly structure.

[out caller-allocates]

Since: 3.8


visu_surface_iter_poly_next ()

void
visu_surface_iter_poly_next (VisuSurfaceIterPoly *iter);

Iterate to the next drawn polygon.

Parameters

iter

a VisuSurfaceIterPoly structure.

 

Since: 3.8


visu_surface_iter_poly_getZ ()

gboolean
visu_surface_iter_poly_getZ (const VisuSurfaceIterPoly *iter,
                             double *z,
                             const float mat[16]);

Retrieve the z value in the viewport basis of the drawn polygon defined by iter . If the polygon is not drawn, z is not computed.

Return: TRUE if polygon defined by iter is drawn and z is computed

Parameters

iter

a VisuSurfaceIterPoly structure.

 

z

a location to store double.

[out]

mat

a transformation matrix to go into viewport basis.

 

Since: 3.8


visu_surface_iter_poly_getVertices ()

void
visu_surface_iter_poly_getVertices (const VisuSurfaceIterPoly *iter,
                                    GArray *vertices);

Retrieve the position and normal of the point refered by iter .

Parameters

iter

a VisuSurfaceIterPoly structure.

 

vertices

an array to store the vertex coordinates and normals.

[element-type VisuSurfacePoint]

Since: 3.8


visu_surface_getPropertyFloat ()

float *
visu_surface_getPropertyFloat (VisuSurface *surf,
                               const gchar *name);

Some properties can be associated to the surfaces stored in surf . This method is used to retrieve floating point values properties.

Parameters

surf

a VisuSurface object ;

 

name

the name of the property to look for.

 

Returns

a table with the values if the property is found, NULL otherwise.


visu_surface_addPropertyFloat ()

float *
visu_surface_addPropertyFloat (VisuSurface *surf,
                               const gchar *name);

Some properties can be associated to the surfaces stored in surf . This method is add a new property.

Parameters

surf

a VisuSurface object ;

 

name

the name of the property to add.

 

Returns

a newly allocated array that can be populated.


visu_surface_getPropertyValueFloat ()

gboolean
visu_surface_getPropertyValueFloat (VisuSurface *surf,
                                    const gchar *name,
                                    float *value);

This method retrieves a float value stored as a property called name for the surface defined by its number idSurf .

Parameters

surf

a VisuSurface object ;

 

name

the name of the property to get the value from ;

 

value

a location to store the value.

 

Returns

TRUE if a value is indeed found.


visu_surface_checkConsistency ()

void
visu_surface_checkConsistency (VisuSurface *surf);

Check if all arrays in the structures are consistent (without overflow).

Parameters

surf

a VisuSurface object.

 

Types and Values

struct VisuSurface

struct VisuSurface;

All fields are private, use the access routines.


struct VisuSurfaceClass

struct VisuSurfaceClass {
  VisuObjectClass parent;
};

An opaque structure.

Members

VisuObjectClass parent;

the parent.

 

VISU_ERROR_ISOSURFACES

#define VISU_ERROR_ISOSURFACES visu_surface_getErrorQuark()

Internal function for error handling.


VISU_SURFACE_PROPERTY_POTENTIAL

#define VISU_SURFACE_PROPERTY_POTENTIAL "potential_values"

Flag used in an ASCII surf file to give informations on the value the surface is built from.


struct VisuSurfaceIterPoly

struct VisuSurfaceIterPoly {
  VisuSurface *surf;
  gboolean valid;
  guint i;

  /* Private */
  VisuSurfacePoints *points;
};

Structures used to iterate on polygons of surf .

Members

VisuSurface *surf;

the parent VisuSurface.

 

gboolean valid;

a flag TRUE, as long as the iterator is valid.

 

guint i;

the index of the current polygon.

 

VisuSurfacePoints *points;

the storage for polygons.

 

Since: 3.8

Property Details

The “resource” property

  “resource”                 VisuSurfaceResource *

resource.

Flags: Read / Write

Signal Details

The “masked” signal

void
user_function (VisuSurface *surf,
               gpointer     user_data)

Gets emitted when a surface is shown or hidden by a plane.

Parameters

surf

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: No Hooks

Since: 3.7