/** * @file FITKAbsGeoTransformation.h * @brief 模型变换抽象类. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ #ifndef FITKABSGEOTRANSFORMATION_H #define FITKABSGEOTRANSFORMATION_H #include "FITKAbsGeoCommand.h" #include "FITKInterfaceGeometryAPI.h" #include namespace Interface { /** * @brief 变换基类. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoTransformation : public FITKAbsGeoCommand { public: FITKAbsGeoTransformation() = default; virtual ~FITKAbsGeoTransformation() = default; VirtualShape sourceShape() const { return m_SourceShape; } void setSourceShape(VirtualShape shape) { m_SourceShape = shape; } bool isCopy() const { return m_IsCopy; } void setCopy(bool copy) { m_IsCopy = copy; } protected: /** * @brief 原始形状. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ VirtualShape m_SourceShape{}; /** * @brief 是否拷贝原形状. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ bool m_IsCopy{ false }; }; /** * @brief 平移变换. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoModelTransform : public FITKAbsGeoTransformation { public: FITKAbsGeoModelTransform() = default; ~FITKAbsGeoModelTransform() override = default; FITKGeoEnum::FITKGeometryComType getGeometryCommandType() override; std::array vector() const { return m_Vector; } void setVector(std::array vec) { m_Vector = vec; } void setVector(double x, double y, double z) { m_Vector = { x,y,z }; } protected: /** * @brief 平移向量. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_Vector{}; }; /** * @brief 通过两个点平移变换. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoModelTransformByTwoPoints : public FITKAbsGeoModelTransform { public: FITKAbsGeoModelTransformByTwoPoints() = default; ~FITKAbsGeoModelTransformByTwoPoints()override = default; FITKGeoEnum::FITKGeometryComType getGeometryCommandType() override; std::array startPoint() const { return m_StartPoint; } void setStartPoint(std::array vec) { m_StartPoint = vec; } void setStartPoint(double x, double y, double z) { m_StartPoint = { x,y,z }; } std::array endPoint() const { return m_EndPoint; } void setEndPoint(std::array vec) { m_EndPoint = vec; } void setEndPoint(double x, double y, double z) { m_EndPoint = { x,y,z }; } protected: /** * @brief 起始点. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_StartPoint{}; /** * @brief 终止点. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_EndPoint{}; }; /** * @brief 通过方向和距离平移变换. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoModelTransformByDirAndDis : public FITKAbsGeoModelTransform { public: FITKAbsGeoModelTransformByDirAndDis() = default; ~FITKAbsGeoModelTransformByDirAndDis()override = default; FITKGeoEnum::FITKGeometryComType getGeometryCommandType() override; std::array direction() const { return m_Direction; } void setDirection(std::array dir) { m_Direction = dir; } void setDirection(double x, double y, double z) { m_Direction = { x,y,z }; } double distance() const { return m_Distance; } void setDistance(double dis) { m_Distance = dis; } protected: /** * @brief 平移方向. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_Direction{}; /** * @brief 平移距离. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ double m_Distance{}; }; /** * @brief 旋转变换. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoModelRotate : public FITKAbsGeoTransformation { public: FITKAbsGeoModelRotate() = default; ~FITKAbsGeoModelRotate() override = default; FITKGeoEnum::FITKGeometryComType getGeometryCommandType() override; std::array axisStartPoint() const { return m_AxisStartPoint; } void setAxisStartPoint(std::array xyz) { m_AxisStartPoint = xyz; } void setAxisStartPoint(double x, double y, double z) { m_AxisStartPoint = { x,y,z }; } std::array axisEndPoint() const { return m_AxisEndPoint; } void setAxisEndPoint(std::array xyz) { m_AxisEndPoint = xyz; } void setAxisEndPoint(double x, double y, double z) { m_AxisEndPoint = { x,y,z }; } double degree() const { return m_Angle / 3.14159265358979323846 * 180; } void setDegree(double deg) { m_Angle = deg / 180 * 3.14159265358979323846; } double radian() const { return m_Angle; } void setRadian(double rad) { m_Angle = rad; } protected: /** * @brief 旋转轴起始点. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_AxisStartPoint{}; /** * @brief 旋转轴终止点. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_AxisEndPoint{}; /** * @brief 旋转角度(弧度值). * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ double m_Angle{}; }; /** * @brief 缩放变换. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ class FITKInterfaceGeometryAPI FITKAbsGeoModelScale : public FITKAbsGeoTransformation { public: FITKAbsGeoModelScale() = default; ~FITKAbsGeoModelScale()override = default; FITKGeoEnum::FITKGeometryComType getGeometryCommandType() override; std::array factors() const { return m_Factors; } void setFactors(std::array factors) { m_Factors = factors; } void setFactors(double x, double y, double z) { m_Factors = { x, y, z }; } std::array basePoint() const { return m_BasePoint; } void setBasePoint(std::array point) { m_BasePoint = point; } void setBasePoint(double x, double y, double z) { m_BasePoint = { x, y, z }; } protected: /** * @brief 缩放因子. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_Factors{}; /** * @brief 缩放基准点. * @author YanZhiHui (chanyuantiandao@126.com) * @date 2024-09-10 */ std::array m_BasePoint{ 0, 0, 0 }; }; } #endif // FITKABSGEOTRANSFORMATION_H