15#ifndef _RBTREALGRID_H_
16#define _RBTREALGRID_H_
19#define EIGEN_DONT_VECTORIZE
24#include <unsupported/Eigen/CXX11/Tensor>
26#include "rxdock/BaseGrid.h"
33 static const std::string _CT;
39 unsigned int NX,
unsigned int NY,
unsigned int NZ,
40 unsigned int NPad = 0);
64 virtual void Print(std::ostream &ostr)
const;
73 float *GetGridData() {
74 float *data = m_grid.data();
83 double GetTolerance()
const {
return m_tol; }
84 void SetTolerance(
double tol) { m_tol = tol; }
87 double GetValue(
const Coord &c)
const {
88 return isValid(c) ? m_grid(GetIX(c), GetIY(c), GetIZ(c)) : 0.0;
91 double GetValue(
unsigned int iX,
unsigned int iY,
unsigned int iZ)
const {
92 return isValid(iX, iY, iZ) ? m_grid(iX, iY, iZ) : 0.0;
95 double GetValue(
unsigned int iXYZ)
const {
96 const float *data = m_grid.data();
97 return isValid(iXYZ) ? data[iXYZ] : 0.0;
102 RBTDLL_EXPORT
double GetSmoothedValue(
const Coord &c)
const;
104 void SetValue(
const Coord &c,
double val) {
106 m_grid(GetIX(c), GetIY(c), GetIZ(c)) = val;
109 void SetValue(
unsigned int iX,
unsigned int iY,
unsigned int iZ,
double val) {
110 if (isValid(iX, iY, iZ))
111 m_grid(iX, iY, iZ) = val;
114 void SetValue(
unsigned int iXYZ,
double val) {
115 float *data = m_grid.data();
121 RBTDLL_EXPORT
void SetAllValues(
double val);
123 void ReplaceValue(
double oldVal,
double newVal) {
124 ReplaceValueRange(oldVal - m_tol, oldVal + m_tol, newVal);
127 void ReplaceValueRange(
double oldValMin,
double oldValMax,
double newVal);
132 void SetSphere(
const Coord &c,
double radius,
double val,
133 bool bOverwrite =
true);
138 void SetSurface(
const Coord &c,
double innerRad,
double outerRad,
double val,
139 bool bOverwrite =
true);
144 void CreateSurface(
double oldVal,
double adjVal,
double newVal);
149 bool isValueWithinSphere(
const Coord &c,
double radius,
double val);
156 void SetAccessible(
double radius,
double oldVal,
double adjVal,
double newVal,
157 bool bCenterOnly =
true);
164 unsigned int Count(
double val)
const {
165 return CountRange(val - m_tol, val + m_tol);
168 unsigned int CountRange(
double valMin,
double valMax)
const;
171 double MinValue()
const;
172 double MaxValue()
const;
175 FindMinValue()
const;
177 FindMaxValue()
const;
184 RBTDLL_EXPORT
void PrintInsightGrid(std::ostream &s)
const;
186 RBTDLL_EXPORT
friend void to_json(json &j,
const RealGrid &grid);
187 friend void from_json(
const json &j,
RealGrid &grid);
194 void OwnPrint(std::ostream &ostr)
const;
205 bool isValueWithinList(
const std::vector<unsigned int> &iXYZList,
double val);
210 void SetValues(
const std::vector<unsigned int> &iXYZList,
double val,
211 bool bOverwrite =
true);
227 Eigen::Tensor<float, 3, Eigen::RowMajor>
234typedef std::vector<RealGridPtr> RealGridList;
235typedef RealGridList::iterator RealGridListIter;
236typedef RealGridList::const_iterator RealGridListConstIter;
238RBTDLL_EXPORT
void to_json(json &j,
const RealGrid &grid);
239void from_json(
const json &j,
RealGrid &grid);
Definition SmartPointer.h:48