79 Tcl_Obj* returnObj = NULL;
81 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
83 cout <<
"DEBUG do_filament: Item: " << item <<
" (" << item.
length() <<
")" << endl;
90 cerr <<
"Error in do_filament: Item " << item <<
" must be a micrograph or reconstruction!" << endl;
91 returnObj = Tcl_NewObj();
105 filename = field->
mg->
fmg;
107 cerr <<
"Error in do_filament: Field " <<
id <<
" not found!" << endl;
108 }
else if ( item.
contains(
"Micrograph") ) {
110 for ( mg = field->
mg; mg && mg->
id !=
id; mg = mg->
next ) ;
119 cerr <<
"Error in do_filament: Micrograph " <<
id <<
" not found!" << endl;
120 }
else if ( item.
contains(
"Reconstruction") ) {
123 filename = rec->
frec;
125 cerr <<
"Error in do_filament: Reconstruction " <<
id <<
" not found!" << endl;
128 if ( filename.
length() ) {
132 if ( filename2.
base() ==
base )
break;
136 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
138 cout <<
"DEBUG do_filament: Action: " << action <<
" (" << action.
length() <<
")" << endl;
140 if ( action ==
"count" ) {
145 }
else if ( action ==
"delete" ) {
146 if ( objc > 4 ) delete_what = Tcl_GetStringFromObj(objv[4], NULL);
147 if ( delete_what ==
"all" || delete_what ==
"mg" || delete_what ==
"rec" )
152 }
else if ( action ==
"extract" ) {
154 }
else if ( action ==
"profile" ) {
156 }
else if ( action ==
"center" ) {
158 }
else if ( action ==
"toparticles" ) {
161 cerr <<
"Error: Action " << action <<
" not recognized!" << endl;
165 returnObj = Tcl_NewObj();
166 Tcl_SetIntObj(returnObj, 0);
174 Tcl_Obj* returnObj = Tcl_NewObj();
183 for ( mg = field->
mg; mg; mg = mg->
next )
192 Tcl_SetIntObj(returnObj, nfil);
199 Tcl_Obj* returnObj = Tcl_NewObj();
205 for ( mg = field->
mg; mg; mg = mg->
next )
210 Tcl_SetIntObj(returnObj, nfil);
217 Tcl_Obj* returnObj = Tcl_NewObj();
224 Tcl_SetIntObj(returnObj, nfil);
231 Tcl_Obj* returnObj = Tcl_NewObj();
235 if ( rec && rec->
fil )
238 Tcl_SetIntObj(returnObj, nfil);
245 Tcl_Obj* returnObj = Tcl_NewObj();
247 int fid(0), n(-1), all(0);
249 Bstring action = Tcl_GetStringFromObj(objv[4], NULL);
251 char string[64] =
"";
257 if ( action ==
"all" || action ==
"mg" ) {
259 for ( mg = field->
mg; mg; mg = mg->
next ) {
267 if ( action ==
"all" || action ==
"rec" ) {
276 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
283 if ( field )
for ( mg = field->
mg; mg; mg = mg->
next ) {
284 for ( fil = mg->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
291 if ( field )
for ( mg = field->
mg; mg && mg->
img_num != n; mg = mg->
next ) ;
293 for ( fil = mg->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
302 for ( fil = rec->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
311 sprintf(
string,
"%d", fid);
312 Tcl_SetStringObj(returnObj,
string, strlen(
string));
319 Tcl_Obj* returnObj = Tcl_NewObj();
324 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
326 if ( mg && fid > 0 ) {
327 for ( fil = mg->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
334 Tcl_SetIntObj(returnObj, fid);
341 Tcl_Obj* returnObj = Tcl_NewObj();
346 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
348 if ( rec && fid > 0 ) {
349 for ( fil = rec->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
356 Tcl_SetIntObj(returnObj, fid);
366 for ( fnode = fil->
node; fnode; fnode = fnode->
next ) fnode->
id = ++nnode;
373 Tcl_Obj* returnObj = Tcl_NewObj();
375 if ( !p )
return returnObj;
378 int nfil(0),
split(0), axis(0);
379 double filament_width(10);
381 if ( objc > 4 ) filename = Tcl_GetStringFromObj(objv[4], NULL);
382 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &filament_width);
383 if ( objc > 6 ) Tcl_GetIntFromObj(NULL, objv[6], &axis);
384 if ( objc > 7 ) Tcl_GetIntFromObj(NULL, objv[7], &
split);
385 if ( objc > 8 ) filpath = Tcl_GetStringFromObj(objv[8], NULL);
389 if ( filename.
length() ) {
397 filename = filpath +
"/" + filename;
409 filename = filpath +
"/" + filename;
411 rec->
ffil = filename;
417 Tcl_SetIntObj(returnObj, nfil);
424 Tcl_Obj* returnObj = Tcl_NewObj();
426 if ( !p )
return returnObj;
429 double filament_width(10);
431 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
432 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &nid);
433 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &filament_width);
435 long i, n(0), img_num(0);
436 double* profile = NULL;
443 }
else if ( rec ) fil = rec->
fil;
446 for ( ; fil && fil->
id != fid; fil = fil->
next ) ;
449 sprintf(
string,
"%ld", n);
450 Tcl_SetStringObj(returnObj,
string, strlen(
string));
451 for ( i=0; i<2*n; i++ ) {
452 sprintf(
string,
" %lf", profile[i]);
453 Tcl_AppendToObj(returnObj,
string, strlen(
string));
464 Tcl_Obj* returnObj = Tcl_NewObj();
466 if ( !p )
return returnObj;
468 int filament_width(40);
470 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &filament_width);
472 long n(0), img_num(0);
479 }
else if ( rec ) fil = rec->
fil;
488 Tcl_SetDoubleObj(returnObj, cc);
495 Tcl_Obj* returnObj = Tcl_NewObj();
498 double filament_width(10), boxing_interval(0), rise(1e30), angle(0);
500 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &filament_width);
501 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &boxing_interval);
502 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &rise);
503 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &angle);
505 Vector3<int> box_size((
int)filament_width, (
int)filament_width, (
int)filament_width);
508 Tcl_SetIntObj(returnObj, nfil);
536 Tcl_Obj* returnObj = NULL;
538 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
540 cout <<
"DEBUG do_node: Item: " << item <<
" (" << item.
length() <<
")" << endl;
544 item = item.
pre(
':');
547 cerr <<
"Error in do_node: Item " << item <<
" must be a micrograph or reconstruction!" << endl;
548 returnObj = Tcl_NewObj();
562 }
else if ( item.
contains(
"Micrograph") ) {
564 for ( mg = field->
mg; mg && mg->
id !=
id; mg = mg->
next ) ;
570 }
else cerr <<
"Error in do_node: Micrograph " <<
id <<
" not found!" << endl;
571 }
else if ( item.
contains(
"Reconstruction") ) {
576 }
else cerr <<
"Error in do_node: Reconstruction " <<
id <<
" not found!" << endl;
579 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
581 cout <<
"DEBUG do_node: Action: " << action <<
" (" << action.
length() <<
")" << endl;
583 if ( action ==
"count" ) {
585 else if ( field ) returnObj =
node_count(field);
588 }
else if ( action ==
"ids" ) {
589 if ( fil ) returnObj =
node_ids(fil);
590 }
else if ( action ==
"location" ) {
592 }
else if ( action ==
"select" ) {
593 if ( fil ) returnObj =
node_select(fil, radius, objc, objv);
594 }
else if ( action ==
"move" ) {
595 if ( fil ) returnObj =
node_move(fil, objc, objv);
596 }
else if ( action ==
"create" ) {
599 }
else if ( action ==
"delete" ) {
600 if ( objc > 4 ) delete_what = Tcl_GetStringFromObj(objv[4], NULL);
601 if ( delete_what ==
"all" || delete_what ==
"mg" || delete_what ==
"rec" )
603 else if ( mg ) returnObj =
node_delete(mg, objc, objv);
604 else if ( rec ) returnObj =
node_delete(rec, objc, objv);
607 cerr <<
"Error: Action " << action <<
" not recognized!" << endl;
611 returnObj = Tcl_NewObj();
620 Tcl_Obj* returnObj = Tcl_NewObj();
630 for ( mg = field->
mg; mg; mg = mg->
next )
631 for ( fil = mg->
fil; fil; fil = fil->
next )
635 for ( fil = rec->
fil; fil; fil = fil->
next )
639 Tcl_SetIntObj(returnObj, nnode);
646 Tcl_Obj* returnObj = Tcl_NewObj();
653 for ( mg = field->
mg; mg; mg = mg->
next )
654 for ( fil = mg->
fil; fil; fil = fil->
next )
657 Tcl_SetIntObj(returnObj, nnode);
664 Tcl_Obj* returnObj = Tcl_NewObj();
670 for ( fil = mg->
fil; fil; fil = fil->
next )
673 Tcl_SetIntObj(returnObj, nnode);
680 Tcl_Obj* returnObj = Tcl_NewObj();
685 if ( rec && rec->
fil )
686 for ( fil = rec->
fil; fil; fil = fil->
next )
689 Tcl_SetIntObj(returnObj, nnode);
696 Tcl_Obj* returnObj = Tcl_NewObj();
703 for ( fil = fillist; fil; fil = fil->
next ) {
704 for ( fnode = fil->
node; fnode; fnode = fnode->
next ) {
705 sprintf(
string,
" %d %d", fil->
id, fnode->
id);
706 Tcl_AppendToObj(returnObj,
string, strlen(
string));
716 Tcl_Obj* returnObj = Tcl_NewObj();
723 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
724 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &nid);
727 for ( fil = fillist; fil && fil->
id != fid; fil = fil->
next ) ;
729 for ( fnode = fil->
node; fnode && fnode->
id != nid; fnode = fnode->
next ) ;
731 sprintf(
string,
"%f %f %f", fnode->
loc[0], fnode->
loc[1], fnode->
loc[2]);
732 Tcl_SetStringObj(returnObj,
string, strlen(
string));
741 Tcl_Obj* returnObj = Tcl_NewObj();
744 double x(0), y(0), z(0);
746 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
747 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
748 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
751 char string[64] =
"";
759 for ( fil = fillist; fil; fil = fil->
next ) {
760 for ( fnode = fil->
node; fnode; fnode = fnode->
next ) {
769 if ( dmin <= radius ) {
770 sprintf(
string,
"%d %d", fid, nid);
771 Tcl_SetStringObj(returnObj,
string, strlen(
string));
780 Tcl_Obj* returnObj = Tcl_NewObj();
783 double dx(0), dy(0), dz(0);
785 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
786 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &nid);
787 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &dx);
788 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &dy);
789 if ( objc > 8 ) Tcl_GetDoubleFromObj(NULL, objv[8], &dz);
792 char string[64] =
"";
797 for ( fil = fillist; fil && fil->
id != fid; fil = fil->
next ) ;
799 for ( fnode = fil->
node; fnode && fnode->
id != nid; fnode = fnode->
next ) ;
802 sprintf(
string,
"%d %d", fid, nid);
803 Tcl_SetStringObj(returnObj,
string, strlen(
string));
812 Tcl_Obj* returnObj = Tcl_NewObj();
814 int fid(0), nid(0), fid_max(0), nid_max(0);
815 double x(0), y(0), z(0);
817 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
818 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
819 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
820 if ( objc > 7 ) Tcl_GetIntFromObj(NULL, objv[7], &fid);
821 if ( objc > 8 ) Tcl_GetIntFromObj(NULL, objv[8], &nid);
823 char string[64] =
"";
834 for ( fil = *fillist; fil && fil->
id != fid; fil = fil->
next )
835 if ( fid_max < fil->
id ) fid_max = fil->
id;
842 for ( fnode = fil->
node; fnode && fnode->
id != nid; fnode = fnode->
next )
843 if ( nid_max < nid ) nid_max = nid;
849 fnode2 = fnode->
next;
852 fnode->
next = fnode2;
853 for ( ; fnode2; fnode2 = fnode2->
next ) fnode2->
id = ++nid;
858 sprintf(
string,
"%d %d", fil->
id, fnode->
id);
859 Tcl_SetStringObj(returnObj,
string, strlen(
string));
866 Tcl_Obj* returnObj = Tcl_NewObj();
868 Bstring action = Tcl_GetStringFromObj(objv[4], NULL);
874 if ( action ==
"all" || action ==
"mg" ) {
876 for ( mg = field->
mg; mg; mg = mg->
next ) {
883 if ( action ==
"all" || action ==
"rec" ) {
897 Tcl_Obj* returnObj = Tcl_NewObj();
900 char string[64] =
"";
904 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
905 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &nid);
908 for ( fil = mg->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
910 for ( fnode = fil->
node; fnode && fnode->
id != nid; fnode = fnode->
next ) ;
919 sprintf(
string,
"%d %d", fid, nid);
920 Tcl_SetStringObj(returnObj,
string, strlen(
string));
928 Tcl_Obj* returnObj = Tcl_NewObj();
931 char string[64] =
"";
935 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &fid);
936 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &nid);
939 for ( fil = rec->
fil; fil && fil->
id != fid; fil = fil->
next ) ;
941 for ( fnode = fil->
node; fnode && fnode->
id != nid; fnode = fnode->
next ) ;
950 sprintf(
string,
"%d %d", fid, nid);
951 Tcl_SetStringObj(returnObj,
string, strlen(
string));