https://mooseframework.inl.gov
CSGTransformationHelper.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseTypes.h"
13 #include "MooseEnum.h"
14 
15 namespace CSG
16 {
17 
22 {
23  TRANSLATION = 0, // Translation in x, y, z directions
24  ROTATION = 1, // Rotation in the form of euler angles (phi, theta, psi)
25  SCALE = 2 // Scaling in x, y, z directions
26 };
27 
29 static const MooseEnum transformation_type_enum{"TRANSLATION=0 ROTATION=1 SCALE=2"};
30 
35 {
36 public:
40  CSGTransformationHelper() = default;
41 
46  const std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real>>> &
48  {
49  return _transformations;
50  }
51 
59  const std::tuple<Real, Real, Real> & values);
60 
66  static std::string getTransformationTypeString(TransformationType type);
67 
72  std::vector<std::pair<std::string, std::tuple<Real, Real, Real>>>
74 
75 protected:
81  void addTransformation(TransformationType type, const std::tuple<Real, Real, Real> & values);
82 
89  Point applyReverseTransformsToPoint(Point p) const;
90 
92  std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real>>> _transformations;
93 
94  // CSGBase needs to be a friend to access addTransformation
95  friend class CSGBase;
96 
97 #ifdef MOOSE_UNIT_TEST
98  FRIEND_TEST(CSGSurfaceTest, testHalfspaceWithTransform);
101  FRIEND_TEST(CSGSurfaceTest, testHalfspaceWithNullTransform);
103 #endif
104 };
105 
106 } // namespace CSG
static bool isValidTransformationValue(TransformationType type, const std::tuple< Real, Real, Real > &values)
Check if the transformation value is valid for the given type.
TransformationType
Enumeration of transformation types that can be applied to CSG objects.
CSGTransformationHelper()=default
Default constructor.
static std::string getTransformationTypeString(TransformationType type)
Get the string representation of the transformation type.
FRIEND_TEST(CSGSurfaceTest, testHalfspaceWithTransform)
Friends for unit testing.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.
void addTransformation(TransformationType type, const std::tuple< Real, Real, Real > &values)
Add a transformation to the list of transformations.
Point applyReverseTransformsToPoint(Point p) const
update the value of point p by applying the inverse of the list of transformations to the point ...
static const MooseEnum transformation_type_enum
MooseEnum for transformation types, matching the TransformationType enum values.
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings() const
Get the transformations of this object with string representations for types.
Class for managing transformations in CSG objects.
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model...
Definition: CSGBase.h:51
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.