示例#1
0
 void transConformer(Conformer &conf, python::object trans) {
   PyObject *transObj = trans.ptr();
   if (!PyArray_Check(transObj)) {
     throw_value_error("Expecting a numeric array for transformation");
   }
   PyArrayObject *transMat = reinterpret_cast<PyArrayObject *>(transObj);
   unsigned int nrows = transMat->dimensions[0];
   unsigned int dSize = nrows*nrows;
   double *inData = reinterpret_cast<double *>(transMat->data);
   RDGeom::Transform3D transform;
   double *tData  = transform.getData();
   memcpy(static_cast<void *>(tData), static_cast<void *>(inData), dSize*sizeof(double));
   MolTransforms::transformConformer(conf, transform);
 }
示例#2
0
 void _copyTransform(const PyArrayObject *transMat, RDGeom::Transform3D &trans) {
   unsigned int nrows = transMat->dimensions[0];
   unsigned int ncols = transMat->dimensions[1];
   if ((nrows != 4) || (ncols != 4)) {
     throw_value_error("The transform has to be square matrix, of size 4x4");
   }
   if (transMat->descr->type_num != PyArray_DOUBLE)
     throw_value_error("Only double arrays allowed for transform object ");
   
   unsigned int dSize = nrows*nrows;
   const double *inData = reinterpret_cast<const double *>(transMat->data);
   double *tData  = trans.getData();
   memcpy(static_cast<void *>(tData), static_cast<const void *>(inData), dSize*sizeof(double));
 }
示例#3
0
 PyObject *computeCanonTrans(const Conformer &conf, const RDGeom::Point3D *center=0,
                             bool normalizeCovar=false, bool ignoreHs=true) {
   RDGeom::Transform3D *trans;
   trans = MolTransforms::computeCanonicalTransform(conf, center, 
                                                    normalizeCovar, ignoreHs);
   npy_intp dims[2];
   dims[0] = 4;
   dims[1] = 4;
   PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE);
   double *resData=reinterpret_cast<double *>(res->data);
   const double *tdata = trans->getData();
   memcpy(static_cast<void *>(resData), static_cast<const void *>(tdata), 4*4*sizeof(double));
   delete trans;
   return PyArray_Return(res);
 }