1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* Copyright (c) Schrodinger, LLC.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_Map
#define _H_Map
/* Map - a 3-D hash object for optimizing neighbor searches */
#include"Vector.h"
#include"PyMOLGlobals.h"
struct MapType {
PyMOLGlobals *G;
float Div;
float recipDiv;
Vector3i Dim;
int D1D2;
Vector3i iMin, iMax;
int* Head = nullptr;
int* Link = nullptr;
int* EHead = nullptr;
int* EList = nullptr;
int* EMask = nullptr;
int NVert;
int NEElem = 0;
Vector3f Max, Min;
int group_id;
int block_base;
~MapType();
};
typedef struct {
PyMOLGlobals *G;
int *Cache, *CacheLink, CacheStart;
int block_base;
} MapCache;
#define MapBorder 2
MapType *MapNew(PyMOLGlobals * G, float range, const float *vert, int nVert,
const float* extent = nullptr);
MapType *MapNewCached(PyMOLGlobals * G, float range, const float *vert, int nVert,
const float *extent, int group_id, int block_id);
using MapFlag_t = int;
MapType *MapNewFlagged(PyMOLGlobals * G, float range, const float *vert, int nVert,
const float *extent, const MapFlag_t *flag);
int MapSetupExpress(MapType * I);
int MapSetupExpressPerp(MapType * I, const float *vert, float front, int nVertHint,
int negative_start, const int *spanner);
#define MapFree(I) delete(I)
#define MapFirst(m,a,b,c) (m->Head + ((a) * m->D1D2) + ((b)*m->Dim[2]) + (c))
#define MapEStart(m,a,b,c) (m->EHead + ((a) * m->D1D2) + ((b)*m->Dim[2]) + (c))
#define MapNext(m,a) (*(m->Link+(a)))
void MapLocus(const MapType * map, const float *v, int *a, int *b, int *c);
int *MapLocusEStart(MapType * map, const float *v);
#define MapCache(m,a) {(m)->Cache[a]=1;(m)->CacheLink[a]=(m)->CacheStart;(m)->CacheStart=a;}
#define MapCached(m,a) ((m)->Cache[a])
int MapCacheInit(MapCache * M, MapType * I, int group_id, int block_base);
void MapCacheReset(MapCache * M);
void MapCacheFree(MapCache * M, int group_id, int block_base);
float MapGetSeparation(PyMOLGlobals * G, float range, const float *mx, const float *mn,
float *diagonal);
float MapGetDiv(MapType * I);
/* special routines for raytracing */
int MapInsideXY(MapType * I, const float *v, int *a, int *b, int *c);
int MapSetupExpressXY(MapType * I, int n_vert, int negative_start);
int MapSetupExpressXYVert(MapType * I, float *vert, int n_vert, int negative_start);
/**
* Range iteration over points in proximity of a 3D query point
*/
class MapEIter
{
const int* m_elist = nullptr;
int m_i = 0;
public:
MapEIter() = default;
/**
* @param map Map to query
* @param v 3D query point
* @param excl If true, exclude `v` if it's outside the grid
*/
MapEIter(MapType& map, const float* v, bool excl = true);
bool operator!=(MapEIter const& other) const { return m_i != other.m_i; }
int operator*() const { return m_elist[m_i]; }
MapEIter& operator++()
{
if (m_elist[++m_i] < 0) {
m_i = 0;
}
return *this;
}
MapEIter begin() const { return *this; }
MapEIter end() const { return {}; }
};
bool MapAnyWithin(
MapType& map, const float* v_map, const float* v_query, float cutoff);
#endif
|