226 int h, i, j, k, l, m;
230 gboolean * frag_to_test;
231 gboolean * frag_to_remove;
232 gboolean * show_frag = NULL;
235 int * tmp_vois = NULL;
254 int tcf = (this_proj) ? this_proj -> coord -> totcoord[2] : this_object -> coord -> totcoord[2];
259 show_frag =
duplicate_bool (tcf, this_proj -> modelgl -> anim -> last ->
img -> show_coord[2]);
269 int nat = (this_proj) ? this_proj -> natomes : this_object ->
atoms;
276 for (i=0; i<nat; i++)
278 j = (this_proj) ? this_proj ->
atoms[0][i].coord[2] : tmp_list -> coord[2];
283 if (! remove && ! passivate)
286 id_mod[tmp_list -> id] = h;
292 id_mod[tmp_list -> id] = h;
295 if (old_id[i] > 0 || ! remove)
297 if (tmp_list -> numv > 0)
301 for (l=0; l<tmp_list -> numv; l++)
303 m = tmp_list -> vois[l];
304 if ((remove && old_id[m] > 0) || (! remove && old_id[i] > 0 && old_id[m] > 0) || (! remove && old_id[i] < 0 && old_id[m] < 0))
310 g_free (tmp_list -> vois);
311 tmp_list -> vois = NULL;
312 tmp_list -> numv = k;
317 for (l=0; l<k; l++) tmp_list -> vois[l] = tmp_vois[l];
321 if ( old_id[i] > 0 || ! remove || passivate) tmp_list = tmp_list -> next;
329 i = tmp_list -> coord[2];
330 if (! tmp_list -> numv && per_frag[i] > 1 && old_id[tmp_list ->
id] > 0)
333 show_frag = g_realloc (show_frag, (tcf+1)*
sizeof*show_frag);
334 per_frag = g_realloc (per_frag, (tcf+1)*
sizeof*per_frag);
335 in_frag = g_realloc (in_frag, (tcf+1)*
sizeof*in_frag);
336 show_frag[tcf] = show_frag[i];
339 tmp_list -> coord[2] = tcf;
342 tmp_list = tmp_list -> next;
347 for (i=0; i<tcf; i++)
349 if (in_frag[i] == per_frag[i])
353 frag_to_remove[i] = TRUE;
357 frag_to_test[i] = TRUE;
360 else if (per_frag[i] > 1 && in_frag[i])
362 frag_to_test[i] = TRUE;
368 atom ** atom_list = g_malloc0 (nat*
sizeof*atom_list);
373 if (old_id[i] > 0 || ! remove)
377 tmp_list = tmp_list -> next;
379 if (remove && this_proj)
384 for (j=0; j<tcf; j++) new_fid[j] = j;
385 for (j=0; j<tcf-1; j++)
387 if (frag_to_remove[j])
389 for (k=j+1; k<tcf; k++) new_fid[k] --;
392 for (j=0; j<tcf; j++)
394 if (frag_to_remove[j])
396 for (k=j; k<tcf-i-1; k++) show_frag[k] = show_frag[k+1];
397 for (k=j; k<tcf-i-1; k++) frag_to_test[k] = frag_to_test[k+1];
401 for (j=0; j<nat; j++)
403 if (atom_list[j]) atom_list[j] -> coord[2] = new_fid[atom_list[j] -> coord[2]];
409 show_frag = g_realloc (show_frag, tcf*
sizeof*show_frag);
422 show_frag = g_realloc (show_frag, (tcf+k)*
sizeof*show_frag);
423 for (l=tcf; l<tcf+k; l++) show_frag[l] = show_frag[j];
428 g_free (frag_to_test);
429 g_free (frag_to_remove);
432 this_proj -> coord -> totcoord[2] = tcf;
436 this_object -> coord -> totcoord[2] = tcf;
442 if (old_id[i] > 0 || ! remove)
444 tmp_list -> coord[2] = atom_list[i] -> coord[2];
445 g_free (atom_list[i]);
448 tmp_list = tmp_list -> next;
461 if (this_proj -> modelgl ->
bonds[0][i])
463 tmpbondid[i] =
allocdint (this_proj -> modelgl ->
bonds[0][i], 2);
465 for (k=0; k<this_proj -> modelgl ->
bonds[0][i]; k++)
467 l = this_proj -> modelgl -> bondid[0][i][k][0];
468 m = this_proj -> modelgl -> bondid[0][i][k][1];
469 if (old_id[l] > 0 && old_id[m] > 0)
471 tmpbondid[i][j][0] = l;
472 tmpbondid[i][j][1] = m;
475 else if (! remove && (old_id[l] < 0 && old_id[m] < 0))
477 tmpbondid[i][j][0] = l;
478 tmpbondid[i][j][1] = m;
489 if (this_proj -> modelgl ->
bonds[0][i])
491 g_free (this_proj -> modelgl -> bondid[0][i]);
492 this_proj -> modelgl -> bondid[0][i] = NULL;
495 g_free (this_proj -> modelgl -> clones[0]);
496 this_proj -> modelgl -> clones[0] = NULL;
500 if (i) this_proj -> modelgl -> clones[0] = g_malloc0 (tmpbond[i]*
sizeof*this_proj -> modelgl -> clones[0]);
501 this_proj -> modelgl -> bondid[0][i] =
allocdint (tmpbond[i], 2);
502 for (k=0; k<tmpbond[i]; k++)
504 this_proj -> modelgl -> bondid[0][i][k][0] = id_mod[tmpbondid[i][k][0]];
505 this_proj -> modelgl -> bondid[0][i][k][1] = id_mod[tmpbondid[i][k][1]];
509 l = this_proj -> modelgl -> bondid[0][i][k][0];
510 m = this_proj -> modelgl -> bondid[0][i][k][1];
512 this_proj -> modelgl -> clones[0][k].x = clo.
x;
513 this_proj -> modelgl -> clones[0][k].y = clo.
y;
514 this_proj -> modelgl -> clones[0][k].z = clo.
z;
518 this_proj -> modelgl ->
bonds[0][i] = tmpbond[i];
519 this_proj -> modelgl -> allbonds[i] = tmpbond[i];
523 g_free (tmpbondid[i]);
535 if (old_id[i] > 0 || ! remove)
537 if (tmp_list -> numv > 0)
539 for (j=0; j<tmp_list -> numv; j++)
541 k = tmp_list -> vois[j];
542 tmp_list -> vois[j] = id_mod[k];
546 tmp_list = tmp_list -> next;
656 int num_elem = asearch -> todo_size;
657 int * passivate_todo =
duplicate_int (num_elem, asearch -> todo);
658 g_free (asearch -> todo);
660 if (this_proj -> modelgl -> atom_win -> to_be_inserted[3])
662 tmp_oba = this_proj -> modelgl -> atom_win -> to_be_inserted[3];
665 while (tmp_oba -> next)
667 tmp_oba = tmp_oba -> next;
669 tmp_obb = tmp_obb -> next;
671 g_free (this_proj -> modelgl -> atom_win -> to_be_inserted[3]);
672 this_proj -> modelgl -> atom_win -> to_be_inserted[3] = NULL;
675 asearch -> in_selection = 0;
677 for (i=0; i<num_elem; i++)
679 if (passivate_todo[i])
681 for (j=0; j<this_proj -> natomes; j++)
686 k = this_proj ->
atoms[0][j].sp;
690 if (k == i) doit = TRUE;
693 if (this_proj ->
atoms[0][j].numv == i) doit = TRUE;
697 for (m=0;m<k;m++) l += this_proj -> coord -> ntg[1][m];
698 if (l == i) doit = TRUE;
701 if (this_proj ->
atoms[0][j].coord[
filter-1] == i) doit = TRUE;
706 asearch -> todo[j] = 1;
707 if (this_proj -> modelgl -> atom_win -> to_be_inserted[3] == NULL)
710 tmp_obb = this_proj -> modelgl -> atom_win -> to_be_inserted[3];
715 tmp_obb -> next -> prev = tmp_obb;
716 tmp_obb = tmp_obb -> next;
719 asearch -> in_selection ++;
723 if (tmp_oba -> next != NULL) tmp_oba = tmp_oba -> next;
726 if (passivate_todo) g_free (passivate_todo);