EBGeometry  1.0
EBGeometry_Transform.hpp
Go to the documentation of this file.
1 /* EBGeometry
2  * Copyright © 2022 Robert Marskar
3  * Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
4  */
5 
12 #ifndef EBGeometry_Transform
13 #define EBGeometry_Transform
14 
15 // Our includes
17 #include "EBGeometry_Vec.hpp"
19 
24 template <class T>
25 std::shared_ptr<ImplicitFunction<T>>
26 Complement(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction) noexcept;
27 
33 template <class T>
34 std::shared_ptr<ImplicitFunction<T>>
35 Translate(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const Vec3T<T>& a_shift) noexcept;
36 
43 template <class T>
44 std::shared_ptr<ImplicitFunction<T>>
45 Rotate(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_angle, const size_t a_axis) noexcept;
46 
52 template <class T>
53 std::shared_ptr<ImplicitFunction<T>>
54 Scale(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_scale) noexcept;
55 
61 template <class T>
62 std::shared_ptr<ImplicitFunction<T>>
63 Offset(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_offset) noexcept;
64 
70 template <class T>
71 std::shared_ptr<ImplicitFunction<T>>
72 Annular(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_delta) noexcept;
73 
79 template <class T>
80 std::shared_ptr<ImplicitFunction<T>>
81 Blur(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_blurDistance) noexcept;
82 
89 template <class T>
90 std::shared_ptr<ImplicitFunction<T>>
91 Mollify(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction,
92  const T a_dist,
93  const size_t a_mollifierSamples = 2) noexcept;
94 
100 template <class T>
101 std::shared_ptr<ImplicitFunction<T>>
102 Elongate(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const Vec3T<T>& a_elongation) noexcept;
103 
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 
116 template <class T>
118 {
119 public:
123  ComplementIF() = delete;
124 
129  ComplementIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction) noexcept;
130 
134  virtual ~ComplementIF();
135 
139  virtual T
140  value(const Vec3T<T>& a_point) const noexcept override;
141 
142 protected:
146  std::shared_ptr<ImplicitFunction<T>> m_implicitFunction;
147 };
148 
152 template <class T>
153 class TranslateIF : public ImplicitFunction<T>
154 {
155 public:
159  TranslateIF() = delete;
160 
166  TranslateIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const Vec3T<T>& a_shift) noexcept;
167 
171  virtual ~TranslateIF();
172 
176  virtual T
177  value(const Vec3T<T>& a_point) const noexcept override;
178 
179 protected:
183  std::shared_ptr<ImplicitFunction<T>> m_implicitFunction;
184 
189 };
190 
194 template <class T>
195 class RotateIF : public ImplicitFunction<T>
196 {
197 public:
201  RotateIF() = delete;
202 
209  RotateIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction,
210  const T a_angle,
211  const size_t a_axis) noexcept;
212 
216  virtual ~RotateIF();
217 
221  virtual T
222  value(const Vec3T<T>& a_point) const noexcept override;
223 
224 protected:
228  std::shared_ptr<ImplicitFunction<T>> m_implicitFunction;
229 
233  size_t m_axis;
234 
239 
244 
249 };
250 
254 template <class T>
255 class OffsetIF : public ImplicitFunction<T>
256 {
257 public:
261  OffsetIF() = delete;
262 
268  OffsetIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_offset) noexcept;
269 
273  virtual ~OffsetIF();
274 
278  virtual T
279  value(const Vec3T<T>& a_point) const noexcept override;
280 
281 protected:
285  std::shared_ptr<ImplicitFunction<T>> m_implicitFunction;
286 
291 };
292 
296 template <class T>
297 class ScaleIF : public ImplicitFunction<T>
298 {
299 public:
303  ScaleIF() = delete;
304 
310  ScaleIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const T a_scale) noexcept;
311 
315  virtual ~ScaleIF() noexcept;
316 
321  virtual T
322  value(const Vec3T<T>& a_point) const noexcept override;
323 
324 protected:
329 
334 };
335 
339 template <class T>
340 class AnnularIF : public ImplicitFunction<T>
341 {
342 public:
346  AnnularIF() = delete;
347 
353  AnnularIF(const std::shared_ptr<ImplicitFunction<T>> a_implicitFunction, const T a_delta);
354 
358  virtual ~AnnularIF();
359 
364  virtual T
365  value(const Vec3T<T>& a_point) const noexcept override;
366 
367 protected:
371  std::shared_ptr<const ImplicitFunction<T>> m_implicitFunction;
372 
377 };
378 
385 template <class T>
386 class BlurIF : public ImplicitFunction<T>
387 {
388 public:
392  BlurIF() = delete;
393 
400  BlurIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction,
401  const T a_blurDistance,
402  const T a_alpha = 0.5) noexcept;
403 
407  virtual ~BlurIF() noexcept;
408 
413  virtual T
414  value(const Vec3T<T>& a_point) const noexcept override;
415 
416 protected:
421 
425  T m_blurDistance;
426 
430  T m_alpha;
431 };
432 
436 template <class T>
437 class MollifyIF : public ImplicitFunction<T>
438 {
439 public:
443  MollifyIF() = delete;
444 
452  MollifyIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction,
453  const std::shared_ptr<ImplicitFunction<T>>& a_mollifier,
454  const T a_maxValue,
455  const size_t a_numPoints) noexcept;
456 
460  virtual ~MollifyIF() noexcept;
461 
466  virtual T
467  value(const Vec3T<T>& a_point) const noexcept override;
468 
469 protected:
474 
478  std::shared_ptr<ImplicitFunction<T>> m_mollifier;
479 
483  std::vector<std::pair<Vec3T<T>, T>> m_sampledMollifier;
484 };
485 
489 template <class T>
490 class ElongateIF : public ImplicitFunction<T>
491 {
492 public:
496  ElongateIF() = delete;
497 
503  ElongateIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const Vec3T<T>& a_elongation) noexcept;
504 
508  virtual ~ElongateIF() noexcept;
509 
514  virtual T
515  value(const Vec3T<T>& a_point) const noexcept override;
516 
517 protected:
521  std::shared_ptr<const ImplicitFunction<T>> m_implicitFunction;
522 
526  Vec3T<T> m_elongation;
527 };
528 
532 template <class T>
533 class ReflectIF : public ImplicitFunction<T>
534 {
535 public:
539  ReflectIF() = delete;
540 
546  ReflectIF(const std::shared_ptr<ImplicitFunction<T>>& a_implicitFunction, const size_t& a_reflectPlane) noexcept;
547 
551  virtual ~ReflectIF() noexcept;
552 
557  virtual T
558  value(const Vec3T<T>& a_point) const noexcept override;
559 
560 protected:
564  std::shared_ptr<const ImplicitFunction<T>> m_implicitFunction;
565 
569  Vec3T<T> m_reflectParams;
570 };
571 
572 #include "EBGeometry_NamespaceFooter.hpp"
573 
574 #include "EBGeometry_TransformImplem.hpp"
575 
576 #endif
Abstract base class for representing an implicit function.
std::shared_ptr< ImplicitFunction< T > > Annular(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_delta) noexcept
Convenience function for creating a shell out of an implicit function.
std::shared_ptr< ImplicitFunction< T > > Mollify(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_dist, const size_t a_mollifierSamples=2) noexcept
Convenience function for mollification with an input sphere.
std::shared_ptr< ImplicitFunction< T > > Offset(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_offset) noexcept
Convenience function for offsetting an implicit function.
std::shared_ptr< ImplicitFunction< T > > Scale(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_scale) noexcept
Convenience function for scaling an implicit function.
std::shared_ptr< ImplicitFunction< T > > Blur(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_blurDistance) noexcept
Convenience function for blurring an implicit function.
std::shared_ptr< ImplicitFunction< T > > Rotate(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_angle, const size_t a_axis) noexcept
Convenience function for rotating an implicit function.
std::shared_ptr< ImplicitFunction< T > > Translate(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const Vec3T< T > &a_shift) noexcept
Convenience function for translating an implicit function.
std::shared_ptr< ImplicitFunction< T > > Complement(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction) noexcept
Convenience function for taking the complement of an implicit function.
std::shared_ptr< ImplicitFunction< T > > Elongate(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const Vec3T< T > &a_elongation) noexcept
Convenience function for elongating (stretching) an implicit function.
std::shared_ptr< ImplicitFunction< T > > Reflect(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const size_t &a_reflectPlane) noexcept
Convenience function for reflecting an implicit function.
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Annular implicit function function. Creates a shell out of the implicit function.
Definition: EBGeometry_Transform.hpp:341
virtual T value(const Vec3T< T > &a_point) const noexcept override
Value function.
std::shared_ptr< const ImplicitFunction< T > > m_implicitFunction
Original implicit function.
Definition: EBGeometry_Transform.hpp:371
T m_delta
Shell thickness.
Definition: EBGeometry_Transform.hpp:376
AnnularIF()=delete
Disallowed weak construction.
AnnularIF(const std::shared_ptr< ImplicitFunction< T >> a_implicitFunction, const T a_delta)
Full constructor.
virtual ~AnnularIF()
Destructor.
Blurred/interpolated implicit function - can be used for smoothing.
Definition: EBGeometry_Transform.hpp:387
BlurIF()=delete
Disallowed weak constructino.
BlurIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_blurDistance, const T a_alpha=0.5) noexcept
Full constructor.
Complemented implicit function.
Definition: EBGeometry_Transform.hpp:118
ComplementIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction) noexcept
Full constructor.
std::shared_ptr< ImplicitFunction< T > > m_implicitFunction
Implicit function.
Definition: EBGeometry_Transform.hpp:146
virtual ~ComplementIF()
Destructor (does nothing)
virtual T value(const Vec3T< T > &a_point) const noexcept override
Value function.
ComplementIF()=delete
No weak construction for this one.
Implicit function which is an elongation of another implicit function along some axis.
Definition: EBGeometry_Transform.hpp:491
virtual ~ElongateIF() noexcept
Destructor.
ElongateIF()=delete
Disallowed weak construction.
ElongateIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const Vec3T< T > &a_elongation) noexcept
Full constructor.
Abstract representation of an implicit function function (not necessarily signed distance).
Definition: EBGeometry_ImplicitFunction.hpp:27
Mollified implicit function.
Definition: EBGeometry_Transform.hpp:438
virtual ~MollifyIF() noexcept
Destructor.
MollifyIF()=delete
Disallowed weak construction.
MollifyIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const std::shared_ptr< ImplicitFunction< T >> &a_mollifier, const T a_maxValue, const size_t a_numPoints) noexcept
Full constructor.
Offset implicit function. Offsets the implicit function using the input value.
Definition: EBGeometry_Transform.hpp:256
OffsetIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_offset) noexcept
Rounded SDF. Rounds the input SDF.
std::shared_ptr< ImplicitFunction< T > > m_implicitFunction
Underlying implicit function.
Definition: EBGeometry_Transform.hpp:285
virtual ~OffsetIF()
Destructor.
T m_offset
Offset value.
Definition: EBGeometry_Transform.hpp:290
OffsetIF()=delete
Disallowed weak construction.
virtual T value(const Vec3T< T > &a_point) const noexcept override
Implementation of value function with offset.
Implicit function which is a reflection of another implicit function.
Definition: EBGeometry_Transform.hpp:534
virtual ~ReflectIF() noexcept
Destructor.
ReflectIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const size_t &a_reflectPlane) noexcept
Full constructor. Reflects around the input plane (0=yz-plane, 1=xz-plane, 2=xy-plane).
ReflectIF()=delete
Disallowed weak construction.
Rotated implicit function. Rotates an implicit function about an axis.
Definition: EBGeometry_Transform.hpp:196
virtual ~RotateIF()
Destructor.
T m_sinAngle
Parameter in rotation matrix. Stored for efficiency.
Definition: EBGeometry_Transform.hpp:248
std::shared_ptr< ImplicitFunction< T > > m_implicitFunction
Underlying implicit function.
Definition: EBGeometry_Transform.hpp:228
RotateIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_angle, const size_t a_axis) noexcept
Rounded SDF. Rounds the input SDF.
RotateIF()=delete
No weak construction.
T m_angle
Angle to rotate.
Definition: EBGeometry_Transform.hpp:238
T m_cosAngle
Parameter in rotation matrix. Stored for efficiency.
Definition: EBGeometry_Transform.hpp:243
size_t m_axis
Axis to rotate about.
Definition: EBGeometry_Transform.hpp:233
virtual T value(const Vec3T< T > &a_point) const noexcept override
Implementation of value function with rotation.
Scaled implicit function.
Definition: EBGeometry_Transform.hpp:298
T m_scale
Scaling factor.
Definition: EBGeometry_Transform.hpp:333
virtual T value(const Vec3T< T > &a_point) const noexcept override
Value function.
ScaleIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const T a_scale) noexcept
Scaled implicit function.
ScaleIF()=delete
Disallowed weak construction.
std::shared_ptr< ImplicitFunction< T > > m_implicitFunction
Original implicit function.
Definition: EBGeometry_Transform.hpp:328
virtual ~ScaleIF() noexcept
Destructor.
Translated implicit function.
Definition: EBGeometry_Transform.hpp:154
Vec3T< T > m_shift
Input point translate.
Definition: EBGeometry_Transform.hpp:188
virtual ~TranslateIF()
Destructor (does nothing)
virtual T value(const Vec3T< T > &a_point) const noexcept override
Value function.
TranslateIF()=delete
No weak construction for this one.
TranslateIF(const std::shared_ptr< ImplicitFunction< T >> &a_implicitFunction, const Vec3T< T > &a_shift) noexcept
Full constructor.
std::shared_ptr< ImplicitFunction< T > > m_implicitFunction
Underlying implicit function.
Definition: EBGeometry_Transform.hpp:183
Three-dimensional vector class with arithmetic operators.
Definition: EBGeometry_Vec.hpp:218