STDMETHODIMP CComDigiDocLib::oem2unicode(BSTR szOem, BSTR* pVal) { char *psBuf; int iLen; int iErr; _bstr_t bsTemp(szOem); USES_CONVERSION; char *psVal = (char *)bsTemp; iErr = ::oem2unicode(psVal, &psBuf,&iLen); *pVal = SysAllocString(W2OLE((wchar_t *)psBuf)); return S_OK; }
STDMETHODIMP CComDigiDocLib::unicode2oem(BSTR szUnicode, BSTR* pVal) { char *psBuf; int iLen; int iErr; if(szUnicode && *szUnicode) { _bstr_t bsTemp(szUnicode); USES_CONVERSION; wchar_t *pswVal = (wchar_t *)bsTemp; iErr = ::unicode2oem((char *)pswVal, &psBuf,&iLen); *pVal = SysAllocString(A2OLE(psBuf)); if (psBuf != NULL) freeLibMem(psBuf); } return S_OK; }
STDMETHODIMP CComDigiDocLib::utf82unicode(BSTR szUtf8, BSTR* pVal) { USES_CONVERSION; char *psBuf; int iLen; int iErr; if(szUtf8 && *szUtf8) { _bstr_t bsTemp(szUtf8); char *psVal = (char *)bsTemp; iErr = ::utf82unicode(psVal, &psBuf,&iLen); if (!iErr) { *pVal = SysAllocString(W2OLE((wchar_t *)psBuf)); } else { *pVal = SysAllocString(W2OLE((wchar_t *)"")); } if (psBuf != NULL) freeLibMem(psBuf); } return S_OK; }
STDMETHODIMP CComDigiDocLib::longnum2hex(BSTR longNumber, BSTR* pVal) { char *psBuf; int iLen; int iErr; BIGNUM *bn=NULL; char* str; _bstr_t bsTemp(longNumber); char *inputt = bsTemp; BN_dec2bn(&bn, inputt); str = BN_bn2hex(bn); BN_free(bn); iErr = ::oem2unicode(str, &psBuf,&iLen); OPENSSL_free(str); *pVal = SysAllocString(W2OLE((wchar_t *)psBuf)); return S_OK; }
SelectionSet DistanceFinder::find(const SelectionSet& bs, RealType distance, int frame ) { StuntDouble * center; Vector3d centerPos; Snapshot* currSnapshot = info_->getSnapshotManager()->getSnapshot(frame); SelectionSet bsResult(nObjects_); assert(bsResult.size() == bs.size()); #ifdef IS_MPI int mol; int proc; RealType data[3]; int worldRank = MPI::COMM_WORLD.Get_rank(); #endif for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { if (stuntdoubles_[j]->isRigidBody()) { RigidBody* rb = static_cast<RigidBody*>(stuntdoubles_[j]); rb->updateAtoms(frame); } } SelectionSet bsTemp(nObjects_); bsTemp = bs; bsTemp.parallelReduce(); for (int i = bsTemp.bitsets_[STUNTDOUBLE].firstOnBit(); i != -1; i = bsTemp.bitsets_[STUNTDOUBLE].nextOnBit(i)) { // Now, if we own stuntdouble i, we can use the position, but in // parallel, we'll need to let everyone else know what that // position is! #ifdef IS_MPI mol = info_->getGlobalMolMembership(i); proc = info_->getMolToProc(mol); if (proc == worldRank) { center = stuntdoubles_[i]; centerPos = center->getPos(frame); data[0] = centerPos.x(); data[1] = centerPos.y(); data[2] = centerPos.z(); MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); } else { MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); centerPos = Vector3d(data); } #else center = stuntdoubles_[i]; centerPos = center->getPos(frame); #endif for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { Vector3d r =centerPos - stuntdoubles_[j]->getPos(frame); currSnapshot->wrapVector(r); if (r.length() <= distance) { bsResult.bitsets_[STUNTDOUBLE].setBitOn(j); } } for (unsigned int j = 0; j < bonds_.size(); ++j) { Vector3d loc = bonds_[j]->getAtomA()->getPos(frame); loc += bonds_[j]->getAtomB()->getPos(frame); loc = loc / 2.0; Vector3d r = centerPos - loc; currSnapshot->wrapVector(r); if (r.length() <= distance) { bsResult.bitsets_[BOND].setBitOn(j); } } for (unsigned int j = 0; j < bends_.size(); ++j) { Vector3d loc = bends_[j]->getAtomA()->getPos(frame); loc += bends_[j]->getAtomB()->getPos(frame); loc += bends_[j]->getAtomC()->getPos(frame); loc = loc / 3.0; Vector3d r = centerPos - loc; currSnapshot->wrapVector(r); if (r.length() <= distance) { bsResult.bitsets_[BEND].setBitOn(j); } } for (unsigned int j = 0; j < torsions_.size(); ++j) { Vector3d loc = torsions_[j]->getAtomA()->getPos(frame); loc += torsions_[j]->getAtomB()->getPos(frame); loc += torsions_[j]->getAtomC()->getPos(frame); loc += torsions_[j]->getAtomD()->getPos(frame); loc = loc / 4.0; Vector3d r = centerPos - loc; currSnapshot->wrapVector(r); if (r.length() <= distance) { bsResult.bitsets_[TORSION].setBitOn(j); } } for (unsigned int j = 0; j < inversions_.size(); ++j) { Vector3d loc = inversions_[j]->getAtomA()->getPos(frame); loc += inversions_[j]->getAtomB()->getPos(frame); loc += inversions_[j]->getAtomC()->getPos(frame); loc += inversions_[j]->getAtomD()->getPos(frame); loc = loc / 4.0; Vector3d r = centerPos - loc; currSnapshot->wrapVector(r); if (r.length() <= distance) { bsResult.bitsets_[INVERSION].setBitOn(j); } } } return bsResult; }