db3dProfile.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. //
  13. // DESCRIPTION:
  14. //
  15. // The AcDb3dProfile class is used to encapsulate profile information for
  16. // certain commands such as EXTRUDE, REVOLVE, SWEEP, and LOFT.
  17. #pragma once
  18. #ifndef DB3DPROFILE_H
  19. #define DB3DPROFILE_H
  20. #include "dbsurf.h"
  21. #include "AcDbGeomRef.h"
  22. class AcDb3dProfileData;
  23. #pragma pack(push, 8)
  24. /// <summary> <para>
  25. /// This class is used to represent a 3d profile that can be used as input to
  26. /// functions such as createExtrudedSurface(), createRevolvedSurface(), and
  27. /// createSweptSurface(). An object of this class can represent an entity
  28. /// such as a curve or a region, or it can represent an edge or a set of edges
  29. /// that form a connected chain.
  30. /// </para> </summary>
  31. ///
  32. class ACDB_PORT AcDb3dProfile : public AcRxObject
  33. {
  34. public:
  35. ACRX_DECLARE_MEMBERS(AcDb3dProfile);
  36. /// <summary>
  37. /// Default constructor.
  38. /// </summary>
  39. AcDb3dProfile ();
  40. /// <summary>
  41. /// Constructor for a profile that is an entity such as a curve or region.
  42. /// </summary>
  43. /// <param name="pEntity">
  44. /// Pointer to an AcDbEntity that is to be used as a profile to create
  45. /// a surface such as an extrusion or loft.
  46. /// </param>
  47. AcDb3dProfile ( AcDbEntity *pEntity );
  48. /// <summary>
  49. /// Constructor for a profile that is a face. The profile will consist of
  50. /// the outer edges of the face.
  51. /// </summary>
  52. /// <param name="faceSubentPath">
  53. /// Subent path of the face.
  54. /// </param>
  55. AcDb3dProfile ( const AcDbFullSubentPath& faceSubentPath );
  56. /// <summary>
  57. /// Constructor for a profile that is a path.
  58. /// </summary>
  59. /// <param name="pathRef">
  60. /// reference to the path
  61. /// </param>
  62. AcDb3dProfile ( const AcDbPathRef & pathRef);
  63. /// <summary>
  64. /// Constructor for a profile that is a vertex
  65. /// </summary>
  66. /// <param name="vertexRef">
  67. /// reference to the vertex
  68. /// </param>
  69. AcDb3dProfile ( const AcDbVertexRef & vertexRef);
  70. /// <summary>
  71. /// Copy constructor.
  72. /// </summary>
  73. /// <param name="src">
  74. /// Source object to be copied.
  75. /// </param>
  76. AcDb3dProfile ( const AcDb3dProfile& src );
  77. /// <summary>
  78. /// Destructor.
  79. /// </summary>
  80. virtual ~AcDb3dProfile();
  81. /// <summary>
  82. /// Copies the contents of input object into this object.
  83. /// </summary>
  84. /// <param name="src">
  85. /// Source object to be copied.
  86. /// </param>
  87. /// <returns>
  88. /// eOk if successful.
  89. /// </returns>
  90. virtual Acad::ErrorStatus copyFrom ( const AcRxObject *src );
  91. /// <summary>
  92. /// Returns the profile entity. If the profile is for an edge or set of
  93. /// edges then the returned entity will be an AcDbCurve of the edge or edges.
  94. /// The caller should not delete this pointer or post it to the database.
  95. /// </summary>
  96. /// <returns>
  97. /// Profile entity. The caller should not delete this pointer.
  98. /// </returns>
  99. AcDbEntity* entity () const;
  100. /// <summary>
  101. /// Returns the path reference of the edge if the profile is an edge or
  102. /// set of edges. If the profile is not an edge or set of edges, pathRef will be
  103. /// empty and eInvalidInput will be returned
  104. /// </summary>
  105. /// <param name="pathRef">
  106. /// path reference of the edge(s)
  107. /// </param>
  108. /// <returns>
  109. /// Acad::ErrorStatus
  110. /// </returns>
  111. Acad::ErrorStatus getPathRef( AcDbPathRef &pathRef ) const;
  112. /// <summary>
  113. /// Returns the vertex reference of the vertex if the profile is a vertex.
  114. /// If the profile is not an edge or set of edges, vertexRef will be
  115. /// empty and eInvalidInput will be returned
  116. /// </summary>
  117. /// <param name="vertexRef">
  118. /// vertex reference
  119. /// </param>
  120. /// <returns>
  121. /// Acad::ErrorStatus
  122. /// </returns>
  123. Acad::ErrorStatus getVertexRef( AcDbVertexRef &vertexRef ) const;
  124. /// <summary>
  125. /// Converts profile into new profiles that are of a type that can be used for
  126. /// extrude, revolve, sweep, or loft operations. The converted profiles are returned in
  127. /// the output array. If this profile is of type AcDbTrace, AcDbSolid, or AcDbFace then
  128. /// the converted profile will be for a region. If this profile is of type
  129. /// AcDb3dPolyline and the profile is linear or whose 'Fit' property is quadratic or
  130. /// cubic then the converted profile will be a line or a spline.
  131. /// </summary>
  132. /// <param name="explodeMultiFaceRegions">
  133. /// If this profile is of type AcDbSurface or AcDbRegion and has more than one face,
  134. /// then we explode to get multiple surface or region profiles that each have only
  135. /// one face.
  136. /// </param>
  137. /// <param name="convertSurfaceToEdges">
  138. /// If this profile is a face or is of type AcDbSurface, AcDbRegion, AcDbTrace,
  139. /// AcDbSolid, or AcDbFace then we convert to an edge profile that is defined by
  140. /// the surface or region edges.
  141. /// </param>
  142. /// <param name="nonPlanarOnly">
  143. /// This parameter is only relevant when convertSurfaceToEdges is set to true.
  144. /// If this parameter is true then only non-planar surfaces will be converted to
  145. /// edge profiles. Regions and planar surfaces will not be converted.
  146. /// </param>
  147. /// <param name="outerLoopOnly">
  148. /// This parameter is only relevant when convertSurfaceToEdges is set to true.
  149. /// If this parameter is true then only the outer loop of the surface or region
  150. /// will be converted to an edge profile.
  151. /// </param>
  152. /// <param name="convertedProfileArr">
  153. /// Output list of converted profiles. The caller is responsible for
  154. /// deleting the objects in this list.
  155. /// </param>
  156. /// <returns>
  157. /// eOk if successful. Even when this function returns eOk, it is possible for
  158. /// the output list to be empty depending on the profile type and the values of
  159. /// the other parameters.
  160. /// </returns>
  161. Acad::ErrorStatus convertProfile ( bool explodeMultiFaceRegions, bool convertSurfaceToEdges,
  162. bool nonPlanarOnly, bool outerLoopOnly,
  163. AcArray<AcDb3dProfile*>& convertedProfileArr ) const;
  164. static AcDb3dProfile* convertProfile(const AcArray<AcDbPathRef>&);
  165. /// <summary>
  166. /// Set the profile to a path.
  167. /// </summary>
  168. /// <param name="pathRef">
  169. /// reference to the path
  170. /// </param>
  171. /// <returns>
  172. /// eOk if successful.
  173. /// </returns>
  174. Acad::ErrorStatus set ( const AcDbPathRef &pathRef );
  175. /// <summary>
  176. /// Set the profile to a vertex.
  177. /// </summary>
  178. /// <param name="vertexRef">
  179. /// reference to the vertex
  180. /// </param>
  181. /// <returns>
  182. /// eOk if successful.
  183. /// </returns>
  184. Acad::ErrorStatus set ( const AcDbVertexRef &vertexRef );
  185. /// <summary>
  186. /// Set the profile to an entity such as a curve or region.
  187. /// </summary>
  188. /// <param name="pEntity">
  189. /// Pointer to an AcDbEntity that is to be used as a profile to create
  190. /// a surface such as an extrusion or loft.
  191. /// </param>
  192. /// <returns>
  193. /// eOk if successful.
  194. /// </returns>
  195. Acad::ErrorStatus set ( AcDbEntity *pEntity );
  196. /// <summary>
  197. /// Return whether the profile forms a closed loop.
  198. /// </summary>
  199. /// <returns>
  200. /// True if profile is closed, false otherwise.
  201. /// </returns>
  202. bool isClosed () const;
  203. /// <summary>
  204. /// Return whether the profile is planar.
  205. /// </summary>
  206. /// <returns>
  207. /// True if profile is planar, false otherwise.
  208. /// </returns>
  209. bool isPlanar () const;
  210. /// <summary>
  211. /// Return whether the profile is an edge or face.
  212. /// </summary>
  213. /// <returns>
  214. /// True if profile is an edge or face, false otherwise.
  215. /// </returns>
  216. bool isSubent () const;
  217. /// <summary>
  218. /// Return whether the profile is a face.
  219. /// </summary>
  220. /// <returns>
  221. /// True if profile is a face, false otherwise.
  222. /// </returns>
  223. bool isFace () const;
  224. /// <summary>
  225. /// Return whether the profile is an edge.
  226. /// </summary>
  227. /// <returns>
  228. /// True if profile is an edge, false otherwise.
  229. /// </returns>
  230. bool isEdge () const;
  231. /// <summary>
  232. /// Return whether the profile is valid and may be used to
  233. /// create a surface.
  234. /// </summary>
  235. /// <returns>
  236. /// True if profile is a valid entity, edge, or face.
  237. /// </returns>
  238. bool isValid () const;
  239. /// <summary>
  240. /// Merge connected sets of profiles into one or more profiles.
  241. /// </summary>
  242. /// <param name="profileArr">
  243. /// Input array of profiles that are to be merged.
  244. /// </param>
  245. /// <param name="mergeEdges">
  246. /// If this parameter is false then any edge profiles in the input array will
  247. /// not be merged and will be copied directly to the ouput array.
  248. /// </param>
  249. /// <param name="mergeCurves">
  250. /// If this parameter is false then any curve profiles in the input array will
  251. /// not be merged and will be copied directly to the ouput array.
  252. /// </param>
  253. /// <param name="mergedProfileArr">
  254. /// Output array of merged profiles. The caller is responsible for deleting all
  255. /// objects that are returned in this array.
  256. /// </param>
  257. /// <returns>
  258. /// eOk if successful.
  259. /// </returns>
  260. static Acad::ErrorStatus mergeProfiles ( const AcArray<AcDb3dProfile*>& profileArr,
  261. bool mergeEdges, bool mergeCurves,
  262. AcArray<AcDb3dProfile*>& mergedProfileArr );
  263. /// <summary>
  264. /// Assignment operator.
  265. /// </summary>
  266. /// <param name="src">
  267. /// Source object to be copied.
  268. /// </param>
  269. /// <returns>
  270. /// Reference to this object.
  271. /// </returns>
  272. AcDb3dProfile& operator = ( const AcDb3dProfile& src );
  273. private:
  274. friend class AcDb3dProfileData;
  275. friend class AcDbLoftProfile;
  276. AcDb3dProfileData *mProfileData;
  277. };
  278. /// <summary> <para>
  279. /// This class is used to represent a profile that can be used as input to
  280. /// createLoftedSurface(). An object of this class can represent an entity
  281. /// such as a curve or a region, or it can represent an edge or a set of edges
  282. /// that form a connected chain. This class also maintains continuity data
  283. /// if the profile is for an edge or point and the profile is the first or
  284. /// last profile of the loft.
  285. /// </para> </summary>
  286. ///
  287. class ACDB_PORT AcDbLoftProfile : public AcDb3dProfile
  288. {
  289. public:
  290. ACRX_DECLARE_MEMBERS(AcDbLoftProfile);
  291. /// <summary>
  292. /// Default constructor.
  293. /// </summary>
  294. AcDbLoftProfile ();
  295. /// <summary>
  296. /// Constructor for a profile that is an entity such as a curve or region.
  297. /// </summary>
  298. /// <param name="pEntity">
  299. /// Pointer to an AcDbEntity that is to be used as a profile to create
  300. /// a surface such as an extrusion or loft.
  301. /// </param>
  302. AcDbLoftProfile ( AcDbEntity *pEntity );
  303. /// <summary>
  304. /// Constructor for a profile that is an edge or a sequence of connected
  305. /// edges.
  306. /// </summary>
  307. /// <param name="pathRef">
  308. /// Subent paths of the edges that make up the profile.
  309. /// </param>
  310. AcDbLoftProfile ( const AcDbPathRef & pathRef);
  311. /// <summary>
  312. /// Constructor for a profile that is a point.
  313. /// </summary>
  314. /// <param name="pnt">
  315. /// An AcGePoint3d that is to be used as a profile to create
  316. /// a surface such as an extrusion or loft.
  317. /// </param>
  318. AcDbLoftProfile ( const AcGePoint3d& pnt );
  319. /// <summary>
  320. /// Copy constructor.
  321. /// </summary>
  322. /// <param name="src">
  323. /// Source object to be copied.
  324. /// </param>
  325. AcDbLoftProfile ( const AcDbLoftProfile& src );
  326. /// <summary>
  327. /// Copies the contents of input object into this object.
  328. /// </summary>
  329. /// <param name="src">
  330. /// Source object to be copied.
  331. /// </param>
  332. /// <returns>
  333. /// eOk if successful.
  334. /// </returns>
  335. virtual Acad::ErrorStatus copyFrom ( const AcRxObject *src );
  336. /// <summary>
  337. /// Return the continuity for the profile: 0, 1, or 2, which
  338. /// corresponds to a continuity of G0, G1, or G2. By default, the
  339. /// continuity is 1 unless it has been explicitly set to another
  340. /// value.
  341. /// </summary>
  342. /// <returns>
  343. /// Continuity for the profile: 0, 1, or 2, which
  344. /// corresponds to a continuity of G0, G1, or G2.
  345. /// </returns>
  346. Adesk::Int16 continuity () const;
  347. /// <summary>
  348. /// Set the continuity for the profile.
  349. /// </summary>
  350. /// <param name="value">
  351. /// Must be 0, 1, or 2, which corresponds to a continuity of
  352. /// G0, G1, or G2.
  353. /// </param>
  354. void setContinuity ( Adesk::Int16 value );
  355. /// <summary>
  356. /// Return the magnitude of the takeoff vector if the continuity is
  357. /// 1 or 2. By default, this value is 0.5 unless it has been
  358. /// explicitly set to another value.
  359. /// </summary>
  360. /// <returns>
  361. /// Magnitude of the takeoff vector.
  362. /// </returns>
  363. double magnitude () const;
  364. /// <summary>
  365. /// Set the magnitude of the takeoff vector for the profile if
  366. /// the continuity is 1 or 2.
  367. /// </summary>
  368. /// <param name="value">
  369. /// Magnitude of takeoff vector.
  370. /// </param>
  371. void setMagnitude ( double value );
  372. /// <summary>
  373. /// Assignment operator.
  374. /// </summary>
  375. /// <param name="src">
  376. /// Source object to be copied.
  377. /// </param>
  378. /// <returns>
  379. /// Reference to this object.
  380. /// </returns>
  381. AcDbLoftProfile& operator = ( const AcDbLoftProfile& src );
  382. /// <summary>
  383. /// Assignment operator. Copies the entity and edge data from the
  384. /// input object, but does not change the continuity or magnitude.
  385. /// </summary>
  386. /// <param name="src">
  387. /// Source object to be copied.
  388. /// </param>
  389. /// <returns>
  390. /// Reference to this object.
  391. /// </returns>
  392. AcDbLoftProfile& operator = ( const AcDb3dProfile& src );
  393. };
  394. #pragma pack(pop)
  395. #endif // DB3DPROFILE_H