Skip to content

Commit

Permalink
added const embree simulate functions. TODO: check if this is possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
amock committed Dec 2, 2023
1 parent 1d7279b commit 8a83b16
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,35 @@ class O1DnSimulatorEmbree {
void setModel(const MemoryView<O1DnModel_<RAM>, RAM>& model);
void setModel(const O1DnModel_<RAM>& model);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret) const;

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm) const;



// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges);
MemoryView<float, RAM>& ranges) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<float, RAM> simulateRanges(
const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits);
MemoryView<uint8_t, RAM>& hits) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<uint8_t, RAM> simulateHits(
const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret);

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm);


protected:
EmbreeMapPtr m_map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace rmagine
template<typename BundleT>
void O1DnSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm,
BundleT& ret)
BundleT& ret) const
{
SimulationFlags flags = SimulationFlags::Zero();
set_simulation_flags_<RAM>(ret, flags);
Expand Down Expand Up @@ -209,7 +209,7 @@ void O1DnSimulatorEmbree::simulate(

template<typename BundleT>
BundleT O1DnSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
BundleT res;
resize_memory_bundle<RAM>(res, m_model->getWidth(), m_model->getHeight(), Tbm.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,32 @@ class OnDnSimulatorEmbree {
void setModel(const OnDnModel_<RAM>& model);
void setModel(const MemoryView<OnDnModel_<RAM>, RAM>& model);


// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret) const;

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges);
MemoryView<float, RAM>& ranges) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<float, RAM> simulateRanges(
const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits);
MemoryView<uint8_t, RAM>& hits) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<uint8_t, RAM> simulateHits(
const MemoryView<Transform, RAM>& Tbm);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret);

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

protected:
EmbreeMapPtr m_map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace rmagine
template<typename BundleT>
void OnDnSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm,
BundleT& ret)
BundleT& ret) const
{
SimulationFlags flags = SimulationFlags::Zero();
set_simulation_flags_<RAM>(ret, flags);
Expand Down Expand Up @@ -209,7 +209,7 @@ void OnDnSimulatorEmbree::simulate(

template<typename BundleT>
BundleT OnDnSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
BundleT res;
resize_memory_bundle<RAM>(res, m_model->getWidth(), m_model->getHeight(), Tbm.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,31 @@ class PinholeSimulatorEmbree {
void setModel(const MemoryView<PinholeModel, RAM>& model);
void setModel(const PinholeModel& model);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret) const;

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges);
MemoryView<float, RAM>& ranges) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<float, RAM> simulateRanges(
const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits);
MemoryView<uint8_t, RAM>& hits) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<uint8_t, RAM> simulateHits(
const MemoryView<Transform, RAM>& Tbm);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret);

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

protected:
EmbreeMapPtr m_map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace rmagine
template<typename BundleT>
void PinholeSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm,
BundleT& ret)
BundleT& ret) const
{
SimulationFlags flags = SimulationFlags::Zero();
set_simulation_flags_<RAM>(ret, flags);
Expand Down Expand Up @@ -206,7 +206,7 @@ void PinholeSimulatorEmbree::simulate(

template<typename BundleT>
BundleT PinholeSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
BundleT res;
resize_memory_bundle<RAM>(res, m_model->getWidth(), m_model->getHeight(), Tbm.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,31 @@ class SphereSimulatorEmbree {
void setModel(const MemoryView<SphericalModel, RAM>& model);
void setModel(const SphericalModel& model);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret) const;

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges);
MemoryView<float, RAM>& ranges) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<float, RAM> simulateRanges(
const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
void simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits);
MemoryView<uint8_t, RAM>& hits) const;

// [[deprecated("Use simulate<AttrT>() instead.")]]
Memory<uint8_t, RAM> simulateHits(
const MemoryView<Transform, RAM>& Tbm);

// Generic Version
template<typename BundleT>
void simulate(const MemoryView<Transform, RAM>& Tbm,
BundleT& ret);

template<typename BundleT>
BundleT simulate(const MemoryView<Transform, RAM>& Tbm);
const MemoryView<Transform, RAM>& Tbm) const;

protected:
EmbreeMapPtr m_map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
namespace rmagine
{


template<typename BundleT>
void SphereSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm,
BundleT& ret)
BundleT& ret) const
{
SimulationFlags flags = SimulationFlags::Zero();
set_simulation_flags_<RAM>(ret, flags);
Expand Down Expand Up @@ -207,7 +206,7 @@ void SphereSimulatorEmbree::simulate(

template<typename BundleT>
BundleT SphereSimulatorEmbree::simulate(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
BundleT res;
resize_memory_bundle<RAM>(res, m_model->getWidth(), m_model->getHeight(), Tbm.size());
Expand Down
8 changes: 4 additions & 4 deletions src/rmagine_embree/src/simulation/O1DnSimulatorEmbree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void O1DnSimulatorEmbree::setModel(

void O1DnSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges)
MemoryView<float, RAM>& ranges) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -113,7 +113,7 @@ void O1DnSimulatorEmbree::simulateRanges(
}

Memory<float, RAM> O1DnSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<float, RAM> res(m_model->size() * Tbm.size());
simulateRanges(Tbm, res);
Expand All @@ -122,7 +122,7 @@ Memory<float, RAM> O1DnSimulatorEmbree::simulateRanges(

void O1DnSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits)
MemoryView<uint8_t, RAM>& hits) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -173,7 +173,7 @@ void O1DnSimulatorEmbree::simulateHits(
}

Memory<uint8_t, RAM> O1DnSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<uint8_t, RAM> res(m_model->size() * Tbm.size());
simulateHits(Tbm, res);
Expand Down
8 changes: 4 additions & 4 deletions src/rmagine_embree/src/simulation/OnDnSimulatorEmbree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void OnDnSimulatorEmbree::setModel(

void OnDnSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges)
MemoryView<float, RAM>& ranges) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -117,7 +117,7 @@ void OnDnSimulatorEmbree::simulateRanges(
}

Memory<float, RAM> OnDnSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<float, RAM> res(m_model->size() * Tbm.size());
simulateRanges(Tbm, res);
Expand All @@ -126,7 +126,7 @@ Memory<float, RAM> OnDnSimulatorEmbree::simulateRanges(

void OnDnSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits)
MemoryView<uint8_t, RAM>& hits) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -177,7 +177,7 @@ void OnDnSimulatorEmbree::simulateHits(
}

Memory<uint8_t, RAM> OnDnSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<uint8_t, RAM> res(m_model->size() * Tbm.size());
simulateHits(Tbm, res);
Expand Down
8 changes: 4 additions & 4 deletions src/rmagine_embree/src/simulation/PinholeSimulatorEmbree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void PinholeSimulatorEmbree::setModel(const PinholeModel& model)

void PinholeSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges)
MemoryView<float, RAM>& ranges) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -99,7 +99,7 @@ void PinholeSimulatorEmbree::simulateRanges(
}

Memory<float, RAM> PinholeSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<float, RAM> res(m_model->size() * Tbm.size());
simulateRanges(Tbm, res);
Expand All @@ -108,7 +108,7 @@ Memory<float, RAM> PinholeSimulatorEmbree::simulateRanges(

void PinholeSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits)
MemoryView<uint8_t, RAM>& hits) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -156,7 +156,7 @@ void PinholeSimulatorEmbree::simulateHits(
}

Memory<uint8_t, RAM> PinholeSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<uint8_t, RAM> res(m_model->size() * Tbm.size());
simulateHits(Tbm, res);
Expand Down
8 changes: 4 additions & 4 deletions src/rmagine_embree/src/simulation/SphereSimulatorEmbree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void SphereSimulatorEmbree::setModel(

void SphereSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<float, RAM>& ranges)
MemoryView<float, RAM>& ranges) const
{
auto handle = m_map->scene->handle();

Expand Down Expand Up @@ -108,7 +108,7 @@ void SphereSimulatorEmbree::simulateRanges(
}

Memory<float, RAM> SphereSimulatorEmbree::simulateRanges(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<float, RAM> res(m_model->phi.size * m_model->theta.size * Tbm.size());
simulateRanges(Tbm, res);
Expand All @@ -117,7 +117,7 @@ Memory<float, RAM> SphereSimulatorEmbree::simulateRanges(

void SphereSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm,
MemoryView<uint8_t, RAM>& hits)
MemoryView<uint8_t, RAM>& hits) const
{
#pragma omp parallel for
for(size_t pid = 0; pid < Tbm.size(); pid++)
Expand Down Expand Up @@ -165,7 +165,7 @@ void SphereSimulatorEmbree::simulateHits(
}

Memory<uint8_t, RAM> SphereSimulatorEmbree::simulateHits(
const MemoryView<Transform, RAM>& Tbm)
const MemoryView<Transform, RAM>& Tbm) const
{
Memory<uint8_t, RAM> res(m_model->phi.size * m_model->theta.size * Tbm.size());
simulateHits(Tbm, res);
Expand Down

0 comments on commit 8a83b16

Please sign in to comment.