Commit e9f6c297 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python][wrappers] add conversion helper functions for compatibility

parent 43c95fcf
......@@ -125,36 +125,19 @@ IntersectionResult<Geo1, Geo2> intersectAndConvert(const Geo1& geo1, const Geo2&
template<class Geo1, class Geo2>
IntersectionResult<Geo1, Geo2> intersect(const Geo1& geo1, const Geo2& geo2)
{
constexpr bool isWrapper1 = OCCUtilities::IsBRepWrapper<Geo1>::value;
constexpr bool isWrapper2 = OCCUtilities::IsBRepWrapper<Geo2>::value;
if constexpr (isWrapper1 && isWrapper2)
return intersectAndConvert(geo1.get(), geo2.get());
else if constexpr(isWrapper1 && !isWrapper2)
return intersectAndConvert(geo1.get(), geo2);
else if constexpr(!isWrapper1 && isWrapper2)
return intersectAndConvert(geo1, geo2.get());
else
return intersectAndConvert(geo1, geo2);
using namespace OCCUtilities;
return intersectAndConvert(getUnwrappedShape(geo1), getUnwrappedShape(geo2));
}
//! convert shape wrapper function arguments into shape representations and forward
template<class Geo1, class Geo2, class ctype>
IntersectionResult<Geo1, Geo2> intersect(const Geo1& geo1, const Geo2& geo2, ctype eps)
{
constexpr bool isWrapper1 = OCCUtilities::IsBRepWrapper<Geo1>::value;
constexpr bool isWrapper2 = OCCUtilities::IsBRepWrapper<Geo2>::value;
if constexpr (isWrapper1 && isWrapper2)
return intersectAndConvert(geo1.get(), geo2.get(), eps);
else if constexpr(isWrapper1 && !isWrapper2)
return intersectAndConvert(geo1.get(), geo2, eps);
else if constexpr(!isWrapper1 && isWrapper2)
return intersectAndConvert(geo1, geo2.get(), eps);
else
return intersectAndConvert(geo1, geo2, eps);
using namespace OCCUtilities;
return intersectAndConvert(getUnwrappedShape(geo1), getUnwrappedShape(geo2), eps);
}
template<class Geo1, class Geo2, class ctype>
void registerIntersectionFunction(py::module& module,
const std::string& name1,
......
......@@ -134,6 +134,24 @@ struct IsBRepWrapper : public std::false_type {};
template<class S>
struct IsBRepWrapper<BRepWrapper<S>> : public std::true_type {};
// helper function to obtain the unwrapped geometry type
template<class Geo, std::enable_if_t<IsBRepWrapper<Geo>::value, int> = 0>
const typename Geo::Shape& getUnwrappedShape(const Geo& geo)
{ return geo.get(); }
template<class Geo, std::enable_if_t<!IsBRepWrapper<Geo>::value, int> = 0>
const Geo& getUnwrappedShape(const Geo& geo)
{ return geo; }
// helper function to obtain the wrapped geometry type
template<class Geo, std::enable_if_t<std::is_convertible_v<Geo, TopoDS_Shape>, int> = 0>
BRepWrapper<Geo> getWrappedShape(const Geo& geo)
{ return {geo}; }
template<class Geo, std::enable_if_t<!std::is_convertible_v<Geo, TopoDS_Shape>, int> = 0>
const Geo& getWrappedShape(const Geo& geo)
{ return geo; }
} // end namespace Frackit::Python::OCCUtilities
#endif
Supports Markdown
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