| Bsoft 2.0.5 Bernard's software package

tcltk_bmodel.cpp
Go to the documentation of this file.
1
9 // Tk must be included before anything else to remedy symbol conflicts
10 #include <tk.h>
11
12 #include "tcltk_bmodel.h"
13 #include "rwmodel.h"
14 #include "rwimg.h"
15 #include "model_create.h"
16 #include "model_map.h"
17 #include "model_select.h"
18 #include "model_mask.h"
19 #include "model_color.h"
20 #include "model_views.h"
21 #include "mg_processing.h"
22 #include "Vector3.h"
23 #include "linked_list.h"
24 #include "Color.h"
25 #include "utilities.h"
26
27 // Declaration of global variables
28 extern int verbose; // Level of output to the screen
29 extern Bimage* imglist;
30 extern Bmodel* model;
31 extern Bproject* project;
32
33 // Internal function prototypes
34 Tcl_Obj* do_find(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
35 Tcl_Obj* do_get(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
36 int do_set(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
37 int do_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
38 int do_delete_non_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
39 int do_components_to_particles(Bmodel* model, Bproject* project, int objc, Tcl_Obj *CONST objv[]);
40 int do_extract_segments(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
41 int do_create_shell(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
42 Tcl_Obj* do_component_type(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
43 Tcl_Obj* do_component(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
44 Tcl_Obj* do_link(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
45
46 Tcl_Obj* comptype_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
47 Tcl_Obj* comptype_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
48 Tcl_Obj* comptype_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
49 Tcl_Obj* comptype_list(Bmodel* model);
50 Tcl_Obj* comptype_create_update(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
51 Tcl_Obj* comptype_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
52 Tcl_Obj* comptype_deselect(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
53 Tcl_Obj* comptype_first_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
54
55 Tcl_Obj* component_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
56 Tcl_Obj* component_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
57 Tcl_Obj* component_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
58 Tcl_Obj* component_location(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
59 Tcl_Obj* component_distance(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
60 Tcl_Obj* component_img_coords(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
61 Tcl_Obj* component_fom(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
62 Tcl_Obj* component_radius(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
63 Tcl_Obj* component_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
64 Tcl_Obj* component_move(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
65 Tcl_Obj* component_create(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
66 Tcl_Obj* component_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
67 Tcl_Obj* component_color(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
68
69 Tcl_Obj* link_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
70 Tcl_Obj* link_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
71 Tcl_Obj* link_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
72 Tcl_Obj* link_img_coords(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
73 Tcl_Obj* link_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
74 Tcl_Obj* link_create(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
75 Tcl_Obj* link_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[]);
76
120 int model_processing(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
121 {
122 // verbose = 967;
123
124 Tcl_ResetResult(interp);
125
126 if ( objc < 2 ) {
127 Tcl_AppendResult(interp, "wrong # args", (char *)NULL);
128 return TCL_ERROR;
129 }
130
131 Bstring action = Tcl_GetStringFromObj(objv[1], NULL);
132 if ( verbose & VERB_DEBUG )
133 cout << "DEBUG model_processing: Action: " << action << " (" << action.length() << ")" << endl;
134
135 Tcl_Obj* returnObj = Tcl_NewObj();
136
137 char string[128] = " ";
138 Tcl_SetStringObj(returnObj, string, 1);
139
140 Bstring filename, id("1");
141
142 time_t ti = time(NULL);
143
144 if ( action == "create" ) {
145 model = model_from_images(imglist);
146 id = "Model:" + model->id;
147 Tcl_SetStringObj(returnObj, (char *)id.c_str(), id.length());
148 } else if ( action == "exists" ) {
149 if ( model ) Tcl_SetIntObj(returnObj, 1);
150 else Tcl_SetIntObj(returnObj, 0);
151 } else if ( action == "read" ) {
152 if ( objc < 2 ) {
153 Tcl_AppendResult(interp, "No file name given!", (char *)NULL);
154 return TCL_ERROR;
155 }
156 filename = Tcl_GetStringFromObj(objv[2], NULL);
157 if ( verbose & VERB_DEBUG )
158 cout << "DEBUG model_processing: File name: " << filename << " (" << filename.length() << ")" << endl;
159 if ( model ) model_kill(model);
160 model = read_model(filename);
161 Tcl_SetStringObj(returnObj, (char *)model->id.c_str(), model->id.length());
162 } else if ( action == "write" ) {
163 if ( objc < 2 ) {
164 Tcl_AppendResult(interp, "No file name given!", (char *)NULL);
165 return TCL_ERROR;
166 }
167 filename = Tcl_GetStringFromObj(objv[2], NULL);
168 if ( verbose & VERB_DEBUG )
169 cout << "DEBUG BmodelCmd: File name: " << filename << " (" << filename.length() << ")" << endl;
170 if ( !model ) {
171 Tcl_AppendResult(interp, "No model in memory!", (char *)NULL);
172 return TCL_ERROR;
173 }
174 model->comment += "\n# Written from Bshow\n# " + Bstring(asctime(localtime(&ti))) + "\n";
175 write_model(filename, model);
176 } else if ( action == "kill" ) {
177 model_kill(model);
178 } else if ( action == "find" ) {
179 returnObj = do_find(model, objc, objv);
180 } else if ( action == "get" ) {
181 returnObj = do_get(model, objc, objv);
182 } else if ( action == "set" ) {
183 do_set(model, objc, objv);
184 } else if ( action == "delete_non_selected" ) {
185 do_delete_non_selected(model, objc, objv);
186 } else if ( action == "delete" ) {
187 do_delete(model, objc, objv);
188 } else if ( action == "components_to_particles" ) {
189 do_components_to_particles(model, project, objc, objv);
190 } else if ( action == "extract_segments" ) {
191 do_extract_segments(model, objc, objv);
192 } else if ( action == "create_shell" ) {
193 do_create_shell(model, objc, objv);
194 } else if ( action == "comptype" ) {
195 returnObj = do_component_type(model, objc, objv);
196 } else if ( action == "component" ) {
197 returnObj = do_component(model, objc, objv);
198 } else if ( action == "link" ) {
199 returnObj = do_link(model, objc, objv);
200 } else {
201 cerr << "Error: Action " << action << " not recognized!" << endl;
202 }
203
204 Tcl_SetObjResult(interp, returnObj);
205
206 return TCL_OK;
207 }
208
209 Tcl_Obj* do_find(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
210 {
211 Tcl_Obj* returnObj = Tcl_NewObj();
212
213 int number(0);
214 Bstring name;
215 Bmodel* mp = model;
216
217 if ( objc > 2 ) name = Tcl_GetStringFromObj(objv[2], NULL);
218 if ( objc > 3 ) Tcl_GetIntFromObj(NULL, objv[3], &number);
219
220 for ( mp = model; mp; mp = mp->next ) {
221 if ( mp->fmap.contains(name) || name.contains(mp->fmap) )
222 if ( mp->img_num == number ) break;
223 }
224
225 if ( !mp ) return returnObj;
226
227 Bstring bstr = mp->fmap + "::Model:" + mp->id + " ";
228
229 Tcl_AppendToObj(returnObj, bstr.c_str(), bstr.length());
230
231 return returnObj;
232 }
233
234 Tcl_Obj* do_get(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
235 {
236 Tcl_Obj* returnObj = Tcl_NewObj();
237
238 int err(0);
239 Bmodel* mp = model;
240 Bstring bstr, imgtype;
241
242 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
243
244 Bstring property = Tcl_GetStringFromObj(objv[3], NULL);
245
246 Bstring id = item.post(':');
247 id = id.remove(' ');
248 item = item.pre(':');
249
250 if ( verbose & VERB_DEBUG ) {
251 cout << "DEBUG do_get: Item: " << item << " (" << item.length() << ")" << endl;
252 cout << "DEBUG do_get: ID: " << id << " (" << id.length() << ")" << endl;
253 cout << "DEBUG do_get: Property: " << property << " (" << property.length() << ")" << endl;
254 }
255
256 if ( item.contains("all" ) ) {
257 mp = model;
258 } else if ( item.contains("Model") ) {
259 for ( mp = model; mp && mp->id != id; mp = mp->next ) ;
260 if ( !mp ) err++;
261 } else {
262 cerr << "Error in do_get: item \"" << item << "\" not supported!" << endl;
263 return returnObj;
264 }
265
266 if ( !mp || property.empty() ) {
267 Tcl_SetIntObj(returnObj, 0);
268 } else if ( property == "id" ) {
269 Tcl_SetStringObj(returnObj, (char *)mp->id.c_str(), mp->id.length());
270 } else if ( property == "selection" ) {
271 Tcl_SetIntObj(returnObj, mp->sel);
272 } else if ( property == "map" ) {
273 Tcl_SetStringObj(returnObj, (char *)mp->fmap.c_str(), mp->fmap.length());
274 } else if ( property == "number" ) {
275 Tcl_SetIntObj(returnObj, mp->img_num);
276 } else if ( property == "image_filenames" ) {
277 for ( mp = model; mp; mp = mp->next ) {
278 if ( mp->fmap.length() && mp->fmap != "?" ) {
279 bstr = mp->fmap + "::Model:" + mp->id + " ";
280 Tcl_AppendToObj(returnObj, bstr.c_str(), bstr.length());
281 // cout << bstr << endl;
282 }
283 }
284 // } else if ( property == "types" ) {
285 // returnObj = component_type_list(model);
286 } else {
287 cerr << "Error in do_get: Property " << property << " not recognized!" << endl;
288 }
289
290 return returnObj;
291 }
292
293 int set_component_radius(Bmodel* model, float radius)
294 {
295 if ( radius < 0.001 ) return 0;
296
297 Bcomponent* comp = NULL;
298
299 if ( verbose & VERB_DEBUG )
300 cout << "DEBUG set_component_radius: radius = " << radius << endl;
301
302 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel )
303 comp->radius = radius;
304
305 return 0;
306 }
307
308 int set_link_radius(Bmodel* model, float radius)
309 {
310 if ( radius < 0.001 ) return 0;
311
312 Blink* link = NULL;
313
314 if ( verbose & VERB_DEBUG )
315 cout << "DEBUG set_link_radius: radius = " << radius << endl;
316
317 for ( link = model->link; link; link = link->next ) if ( link->sel )
318 link->radius = radius;
319
320 return 0;
321 }
322
323 int do_set(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
324 {
325 if ( !model ) return 0;
326
327 int err(0);
328 int rtn(0);
329 double radius(1);
330 Bstring calc_views;
331 Bmodel* mp = model;
332
333 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
334
335 Bstring property = Tcl_GetStringFromObj(objv[3], NULL);
336
337 Bstring id = item.post(':');
338 id = id.remove(' ');
339 item = item.pre(':');
340
341 if ( verbose & VERB_DEBUG ) {
342 cout << "DEBUG do_set: Item: " << item << " (" << item.length() << ")" << endl;
343 cout << "DEBUG do_set: ID: " << id << " (" << id.length() << ")" << endl;
344 cout << "DEBUG do_set: Property: " << property << " (" << property.length() << ")" << endl;
345 }
346
347 if ( item.contains("all" ) ) {
348 mp = model;
349 } else if ( item.contains("Model") ) {
350 for ( mp = model; mp && mp->id != id; mp = mp->next ) ;
351 if ( !mp ) err++;
352 } else {
353 cerr << "Error in do_get: item \"" << item << "\" not supported!" << endl;
354 return rtn;
355 }
356
357 if ( property == "id" ) {
358 if ( objc > 4 )
359 mp->id = Tcl_GetStringFromObj(objv[4], NULL);
360 } else if ( property == "map" ) {
361 if ( objc > 4 )
362 mp->fmap = Tcl_GetStringFromObj(objv[4], NULL);
363 if ( objc > 5 )
364 Tcl_GetIntFromObj(NULL, objv[5], &mp->img_num);
365 } else if ( property == "number" ) {
366 if ( objc > 4 )
367 Tcl_GetIntFromObj(NULL, objv[4], &mp->img_num);
368 } else if ( property == "compradius" ) {
369 if ( objc > 5 ) {
370 component_radius(mp, objc, objv);
371 } else if ( objc > 4 ) {
372 Tcl_GetDoubleFromObj(NULL, objv[4], &radius);
373 set_component_radius(mp, radius);
374 }
375 } else if ( property == "linkradius" ) {
376 if ( objc > 4 ) {
377 Tcl_GetDoubleFromObj(NULL, objv[4], &radius);
378 set_link_radius(mp, radius);
379 }
380 } else if ( property == "views" ) {
381 if ( objc > 4 )
382 calc_views = Tcl_GetStringFromObj(objv[4], NULL);
383 model_calculate_views(mp, calc_views);
384 } else {
385 cerr << "Error in do_set: Property " << property << " not recognized!" << endl;
386 }
387
388 return rtn;
389 }
390
391 int do_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
392 {
393 if ( !model ) return 0;
394
395 model_link_list_kill(model);
396 component_list_kill(model->comp);
397
398 model->comp = NULL;
399 model->link = NULL;
400
401 return 0;
402 }
403
404 int do_delete_non_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
405 {
406 model_delete_non_selected(&model);
407
408 return 0;
409 }
410
411 int do_components_to_particles(Bmodel* model, Bproject* project, int objc, Tcl_Obj *CONST objv[])
412 {
413 if ( !project ) return 0;
414 if ( project->select < 1 ) return 0;
415
416 Bstring rec_id, filename2;
417 Breconstruction* rec = project->rec;
418
419 Bimage* p = NULL;
420
421 Bstring base = model->fmap.base();
422 for ( p = imglist; p; p = p->next ) {
423 filename2 = p->file_name();
424 if ( filename2.base() == base ) break;
425 }
426
427 if ( !p ) return 0;
428
429 if ( !project->rec ) {
430 rec_id = "1";
431 rec = reconstruction_add(&project->rec, rec_id);
432 rec->frec = p->file_name();
433 }
434
435 int id(0);
436 Bcomponent* comp = NULL;
437 Bparticle* part = NULL;
438
439 particle_kill(rec->part);
440 rec->part = NULL;
441
442 if ( rec->box_size.volume() < 1 ) rec->box_size = Vector3<float>(10,10,10);
443 if ( rec->bad_radius < 1 ) rec->bad_radius = 5;
444 if ( rec->voxel_size < 0.001 ) rec->voxel_size = p->sampling()[0];
445
446 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
447 id = comp->id.integer();
448 part = particle_add(&project->rec->part, id);
449 part->group = comp->type->id.integer();
450 part->loc[0] = comp->loc[0]/p->sampling()[0] + p->image->origin()[0];
451 part->loc[1] = comp->loc[1]/p->sampling()[1] + p->image->origin()[1];
452 part->loc[2] = comp->loc[2]/p->sampling()[2] + p->image->origin()[2];
453 part->ori = rec->box_size/2;
454 part->view[2] = 1;
455 part->fom[0] = comp->fom;
456 part->sel = comp->sel;
457 }
458
459 return 0;
460 }
461
462 int do_extract_segments(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
463 {
464 if ( !model ) return 0;
465
466 Bstring filename, filename2;
467 int multi_level(0);
468
469 if ( objc > 2 ) filename = Tcl_GetStringFromObj(objv[2], NULL);
470 if ( objc > 3 ) Tcl_GetIntFromObj(NULL, objv[3], &multi_level);
471
472 Bimage* p = NULL;
473
474 Bstring base = model->fmap.base();
475 for ( p = imglist; p; p = p->next ) {
476 filename2 = p->file_name();
477 if ( filename2.base() == base ) break;
478 }
479
480 if ( !p ) {
481 cerr << "Error: No map found!" << endl;
482 return 0;
483 }
484
485 Bimage* pseg = img_extract_segments_using_model(p, model, multi_level);
486
487 write_img(filename, pseg, 0);
488
489 delete pseg;
490
491 return 0;
492 }
493
494 int do_create_shell(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
495 {
496 if ( !model ) return 0;
497
498 int n(0), number(0), twod(0);
499 double radius(0), distance(0);
500
501 if ( objc > 2 ) Tcl_GetIntFromObj(NULL, objv[2], &number);
502 if ( objc > 3 ) Tcl_GetDoubleFromObj(NULL, objv[3], &radius);
503 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &distance);
504 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &twod);
505
506 if ( number > 0 ) n++;
507 if ( radius > 0 ) n++;
508 if ( distance > 0 ) n++;
509
510 Bmodel* numod = NULL;
511 Bcomponent* comp = NULL;
512 Bcomponent* nucomp;
513
514 if ( n > 1 ) {
515 if ( twod )
516 numod = model_create_circle(radius, 0, distance);
517 else
518 numod = model_create_shell(number, radius, distance);
519 if ( model->comp ) model_add(&model, numod);
520 else {
521 for ( nucomp = numod->comp; nucomp; nucomp = nucomp->next ) {
522 comp = component_add(&comp, nucomp->id);
523 if ( !model->comp ) model->comp = comp;
524 component_copy(nucomp, comp);
525 }
526 }
527 }
528
529 model_kill(numod);
530
531 return 0;
532 }
533
534
535 /*
536 Component type interface syntax:
537 Bmodel comptype [item] [action] [params]
538 Actions:
539 count [n] counts the number of component types
540 countselected [n] counts the number of selected component types
541 ids [n] returns the identifiers of component types
542 list returns a list of component types
543 create [tid] [m] [fn] [in] [mn] creates or updates a component type
544 select [t] sets the selection for a component type
545 deselect [t] unsets the selection for a component type
546 firstselected returns first selected component type
547 Parameters:
548 n image number
549 tid type id
550 mn model number
551 m mass
552 fn file name
553 in image number
554 t type id list for selection/deselection
555 */
556 Tcl_Obj* do_component_type(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
557 {
558 Tcl_Obj* returnObj = NULL;
559
560 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
561
562 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
563 if ( verbose & VERB_DEBUG )
564 cout << "DEBUG do_component_type: action: " << action << " (" << action.length() << ")" << endl;
565
566 Bstring id = item.post(':');
567 id = id.remove(' ');
568 item = item.pre(':');
569
570 Bmodel* mp = model;
571
572 if ( item.contains("Model") )
573 for ( mp = model; mp && mp->id != id; mp = mp->next ) ;
574
575 if ( model && !mp ) {
576 cerr << "Error in do_component_type: item \"" << item << "\" not supported!" << endl;
577 returnObj = Tcl_NewObj();
578 return returnObj;
579 }
580
581 if ( action == "count" ) {
582 returnObj = comptype_count(mp, objc, objv);
583 } else if ( action == "countselected" ) {
584 returnObj = comptype_count_selected(mp, objc, objv);
585 } else if ( action == "ids" ) {
586 returnObj = comptype_ids(mp, objc, objv);
587 } else if ( action == "list" ) {
588 returnObj = comptype_list(mp);
589 } else if ( action == "create" ) {
590 returnObj = comptype_create_update(mp, objc, objv);
591 } else if ( action == "select" ) {
592 returnObj = comptype_select(mp, objc, objv);
593 } else if ( action == "deselect" ) {
594 returnObj = comptype_deselect(mp, objc, objv);
595 } else if ( action == "firstselected" ) {
596 returnObj = comptype_first_selected(mp, objc, objv);
597 } else {
598 cerr << "Error: Action " << action << " not recognized!" << endl;
599 }
600
601 action = 0;
602
603 return returnObj;
604 }
605
606 Tcl_Obj* comptype_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
607 {
608 Tcl_Obj* returnObj = Tcl_NewObj();
609
610 int nct(0);
611
612 Bcomptype* ct;
613
614 for ( ct = model->type; ct; ct = ct->next ) nct++;
615
616 Tcl_SetIntObj(returnObj, nct);
617
618 return returnObj;
619 }
620
621 Tcl_Obj* comptype_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
622 {
623 Tcl_Obj* returnObj = Tcl_NewObj();
624
625 int nct(0);
626
627 Bcomptype* ct;
628
629 for ( ct = model->type; ct; ct = ct->next ) if ( ct->sel ) nct++;
630
631 Tcl_SetIntObj(returnObj, nct);
632
633 return returnObj;
634 }
635
636 Tcl_Obj* comptype_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
637 {
638 Tcl_Obj* returnObj = Tcl_NewObj();
639
640 char string[MAXLINELEN] = "";
641
642 Bcomptype* ct;
643
644 for ( ct = model->type; ct; ct = ct->next ) if ( ct->sel ) {
645 sprintf(string, " %ld", ct->id.integer());
646 Tcl_AppendToObj(returnObj, string, strlen(string));
647 }
648
649 return returnObj;
650 }
651
652 Tcl_Obj* comptype_list(Bmodel* model)
653 {
654 Tcl_Obj* returnObj = Tcl_NewObj();
655
656 char string[MAXLINELEN];
657 Bcomptype* ct;
658
659 model_count_component_types(model);
660
661 for ( ct = model->type; ct; ct = ct->next ) {
662 sprintf(string, " %s %s %d %d %g %g %d", ct->id.c_str(), ct->fmod.c_str(),
663 ct->num, ct->count, ct->mass, ct->fom, ct->sel);
664 Tcl_AppendToObj(returnObj, string, strlen(string));
665 }
666
667 return returnObj;
668 }
669
670 Tcl_Obj* comptype_create_update(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
671 {
672 Tcl_Obj* returnObj = Tcl_NewObj();
673
674 int num(-1);
675 double mass(0);
676 Bstring type_id("VER");
677 Bcomptype* ct;
678 Bstring filename;
679
680 if ( objc > 4 ) type_id = Tcl_GetStringFromObj(objv[4], NULL);
681 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &mass);
682 if ( objc > 6 ) filename = Tcl_GetStringFromObj(objv[6], NULL);
683 if ( objc > 7 ) Tcl_GetIntFromObj(NULL, objv[7], &num);
684
685 ct = model_add_type_by_id(model, type_id);
686 if ( mass > 0 ) ct->mass = mass;
687 if ( filename.length() && filename != "?" ) ct->fmod = filename;
688 if ( num >= 0 ) ct->num = num;
689
690 filename = 0;
691
692 return returnObj;
693 }
694
695 Tcl_Obj* comptype_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
696 {
697 Tcl_Obj* returnObj = Tcl_NewObj();
698
699 Bstring selection_string;
700 Bstring* typelist, *type;
701 Bcomptype* ct = NULL;
702
703 if ( objc > 4 ) selection_string = Tcl_GetStringFromObj(objv[4], NULL);
704
705 if ( selection_string == "all" ) {
706 for ( ct = model->type; ct; ct = ct->next ) ct->sel = 1;
707 } else {
708 typelist = selection_string.split(",");
709 for ( ct = model->type; ct; ct = ct->next ) {
710 for ( type = typelist; type; type = type->next )
711 if ( ct->id == *type ) ct->sel = 1;
712 }
713 }
714
715 selection_string = 0;
716
717 return returnObj;
718 }
719
720 Tcl_Obj* comptype_deselect(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
721 {
722 Tcl_Obj* returnObj = Tcl_NewObj();
723
724 Bstring selection_string;
725 Bstring* typelist, *type;
726 Bcomptype* ct = NULL;
727
728 if ( objc > 4 ) selection_string = Tcl_GetStringFromObj(objv[4], NULL);
729
730 if ( selection_string == "all" ) {
731 for ( ct = model->type; ct; ct = ct->next ) ct->sel = 1;
732 } else {
733 typelist = selection_string.split(",");
734 for ( ct = model->type; ct; ct = ct->next ) {
735 for ( type = typelist; type; type = type->next )
736 if ( ct->id == *type ) ct->sel = 0;
737 }
738 }
739
740 selection_string = 0;
741
742 return returnObj;
743 }
744
745 Tcl_Obj* comptype_first_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
746 {
747 Tcl_Obj* returnObj = Tcl_NewObj();
748
749 char string[MAXLINELEN];
750 Bcomptype* ct = NULL;
751 Bcomptype* ctsel = NULL;
752
753 for ( ct = model->type; ct && !ctsel; ct = ct->next )
754 if ( ct->sel ) ctsel = ct;
755
756 if ( ct ) {
757 sprintf(string, " %s %s %d %d %g %g %d", ct->id.c_str(), ct->fmod.c_str(),
758 ct->num, ct->count, ct->mass, ct->fom, ct->sel);
759 } else {
760 sprintf(string, " VER ? 0 0 1 1 1");
761 }
762
763 Tcl_SetStringObj(returnObj, string, strlen(string));
764
765 return returnObj;
766 }
767
768
769 /*
770 Component interface syntax:
771 Bmodel component [item] [action] [params]
772 Actions:
773 count [n] counts the number of components
774 countselected [n] counts the number of selected components
775 ids [n] [f] returns the identifiers of components
776 img_coords [n] [id] returns one component's coordinates in the image
777 img_coords [n] [f] returns a list of component coordinates in the image
778 location [id] [n] returns the location of a component
779 fom [id] [n] returns the FOM of a component
780 radius [id] [n] returns the radius of a component
781 select [x] [y] [z] [n] returns the component identifier at the given location
782 move [id] [n] [dx] [dy] [dz] updates a component location by the given vector
783 create [x] [y] [z] [n] creates a new component at the given location
784 delete [id] [n] deletes a component
785 color [id [n] colors a component
786 Parameters:
787 id component identifier
788 x x location
789 y y location
790 z z location
791 n image number
792 f FOM cutoff
793 dx change in x
794 dy change in y
795 dz change in z
796 */
797 Tcl_Obj* do_component(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
798 {
799 Tcl_Obj* returnObj = NULL;
800
801 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
802
803 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
804 if ( verbose & VERB_DEBUG )
805 cout << "DEBUG do_component: action: " << action << " (" << action.length() << ")" << endl;
806
807 Bstring id = item.post(':');
808 id = id.remove(' ');
809 item = item.pre(':');
810
811 Bmodel* mp = model;
812
813 if ( item.contains("Model") )
814 for ( mp = model; mp && mp->id != id; mp = mp->next ) ;
815
816 if ( model && !mp ) {
817 cerr << "Error in do_component: item \"" << item << "\" not supported!" << endl;
818 cerr << "ID = " << id << endl;
819 // for ( mp = model; mp; mp = mp->next ) cerr << mp->id << endl;
820 returnObj = Tcl_NewObj();
821 return returnObj;
822 }
823
824 // cout << mp->id << tab << action << endl;
825
826 if ( action == "count" ) {
827 returnObj = component_count(mp, objc, objv);
828 } else if ( action == "countselected" ) {
829 returnObj = component_count_selected(mp, objc, objv);
830 } else if ( action == "ids" ) {
831 returnObj = component_ids(mp, objc, objv);
832 } else if ( action == "location" ) {
833 returnObj = component_location(mp, objc, objv);
834 } else if ( action == "distance" ) {
835 returnObj = component_distance(mp, objc, objv);
836 } else if ( action == "img_coords" ) {
837 returnObj = component_img_coords(mp, objc, objv);
838 } else if ( action == "fom" ) {
839 returnObj = component_fom(mp, objc, objv);
840 } else if ( action == "radius" ) {
841 returnObj = component_radius(mp, objc, objv);
842 } else if ( action == "select" ) {
843 returnObj = component_select(mp, objc, objv);
844 } else if ( action == "move" ) {
845 returnObj = component_move(mp, objc, objv);
846 } else if ( action == "create" ) {
847 returnObj = component_create(mp, objc, objv);
848 } else if ( action == "delete" ) {
849 returnObj = component_delete(mp, objc, objv);
850 } else if ( action == "color" ) {
851 returnObj = component_color(mp, objc, objv);
852 } else {
853 returnObj = Tcl_NewObj();
854 cerr << "Error: Action " << action << " not recognized!" << endl;
855 }
856
857 return returnObj;
858 }
859
860 Tcl_Obj* component_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
861 {
862 Tcl_Obj* returnObj = Tcl_NewObj();
863
864 if ( !model ) return returnObj;
865
866 int ncomp(0);
867
868 Bcomponent* comp = NULL;
869
870 for ( comp = model->comp; comp; comp = comp->next ) ncomp++;
871
872 Tcl_SetIntObj(returnObj, ncomp);
873
874 return returnObj;
875 }
876
877 Tcl_Obj* component_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
878 {
879 Tcl_Obj* returnObj = Tcl_NewObj();
880
881 if ( !model ) return returnObj;
882
883 int ncomp(0);
884
885 Bcomponent* comp = NULL;
886
887 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) ncomp++;
888
889 Tcl_SetIntObj(returnObj, ncomp);
890
891 return returnObj;
892 }
893
894 Tcl_Obj* component_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
895 {
896 Tcl_Obj* returnObj = Tcl_NewObj();
897
898 if ( !model ) return returnObj;
899
900 double fom_cut(0);
901 char string[MAXLINELEN] = "";
902
903 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
904
905 Bcomponent* comp = NULL;
906
907 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->fom >= fom_cut ) {
908 sprintf(string, " %ld", comp->id.integer());
909 Tcl_AppendToObj(returnObj, string, strlen(string));
910 }
911
912 return returnObj;
913 }
914
915 Tcl_Obj* component_location(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
916 {
917 Tcl_Obj* returnObj = Tcl_NewObj();
918
919 if ( !model ) return returnObj;
920
921 int id;
922 char string[MAXLINELEN] = "";
923
924 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
925
926 Bcomponent* comp = NULL;
927
928 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
929
930 if ( comp ) {
931 sprintf(string, "%f %f %f", comp->loc[0], comp->loc[1], comp->loc[2]);
932 Tcl_SetStringObj(returnObj, string, strlen(string));
933 }
934
935 return returnObj;
936 }
937
938 Tcl_Obj* component_distance(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
939 {
940 Tcl_Obj* returnObj = Tcl_NewObj();
941
942 if ( !model ) return returnObj;
943
944 int id1, id2;
945 double dist(0);
946
947 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id1);
948 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id2);
949
950 Bcomponent* comp = NULL;
951 Bcomponent* comp1 = NULL;
952 Bcomponent* comp2 = NULL;
953
954 for ( comp = model->comp; comp && ( !comp1 || !comp2 ); comp = comp->next ) {
955 if ( comp->id.integer() == id1 ) comp1 = comp;
956 if ( comp->id.integer() == id2 ) comp2 = comp;
957 }
958
959 if ( comp1 && comp2 ) dist = comp1->loc.distance(comp2->loc);
960
961 Tcl_SetDoubleObj(returnObj, dist);
962
963 return returnObj;
964 }
965
966 Tcl_Obj* component_img_coords(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
967 {
968 Tcl_Obj* returnObj = Tcl_NewObj();
969
970 if ( !model ) return returnObj;
971
972 Bimage* p = NULL;
973
974 // cout << imglist->file_name() << endl;
975
976 Bstring base = model->fmap.base();
977 Bstring filename2;
978 for ( p = imglist; p; p = p->next ) {
979 filename2 = p->file_name();
980 if ( filename2.base() == base ) break;
981 }
982
983 if ( !p ) {
984 cerr << "Error: Image " << model->fmap << " not found!" << endl;
985 return returnObj;
986 }
987
988 int id(0), n(model->img_num);
989 double fom_cut(0);
990 char string[MAXLINELEN] = "";
991
992 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
993
994 if ( fom_cut >= 1 ) id = (int) fom_cut;
995
996 Bcomponent* comp = NULL;
997 Bstring hexcol;
998
999 if ( id > 0 ) {
1000 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1001 if ( comp ) {
1002 hexcol = comp->color.hex();
1003 sprintf(string, " %ld %g %g %g %g %s", comp->id.integer(),
1004 comp->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1005 comp->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1006 comp->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1007 comp->radius/p->sampling()[0], hexcol.c_str());
1008 Tcl_AppendToObj(returnObj, string, strlen(string));
1009 }
1010 } else {
1011 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->fom >= fom_cut ) {
1012 hexcol = comp->color.hex();
1013 sprintf(string, " %ld %g %g %g %g %s", comp->id.integer(),
1014 comp->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1015 comp->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1016 comp->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1017 comp->radius/p->sampling()[0], hexcol.c_str());
1018 Tcl_AppendToObj(returnObj, string, strlen(string));
1019 }
1020 // } else {
1021 // sprintf(string, " -1");
1022 // Tcl_AppendToObj(returnObj, string, strlen(string));
1023 }
1024
1025 return returnObj;
1026 }
1027
1028 Tcl_Obj* component_fom(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1029 {
1030 Tcl_Obj* returnObj = Tcl_NewObj();
1031
1032 if ( !model ) return returnObj;
1033
1034 int id, set(0);
1035 double fom = 1;
1036
1037 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
1038 if ( objc > 5 ) {
1039 Tcl_GetDoubleFromObj(NULL, objv[5], &fom);
1040 set = 1;
1041 }
1042
1043 Bcomponent* comp = NULL;
1044
1045 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1046
1047 if ( comp ) {
1048 if ( set ) comp->fom = fom;
1049 else fom = comp->fom;
1050 }
1051
1052 Tcl_SetDoubleObj(returnObj, fom);
1053
1054 return returnObj;
1055 }
1056
1057 Tcl_Obj* component_radius(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1058 {
1059 Tcl_Obj* returnObj = Tcl_NewObj();
1060
1061 if ( !model ) return returnObj;
1062
1063 int id(-1), set(0);
1064 double rad(1);
1065
1066 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
1067 if ( objc > 5 ) {
1068 Tcl_GetDoubleFromObj(NULL, objv[5], &rad);
1069 set = 1;
1070 }
1071
1072 Bcomponent* comp = NULL;
1073
1074 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1075
1076 if ( comp ) {
1077 if ( set ) comp->radius = rad;
1078 else rad = comp->radius;
1079 }
1080
1081 Tcl_SetDoubleObj(returnObj, rad);
1082
1083 return returnObj;
1084 }
1085
1086 Tcl_Obj* component_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1087 {
1088 Tcl_Obj* returnObj = Tcl_NewObj();
1089
1090 if ( !model ) return returnObj;
1091
1092 int id(0);
1093 double x(0), y(0), z(0);
1094 Bstring selection_string, types, ids;
1095 double d, dmin(1000000);
1096 Vector3<float> loc;
1097 Bcomponent* comp = NULL;
1098 Bcomponent* compsel = NULL;
1099
1100 if ( objc > 4 ) selection_string = Tcl_GetStringFromObj(objv[4], NULL);
1101
1102 if ( verbose & VERB_DEBUG )
1103 cout << "DEBUG component_select: Model " << model->id << ": selection_string=" << selection_string << endl;
1104
1105 if ( selection_string.length() < 1 ) {
1106 return returnObj;
1107 } else if ( selection_string == "none" ) {
1108 model_unset_selection(model);
1109 } else if ( selection_string == "all" ) {
1110 model_reset_selection(model);
1111 } else if ( selection_string == "types" ) {
1112 if ( objc > 5 ) {
1113 types = "%.";
1114 model_select(model, types);
1115 types = "%";
1116 types += Tcl_GetStringFromObj(objv[5], NULL);
1117 types = types.replace(' ', ',');
1118 // cout << "types = " << types << endl;
1119 model_select(model, types);
1120 }
1121 } else if ( selection_string == "id" ) {
1122 if ( objc > 5 ) {
1123 model_unset_selection(model);
1124 ids = "@";
1125 ids += Tcl_GetStringFromObj(objv[5], NULL);
1126 ids = ids.replace(' ', ',');
1127 // cout << "ids = " << ids << endl;
1128 model_select(model, ids);
1129 }
1130 } else {
1131 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
1132 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
1133 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
1134 loc = Vector3<float>(x, y, z);
1135 // cout << "location for selection = " << loc[0] << " " << loc[1] << " " << loc[2] << endl;
1136 for ( comp = model->comp; comp; comp = comp->next ) {
1137 d = loc.distance(comp->loc);
1138 if ( dmin > d ) {
1139 dmin = d;
1140 compsel = comp;
1141 }
1142 }
1143 if ( compsel && ( dmin <= compsel->radius ) ) {
1144 id = compsel->id.integer();
1145 if ( compsel->sel ) compsel->sel = 0; // Toggle the selection
1146 else compsel->sel = 1;
1147 }
1148 }
1149
1150 Tcl_SetIntObj(returnObj, id);
1151
1152 return returnObj;
1153 }
1154
1155 Tcl_Obj* component_move(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1156 {
1157 Tcl_Obj* returnObj = Tcl_NewObj();
1158
1159 if ( !model ) return returnObj;
1160
1161 int id(0);
1162 double dx(0), dy(0), dz(0);
1163
1164 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
1165 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &dx);
1166 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &dy);
1167 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &dz);
1168
1169 Bcomponent* comp = NULL;
1170 Vector3<float> d(dx, dy, dz);
1171
1172 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1173
1174 if ( comp ) comp->loc += d;
1175
1176 Tcl_SetIntObj(returnObj, id);
1177
1178 return returnObj;
1179 }
1180
1181 Tcl_Obj* component_create(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1182 {
1183 Tcl_Obj* returnObj = Tcl_NewObj();
1184
1185 if ( !model ) return returnObj;
1186
1187 int i(0);
1188 double x(0), y(0), z(0);
1189
1190 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
1191 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
1192 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
1193
1194 Bstring id("0");
1195 Bstring tid("VER");
1196 Bcomponent* comp = NULL;
1197 Bcomptype* ct = NULL;
1198
1199 for ( i=0, comp = model->comp; comp; comp = comp->next )
1200 if ( i < comp->id.integer() ) i = comp->id.integer();
1201
1202 id = Bstring(++i, "%d");
1203 comp = component_add(&model->comp, id);
1204 for ( ct = model->type; ct && ct->sel < 1; ct = ct->next ) ;
1205 if ( ct ) comp->type = ct;
1206 else comp->type = model_add_type_by_id(model, tid);
1207 comp->loc = Vector3<float>(x, y, z);
1208 comp->fom = 1;
1209 comp->sel = 1;
1210
1211 if ( verbose & VERB_DEBUG )
1212 cout << "DEBUG component_create: id=" << i << endl;
1213
1214 Tcl_SetIntObj(returnObj, i);
1215
1216 return returnObj;
1217 }
1218
1219 Tcl_Obj* component_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1220 {
1221 Tcl_Obj* returnObj = Tcl_NewObj();
1222
1223 if ( !model ) return returnObj;
1224
1225 int id(0);
1226
1227 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
1228
1229 Bcomponent* comp = NULL;
1230
1231 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1232
1233 if ( comp ) {
1234 comp_associated_links_kill(comp, &model->link);
1235 comp->id = 0;
1236 comp->type = NULL;
1237 remove_item((char **)&model->comp, (char *)comp, sizeof(Bcomponent));
1238 }
1239
1240 Tcl_SetIntObj(returnObj, id);
1241
1242 return returnObj;
1243 }
1244
1245 Tcl_Obj* component_color(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1246 {
1247 Tcl_Obj* returnObj = Tcl_NewObj();
1248
1249 if ( !model ) return returnObj;
1250
1251 int id(0);
1252 RGBA<float> color;
1253 Bstring selection_string, color_string;
1254
1255 if ( objc > 4 ) selection_string = Tcl_GetStringFromObj(objv[4], NULL);
1256 if ( objc > 5 ) {
1257 color_string = Tcl_GetStringFromObj(objv[5], NULL);
1258 color = RGBA<float>(color_string);
1259 }
1260
1261 Bcomponent* comp = NULL;
1262
1263 if ( verbose & VERB_DEBUG )
1264 cout << "DEBUG component_color: Select=" << selection_string << " color=" << color_string << endl;
1265
1266 if ( selection_string.length() < 1 || selection_string == "none" ) {
1267 return returnObj;
1268 } else if ( selection_string == "all" ) {
1269 model_color_uniformly(model, color);
1270 } else if ( selection_string == "selected" ) {
1271 model_color_selected_types(model, color);
1272 } else if ( selection_string == "density" ) {
1273 model_color_by_density(model);
1274 } else if ( selection_string == "fom" ) {
1275 model_color_by_fom(model);
1276 } else {
1277 color_string = Tcl_GetStringFromObj(objv[4], NULL);
1278 color = RGBA<float>(color_string);
1279 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id);
1280 if ( id > 0 ) {
1281 for ( comp = model->comp; comp && comp->id.integer() != id; comp = comp->next ) ;
1282 if ( comp ) comp->color = color;
1283 } else {
1284 for ( comp = model->comp; comp; comp = comp->next )
1285 comp->color = color;
1286 }
1287 }
1288
1289 Tcl_SetIntObj(returnObj, id);
1290
1291 return returnObj;
1292 }
1293
1294
1295
1296 /*
1297 Link interface syntax:
1298 Bmodel link [action] [params]
1299 Actions:
1300 count [n] counts the number of links
1301 countselected [n] counts the number of selected links
1302 ids [n] [f] returns the link component identifiers
1303 img_coords [n] [id1] [id2] returns one pair of link coordinates in the image
1304 img_coords [n] [f] returns a list of link coordinates in the image
1305 select [x] [y] [z] [n] [r] returns the link component identifiers at the given location
1306 create [id1] [id2] [n] creates a new link between two components
1307 delete [id1] [id2] [n] deletes a link between two components
1308 Parameters:
1309 id1 first link component identifier
1310 id2 second link component identifier
1311 x x location
1312 y y location
1313 z z location
1314 n image number
1315 f FOM cutoff
1316 r radius to select a link
1317 */
1318 Tcl_Obj* do_link(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1319 {
1320 Tcl_Obj* returnObj = NULL;
1321
1322 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
1323
1324 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
1325 if ( verbose & VERB_DEBUG )
1326 cout << "DEBUG do_link: action: " << action << " (" << action.length() << ")" << endl;
1327
1328 Bstring id = item.post(':');
1329 id = id.remove(' ');
1330 item = item.pre(':');
1331
1332 Bmodel* mp = model;
1333
1334 if ( item.contains("Model") )
1335 for ( mp = model; mp && mp->id != id; mp = mp->next ) ;
1336
1337 if ( model && !mp ) {
1338 cerr << "Error in do_link: item \"" << item << "\" not supported!" << endl;
1339 returnObj = Tcl_NewObj();
1340 return returnObj;
1341 }
1342
1343 if ( action == "count" ) {
1344 returnObj = link_count(mp, objc, objv);
1345 } else if ( action == "countselected" ) {
1346 returnObj = link_count_selected(mp, objc, objv);
1347 } else if ( action == "ids" ) {
1348 returnObj = link_ids(mp, objc, objv);
1349 } else if ( action == "img_coords" ) {
1350 returnObj = link_img_coords(mp, objc, objv);
1351 } else if ( action == "select" ) {
1352 returnObj = link_select(mp, objc, objv);
1353 } else if ( action == "create" ) {
1354 returnObj = link_create(mp, objc, objv);
1355 } else if ( action == "delete" ) {
1356 returnObj = link_delete(mp, objc, objv);
1357 } else {
1358 returnObj = Tcl_NewObj();
1359 cerr << "Error: Action " << action << " not recognized!" << endl;
1360 }
1361
1362 return returnObj;
1363 }
1364
1365 Tcl_Obj* link_count(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1366 {
1367 Tcl_Obj* returnObj = Tcl_NewObj();
1368
1369 if ( !model ) return returnObj;
1370
1371 int nlink(0);
1372
1373 Blink* link = NULL;
1374
1375 for ( link = model->link; link; link = link->next ) nlink++;
1376
1377 Tcl_SetIntObj(returnObj, nlink);
1378
1379 return returnObj;
1380 }
1381
1382 Tcl_Obj* link_count_selected(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1383 {
1384 Tcl_Obj* returnObj = Tcl_NewObj();
1385
1386 if ( !model ) return returnObj;
1387
1388 int nlink(0);
1389
1390 Blink* link = NULL;
1391
1392 for ( link = model->link; link; link = link->next ) if ( link->sel ) nlink++;
1393
1394 Tcl_SetIntObj(returnObj, nlink);
1395
1396 return returnObj;
1397 }
1398
1399 Tcl_Obj* link_ids(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1400 {
1401 Tcl_Obj* returnObj = Tcl_NewObj();
1402
1403 if ( !model ) return returnObj;
1404
1405 double fom_cut(0);
1406 char string[MAXLINELEN] = "";
1407
1408 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
1409
1410 Blink* link = NULL;
1411
1412 for ( link = model->link; link; link = link->next )
1413 if ( link->comp[0]->fom >= fom_cut && link->comp[1]->fom >= fom_cut ) {
1414 sprintf(string, " %ld %ld", link->comp[0]->id.integer(), link->comp[1]->id.integer());
1415 Tcl_AppendToObj(returnObj, string, strlen(string));
1416 }
1417
1418 return returnObj;
1419 }
1420
1421 Tcl_Obj* link_img_coords(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1422 {
1423 Tcl_Obj* returnObj = Tcl_NewObj();
1424
1425 if ( !model ) return returnObj;
1426
1427 Bimage* p = NULL;
1428
1429 Bstring base = model->fmap.base();
1430 Bstring filename2;
1431 for ( p = imglist; p; p = p->next ) {
1432 filename2 = p->file_name();
1433 if ( filename2.base() == base ) break;
1434 }
1435
1436 if ( !p ) {
1437 cerr << "Error: Image " << model->fmap << " not found!" << endl;
1438 return returnObj;
1439 }
1440
1441
1442 int id1(0), id2(0), n(model->img_num);
1443 double fom_cut(0);
1444 char string[MAXLINELEN] = "";
1445
1446 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
1447
1448 if ( fom_cut >= 1 ) {
1449 id1 = (int) fom_cut;
1450 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id2);
1451 }
1452
1453 Blink* link = NULL;
1454 Bstring hexcol;
1455
1456 if ( id1 > 0 && id2 > 0 ) {
1457 for ( link = model->link; link; link = link->next )
1458 if ( ( link->comp[0]->id.integer() == id1 && link->comp[1]->id.integer() == id2 ) ||
1459 ( link->comp[0]->id.integer() == id2 && link->comp[1]->id.integer() == id1 ) ) break;
1460 if ( link ) {
1461 hexcol = link->color.hex();
1462 sprintf(string, " %g %g %g %g %g %g %g %s",
1463 link->comp[0]->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1464 link->comp[0]->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1465 link->comp[0]->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1466 link->comp[1]->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1467 link->comp[1]->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1468 link->comp[1]->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1469 link->radius/p->sampling()[0], hexcol.c_str());
1470 Tcl_AppendToObj(returnObj, string, strlen(string));
1471 }
1472 } else {
1473 for ( link = model->link; link; link = link->next )
1474 if ( link->comp[0]->fom >= fom_cut && link->comp[1]->fom >= fom_cut ) {
1475 hexcol = link->color.hex();
1476 sprintf(string, " %g %g %g %g %g %g %g %s",
1477 link->comp[0]->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1478 link->comp[0]->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1479 link->comp[0]->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1480 link->comp[1]->loc[0]/p->sampling()[0] + p->image[n].origin()[0],
1481 link->comp[1]->loc[1]/p->sampling()[1] + p->image[n].origin()[1],
1482 link->comp[1]->loc[2]/p->sampling()[2] + p->image[n].origin()[2],
1483 link->radius/p->sampling()[0], hexcol.c_str());
1484 Tcl_AppendToObj(returnObj, string, strlen(string));
1485 }
1486 }
1487
1488 return returnObj;
1489 }
1490
1491 Tcl_Obj* link_select(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1492 {
1493 Tcl_Obj* returnObj = Tcl_NewObj();
1494
1495 if ( !model ) return returnObj;
1496
1497 int id1(0), id2(0);
1498 double x(0), y(0), z(0), rad(20);
1499
1500 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
1501 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
1502 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
1503 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &rad);
1504
1505 char string[64] = "";
1506 double d, d1, d2, dmin(1000000);
1507 Vector3<float> loc(x, y, z);
1508 Blink* link = NULL;
1509 Blink* linksel = NULL;
1510
1511 for ( link = model->link; link; link = link->next ) {
1512 d = link->comp[0]->loc.distance(link->comp[1]->loc);
1513 d1 = link->comp[0]->loc.distance(loc);
1514 d2 = link->comp[1]->loc.distance(loc);
1515 d = d1 + d2 - d;
1516 if ( dmin > d ) {
1517 dmin = d;
1518 linksel = link;
1519 }
1520 }
1521
1522 if ( linksel && dmin <= rad ) {
1523 id1 = linksel->comp[0]->id.integer();
1524 id2 = linksel->comp[1]->id.integer();
1525 sprintf(string, "%d %d", id1, id2);
1526 Tcl_SetStringObj(returnObj, string, strlen(string));
1527 }
1528
1529 return returnObj;
1530 }
1531
1532 Tcl_Obj* link_create(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1533 {
1534 Tcl_Obj* returnObj = Tcl_NewObj();
1535
1536 if ( !model ) return returnObj;
1537
1538 int id1(0), id2(0);
1539
1540 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id1);
1541 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id2);
1542
1543 char string[64] = "";
1544 Bcomponent* comp1 = NULL;
1545 Bcomponent* comp2 = NULL;
1546
1547 if ( id1 != id2 ) {
1548 for ( comp1 = model->comp; comp1 && comp1->id.integer() != id1; comp1 = comp1->next ) ;
1549 for ( comp2 = model->comp; comp2 && comp2->id.integer() != id2; comp2 = comp2->next ) ;
1550 if ( comp1 && comp2 )
1551 link_add(&model->link, comp1, comp2, 0, 1);
1552 }
1553
1554 sprintf(string, "%d %d", id1, id2);
1555 Tcl_SetStringObj(returnObj, string, strlen(string));
1556
1557 return returnObj;
1558 }
1559
1560 Tcl_Obj* link_delete(Bmodel* model, int objc, Tcl_Obj *CONST objv[])
1561 {
1562 Tcl_Obj* returnObj = Tcl_NewObj();
1563
1564 if ( !model ) return returnObj;
1565
1566 int id1(0), id2(0);
1567
1568 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id1);
1569 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id2);
1570
1571 char string[64] = "";
1572 Blink* link = NULL;
1573 Bcomponent* comp1 = NULL;
1574 Bcomponent* comp2 = NULL;
1575
1576 if ( id1 != id2 ) {
1577 for ( comp1 = model->comp; comp1 && comp1->id.integer() != id1; comp1 = comp1->next ) ;
1578 for ( comp2 = model->comp; comp2 && comp2->id.integer() != id2; comp2 = comp2->next ) ;
1579 if ( comp1 && comp2 )
1580 for ( link = model->link; link && link->comp[0] != comp1 && link->comp[1] != comp2; link = link->next ) ;
1581 if ( link )
1582 remove_item((char **)&model->link, (char *)link, sizeof(Blink));
1583 }
1584
1585 sprintf(string, "%d %d", id1, id2);
1586 Tcl_SetStringObj(returnObj, string, strlen(string));
1587
1588 return returnObj;
1589 }
1590
comptype_count
Tcl_Obj * comptype_count(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:606
distance
double distance(vector< T1 > &v1, vector< T2 > &v2)
Definition: Vector3.h:536
Bmodel::img_num
int img_num
Definition: rwmodel.h:127
Bcomponent::id
Bstring id
Definition: rwmodel.h:53
model_map.h
Header file for model to map conversions.
Bcomponent::type
Bcomptype * type
Definition: rwmodel.h:54
component_color
Tcl_Obj * component_color(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1245
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
model_create.h
Library routines used for model creation.
Blink
Definition: rwmodel.h:82
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:394
Bmodel::id
Bstring id
Definition: rwmodel.h:121
link_ids
Tcl_Obj * link_ids(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1399
model_views.h
Library routines used for analysing model component views.
Bparticle::view
View view
Definition: mg_processing.h:101
model_count_component_types
int model_count_component_types(Bmodel *model)
Counts the number of components for each type.
Definition: rwmodel.cpp:568
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
model_create_shell
Bmodel * model_create_shell(long number, double radius, double distance)
Creates a sphere point model.
Definition: model_create.cpp:472
component_fom
Tcl_Obj * component_fom(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1028
utilities.h
Header file for general utilities.
Blink::color
RGBA< float > color
Definition: rwmodel.h:88
do_component_type
Tcl_Obj * do_component_type(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:556
model_select
long model_select(Bmodel *model, Bstring &comptype)
Selects models, components and component types.
Definition: model_select.cpp:36
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
img_extract_segments_using_model
Bimage * img_extract_segments_using_model(Bimage *p, Bmodel *model, int multi_level)
Extracts segmentss from a multi-level mask around points defined by a model.
Definition: model_mask.cpp:334
Breconstruction
Definition: mg_processing.h:280
Bcomptype::fmod
Bstring fmod
Definition: rwmodel.h:29
RGBA< float >
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
do_find
Tcl_Obj * do_find(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:209
link_img_coords
Tcl_Obj * link_img_coords(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1421
Blink::sel
int sel
Definition: rwmodel.h:90
particle_add
Bparticle * particle_add(Bparticle **part, int pid)
Adds a particle parameter structure to a linked list.
Definition: mg_processing.cpp:527
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmodel::comment
Bstring comment
Definition: rwmodel.h:126
particle_kill
int particle_kill(Bparticle *part)
Frees a list of particles.
Definition: mg_processing.cpp:1323
component_ids
Tcl_Obj * component_ids(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:894
component_add
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Definition: rwmodel.cpp:267
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:315
Bcomptype::mass
float mass
Definition: rwmodel.h:32
Bstring::remove
Bstring remove(const char c)
Definition: Bstring.cpp:465
Bmodel::sel
int sel
Definition: rwmodel.h:129
MAXLINELEN
#define MAXLINELEN
Definition: utilities.h:44
component_count_selected
Tcl_Obj * component_count_selected(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:877
RGBA::hex
Bstring hex()
Definition: Color.h:214
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:230
link_delete
Tcl_Obj * link_delete(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1560
Bcomptype::sel
int sel
Definition: rwmodel.h:34
component_list_kill
int component_list_kill(Bcomponent *comp)
Deallocates memory for a list of components.
Definition: rwmodel.cpp:891
Blink::comp
Bcomponent * comp[2]
Definition: rwmodel.h:84
Vector3::distance
double distance(const Vector3 &v)
Definition: Vector3.h:227
Breconstruction::box_size
Vector3< long > box_size
Definition: mg_processing.h:296
set_link_radius
int set_link_radius(Bmodel *model, float radius)
Definition: tcltk_bmodel.cpp:308
Bstring::replace
Bstring replace(char cold, char cnew)
Definition: Bstring.cpp:457
model_color_by_fom
int model_color_by_fom(Bmodel *model)
Colors model components by fom.
Definition: model_color.cpp:159
model_color.h
Functions to color models.
Bimage
General image parameter class.
Definition: Bimage.h:163
reconstruction_add
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
Definition: mg_processing.cpp:704
comptype_first_selected
Tcl_Obj * comptype_first_selected(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:745
comptype_select
Tcl_Obj * comptype_select(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:695
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
Bparticle::sel
long sel
Definition: mg_processing.h:103
linked_list.h
Header file for generalized linked list functions.
model_color_by_density
int model_color_by_density(Bmodel *model)
Colors model components by density.
Definition: model_color.cpp:118
model_kill
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1124
base
string base(string &filename)
Definition: string_util.cpp:28
verbose
int verbose
Blink::next
Blink * next
Definition: rwmodel.h:83
Bcomponent::fom
float fom
Definition: rwmodel.h:65
imglist
Bimage * imglist
Definition: bshow.cpp:30
do_link
Tcl_Obj * do_link(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1318
Bstring::next
Bstring * next
Definition: Bstring.h:31
Bmodel::type
Bcomptype * type
Definition: rwmodel.h:131
link_select
Tcl_Obj * link_select(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1491
Bstring::pre
Bstring pre(char c)
Definition: Bstring.cpp:381
do_set
int do_set(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:323
component_create
Tcl_Obj * component_create(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1181
Blink::radius
float radius
Definition: rwmodel.h:87
length
double length(vector< T > v)
Definition: Vector3.h:528
link_count
Tcl_Obj * link_count(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1365
comptype_deselect
Tcl_Obj * comptype_deselect(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:720
project
Bproject * project
Definition: bshow.cpp:31
set_component_radius
int set_component_radius(Bmodel *model, float radius)
Definition: tcltk_bmodel.cpp:293
component_select
Tcl_Obj * component_select(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1086
component_img_coords
Tcl_Obj * component_img_coords(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:966
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:280
Bparticle::group
int group
Definition: mg_processing.h:93
do_delete_non_selected
int do_delete_non_selected(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:404
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:127
do_delete
int do_delete(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:391
remove_item
char * remove_item(char **list, char *item, unsigned long size)
Finds the given item and deletes it from the linked list.
Definition: linked_list.cpp:114
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
link_count_selected
Tcl_Obj * link_count_selected(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1382
tcltk_bmodel.h
A shared object to manage model parameter files in TCL/Tk.
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bmodel::next
Bmodel * next
Definition: rwmodel.h:120
Bcomponent::sel
int sel
Definition: rwmodel.h:66
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:411
Bcomponent::radius
float radius
Definition: rwmodel.h:62
Bimage::next
Bimage * next
Definition: Bimage.h:165
Bstring::base
Bstring base()
Definition: Bstring.cpp:508
model_processing
int model_processing(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
Implements the "Bmodel" command in Tcl/Tk to access model parameter files through Bsoft.
Definition: tcltk_bmodel.cpp:120
read_model
Bmodel * read_model(Bstring &filename)
Definition: rwmodel.cpp:28
write_model
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Definition: rwmodel.cpp:91
do_extract_segments
int do_extract_segments(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:462
Bparticle
Definition: mg_processing.h:89
model_color_selected_types
int model_color_selected_types(Bmodel *model, RGBA< float > rgba)
Colors model components by fom.
Definition: model_color.cpp:201
comptype_ids
Tcl_Obj * comptype_ids(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:636
Bstring
Definition: Bstring.h:29
comptype_count_selected
Tcl_Obj * comptype_count_selected(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:621
model_reset_selection
long model_reset_selection(Bmodel *model)
Resets the selection to all components.
Definition: model_select.cpp:232
model_delete_non_selected
long model_delete_non_selected(Bmodel **model)
Deletes selected components and associated links from the model.
Definition: model_select.cpp:781
Bmodel::link
Blink * link
Definition: rwmodel.h:133
Bproject::select
int select
Definition: mg_processing.h:339
Bmodel::fmap
Bstring fmap
Definition: rwmodel.h:125
comp_associated_links_kill
int comp_associated_links_kill(Bcomponent *comp, Blink **link)
Deallocates memory for links associated with a component.
Definition: rwmodel.cpp:1092
Breconstruction::bad_radius
double bad_radius
Definition: mg_processing.h:299
Bcomptype::num
int num
Definition: rwmodel.h:30
model_from_images
Bmodel * model_from_images(Bimage *plist)
Creates one or more models from 3D images.
Definition: model_map.cpp:28
comptype_create_update
Tcl_Obj * comptype_create_update(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:670
model_add
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
Definition: rwmodel.cpp:178
Bcomponent::next
Bcomponent * next
Definition: rwmodel.h:52
rwmodel.h
Header file for reading and writing atomic model files.
component_location
Tcl_Obj * component_location(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:915
Bcomptype::id
Bstring id
Definition: rwmodel.h:27
Vector3< float >
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
Vector3.h
Class for 3-value vectors.
do_create_shell
int do_create_shell(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:494
model_mask.h
Functions to generate masks from models.
comptype_list
Tcl_Obj * comptype_list(Bmodel *model)
Definition: tcltk_bmodel.cpp:652
component_copy
int component_copy(Bcomponent *fromcomp, Bcomponent *tocomp)
Copies all elements from one component to another.
Definition: rwmodel.cpp:783
component_distance
Tcl_Obj * component_distance(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:938
Bstring::integer
long integer()
Definition: Bstring.cpp:539
Color.h
Classes for color objects.
Bmodel
Definition: rwmodel.h:119
mg_processing.h
Header file for micrograph processing.
model_link_list_kill
int model_link_list_kill(Bmodel *model)
Deallocates memory for a list of component links.
Definition: rwmodel.cpp:950
Breconstruction::frec
Bstring frec
Definition: mg_processing.h:287
component_count
Tcl_Obj * component_count(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:860
Breconstruction::voxel_size
double voxel_size
Definition: mg_processing.h:292
model_color_uniformly
int model_color_uniformly(Bmodel *model, RGBA< float > color)
Colors model components uniformly.
Definition: model_color.cpp:29
model
Bmodel * model
Definition: bshow.cpp:32
rwimg.h
Header file for 2D and 3D image I/O.
component_radius
Tcl_Obj * component_radius(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1057
Bcomptype
Definition: rwmodel.h:25
component_move
Tcl_Obj * component_move(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1155
Bmodel::comp
Bcomponent * comp
Definition: rwmodel.h:132
do_get
Tcl_Obj * do_get(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:234
model_calculate_views
long model_calculate_views(Bmodel *model, Bstring &mode)
Calculates the views associated with each component.
Definition: model_views.cpp:263
Vector3::volume
double volume()
Definition: Vector3.h:235
do_components_to_particles
int do_components_to_particles(Bmodel *model, Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:411
model_select.h
Header file for reading and writing atomic model files.
Bcomponent::loc
Vector3< float > loc
Definition: rwmodel.h:58
Bcomptype::fom
float fom
Definition: rwmodel.h:33
do_component
Tcl_Obj * do_component(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:797
model_unset_selection
long model_unset_selection(Bmodel *model)
Unsets the selection to all components but not models.
Definition: model_select.cpp:261
Bcomptype::count
int count
Definition: rwmodel.h:31
Bcomponent::color
RGBA< float > color
Definition: rwmodel.h:63
Bproject
Definition: mg_processing.h:333
Bimage::image
Bsub_image * image
Definition: Bimage.h:188
link_create
Tcl_Obj * link_create(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1532
Bstring::split
Bstring * split()
Definition: Bstring.cpp:597
Bcomptype::next
Bcomptype * next
Definition: rwmodel.h:26
model_create_circle
Bmodel * model_create_circle(double radius, double z, double distance)
Creates a circle with the given radius, height, and component separation.
Definition: model_create.cpp:897
component_delete
Tcl_Obj * component_delete(Bmodel *model, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmodel.cpp:1219
Bcomponent
Definition: rwmodel.h:51