Skip to content

Commit

Permalink
[tube] added TubeTreeSynthesis::slice(double t)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Feb 16, 2021
1 parent 87b2ae9 commit ed3ff69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/domains/tube/codac_Tube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ namespace codac
assert(tdomain().contains(t));

if(m_synthesis_tree != NULL) // fast evaluation
return m_synthesis_tree->slice(m_synthesis_tree->time_to_index(t));
return m_synthesis_tree->slice(t);

else
{
Expand Down
23 changes: 23 additions & 0 deletions src/core/domains/tube/codac_TubeTreeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,29 @@ namespace codac
}
}

Slice* TubeTreeSynthesis::slice(double t)
{
assert(tdomain().contains(t));
return const_cast<Slice*>(static_cast<const TubeTreeSynthesis&>(*this).slice(t));
}

const Slice* TubeTreeSynthesis::slice(double t) const
{
assert(tdomain().contains(t));

if(is_leaf())
return m_slice_ref;

else
{
if(t < m_first_subtree->tdomain().ub())
return m_first_subtree->slice(t);

else
return m_second_subtree->slice(t);
}
}

void TubeTreeSynthesis::request_values_update()
{
if(m_values_update_needed)
Expand Down
2 changes: 2 additions & 0 deletions src/core/domains/tube/codac_TubeTreeSynthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace codac
int time_to_index(double t) const;
Slice* slice(int slice_id);
const Slice* slice(int slice_id) const;
Slice* slice(double t);
const Slice* slice(double t) const;

bool is_leaf() const;
bool is_root() const;
Expand Down

0 comments on commit ed3ff69

Please sign in to comment.