mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
3D beam
This commit is contained in:
@@ -208,49 +208,54 @@ VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in, const
|
|||||||
|
|
||||||
// Rectangular beam
|
// Rectangular beam
|
||||||
VoxRaytracer::RayData VoxRaytracer::BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out,
|
VoxRaytracer::RayData VoxRaytracer::BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out,
|
||||||
int h_thick, int v_thick) const
|
int x_thick, int y_thick, int z_thick) const
|
||||||
{
|
{
|
||||||
if (h_thick < 0) h_thick = 0;
|
if (x_thick < 0) x_thick = 0;
|
||||||
if (v_thick < 0) v_thick = 0;
|
if (y_thick < 0) y_thick = 0;
|
||||||
|
if (z_thick < 0) z_thick = 0;
|
||||||
|
|
||||||
RayData ray = TraceBetweenPoints(in, out);
|
RayData ray = TraceBetweenPoints(in, out);
|
||||||
if (h_thick == 0 && v_thick == 0) return ray;
|
if (x_thick == 0 && y_thick == 0 && z_thick == 0) return ray;
|
||||||
|
|
||||||
RayTable rTable = RayTable(ray.Data().size());
|
RayTable rTable = RayTable(ray.Data().size());
|
||||||
for(auto it = ray.Data().begin(); it < ray.Data().end(); ++it)
|
|
||||||
{
|
|
||||||
rTable.emplace(it->vox_id, it->L);
|
|
||||||
}
|
|
||||||
|
|
||||||
RayData beam;
|
for (auto iter : ray.Data())
|
||||||
for(auto it = ray.Data().begin(); it < ray.Data().end(); ++it)
|
|
||||||
{
|
{
|
||||||
Vector3i rPos = m_Image->UnMap(it->vox_id);
|
Vector3i rPos = m_Image->UnMap(iter.vox_id);
|
||||||
|
|
||||||
for (int k = h_thick * -1; k <= h_thick; k++)
|
for (int k = x_thick * -1; k <= x_thick; k++)
|
||||||
{
|
{
|
||||||
for (int j = v_thick * -1; j <= v_thick; j++)
|
for (int j = y_thick * -1; j <= y_thick; j++)
|
||||||
{
|
{
|
||||||
// TODO check data order in StructuredData
|
for (int h = z_thick * -1; h <= z_thick; h++)
|
||||||
Vector3i offset { j, k, 0 };
|
|
||||||
Vector3i n_id = rPos + offset;
|
|
||||||
if (!m_Image->IsInsideGrid(n_id)) continue;
|
|
||||||
|
|
||||||
Id_t n_vox_id = m_Image->Map(n_id);
|
|
||||||
|
|
||||||
auto tPair = rTable.find(n_vox_id);
|
|
||||||
if (tPair == rTable.end())
|
|
||||||
{
|
{
|
||||||
beam.AddElement(n_vox_id, 0); //TODO Verify any condition with L==0
|
// TODO check data order in StructuredData
|
||||||
}
|
Vector3i offset { j, k, h };
|
||||||
else if (tPair->second != 0)
|
Vector3i n_id = rPos + offset;
|
||||||
{
|
if (!m_Image->IsInsideGrid(n_id)) continue;
|
||||||
beam.AddElement(n_vox_id, tPair->second);
|
|
||||||
rTable[n_vox_id] = 0;
|
Id_t n_vox_id = m_Image->Map(n_id);
|
||||||
|
Scalarf t_len = (k == 0 && j == 0 && h == 0) ? iter.L : 0; //TODO Verify any condition with L==0
|
||||||
|
|
||||||
|
auto tPair = rTable.find(n_vox_id);
|
||||||
|
if (tPair == rTable.end())
|
||||||
|
{
|
||||||
|
rTable.emplace(n_vox_id, t_len);
|
||||||
|
}
|
||||||
|
else if (t_len != 0)
|
||||||
|
{
|
||||||
|
rTable[n_vox_id] = t_len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RayData beam;
|
||||||
|
for (auto iter : rTable)
|
||||||
|
{
|
||||||
|
beam.AddElement(iter.first, iter.second);
|
||||||
|
}
|
||||||
return beam;
|
return beam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
||||||
|
|
||||||
RayData BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out,
|
RayData BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out,
|
||||||
int h_thick = 0, int v_thick = 0) const;
|
int x_thick = 0, int y_thick = 0, int z_thick = 0) const;
|
||||||
|
|
||||||
RayData TraceLine(const HLine3f &line) const;
|
RayData TraceLine(const HLine3f &line) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user