Skip to content

Commit 9a7f967

Browse files
committed
Merge branch 'next' into feat/add-ellipse-basic-object-ditance-and-intersection
2 parents 69e7937 + 1a52d46 commit 9a7f967

File tree

61 files changed

+1000
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1000
-73
lines changed

bindings/python/src/mesh/core/light_regular_grid.cpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,39 @@
3030

3131
#include <geode/mesh/core/light_regular_grid.hpp>
3232

33-
#define PYTHON_LIGHT_REGULAR_GRID( dimension ) \
34-
const auto name##dimension = \
35-
"LightRegularGrid" + std::to_string( dimension ) + "D"; \
36-
pybind11::class_< LightRegularGrid##dimension##D, Grid##dimension##D, \
37-
Identifier >( module, name##dimension.c_str() ) \
38-
.def( pybind11::init< Point< dimension >, \
39-
std::array< index_t, dimension >, \
40-
std::array< double, dimension > >() ) \
41-
.def( pybind11::init< Point< dimension >, \
42-
std::array< index_t, dimension >, \
43-
std::array< Vector< dimension >, dimension > >() ) \
44-
.def( "native_extension", \
45-
&LightRegularGrid##dimension##D::native_extension )
33+
namespace
34+
{
35+
template < geode::index_t dimension >
36+
void define_python_light_regular_grid( pybind11::module& module )
37+
{
38+
const auto class_name =
39+
absl::StrCat( "LightRegularGrid", dimension, "D" );
40+
pybind11::class_< geode::LightRegularGrid< dimension >,
41+
geode::Grid< dimension >, geode::Identifier >(
42+
module, class_name.c_str() )
43+
.def( pybind11::init< geode::Point< dimension >,
44+
std::array< geode::index_t, dimension >,
45+
std::array< double, dimension > >() )
46+
.def( pybind11::init< geode::Point< dimension >,
47+
std::array< geode::index_t, dimension >,
48+
std::array< geode::Vector< dimension >, dimension > >() )
49+
.def( "vertex_attribute_manager",
50+
&geode::Grid< dimension >::grid_vertex_attribute_manager,
51+
pybind11::return_value_policy::reference )
52+
.def( dimension == 2 ? "polygon_attribute_manager"
53+
: "polyhedron_attribute_manager",
54+
&geode::Grid< dimension >::cell_attribute_manager,
55+
pybind11::return_value_policy::reference )
56+
.def( "native_extension",
57+
&geode::LightRegularGrid< dimension >::native_extension );
58+
}
59+
} // namespace
4660

4761
namespace geode
4862
{
4963
void define_light_regular_grid( pybind11::module& module )
5064
{
51-
PYTHON_LIGHT_REGULAR_GRID( 2 );
52-
PYTHON_LIGHT_REGULAR_GRID( 3 );
65+
define_python_light_regular_grid< 2 >( module );
66+
define_python_light_regular_grid< 3 >( module );
5367
}
5468
} // namespace geode

bindings/python/tests/geometry/test-py-nnsearch.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,3 @@
5555
colocated_info = colocator.colocated_index_mapping(basic.GLOBAL_EPSILON)
5656
if colocated_info.nb_colocated_points() != 3:
5757
raise ValueError("[Test] Should be 3 colocated points")
58-
mapping_answer = [0, 0, 1, 0, 2, 1, 3]
59-
if colocated_info.colocated_mapping != mapping_answer:
60-
raise ValueError("[Test] Error in colocated mapping")
61-
points_answer = [p0, p1, p2, p3]
62-
for p in range(4):
63-
if colocated_info.unique_points[p] != points_answer[p]:
64-
raise ValueError("[Test] Error in unique points")

bindings/python/tests/mesh/test-py-light-regular-grid.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,44 @@ def test_closest_vertex( grid ):
240240
if result != answer:
241241
raise ValueError( "[Test] Wrong result for closest vertex for query p4" )
242242

243-
def test_attribute( grid ):
243+
def test_attribute_3d( grid ):
244244
attribute = grid.cell_attribute_manager().find_or_create_attribute_variable_double( "toto", -1 )
245245
attribute.set_value( 10, 10 )
246+
attribute = grid.polyhedron_attribute_manager().find_attribute_double( "toto" )
246247
if attribute.value( 0 ) != -1:
247248
raise ValueError( "[Test] Wrong attribute value" )
248249
if attribute.value( 10 ) != 10:
249250
raise ValueError( "[Test] Wrong attribute value" )
250251
if attribute.value( grid.nb_cells() - 1 ) != -1:
251252
raise ValueError( "[Test] Wrong attribute value" )
253+
attribute = grid.vertex_attribute_manager().find_or_create_attribute_variable_double( "toto_vertex", 1 )
254+
attribute.set_value( 10, 10 )
255+
if attribute.value( 0 ) != 1:
256+
raise ValueError( "[Test] Wrong attribute value" )
257+
if attribute.value( 10 ) != 10:
258+
raise ValueError( "[Test] Wrong attribute value" )
259+
if attribute.value( grid.nb_cells() - 1 ) != 1:
260+
raise ValueError( "[Test] Wrong attribute value" )
261+
262+
def test_attribute_2d():
263+
grid = mesh.LightRegularGrid2D(geom.Point2D([1.5, 0]), [5, 10], [1., 2.])
264+
attribute = grid.cell_attribute_manager().find_or_create_attribute_variable_double( "toto", -1 )
265+
attribute.set_value( 10, 10 )
266+
attribute = grid.polygon_attribute_manager().find_attribute_double( "toto" )
267+
if attribute.value( 0 ) != -1:
268+
raise ValueError( "[Test] Wrong attribute value" )
269+
if attribute.value( 10 ) != 10:
270+
raise ValueError( "[Test] Wrong attribute value" )
271+
if attribute.value( grid.nb_cells() - 1 ) != -1:
272+
raise ValueError( "[Test] Wrong attribute value" )
273+
attribute = grid.vertex_attribute_manager().find_or_create_attribute_variable_double( "toto_vertex", 1 )
274+
attribute.set_value( 10, 10 )
275+
if attribute.value( 0 ) != 1:
276+
raise ValueError( "[Test] Wrong attribute value" )
277+
if attribute.value( 10 ) != 10:
278+
raise ValueError( "[Test] Wrong attribute value" )
279+
if attribute.value( grid.nb_cells() - 1 ) != 1:
280+
raise ValueError( "[Test] Wrong attribute value" )
252281

253282
def test_io(grid, filename):
254283
mesh.save_light_regular_grid3D(grid, filename)
@@ -266,5 +295,6 @@ def test_io(grid, filename):
266295
test_cell_query( grid )
267296
test_boundary_box( grid )
268297
test_closest_vertex( grid )
269-
test_attribute( grid )
298+
test_attribute_3d( grid )
299+
test_attribute_2d()
270300
test_io(grid, "test." + grid.native_extension())

include/geode/basic/attribute_manager.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ namespace geode
7979
std::dynamic_pointer_cast< ReadOnlyAttribute< T > >(
8080
find_attribute_base( name ) );
8181
OPENGEODE_EXCEPTION( attribute.get(),
82-
"[AttributeManager::find_attribute] You have to create an "
83-
"attribute before using it. "
84-
"See find_or_create_attribute method and "
85-
"derived classes of ReadOnlyAttribute." );
82+
"[AttributeManager::find_attribute] Could not find attribute '",
83+
name,
84+
"'. You have to create an attribute before using it. See "
85+
"find_or_create_attribute method and derived classes of "
86+
"ReadOnlyAttribute." );
8687
return attribute;
8788
}
8889

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <absl/time/time.h>
27+
28+
#include <geode/basic/common.hpp>
29+
#include <geode/basic/pimpl.hpp>
30+
31+
namespace geode
32+
{
33+
class opengeode_basic_api Chronometer
34+
{
35+
public:
36+
Chronometer();
37+
Chronometer( Chronometer&& other ) noexcept;
38+
~Chronometer();
39+
40+
void start();
41+
42+
void stop();
43+
44+
[[nodiscard]] absl::Duration raw_duration() const;
45+
46+
[[nodiscard]] std::string duration() const;
47+
48+
void reset();
49+
50+
private:
51+
IMPLEMENTATION_MEMBER( impl_ );
52+
};
53+
} // namespace geode

include/geode/basic/mapping.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ namespace geode
3636
class StorageType >
3737
class MappingBase
3838
{
39-
OPENGEODE_DISABLE_COPY( MappingBase );
40-
4139
public:
4240
template < typename T >
4341
using Storage = typename StorageType< T >::Type;
@@ -88,8 +86,10 @@ namespace geode
8886

8987
protected:
9088
MappingBase() = default;
91-
MappingBase( MappingBase&& other ) = default;
92-
MappingBase& operator=( MappingBase&& other ) = default;
89+
MappingBase( const MappingBase& ) = default;
90+
MappingBase& operator=( const MappingBase& ) = default;
91+
MappingBase( MappingBase&& ) noexcept = default;
92+
MappingBase& operator=( MappingBase&& ) noexcept = default;
9393

9494
[[nodiscard]] index_t size_input() const
9595
{
@@ -127,8 +127,10 @@ namespace geode
127127
{
128128
public:
129129
BijectiveMapping() = default;
130-
BijectiveMapping( BijectiveMapping&& other ) = default;
131-
BijectiveMapping& operator=( BijectiveMapping&& other ) = default;
130+
BijectiveMapping( const BijectiveMapping& ) = default;
131+
BijectiveMapping& operator=( const BijectiveMapping& ) = default;
132+
BijectiveMapping( BijectiveMapping&& ) noexcept = default;
133+
BijectiveMapping& operator=( BijectiveMapping&& ) noexcept = default;
132134

133135
void map( const T1& in, const T2& out )
134136
{
@@ -189,8 +191,10 @@ namespace geode
189191
{
190192
public:
191193
GenericMapping() = default;
192-
GenericMapping( GenericMapping&& other ) = default;
193-
GenericMapping& operator=( GenericMapping&& other ) = default;
194+
GenericMapping( const GenericMapping& ) = default;
195+
GenericMapping& operator=( const GenericMapping& ) = default;
196+
GenericMapping( GenericMapping&& ) noexcept = default;
197+
GenericMapping& operator=( GenericMapping&& ) noexcept = default;
194198

195199
void map( const T1& in, const T2& out )
196200
{

include/geode/basic/small_set.hpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <absl/algorithm/container.h>
27+
#include <absl/container/inlined_vector.h>
28+
29+
#include <geode/basic/common.hpp>
30+
#include <geode/basic/range.hpp>
31+
32+
namespace geode
33+
{
34+
template < typename Type, index_t capacity = 10 >
35+
class SmallSet
36+
{
37+
public:
38+
auto size() const
39+
{
40+
return container_.size();
41+
}
42+
43+
auto empty() const
44+
{
45+
return container_.empty();
46+
}
47+
48+
auto begin() const
49+
{
50+
return container_.begin();
51+
}
52+
53+
auto end() const
54+
{
55+
return container_.end();
56+
}
57+
58+
auto insert( const Type& element )
59+
{
60+
if( absl::c_contains( container_, element ) )
61+
{
62+
return false;
63+
}
64+
container_.push_back( element );
65+
return true;
66+
}
67+
68+
private:
69+
absl::InlinedVector< Type, capacity > container_;
70+
};
71+
} // namespace geode

include/geode/geometry/distance.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#pragma once
2525

26+
#include <optional>
27+
2628
#include <geode/geometry/common.hpp>
2729

2830
namespace geode

include/geode/geometry/quality.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ namespace geode
3636
const Tetrahedron& tetra );
3737
[[nodiscard]] double opengeode_geometry_api
3838
tetrahedron_volume_to_edge_ratio( const Tetrahedron& tetra );
39+
40+
[[nodiscard]] double opengeode_geometry_api
41+
tetrahedron_collapse_aspect_ratio( const Tetrahedron& tetra );
3942
} // namespace geode

include/geode/mesh/builder/edged_curve_builder.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ namespace geode
4646
public:
4747
static constexpr auto dim = dimension;
4848

49+
EdgedCurveBuilder( EdgedCurveBuilder&& ) noexcept = default;
50+
4951
/*!
5052
* Create the builder associated with an EdgedCurve.
5153
* @param[in] mesh The EdgedCurve to build/modify

0 commit comments

Comments
 (0)