Skip to content

Commit

Permalink
[paving] added ConnectecSubset::contains + binding
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Jun 21, 2023
1 parent eeb6d3d commit 2912ab5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/src/core/paving/codac_py_ConnectedSubset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <pybind11/stl.h>
#include <pybind11/operators.h>
#include <pybind11/functional.h>
#include "codac_type_caster.h"

#include "codac_Vector.h"
#include "codac_ConnectedSubset.h"
// Generated file from Doxygen XML (doxygen2docstring.py):
#include "codac_py_ConnectedSubset_docs.h"
Expand All @@ -32,5 +34,12 @@ void export_ConnectedSubset(py::module& m)
.def("get_boxes", &ConnectedSubset::get_boxes,
CONNECTEDSUBSET_VECTORINTERVALVECTOR_GET_BOXES)

.def("is_strictly_included_in_paving", &ConnectedSubset::is_strictly_included_in_paving,
CONNECTEDSUBSET_BOOL_IS_STRICTLY_INCLUDED_IN_PAVING)

.def("contains", &ConnectedSubset::contains,
CONNECTEDSUBSET_BOOL_CONTAINS_VECTOR,
"p"_a.noconvert())

;
}
8 changes: 8 additions & 0 deletions src/core/paving/codac_ConnectedSubset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ namespace codac
return box().is_strict_interior_subset(get_paving()->box());
}

bool ConnectedSubset::contains(const Vector& p) const
{
for(const auto& subset_item : m_v_subset_items)
if(subset_item->box().contains(p))
return true;
return false;
}

const Paving* ConnectedSubset::get_paving() const
{
assert(!m_v_subset_items.empty() && "no items in ConnectedSubset (empty items vector)");
Expand Down
9 changes: 9 additions & 0 deletions src/core/paving/codac_ConnectedSubset.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <functional>
#include "codac_IntervalMatrix.h"
#include "codac_Vector.h"
#include "codac_Set.h"

namespace codac
Expand Down Expand Up @@ -56,6 +57,14 @@ namespace codac
*/
bool is_strictly_included_in_paving() const;

/**
* \brief Tests if p is contained in the connected subset
*
* \param p vector to be tested
* \return `true` if p is inside this
*/
bool contains(const Vector& p) const;

/**
* \brief Returns a const pointer to the paving structure
*
Expand Down

0 comments on commit 2912ab5

Please sign in to comment.