Skip to content

Commit 46f1356

Browse files
authored
Add reflection transformation operator (#66)
1 parent 1885318 commit 46f1356

3 files changed

+83
-0
lines changed

Source/EBGeometry_AnalyticDistanceFunctions.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ class RoundedBoxSDF : public SignedDistanceFunction<T>
844844

845845
/*!
846846
@brief Full constructor. User inputs dimensions and corner curvature.
847+
@note The extensions of the box in each direction 'dir' is a_dimensions[dir] + a_curvature.
847848
@param[in] a_dimensions Box dimensions (width, length, height)
848849
@param[in] a_curvature Corner curvature.
849850
@note Curvature must be > 0.0

Source/EBGeometry_Transform.hpp

+52
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ template <class T>
101101
std::shared_ptr<ImplicitFunction<T>>
102102
Elongate(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const Vec3T<T>& a_elongation) noexcept;
103103

104+
/*!
105+
@brief Convenience function for reflecting an implicit function
106+
@param[in] a_implicitFunction Implicit function to be reflected
107+
@param[in] a_reflectPlane Plane to reflect across (0=yz-plane, 1=xz-plane, 2=xy-plane).
108+
*/
109+
template <class T>
110+
std::shared_ptr<ImplicitFunction<T>>
111+
Reflect(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const size_t& a_reflectPlane) noexcept;
112+
104113
/*!
105114
@brief Complemented implicit function
106115
*/
@@ -517,6 +526,49 @@ class ElongateIF : public ImplicitFunction<T>
517526
Vec3T<T> m_elongation;
518527
};
519528

529+
/*!
530+
@brief Implicit function which is a reflection of another implicit function
531+
*/
532+
template <class T>
533+
class ReflectIF : public ImplicitFunction<T>
534+
{
535+
public:
536+
/*!
537+
@brief Disallowed weak construction
538+
*/
539+
ReflectIF() = delete;
540+
541+
/*!
542+
@brief Full constructor. Reflects around the input plane (0=yz-plane, 1=xz-plane, 2=xy-plane).
543+
@param[in] a_implicitFunction Implicit function to be reflected
544+
@param[in] a_reflectPlane Plane to reflect across
545+
*/
546+
ReflectIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const size_t& a_reflectPlane) noexcept;
547+
548+
/*!
549+
@brief Destructor
550+
*/
551+
virtual ~ReflectIF() noexcept;
552+
553+
/*!
554+
@brief Value function
555+
@param[in] a_point input point
556+
*/
557+
virtual T
558+
value(const Vec3T<T>& a_point) const noexcept override;
559+
560+
protected:
561+
/*!
562+
@brief Underlying implicit function to be reflected
563+
*/
564+
std::shared_ptr<const ImplicitFunction<T>> m_implicitFunction;
565+
566+
/*!
567+
@brief Reflection parameters
568+
*/
569+
Vec3T<T> m_reflectParams;
570+
};
571+
520572
#include "EBGeometry_NamespaceFooter.hpp"
521573

522574
#include "EBGeometry_TransformImplem.hpp"

Source/EBGeometry_TransformImplem.hpp

+30
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ Elongate(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const V
8484
return std::make_shared<ElongateIF<T>>(a_implicitFunction, a_elongation);
8585
}
8686

87+
template <class T>
88+
std::shared_ptr<ImplicitFunction<T>>
89+
Reflect(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const size_t& a_reflectPlane) noexcept
90+
{
91+
return std::make_shared<ReflectIF<T>>(a_implicitFunction, a_reflectPlane);
92+
}
93+
8794
template <class T>
8895
ComplementIF<T>::ComplementIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction) noexcept
8996

@@ -349,6 +356,29 @@ ElongateIF<T>::value(const Vec3T<T>& a_point) const noexcept
349356
return m_implicitFunction->value(a_point - clamp(a_point, -m_elongation, m_elongation));
350357
}
351358

359+
template <class T>
360+
ReflectIF<T>::ReflectIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction,
361+
const size_t& a_reflectPlane) noexcept
362+
{
363+
m_implicitFunction = a_implicitFunction;
364+
m_reflectParams = Vec3T<T>::one();
365+
366+
if (a_reflectPlane >= 0 && a_reflectPlane <= 2) {
367+
m_reflectParams[a_reflectPlane] = -1;
368+
}
369+
}
370+
371+
template <class T>
372+
ReflectIF<T>::~ReflectIF() noexcept
373+
{}
374+
375+
template <class T>
376+
T
377+
ReflectIF<T>::value(const Vec3T<T>& a_point) const noexcept
378+
{
379+
return m_implicitFunction->value(a_point * m_reflectParams);
380+
}
381+
352382
#include "EBGeometry_NamespaceFooter.hpp"
353383

354384
#endif

0 commit comments

Comments
 (0)