mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
113 lines
4.6 KiB
C++
113 lines
4.6 KiB
C++
// $Id$
|
|
//
|
|
// Copyright (C) 2005 Rational Discovery LLC
|
|
//
|
|
// @@ All Rights Reserved @@
|
|
//
|
|
|
|
#include <RDGeneral/types.h>
|
|
#include <RDGeneral/Invariant.h>
|
|
#include <DataStructs/DiscreteValueVect.h>
|
|
#include <Geometry/point.h>
|
|
#include <Geometry/UniformGrid3D.h>
|
|
#include <Geometry/GridUtils.h>
|
|
#include <boost/python.hpp>
|
|
#include <RDBoost/Wrap.h>
|
|
namespace python = boost::python;
|
|
|
|
namespace RDGeom {
|
|
|
|
UniformGrid3D *makeUnformGrid3D(double dimX, double dimY, double dimZ, double spacing=0.5,
|
|
DiscreteValueVect::DiscreteValueType valType=DiscreteValueVect::TWOBITVALUE,
|
|
const Point3D *offSet=0) {
|
|
UniformGrid3D *grd = new UniformGrid3D(dimX, dimY, dimZ, spacing, valType, offSet);
|
|
return grd;
|
|
}
|
|
|
|
int getValPoint(const UniformGrid3D &grid, const Point3D &pt) {
|
|
return grid.getVal(pt);
|
|
}
|
|
|
|
int getValIndex(const UniformGrid3D &grid, unsigned int id) {
|
|
return grid.getVal(id);
|
|
}
|
|
|
|
void setValIndex(UniformGrid3D &grid, unsigned int id, unsigned int val) {
|
|
grid.setVal(id, val);
|
|
}
|
|
|
|
void setValPoint(UniformGrid3D &grid, const Point3D &pt, unsigned int val) {
|
|
grid.setVal(pt, val);
|
|
}
|
|
|
|
std::string uGridClassDoc = "Class to represent a uniform three-dimensional\n\
|
|
cubic grid. Each grid point can store a poisitive integer value. For the sake\n\
|
|
of efficiency these value can either be binary, fit in 2, 4, 8 or 16 bits\n";
|
|
|
|
struct uGrid3D_wrapper {
|
|
static void wrap() {
|
|
|
|
python::class_<UniformGrid3D>("UniformGrid3D", uGridClassDoc.c_str(),
|
|
python::no_init)
|
|
.def("GetGridPointIndex", &UniformGrid3D::getGridPointIndex,
|
|
"Get the index to the grid point closest to the specified point")
|
|
.def("GetValPoint", getValPoint,
|
|
"Get the value at the closest grid point")
|
|
.def("GetVal", getValIndex,
|
|
"Get the value at the specified grid point")
|
|
.def("SetVal", setValIndex,
|
|
"Set the value at the specified grid point")
|
|
.def("SetValPoint", setValPoint,
|
|
"Set the value at grid point closest to the specified point")
|
|
.def("GetGridPointLoc", &UniformGrid3D::getGridPointLoc,
|
|
"Get the location of the specified grid point")
|
|
.def("GetSize", &UniformGrid3D::getSize,
|
|
"Get the size of the grid (number of grid points)")
|
|
.def("GetNumX", &UniformGrid3D::getNumX,
|
|
"Get the number of grid points along x-axis")
|
|
.def("GetNumY", &UniformGrid3D::getNumY,
|
|
"Get the number of grid points along y-axis")
|
|
.def("GetNumZ", &UniformGrid3D::getNumZ,
|
|
"Get the number of grid points along z-axis")
|
|
.def("GetOffset", &UniformGrid3D::getOffset,
|
|
python::return_value_policy<python::copy_const_reference>(),
|
|
"Get the location of the center of the grid")
|
|
.def("GetSpacing", &UniformGrid3D::getSpacing,
|
|
"Get the grid spacing")
|
|
.def("GetOccupancyVect", &UniformGrid3D::getOccupancyVect,
|
|
python::return_value_policy<python::reference_existing_object>(),
|
|
"Get the occupancy vector for the grid")
|
|
.def("CompareParams", &UniformGrid3D::compareParams,
|
|
"Compare the parameters between two grid object")
|
|
.def("SetSphereOccupancy", &UniformGrid3D::setSphereOccupancy,
|
|
(python::arg("self"), python::arg("center"),
|
|
python::arg("radius"), python::arg("stepSize"),
|
|
python::arg("maxLayers")=-1,
|
|
python::arg("ignoreOutOfBound")=true),
|
|
"Set the occupancy on the grid for a sphere or specified radius\n"
|
|
" and multiple layers around this sphere, with decreasing values of \n"
|
|
"occupancy\n")
|
|
;
|
|
|
|
python::def("UniformGrid3D", makeUnformGrid3D,
|
|
(python::arg("dimX"), python::arg("dimY"), python::arg("dimZ"),
|
|
python::arg("spacing")=0.5,
|
|
python::arg("valType")=DiscreteValueVect::TWOBITVALUE,
|
|
python::arg("offSet")=(const Point3D *)(0)),
|
|
"Faking the constructor",
|
|
python::return_value_policy<python::manage_new_object>());
|
|
|
|
python::def("WriteGridToFile", writeGridToFile,
|
|
"Write the grid to a grid file");
|
|
|
|
python::def("TanimotoDistance", tanimotoDistance<UniformGrid3D>,
|
|
"Compute the tanimoto distance between two grid objects");
|
|
}
|
|
};
|
|
}
|
|
|
|
void wrap_uniformGrid() {
|
|
RDGeom::uGrid3D_wrapper::wrap();
|
|
}
|
|
|