Skip to content

Commit 2e97187

Browse files
committed
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeode into fix_removing_apex_refine_in_remesh
2 parents 4043ef5 + 355e21e commit 2e97187

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

include/geode/basic/range.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ namespace geode
8181
: iter_( static_cast< Type >( begin ) ),
8282
last_( static_cast< Type >( end ) )
8383
{
84+
if constexpr( std::is_arithmetic_v< Type > )
85+
{
86+
using T1U = std::make_unsigned_t< T1 >;
87+
using T2U = std::make_unsigned_t< T2 >;
88+
const auto beginU = static_cast< T1U >( begin );
89+
const auto endU = static_cast< T2U >( end );
90+
const auto max = std::numeric_limits< Type >::max();
91+
OPENGEODE_EXCEPTION( beginU <= max,
92+
"[Range] Invalid range: ", begin, " > ", max );
93+
OPENGEODE_EXCEPTION(
94+
endU <= max, "[Range] Invalid range: ", end, " > ", max );
95+
}
8496
}
8597

8698
private:
@@ -115,7 +127,8 @@ namespace geode
115127
}
116128

117129
template < typename T >
118-
constexpr explicit TRange( T end ) : TRange( 0, end )
130+
constexpr explicit TRange( T end )
131+
: TRange( static_cast< Type >( 0 ), end )
119132
{
120133
}
121134

@@ -148,7 +161,9 @@ namespace geode
148161
}
149162

150163
template < typename T >
151-
constexpr explicit TReverseRange( T begin ) : TReverseRange( begin, 0 )
164+
constexpr explicit TReverseRange( T begin )
165+
: BaseRange< Type, DecrementOperator >(
166+
begin - 1, static_cast< Type >( -1 ) )
152167
{
153168
}
154169

@@ -176,7 +191,8 @@ namespace geode
176191
public:
177192
template < typename Container >
178193
constexpr explicit TIndices( const Container& container )
179-
: BaseRange< Type, IncrementOperator >( 0, container.size() )
194+
: BaseRange< Type, IncrementOperator >(
195+
static_cast< Type >( 0 ), container.size() )
180196
{
181197
}
182198

src/geode/mesh/helpers/rasterize.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,18 +685,18 @@ namespace
685685
void fill_values( const geode::Triangle2D& triangle )
686686
{
687687
const auto bbox = triangle.bounding_box();
688-
const auto max_j = std::floor(
688+
const auto max_j = static_cast< geode::index_t >( std::floor(
689689
bbox.max().value( 0 ) / grid_.cell_length_in_direction( 1 )
690-
- 0.5 );
691-
const auto max_k = std::floor(
690+
- 0.5 ) );
691+
const auto max_k = static_cast< geode::index_t >( std::floor(
692692
bbox.max().value( 1 ) / grid_.cell_length_in_direction( 2 )
693-
- 0.5 );
694-
const auto min_j = std::ceil(
693+
- 0.5 ) );
694+
const auto min_j = static_cast< geode::index_t >( std::ceil(
695695
bbox.min().value( 0 ) / grid_.cell_length_in_direction( 1 )
696-
- 0.5 );
697-
const auto min_k = std::ceil(
696+
- 0.5 ) );
697+
const auto min_k = static_cast< geode::index_t >( std::ceil(
698698
bbox.min().value( 1 ) / grid_.cell_length_in_direction( 2 )
699-
- 0.5 );
699+
- 0.5 ) );
700700
const auto max_i_grid = grid_.nb_cells_in_direction( 0 ) - 1;
701701
for( const auto j : geode::Range{ min_j, max_j + 1 } )
702702
{

tests/common.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace geode
4646
try \
4747
{ \
4848
geode::OpenGeodeBasicLibrary::initialize(); \
49+
geode::Logger::set_level( geode::Logger::LEVEL::trace ); \
4950
test(); \
5051
\
5152
geode::Logger::info( "TEST SUCCESS" ); \

0 commit comments

Comments
 (0)