![]() |
![]() |
![]() |
V_Sim API - Reference Manual | ![]() |
---|---|---|---|---|
#define ISOSURFACES_PROPERTY_POTENTIAL typedef SurfaceResource; struct SurfacesOrder_struct; typedef SurfacesOrder; struct Surfaces_struct; typedef Surfaces; Surfaces* isosurfacesNew (int bufferSize); void isosurfacesAllocate (Surfaces *surf, int nsurf, int npolys, int npoints); void isosurfacesFree (Surfaces *surf); void isosurfacesFree_resource (SurfaceResource *res); gboolean isosurfacesHide (Surfaces *surf, Plane **planes); gboolean isosurfacesRemove (Surfaces *surf, int idSurf); void isosurfacesDuplicate (int totalList, int simpleBlockList, VisuData *dataObj, gboolean reorder); gboolean isosurfacesLoad_file (const char *file, Surfaces **surf, GError **error); void isosurfacesDraw_surfaces (int openGLId, Surfaces *surf[], SurfacesOrder *order); void isosurfacesSet_box (Surfaces *surf, double box[6]); void isosurfacesCopy_resource (SurfaceResource *res, SurfaceResource *res_old); void isosurfacesAddSurfaces (Surfaces *surf, int nsurf, int npolys, int npoints); void isosurfacesResourcesInit (); void isoSurfacesSet_fitToBox (VisuData *data, Surfaces *surf); void isosurfacesSet_showAll (Surfaces *surf, gboolean show); void isosurfacesSet_surfaceResource (Surfaces *surf, int surf_index, SurfaceResource *res); gboolean isosurfacesSet_drawIntra (gboolean status); double* isosurfacesGet_box (Surfaces *surf); int isosurfacesGet_nbSurfaces (Surfaces *surf); int isosurfacesGet_surfaceId (Surfaces *surf, int i); int isosurfacesGet_surfacePosition (Surfaces *surf, int id); gboolean isosurfacesGet_surfaceRendered (Surfaces *surf, int surf_index); SurfaceResource* isosurfacesGet_surfaceResource (Surfaces *surf, int surf_index); const gchar* isosurfacesGet_surfaceName (Surfaces *surf, int surf_index); int* isosurfacesGet_surfaceSortedById (Surfaces *surf); SurfaceResource* isosurfacesGet_resourceFromName (const gchar *surf_name, gboolean *nw); int isosurfacesGet_newId (Surfaces *surf); gboolean isosurfacesGet_drawIntra (); float* isosurfacesGet_floatProperty (Surfaces *surf, const gchar *name); float* isosurfacesAdd_floatProperty (Surfaces *surf, const gchar *name); gboolean isosurfacesGet_floatPropertyValue (Surfaces *surf, int idSurf, const gchar *name, float *value); SurfacesOrder* isosurfacesOrder_new (); void isosurfacesOrder_free (SurfacesOrder *order); void isosurfacesOrder_polygons (SurfacesOrder *order, Surfaces *surf[]); #define VISU_ERROR_ISOSURFACES void isosurfacesInit (); void isosurfacesCheck_consistency (Surfaces *surf); GQuark isosurfacesGet_quark ();
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.
#define ISOSURFACES_PROPERTY_POTENTIAL "potential_values"
Flag used in an ASCII surf file to give informations on the value the surface is built from.
typedef struct SurfaceResource_struct SurfaceResource;
Short name to adress SurfaceResource_struct objects.
struct SurfacesOrder_struct;
An opaque structure to store the order of drawn polygons when surfaces are involved.
typedef struct SurfacesOrder_struct SurfacesOrder;
Short name to adress SurfacesOrder_struct objects.
struct Surfaces_struct;
This structure stores surfaces. Several surfaces are stored in a single structure for improved performences.
Surfaces* isosurfacesNew (int bufferSize);
Create a new (with unallocated internal arrays) structure to store surfaces. The buffer size is used to store other values than the position and the normal on each point.
|
an integer. |
Returns : |
a newly allocated Surfaces structure. |
void isosurfacesAllocate (Surfaces *surf, int nsurf, int npolys, int npoints);
Allocate internal arrays to store surfaces having the given description.
|
a Surfaces structure ; |
|
the number of surfaces to store ; |
|
the number of polygons (in total) ; |
|
the total number of vertices. |
void isosurfacesFree (Surfaces *surf);
Free all memory associated to the given surfaces.
|
a Surfaces structure. |
void isosurfacesFree_resource (SurfaceResource *res);
This method frees the memory used by the given resource.
|
an allocated SurfaceResource object to be freed. |
gboolean isosurfacesHide (Surfaces *surf, Plane **planes);
Change the visibility of polygons stored in surf
, following the masking
scheme defined by the given list of planes
(see Plane).
|
a Surfaces object ; |
|
an array of planes (NULL terminated). |
Returns : |
TRUE if the surfaces should be rebuilt (see isosurfacesDraw_surfaces() ).
|
gboolean isosurfacesRemove (Surfaces *surf, int idSurf);
Remove from memory all polygons from the given surface.
|
a Surfaces object ; |
|
the id of the surf to remove. |
Returns : |
TRUE if the surface list is reduced to zero (and surf
to be freed).
|
void isosurfacesDuplicate (int totalList, int simpleBlockList, VisuData *dataObj, gboolean reorder);
Duplicate the list simpleBlockList
using the extension of the
given dataObj
.
|
an OpenGL identifier for the global list to create ; |
|
an OpenGL identifier for the list with the surfaces in the primitive cell ; |
|
the corresponding VisuData object ; |
|
if TRUE the blocks are drawn from back to front. |
gboolean isosurfacesLoad_file (const char *file, Surfaces **surf, GError **error);
This loads a surface file and set default material properties for it. See surf file specifications.
|
target file to load ; |
|
a set of surfaces (location) ; |
|
a location to store errors. |
Returns : |
TRUE in case of success, FALSE otherwise. Even in case of success
error may have been set.
|
void isosurfacesDraw_surfaces (int openGLId, Surfaces *surf[], SurfacesOrder *order);
Rebuild each visible surface's list. The order in which to draw the surfaces
is given in the order
argument. If the resource 'isosurfaces_drawIntra' is TRUE
then, the interior of the surfaces is drawn as color inverse.
|
an id for the OpenGL list ; |
|
an array of Surfaces object, must be NULL terminated. |
|
a SurfacesOrder object. |
void isosurfacesSet_box (Surfaces *surf, double box[6]);
Copy the given box
to the box of surfaces.
|
a Surfaces object ; |
|
a box definition in reduced coordinates. |
void isosurfacesCopy_resource (SurfaceResource *res, SurfaceResource *res_old);
This method copies all values from res_old
to res
.
|
an allocated SurfaceResource object to receive values ; |
|
a SurfaceResource to read the values from. |
void isosurfacesAddSurfaces (Surfaces *surf, int nsurf, int npolys, int npoints);
Change the allocation of internal arrays to store the additional surfaces with the given description.
|
a Surfaces structure ; |
|
the number of surfaces to add ; |
|
the number of polygons to add ; |
|
the number of vertices to add. |
void isosurfacesResourcesInit ();
Internal routine called by isosurfacesInit()
at startup. Do not use
it.
void isoSurfacesSet_fitToBox (VisuData *data, Surfaces *surf);
This method changes the position of all vertices in the structure
to match the box description given in data
.
|
a VisuData object ; |
|
a set of surfaces. |
void isosurfacesSet_showAll (Surfaces *surf, gboolean show);
Shows or hides all surfaces and check their "draw" status in the panel accordingly.
|
a Surfaces object ; |
|
TRUE to show all surfaces, FALSE to hide them. |
void isosurfacesSet_surfaceResource (Surfaces *surf, int surf_index, SurfaceResource *res);
This method is used to change the resource of a surface.
|
the surface object ; |
|
the number of the surface ; |
|
the new resource. |
gboolean isosurfacesSet_drawIntra (gboolean status);
Set if the interiors of surfaces are drawn with a colour inverse or not.
|
a boolean. |
Returns : |
TRUE if calling routine should redraw the surfaces with
isosurfacesDraw_surfaces() .
|
double* isosurfacesGet_box (Surfaces *surf);
Get the box of the surfaces.
|
a Surfaces object. |
Returns : |
6 floats, private, read-only. |
int isosurfacesGet_nbSurfaces (Surfaces *surf);
Retrieves th number of surfaces stired in a given surf
object.
|
the surface object. |
Returns : |
number of surfaces. |
int isosurfacesGet_surfaceId (Surfaces *surf, int i);
This returns for the given i
its id information.
|
the surface object ; |
|
the number of the surface. |
Returns : |
the id of the surface or 0, if i is invalid.
|
int isosurfacesGet_surfacePosition (Surfaces *surf, int id);
This returns for the given id
its number.
|
the surface object ; |
|
the id of the surface. |
Returns : |
the number of the surface or 0, if id is invalid.
|
gboolean isosurfacesGet_surfaceRendered (Surfaces *surf, int surf_index);
This returns for the given surf_index
its visibility.
|
the surface object ; |
|
the number of the surface. |
Returns : |
the visibility of the surface or FALSE, if surf_index is invalid.
|
SurfaceResource* isosurfacesGet_surfaceResource (Surfaces *surf, int surf_index);
This returns for the given surf_index
its resource information.
|
the surface object ; |
|
the number of the surface. |
Returns : |
the resource of the surface or NULL, if surf_index is invalid.
|
const gchar* isosurfacesGet_surfaceName (Surfaces *surf, int surf_index);
This returns for the given surf_index
its name
(1 <= surf_index <= surfaces_number)
|
the surface object ; |
|
the number of the surface. |
Returns : |
the name of the surface or empty name or NULL, if surf_index is invalid.
|
int* isosurfacesGet_surfaceSortedById (Surfaces *surf);
This returns the surface numbers sorted using their ids.
|
the surface object. |
Returns : |
a newly allocated array with surface numbers. |
SurfaceResource* isosurfacesGet_resourceFromName (const gchar *surf_name, gboolean *nw);
This returns the resource information matching the given surf_name
. If
the resource doesn't exist, it is created and new
is set to TRUE. If the given
name (surf_name
) is NULL, then a new resource is created, but it is not stored
and will not be shared by surfaces.
|
the name of the surface (can be NULL) ; |
|
a location to store a boolean value (can be NULL). |
Returns : |
the resource (created or retrieved). |
int isosurfacesGet_newId (Surfaces *surf);
This returns a unique id to create a new surface.
|
the surface object. |
Returns : |
a value suitable to create a new surface in this set of surfaces. |
gboolean isosurfacesGet_drawIntra ();
Retrieve if the interiors of surfaces are drawn with a colour inverse or not.
Returns : |
TRUE if the interior is painted in colour inverse. |
float* isosurfacesGet_floatProperty (Surfaces *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.
|
a Surfaces object ; |
|
the name of the property to look for. |
Returns : |
a table with the values if the property is found, NULL otherwise. |
float* isosurfacesAdd_floatProperty (Surfaces *surf, const gchar *name);
Some properties can be associated to the surfaces stored in surf
.
This method is add a new property.
|
a Surfaces object ; |
|
the name of the property to add. |
Returns : |
a newly allocated array that can be populated. |
gboolean isosurfacesGet_floatPropertyValue (Surfaces *surf, int idSurf, 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
.
|
a Surfaces object ; |
|
a surface number ; |
|
the name of the property to get the value from ; |
|
a location to store the value. |
Returns : |
TRUE if a value is indeed found. |
SurfacesOrder* isosurfacesOrder_new ();
Create an object to hold the order in which the surfaces must be
drawn. See isosurfacesOrder_polygons()
to set this object.
Returns : |
a newly created SurfacesOrder object without any values. |
void isosurfacesOrder_free (SurfacesOrder *order);
Free memory used by a SurfacesOrder object.
|
the object to be freed. |
void isosurfacesOrder_polygons (SurfacesOrder *order, Surfaces *surf[]);
Re-orders the polygons in back to front order. This function should be called everytime a redraw is needed.
|
the description of the polygons order ; |
|
an array of Surfaces object, must be NULL terminated. |
void isosurfacesInit ();
Method used to initialised the surface handling, should not be called.
void isosurfacesCheck_consistency (Surfaces *surf);
Check if all arrays in the structures are consistent (without overflow).
|
a Surfaces object. |