atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
save_bond.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'save_bond.c'
24*
25* Contains:
26*
27
28 - The functions to save bonding information in the atomes project file format
29
30*
31* List of functions:
32
33 int save_bonding (FILE * fp, project * this_proj);
34
35*/
36
37#include "global.h"
38#include "project.h"
39#include "glview.h"
40#include "initcoord.h"
41
50int save_bonding (FILE * fp, project * this_proj)
51{
52 int i, j, k;
53 image * img = this_proj -> modelgl -> anim -> last -> img;
54 if (! this_proj -> modelgl -> bonding || ! this_proj -> modelgl -> adv_bonding[1] || this_proj -> natomes > ATOM_LIMIT || this_proj -> steps > STEP_LIMIT)
55 {
56 for (i=0; i<this_proj -> steps; i++)
57 {
58 for (j=0; j<this_proj -> natomes; j++)
59 {
60 if (fwrite (this_proj -> atoms[i][j].coord, sizeof(int), 5, fp) != 5) return ERROR_COORD;
61 if (fwrite (& this_proj -> atoms[i][j].numv, sizeof(int), 1, fp) != 1) return ERROR_COORD;
62 if (this_proj -> atoms[i][j].numv)
63 {
64 if (fwrite (this_proj -> atoms[i][j].vois, sizeof(int), this_proj -> atoms[i][j].numv, fp) != this_proj -> atoms[i][j].numv) return ERROR_COORD;
65 }
66 }
67 if (fwrite (this_proj -> modelgl -> bonds[i], sizeof(int), 2, fp) != 2) return ERROR_COORD;
68 for (j=0; j<2; j++)
69 {
70 for (k=0; k<this_proj -> modelgl -> bonds[i][j]; k++)
71 {
72 if (fwrite (this_proj -> modelgl -> bondid[i][j][k], sizeof(int), 2, fp) != 2) return ERROR_COORD;
73 }
74 }
75 }
76
77 coord_info * coord = this_proj -> coord;
78 for (i=0; i<2; i++)
79 {
80 if (fwrite (coord -> ntg[i], sizeof(int), coord -> species, fp) != coord -> species) return ERROR_COORD;
81 for (j=0; j<coord -> species; j++)
82 {
83 if (fwrite (coord -> geolist[i][j], sizeof(int), coord -> ntg[i][j], fp) != coord -> ntg[i][j]) return ERROR_COORD;
84 if (i == 1)
85 {
86 for (k=0; k<coord -> ntg[i][j]; k++)
87 {
88 if (fwrite (coord -> partial_geo[j][k], sizeof(int), coord -> species, fp) != coord -> species) return ERROR_COORD;
89 }
90 }
91 }
92 }
93 }
94
95 for (i=0; i<10; i++)
96 {
97 if (fwrite (& this_proj -> coord -> totcoord[i], sizeof(int), 1, fp) != 1) return ERROR_COORD;
98 if (i < 2)
99 {
100 if (fwrite (img -> show_atom[i], sizeof(gboolean), this_proj -> nspec, fp) != this_proj -> nspec) return ERROR_COORD;
101 if (fwrite (img -> show_label[i], sizeof(gboolean), this_proj -> nspec, fp) != this_proj -> nspec) return ERROR_COORD;
102 }
103 if (this_proj -> coord -> totcoord[i])
104 {
105 if (fwrite (img -> show_coord[i], sizeof(gboolean), this_proj -> coord -> totcoord[i], fp) != this_proj -> coord -> totcoord[i]) return ERROR_COORD;
106 if (i < 2 || (i > 3 && i < 9))
107 {
108 if (fwrite (img -> show_poly[i], sizeof(gboolean), this_proj -> coord -> totcoord[i], fp) != this_proj -> coord -> totcoord[i]) return ERROR_COORD;
109 }
110 }
111 }
112
113 return OK;
114}
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
int atoms[NUM_STYLES][2]
int bonds[NUM_STYLES][2]
FILE * fp
Global variable declarations Global convenience function declarations Global data structure defin...
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
#define STEP_LIMIT
Definition global.h:277
#define OK
Definition global.h:279
#define ERROR_COORD
Definition global.h:288
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations to handle the atomic coordination data.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int save_bonding(FILE *fp, project *this_proj)
save bonding information to file
Definition save_bond.c:50
Definition glwin.h:277
GtkWidget * img
Definition workspace.c:70