Commit b000ebb5 authored by Nils Kohl's avatar Nils Kohl 🌝
Browse files

Replaced boost::tribool with walberla::optional.

parent f06a59c9
......@@ -25,8 +25,7 @@
#include "TriangleMeshes.h"
#include "core/math/GenericAABB.h"
#include <boost/logic/tribool.hpp>
#include "core/Optional.h"
#include <set>
#include <iterator>
......@@ -72,13 +71,13 @@ template< typename MeshType >
void findConnectedVertices( const MeshType & mesh, const typename MeshType::FaceHandle & face, std::vector< typename MeshType::VertexHandle > & outVertices );
template< typename DistanceObject, typename T, typename U >
boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError );
walberla::optional< bool > isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError );
template< typename DistanceObject, typename T, typename U >
boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError );
walberla::optional< bool > fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError );
template< typename DistanceObject, typename T, typename U, typename V >
boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance );
walberla::optional< bool > intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance );
template< typename MeshType, typename InputIterator >
typename MeshType::Point principalComponent( const MeshType & mesh, InputIterator beginFh, InputIterator endFh, const uint_t iterations = uint_t(10) );
......@@ -341,7 +340,7 @@ void findConnectedVertices( const MeshType & mesh, const typename MeshType::Face
template< typename DistanceObject, typename T, typename U >
boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError )
walberla::optional< bool > isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError )
{
typedef typename DistanceObject::Scalar Scalar;
......@@ -388,7 +387,7 @@ boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, con
if( error < maxErrorScalar )
{
return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough
return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough
}
const auto & min = curAabb.minCorner();
......@@ -413,7 +412,7 @@ boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, con
template< typename DistanceObject, typename T, typename U >
boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError )
walberla::optional< bool > fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError )
{
typedef typename DistanceObject::Scalar Scalar;
......@@ -459,7 +458,7 @@ boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, co
if( error < maxErrorScalar )
{
return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough
return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough
}
const auto & min = curAabb.minCorner();
......@@ -484,7 +483,7 @@ boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, co
template< typename DistanceObject, typename T, typename U, typename V >
boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance )
walberla::optional< bool > intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance )
{
typedef typename DistanceObject::Scalar Scalar;
......@@ -532,7 +531,7 @@ boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject,
if(error < maxErrorScalar)
{
return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough
return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough
}
const auto & min = curAabb.minCorner();
......@@ -609,4 +608,4 @@ typename MeshType::Point principalComponent( const MeshType & mesh, const uint_t
} // namespace mesh
} // namespace walberla
\ No newline at end of file
} // namespace walberla
......@@ -30,6 +30,7 @@
#include "core/cell/CellInterval.h"
#include "core/mpi/MPIManager.h"
#include "core/mpi/Reduce.h"
#include "core/Optional.h"
#include <random>
#include <vector>
......@@ -101,8 +102,8 @@ inline void walberla::mesh::RefinementSelection<DistanceObject>::operator()( blo
if( blockLevel >= level_ )
continue;
boost::tribool intersects = intersectsSurface( *distanceObject_, blocks[ shuffle[ii] ]->getAABB(), maxError_, distance_ );
if( indeterminate( intersects ) || intersects )
walberla::optional< bool > intersects = intersectsSurface( *distanceObject_, blocks[ shuffle[ii] ]->getAABB(), maxError_, distance_ );
if( intersects.value_or( true ) )
refine[ shuffle[ ii ] ] = uint8_t( 1 );
}
......
......@@ -23,6 +23,7 @@
#include "core/logging/Logging.h"
#include "core/math/AABB.h"
#include "core/mpi/Environment.h"
#include "core/Optional.h"
#include "mesh/MeshIO.h"
#include "mesh/MeshOperations.h"
......@@ -50,7 +51,7 @@ void runTests( const uint_t numAABBs )
TriangleDistance<MeshType> triDist( mesh );
WALBERLA_CHECK( isIntersecting( triDist, meshAABB, real_t(0) ).value, boost::logic::tribool::true_value );
WALBERLA_CHECK( isIntersecting( triDist, meshAABB, real_t(0) ).value_or( false ) );
std::mt19937 rng( uint32_t(42) );
......@@ -60,19 +61,18 @@ void runTests( const uint_t numAABBs )
const real_t maxErr = real_t(1e-2);
boost::tribool result = isIntersecting( triDist, testAABB, maxErr );
walberla::optional< bool > result = isIntersecting( triDist, testAABB, maxErr );
if(result)
if ( result.has_value() )
{
WALBERLA_CHECK( meshAABB.intersects( testAABB ), "Box#: " << i );
}
else if(!result)
{
WALBERLA_CHECK( !meshAABB.intersects( testAABB ), "Box#: " << i );
}
else
{
WALBERLA_ASSERT( boost::logic::indeterminate( result ) );
if(result.value())
{
WALBERLA_CHECK( meshAABB.intersects( testAABB ), "Box#: " << i );
}
else if(!result.value())
{
WALBERLA_CHECK( !meshAABB.intersects( testAABB ), "Box#: " << i );
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment