/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef DWGConstraintArgsValidator_INCLUDED_ #define DWGConstraintArgsValidator_INCLUDED_ #include #include "DbAssocGlobal.h" #include "OdConstrainedGeometry.h" #include "DWGCommandsUtils.h" /** \details The base class for arguments validator. Args validator checks if entity can be used as argument of the given constraint. */ class ConstraintArgsValidator { public: enum class Modificator { Default, FixEntireObj, HorVertTwoPoins, CoincidentObjectPoint, SymmetricTwoPoints }; ConstraintArgsValidator(); bool isEntityValidForConstraint(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); void setModificator(Modificator m); protected: Modificator modificator; int argumentNumber; using CurveTypeList = std::vector; bool isCurveValid(DWGConstraintUtils::CurvePtr curve, const CurveTypeList& validCurves); virtual bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) = 0; }; /** */ class CoincidentArgsValidator : public ConstraintArgsValidator { public: bool isVerticesValidForConstraint(const OdDbObjectId& entId, const OdDbFullSubentPath& vertexSubentPath1, const OdDbFullSubentPath& vertexSubentPath2); protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kCircArc3d, OdGe::kEllipArc3d, OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kNurbCurve3d }; bool isEntityValidForTwoPointsConstraint(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); bool isEntityValidForObjPointConstraint(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); }; /** */ class FixArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kCircArc3d, OdGe::kEllipArc3d, OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kNurbCurve3d }; }; /** */ class LinesConstraintArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kEllipArc3d }; }; /** */ class HorizontalVerticalArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kEllipArc3d }; }; /** */ class SymmetricArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kCircArc3d, OdGe::kEllipArc3d, OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kNurbCurve3d }; const std::vector allowedSymmetryLines = std::vector{ OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d }; bool firstEntityIsPoint; OdGe::EntityId firstCurveType; bool validateFirstArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); bool validateSecondArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); bool validateThirdArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); }; /** */ class TangentArgsValidator : public ConstraintArgsValidator { public: TangentArgsValidator(); protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kRay3d, OdGe::kLine3d, OdGe::kCircArc3d, OdGe::kEllipArc3d }; bool arcFirst; bool validateFirstArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); bool validateSecondArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); }; /** */ class EqualArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; private: const std::vector allowedCurves = std::vector{ OdGe::kLinearEnt3d, OdGe::kLineSeg3d, OdGe::kLine3d, OdGe::kCircArc3d, OdGe::kPointEnt3d }; OdGe::EntityId firstCurveType; bool validateFirstArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); bool validateSecondArgument(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint); }; /** */ class ConcentricArgsValidator : public ConstraintArgsValidator { protected: bool isEntityValidForConstraintPrivate(const OdDbObjectId& entityId, const OdGePoint3d& pickedPoint) ODRX_OVERRIDE; }; #endif