1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Select atoms above the plane. The normal vector defines what is up
12
(1) Pointer to MolComplexS structure, with macromol. complexes.
13
(2) Number of macromolecular complexes.
14
(4) Selection mode index (0 = overwrite, 1 = restrict, 2 = expand
18
(1) The flag selectedF set to one for selected atoms in every
19
caught macromolecular complex.
23
(1) The number of selected atoms (zero or positive value).
25
========includes:============================================================*/
30
#include <X11/Xutil.h>
32
#include <X11/Xatom.h>
37
/*======function prototypes:=================================================*/
39
double ScalarProduct_ (VectorS *, VectorS *);
41
/*======select atoms above the plane:========================================*/
43
long SelectAbove_ (MolComplexS *mol_complexSP, int mol_complexesN,
46
long selected_atomsN = 0;
48
MolComplexS *curr_mol_complexSP;
50
VectorS normal_vectorS;
51
double plane_center_x, plane_center_y, plane_center_z;
57
/* Select all atoms above the plane: */
58
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
60
/* Pointer to the current macromolecular complex: */
61
curr_mol_complexSP = mol_complexSP + mol_complexI;
63
/* Check is the current macromolecular complex caught: */
64
if (curr_mol_complexSP->catchF == 0) continue;
66
/* Number of atoms in a macromolecular complex: */
67
atomsN = curr_mol_complexSP->atomsN;
68
if (atomsN == 0) continue;
70
/* The normal vector: */
71
normal_vectorS.x = curr_mol_complexSP->planeS.normal_x[0];
72
normal_vectorS.y = curr_mol_complexSP->planeS.normal_y;
73
normal_vectorS.z = curr_mol_complexSP->planeS.normal_z[0];
75
/* Position of the plane center: */
76
plane_center_x = curr_mol_complexSP->planeS.center_x[0];
77
plane_center_y = curr_mol_complexSP->planeS.center_y;
78
plane_center_z = curr_mol_complexSP->planeS.center_z[0];
80
/* Scan all atoms in the current complex: */
81
for (atomI = 0; atomI < atomsN; atomI++)
83
/* Pointer to the current atom: */
84
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
86
/* Copy the coordinates: */
87
x = curr_atomSP->raw_atomS.x[0];
88
y = curr_atomSP->raw_atomS.y;
89
z = curr_atomSP->raw_atomS.z[0];
91
/* Position of the atom relative to the plane center: */
92
curr_vectorS.x = x - plane_center_x;
93
curr_vectorS.y = y - plane_center_y;
94
curr_vectorS.z = z - plane_center_z;
99
/* Check the sign of the scalar product: */
100
if (ScalarProduct_ (&curr_vectorS, &normal_vectorS) > 0)
105
/* Set the selection flag for the current atom: */
106
switch (selection_modeI)
108
/* Overwrite the previous selection: */
110
curr_atomSP->selectedF = aboveF;
113
/* Restrict the previous selection: */
115
curr_atomSP->selectedF &= aboveF;
118
/* Expand the previous selection: */
120
curr_atomSP->selectedF |= aboveF;
127
/* Check the selection flag; increase */
128
/* the count if flag is equal to one: */
129
if (curr_atomSP->selectedF) selected_atomsN++;
133
/* Return the number of selected atoms: */
134
return selected_atomsN;
137
/*===========================================================================*/