Line data Source code
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 : 18 : /** 19 : * Enumeration of transformation types that can be applied to CSG objects. 20 : */ 21 : enum class TransformationType 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 : 28 : /// MooseEnum for transformation types, matching the TransformationType enum values 29 : static const MooseEnum transformation_type_enum{"TRANSLATION=0 ROTATION=1 SCALE=2"}; 30 : 31 : /** 32 : * Class for managing transformations in CSG objects 33 : */ 34 : class CSGTransformationHelper 35 : { 36 : public: 37 : /** 38 : * Default constructor 39 : */ 40 1905 : CSGTransformationHelper() = default; 41 : 42 : /** 43 : * Get the list of transformations 44 : * @return The list of transformations 45 : */ 46 : const std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real>>> & 47 3034 : getTransformations() const 48 : { 49 3034 : return _transformations; 50 : } 51 : 52 : /** 53 : * Check if the transformation value is valid for the given type 54 : * @param type The type of transformation 55 : * @param values The values for the transformation 56 : * @return True if the values are valid for the type 57 : */ 58 : static bool isValidTransformationValue(TransformationType type, 59 : const std::tuple<Real, Real, Real> & values); 60 : 61 : /** 62 : * Get the string representation of the transformation type. 63 : * @param type The transformation type 64 : * @return String name of the transformation type 65 : */ 66 : static std::string getTransformationTypeString(TransformationType type); 67 : 68 : /** 69 : * Get the transformations of this object with string representations for types. 70 : * @return Vector of transformation pairs with string representations for types 71 : */ 72 : std::vector<std::pair<std::string, std::tuple<Real, Real, Real>>> 73 : getTransformationsAsStrings() const; 74 : 75 : protected: 76 : /** 77 : * Add a transformation to the list of transformations 78 : * @param type The type of transformation 79 : * @param values The values for the transformation 80 : */ 81 : void addTransformation(TransformationType type, const std::tuple<Real, Real, Real> & values); 82 : 83 : /** 84 : * @brief update the value of point p by applying the inverse of the list of transformations to 85 : * the point 86 : * @param p point to transform 87 : * @return transformed point 88 : */ 89 : Point applyReverseTransformsToPoint(Point p) const; 90 : 91 : /// List of transformations applied to this object 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 : /// Friends for unit testing 99 : ///@{ 100 : FRIEND_TEST(CSGSurfaceTest, testHalfspaceWithTransform); 101 : FRIEND_TEST(CSGSurfaceTest, testHalfspaceWithNullTransform); 102 : ///@} 103 : #endif 104 : }; 105 : 106 : } // namespace CSG