ObjectMolecule2.cpp (pymol-open-source-2.2.0) | : | ObjectMolecule2.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#include"P.h" | #include"P.h" | |||
#include"ObjectCGO.h" | #include"ObjectCGO.h" | |||
#include"Scene.h" | #include"Scene.h" | |||
#include "Lex.h" | #include "Lex.h" | |||
#include"AtomInfoHistory.h" | #include"AtomInfoHistory.h" | |||
#include"BondTypeHistory.h" | #include"BondTypeHistory.h" | |||
#include <iostream> | #include <iostream> | |||
#include <map> | #include <map> | |||
#ifdef _PYMOL_NO_CXX11 | ||||
#define STD_MOVE(x) (x) | ||||
#else | ||||
#define STD_MOVE(x) std::move(x) | ||||
#endif | ||||
#define ntrim ParseNTrim | #define ntrim ParseNTrim | |||
#define nextline ParseNextLine | #define nextline ParseNextLine | |||
#define ncopy ParseNCopy | #define ncopy ParseNCopy | |||
#define nskip ParseNSkip | #define nskip ParseNSkip | |||
#define cResvMask 0x7FFF | #define cResvMask 0x7FFF | |||
#define cMaxOther 6 | #define cMaxOther 6 | |||
#define strstartswith p_strstartswith | #define strstartswith p_strstartswith | |||
skipping to change at line 245 | skipping to change at line 239 | |||
int hetatm, float b, float q, const char *label, | int hetatm, float b, float q, const char *label, | |||
float *pos, int color, int state, int mode, int quiet) | float *pos, int color, int state, int mode, int quiet) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
int start_state = 0, stop_state = 0; | int start_state = 0, stop_state = 0; | |||
int extant_only = false; | int extant_only = false; | |||
int ai_merged = false; | int ai_merged = false; | |||
float pos_array[3] = { 0.0F, 0.0F, 0.0F }; | float pos_array[3] = { 0.0F, 0.0F, 0.0F }; | |||
int ok = true; | int ok = true; | |||
AtomInfoType *atInfo = VLACalloc(AtomInfoType, 1); | pymol::vla<AtomInfoType> atInfo(1); | |||
AtomInfoType* ai = atInfo.data(); | ||||
#ifdef _PYMOL_IP_EXTRAS | #ifdef _PYMOL_IP_EXTRAS | |||
atInfo->oldid = -1; | atInfo->oldid = -1; | |||
#endif | #endif | |||
if(state >= 0) { /* specific state */ | if(state >= 0) { /* specific state */ | |||
start_state = state; | start_state = state; | |||
stop_state = state + 1; | stop_state = state + 1; | |||
} else if(state == -1) { /* current state */ | } else if(state == -1) { /* current state */ | |||
start_state = ObjectGetCurrentState(&I->Obj, true); | start_state = ObjectGetCurrentState(&I->Obj, true); | |||
stop_state = start_state + 1; | stop_state = start_state + 1; | |||
} else { /* all states */ | } else { /* all states */ | |||
if(sele_index >= 0) { | if(sele_index >= 0) { | |||
start_state = 0; | start_state = 0; | |||
stop_state = SelectorCountStates(G, sele_index); | stop_state = SelectorCountStates(G, sele_index); | |||
skipping to change at line 270 | skipping to change at line 267 | |||
extant_only = true; | extant_only = true; | |||
} else { | } else { | |||
start_state = 0; | start_state = 0; | |||
stop_state = ExecutiveCountStates(G, cKeywordAll); | stop_state = ExecutiveCountStates(G, cKeywordAll); | |||
if(stop_state < 1) | if(stop_state < 1) | |||
stop_state = 1; | stop_state = 1; | |||
} | } | |||
} | } | |||
{ | { | |||
/* match existing properties of the old atom */ | /* match existing properties of the old atom */ | |||
AtomInfoType *ai = atInfo; | ||||
ai->setResi(resi); | ai->setResi(resi); | |||
ai->hetatm = hetatm; | ai->hetatm = hetatm; | |||
ai->geom = cAtomInfoNone; | ai->geom = cAtomInfoNone; | |||
ai->q = q; | ai->q = q; | |||
ai->b = b; | ai->b = b; | |||
ai->chain = LexIdx(G, chain); | ai->chain = LexIdx(G, chain); | |||
ai->segi = LexIdx(G, segi); | ai->segi = LexIdx(G, segi); | |||
ai->resn = LexIdx(G, resn); | ai->resn = LexIdx(G, resn); | |||
ai->name = LexIdx(G, name); | ai->name = LexIdx(G, name); | |||
strcpy(ai->elem, elem); | strcpy(ai->elem, elem); | |||
skipping to change at line 362 | skipping to change at line 358 | |||
op.cs1 = state; | op.cs1 = state; | |||
ExecutiveObjMolSeleOp(I->Obj.G, sele_index, &op); | ExecutiveObjMolSeleOp(I->Obj.G, sele_index, &op); | |||
vdw = sqrt1f(op.d1 / op.i1); | vdw = sqrt1f(op.d1 / op.i1); | |||
break; | break; | |||
case 0: | case 0: | |||
default: | default: | |||
vdw = 0.5F; | vdw = 0.5F; | |||
break; | break; | |||
} | } | |||
if(vdw >= 0.0F) | if(vdw >= 0.0F) | |||
atInfo->vdw = vdw; /* NOTE: only uses vdw from first state selection... */ | ai->vdw = vdw; /* NOTE: only uses vdw from first state sele ction... */ | |||
} | } | |||
} else { | } else { | |||
pos = NULL; /* skip this state */ | pos = NULL; /* skip this state */ | |||
} | } | |||
} else if(!pos) { | } else if(!pos) { | |||
pos = pos_array; | pos = pos_array; | |||
SceneGetCenter(I->Obj.G, pos); | SceneGetCenter(I->Obj.G, pos); | |||
} | } | |||
if(pos) { /* only add coordinate to state if we have posit ion for it */ | if(pos) { /* only add coordinate to state if we have posit ion for it */ | |||
float *coord = cset->Coord; | float *coord = cset->Coord; | |||
copy3f(pos, coord); | copy3f(pos, coord); | |||
if(!ai_merged) { | if(!ai_merged) { | |||
if (ok) | if (ok) | |||
ok &= ObjectMoleculeMerge(I, atInfo, cset, false, cAIC_AllMask, true) ; /* NOTE: will release atInfo */ | ok &= ObjectMoleculeMerge(I, std::move(atInfo), cset, false, cAIC_All Mask, true); /* NOTE: will release atInfo */ | |||
if (ok) | if (ok) | |||
ok &= ObjectMoleculeExtendIndices(I, -1); | ok &= ObjectMoleculeExtendIndices(I, -1); | |||
if (ok) | if (ok) | |||
ok &= ObjectMoleculeUpdateNeighbors(I); | ok &= ObjectMoleculeUpdateNeighbors(I); | |||
ai_merged = true; | ai_merged = true; | |||
} | } | |||
if(state >= I->NCSet) { | if(state >= I->NCSet) { | |||
VLACheck(I->CSet, CoordSet *, state); | VLACheck(I->CSet, CoordSet *, state); | |||
I->NCSet = state + 1; | I->NCSet = state + 1; | |||
} | } | |||
skipping to change at line 1828 | skipping to change at line 1824 | |||
} | } | |||
p = nextline(p); | p = nextline(p); | |||
} | } | |||
} | } | |||
/* | /* | |||
* Datastructure for efficient array-based secondary structure lookup. | * Datastructure for efficient array-based secondary structure lookup. | |||
*/ | */ | |||
typedef struct { | typedef struct { | |||
int n_ss; // number of ss_list items | int n_ss; // number of ss_list items | |||
int *(ss[256]); // one array for each chain identifier | int* ss[256]; // one array for each chain identifier | |||
SSEntry *ss_list; // VLA | SSEntry *ss_list; // VLA | |||
} SSHash; | } SSHash; | |||
static void sshash_free(SSHash *hash) { | static void sshash_free(SSHash *hash) { | |||
int a; | int a; | |||
if(!hash) | if(!hash) | |||
return; | return; | |||
for(a = 0; a <= 255; a++) | for(a = 0; a <= 255; a++) | |||
FreeP(hash->ss[a]); | FreeP(hash->ss[a]); | |||
VLAFreeP(hash->ss_list); | VLAFreeP(hash->ss_list); | |||
skipping to change at line 3676 | skipping to change at line 3672 | |||
bond->stereo = (short int) stereo; | bond->stereo = (short int) stereo; | |||
if(ok && (ll > 5)) { | if(ok && (ll > 5)) { | |||
int has_setting; | int has_setting; | |||
if(ok) | if(ok) | |||
ok = PConvPyIntToInt(PyList_GetItem(bond_list, 5), &bond->unique_id); | ok = PConvPyIntToInt(PyList_GetItem(bond_list, 5), &bond->unique_id); | |||
if(ok) | if(ok) | |||
ok = PConvPyIntToInt(PyList_GetItem(bond_list, 6), &has_setting); | ok = PConvPyIntToInt(PyList_GetItem(bond_list, 6), &has_setting); | |||
if(ok) | if(ok) | |||
bond->has_setting = (short int) has_setting; | bond->has_setting = (short int) has_setting; | |||
if(ok && bond->unique_id) { /* reserve existing IDs */ | if(ok && bond->unique_id) { /* reserve existing IDs */ | |||
bond->unique_id = SettingUniqueConvertOldSessionID(I->Obj.G, bond->uniqu e_id); | bond->unique_id = SettingUniqueConvertOldSessionID(G, bond->unique_id); | |||
} | } | |||
} | } | |||
bond++; | bond++; | |||
} | } | |||
} | } | |||
PRINTFB(I->Obj.G, FB_ObjectMolecule, FB_Debugging) | PRINTFB(G, FB_ObjectMolecule, FB_Debugging) | |||
" ObjectMoleculeBondFromPyList: ok %d after restore\n", ok ENDFB(I->Obj.G); | " ObjectMoleculeBondFromPyList: ok %d after restore\n", ok ENDFB(G); | |||
return (ok); | return (ok); | |||
} | } | |||
static PyObject *ObjectMoleculeAtomAsPyList(ObjectMolecule * I) | static PyObject *ObjectMoleculeAtomAsPyList(ObjectMolecule * I) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
PyObject *result = NULL; | PyObject *result = NULL; | |||
AtomInfoType *ai; | AtomInfoType *ai; | |||
int a; | int a; | |||
#ifndef PICKLETOOLS | #ifndef PICKLETOOLS | |||
int pse_export_version = SettingGetGlobal_f(I->Obj.G, cSetting_pse_export_vers ion) * 1000; | int pse_export_version = SettingGetGlobal_f(I->Obj.G, cSetting_pse_export_vers ion) * 1000; | |||
if (SettingGetGlobal_b(G, cSetting_pse_binary_dump) && (!pse_export_version || pse_export_version >= 1765)){ | if (SettingGetGlobal_b(G, cSetting_pse_binary_dump) && (!pse_export_version || pse_export_version >= 1765)){ | |||
/* For the pse_binary_dump, record all strings in lex and | /* For the pse_binary_dump, record all strings in lex and | |||
write them into separate binary string | write them into separate binary string | |||
*/ | */ | |||
std::set<int> lexIDs; | AtomInfoTypeConverter converter(G, I->NAtom); | |||
std::set<lexidx_t> lexIDs; | ||||
int totalstlen = 0; | int totalstlen = 0; | |||
AtomInfoType *ai = I->AtomInfo; | AtomInfoType *ai = I->AtomInfo; | |||
for(a = 0; a < I->NAtom; a++) { | for(a = 0; a < I->NAtom; a++) { | |||
if (ai->textType) lexIDs.insert(ai->textType); | if (ai->textType) lexIDs.insert(ai->textType); | |||
if (ai->chain) lexIDs.insert(ai->chain); | if (ai->chain) lexIDs.insert(ai->chain); | |||
if (ai->label) lexIDs.insert(ai->label); | if (ai->label) lexIDs.insert(ai->label); | |||
if (ai->custom) lexIDs.insert(ai->custom); | if (ai->custom) lexIDs.insert(ai->custom); | |||
if (ai->segi) lexIDs.insert(ai->segi); | if (ai->segi) lexIDs.insert(ai->segi); | |||
if (ai->resn) lexIDs.insert(ai->resn); | if (ai->resn) lexIDs.insert(ai->resn); | |||
if (ai->name) lexIDs.insert(ai->name); | if (ai->name) lexIDs.insert(ai->name); | |||
++ai; | ++ai; | |||
} | } | |||
for (auto it = lexIDs.begin(); it != lexIDs.end(); ++it){ // need to calcula | for (const auto& lexID : lexIDs) { // need to calculate totalstlen so we can | |||
te totalstlen so we can allocate | allocate | |||
const char *lexstr = LexStr(G, *it); | const char *lexstr = LexStr(G, lexID); | |||
int lexlen = strlen(lexstr); | int lexlen = strlen(lexstr); | |||
totalstlen += lexlen + 1; | totalstlen += lexlen + 1; | |||
} | } | |||
int strinfolen = totalstlen + sizeof(int) * (lexIDs.size() + 1); | int strinfolen = totalstlen + sizeof(int) * (lexIDs.size() + 1); | |||
void *strinfo = Alloc(unsigned char, strinfolen); | void *strinfo = Alloc(unsigned char, strinfolen); | |||
int *strval = (int*)strinfo; | int *strval = (int*)strinfo; | |||
*(strval++) = lexIDs.size(); // first write number of strings into binary da ta string | *(strval++) = lexIDs.size(); // first write number of strings into binary da ta string | |||
char *strpl = (char*)((char*)strinfo + (1 + lexIDs.size()) * sizeof(int)); | char *strpl = (char*)((char*)strinfo + (1 + lexIDs.size()) * sizeof(int)); | |||
/* write map of lex ids and strings into binary data string as an array of i ds | /* write map of lex ids and strings into binary data string as an array of i ds | |||
and null-terminated strings */ | and null-terminated strings */ | |||
for (auto it = lexIDs.begin(); it != lexIDs.end(); ++it){ | for (const auto& lexID : lexIDs) { | |||
*(strval++) = *it; | *(strval++) = converter.to_lexidx_int(lexID); | |||
const char *strptr = LexStr(G, *it); | const char *strptr = LexStr(G, lexID); | |||
strcpy(strpl, strptr); | strcpy(strpl, strptr); | |||
strpl += strlen(strptr) + 1; | strpl += strlen(strptr) + 1; | |||
} | } | |||
auto version = AtomInfoVERSION; | auto version = AtomInfoVERSION; | |||
if (pse_export_version && pse_export_version < 1810) { | if (pse_export_version && pse_export_version < 1810) { | |||
if (pse_export_version < 1770) { | if (pse_export_version < 1770) { | |||
version = 176; | version = 176; | |||
} else { | } else { | |||
version = 177; | version = 177; | |||
} | } | |||
} | } | |||
AtomInfoTypeConverter converter(G, I->NAtom); | ||||
auto blob = converter.allocCopy(version, I->AtomInfo); | auto blob = converter.allocCopy(version, I->AtomInfo); | |||
auto blobsize = VLAGetByteSize(blob); | auto blobsize = VLAGetByteSize(blob); | |||
result = PyList_New(3); | result = PyList_New(3); | |||
PyList_SetItem(result, 0, PyInt_FromLong(version)); | PyList_SetItem(result, 0, PyInt_FromLong(version)); | |||
PyList_SetItem(result, 1, PyBytes_FromStringAndSize(reinterpret_cast<const c har*>(blob), blobsize)); | PyList_SetItem(result, 1, PyBytes_FromStringAndSize(reinterpret_cast<const c har*>(blob), blobsize)); | |||
PyList_SetItem(result, 2, PyBytes_FromStringAndSize(reinterpret_cast<const c har*>(strinfo), strinfolen)); | PyList_SetItem(result, 2, PyBytes_FromStringAndSize(reinterpret_cast<const c har*>(strinfo), strinfolen)); | |||
VLAFreeP(blob); | VLAFreeP(blob); | |||
FreeP(strinfo); | FreeP(strinfo); | |||
skipping to change at line 3765 | skipping to change at line 3761 | |||
#endif | #endif | |||
result = PyList_New(I->NAtom); | result = PyList_New(I->NAtom); | |||
ai = I->AtomInfo; | ai = I->AtomInfo; | |||
for(a = 0; a < I->NAtom; a++) { | for(a = 0; a < I->NAtom; a++) { | |||
PyList_SetItem(result, a, AtomInfoAsPyList(I->Obj.G, ai)); | PyList_SetItem(result, a, AtomInfoAsPyList(I->Obj.G, ai)); | |||
ai++; | ai++; | |||
} | } | |||
return (PConvAutoNone(result)); | return (PConvAutoNone(result)); | |||
} | } | |||
#define CONVERT_TO_NEW_LEX(lexval) \ | ||||
if (lexval){ \ | ||||
lexval = oldIDtoLexID[lexval]; \ | ||||
LexInc(G, lexval); \ | ||||
} | ||||
static int ObjectMoleculeAtomFromPyList(ObjectMolecule * I, PyObject * list) | static int ObjectMoleculeAtomFromPyList(ObjectMolecule * I, PyObject * list) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
int ok = true; | int ok = true; | |||
int a, ll; | int a, ll = 0; | |||
AtomInfoType *ai; | AtomInfoType *ai; | |||
if(ok) | if(ok) | |||
ok = PyList_Check(list); | ok = PyList_Check(list); | |||
if (ok) | if (ok) | |||
ll = PyList_Size(list); | ll = PyList_Size(list); | |||
bool pse_binary_dump = false; | bool pse_binary_dump = false; | |||
if (ll == 3){ | if (ll == 3){ | |||
skipping to change at line 3812 | skipping to change at line 3802 | |||
AtomInfoTypeConverter converter(G, I->NAtom); | AtomInfoTypeConverter converter(G, I->NAtom); | |||
auto& oldIDtoLexID = converter.lexidxmap; | auto& oldIDtoLexID = converter.lexidxmap; | |||
int nstrings = *(strval++); | int nstrings = *(strval++); | |||
char *strpl = (char*)(strval + nstrings); | char *strpl = (char*)(strval + nstrings); | |||
int strcnt = nstrings; | int strcnt = nstrings; | |||
int stlen; | int stlen; | |||
// populate oldIDtoLexID with nstrings from binary string data (3rd entry in list) | // populate oldIDtoLexID with nstrings from binary string data (3rd entry in list) | |||
while (strcnt){ | while (strcnt){ | |||
int idx = LexIdx(G, strpl); // increments ref count, need to take into acc ount | lexidx_t idx = LexIdx(G, strpl); // increments ref count, need to take int o account | |||
int oldidx = *(strval++); | int oldidx = *(strval++); | |||
oldIDtoLexID[oldidx] = idx; | oldIDtoLexID[oldidx] = idx; | |||
stlen = strlen(strpl); | stlen = strlen(strpl); | |||
strpl += stlen + 1; | strpl += stlen + 1; | |||
strcnt--; | strcnt--; | |||
} | } | |||
CPythonVal *strobj = CPythonVal_PyList_GetItem(G, list, 1); | CPythonVal *strobj = CPythonVal_PyList_GetItem(G, list, 1); | |||
auto strval_2 = PyBytes_AsSomeString(strobj); | auto strval_2 = PyBytes_AsSomeString(strobj); | |||
skipping to change at line 3866 | skipping to change at line 3856 | |||
" ObjectMoleculeAtomFromPyList: ok %d \n", ok ENDFB(I->Obj.G); | " ObjectMoleculeAtomFromPyList: ok %d \n", ok ENDFB(I->Obj.G); | |||
return (ok); | return (ok); | |||
} | } | |||
int ObjectMoleculeNewFromPyList(PyMOLGlobals * G, PyObject * list, | int ObjectMoleculeNewFromPyList(PyMOLGlobals * G, PyObject * list, | |||
ObjectMolecule ** result) | ObjectMolecule ** result) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
ObjectMolecule *I = NULL; | ObjectMolecule *I = NULL; | |||
int discrete_flag = 0; | int discrete_flag = 0; | |||
int ll; | ||||
(*result) = NULL; | (*result) = NULL; | |||
if(ok) | if(ok) | |||
ok = PyList_Check(list); | ok = PyList_Check(list); | |||
if(ok) | ||||
ll = PyList_Size(list); | ||||
/* TO SUPPORT BACKWARDS COMPATIBILITY... | /* TO SUPPORT BACKWARDS COMPATIBILITY... | |||
Always check ll when adding new PyList_GetItem's */ | Always check ll when adding new PyList_GetItem's */ | |||
if(ok) | if(ok) | |||
ok = PConvPyIntToInt(PyList_GetItem(list, 8), &discrete_flag); | ok = PConvPyIntToInt(PyList_GetItem(list, 8), &discrete_flag); | |||
if (ok) | if (ok) | |||
I = ObjectMoleculeNew(G, discrete_flag); | I = ObjectMoleculeNew(G, discrete_flag); | |||
CHECKOK(ok, I); | CHECKOK(ok, I); | |||
if(ok) | if(ok) | |||
skipping to change at line 3919 | skipping to change at line 3906 | |||
ok = PConvPyIntToInt(PyList_GetItem(list, 13), &I->AtomCounter); | ok = PConvPyIntToInt(PyList_GetItem(list, 13), &I->AtomCounter); | |||
I->updateAtmToIdx(); | I->updateAtmToIdx(); | |||
if (ok) | if (ok) | |||
ObjectMoleculeInvalidate(I, cRepAll, cRepInvAll, -1); | ObjectMoleculeInvalidate(I, cRepAll, cRepInvAll, -1); | |||
if(ok) | if(ok) | |||
(*result) = I; | (*result) = I; | |||
else { | else { | |||
/* cleanup */ | /* cleanup */ | |||
#ifdef _PYMOL_IP_EXTRAS // incomplete objects can cause crash - prefer the memor y leak | ||||
if (I) | if (I) | |||
ObjectMoleculeFree(I); | ObjectMoleculeFree(I); | |||
#endif | ||||
(*result) = NULL; | (*result) = NULL; | |||
} | } | |||
return (ok); | return (ok); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
PyObject *ObjectMoleculeAsPyList(ObjectMolecule * I) | PyObject *ObjectMoleculeAsPyList(ObjectMolecule * I) | |||
{ | { | |||
PyObject *result = NULL; | PyObject *result = NULL; | |||
skipping to change at line 4079 | skipping to change at line 4064 | |||
/*========================================================================*/ | /*========================================================================*/ | |||
int ObjectMoleculeConnect(ObjectMolecule * I, int *nbond, BondType ** bond, Atom InfoType * ai, | int ObjectMoleculeConnect(ObjectMolecule * I, int *nbond, BondType ** bond, Atom InfoType * ai, | |||
struct CoordSet *cs, int bondSearchMode, | struct CoordSet *cs, int bondSearchMode, | |||
int connectModeOverride) | int connectModeOverride) | |||
{ | { | |||
#define cMULT 1 | #define cMULT 1 | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
int a, b, c, d, e, f, i, j; | int a, b, c, d, e, f, i, j; | |||
int a1, a2; | int a1, a2; | |||
float *v1, *v2, dst; | float *v1, *v2; | |||
int maxBond; | int maxBond; | |||
MapType *map; | MapType *map; | |||
int nBond; | int nBond; | |||
BondType *ii1, *ii2; | BondType *ii1, *ii2; | |||
int flag; | int flag; | |||
int order; | int order; | |||
AtomInfoType *ai1, *ai2; | AtomInfoType *ai1, *ai2; | |||
/* Sulfur cutoff */ | /* Sulfur cutoff */ | |||
float cutoff_s; | float cutoff_s; | |||
float cutoff_v; | float cutoff_v; | |||
skipping to change at line 4425 | skipping to change at line 4410 | |||
return ok; | return ok; | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
int ObjectMoleculeSort(ObjectMolecule * I) | int ObjectMoleculeSort(ObjectMolecule * I) | |||
{ /* sorts atoms and bonds */ | { /* sorts atoms and bonds */ | |||
int *index; | int *index; | |||
int *outdex = NULL; | int *outdex = NULL; | |||
int a, b; | int a, b; | |||
CoordSet *cs, **dcs; | CoordSet *cs, **dcs; | |||
AtomInfoType *atInfo; | ||||
int *dAtmToIdx = NULL; | int *dAtmToIdx = NULL; | |||
int ok = true; | int ok = true; | |||
if(!I->DiscreteFlag) { /* currently, discrete objects are never sorted */ | if(!I->DiscreteFlag) { /* currently, discrete objects are never sorted */ | |||
int n_bytes = sizeof(int) * I->NAtom; | int n_bytes = sizeof(int) * I->NAtom; | |||
int already_in_order = true; | int already_in_order = true; | |||
int i_NAtom = I->NAtom; | int i_NAtom = I->NAtom; | |||
index = AtomInfoGetSortedIndex(I->Obj.G, I, I->AtomInfo, i_NAtom, &outdex); | index = AtomInfoGetSortedIndex(I->Obj.G, I, I->AtomInfo, i_NAtom, &outdex); | |||
CHECKOK(ok, index); | CHECKOK(ok, index); | |||
if (ok){ | if (ok){ | |||
for(a = 0; a < i_NAtom; a++) { | for(a = 0; a < i_NAtom; a++) { | |||
skipping to change at line 4475 | skipping to change at line 4459 | |||
cs_AtmToIdx[b]=-1; */ | cs_AtmToIdx[b]=-1; */ | |||
for(b = 0; b < cs_NIndex; b++) { | for(b = 0; b < cs_NIndex; b++) { | |||
cs_AtmToIdx[cs_IdxToAtm[b]] = b; | cs_AtmToIdx[cs_IdxToAtm[b]] = b; | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
ExecutiveUniqueIDAtomDictInvalidate(I->Obj.G); | ExecutiveUniqueIDAtomDictInvalidate(I->Obj.G); | |||
atInfo = (AtomInfoType *) VLAMalloc(i_NAtom, sizeof(AtomInfoType), 5, true ); | pymol::vla<AtomInfoType> atInfo(i_NAtom); | |||
CHECKOK(ok, atInfo); | CHECKOK(ok, atInfo); | |||
if (ok){ | if (ok){ | |||
/* autozero here is important */ | /* autozero here is important */ | |||
for(a = 0; a < i_NAtom; a++) | for(a = 0; a < i_NAtom; a++) | |||
atInfo[a] = STD_MOVE(I->AtomInfo[index[a]]); | atInfo[a] = std::move(I->AtomInfo[index[a]]); | |||
} | } | |||
VLAFreeP(I->AtomInfo); | VLAFreeP(I->AtomInfo); | |||
I->AtomInfo = atInfo; | std::swap(I->AtomInfo, atInfo); | |||
if(ok && I->DiscreteFlag) { | if(ok && I->DiscreteFlag) { | |||
dcs = VLAlloc(CoordSet *, i_NAtom); | dcs = VLAlloc(CoordSet *, i_NAtom); | |||
CHECKOK(ok, dcs); | CHECKOK(ok, dcs); | |||
if (ok) | if (ok) | |||
dAtmToIdx = VLAlloc(int, i_NAtom); | dAtmToIdx = VLAlloc(int, i_NAtom); | |||
CHECKOK(ok, dAtmToIdx); | CHECKOK(ok, dAtmToIdx); | |||
if (ok){ | if (ok){ | |||
for(a = 0; a < i_NAtom; a++) { | for(a = 0; a < i_NAtom; a++) { | |||
b = index[a]; | b = index[a]; | |||
End of changes. 25 change blocks. | ||||
40 lines changed or deleted | 24 lines changed or added |