Files
rdkit/Code/Geometry/Grid3D.h
Greg Landrum c90cee9b77 Add Molecular Interaction Fields (#7993)
* Add RealValueVect.

* Add UniformRealValueGrid3D

* Add Molecular Interaction Fields (MIFs)

* line endings

* cherry-pick f1bc94a4c8

* format

* Adapt tests for python3.

* Adapt RealValueVector pickling for python3.

* Speed-up of MIF calculations.

* Bugfix in MIFDescriptors.cpp.

* all tests pass

* clean up some memory leaks

* update copyrights

* rename

* rename the library

* complete the rename

* lost file

* another forgotten file

* cleanup

* clang-tidy

* clang-tidy

* windows DLL builds work

* python wrapper and tests cleanup

* convert to catch2 testing

* switch RealValueVect to use std::vector

* remove obsolete friend

* - Replace explicit loops with stdlib implicit equivalents
- Replace explicit types with auto where possible
- Avoid unnecessary copy operations where possible
- Replace raw pointers with exception-safe unique_ptr
- Replace C-style #define with constexpr
- Replace C-style casts with C++ casts
- Replace C-style arrays with std::vector
- Avoid code duplication with templated operators
- Replace VdWaals class taking multiple atom type definitions and force-field name as string parameter with force-field-specific classes deriving from an abstract VdWaals class
- Replace x,y,z doubles with Point3D class where possible
- Removed unused (and untested) DistanceToClosestAtom class
- Renamed some variables and functions for better clarity
- Converted tabs to spaces
- Made the mol parameter in cube read/write functions optional for convenience
- Made the Python wrappers more pythonic (e.g., avoid C++-style passing objects as parameters which are modified in place)
- Implemented alternative Python class constructors using boost::python::make_constructor rather than with external non-class functions
- The Python wrappers taking a sequence of Point3D now take a sequence of sequences, such that the output of Conformer.GetPositions() can be passed
- Made the Python wrapper sequence parsing more robust
- Removed duplicated code from Python wrappers

* - avoid an unnecessary copy

* progress

* works

* more cleanup

* all tests pass

* changes in response to review

---------

Co-authored-by: dfhahn <dfhahn@users.noreply.github.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-14 17:08:43 +01:00

55 lines
1.6 KiB
C++

//
// Copyright (C) 2005-2006 Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef _GRID3D_H_20050124_1113
#define _GRID3D_H_20050124_1113
#include <exception>
#include <string>
#include <utility>
namespace RDKit {
class DiscreteValueVect;
}
namespace RDGeom {
class Point3D;
class RDKIT_RDGEOMETRYLIB_EXPORT GridException : public std::exception {
public:
//! construct with an error message
GridException(const char *msg) : _msg(msg) {}
//! construct with an error message
GridException(std::string msg) : _msg(std::move(msg)) {}
//! get the error message
const char *what() const noexcept override { return _msg.c_str(); }
~GridException() noexcept override = default;
private:
std::string _msg;
};
//! Virtual base class for a grid object
template <typename VectorType, typename ValueType1, typename ValueType2>
class RDKIT_RDGEOMETRYLIB_EXPORT Grid3D {
public:
virtual ~Grid3D(){};
virtual int getGridPointIndex(const Point3D &point) const = 0;
virtual ValueType1 getVal(const Point3D &point) const = 0;
virtual void setVal(const Point3D &point, ValueType2 val) = 0;
virtual Point3D getGridPointLoc(unsigned int pointId) const = 0;
virtual ValueType2 getVal(unsigned int pointId) const = 0;
virtual void setVal(unsigned int pointId, ValueType2 val) = 0;
virtual unsigned int getSize() const = 0;
virtual const VectorType *getOccupancyVect() const = 0;
};
} // namespace RDGeom
#endif