AcDbAssoc2dConstraintGroup.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. //
  12. // DESCRIPTION:
  13. //
  14. // AcDbAssoc2dConstraintGroup class.
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. #pragma once
  18. #include "AcDbAssocAction.h"
  19. #include "AcConstraintGroupNode.h"
  20. #include "AcConstrainedGeometry.h"
  21. #include "AcGeomConstraint.h"
  22. #include "AcExplicitConstr.h"
  23. #pragma pack (push, 8)
  24. class AcAutoConstrainEvaluationCallback;
  25. /// <summary> <para>
  26. /// The AcDbAssoc2dConstraintGroup class represents a set of geometric constraint
  27. /// relations between subentities of geometric entities. All the geometries must
  28. /// lie in a single plane.
  29. /// </para> <para>
  30. /// The AcDbAssoc2dConstraintGroup object owns the constraints that are derived
  31. /// from the AcGeomConstraint class, and "proxies" of the constrained geometried,
  32. /// derived from AcConstrainedGeometry class. AcConstrainedGeometries often
  33. /// refer to subentities of AutoCAD entities and the AcDbAssoc2dConstraintGroup
  34. /// owns AcDbAssocGeomDepedencies on these entities. It also owns
  35. /// AcDbAssocValueDependencies on the AcDbAssocVariables that are the values of
  36. /// dimensional constraints (represented by classes derived from AcExplicitConstraint).
  37. /// </para> <para>
  38. /// If the dimensional constraint has a graphical representation, such as in the
  39. /// form of an AcDbDimension entity, the AcExplicitConstraint also owns
  40. /// AcdbAssocDependency owning an object derived from AcDbAssocDimDependencyBody
  41. /// that facilitates the interaction between the AcExplicitConstraint, the
  42. /// AcDbAssocVariable keeping the value of the dimensional constraint, and the
  43. /// AcDbDimension (or other object/entity) that serves as a graphical representation
  44. /// of the dimensional constraint.
  45. /// </para> <para>
  46. /// The evaluate() method of this action takes the current properties of the
  47. /// referenced geometries and the current values of the variables referenced by
  48. /// AcExplicitConstraints. Then it invokes a constraint solver that finds new
  49. /// positions and shapes of the constrained geometries so that they satisfy the
  50. /// constraints. Finally the referenced geometries are updated to their new
  51. /// positions and shapes. The evaluate method call may fail if a solution
  52. /// satisfying all the constraints can not be found.
  53. /// </para> </summary>
  54. ///
  55. class ACDB_PORT AcDbAssoc2dConstraintGroup : public AcDbAssocAction
  56. {
  57. public:
  58. ACRX_DECLARE_MEMBERS(AcDbAssoc2dConstraintGroup);
  59. /// <summary> The solution status of this constraint group. </summary>
  60. ///
  61. enum SolutionStatus
  62. {
  63. /// <summary>
  64. /// All constrained geometries are fully constrained.
  65. /// The degree of freedom of the entire model is 0.
  66. /// </summary>
  67. ///
  68. kWellDefined = 0,
  69. /// <summary>
  70. /// Some or all constrained geometries are under constrained.
  71. /// The degree of freedom of the entire model is larger than 0.
  72. /// </summary>
  73. ///
  74. kUnderConstrained,
  75. /// <summary>
  76. /// Some or all constrained geometries are over constrained.
  77. /// Normally this is because duplicate or redundant constraints are added.
  78. /// </summary>
  79. ///
  80. kOverConstrained,
  81. /// <summary>
  82. /// Some or all constrained geometries/constraints are inconsistent.
  83. /// Normally this is because invalid constraints are added.
  84. /// For example, two lines are made both parallel and perpendicular.
  85. /// </summary>
  86. ///
  87. kInconsistent,
  88. /// <summary>
  89. /// Some or all constrained geometries/constraints are not evaluated.
  90. /// Normally this means new constrained geometries or constraints are
  91. /// added since last evaluation.
  92. /// </summary>
  93. ///
  94. kNotEvaluated,
  95. /// <summary>
  96. /// Not able to get the solution status.
  97. /// Normally this means fatal errors.
  98. /// </summary>
  99. ///
  100. kNotAvailable,
  101. /// <summary>
  102. /// Evaluation produced result that may be considered valid by DCM but is
  103. /// rejected by the client code, such as when degenerate geometry was created
  104. /// and the client code does not want to accept it.
  105. /// </summary>
  106. ///
  107. kRejectedByClient,
  108. };
  109. /// <summary>
  110. /// Default constructor.
  111. /// </summary>
  112. /// <param name="plane">
  113. /// Input AcGePlane of the newly created constraint group object.
  114. /// Default value is AcGePlane::kXYPlane.
  115. /// </param>
  116. ///
  117. AcDbAssoc2dConstraintGroup(const AcGePlane& plane = AcGePlane::kXYPlane);
  118. /// <summary>
  119. /// Gets the work plane of this constraint group. This work plane defines the
  120. /// mapping from the internal coordinate system of the constraint group in which
  121. /// AcConstrainedGeometries and AcGeomConstraints are represented, to the world
  122. /// coordinate system in which the referenced constrained AcDbEntities are
  123. /// represented.
  124. /// </summary>
  125. /// <returns> AcGePlane </returns>
  126. ///
  127. const AcGePlane getWorkPlane() const;
  128. /// <summary>
  129. /// Sets the work plane of this constraint group. This API
  130. /// re-initializes all AcConstrainedGeometry objects owned by it.
  131. /// It is important to transform the constrained entities to the
  132. /// new work plane before this API is called, otherwise, some
  133. /// constraints might be erased during the next evaluation
  134. /// </summary>
  135. /// <param name="newPlane"> The given new work plane. </param>
  136. /// <returns> void </returns>
  137. ///
  138. void setWorkPlane(const AcGePlane& newPlane);
  139. /// <summary>
  140. /// Transforms the work plane of the constraint group by the rigid motion
  141. /// component of the transformation matrix. If the transformation matrix also
  142. /// contains a uniform scaling factor, it removes all AcExplicitConstraint nodes.
  143. /// If the transformation matrix contains a general component, it removes all
  144. /// AcGeomConstraint nodes.
  145. /// </summary>
  146. /// <param name="transform"> The given transformation matrix. </param>
  147. /// <returns> Returns Acad::eOk. </returns>
  148. ///
  149. Acad::ErrorStatus transformActionBy(const AcGeMatrix3d& transform);
  150. /// <summary>
  151. /// Get the remaining DOF (Degree of Freedom) of this constraint group.
  152. /// It includes the positional DOF of a well-defined model.
  153. /// </summary>
  154. /// <returns>int</returns>
  155. ///
  156. int getDOF();
  157. /// <summary>
  158. /// Get the solution evaluation status of this constraint group.
  159. /// Normally this method should only be called after an evaluation
  160. /// </summary>
  161. /// <param name="bAlsoCheckForConstraints">
  162. /// Input boolean indicating if need to check constraints.
  163. /// Default value is true.
  164. /// </param>
  165. /// <returns>SolutionStatus</returns>
  166. ///
  167. SolutionStatus solutionStatus(bool bAlsoCheckForConstraints = true) const;
  168. /// <summary>
  169. /// Get the evaluation status of the passed in constrained geometry.
  170. /// Normally this method should only be called after an evaluation
  171. /// </summary>
  172. /// <param name="pConsGeom">
  173. /// Input pointer to AcConstrainedGeometry indicating the constrained
  174. /// geometry object to be checked.
  175. /// </param>
  176. /// <returns>SolutionStatus</returns>
  177. ///
  178. SolutionStatus geometryStatus(const AcConstrainedGeometry* pConsGeom) const;
  179. /// <summary>
  180. /// Get the evaluation status of the passed in constraint.
  181. /// </summary>
  182. /// <param name="pConstraint">
  183. /// Input pointer to AcGeomConstraint indicating the constraint object to be checked.
  184. /// </param>
  185. /// <returns>SolutionStatus</returns>
  186. ///
  187. SolutionStatus constraintStatus(const AcGeomConstraint* pConstraint) const;
  188. /// <summary>
  189. /// Create and add a new AcConstrainedGeometry object into this constraint group.
  190. /// Caller should not cache the pointer returned for future use.
  191. /// instead caller may cache the node id of AcConstrainedGeometry.
  192. /// <seealso cref="AcConstraintGroupNode::nodeId"/>
  193. /// </summary>
  194. /// <param name="subentPath">
  195. /// Input AcDbFullSubentPath of the constrained entity, down to the subentity level.
  196. /// Only AcDb::kEdgeSubentType and AcDb::kVertexSubentType are valid subent types.
  197. /// The vertex subent must NOT be edge vertex.
  198. /// </param>
  199. /// <param name="pConsGeom">
  200. /// Output pointer to AcConstrainedGeometry.
  201. /// If the corresponding constrained geometry is already there, pConsGeom is set to
  202. /// point to the existing AcConstrainedGeometry object and Acad::eAlreadyInGroup returned.
  203. /// If the constrained geometry is not created successfully, pConsGeom is set to NULL.
  204. /// </param>
  205. /// <returns>Returns Acad::eOk if successful.</returns>
  206. ///
  207. Acad::ErrorStatus addConstrainedGeometry(const AcDbFullSubentPath& subentPath, AcConstrainedGeometry*& pConsGeom);
  208. /// <summary>
  209. /// Delete an existing AcConstrainedGeometry object which is internally held.
  210. /// This function also remove and erase the AcDbAssocGeomDependency object
  211. /// from this constraint group action.
  212. /// </summary>
  213. /// <param name="geomDependencyId">
  214. /// Input AcDbObjectId of the AcDbAssocGeomDependency object.
  215. /// </param>
  216. /// <returns>Returns Acad::eOk if successful.</returns>
  217. ///
  218. Acad::ErrorStatus deleteConstrainedGeometry(const AcDbObjectId& geomDependencyId);
  219. /// <summary>
  220. /// Get pointer to the corresponding internally held AcConstrainedGeometry.
  221. /// The pointer returned might be temporary and caller should not cache it
  222. /// for future use, instead caller may cache the node id of AcConstrainedGeometry.
  223. /// <seealso cref="AcConstraintGroupNode::nodeId"/>
  224. /// </summary>
  225. /// <param name="fullSubentPath">
  226. /// Input AcDbFullSubentPath of the constrained entity, down to the subentity level.
  227. /// Only vertex or edge subentity type can be passed in, otherwise Acad::eInvalidInput returned
  228. /// </param>
  229. /// <param name="pConsGeom">
  230. /// Output pointer to AcConstrainedGeometry.
  231. /// If the constrained geometry is not found, pConsGeom is set to NULL.
  232. /// </param>
  233. /// <param name="bCreateArcLineMid">
  234. /// Input Boolean indicating if create implicit midpoint of arc or line segment if it is not there.
  235. /// Default value is false.
  236. /// </param>
  237. /// <returns>Returns Acad::eOk if successful.</returns>
  238. ///
  239. Acad::ErrorStatus getConstrainedGeometry(const AcDbFullSubentPath& fullSubentPath,
  240. AcConstrainedGeometry*& pConsGeom,
  241. bool bCreateArcLineMid = false);
  242. /// <summary>
  243. /// Get pointer to the corresponding internally held AcConstrainedGeometry.
  244. /// The pointer returned might be temporary and caller should not cache it
  245. /// for future use, instead caller may cache the node id of AcConstrainedGeometry.
  246. /// <seealso cref="AcConstraintGroupNode::nodeId"/>
  247. /// </summary>
  248. /// <param name="pGeomDependency">
  249. /// Input pointer to AcDbAssocGeomDependency of the constrained entity.
  250. /// The AcDbAssocGeomDependency object maybe transient, in other words,
  251. /// not added into the database yet.
  252. /// </param>
  253. /// <param name="pConsGeom">
  254. /// Output pointer to AcConstrainedGeometry.
  255. /// If the constrained geometry is not found, pConsGeom is set to NULL.
  256. /// </param>
  257. /// <param name="pPtType">
  258. /// Input pointer to ImplicitPointType indicating the implicit
  259. /// point type of a constrained curve. Only present when caller want to retrieve the
  260. /// AcConstrainedImplicitPoint of a AcConstrainedCurve.
  261. /// Default value is NULL.
  262. /// </param>
  263. /// <param name="defPtIndex">
  264. /// Input integer index of define points of a parametric curve. Currently only control points
  265. /// of a spline are supported. It is only valid when the implicit point type is kDefineImplicit.
  266. /// Default value is -1(invalid index value).
  267. /// </param>
  268. /// <param name="bCreateArcLineMid">
  269. /// Input Boolean indicating if create implicit midpoint of arc or line segment if it is not there.
  270. /// Default value is false.
  271. /// </param>
  272. /// <returns>Returns Acad::eOk if successful.</returns>
  273. ///
  274. Acad::ErrorStatus getConstrainedGeometry(const AcDbAssocGeomDependency* pGeomDependency,
  275. AcConstrainedGeometry*& pConsGeom,
  276. AcDb::ImplicitPointType* pPtType = NULL,
  277. int defPtIndex = -1,
  278. bool bCreateArcLineMid = false);
  279. /// <summary>
  280. /// Get all AcConstrainedGeometry objects in this constraint group,
  281. /// including AcConstraintImplicitPoint objects which are associated
  282. /// with corresponding AcConstrainedCurve objects.
  283. /// </summary>
  284. /// <param name="aConstGeom">
  285. /// Output AcArray of the AcConstrainedGeometry objects.
  286. /// </param>
  287. /// <returns>Returns Acad::eOk if successful.</returns>
  288. ///
  289. Acad::ErrorStatus getConstrainedGeometries(AcArray<AcConstrainedGeometry*>& aConstGeom) const;
  290. /// <summary>
  291. /// Create and add a geometrical constraint into this constraint group.
  292. /// </summary>
  293. /// <param name="type">
  294. /// Input AcGeomConstraint::GeomConstraintType indicating the type of constraint to be created.
  295. /// </param>
  296. /// <param name="aPaths">
  297. /// Input AcArray of the AcDbFullSubentPath which can be mapped to AcConstrainedGeometry.
  298. /// </param>
  299. /// <param name="ppNewConstraint">
  300. /// Output pointer to AcGeomConstraint* pointing the newly created AcGeomConstraint object.
  301. /// Default value is NULL.
  302. /// </param>
  303. /// <param name="pUCSCoord">
  304. /// Optionally input pointer to AcGeMatrix3d which is used as UCS coordinate. This parameter
  305. /// is only used when Horizontal or Vertical constraint is applied
  306. /// Default value is NULL.
  307. /// </param>
  308. /// <returns>
  309. /// Returns Acad::eOk if successful.
  310. /// Returns Acad::eFailedToAddConstraint if the constraint cannot be added in because of
  311. /// over-constrained or inconsistent model.
  312. /// Returns Acad::eAlreadyInGroup if a same type of constraint is already there.
  313. /// Returns Acad::eInvalidInput or Acad::eNotApplicable for other errors.
  314. /// </returns>
  315. ///
  316. Acad::ErrorStatus addGeometricalConstraint(AcGeomConstraint::GeomConstraintType type,
  317. const AcDbFullSubentPathArray& aPaths,
  318. AcGeomConstraint** ppNewConstraint = NULL,
  319. const AcGeMatrix3d* pUCSCoord = NULL);
  320. /// <summary>
  321. /// Create and add a geometrical constraint into this constraint group.
  322. /// </summary>
  323. /// <param name="type">
  324. /// Input AcGeomConstraint::GeomConstraintType indicating the type of constraint to be created.
  325. /// </param>
  326. /// <param name="apConsGeoms">
  327. /// Input AcArray of the AcConstrainedGeometry.
  328. /// </param>
  329. /// <param name="ppNewConstraint">
  330. /// Output pointer to AcGeomConstraint* pointing the newly created AcGeomConstraint object.
  331. /// Default value is NULL.
  332. /// </param>
  333. /// <param name="pUCSCoord">
  334. /// Optionally input pointer to AcGeMatrix3d which is used as UCS coordinate. This parameter
  335. /// is only used when Horizontal or Vertical constraint is applied
  336. /// Default value is NULL.
  337. /// </param>
  338. /// <returns>
  339. /// Returns Acad::eOk if successful.
  340. /// Returns Acad::eFailedToAddConstraint if the constraint cannot be added in because of
  341. /// over-constrained or inconsistent model.
  342. /// Returns Acad::eAlreadyInGroup if a same type of constraint is already there.
  343. /// Returns Acad::eInvalidInput or Acad::eNotApplicable for other errors.
  344. /// </returns>
  345. ///
  346. Acad::ErrorStatus addGeometricalConstraint(AcGeomConstraint::GeomConstraintType type,
  347. const AcArray<AcConstrainedGeometry*>& apConsGeoms,
  348. AcGeomConstraint** ppNewConstraint = NULL,
  349. const AcGeMatrix3d* pUCSCoord = NULL);
  350. /// <summary>
  351. /// Create and add a distance constraint into this constraint group.
  352. /// </summary>
  353. /// <param name="pConsGeom1">
  354. /// Input pointer to the first AcConstrainedGeometry object.
  355. /// </param>
  356. /// <param name="pConsGeom2">
  357. /// Input pointer to the second AcConstrainedGeometry object.
  358. /// </param>
  359. /// <param name="directionType">
  360. /// Input AcDistanceConstraint::DirectionType indicating the direction type
  361. /// of the distance constraint to be created.
  362. /// </param>
  363. /// <param name="valueDependencyId">
  364. /// Input object id of the value dependency object.
  365. /// </param>
  366. /// <param name="pFixedDirection">
  367. /// Input pointer to AcGeVector3d indicating the fixed direction of
  368. /// the distance constraint to be created. It will be used only when
  369. /// the directionType is kFixedDirection.
  370. /// Relative to the World Coordinate System.
  371. /// </param>
  372. /// <param name="pDirectionLine">
  373. /// Input pointer to AcConstrainedLine object indicating the relative
  374. /// direction of the distance constraint to be created. It will be used only
  375. /// when the directionType is kPerpendicularToLine or kParallelToLine.
  376. /// </param>
  377. /// <param name="ppNewDisConstraint">
  378. /// Output pointer to AcDistanceConstraint* pointing the newly created AcDistanceConstraint object.
  379. /// Default value is NULL.
  380. /// </param>
  381. /// <returns>Returns Acad::eOk if successful.</returns>
  382. ///
  383. Acad::ErrorStatus addDistanceConstraint(AcConstrainedGeometry* pConsGeom1,
  384. AcConstrainedGeometry* pConsGeom2,
  385. AcDistanceConstraint::DirectionType directionType,
  386. AcDbObjectId valueDependencyId,
  387. AcDbObjectId dimDependencyId, // May be null
  388. const AcGeVector3d* pFixedDirection = NULL,
  389. const AcConstrainedLine* pDirectionLine = NULL,
  390. AcDistanceConstraint** ppNewDisConstraint = NULL);
  391. /// <summary>
  392. /// Create and add an angle constraint into this constraint group.
  393. /// </summary>
  394. /// <param name="pConsLine1">
  395. /// Input pointer to AcConstrainedLine object
  396. /// </param>
  397. /// <param name="pConsLine2">
  398. /// Input pointer to AcConstrainedLine object
  399. /// </param>
  400. /// <param name="sectorType">
  401. /// Input AcAngleConstraint::SectorType indicating the angle sector to measure.
  402. /// </param>
  403. /// <param name="valueDependencyId">
  404. /// Input object id of the value dependency object.
  405. /// </param>
  406. /// <param name="dimDependencyId">
  407. /// Input object id of the dimension dependency object.
  408. /// </param>
  409. /// <param name="ppNewAngConstraint">
  410. /// Output pointer to AcAngleConstraint* pointing the newly created AcAngleConstraint object.
  411. /// Default value is NULL.
  412. /// </param>
  413. /// <returns>Returns Acad::eOk if successful.</returns>
  414. ///
  415. Acad::ErrorStatus addAngleConstraint(AcConstrainedLine* pConsLine1,
  416. AcConstrainedLine* pConsLine2,
  417. AcAngleConstraint::SectorType sectorType,
  418. AcDbObjectId valueDependencyId,
  419. AcDbObjectId dimDependencyId, // May be null
  420. AcAngleConstraint** ppNewAngConstraint = NULL);
  421. /// <summary>
  422. /// Create and add a 3point angle constraint into this constraint group.
  423. /// </summary>
  424. /// <param name="pConsPoint1">
  425. /// Input pointer of the first (angle) point which must be a kind of
  426. /// AcConstraintPoint
  427. /// </param>
  428. /// <param name="pConsPoint2">
  429. /// Input pointer of the second point which must be a kind of
  430. /// AcConstraintPoint
  431. /// </param>
  432. /// <param name="pConsPoint3">
  433. /// Input pointer of the third point which must be a kind of
  434. /// AcConstraintPoint
  435. /// </param>
  436. /// <param name="sectorType">
  437. /// Input AcAngleConstraint::SectorType indicating the angle sector to measure.
  438. /// </param>
  439. /// <param name="valueDependencyId">
  440. /// Input object id of the value dependency object.
  441. /// </param>
  442. /// <param name="dimDependencyId">
  443. /// Input object id of the dimension dependency object.
  444. /// </param>
  445. /// <param name="ppNewAngConstraint">
  446. /// Output pointer to Ac3PointAngleConstraint* pointing the newly created Ac3PointAngleConstraint object.
  447. /// Default value is NULL.
  448. /// </param>
  449. /// <returns>Returns Acad::eOk if successful.</returns>
  450. Acad::ErrorStatus add3PointAngleConstraint(AcConstrainedPoint* pConsPoint1,
  451. AcConstrainedPoint* pConsPoint2,
  452. AcConstrainedPoint* pConsPoint3,
  453. AcAngleConstraint::SectorType sectorType,
  454. AcDbObjectId valueDependencyId,
  455. AcDbObjectId dimDependencyId, // May be null
  456. Ac3PointAngleConstraint** ppNewAngConstraint = NULL);
  457. /// <summary>
  458. /// Create and add a radius or diameter constraint into this constraint group.
  459. /// </summary>
  460. /// <param name="pConsGeom">
  461. /// Input pointer to AcConstrainedGeometry object which must be a kind of
  462. /// AcConstrainedCircle or AcConstrainedEllipse.
  463. /// </param>
  464. /// <param name="type">
  465. /// Input AcRadiusDiameterConstraint::RadiusDiameterConstrType indicating the type of constraint to be created.
  466. /// </param>
  467. /// <param name="valueDependencyId">
  468. /// Input object id of the value dependency object.
  469. /// </param>
  470. /// <param name="ppNewRadDiaConstraint">
  471. /// Output pointer to AcRadiusDiameterConstraint* pointing the newly created AcRadiusDiameterConstraint object.
  472. /// Default value is NULL.
  473. /// </param>
  474. /// <returns>Returns Acad::eOk if successful.</returns>
  475. ///
  476. Acad::ErrorStatus addRadiusDiameterConstraint(AcConstrainedGeometry* pConsGeom,
  477. AcRadiusDiameterConstraint::RadiusDiameterConstrType type,
  478. AcDbObjectId valueDependencyId,
  479. AcDbObjectId dimDependencyId, // May be null
  480. AcRadiusDiameterConstraint** ppNewRadDiaConstraint = NULL);
  481. /// <summary>
  482. /// Delete an existing AcGeomConstraint object which is internally held.
  483. /// </summary>
  484. /// <param name="pGeomConst">
  485. /// Input AcGeomConstraint indicating the constraint to be deleted.
  486. /// If pGeomConst is owned by a composite constraint, Acad::eInvalidInput is returned.
  487. /// </param>
  488. /// <returns>Returns Acad::eOk if successful.</returns>
  489. ///
  490. Acad::ErrorStatus deleteConstraint(AcGeomConstraint* pGeomConst);
  491. /// <summary>
  492. /// Get all AcGeomConstraint objects in this constraint group,
  493. /// including topological and dimensional constraints
  494. /// </summary>
  495. /// <param name="apConstraints">
  496. /// Output AcArray of the AcGeomConstraint objects.
  497. /// </param>
  498. /// <returns>Returns Acad::eOk if successful.</returns>
  499. ///
  500. Acad::ErrorStatus getConstraints(AcArray<AcGeomConstraint*>& apConstraints) const;
  501. /// <summary>
  502. /// define constraints that can be added to an under-constrained model.
  503. /// </summary>
  504. /// <param name="aPaths">
  505. /// List of subentites which are to be constrained automatically.
  506. /// </param>
  507. /// <param name="tol">
  508. /// Reference to AcGeTol to define distance tolerance as well as angle tolerance.
  509. /// AcGeTol::equalPoint() defines distance tolerance and AcGeTol::equalVector()
  510. /// defines angle tolerance. Angle tolerance is in radians of angle.
  511. /// </param>
  512. /// <param name="pCallback">
  513. /// Pointer to autoconstraint evaluation callback. This callback will implement constraint
  514. /// priority and priority override.
  515. /// </param>
  516. /// <returns>Returns Acad::eOk if successful.</returns>
  517. ///
  518. Acad::ErrorStatus autoConstrain(const AcDbFullSubentPathArray& aPaths,
  519. const AcGeTol& tol,
  520. AcAutoConstrainEvaluationCallback* pCallback);
  521. /// <summary>
  522. /// Get all AcDbAssocGeomDependency objects which are connected by constraints.
  523. /// </summary>
  524. /// <param name="srcGeomDependencyIds">
  525. /// Input AcDbObjectIdArray indicating the source AcDbAssocGeomDependency objects.
  526. /// </param>
  527. /// <param name="allConnectedGeomDependencyIds">
  528. /// Output AcDbObjectIdArray indicating the all the connected AcDbAssocGeomDependency objects.
  529. /// It contains all the source AcDbAssocGeomDependency objects.
  530. /// </param>
  531. /// <returns>Returns Acad::eOk if successful.</returns>
  532. ///
  533. Acad::ErrorStatus getAllConnectedGeomDependencies(const AcDbObjectIdArray& srcGeomDependencyIds,
  534. AcDbObjectIdArray& allConnectedGeomDependencyIds) const;
  535. /// <summary>
  536. /// Get pointer to AcConstraintGroupNode object.
  537. /// </summary>
  538. /// <param name="nodeId">
  539. /// Input id of AcGraphNode.
  540. /// </param>
  541. /// <returns>Returns pointer to AcConstraintGroupNode if successful, otherwise NULL</returns>
  542. ///
  543. AcConstraintGroupNode* getGroupNodePtr(const AcGraphNode::Id nodeId) const;
  544. /// <summary>
  545. /// Regenerate the internal dimension system.
  546. /// For internal use only.
  547. /// </summary>
  548. /// <returns>Returns void</returns>
  549. ///
  550. void regenDimensionSystem();
  551. /// <summary>
  552. /// Called by the client code to inform the constraint group that dependent
  553. /// entity for <paramref name="pGeomDependency"/> has been mirrored. The
  554. /// constraint group then mirrors the implicit points for the constrained
  555. /// curve for the given geom dependency. For the majority of constrained curves
  556. /// it is just a no-op, but for some curves (such as for AcConstrainedArc)
  557. /// the implicit points needs to be actually updated.
  558. /// </summary>
  559. /// <param name="pGeomDependency">Pointer to AcDbAssocGeomDependency for which
  560. /// implicit point needs to be updated for mirror action. </param>
  561. /// <returns> Acad::ErrorStatus. </returns>
  562. ///
  563. Acad::ErrorStatus geometryMirrored(AcDbAssocGeomDependency* pGeomDependency);
  564. /// <summary>
  565. /// See the explanation of AcDbAssoc2dConstraintCallback. Multiple global callbacks
  566. /// can be registered and they apply to all AcDbAssoc2dConstraintGroup.
  567. /// </summary>
  568. /// <param name="pCallback"> The callback to be registered. </param>
  569. ///
  570. static void addGlobalCallback(class AcDbAssoc2dConstraintCallback* pCallback);
  571. /// <summary>
  572. /// See the explanation of AcDbAssoc2dConstraintCallback. Multiple global callbacks
  573. /// can be registered and they apply to all AcDbAssoc2dConstraintGroup.
  574. /// </summary>
  575. /// <param name="pCallback"> The callback to be unregistered. </param>
  576. ///
  577. static void removeGlobalCallback(class AcDbAssoc2dConstraintCallback* pCallback);
  578. /// <summary>
  579. /// Returns a callback that is the collection of all callbacks registered by
  580. /// client code. This function is meant mostly for private use and there should
  581. /// not be much need for the client code to use it. Anyway, the client code
  582. /// must never delete or unregister the returned callback, or do anything with
  583. /// it except for calling its methods.
  584. /// </summary>
  585. /// <returns>
  586. /// The global AcDbAssocVariable(Multi)Callback that keeps all the callbacks
  587. /// registered by the client code. The returned pointer is never null.
  588. /// </returns>
  589. ///
  590. static class AcDbAssoc2dConstraintCallback* globalCallback();
  591. }; // class AcDbAssoc2dConstraintGroup
  592. /// <summary>
  593. /// Client code can register callback(s) derived from AcDbAssoc2dConstraintCallback
  594. /// that are then called when some events happen with AcDbAssoc2dConstraintGroup.
  595. /// </summary>
  596. ///
  597. class AcDbAssoc2dConstraintCallback
  598. {
  599. public:
  600. /// <summary>Default constructor. </summary>
  601. ///
  602. AcDbAssoc2dConstraintCallback() {}
  603. /// <summary>Destructor. </summary>
  604. ///
  605. virtual ~AcDbAssoc2dConstraintCallback() {}
  606. /// <summary>
  607. /// Allows client code to veto erasing a dimension constraint when a
  608. /// dimension constraint is not satisfied and being erased during relax
  609. /// evaluation of 2d constraint group. If this method returns true then this
  610. /// dimension constraint is converted to a reference dimension, client needs
  611. /// to update variable value with it's measured value.
  612. /// </summary>
  613. /// <param name="pConstraint"> The dimension constraint that is to be
  614. /// erased. </param>
  615. /// <returns>
  616. /// true == client code allows the constraint to be converted to reference
  617. /// or driven constraint. false == client code allows the constraint to be
  618. /// erased.
  619. /// </returns>
  620. ///
  621. virtual bool canBeRelaxed(const class AcExplicitConstraint* pConstraint)
  622. {
  623. UNREFERENCED_PARAMETER(pConstraint);
  624. return false;
  625. }
  626. /// <summary>
  627. /// This function will be called when a constraint is
  628. /// deactivated/reactivated. This notification takes place when
  629. /// AcExplicitConstraint::deactivate() or
  630. /// AcExplicitConstraint::reactivate() is invoked.
  631. /// </summary>
  632. /// <param name="bDeactivated"> indicated whether to deactivate or
  633. /// reactivate the constraint </param>
  634. /// <param name="pConstraint"> The constraint that is to be
  635. /// activated/deactivated. </param>
  636. ///
  637. virtual void constraintDeactivated(const AcExplicitConstraint *pConstraint,
  638. bool bDeactivated = true) {
  639. UNREFERENCED_PARAMETER(pConstraint);
  640. UNREFERENCED_PARAMETER(bDeactivated);
  641. }
  642. };
  643. /// <summary>
  644. /// Client needs to implement this callback to provide constraint priorities
  645. /// and priority override for autconstraint evaluation.
  646. /// </summary>
  647. ///
  648. class ACDB_PORT AcAutoConstrainEvaluationCallback
  649. {
  650. friend class AcDbImpAssoc2dConstraintGroup;
  651. friend class AcAutoConstraintEvalManager;
  652. public:
  653. virtual ~AcAutoConstrainEvaluationCallback() { }
  654. /// <summary>
  655. /// This function will be called when system finds a possible constraint between given set of
  656. /// constrained geometries. This function expects to get an override to increase, decrease or
  657. /// maintain the priority for the given constraint condition.
  658. /// </summary>
  659. /// <param name="type">
  660. /// Geometric constraint type that is possible between given set of constrained geometry.
  661. /// </param>
  662. /// <param name="geometries">
  663. /// List of constrained geometry, which are potential candidate for provided constraint type.
  664. /// User may
  665. /// </param>
  666. /// <param name="priority">
  667. /// Priority for the given constraint. Application may modify it by increasing or decreasing
  668. /// the priority, a negative value means constraint should not be applied between the given
  669. /// geometries. Higher value of priority means this contraint will be given preference over
  670. /// other possible constraint and will be applied earlier.</param>
  671. ///
  672. virtual void getConstraintPriorityOverride(AcGeomConstraint::GeomConstraintType type,
  673. const AcArray<const AcConstrainedGeometry*>& geometries, int& priority) const
  674. {
  675. UNREFERENCED_PARAMETER(type);
  676. UNREFERENCED_PARAMETER(geometries);
  677. UNREFERENCED_PARAMETER(priority);
  678. return; //No override.
  679. }
  680. /// <summary>
  681. /// define order of the constraints type in which it can be used for autoConstrain.
  682. /// </summary>
  683. /// <param name="constraintList">
  684. /// List of constraint types to be considered for autoConstrain in decending order
  685. /// of priority. Constraint type not present in the list will not be considered
  686. /// for autoconstraint.
  687. /// </param>
  688. ///
  689. virtual void getAutoConstrainPriority(AcArray<AcGeomConstraint::GeomConstraintType>& constraintList) const
  690. {
  691. constraintList.setLogicalLength(0);
  692. for(int type = (int)AcGeomConstraint::kHorizontal;
  693. type < (int)AcGeomConstraint::kEqualRadius; ++type)
  694. {
  695. constraintList.append((AcGeomConstraint::GeomConstraintType)type);
  696. }
  697. }
  698. /// <summary>
  699. /// Checks if evaluation is canecelled by caller. If this function returns
  700. /// true the autoconstraint evaluation from DCM will be cancelled.
  701. /// </summary>
  702. /// <returns>
  703. /// True to cancel the evaluation else False.
  704. /// </returns>
  705. ///
  706. virtual bool isEvaluationCancelled() { return false; }
  707. /// <summary>
  708. /// Returns list of constraints found by autoconstraint evaluation.
  709. /// </summary>
  710. /// <param name="pConstraints"> Pointer to array of constraints, to return
  711. /// list of constraints found by autoconstraint evaluation. This parameter
  712. /// can be NULL if caller doesn't want list of constraints.</param>
  713. /// <returns>
  714. /// Number of constraints found by autoconstraint evaluation.
  715. /// </returns>
  716. ///
  717. int getTotalConstraints(AcArray<AcGeomConstraint*>* pConstraints) const;
  718. private:
  719. /// <summary>Returns mask for DCM autoconstrain evaluation. This function is
  720. /// is for internal use only.</summary>
  721. /// <returns>mask for DCM autoconstrain evaluation.</returns>
  722. int getAutoConstraintMask() const;
  723. /// <summary>Validates autoconstraint data. This function is
  724. /// is for internal use only.</summary>
  725. /// <param name="pData">Data for validation.</param>
  726. void validate(void* pData);
  727. /// <summarry> Checks if the constraint is of the given constraint type.
  728. /// </summary>
  729. /// <param name="type">GeomConstraint type for check.</param>
  730. /// <param name="pConstraint">Pointer to GeomConstraint which needs to be
  731. /// checked for given <paramref name="type"/>.</param>
  732. /// <returns> true, if valid constraint type, else false.<returns>
  733. bool isValidConstraintType(AcGeomConstraint::GeomConstraintType type,
  734. const AcGeomConstraint* pConstraint) const;
  735. /// <summary>This method is called by AcAutoConstraintEvalManager to notify
  736. /// the callback for constraint added event.</summary>
  737. /// <param name="pNewCons">Pointer to the constraint that has been added.</param>
  738. void constraintAdded(AcGeomConstraint* pNewCons);
  739. private:
  740. AcArray<AcGeomConstraint*> mConstraints;
  741. };
  742. #pragma pack (pop)