Bsoft 2.1.4
Bernard's software package
rwmodel.h File Reference

Header file for reading and writing atomic model files. More...

#include "View2.h"
#include "Bstring.h"
#include "Color.h"
#include <map>

Classes

class  Bcomptype
 
class  Blinktype
 
class  Bangletype
 
class  Bcomponent
 
class  Blink
 
class  Bpolygon
 
class  Bgroup
 
class  Bmodel
 

Macros

#define MAXLINK   10
 
#define _Bmodel_
 

Functions

Bmodelread_model (Bstring &filename)
 
Bmodelread_model (Bstring *file_list)
 
Bmodelread_model (Bstring &filename, Bstring &paramfile)
 
Bmodelread_model (Bstring *file_list, Bstring &paramfile)
 Reads model parameters. More...
 
int write_model (Bstring &filename, Bmodel *model)
 Writes model parameters. More...
 
int write_model (Bstring &filename, Bmodel *model, int split)
 Writes model parameters. More...
 
Bmodelmodel_add (Bmodel **model, string id)
 Adds a model to a linked list. More...
 
Bcomponentcomponent_add (Bcomponent **comp, string &id)
 Adds a component to a linked list. More...
 
Bcomponentcomponent_add (Bcomponent **comp, unsigned long number)
 
Blinklink_add (Blink **link, Bcomponent *comp1, Bcomponent *comp2, double length, double radius)
 Adds a component link to a linked list. More...
 
Blinklink_add (Blink **link, Bcomponent *comp1, Bcomponent *comp2)
 
int model_set_map_filenames (Bmodel *model, Bstring &mapfile)
 Sets all the map file names of selected models. More...
 
int model_set_type (Bmodel *model, Bstring &set_type)
 Reset the component types. More...
 
int model_change_type (Bmodel *model, Bstring &change_type)
 Change a component type name. More...
 
int model_check (Bmodel *model, Bstring path)
 Checks model properties. More...
 
Bmodelmodel_list_copy (Bmodel *model)
 Copies a model. More...
 
int component_list_kill (Bcomponent *comp)
 Deallocates memory for a list of components. More...
 
int comp_type_list_kill (Bcomptype *type)
 Deallocates memory for a list of component types. More...
 
int model_link_list_kill (Bmodel *model)
 Deallocates memory for a list of component links. More...
 
int link_kill (Blink **link_list, Bcomponent *comp, int i)
 Deletes a link. More...
 
int link_kill (Blink **link_list, Bcomponent *comp, Bcomponent *comp2)
 Deletes a link. More...
 
int poly_list_kill (Bpolygon *poly)
 Deallocates memory for a list of polygons. More...
 
int comp_associated_links_kill (Bcomponent *comp, Blink **link)
 Deallocates memory for links associated with a component. More...
 
int model_kill (Bmodel *model)
 Deallocates all memory in the list. More...
 
int model_associate (Bmodel *model, Bstring &associate_type, Bstring &associate_file)
 Associates a model file with a component type. More...
 
int model_associate_mass (Bmodel *model, Bstring &associate_type, double mass)
 Associates a mass with a component type. More...
 
int model_set_comptype_filenames (Bmodel *model, Bstring &filename)
 Sets the filenames of all selected component types to the given string. More...
 
long model_set_component_radius (Bmodel *model, double comprad)
 Set the display radius for all components to a specific value. More...
 

Detailed Description

Header file for reading and writing atomic model files.

Author
Bernard Heymann
Date
Created: 20060919
Modified: 20220929

Macro Definition Documentation

◆ _Bmodel_

#define _Bmodel_

◆ MAXLINK

#define MAXLINK   10

Function Documentation

◆ comp_associated_links_kill()

int comp_associated_links_kill ( Bcomponent comp,
Blink **  link 
)

Deallocates memory for links associated with a component.

Parameters
*compassociated componet.
**linkpointer to component link list.
Returns
int number of component links deallocated.

◆ comp_type_list_kill()

int comp_type_list_kill ( Bcomptype type)

Deallocates memory for a list of component types.

Parameters
*typecomponent type list.
Returns
int total number of component types.

◆ component_add() [1/2]

Bcomponent * component_add ( Bcomponent **  comp,
string &  id 
)

Adds a component to a linked list.

Parameters
**compcomponent list.
&idcomponent identifier.
Returns
Bcomponent new component.
The function allocates memory for a new component structure.
If the content of the pointer is null, the new structure is
the first in the list. Otherwise, the end of the list is found
and the new structure added to it.

◆ component_add() [2/2]

Bcomponent * component_add ( Bcomponent **  comp,
unsigned long  number 
)

◆ component_list_kill()

int component_list_kill ( Bcomponent comp)

Deallocates memory for a list of components.

Parameters
*compcomponent list.
Returns
int total number of components.

◆ link_add() [1/2]

Blink * link_add ( Blink **  link,
Bcomponent comp1,
Bcomponent comp2 
)

◆ link_add() [2/2]

Blink * link_add ( Blink **  link,
Bcomponent comp1,
Bcomponent comp2,
double  length,
double  radius 
)

Adds a component link to a linked list.

Parameters
**linkcomponent link list.
*comp1first component.
*comp2second component.
lengthlength of link.
radiusdisplay radius.
Returns
Bcomponent new component.
The function allocates memory for a new link structure.
If the content of the pointer is null, the new structure is
the first in the list. Otherwise, the end of the list is found
and the new structure added to it.

◆ link_kill() [1/2]

int link_kill ( Blink **  link_list,
Bcomponent comp,
Bcomponent comp2 
)

Deletes a link.

The link in the model link list is removed.
The associated references to the link in the component link arrays
are removed and the link arrays reorganized.
Parameters
**link_listpointer to list of links.
*compone component in the link.
*comp2second component in the link.
Returns
Bdistmat* new distance matrix structure.

◆ link_kill() [2/2]

int link_kill ( Blink **  link_list,
Bcomponent comp,
int  i 
)

Deletes a link.

The link in the model link list is removed.
The associated references to the link in the component link arrays
are removed and the link arrays reorganized.
Parameters
**link_listpointer to list of links.
*compone component in the link.
iindex for second component in link array of first component.
Returns
Bdistmat* new distance matrix structure.

◆ model_add()

Bmodel * model_add ( Bmodel **  model,
string  id 
)

Adds a model to a linked list.

Parameters
**modelmodel list.
idmodel identifier.
Returns
Bmodel* new model.
The function allocates memory for a new model structure.
If the content of the pointer is null, the new structure is
the first in the list. Otherwise, the end of the list is found
and the new structure added to it.

◆ model_associate()

int model_associate ( Bmodel model,
Bstring associate_type,
Bstring associate_file 
)

Associates a model file with a component type.

Parameters
*modelthe model.
&associate_typecomponent type.
&associate_filecomponent file name.
Returns
int number of types associated.
Model files can be coordinates or maps.

◆ model_associate_mass()

int model_associate_mass ( Bmodel model,
Bstring associate_type,
double  mass 
)

Associates a mass with a component type.

Parameters
*modelmodel list.
&associate_typecomponent type.
masscomponent type mass.
Returns
int number of types associated.

◆ model_change_type()

int model_change_type ( Bmodel model,
Bstring change_type 
)

Change a component type name.

Parameters
*modelmodel.
&change_typecomponent type.
Returns
int number of models.
Sets all the component types to the given string.

◆ model_check()

int model_check ( Bmodel model,
Bstring  path 
)

Checks model properties.

Parameters
*modelmodel.
pathsearch path to find map files.
Returns
int 0.

◆ model_kill()

int model_kill ( Bmodel model)

Deallocates all memory in the list.

Parameters
*modelmodel parameters.
Returns
int 0.

◆ model_link_list_kill()

int model_link_list_kill ( Bmodel model)

Deallocates memory for a list of component links.

Only the first model in the list is processed.
Parameters
*modelmodel.
Returns
int total number of component links.

◆ model_list_copy()

Bmodel * model_list_copy ( Bmodel model)

Copies a model.

Parameters
*modelmodel parameters.
Returns
Bmodel* model copy.
Copies all the models in a list.

◆ model_set_component_radius()

long model_set_component_radius ( Bmodel model,
double  comprad 
)

Set the display radius for all components to a specific value.

Parameters
*modelmodel parameters.
compradcomponent display radius.
Returns
long number of components selected.

◆ model_set_comptype_filenames()

int model_set_comptype_filenames ( Bmodel model,
Bstring filename 
)

Sets the filenames of all selected component types to the given string.

Parameters
*modelmodel parameters.
&filenamecomponent file name.
Returns
int number of component types set.
The image numbers are sequentially set as well.

◆ model_set_map_filenames()

int model_set_map_filenames ( Bmodel model,
Bstring mapfile 
)

Sets all the map file names of selected models.

Parameters
*modelmodel parameters.
&mapfilemap file name.
Returns
int 0.

◆ model_set_type()

int model_set_type ( Bmodel model,
Bstring set_type 
)

Reset the component types.

Parameters
*modelmodel.
&set_typecomponent type.
Returns
int number of models.
Sets all the component types to the given string.

◆ poly_list_kill()

int poly_list_kill ( Bpolygon poly)

Deallocates memory for a list of polygons.

Parameters
*polypolygon list.
Returns
int total number of polygons.

◆ read_model() [1/4]

Bmodel * read_model ( Bstring filename)

◆ read_model() [2/4]

Bmodel * read_model ( Bstring filename,
Bstring paramfile 
)

◆ read_model() [3/4]

Bmodel * read_model ( Bstring file_list)

◆ read_model() [4/4]

Bmodel * read_model ( Bstring file_list,
Bstring paramfile 
)

Reads model parameters.

Parameters
*file_listlist of model parameter file names.
&paramfileparameter file.
Returns
Bmodel* model parameters.

◆ write_model() [1/2]

int write_model ( Bstring filename,
Bmodel model 
)

Writes model parameters.

Parameters
&filenamemodel parameter file name.
*modelmodel parameters.
Returns
int number of models.

◆ write_model() [2/2]

int write_model ( Bstring filename,
Bmodel model,
int  split 
)

Writes model parameters.

Parameters
&filenamemodel parameter file name.
*modelmodel parameters.
splitnumber of digits for writing multiple models.
Returns
int number of models.