#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "rpdb.h"
#include "voronoi.h"
#include "memhandler.h"
Go to the source code of this file.
Data Structures | |
struct | s_vect_elem |
struct | s_vsort |
Defines | |
#define | M_ATOM_TYPE 0 |
#define | M_VERTICE_TYPE 1 |
#define | M_SORT_X 1 |
#define | M_SORT_Y 2 |
#define | M_SORT_Z 3 |
Functions | |
s_vsort * | get_sorted_list (s_atm **atoms, int natms, s_vvertice **pvert, int nvert) |
void | print_sorted_lst (s_vsort *lsort, FILE *buf) |
void | free_s_vsort (s_vsort *lsort) |
#define M_ATOM_TYPE 0 |
Definition at line 52 of file sort.h.
Referenced by merge_atom_vert(), partition_x(), and print_sorted_lst().
#define M_VERTICE_TYPE 1 |
Definition at line 53 of file sort.h.
Referenced by count_atm_prop_vert_neigh(), count_pocket_lig_vert_ovlp(), get_mol_ctd_atm_neigh(), get_mol_vert_neigh(), and merge_atom_vert().
void free_s_vsort | ( | s_vsort * | lsort | ) |
## FUNCTION: free_s_vsort
## SPECIFICATION: Free memory for s_vsort structure
## PARAMETRES: @ s_vsort *lsort: Structure to free
## RETURN:
Definition at line 328 of file sort.c.
References my_free(), and s_vsort::xsort.
Referenced by count_atm_prop_vert_neigh(), count_pocket_lig_vert_ovlp(), count_vert_neigh_P(), get_mol_atm_neigh(), get_mol_ctd_atm_neigh(), and get_mol_vert_neigh().
00329 { 00330 if(lsort) { 00331 if(lsort->xsort) my_free(lsort->xsort) ; 00332 00333 my_free(lsort) ; 00334 } 00335 }
s_vsort* get_sorted_list | ( | s_atm ** | atoms, | |
int | natms, | |||
s_vvertice ** | pvert, | |||
int | nvert | |||
) |
## FUNCTION: get_sorted_list
## SPECIFICATION: This function will return a lists which will contains all atoms and vertices sorted on x axis. First, we merge atom and vertice lists into those a single list. Then they will be sorted using a quickSort algorithm, using the x positions of vertices and atoms as criteria for sorting.
## PARAMETRES: @ s_pdb *pdb : PDB structure, basically containing atoms @ s_vvertice **pvert, int nvert : List of vertices (if NULL, only atoms will be sorted)
## RETURN: s_vsort*: pointer to the structure containing all sorted data (see .h)
Definition at line 86 of file sort.c.
References merge_atom_vert(), my_malloc(), s_vsort::nelem, qsort_dim(), and s_vsort::xsort.
Referenced by count_atm_prop_vert_neigh(), count_pocket_lig_vert_ovlp(), count_vert_neigh_P(), get_mol_atm_neigh(), get_mol_ctd_atm_neigh(), and get_mol_vert_neigh().
00087 { 00088 s_vsort *lsort = (s_vsort *) my_malloc(sizeof(s_vsort)) ; 00089 00090 lsort->nelem = 0 ; 00091 00092 if(atoms) lsort->nelem += natms ; 00093 if(pvert) lsort->nelem += nvert ; 00094 00095 if(lsort->nelem == 0) return NULL ; 00096 00097 /* Allocate memory */ 00098 lsort->xsort = (s_vect_elem*) my_malloc((lsort->nelem)*sizeof(s_vect_elem)) ; 00099 00100 merge_atom_vert(lsort, atoms, natms, pvert, nvert) ; 00101 qsort_dim(lsort->xsort, lsort->nelem) ; 00102 00103 return lsort ; 00104 00105 }
void print_sorted_lst | ( | s_vsort * | lsort, | |
FILE * | buf | |||
) |
## FUNCTION: print_sorted_lst
## SPECIFICATION: Print one of the sorted tab of a s_vsort structure
## PARAMETRES: @ s_vsort *lsort : Structure containing tab @ FILE *buf : Buffer to print in.
## RETURN:
Definition at line 286 of file sort.c.
References M_ATOM_TYPE, s_vsort::nelem, s_vvertice::sort_x, s_atm::sort_x, s_vvertice::x, s_atm::x, and s_vsort::xsort.
00287 { 00288 s_vect_elem *lst = NULL ; 00289 lst = lsort->xsort ; fprintf(buf, "\n========== Printing list of vertices and atoms sorted on X axe:\n") ; 00290 00291 float cval, prev = -1.0 ; 00292 int i ; 00293 00294 for(i = 0 ; i < lsort->nelem ; i++) { 00295 fprintf(buf, "> Element at %d: ", i); 00296 if(lst[i].type == M_ATOM_TYPE) { 00297 s_atm *a = (s_atm*) lst[i].data ; 00298 cval = a->x ; 00299 fprintf(buf, " ATOM coord = %f, index stored: %d", cval, a->sort_x) ; 00300 } 00301 else { 00302 s_vvertice *v = (s_vvertice*) lst[i].data ; 00303 cval = v->x ; 00304 00305 fprintf(buf, " VERTICE coord = %f, index stored: %d", cval, v->sort_x) ; 00306 } 00307 00308 if(prev > cval) fprintf(buf, " !!!!!!! ") ; 00309 fprintf(buf, "\n") ; 00310 00311 prev = cval ; 00312 } 00313 }