AcDbAssocGeomDependency.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. // CREATED BY: Jiri Kripac April 2007
  12. //
  13. // DESCRIPTION:
  14. //
  15. // AcDbAssocGeomDependency class.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #pragma once
  19. #include "AcDbAssocDependency.h"
  20. #include "AcDbAssocPersSubentId.h"
  21. #pragma pack (push, 8)
  22. /// <summary> <para>
  23. /// This class represents a dependency on a subentity (face/edge/vertex) of
  24. /// a geometric entity. It keeps an AcDbAssocPersSubentId that persistently
  25. /// identitfies the subentity and provides new protocol to set the referenced
  26. /// subentity and get/set the subentity geometry.
  27. /// </para> <para>
  28. /// This class may also optionally cache the geometry of the referenced
  29. /// subentity that then allows to filter-out irrelevant change notifications
  30. /// that do no affect the referenced subentity. The caching is controlled by
  31. /// the setCachingSubentityGeometry() method.
  32. /// </para> <para>
  33. /// By default the dependency does not cache the geoemetry of the referenced
  34. /// subentity. The isRelevantChange() predicate uses the base class implementation
  35. /// that calls AcDbAssocAction::isRelevantDependencyChange() of the owning action,
  36. /// letting the action that owns the dependency to decide, such as by caching the
  37. /// geometry of the referenced subentity and comparing it with the current
  38. /// subentity geometry.
  39. /// </para> <para>
  40. /// When the dependency caches the geometry of the referenced subentity, the
  41. /// isRelevantChange() predicate returns false if the geometry of the
  42. /// referenced subentity is the same as the cached geometry. This is how the
  43. /// dependency can filer-out irrelevant change notifications when the referenced
  44. /// subentity geometry does not really change, when something else changes.
  45. /// </para> </summary>
  46. ///
  47. class ACDB_PORT AcDbAssocGeomDependency : public AcDbAssocDependency
  48. {
  49. public:
  50. ACRX_DECLARE_MEMBERS(AcDbAssocGeomDependency);
  51. /// <summary> Default constructor. </summary>
  52. /// <param name="createImpObject"> See AcDbAssocCreateImpObject explanation. </param>
  53. ///
  54. explicit AcDbAssocGeomDependency(AcDbAssocCreateImpObject createImpObject = kAcDbAssocCreateImpObject);
  55. /// <summary>
  56. /// Returns pointer to the internally held AcDbAssocPersSubentId that
  57. /// identifies a subentity of the dependent-on entity. The returned pointer
  58. /// points to internal data owned by this class. The caller must not change
  59. /// or hold-on to this returned AcDbAssocPersSubentId, only call read-only
  60. /// methods on it. The retuned pointer may be NULL.
  61. /// </summary>
  62. /// <returns> Pointer to the internal AcDbAssocPersSubentId or NULL. </returns>
  63. ///
  64. const AcDbAssocPersSubentId* persistentSubentId() const;
  65. /// <summary>
  66. /// Returns the transient AcDbSubentIds of the dependent-on entity
  67. /// corresponding to the internally held AcDbAssocPersSubentId. Notice that
  68. /// one AcDbAssocPersSubentId may generally correspond to none, one, or
  69. /// more than one subentity, though in typical cases it will be exactly one
  70. /// subentity.
  71. /// </summary>
  72. /// <param name="transientSubentIds">
  73. /// The returned transient AcDbSubentIds corresponding to the internally
  74. /// held AcDbAssocPersSubentId.
  75. /// </param>
  76. /// <returns> Acad::ErrorStatus. </returns>
  77. ///
  78. Acad::ErrorStatus getTransientSubentIds(AcArray<AcDbSubentId>& transientSubentIds) const;
  79. /// <summary>
  80. /// Sets the internally held AcDbAssocPersSubentId to persistently identify
  81. /// the given subentity. The subentity must be on the entity the dependency
  82. /// currently depends on.
  83. /// </summary>
  84. /// <param name="transientSubentId">
  85. /// The subentity to be identified by the internally held AcDbAssocPersSubentId.
  86. /// </param>
  87. /// <returns> Acad::ErrorStatus. </returns>
  88. ///
  89. Acad::ErrorStatus setSubentity(const AcDbSubentId& transientSubentId);
  90. /// <summary>
  91. /// Returns the type of the persistently referenced subentity or
  92. /// kNullSubentType if no subentity is referenced.
  93. /// </summary>
  94. /// <returns> The referenced subentity type. </returns>
  95. ///
  96. AcDb::SubentType subentType() const;
  97. /// <summary>
  98. /// Returns the number of transient AcDbSubentIds corresponding to the
  99. /// internally held AcDbAssocPersSubentId. In typical cases it is just
  100. /// a single subentity but in general case it may be none, one or any number
  101. /// of subentities.
  102. /// </summary>
  103. /// <returns> The transient subentity count (usually 1). </returns>
  104. ///
  105. int transientSubentCount() const;
  106. /// <summary>
  107. /// Returns true iff the dependency keeps cache of the referenced subentity
  108. /// geometry (even if the cache may currently be empty). The initial state
  109. /// is false, i.e. the dependency does not keep the subentity geometry cache.
  110. /// </summary>
  111. /// <returns>
  112. /// Returns true iff the dependency keeps cache of the referenced subentity
  113. /// geometry.
  114. /// </returns>
  115. ///
  116. bool isCachingSubentityGeometry() const;
  117. /// <summary>
  118. /// Sets whether the dependency is to keep the cache of the referenced
  119. /// subentity geometry. The initial state is false, i.e. the dependency
  120. /// does not keep the subentity geometry cache.
  121. /// </summary>
  122. /// <param name="yesNo"> Controls whether the dependency should keep the
  123. /// cache of the referenced subentity geometry.
  124. /// </param>
  125. ///
  126. void setCachingSubentityGeometry(bool yesNo);
  127. /// <summary>
  128. /// Gets coordinates of vertex subentities corresponding to the internally
  129. /// held AcDbAssocPersSubentId, which must identify a vertex subentity type.
  130. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  131. /// number of subentities, though in most cases it will be just one subentity.
  132. /// </summary>
  133. /// <param name="vertexPositions"> Returned coordinates of vertex subentities. </param>
  134. /// <returns> Acad::ErrorStatus. </returns>
  135. ///
  136. Acad::ErrorStatus getVertexSubentityGeometry(AcGePoint3dArray& vertexPositions) const;
  137. /// <summary>
  138. /// Gets curves of edge subentities corresponding to the internally
  139. /// held AcDbAssocPersSubentId, which must identify an edge subentity type.
  140. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  141. /// number of subentities, though in most cases it will be just one subentity.
  142. /// The caller will become the owner of the returned curves and is
  143. /// responsible for freeing them after thay are not needed.
  144. /// </summary>
  145. /// <param name="edegeCurves">
  146. /// Returned curves of edge subentities (the caller becomes their owner).
  147. /// </param>
  148. /// <returns> Acad::ErrorStatus. </returns>
  149. ///
  150. Acad::ErrorStatus getEdgeSubentityGeometry(AcArray<AcGeCurve3d*>& edgeCurves) const;
  151. /// <summary>
  152. /// Gets surfaces of face subentities corresponding to the internally
  153. /// held AcDbAssocPersSubentId, which must identify a face subentity type.
  154. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  155. /// number of subentities, though in most cases it will be just one subentity.
  156. /// The caller will become the owner of the returned surfaces and is
  157. /// responsible for freeing them after thay are not needed.
  158. /// </summary>
  159. /// <param name="faceSurfaces">
  160. /// Returned surfaces of face subentities (the caller becomes their owner).
  161. /// </param>
  162. /// <returns> Acad::ErrorStatus. </returns>
  163. ///
  164. Acad::ErrorStatus getFaceSubentityGeometry(AcArray<AcGeSurface*>& faceSurfaces) const;
  165. /// <summary>
  166. /// Sets coordinates of vertex subentities corresponding to the internally
  167. /// held AcDbAssocPersSubentId, which must identify a vertex subentity type.
  168. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  169. /// number of subentities, though in most cases it will be just one subentity.
  170. /// The length of the input array must be the same as the number of subentities
  171. /// corresponding to the internally held AcDbAssocPersSubentId.
  172. /// </summary>
  173. /// <param name="newVertexPositions"> New coordinates of vertex subentities. </param>
  174. /// <returns> Acad::ErrorStatus. </returns>
  175. ///
  176. Acad::ErrorStatus setVertexSubentityGeometry(const AcGePoint3dArray& newVertexPositions);
  177. /// <summary>
  178. /// Sets curves of edge subentities corresponding to the internally
  179. /// held AcDbAssocPersSubentId, which must identify an edge subentity type.
  180. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  181. /// number of subentities, though in most cases it will be just one subentity.
  182. /// The length of the input array must be the same as the number of subentities
  183. /// corresponding to the internally held AcDbAssocPersSubentId.
  184. /// The pased-in curves are not reused but copied, they do not become owned
  185. /// by the dependency.
  186. /// </summary>
  187. /// <param name="newEdgeCurves">
  188. /// New curves of edge subentities (copied, not reused).
  189. /// </param>
  190. /// <returns> Acad::ErrorStatus. </returns>
  191. ///
  192. Acad::ErrorStatus setEdgeSubentityGeometry(const AcArray<const AcGeCurve3d*>& newEdgeCurves);
  193. /// <summary>
  194. /// Sets surfaces of face subentities corresponding to the internally
  195. /// held AcDbAssocPersSubentId, which must identify a surface subentity type.
  196. /// Notice that one AcDbAssocPersSubentId may generally correspond to any
  197. /// number of subentities, though in most cases it will be just one subentity.
  198. /// The length of the input array must be the same as the number of subentities
  199. /// corresponding to the internally held AcDbAssocPersSubentId.
  200. /// The pased-in surfraces are not reused but copied, they do not become
  201. /// owned by the dependency.
  202. /// </summary>
  203. /// <param name="newFaceSurfaces">
  204. /// New surfaces of face subentities (copied, not reused).
  205. /// </param>
  206. /// <returns> Acad::ErrorStatus. </returns>
  207. ///
  208. Acad::ErrorStatus setFaceSubentityGeometry(const AcArray<const AcGeSurface*>& newFaceSurfaces);
  209. /// <summary>
  210. /// Called by the client code to inform the AcDbAssocGeomDependency that
  211. /// the object, whose subentity it depends on, has been mirrored. The
  212. /// dependency then mirrors the AcDbAssocPersSubentId it holds. For the
  213. /// majority of dependent-on entity types it is just a no-op, but for some
  214. /// entity types (such as for AcDbArc) the AcDbAssocPersSubentId needs to
  215. /// be actually updated.
  216. /// </summary>
  217. /// <returns> Acad::ErrorStatus. </returns>
  218. ///
  219. Acad::ErrorStatus dependentOnObjectMirrored();
  220. /// <summary>
  221. /// Returns true iff the dependency keeps cache of the referenced subentity
  222. /// geometry and the cache is not empty.
  223. /// </summary>
  224. /// <returns>
  225. /// Returns true iff the dependency holds the cached geoemetry of the
  226. /// referenced subentity.
  227. /// </returns>
  228. ///
  229. /// bool hasCachedValue() const;
  230. /// <summary>
  231. /// If caching the subentity geometry, evaluates the subentity geometry
  232. /// cache from the current geometry of the referenced subentity and sets
  233. /// the status to kIsUpToDateAssocStatus. Otherwise the base class
  234. /// implementation of this method forwards the call to the owning action's
  235. /// AcDbAssocAction::evaluateDependency() method.
  236. /// </summary>
  237. ///
  238. /// void evaluate();
  239. /// <summary>
  240. /// If caching the subentity geometry, returns true iff the geometry of the
  241. /// referenced subentity is different from the cached subentity geometry.
  242. /// Otherwise the base class implementation of this method forwards the call
  243. /// to the owning action's AcDbAssocAction::isRelevantDependencyChange()
  244. /// predicate.
  245. /// </summary>
  246. /// <returns>
  247. /// <para> true = The subentity geometry changed. </para>
  248. /// <para> false = The subentity geometry didn't change. </para>
  249. /// </returns>
  250. ///
  251. /// bool isRelevantChange() const;
  252. /// <summary>
  253. /// Returns true iff this dependency depends on exactly the same subentity
  254. /// of the same geometric entity as the other dependency.
  255. /// </summary>
  256. /// <param name="pOtherDependency"> The other AcDbAssocGeomDependency, open at least for read. </param>
  257. /// <returns>
  258. /// True iff both dependencies depend on exactly the same subentity of the same entity.
  259. /// </returns>
  260. ///
  261. /// bool isDependentOnTheSameThingAs(const AcDbAssocDependency* pOtherDependency) const;
  262. /// <summary>
  263. /// Gets all AcDbAssocGeomDependencies on the old object that reference
  264. /// the given oldSubentId of that object and redirects them to reference
  265. /// the newSubentId of the new object.
  266. /// </summary>
  267. /// <param name="oldObjectId">
  268. /// The AcDbObject whose AcDbAssocGeomDependencies are to be redirected.
  269. /// It will be opened for write.
  270. /// </param>
  271. /// <param name="oldSubentId">
  272. /// The AcDbSubentId of the AcDbAssocGeomDependencies that is to be
  273. /// redirected.
  274. /// </param>
  275. /// <param name="newObjectId">
  276. /// The object to redirect the dependencies to. It will be opened for write.
  277. /// </param>
  278. /// <param name="newSubentId"> The new AcDbSubentId in the new object. </param>
  279. /// <returns> Acad::ErrorStatus. </returns>
  280. ///
  281. static Acad::ErrorStatus redirectToAnotherSubentity(const AcDbObjectId& oldObjectId,
  282. const AcDbSubentId& oldSubentId,
  283. const AcDbObjectId& newObjectId,
  284. const AcDbSubentId& newSubentId);
  285. }; // class AcDbAssocGeomDependency
  286. #pragma pack (pop)