00001 #include "../headers/refine.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 void refinePockets(c_lst_pockets *pockets, s_fparams *params)
00079 {
00080 node_pocket *nextPocket;
00081 node_pocket *curMobilePocket;
00082
00083 node_pocket *pcur = NULL ;
00084
00085 float *pbary = NULL,
00086 *mpbary = NULL, dst ;
00087
00088 if(pockets) {
00089 pcur = pockets->first ;
00090 while(pcur) {
00091 pbary = pcur->pocket->bary ;
00092 curMobilePocket = pcur->next ;
00093
00094 while(curMobilePocket) {
00095 mpbary = curMobilePocket->pocket->bary ;
00096 nextPocket = curMobilePocket->next ;
00097 dst = dist(pbary[0], pbary[1], pbary[2], mpbary[0], mpbary[1], mpbary[2]) ;
00098 if(dst < params->refine_clust_dist) {
00099
00100 mergePockets(pcur, curMobilePocket, pockets);
00101 }
00102 curMobilePocket = nextPocket ;
00103 }
00104
00105 pcur = pcur->next ;
00106 }
00107 }
00108 else {
00109 fprintf(stderr, "! No pocket to refine! (argument NULL: %p).\n", pockets) ;
00110 }
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 void dropSmallNpolarPockets(c_lst_pockets *pockets, s_fparams *params)
00131 {
00132 double pasph = 0.0 ;
00133 node_pocket *npcur = NULL,
00134 *nextPocket1 = NULL;
00135 s_pocket *pcur = NULL ;
00136
00137 if(pockets) {
00138 npcur = pockets->first ;
00139 while(npcur) {
00140 pcur = npcur->pocket ;
00141 nextPocket1 = npcur->next ;
00142 pasph = (float)((float)pcur->nAlphaApol/(float)pcur->v_lst->n_vertices) ;
00143
00144
00145 if(pcur->v_lst->n_vertices < (size_t) params->min_pock_nb_asph
00146 || pasph < (params->refine_min_apolar_asphere_prop)){
00147
00148
00149 dropPocket(pockets, npcur);
00150 }
00151
00152 if(pockets->n_pockets <= 0) fprintf(stderr, "! No Pockets Found while refining\n");
00153 npcur = nextPocket1 ;
00154 }
00155 }
00156 else {
00157 fprintf(stderr, "! No pockets to drop from (argument NULL: %p).\n", pockets) ;
00158 }
00159
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 void drop_tiny(c_lst_pockets *pockets)
00177 {
00178 node_pocket *npcur = pockets->first,
00179 *npnext = NULL ;
00180 while(npcur) {
00181 npnext = npcur->next ;
00182
00183 if(npcur->pocket->v_lst->n_vertices < 2){
00184
00185 dropPocket(pockets, npcur);
00186 }
00187
00188 if(pockets->n_pockets <= 0) fprintf(stderr, "! No Pockets Found while refining\n");
00189 npcur = npnext ;
00190 }
00191 }
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 void reIndexPockets(c_lst_pockets *pockets)
00209 {
00210 node_vertice *vcur = NULL ;
00211 node_pocket *pcur = NULL ;
00212 s_pocket *pock_cur = NULL ;
00213
00214 int curPocket = 0,
00215 n_vert ;
00216
00217 float posSum[3];
00218
00219 if(pockets && pockets->n_pockets > 0) {
00220 pcur = pockets->first ;
00221 while(pcur) {
00222 curPocket++ ;
00223 n_vert = 0 ;
00224
00225 pock_cur = pcur->pocket ;
00226 pock_cur->bary[0]=0 ;
00227 pock_cur->bary[1]=0 ;
00228 pock_cur->bary[2]=0 ;
00229
00230 posSum[0]=0; posSum[1]=0; posSum[2]=0;
00231 if(pock_cur->v_lst){
00232 vcur = pock_cur->v_lst->first;
00233
00234 while(vcur){
00235 posSum[0] += vcur->vertice->x;
00236 posSum[1] += vcur->vertice->y;
00237 posSum[2] += vcur->vertice->z;
00238 n_vert++;
00239
00240 vcur->vertice->resid = curPocket;
00241 vcur = vcur->next ;
00242 }
00243 }
00244 else {
00245 fprintf(stderr, "! Empty Pocket...something might be wrong over here ;).\n") ;
00246 }
00247
00248 pock_cur->bary[0] = posSum[0]/(float)n_vert;
00249 pock_cur->bary[1] = posSum[1]/(float)n_vert;
00250 pock_cur->bary[2] = posSum[2]/(float)n_vert;
00251 pcur = pcur->next ;
00252 }
00253 }
00254 else {
00255 fprintf(stderr, "! No pocket to reindex.\n") ;
00256 }
00257 }
00258