"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/RepSurface.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

RepSurface.cpp  (pymol-open-source-2.2.0):RepSurface.cpp  (pymol-open-source-2.3.0)
skipping to change at line 74 skipping to change at line 74
/* These variables are for using the shader. All of them */ /* These variables are for using the shader. All of them */
/* are allocated/set when generate_shader_cgo to minimize */ /* are allocated/set when generate_shader_cgo to minimize */
/* allocation during the rendering loop. */ /* allocation during the rendering loop. */
CGO *shaderCGO, *pickingCGO; CGO *shaderCGO, *pickingCGO;
short dot_as_spheres; short dot_as_spheres;
#ifdef _PYMOL_IOS #ifdef _PYMOL_IOS
#endif #endif
} RepSurface; } RepSurface;
void RepSurfaceFree(RepSurface * I); static
int RepSurfaceSameVis(RepSurface * I, CoordSet * cs);
void RepSurfaceColor(RepSurface * I, CoordSet * cs);
void RepSurfaceSmoothEdges(RepSurface * I); void RepSurfaceSmoothEdges(RepSurface * I);
static void setShaderCGO(RepSurface * I, CGO * cgo) { static void setShaderCGO(RepSurface * I, CGO * cgo) {
if (I->shaderCGO != I->pickingCGO) { if (I->shaderCGO != I->pickingCGO) {
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
} }
I->shaderCGO = cgo; I->shaderCGO = cgo;
} }
static void setPickingCGO(RepSurface * I, CGO * cgo) { static void setPickingCGO(RepSurface * I, CGO * cgo) {
if (I->shaderCGO != I->pickingCGO) { if (I->shaderCGO != I->pickingCGO) {
CGOFree(I->pickingCGO); CGOFree(I->pickingCGO);
} }
I->pickingCGO = cgo; I->pickingCGO = cgo;
} }
static
void RepSurfaceFree(RepSurface * I) void RepSurfaceFree(RepSurface * I)
{ {
VLAFreeP(I->V); VLAFreeP(I->V);
VLAFreeP(I->VN); VLAFreeP(I->VN);
setPickingCGO(I, NULL); setPickingCGO(I, NULL);
setShaderCGO(I, NULL); setShaderCGO(I, NULL);
#ifdef _PYMOL_IOS #ifdef _PYMOL_IOS
#endif #endif
FreeP(I->VC); FreeP(I->VC);
FreeP(I->VA); FreeP(I->VA);
skipping to change at line 1427 skipping to change at line 1426
I->pickingCGO->no_pick = !pick_surface; I->pickingCGO->no_pick = !pick_surface;
} }
} }
return ok; return ok;
} }
static void RepSurfaceRender(RepSurface * I, RenderInfo * info) static void RepSurfaceRender(RepSurface * I, RenderInfo * info)
{ {
CRay *ray = info->ray; CRay *ray = info->ray;
Picking **pick = info->pick; auto pick = info->pick;
PyMOLGlobals *G = I->R.G; PyMOLGlobals *G = I->R.G;
float *v = I->V; float *v = I->V;
float *vn = I->VN; float *vn = I->VN;
float *vc = I->VC; float *vc = I->VC;
float *va = I->VA; float *va = I->VA;
int *rc = I->RC; int *rc = I->RC;
int *t = I->T; int *t = I->T;
int *s = I->S; int *s = I->S;
int c = I->N; int c = I->N;
int *vi = I->Vis; int *vi = I->Vis;
int ok = true; int ok = true;
float alpha; float alpha;
int t_mode; int t_mode;
float ambient_occlusion_scale = 0.f; float ambient_occlusion_scale = 0.f;
int ambient_occlusion_mode = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setti ng, cSetting_ambient_occlusion_mode); int ambient_occlusion_mode = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setti ng, cSetting_ambient_occlusion_mode);
int ambient_occlusion_mode_div_4; int ambient_occlusion_mode_div_4 = 0;
if (ambient_occlusion_mode){ if (ambient_occlusion_mode){
ambient_occlusion_scale = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Settin g, cSetting_ambient_occlusion_scale); ambient_occlusion_scale = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Settin g, cSetting_ambient_occlusion_scale);
ambient_occlusion_mode_div_4 = ambient_occlusion_mode / 4; ambient_occlusion_mode_div_4 = ambient_occlusion_mode / 4;
} }
if((I->Type != 1) && (!s)) { if((I->Type != 1) && (!s)) {
return; return;
} }
alpha = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_transpar ency); alpha = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_transpar ency);
skipping to change at line 2139 skipping to change at line 2138
} }
#endif #endif
} }
} }
if (!ok){ if (!ok){
I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge); I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge);
I->R.cs->Active[cRepSurface] = false; I->R.cs->Active[cRepSurface] = false;
} }
} }
static
int RepSurfaceSameVis(RepSurface * I, CoordSet * cs) int RepSurfaceSameVis(RepSurface * I, CoordSet * cs)
{ {
int same = true; int same = true;
char *lv; char *lv;
int a; int a;
AtomInfoType *ai; AtomInfoType *ai;
ai = cs->Obj->AtomInfo; ai = cs->Obj->AtomInfo;
lv = I->LastVisib; lv = I->LastVisib;
skipping to change at line 2187 skipping to change at line 2187
if(ai->visRep & cRepSurfaceBit) { if(ai->visRep & cRepSurfaceBit) {
if(*(lc++) != ai->color) { if(*(lc++) != ai->color) {
return false; return false;
} }
} }
} }
} }
return true; return true;
} }
static
void RepSurfaceColor(RepSurface * I, CoordSet * cs) void RepSurfaceColor(RepSurface * I, CoordSet * cs)
{ {
PyMOLGlobals *G = cs->State.G; PyMOLGlobals *G = cs->State.G;
MapType *map = NULL, *ambient_occlusion_map = NULL; MapType *map = NULL, *ambient_occlusion_map = NULL;
int a, i0, i, j, c1; int a, i0, i, j, c1;
float *v0, *vc, *va; float *v0, *vc, *va;
const float *c0; const float *c0;
float *n0; float *n0;
int *vi, *lc; int *lc;
char *lv; char *lv;
int first_color; int first_color;
float *v_pos, v_above[3]; float *v_pos, v_above[3];
int ramp_above; int ramp_above;
ObjectMolecule *obj; ObjectMolecule *obj;
float probe_radius; float probe_radius;
float dist; float dist;
float cutoff; float cutoff;
int inclH; int inclH;
int inclInvis; int inclInvis;
skipping to change at line 2317 skipping to change at line 2318
I->VC = Alloc(float, 3 * I->N); I->VC = Alloc(float, 3 * I->N);
vc = I->VC; vc = I->VC;
if(!I->VA) if(!I->VA)
I->VA = Alloc(float, I->N); I->VA = Alloc(float, I->N);
va = I->VA; va = I->VA;
if(!I->RC) if(!I->RC)
I->RC = Alloc(int, I->N); I->RC = Alloc(int, I->N);
rc = I->RC; rc = I->RC;
if(!I->Vis) if(!I->Vis)
I->Vis = Alloc(int, I->N); I->Vis = Alloc(int, I->N);
vi = I->Vis;
if(ColorCheckRamped(G, surface_color)) { if(ColorCheckRamped(G, surface_color)) {
I->oneColorFlag = false; I->oneColorFlag = false;
} else { } else {
I->oneColorFlag = true; I->oneColorFlag = true;
} }
first_color = -1; first_color = -1;
present = Alloc(int, cs->NIndex); present = Alloc(int, cs->NIndex);
{ {
int *ap = present; int *ap = present;
skipping to change at line 2374 skipping to change at line 2374
j = map->EList[i++]; j = map->EList[i++];
} }
} }
} }
} }
} }
MapFree(map); MapFree(map);
map = NULL; map = NULL;
} }
if (ambient_occlusion_mode){ /**
* Update the ambient occlusion accessibility array (VAO)
*/
auto update_VAO = [&]() {
if (!ambient_occlusion_mode) {
VLAFreeP(I->VAO);
return;
}
float maxDist = 0.f, maxDistA =0.f; float maxDist = 0.f, maxDistA =0.f;
int level_min = 64, level_max = 0; int level_min = 64, level_max = 0;
double start_time, cur_time; double start_time, cur_time;
short vertex_map = 0; /* vertex or atom map */ short vertex_map = 0; /* vertex or atom map */
float map_cutoff = cutoff; float map_cutoff = cutoff;
switch (ambient_occlusion_mode % 4){ switch (ambient_occlusion_mode % 4){
case 1: case 1:
case 3: case 3:
vertex_map = 0; /* ambient_occlusion_mode - 1 atoms in map (default), 2 - vertices in map */ vertex_map = 0; /* ambient_occlusion_mode - 1 atoms in map (default), 2 - vertices in map */
skipping to change at line 2593 skipping to change at line 2601
float *tmpVAO = Alloc(float, I->N); float *tmpVAO = Alloc(float, I->N);
int *nVAO = Alloc(int, I->N), c, *t; int *nVAO = Alloc(int, I->N), c, *t;
for (j=0; j<ambient_occlusion_smooth; j++){ for (j=0; j<ambient_occlusion_smooth; j++){
memset(nVAO, 0, sizeof(int)*I->N); memset(nVAO, 0, sizeof(int)*I->N);
memset(tmpVAO, 0, sizeof(float)*I->N); memset(tmpVAO, 0, sizeof(float)*I->N);
t = I->T; t = I->T;
c = I->NT; c = I->NT;
while (c--){ while (c--){
if (visibility_test(I->proximity, vi, t)) { if (I->allVisibleFlag ||
visibility_test(I->proximity, I->Vis, t)) {
pt1 = *t; pt2 = *(t+1); pt3 = *(t+2); pt1 = *t; pt2 = *(t+1); pt3 = *(t+2);
nVAO[pt1] += 1; nVAO[pt2] += 1; nVAO[pt3] += 1; nVAO[pt1] += 1; nVAO[pt2] += 1; nVAO[pt3] += 1;
ave = ave3(I->VAO[pt1], I->VAO[pt2], I->VAO[pt3]); ave = ave3(I->VAO[pt1], I->VAO[pt2], I->VAO[pt3]);
tmpVAO[pt1] += ave; tmpVAO[pt1] += ave;
tmpVAO[pt2] += ave; tmpVAO[pt2] += ave;
tmpVAO[pt3] += ave; tmpVAO[pt3] += ave;
} }
t +=3; t +=3;
skipping to change at line 2624 skipping to change at line 2633
FreeP(tmpVAO); FreeP(tmpVAO);
FreeP(nVAO); FreeP(nVAO);
} }
} }
MapFree(ambient_occlusion_map); MapFree(ambient_occlusion_map);
cur_time = UtilGetSeconds(G); cur_time = UtilGetSeconds(G);
PRINTFB(I->R.G, FB_RepSurface, FB_Debugging) "RepSurfaceColor(): Ambient Occlusion computed #atoms=%d #vertices=%d time=%lf seconds\n", cs->NIndex, I->N, (cur_time-start_time) ENDFB(I->R.G); PRINTFB(I->R.G, FB_RepSurface, FB_Debugging) "RepSurfaceColor(): Ambient Occlusion computed #atoms=%d #vertices=%d time=%lf seconds\n", cs->NIndex, I->N, (cur_time-start_time) ENDFB(I->R.G);
ambient_occlusion_map = NULL; ambient_occlusion_map = NULL;
} else {
if (I->VAO){ }; // update_VAO
VLAFreeP(I->VAO);
I->VAO = 0;
}
}
/* now, assign colors to each point */ /* now, assign colors to each point */
map = MapNewFlagged(G, cutoff, cs->Coord, cs->NIndex, NULL, present); map = MapNewFlagged(G, cutoff, cs->Coord, cs->NIndex, NULL, present);
if(map) { if(map) {
short color_smoothing = SettingGetGlobal_i(G, cSetting_surface_color_smoot hing); short color_smoothing = SettingGetGlobal_i(G, cSetting_surface_color_smoot hing);
float color_smoothing_threshold = SettingGetGlobal_f(G, cSetting_surface_c olor_smoothing_threshold); float color_smoothing_threshold = SettingGetGlobal_f(G, cSetting_surface_c olor_smoothing_threshold);
int atm, ok = true; int atm, ok = true;
MapSetupExpress(map); MapSetupExpress(map);
ok &= !G->Interrupt; ok &= !G->Interrupt;
if (ok && !I->AT) if (ok && !I->AT)
I->AT = VLACalloc(int, I->N); I->AT = VLACalloc(int, I->N);
skipping to change at line 2651 skipping to change at line 2657
float at_transp = transp; float at_transp = transp;
AtomInfoType *ai0 = NULL; AtomInfoType *ai0 = NULL;
float minDist = MAXFLOAT, minDist2 = MAXFLOAT, distDiff = MAXFLOAT; float minDist = MAXFLOAT, minDist2 = MAXFLOAT, distDiff = MAXFLOAT;
int pi = -1, catm = -1; /* variables for color smoothing */ int pi = -1, catm = -1; /* variables for color smoothing */
AtomInfoType *pai = NULL, *pai2 = NULL; /* variables for color smoothing */ AtomInfoType *pai = NULL, *pai2 = NULL; /* variables for color smoothing */
c1 = 1; c1 = 1;
i0 = -1; i0 = -1;
v0 = I->V + 3 * a; v0 = I->V + 3 * a;
n0 = I->VN + 3 * a; n0 = I->VN + 3 * a;
vi = I->Vis + a; auto vi = I->Vis + a;
/* colors */ /* colors */
i = *(MapLocusEStart(map, v0)); i = *(MapLocusEStart(map, v0));
if(i && map->EList) { if(i && map->EList) {
j = map->EList[i++]; j = map->EList[i++];
while(j >= 0) { while(j >= 0) {
atm = cs->IdxToAtm[j]; atm = cs->IdxToAtm[j];
ai2 = obj->AtomInfo + atm; ai2 = obj->AtomInfo + atm;
if((inclH || (!ai2->isHydrogen())) && if((inclH || (!ai2->isHydrogen())) &&
((!cullByFlag) || (!(ai2->flags & cAtomFlag_ignore)))) { ((!cullByFlag) || (!(ai2->flags & cAtomFlag_ignore)))) {
dist = (float) diff3f(v0, cs->Coord + j * 3) - ai2->vdw; dist = (float) diff3f(v0, cs->Coord + j * 3) - ai2->vdw;
skipping to change at line 2829 skipping to change at line 2835
*(vc++) = *(c0++); *(vc++) = *(c0++);
*(vc++) = *(c0++); *(vc++) = *(c0++);
} }
} }
if(at_transp != transp) if(at_transp != transp)
variable_alpha = true; variable_alpha = true;
*(va++) = 1.0F - at_transp; *(va++) = 1.0F - at_transp;
if(!*vi) if(!*vi)
I->allVisibleFlag = false; I->allVisibleFlag = false;
vi++;
} }
MapFree(map); MapFree(map);
} }
if(variable_alpha) if(variable_alpha)
I->oneColorFlag = false; I->oneColorFlag = false;
if(I->oneColorFlag) { if(I->oneColorFlag) {
I->oneColor = first_color; I->oneColor = first_color;
} }
// ambient occlusion
update_VAO();
} }
/* /*
if(surface_color>=0) { if(surface_color>=0) {
I->oneColorFlag=true; I->oneColorFlag=true;
I->oneColor=surface_color; I->oneColor=surface_color;
} }
*/ */
if(G->HaveGUI) { if(G->HaveGUI) {
setShaderCGO(I, NULL); setShaderCGO(I, NULL);
skipping to change at line 3970 skipping to change at line 3978
surf_job->carveCutoff = carve_cutoff; surf_job->carveCutoff = carve_cutoff;
surf_job->surfaceMode = SettingGet_i(G, cs->Setting, obj->Obj.Setting, cSett ing_surface_mode); surf_job->surfaceMode = SettingGet_i(G, cs->Setting, obj->Obj.Setting, cSett ing_surface_mode);
surf_job->surfaceSolvent = SettingGet_b(G, cs->Setting, obj->Obj.Setting, cS etting_surface_solvent); surf_job->surfaceSolvent = SettingGet_b(G, cs->Setting, obj->Obj.Setting, cS etting_surface_solvent);
surf_job->cavityCull = SettingGet_i(G, cs->Setting, surf_job->cavityCull = SettingGet_i(G, cs->Setting,
obj->Obj.Setting, cSetting_cavity_cull); obj->Obj.Setting, cSetting_cavity_cull);
} }
return ok; return ok;
} }
#ifndef _PYMOL_NOPY #ifndef _PYMOL_NOPY
static
void RepSurfaceConvertSurfaceJobToPyObject(PyMOLGlobals *G, SurfaceJob *surf_job , CoordSet *cs, ObjectMolecule *obj, PyObject **entry, PyObject **input, PyObjec t **output, int *found){ void RepSurfaceConvertSurfaceJobToPyObject(PyMOLGlobals *G, SurfaceJob *surf_job , CoordSet *cs, ObjectMolecule *obj, PyObject **entry, PyObject **input, PyObjec t **output, int *found){
int cache_mode = SettingGet_i(G, cs->Setting, obj->Obj.Setting, cSetting_cache _mode); int cache_mode = SettingGet_i(G, cs->Setting, obj->Obj.Setting, cSetting_cache _mode);
if(cache_mode > 0) { if(cache_mode > 0) {
int blocked = PAutoBlock(G); int blocked = PAutoBlock(G);
*input = SurfaceJobInputAsTuple(G, surf_job); *input = SurfaceJobInputAsTuple(G, surf_job);
if(PCacheGet(G, output, entry, *input) == OV_STATUS_YES) { if(PCacheGet(G, output, entry, *input) == OV_STATUS_YES) {
if(OV_OK(SurfaceJobResultFromTuple(G, surf_job, *output))) { if(OV_OK(SurfaceJobResultFromTuple(G, surf_job, *output))) {
*found = true; *found = true;
skipping to change at line 4357 skipping to change at line 4366
} }
if(!ok) { if(!ok) {
RepSurfaceFree(I); RepSurfaceFree(I);
I = NULL; I = NULL;
} }
return (Rep *) I; return (Rep *) I;
} }
void RepSurfaceSmoothEdges(RepSurface * I) void RepSurfaceSmoothEdges(RepSurface * I)
{ {
if (I->allVisibleFlag)
return;
std::vector<std::vector<int>> edges(I->N); std::vector<std::vector<int>> edges(I->N);
// Find all edges. // Find all edges.
// Uses the following edge structure: // Uses the following edge structure:
// edge[v0] -> { v1, t0, t1 } // edge[v0] -> { v1, t0, t1 }
// where (v0, v1) defines an edge and (t0, t1) // where (v0, v1) defines an edge and (t0, t1)
// are triangles the edge belongs to. // are triangles the edge belongs to.
// The edge is unique when t0 == t1. // The edge is unique when t0 == t1.
int *t = I->T; int *t = I->T;
int *vi = I->Vis; int *vi = I->Vis;
for (auto i = 0; i < I->NT; i++) { for (auto i = 0; i < I->NT; i++) {
 End of changes. 16 change blocks. 
17 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)