refactor: reformat type introspection code and remove ObjectProps system.

This commit is contained in:
AndreaRigoni
2026-02-21 10:45:25 +00:00
parent 8566ceb662
commit c04722c2bb
17 changed files with 878 additions and 1552 deletions

View File

@@ -23,9 +23,6 @@
//////////////////////////////////////////////////////////////////////////////*/
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
@@ -47,7 +44,6 @@
*
*/
#ifndef ULIB_DENSEMATRIX_H
#define ULIB_DENSEMATRIX_H
@@ -55,27 +51,29 @@
#include <Eigen/Dense>
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/string.hpp>
namespace boost {
namespace serialization {
template<class Archive, class Scalar, int RowsAtCompileTime, int ColsAtCompileTime>
void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> & m, const unsigned int /*version*/) {
ar & boost::serialization::make_array(m.data(), RowsAtCompileTime * ColsAtCompileTime);
template <class Archive, class Scalar, int RowsAtCompileTime,
int ColsAtCompileTime>
void serialize(Archive &ar,
::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> &m,
const unsigned int /*version*/) {
ar &boost::serialization::make_array(m.data(),
RowsAtCompileTime * ColsAtCompileTime);
}
} // serialization
} // boost
} // namespace serialization
} // namespace boost
////////////////////////////////////////////////////////////////////////////////
@@ -84,177 +82,163 @@ void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCo
// this is needed by boost::lexical_cast to cope with Eigens Vectors ///////////
namespace Eigen {
template <typename T, int size>
std::istream & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
std::string str;
for( unsigned int i=0; i<size; i++) {
is >> std::skipws;
is >> str;
if(is.fail()) vec(i) = 0;
else vec(i) = boost::lexical_cast<T>(str);
}
return is;
std::istream &operator>>(std::istream &is, Eigen::Matrix<T, size, 1> &vec) {
std::string str;
for (unsigned int i = 0; i < size; i++) {
is >> std::skipws;
is >> str;
if (is.fail())
vec(i) = 0;
else
vec(i) = boost::lexical_cast<T>(str);
}
return is;
}
template <typename T, int size>
std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec) {
os << vec.transpose();
return os;
std::ostream &operator<<(std::ostream &os,
const Eigen::Matrix<T, size, 1> &vec) {
os << vec.transpose();
return os;
}
} // Eigen
} // namespace Eigen
////////////////////////////////////////////////////////////////////////////////
namespace uLib {
typedef id_t Id_t;
typedef id_t Id_t;
typedef int Scalari;
typedef unsigned int Scalarui;
typedef long Scalarl;
typedef int Scalari;
typedef unsigned int Scalarui;
typedef long Scalarl;
typedef unsigned long Scalarul;
typedef float Scalarf;
typedef double Scalard;
typedef float Scalarf;
typedef double Scalard;
typedef Eigen::Matrix<int,1,1> Matrix1i;
typedef Eigen::Matrix<int, 1, 1> Matrix1i;
typedef Eigen::Matrix2i Matrix2i;
typedef Eigen::Matrix3i Matrix3i;
typedef Eigen::Matrix4i Matrix4i;
typedef Eigen::Matrix<float,1,1> Matrix1f;
typedef Eigen::Matrix<float, 1, 1> Matrix1f;
typedef Eigen::Matrix2f Matrix2f;
typedef Eigen::Matrix3f Matrix3f;
typedef Eigen::Matrix4f Matrix4f;
typedef Eigen::Matrix<int,1,1> Vector1i;
typedef Eigen::Matrix<int, 1, 1> Vector1i;
typedef Eigen::Vector2i Vector2i;
typedef Eigen::Vector3i Vector3i;
typedef Eigen::Vector4i Vector4i;
typedef Eigen::Matrix<float,1,1> Vector1f;
typedef Eigen::Matrix<float, 1, 1> Vector1f;
typedef Eigen::Vector2f Vector2f;
typedef Eigen::Vector3f Vector3f;
typedef Eigen::Vector4f Vector4f;
////////////////////////////////////////////////////////////////////////////////
// Vector String interaction ///////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*! Given a string consisting of a series of doubles with some
* delimiter, return an Eigen::Vector populated with those
* values, in the same order as they are given in the string.
*
* \param vec A double vector to be populated with the results
* \param str A string to be parsed as a series of doubles.
* \param delim Delimiters of the text (a typical default is " ," for comma and space-delimited text
*
*/
* delimiter, return an Eigen::Vector populated with those
* values, in the same order as they are given in the string.
*
* \param vec A double vector to be populated with the results
* \param str A string to be parsed as a series of doubles.
* \param delim Delimiters of the text (a typical default is " ," for comma and
* space-delimited text
*
*/
template <typename T, int size>
void VectorxT_StringTo(Eigen::Matrix<T,size,1> &vec, std::string str, const char *delim = " ,;\t\n") {
std::vector<std::string> strvec;
void VectorxT_StringTo(Eigen::Matrix<T, size, 1> &vec, std::string str,
const char *delim = " ,;\t\n") {
std::vector<std::string> strvec;
boost::algorithm::trim_if( str, boost::algorithm::is_any_of(delim));
boost::algorithm::split(strvec,str,boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
boost::algorithm::trim_if(str, boost::algorithm::is_any_of(delim));
boost::algorithm::split(strvec, str, boost::algorithm::is_any_of(delim),
boost::algorithm::token_compress_on);
for( unsigned int i=0; i<size; i++) {
vec(i) = boost::lexical_cast<T>(strvec[i]);
}
for (unsigned int i = 0; i < size; i++) {
vec(i) = boost::lexical_cast<T>(strvec[i]);
}
}
template <typename T, int size>
std::string VectorxT_ToString(const Eigen::Matrix<T,size,1> &vec) {
std::stringstream sst;
sst << vec.transpose();
return sst.str();
std::string VectorxT_ToString(const Eigen::Matrix<T, size, 1> &vec) {
std::stringstream sst;
sst << vec.transpose();
return sst.str();
}
//template <typename T, int size>
//Eigen::Matrix<T,size,1> & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
//}
// template <typename T, int size>
// Eigen::Matrix<T,size,1> & operator >> (std::istream &is,
// Eigen::Matrix<T,size,1> &vec) {
// }
template <typename T, int size>
void operator>> (std::string& str, Eigen::Matrix<T,size,1> &vec){
VectorxT_StringTo(vec,str);
void operator>>(std::string &str, Eigen::Matrix<T, size, 1> &vec) {
VectorxT_StringTo(vec, str);
}
////////////////////////////////////////////////////////////////////////////////
////// HOMOGENEOUS VECTORS //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
template <bool p>
class _HPoint3f : public Eigen::Matrix< Scalarf,4,1 > {
template <bool p> class _HPoint3f : public Eigen::Matrix<Scalarf, 4, 1> {
public:
typedef Eigen::Matrix< Scalarf,4,1 > BaseClass;
typedef Eigen::Matrix<Scalarf, 4, 1> BaseClass;
_HPoint3f<p>() : BaseClass(0,0,0,p) {}
_HPoint3f<p>(float x,float y,float z) : BaseClass(x,y,z,p) {}
_HPoint3f<p>(Vector3f &in) : BaseClass(in.homogeneous()) { this->operator()(3) = p; }
_HPoint3f() : BaseClass(0, 0, 0, p) {}
_HPoint3f(float x, float y, float z) : BaseClass(x, y, z, p) {}
_HPoint3f(Vector3f &in) : BaseClass(in.homogeneous()) {
this->operator()(3) = p;
}
void operator delete(void* _p, size_t _s) {}
void operator delete(void *_p, size_t _s) {}
// This constructor allows to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
inline _HPoint3f<p>(const Eigen::MatrixBase<OtherDerived>& other)
: BaseClass(other)
{ }
// This method allows to assign Eigen expressions to Vector3H
template<typename OtherDerived>
inline _HPoint3f<p> & operator= (const Eigen::MatrixBase <OtherDerived>& other)
{
this->BaseClass::operator=(other);
return *this;
}
// This constructor allows to construct MyVectorType from Eigen expressions
template <typename OtherDerived>
inline _HPoint3f(const Eigen::MatrixBase<OtherDerived> &other)
: BaseClass(other) {}
// This method allows to assign Eigen expressions to Vector3H
template <typename OtherDerived>
inline _HPoint3f &operator=(const Eigen::MatrixBase<OtherDerived> &other) {
this->BaseClass::operator=(other);
return *this;
}
};
typedef _HPoint3f<false> HVector3f;
typedef _HPoint3f<true> HPoint3f;
////////////////////////////////////////////////////////////////////////////////
////// HOMOGENEOUS LINE //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
struct _HLine3f
{
HPoint3f origin;
HVector3f direction;
struct _HLine3f {
HPoint3f origin;
HVector3f direction;
};
typedef struct _HLine3f HLine3f;
inline std::ostream&
operator<< (std::ostream& stream, const HLine3f &line) {
stream << "HLine3f(" << "pt[" << line.origin.transpose() <<"] , dr[" << line.direction.transpose() << "]) ";
return stream;
inline std::ostream &operator<<(std::ostream &stream, const HLine3f &line) {
stream << "HLine3f(" << "pt[" << line.origin.transpose() << "] , dr["
<< line.direction.transpose() << "]) ";
return stream;
}
struct _HError3f
{
HVector3f position_error;
HVector3f direction_error;
struct _HError3f {
HVector3f position_error;
HVector3f direction_error;
};
typedef struct _HError3f HError3f;
inline std::ostream&
operator<< (std::ostream& stream, const HError3f &err) {
stream << "HError3f(" << "ept[" << err.position_error.transpose() <<"] , edr[" << err.direction_error.transpose() << "]) ";
return stream;
}
inline std::ostream &operator<<(std::ostream &stream, const HError3f &err) {
stream << "HError3f(" << "ept[" << err.position_error.transpose()
<< "] , edr[" << err.direction_error.transpose() << "]) ";
return stream;
}
} // namespace uLib
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -268,13 +252,9 @@ ULIB_SERIALIZABLE(uLib::HPoint3f)
ULIB_SERIALIZABLE(uLib::HVector3f)
ULIB_SERIALIZABLE(uLib::HLine3f)
ULIB_SERIALIZABLE(uLib::HError3f)
#endif // ULIB_SERIALIZATION_ON
#endif // U_DENSEMATRIX_H
#endif // U_DENSEMATRIX_H

View File

@@ -23,11 +23,10 @@
//////////////////////////////////////////////////////////////////////////////*/
#include <iostream>
#include "VoxRaytracer.h"
#include "Utils.h"
#include "VoxRaytracer.h"
#define unlikely(expr) __builtin_expect(!!(expr), 0)
@@ -39,215 +38,206 @@ namespace uLib {
///// RAY DATA /////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void VoxRaytracer::RayData::AddElement(Id_t id, float L)
{
Element el = {id, L};
m_Data.push_back(el);
m_TotalLength += L;
void VoxRaytracer::RayData::AddElement(Id_t id, float L) {
Element el = {id, L};
m_Data.push_back(el);
m_TotalLength += L;
}
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
{
if (unlikely(!in.m_Data.size())) {
std::cout << "Warinig: PoCA on exit border!\n";
return;
}
else if (unlikely(!m_Data.size())) {
m_Data = in.m_Data;
std::cout << "Warinig: PoCA on entrance border!\n";
return;
}
else {
// Opzione 1) un voxel in piu' //
m_Data.reserve(m_Data.size() + in.m_Data.size());
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
// Opzione 2) merge dei voxel nel poca.
// RayData::Element &e1 = m_Data.back();
// const RayData::Element &e2 = in.m_Data.front();
// if(e1.vox_id == e2.vox_id)
// {
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
// e1.L += e2.L; //fix//
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1, in.m_Data.end());
// }
// else {
// m_Data.reserve(m_Data.size() + in.m_Data.size());
// m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
// }
m_TotalLength += in.m_TotalLength;
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in) {
if (unlikely(!in.m_Data.size())) {
std::cout << "Warinig: PoCA on exit border!\n";
return;
} else if (unlikely(!m_Data.size())) {
m_Data = in.m_Data;
std::cout << "Warinig: PoCA on entrance border!\n";
return;
} else {
// Opzione 1) un voxel in piu' //
if (in.m_Data.size() > 0) {
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
}
// Opzione 2) merge dei voxel nel poca.
// RayData::Element &e1 = m_Data.back();
// const RayData::Element &e2 = in.m_Data.front();
// if(e1.vox_id == e2.vox_id)
// {
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
// e1.L += e2.L; //fix//
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1,
// in.m_Data.end());
// }
// else {
// m_Data.reserve(m_Data.size() + in.m_Data.size());
// m_Data.insert(m_Data.end(), in.m_Data.begin(),
// in.m_Data.end());
// }
m_TotalLength += in.m_TotalLength;
}
}
void VoxRaytracer::RayData::PrintSelf(std::ostream &o)
{
o << "Ray: total lenght " << m_TotalLength << "\n";
std::vector<Element>::iterator it;
for(it = m_Data.begin(); it < m_Data.end(); ++it)
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
void VoxRaytracer::RayData::PrintSelf(std::ostream &o) {
o << "Ray: total lenght " << m_TotalLength << "\n";
std::vector<Element>::iterator it;
for (it = m_Data.begin(); it < m_Data.end(); ++it)
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
}
////////////////////////////////////////////////////////////////////////////////
//// RAY TRACER ////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt) {
Vector4f s = m_Image->GetLocalPoint(line.direction);
pt = m_Image->GetLocalPoint(line.origin);
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
{
Vector4f s = m_Image->GetLocalPoint(line.direction);
pt = m_Image->GetLocalPoint(line.origin);
// Considers Structured grid dimensions //
Vector4f dims = m_Image->GetDims().homogeneous().cast<float>();
pt = pt.cwiseQuotient(dims);
s = s.cwiseQuotient(dims);
// Considers Structured grid dimensions //
Vector4f dims = m_Image->GetDims().homogeneous().cast<float>();
pt = pt.cwiseQuotient(dims);
s = s.cwiseQuotient(dims);
float l = s.head(3).norm();
Vector3f L(l / s(0), l / s(1), l / s(2));
float l = s.head(3).norm();
Vector3f L(l/s(0), l/s(1), l/s(2));
Vector3f offset;
for (int i = 0; i < 3; ++i)
offset(i) = (s(i) > 0) - (pt(i) - floor(pt(i)));
offset = offset.cwiseProduct(L).cwiseAbs();
Vector3f offset;
for(int i=0;i<3;++i)
offset(i) = (s(i)>0) - (pt(i)-floor(pt(i))) ;
offset = offset.cwiseProduct(L).cwiseAbs();
int id; float d;
for(int loop=0; loop<8; loop++)
{
int check_border = 0;
for ( int i=0; i<3 ;++i) {
check_border += pt(i) > 1;
check_border += pt(i) < 0;
}
if(check_border == 0) {
for(int i=0;i<3;++i)
pt(i) *= (float)dims(i);
pt = m_Image->GetWorldPoint(pt);
return true;
}
d = offset.minCoeff(&id);
for(int i=0; i<3; ++i)
pt(i) += d / L(i);
pt(id) = rintf(pt(id));
offset.array() -= d;
offset(id) = fabs(L(id));
int id;
float d;
for (int loop = 0; loop < 8; loop++) {
int check_border = 0;
for (int i = 0; i < 3; ++i) {
check_border += pt(i) > 1;
check_border += pt(i) < 0;
}
for(int i=0;i<3;++i)
if (check_border == 0) {
for (int i = 0; i < 3; ++i)
pt(i) *= (float)dims(i);
pt = m_Image->GetWorldPoint(pt);
return false;
}
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt)
{
HLine3f out = line;
out.direction *= -1;
return GetEntryPoint(out,pt);
}
VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
const HPoint3f &out)
const
{
RayData ray;
Vector4f pt1 = m_Image->GetLocalPoint(in);
Vector4f pt2 = m_Image->GetLocalPoint(out);
Vector4f s = pt2 - pt1;
float l = s.head(3).norm();
Vector3f L(l/s(0), l/s(1), l/s(2));
// Vector3f scale; // FIXXX
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
Vector3f offset;
for(int i=0;i<3;++i) offset(i) = (s(i)>=0) - (pt1(i)-floor(pt1(i))) ;
offset = offset.cwiseProduct(L).cwiseAbs();
L = L.cwiseAbs();
//---- Check if the ray only crosses one voxel
Vector3i vid = m_Image->Find(in);
if(vid == m_Image->Find(out)){
ray.AddElement(m_Image->Map(vid),s.norm());
return ray;
pt = m_Image->GetWorldPoint(pt);
return true;
}
//---- Otherwise, loop until ray is finished
int id; float d;
while(l>0){
d = offset.minCoeff(&id);
for (int i = 0; i < 3; ++i)
pt(i) += d / L(i);
d = offset.minCoeff(&id);
pt(id) = rintf(pt(id));
if(m_Image->IsInsideGrid(vid)){
ray.AddElement(m_Image->Map(vid), d * m_scale(id) );
}
offset.array() -= d;
offset(id) = fabs(L(id));
}
for (int i = 0; i < 3; ++i)
pt(i) *= (float)dims(i);
pt = m_Image->GetWorldPoint(pt);
return false;
}
// nan check //
// if(unlikely(!isFinite(d * scale(id)))) {
// std:: cout << "NAN in raytracer\n";
// exit(1);
// }
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt) {
HLine3f out = line;
out.direction *= -1;
return GetEntryPoint(out, pt);
}
vid(id) += (int)fast_sign(s(id));
VoxRaytracer::RayData
VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
const HPoint3f &out) const {
RayData ray;
Vector4f pt1 = m_Image->GetLocalPoint(in);
Vector4f pt2 = m_Image->GetLocalPoint(out);
Vector4f s = pt2 - pt1;
l -= d;
offset.array() -= d;
offset(id) = fmin(L(id),l);
}
float l = s.head(3).norm();
Vector3f L(l / s(0), l / s(1), l / s(2));
// Vector3f scale; // FIXXX
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
Vector3f offset;
for (int i = 0; i < 3; ++i)
offset(i) = (s(i) >= 0) - (pt1(i) - floor(pt1(i)));
offset = offset.cwiseProduct(L).cwiseAbs();
L = L.cwiseAbs();
//---- Check if the ray only crosses one voxel
Vector3i vid = m_Image->Find(in);
if (vid == m_Image->Find(out)) {
ray.AddElement(m_Image->Map(vid), s.norm());
return ray;
}
//---- Otherwise, loop until ray is finished
int id;
float d;
while (l > 0) {
d = offset.minCoeff(&id);
if (m_Image->IsInsideGrid(vid)) {
ray.AddElement(m_Image->Map(vid), d * m_scale(id));
}
// nan check //
// if(unlikely(!isFinite(d * scale(id)))) {
// std:: cout << "NAN in raytracer\n";
// exit(1);
// }
vid(id) += (int)fast_sign(s(id));
l -= d;
offset.array() -= d;
offset(id) = fmin(L(id), l);
}
return ray;
}
// 20150528 SV for absorbed muons
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
{
RayData ray;
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const {
RayData ray;
Vector4f pt = m_Image->GetLocalPoint(line.origin);
Vector4f s = m_Image->GetLocalPoint(line.direction);
Vector4f pt = m_Image->GetLocalPoint(line.origin);
Vector4f s = m_Image->GetLocalPoint(line.direction);
float l = s.head(3).norm();
// intersection between track and grid when spacing is +1
Vector3f L(l/s(0), l/s(1), l/s(2));
float l = s.head(3).norm();
// intersection between track and grid when spacing is +1
Vector3f L(l / s(0), l / s(1), l / s(2));
// RayTracer works with a grid of interspace +1
// Vector3f scale; // FIXXX
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
// RayTracer works with a grid of interspace +1
// Vector3f scale; // FIXXX
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
// offset is the fraction of the segment between grid lines when origin is insiede voxel
// cwiseAbs for having positive distances
Vector3f offset;
for(int i=0;i<3;++i)
offset(i) = (s(i)>=0) - (pt(i)-floor(pt(i)));
offset = offset.cwiseProduct(L).cwiseAbs();
L = L.cwiseAbs();
// offset is the fraction of the segment between grid lines when origin is
// insiede voxel cwiseAbs for having positive distances
Vector3f offset;
for (int i = 0; i < 3; ++i)
offset(i) = (s(i) >= 0) - (pt(i) - floor(pt(i)));
offset = offset.cwiseProduct(L).cwiseAbs();
L = L.cwiseAbs();
int id; float d;
Vector3i vid = m_Image->Find(line.origin);
while(m_Image->IsInsideGrid(vid))
{
// minimun coefficient of offset: id is the coordinate, d is the value
// dependig on which grid line horizontal or vertical it is first intercept
d = offset.minCoeff(&id);
int id;
float d;
Vector3i vid = m_Image->Find(line.origin);
while (m_Image->IsInsideGrid(vid)) {
// minimun coefficient of offset: id is the coordinate, d is the value
// dependig on which grid line horizontal or vertical it is first intercept
d = offset.minCoeff(&id);
// add Lij to ray
ray.AddElement(m_Image->Map(vid), d * m_scale(id) );
// add Lij to ray
ray.AddElement(m_Image->Map(vid), d * m_scale(id));
// move to the next voxel
vid(id) += (int)fast_sign(s(id));
// move to the next voxel
vid(id) += (int)fast_sign(s(id));
offset.array() -= d;
offset(id) = L(id);
}
return ray;
offset.array() -= d;
offset(id) = L(id);
}
return ray;
}
}
} // namespace uLib