Bsoft  2.1.0
Bernard's software package
rwmodel.h
Go to the documentation of this file.
1 
9 #include "View.h"
10 #include "Bstring.h"
11 #include "Color.h"
12 
13 #ifndef _Bmodel_
14 #define MAXLINK 10 // Maximum number of links per component
15 
16 /************************************************************************
17 @Object: struct Bcomptype
18 @Description:
19  Model component type parameter structure.
20 @Features:
21  Reference to a model file, either atomic coordinates or a 3D map.
22  Number of components of this type.
23  Figure-of-merit.
24 *************************************************************************/
25 struct Bcomptype {
26  Bcomptype* next; // Next component type in list
27  Bstring id; // Component type identifier
28  int index; // Type index for reference in a distance matrix
29  Bstring fmod; // Model file name (molecule or map)
30  int num; // Image number in model or map file
31  int count; // Number of components
32  float mass; // Component mass
33  float fom; // Figure-of-merit
34  int sel; // Selection flag
35 } ;
36 
37 /************************************************************************
38 @Object: struct Bcomponent
39 @Description:
40  Model component parameter structure.
41 @Features:
42  Type which must be a valid component type.
43  Location.
44  Orientation.
45  Vector for use as force or displacement.
46  Radius.
47  Color.
48  Figure-of-merit.
49  Selection.
50 *************************************************************************/
51 struct Bcomponent {
52  Bcomponent* next; // Next component in list
53  Bstring id; // Component identifier
54  Bcomptype* type; // Component type pointer
55  Bcomponent* link[MAXLINK]; // Links to other components
56  Bcomponent* neighbor[MAXLINK]; // Neighboring components
57  int flag[MAXLINK]; // Flags for connectors
58  Vector3<float> loc; // Location coordinates (angstroms)
59  View view; // View: 3-value unit vector and angle (radians)
60  Vector3<float> vec; // Vector for use as force or displacement
61  Vector3<float> vel; // Vector for use as velocity
62  float radius; // Display radius
63  RGBA<float> color; // RGBA color
64  float density; // Component density or intensity
65  float fom; // Figure-of-merit
66  int sel; // Selection flag
67 } ;
68 
69 /************************************************************************
70 @Object: struct Blink
71 @Description:
72  Model link parameter structure.
73 @Features:
74  Link between components.
75  Link rotation angle for orientation.
76  Length.
77  Radius.
78  Color.
79  Figure-of-merit.
80  Selection.
81 *************************************************************************/
82 struct Blink {
83  Blink* next; // Next link in list
84  Bcomponent* comp[2]; // Linked components
85  float angle; // Rotation angle around the link
86  float length; // Link reference length
87  float radius; // Display radius
88  RGBA<float> color; // RGBA color
89  float fom; // Figure-of-merit
90  int sel; // Selection flag
91 } ;
92 
93 /************************************************************************
94 @Object: struct Bpolygon
95 @Description:
96  Model polygon parameter structure.
97 @Features:
98  List of components.
99  Polygon normal.
100  A flag to indicate if it is a closed polygon.
101 *************************************************************************/
102 struct Bpolygon {
104  int number; // Number of components
105  Bcomponent* comp[MAXLINK]; // List of components
106  Vector3<float> normal; // Vector normal to the polygon plane
107  int closed; // Flag to indicate a closed polygon
108  float fom; // Figure-of-merit
109  int sel; // Selection flag
110 } ;
111 
112 /************************************************************************
113 @Object: struct Bmodel
114 @Description:
115  Model parameter structure.
116 @Features:
117  Orientation parameters for each model.
118 *************************************************************************/
119 struct Bmodel {
120  Bmodel* next; // Next model in list
121  Bstring id; // Model identifier
122  Bstring type_id; // Type identifier
123  int hand; // Hand or enantiomorph
124  Bstring symmetry; // Symmetry label
125  Bstring fmap; // Density map file name
126  Bstring comment; // Model comment string
127  int img_num; // Image number in map file
128  float fom; // Figure-of-merit
129  int sel; // Selection flag
130  int split; // Flag to split into individual output files
131  Bcomptype* type; // Component type list
132  Bcomponent* comp; // Component list
133  Blink* link; // Link list
134  Bpolygon* poly; // Polygon list
135 } ;
136 
137 #define _Bmodel_
138 #endif
139 
140 /* Function prototypes */
141 Bmodel* read_model(Bstring& filename);
142 Bmodel* read_model(Bstring* file_list);
143 Bmodel* read_model(Bstring& filename, Bstring& paramfile);
144 Bmodel* read_model(Bstring* file_list, Bstring& paramfile);
145 int write_model(Bstring& filename, Bmodel* model);
147 Bmodel* model_init(const char* cid);
149 Bmodel* model_add(Bmodel** model, const char* cid);
150 Bmodel* model_add(Bmodel** model, Bmodel* model_nu);
153 Bcomponent* component_add(Bcomponent** comp, unsigned long number);
154 Blink* link_add(Blink** link, Bcomponent* comp1, Bcomponent* comp2, double length, double radius);
155 Blink* link_add(Blink** link, Bcomponent* comp1, Bcomponent* comp2);
156 int link_index(Bcomponent* comp, Bcomponent* comp2);
162 int model_set_type(Bmodel* model, Bstring& set_type);
163 int model_change_type(Bmodel* model, Bstring& change_type);
165 int model_check(Bmodel* model, Bstring path);
169 int component_type_copy(Bcomptype* fromct, Bcomptype* toct);
170 int component_copy(Bcomponent* fromcomp, Bcomponent* tocomp);
171 long component_count(Bcomponent* comp);
173 int link_copy(Blink* fromlink, Blink* tolink);
174 Blink* link_find(Blink* link, Bcomponent* comp1, Bcomponent* comp2);
175 int component_kill(Bcomponent* comp);
177 int comp_type_kill(Bcomptype* type);
178 int comp_type_list_kill(Bcomptype* type);
180 int link_kill(Blink** link_list, Bcomponent* comp, int i);
181 int link_kill(Blink** link_list, Bcomponent* comp, Bcomponent* comp2);
182 int poly_list_kill(Bpolygon* poly);
183 int comp_associated_links_kill(Bcomponent* comp, Blink** link);
184 int model_kill(Bmodel* model);
185 int model_associate(Bmodel* model, Bstring& associate_type, Bstring& associate_file);
186 int model_associate_mass(Bmodel* model, Bstring& associate_type, double mass);
188 long model_set_component_radius(Bmodel* model, double comprad);
189 long model_set_density(Bmodel* model, double density);
190 long model_set_fom(Bmodel* model, double fom);
191 
192 
comp_type_kill
int comp_type_kill(Bcomptype *type)
Deallocates memory for one component type.
Definition: rwmodel.cpp:915
model_associate_mass
int model_associate_mass(Bmodel *model, Bstring &associate_type, double mass)
Associates a mass with a component type.
Definition: rwmodel.cpp:1190
Bmodel::fom
float fom
Definition: rwmodel.h:128
Bcomponent::next
Bcomponent * next
Definition: rwmodel.h:52
model_check
int model_check(Bmodel *model, Bstring path)
Checks model properties.
Definition: rwmodel.cpp:595
Bcomponent
Definition: rwmodel.h:51
Bpolygon::next
Bpolygon * next
Definition: rwmodel.h:103
Bmodel::hand
int hand
Definition: rwmodel.h:123
Bcomptype::fmod
Bstring fmod
Definition: rwmodel.h:29
Bcomponent::loc
Vector3< float > loc
Definition: rwmodel.h:58
Bcomptype::sel
int sel
Definition: rwmodel.h:34
Bstring
Definition: Bstring.h:29
model_count_component_types
int model_count_component_types(Bmodel *model)
Counts the number of components for each type.
Definition: rwmodel.cpp:571
Bcomponent::id
Bstring id
Definition: rwmodel.h:53
model_change_type
int model_change_type(Bmodel *model, Bstring &change_type)
Change a component type name.
Definition: rwmodel.cpp:548
model_component_count
int model_component_count(Bmodel *model)
Counts the total number of components.
Definition: rwmodel.cpp:638
component_add
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Definition: rwmodel.cpp:270
Bcomptype
Definition: rwmodel.h:25
Vector3< float >
link_add
Blink * link_add(Blink **link, Bcomponent *comp1, Bcomponent *comp2, double length, double radius)
Adds a component link to a linked list.
Definition: rwmodel.cpp:318
Bmodel::next
Bmodel * next
Definition: rwmodel.h:120
Bcomptype::index
int index
Definition: rwmodel.h:28
link_copy
int link_copy(Blink *fromlink, Blink *tolink)
Copies all elements from one link to another.
Definition: rwmodel.cpp:839
model_copy
Bmodel * model_copy(Bmodel *model)
Copies a model.
Definition: rwmodel.cpp:688
Bpolygon::normal
Vector3< float > normal
Definition: rwmodel.h:106
View
Definition: View.h:26
comp_type_list_kill
int comp_type_list_kill(Bcomptype *type)
Deallocates memory for a list of component types.
Definition: rwmodel.cpp:929
Bcomptype::mass
float mass
Definition: rwmodel.h:32
Bmodel::link
Blink * link
Definition: rwmodel.h:133
length
double length(vector< T > v)
Definition: Vector3.h:530
link_find
Blink * link_find(Blink *link, Bcomponent *comp1, Bcomponent *comp2)
Finds a link in a link list.
Definition: rwmodel.cpp:860
Bmodel::fmap
Bstring fmap
Definition: rwmodel.h:125
model_init
Bmodel * model_init(Bstring &id)
Initializes a model structure.
Definition: rwmodel.cpp:147
component_list_kill
int component_list_kill(Bcomponent *comp)
Deallocates memory for a list of components.
Definition: rwmodel.cpp:894
model_add_type_by_filename
Bcomptype * model_add_type_by_filename(Bmodel *model, Bstring &filename, int num)
Add a type to a model if the type with the given file name does not exist already.
Definition: rwmodel.cpp:437
Color.h
Classes for color objects.
Bpolygon::closed
int closed
Definition: rwmodel.h:107
Bmodel::comp
Bcomponent * comp
Definition: rwmodel.h:132
link_index
int link_index(Bcomponent *comp, Bcomponent *comp2)
Returns the index of a linked component.
Definition: rwmodel.cpp:381
model_list_copy
Bmodel * model_list_copy(Bmodel *model)
Copies a model.
Definition: rwmodel.cpp:660
Bcomponent::vec
Vector3< float > vec
Definition: rwmodel.h:60
Bcomponent::vel
Vector3< float > vel
Definition: rwmodel.h:61
model_add_type_by_id_and_filename
Bcomptype * model_add_type_by_id_and_filename(Bmodel *model, Bstring &id, Bstring &filename, int num)
Add a type to a model if the type with the given id and file name does not exist already.
Definition: rwmodel.cpp:468
Bmodel::id
Bstring id
Definition: rwmodel.h:121
model_set_density
long model_set_density(Bmodel *model, double density)
Set the density of selected components to a specific value.
Definition: rwmodel.cpp:1268
model_kill
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1127
Bmodel::split
int split
Definition: rwmodel.h:130
model_get_type
Bcomptype * model_get_type(Bmodel *model, Bstring &id)
Return the type corresponding to an identifier.
Definition: rwmodel.cpp:494
Bmodel::sel
int sel
Definition: rwmodel.h:129
model_set_fom
long model_set_fom(Bmodel *model, double fom)
Set the FOM of selected components to a specific value.
Definition: rwmodel.cpp:1289
Bpolygon::sel
int sel
Definition: rwmodel.h:109
Bstring.h
Header file for the string class.
Bcomponent::flag
int flag[MAXLINK]
Definition: rwmodel.h:57
Bmodel
Definition: rwmodel.h:119
Bmodel::poly
Bpolygon * poly
Definition: rwmodel.h:134
component_kill
int component_kill(Bcomponent *comp)
Deallocates memory for one component.
Definition: rwmodel.cpp:880
Bcomponent::color
RGBA< float > color
Definition: rwmodel.h:63
model_set_map_filenames
int model_set_map_filenames(Bmodel *model, Bstring &mapfile)
Sets all the map file names of selected models.
Definition: rwmodel.cpp:398
write_model
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Definition: rwmodel.cpp:92
RGBA< float >
Bmodel::img_num
int img_num
Definition: rwmodel.h:127
component_type_add
Bcomptype * component_type_add(Bcomptype **type, Bstring &id)
Adds a component type to a linked list.
Definition: rwmodel.cpp:233
Bpolygon::comp
Bcomponent * comp[MAXLINK]
Definition: rwmodel.h:105
Bcomponent::view
View view
Definition: rwmodel.h:59
Bcomptype::num
int num
Definition: rwmodel.h:30
Bcomponent::fom
float fom
Definition: rwmodel.h:65
Bpolygon
Definition: rwmodel.h:102
Bcomponent::type
Bcomptype * type
Definition: rwmodel.h:54
Bcomptype::id
Bstring id
Definition: rwmodel.h:27
model
Bmodel * model
Definition: bshow.cpp:34
Bpolygon::fom
float fom
Definition: rwmodel.h:108
View.h
View object.
poly_list_kill
int poly_list_kill(Bpolygon *poly)
Deallocates memory for a list of polygons.
Definition: rwmodel.cpp:1073
model_add
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
Definition: rwmodel.cpp:181
model_add_type_by_id
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
Definition: rwmodel.cpp:414
read_model
Bmodel * read_model(Bstring &filename)
Definition: rwmodel.cpp:29
Bpolygon::number
int number
Definition: rwmodel.h:104
component_find
Bcomponent * component_find(Bcomponent *comp, Bstring &id)
Finds a component in a component list.
Definition: rwmodel.cpp:825
Bmodel::type
Bcomptype * type
Definition: rwmodel.h:131
Bcomptype::next
Bcomptype * next
Definition: rwmodel.h:26
comp_associated_links_kill
int comp_associated_links_kill(Bcomponent *comp, Blink **link)
Deallocates memory for links associated with a component.
Definition: rwmodel.cpp:1095
model_set_type
int model_set_type(Bmodel *model, Bstring &set_type)
Reset the component types.
Definition: rwmodel.cpp:519
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.
Definition: rwmodel.cpp:1222
Bcomponent::radius
float radius
Definition: rwmodel.h:62
component_type_copy
int component_type_copy(Bcomptype *fromct, Bcomptype *toct)
Copies all elements from one component to another.
Definition: rwmodel.cpp:766
component_copy
int component_copy(Bcomponent *fromcomp, Bcomponent *tocomp)
Copies all elements from one component to another.
Definition: rwmodel.cpp:786
model_set_component_radius
long model_set_component_radius(Bmodel *model, double comprad)
Set the display radius for all components to a specific value.
Definition: rwmodel.cpp:1247
model_link_list_kill
int model_link_list_kill(Bmodel *model)
Deallocates memory for a list of component links.
Definition: rwmodel.cpp:953
MAXLINK
#define MAXLINK
Definition: rwmodel.h:14
Bcomptype::fom
float fom
Definition: rwmodel.h:33
model_associate
int model_associate(Bmodel *model, Bstring &associate_type, Bstring &associate_file)
Associates a model file with a component type.
Definition: rwmodel.cpp:1160
Bcomponent::link
Bcomponent * link[MAXLINK]
Definition: rwmodel.h:55
Bcomponent::density
float density
Definition: rwmodel.h:64
component_count
long component_count(Bcomponent *comp)
Counts the total number of components.
Definition: rwmodel.cpp:808
Bcomptype::count
int count
Definition: rwmodel.h:31
link_kill
int link_kill(Blink **link_list, Bcomponent *comp, int i)
Deletes a link.
Definition: rwmodel.cpp:991
Bcomponent::neighbor
Bcomponent * neighbor[MAXLINK]
Definition: rwmodel.h:56
Bmodel::comment
Bstring comment
Definition: rwmodel.h:126
Bmodel::symmetry
Bstring symmetry
Definition: rwmodel.h:124
Bmodel::type_id
Bstring type_id
Definition: rwmodel.h:122
Bcomponent::sel
int sel
Definition: rwmodel.h:66