/////////////////////////////////////////////////////////////////////////////// // 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 _INC_DWGCONSTRAINTCREATION_INCLUDED #define _INC_DWGCONSTRAINTCREATION_INCLUDED #include "DWGConstraintsExport.h" #include "IConstraintCreation.h" /** \details This class implements the interface to create new constraints in an OdDbDatabase instance. */ class DWGCONSTRAINTS_EXPORT DwgConstraintCreation : public OdIConstraintCreation { public: /** \details Creates a parallel geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createParallelConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a perpendicular geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createPerpendicularConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a tangent geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createTangentConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a symmetric geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param entSymId [in] ObjectID of the entity used as the symmetry axis. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param ptEntSym [in] Point on the third entity used to determine which subentity is closest to it. \param bTwoVertices [in] If true, make symmetric two vertices, not entire entities. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createSymmetricConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdDbObjectId& entSymId, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2, const OdGePoint3d& ptEntSym, bool bTwoVertices = false) ODRX_NOEXCEPT override; /** \details Creates an equal length or equal radius geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createEqualConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a coincident geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param bPointToCurve [in] If true, the point to curve coincidence is created, point to point otherwise. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createCoincidentConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2, bool bPointToCurve = false) ODRX_NOEXCEPT override; /** \details Creates a coincident geometric constraint between two polyline segments (same polyline). \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first polyline. \param entId1 [in] ObjectID of the second polyline. \param vertexSubentPath1 [in] Path to first vertex. \param vertexSubentPath2 [in] Path to second vertex. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createCoincidentConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdDbFullSubentPath& vertexSubentPath1, const OdDbFullSubentPath& vertexSubentPath2) ODRX_NOEXCEPT override; /** \details Creates a collinear geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createCollinearConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a concentric geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createConcentricConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates a fix geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId [in] ObjectID of the entity to apply fixation. \param ptEnt [in] Point on the entity used to determine which subentity is closest to it. \param bFixEntireObj [in] Determines whether to fix the entire entity or a selected subentity. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createFixConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId, const OdGePoint3d& ptEnt, bool bFixEntireObj = false) ODRX_NOEXCEPT override; /** \details Creates a horizontal or vertical geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId [in] ObjectID of the entity. \param ptEnt [in] Point on the entity used to determine which subentity is closest to it. \param bVertical [in] Vertical constraint is created if true, horizontal otherwise. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createHorizontalOrVerticalConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId, const OdGePoint3d& ptEnt, bool bVertical) ODRX_NOEXCEPT override; /** \details Creates a horizontal or vertical geometric constraint to two points. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param bVertical [in] Vertical constraint is created if true, horizontal otherwise. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createHorizontalOrVerticalConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2, bool bVertical) ODRX_NOEXCEPT override; /** \details Creates a smooth geometric constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createSmoothConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& ptEnt1, const OdGePoint3d& ptEnt2) ODRX_NOEXCEPT override; /** \details Creates an aligned dimensional constraint between point subentities. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity (may be the same as entId1 to create a constraint within the same entity). \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param dimPos [in] Position of the dimension. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createAlignedDimConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& entPt1, const OdGePoint3d& entPt2, const OdGePoint3d& dimPos, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details Creates a horizontal or vertical dimensional constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param dimPos [in] Position of the dimension. \param bVertical [in] Vertical constraint is created if true, horizontal otherwise. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createHorizontalOrVerticalDimConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& entPt1, const OdGePoint3d& entPt2, const OdGePoint3d& dimPos, bool bVertical, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details Creates a two line angular dimensional constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param dimPos [in] Position of the dimension. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult create2LineAngularDimConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdGePoint3d& entPt1, const OdGePoint3d& entPt2, const OdGePoint3d& dimPos, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details Creates a three point angular dimensional constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId1 [in] ObjectID of the first entity. \param entId2 [in] ObjectID of the second entity. \param entId3 [in] ObjectID of the third entity. \param ptEnt1 [in] Point on the first entity used to determine which subentity is closest to it. \param ptEnt2 [in] Point on the second entity used to determine which subentity is closest to it. \param ptEnt3 [in] Point on the third entity used to determine which subentity is closest to it. \param dimPos [in] Position of the dimension. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult create3PointAngularDimConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId1, const OdDbObjectId& entId2, const OdDbObjectId& entId3, const OdGePoint3d& entPt1, const OdGePoint3d& entPt2, const OdGePoint3d& entPt3, const OdGePoint3d& dimPos, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details Creates a radial or diameter dimensional constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param entId [in] ObjectID of the entity. \param ptEnt [in] Point on the entity used to determine which subentity is closest to it. \param dimPos [in] Position of the dimension. \param isRadial [in] Radial constraint is created if true, diameter otherwise. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createRadialOrDiamDimConstraint(OdDbDatabase* pDatabase, const OdDbObjectId& entId, const OdGePoint3d& entPt, const OdGePoint3d& dimPos, bool isRadial, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details Converts associative dimensions to dimensional constraints. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be created. \param dimAssocId [in] associative dimensions. \param varDimId [out] ObjectId of the associated AssocVariable created (dimemsion parameter). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult convertAssocDimensionToConstraint(OdDbDatabase* pDatabase, OdDbObjectId& dimAssocId, OdDbObjectId& varDimId) ODRX_NOEXCEPT override; /** \details List all constraints, bounded to entity. \param pDatabase [in] Pointer to OdDbDatabase instance which contains entity and constraints. \param entId [in] ObjectID of the entity. \param ptEnt [in] Point on the entity used to determine which subentity is closest to it. \param constraintList [out] constraint list. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult listConstraints(OdDbDatabase* pDatabase, const OdDbObjectId& entId, const OdGePoint3d& entPt, OdGeomConstraintPtrList& constraintList) ODRX_NOEXCEPT override; /** \details Delete constraint. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be deleted. \param constraint [in] constraint to delete. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult deleteConstraint(OdDbDatabase* pDatabase, OdGeomConstraintPtr constraint) ODRX_NOEXCEPT override; /** \details Delete all constraints, bounded to entity. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraint will be deleted. \param entId [in] ObjectID of the entity. \param ptEnt [in] Point on the entity used to determine which subentity is closest to it. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult deleteAllConstraints(OdDbDatabase* pDatabase, const OdDbObjectId& entId, const OdGePoint3d& entPt) ODRX_NOEXCEPT override; /** \details List parameters. \param pDatabase [in] Pointer to OdDbDatabase instance which contains parameters. \param paramIds [out] List of parameters (assoc variables object identifiers). \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult listParameters(const OdDbDatabase* pDatabase, OdDbObjectIdArray& paramIds) ODRX_NOEXCEPT override; /** \details Create user parameter. \param pDatabase [in] Pointer to OdDbDatabase instance which contains constraints. \param paramId [out] Created parameter (assoc variables object identifier). \param name [in] Name of new parameter. \param expression [in] New parameter expression. \param value [in] New parameter value. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult createUserParameter(const OdDbDatabase* pDatabase, OdDbObjectId& paramId, const OdString& name, const OdString& expression = OdString::kEmpty, double value = 0) ODRX_NOEXCEPT override; /** \details Delete existing parameter. \param pDatabase [in] Pointer to OdDbDatabase where parameter is. \param paramId [in] Parameter identifier. \param autoDereference [in] Automatic dereference flag. If true and deleted parameter referenced by another parameters, then in another parameters the deleted parameter name will be replaced with its value. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult deleteParameter(const OdDbDatabase* pDatabase, const OdDbObjectId& paramId, bool autoDereference = false) ODRX_NOEXCEPT override; /** \details List parameters which reference to given parameter in expression. \param paramId [in] Parameter identifier. \param referenceParamIds [out] List of parameter identifiers which uses given parameter in expression. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult listReferencedParameters(const OdDbObjectId& paramId, OdDbObjectIdArray& referenceParamIds) ODRX_NOEXCEPT override; /** \details Replace parameter name with its value in expression. \param modifiedParamId [in] Parameter identifier which expression reference another parameter. \param referencedParamId [in] Parameter identifier, referenced by expression. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult dereferenceParameter(const OdDbObjectId& modifiedParamId, const OdDbObjectId& referencedParamId) ODRX_NOEXCEPT override; /** \details Creates all requested constraints that match the given entities. \param pDatabase [in] Pointer to OdDbDatabase instance where the constraints will be created. \param aEntId [in] List of the entities to autoconstrain. \param aConstraintType [in] List of constraint types to create. The order in list means priority. \param tol [in] Tolerance to check whether a constraint may be applied. \returns eOk if successful or an appropriate error code if not. \returns eNotApplicable If DWGConstraints module is not inited. */ virtual OdResult autoConstrain(OdDbDatabase* pDatabase, const OdDbObjectIdArray& aEntId, const OdArray& aConstraintType, OdGeTol tol) ODRX_NOEXCEPT override; }; #endif /* _INC_DWGCONSTRAINTCREATION_INCLUDED */