Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/python/src/model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_geode_python_binding(
"helpers/model_concatener.cpp"
"helpers/model_crs.cpp"
"helpers/ray_tracing.cpp"
"helpers/simplicial_brep_creator.cpp"
"mixin/builder/blocks_builder.cpp"
"mixin/builder/block_collections_builder.cpp"
"mixin/builder/component_registry_builder.cpp"
Expand Down
38 changes: 38 additions & 0 deletions bindings/python/src/model/helpers/simplicial_brep_creator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 - 2025 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include "../../common.hpp"

#include <geode/geometry/bounding_box.hpp>

#include <geode/model/helpers/simplicial_brep_creator.hpp>
#include <geode/model/representation/core/brep.hpp>

namespace geode
{
void define_simplicial_brep_creator( pybind11::module& module )
{
module.def(
"create_brep_from_bounding_box", &create_model_from_bounding_box );
}
} // namespace geode
2 changes: 2 additions & 0 deletions bindings/python/src/model/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace geode
void define_model_concatener( pybind11::module& );
void define_model_coordinate_reference_system( pybind11::module& );
void define_model_ray_tracing( pybind11::module& );
void define_simplicial_brep_creator( pybind11::module& );
} // namespace geode

PYBIND11_MODULE( opengeode_py_model, module )
Expand Down Expand Up @@ -164,4 +165,5 @@ PYBIND11_MODULE( opengeode_py_model, module )
geode::define_model_concatener( module );
geode::define_model_coordinate_reference_system( module );
geode::define_model_ray_tracing( module );
geode::define_simplicial_brep_creator( module );
}
28 changes: 28 additions & 0 deletions include/geode/geometry/bounding_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ namespace geode

bool contains( const BoundingBox< dimension >& bbox ) const;

bool epsilon_contains( const Point< dimension >& point ) const;

bool epsilon_contains( const BoundingBox< dimension >& bbox ) const;

[[nodiscard]] bool intersects(
const BoundingBox< dimension >& bbox ) const;

Expand Down Expand Up @@ -94,6 +98,30 @@ namespace geode
[[nodiscard]] typename std::enable_if< T == 3, bool >::type intersects(
const Tetrahedron& tetra ) const;

/*!
* Epsilon intersection methods are equivalent to intersects ones, but
* considering an epsilon extension of the bbox
*/
[[nodiscard]] bool epsilon_intersects(
const BoundingBox< dimension >& bbox ) const;

[[nodiscard]] bool epsilon_intersects(
const Ray< dimension >& ray ) const;

[[nodiscard]] bool epsilon_intersects(
const InfiniteLine< dimension >& line ) const;

[[nodiscard]] bool epsilon_intersects(
const Segment< dimension >& segment ) const;

template < index_t T = dimension >
[[nodiscard]] typename std::enable_if< T == 2 || T == 3, bool >::type
epsilon_intersects( const Triangle< T >& triangle ) const;

template < index_t T = dimension >
[[nodiscard]] typename std::enable_if< T == 3, bool >::type
epsilon_intersects( const Tetrahedron& tetra ) const;

/*!
* Returns the distance between the point and the box.
* If the point is inside the box, the distance is negative.
Expand Down
17 changes: 9 additions & 8 deletions include/geode/geometry/detail/aabb_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ namespace geode
}

// The acceleration is here:
if( !node( node_index1 ).intersects( node( node_index2 ) ) )
if( !node( node_index1 ).epsilon_intersects( node( node_index2 ) ) )
{
return false;
}
Expand Down Expand Up @@ -382,7 +382,8 @@ namespace geode

// The acceleration is here:
if( !node( node_index1 )
.intersects( other_tree.impl_->node( node_index2 ) ) )
.epsilon_intersects(
other_tree.impl_->node( node_index2 ) ) )
{
return false;
}
Expand Down Expand Up @@ -527,7 +528,7 @@ namespace geode
node_index < tree_.size(), "Node index out of tree" );
OPENGEODE_ASSERT( element_begin != element_end,
"Begin and End indices should be different" );
if( !node( node_index ).contains( query ) )
if( !node( node_index ).epsilon_contains( query ) )
{
return;
}
Expand Down Expand Up @@ -588,7 +589,7 @@ namespace geode
const BoundingBox< dimension >& box, EvalIntersection& action ) const
{
const auto box_filter = [&box]( const auto& inner_box ) {
return inner_box.intersects( box );
return inner_box.epsilon_intersects( box );
};
compute_generic_element_bbox_intersections( box_filter, action );
}
Expand Down Expand Up @@ -627,7 +628,7 @@ namespace geode
const Ray< dimension >& ray, EvalIntersection& action ) const
{
const auto box_filter = [&ray]( const auto& box ) {
return box.intersects( ray );
return box.epsilon_intersects( ray );
};
compute_generic_element_bbox_intersections( box_filter, action );
}
Expand All @@ -638,7 +639,7 @@ namespace geode
const InfiniteLine< dimension >& line, EvalIntersection& action ) const
{
const auto box_filter = [&line]( const auto& box ) {
return box.intersects( line );
return box.epsilon_intersects( line );
};
compute_generic_element_bbox_intersections( box_filter, action );
}
Expand All @@ -662,7 +663,7 @@ namespace geode
const Triangle< dimension >& triangle, EvalIntersection& action ) const
{
const auto box_filter = [&triangle]( const auto& box ) {
return box.intersects( triangle );
return box.epsilon_intersects( triangle );
};
compute_generic_element_bbox_intersections( box_filter, action );
}
Expand All @@ -673,7 +674,7 @@ namespace geode
const Segment< dimension >& segment, EvalIntersection& action ) const
{
const auto box_filter = [&segment]( const auto& box ) {
return box.intersects( segment );
return box.epsilon_intersects( segment );
};
compute_generic_element_bbox_intersections( box_filter, action );
}
Expand Down
5 changes: 5 additions & 0 deletions include/geode/model/helpers/simplicial_brep_creator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
namespace geode
{
FORWARD_DECLARATION_DIMENSION_CLASS( Point );
FORWARD_DECLARATION_DIMENSION_CLASS( BoundingBox );
ALIAS_3D( Point );
ALIAS_3D( BoundingBox );
class BRep;
struct uuid;
} // namespace geode
Expand Down Expand Up @@ -76,4 +78,7 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};

BRep opengeode_model_api create_model_from_bounding_box(
const BoundingBox3D& box );
} // namespace geode
Loading