AcDbPointCloudDefEx.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. #pragma once
  12. #include "dbmain.h"
  13. static const TCHAR* kpPointCloudExDictionaryName = /*NOXLATE*/_T("ACAD_POINTCLOUD_EX_DICT");
  14. class PointCloudDefExImp;
  15. namespace Autodesk { namespace RealityStudio { namespace SDK { namespace Interface {
  16. class IRCData;
  17. }}}}
  18. //////////////////////////////////////////////////////////////////////////////
  19. /// <summary>
  20. /// The AcDbPointCloudDefEx object (or "point cloud extension definition object")
  21. /// controls the actual point cloud data associated with one or more
  22. /// AcDbPointCloudEx entities (or "point cloud extension entity"). These objects
  23. /// link the .rcp/.rcs file to the dwg file, similar to how Xrefs work.
  24. ///
  25. /// The relationship between the AcDbPointCloudDefEx and
  26. /// AcDbPointCloudEx classes is much like the relationship
  27. /// between an AutoCAD block definition object and a block reference entity.
  28. ///
  29. /// AcDbPointCloudDefEx objects are stored in a special AcDbDictionary named
  30. /// "ACAD_POINTCLOUD_EX_DICT". These objects are not AutoCAD entities, so they
  31. /// can't be displayed or selected by the end user.
  32. /// </summary>
  33. class ACDB_PORT AcDbPointCloudDefEx : public AcDbObject
  34. {
  35. public:
  36. /// <summary>
  37. /// This enumeration defines the current state of supported properties in
  38. /// the point cloud data.
  39. /// </summary>
  40. enum PropState
  41. {
  42. /// <summary>
  43. /// No scan in the point cloud has the property.
  44. /// </summary>
  45. kNone = -1,
  46. /// <summary>
  47. /// Some scans in the point cloud have the property, but some do not.
  48. /// </summary>
  49. kSome = 0,
  50. /// <summary>
  51. /// All scans in the point cloud have the property.
  52. /// </summary>
  53. kAll = 1
  54. };
  55. /// <summary>
  56. /// This enumeration defines the types of properties that a point cloud can have.
  57. /// </summary>
  58. enum Property
  59. {
  60. /// <summary> The Color property. </summary>
  61. kColor = 1,
  62. /// <summary> The Intensity property. </summary>
  63. kIntensity = 2,
  64. /// <summary> The Classification property. </summary>
  65. kClassification = 3,
  66. /// <summary> The Normal property. </summary>
  67. kNormal = 4,
  68. /// <summary> The Segmentation property. </summary>
  69. kSegmentation = 5,
  70. /// <summary> The Geo Graphic property. </summary>
  71. kGeoGraphic = 6
  72. };
  73. ACRX_DECLARE_MEMBERS(AcDbPointCloudDefEx);
  74. /// <summary>
  75. /// Default constructor
  76. /// </summary>
  77. AcDbPointCloudDefEx();
  78. /// <summary>
  79. /// Destructor
  80. /// </summary>
  81. virtual ~AcDbPointCloudDefEx();
  82. /// <summary>
  83. /// Returns the class version number that indicates which version of
  84. /// AcDbPointCloudEx this object represents. This is primarily used during
  85. /// filing operations to determine what data to read or write.
  86. /// </summary>
  87. static int classVersion();
  88. // create / get point cloud dictionary
  89. //
  90. /// <summary>
  91. /// This function creates a new point cloud extension dictionary.
  92. /// If the dictionary could not be created,
  93. /// then AcDbPointCloudDefEx::pointCloudExDictionary() will return 0.
  94. /// Otherwise, dictId is set by this function, and can be used as if the value had
  95. /// been returned by pointCloudExDictionary().
  96. /// If the dictionary already exists, this method will simply set dictId to the
  97. /// existing dictionary's ID.
  98. /// </summary>
  99. /// <param name="pDb">
  100. /// Input AutoCAD database in which to create the dictionary
  101. /// </param>
  102. /// <param name="dictId">
  103. /// Output parameter that will be set to the object ID of the newly created dictionary, or existing dictionary
  104. /// </param>
  105. /// <returns>
  106. /// Returns Acad::eOk if successful.
  107. /// Returns Acad::eAlreadyInDb if the dictionary "ACAD_POINTCLOUD_EX_DICT"
  108. /// already exists, and no new dictionary was created.
  109. /// Other values are returned if the dictionary could not be created or doesn't exist.
  110. /// </returns>
  111. static Acad::ErrorStatus createPointCloudExDictionary(AcDbDatabase* pDb, AcDbObjectId& dictId);
  112. /// <summary>
  113. /// Returns the object ID of the point cloud extension dictionary in the
  114. /// specified drawing database or 0 if the dictionary was not found.
  115. /// </summary>
  116. /// <param name="pDb">
  117. /// Input AutoCAD database in which to search for the dictionary.
  118. /// </param>
  119. static AcDbObjectId pointCloudExDictionary(AcDbDatabase* pDb);
  120. /// <summary>
  121. /// Returns a pointer to the point cloud extension dictionary for the
  122. /// given AcDbPointCloudDefEx's database, or NULL if the dictionary
  123. /// was not found.
  124. /// If the pDefEx is NULL, the AutoCAD database for the dictionary is
  125. /// typically acdbCurDwg().
  126. /// </summary>
  127. /// <param name="pDefEx">
  128. /// Input AcDbPointCloudDefEx object for which to find the dictionary.
  129. /// </param>
  130. static AcDbDictionary* getPointCloudExDictionary(AcDbPointCloudDefEx* pDefEx);
  131. // Overridden methods from AcDbObject
  132. //
  133. /// <summary>
  134. /// This function is called by dwgIn(). Its purpose is to allow this object to read in its data.
  135. /// </summary>
  136. /// <param name="pFiler">
  137. /// Pointer to the filer to use to read in the object's data
  138. /// </param>
  139. /// <returns>
  140. /// Returns Acad::eOk if successful.
  141. /// </returns>
  142. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
  143. /// <summary>
  144. /// This function is called by dwgOut(). Its purpose is to allow this object to write out its data.
  145. /// </summary>
  146. /// <param name="pFiler">
  147. /// Pointer to filer to use to write out the object's data .
  148. /// </param>
  149. /// <returns>
  150. /// Returns Acad::eOk if successful.
  151. /// </returns>
  152. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  153. /// <summary>
  154. /// This function is called by dxfIn(). Its purpose is to allow this object to read in its data.
  155. /// </summary>
  156. /// <param name="pFiler">
  157. /// Pointer to filer to use to read in the object's data.
  158. /// </param>
  159. /// <returns>
  160. /// Returns Acad::eOk if successful.
  161. /// </returns>
  162. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
  163. /// <summary>
  164. /// This function is called by dxfOut(). Its purpose is to allow this object to write out its data.
  165. /// </summary>
  166. /// <param name="pFiler">
  167. /// Pointer to filer to use to write out the object's data
  168. /// </param>
  169. /// <returns>
  170. /// Returns Acad::eOk if successful.
  171. /// </returns>
  172. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
  173. /// <summary>
  174. /// Called from within erase() before anything else is done.
  175. /// </summary>
  176. /// <param name="erasing">
  177. /// The erasing argument that was passed into the corresponding call to erase().
  178. /// </param>
  179. /// <returns>
  180. /// Returns Acad::eOk if erasing is successful.
  181. /// If this function returns anything other than Acad::eOk, then the
  182. /// erase operation is immediately terminated.
  183. /// </returns>
  184. virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing);
  185. /// <summary>
  186. /// Returns a pointer to the ReCap point cloud data, which will
  187. /// be shared by all AcDbPointCloudEx entities that reference the same ReCap project.
  188. /// </summary>
  189. /// <remarks> Internal use only </remarks>
  190. Autodesk::RealityStudio::SDK::Interface::IRCData* getRCData();
  191. /// <summary>
  192. /// Loads point cloud data from the source point cloud file.
  193. /// If the point cloud is already loaded, Acad::eOk is returned.
  194. /// This will notifies all dependent AcDbPointCloudEx
  195. /// entities to be redrawn.
  196. /// </summary>
  197. /// <returns>
  198. /// Returns Acad::eOk if successful, or Acad::eInvalidInput otherwise.
  199. /// </returns>
  200. Acad::ErrorStatus load();
  201. /// <summary>
  202. /// Immediately unloads all point cloud data in the AcDbPointCloudDefEx,
  203. /// but does not delete the
  204. /// AcDbPointCloudDefEx itself. This method notifies all dependent
  205. /// AcDbPointCloudEx entities to be redrawn.
  206. /// </summary>
  207. /// <returns> Returns Acad::eOk if successful. </returns>
  208. Acad::ErrorStatus unload();
  209. /// <summary>
  210. /// Returns Adesk::kTrue if the point cloud is loaded, or Adesk::kFalse otherwise.
  211. /// </summary>
  212. Adesk::Boolean isLoaded() const;
  213. /// <summary>
  214. /// Returns the number of AcDbPointCloudEx entities in the current drawing
  215. /// that are dependent upon this object for display graphics. If the pointer
  216. /// pbLocked is non-zero, then this function will set the value at that
  217. /// pointer to Adesk::kTrue if any dependent entities reside on locked
  218. /// layers. It returns Adesk::kFalse otherwise.
  219. /// </summary>
  220. /// <param name="pbLocked">
  221. /// Input pointer value
  222. /// </param>
  223. int entityCount(Adesk::Boolean* pbLocked = 0) const;
  224. /// <summary>
  225. /// This function sets the pathname of the externally referenced point cloud
  226. /// file. The point cloud file path name is stored when the current drawing
  227. /// is saved. The point cloud extension definition is initialized and
  228. /// a file descriptor is created for access to the point cloud file.
  229. /// </summary>
  230. /// <param name="pPathName">
  231. /// Input path name of the point cloud
  232. /// </param>
  233. /// <returns>
  234. /// Returns Acad::eOk if successful.
  235. /// Returns Acad::eInvalidInput if the input path is invalid.
  236. /// </returns>
  237. Acad::ErrorStatus setSourceFileName(const TCHAR* pPathName);
  238. /// <summary>
  239. /// Returns the path name of the externally referenced point cloud file name.
  240. /// This file name is saved in the DWG file with the object.
  241. /// </summary>
  242. const TCHAR* sourceFileName() const;
  243. /// <summary>
  244. /// This function sets the active path name of the externally referenced
  245. /// point cloud file. The active path points to the file that is
  246. /// actually used to define the point cloud in the current drawing.
  247. /// However, the active path is not persistent, and is not saved in the
  248. /// drawing file. If pPathName does not point to a valid point cloud file,
  249. /// then the active path is unchanged.
  250. /// </summary>
  251. /// <param name="pPathName">
  252. /// Input path name of the point cloud
  253. /// </param>
  254. /// <returns>
  255. /// Returns Acad::eOk if successful.
  256. /// Returns Acad::eInvalidInput if the input path is invalid.
  257. /// </returns>
  258. Acad::ErrorStatus setActiveFileName(const TCHAR* pPathName);
  259. /// <summary>
  260. /// Returns the path name of the actual file being currently used to define
  261. /// the point cloud.
  262. /// </summary>
  263. const TCHAR* activeFileName() const;
  264. /// <summary>
  265. /// Returns the file extension of this definition's point cloud file.
  266. /// There are two types: RCP for a ReCap project file; RCS for a ReCap scan file.
  267. /// </summary>
  268. const TCHAR* fileType() const;
  269. /// <summary>
  270. /// Returns the total point count for the point cloud file.
  271. /// </summary>
  272. unsigned long long totalPointsCount() const;
  273. /// <summary>
  274. /// Returns the total region count for the point cloud file.
  275. /// </summary>
  276. int totalRegionsCount() const;
  277. /// <summary>
  278. /// Returns the total scan count for the point cloud file.
  279. /// </summary>
  280. int totalScansCount() const;
  281. /// <summary>
  282. /// Returns the default extent's width of the point cloud file.
  283. /// </summary>
  284. double defaultWidth() const;
  285. /// <summary>
  286. /// Returns the default extent's length of the point cloud file.
  287. /// </summary>
  288. double defaultLength() const;
  289. /// <summary>
  290. /// Returns the default extent's height of the point cloud file.
  291. /// </summary>
  292. double defaultHeight() const;
  293. /// <summary>
  294. /// Returns the property state of a specified property in the point cloud file.
  295. /// This will tell if a given property is present in all, some, or none of the
  296. /// scans that are in the current point cloud file.
  297. /// </summary>
  298. /// <param name="prop">
  299. /// Input property type of the point cloud
  300. /// </param>
  301. PropState hasProperty(Property prop) const;
  302. /// <summary>
  303. /// Create a thumbnail image of the point cloud that is
  304. /// a specified width and height.
  305. /// </summary>
  306. /// <param name="pBmpInfo">
  307. /// A pointer to the bitmap upon successful return. The caller is responsible
  308. /// for freeing this data structure using GlobalFree().
  309. /// </param>
  310. /// <param name="width">
  311. /// The width value of the preview bitmap
  312. /// </param>
  313. /// <param name="height">
  314. /// The height value of the preview bitmap
  315. /// </param>
  316. /// <returns>Returns Acad::eOk if successful.</returns>
  317. Acad::ErrorStatus createThumbnailBitmap( BITMAPINFO*& pBmpInfo,
  318. int width,
  319. int height ) const;
  320. /// <summary>
  321. /// Gets the whole extents of attached point cloud
  322. /// </summary>
  323. AcDbExtents extents() const;
  324. /// <summary>
  325. /// Gets the coordinate system name of attached point cloud
  326. /// </summary>
  327. const TCHAR* coordinateSystemName() const;
  328. /// <summary>
  329. /// Gets the file path of specified RCS
  330. /// </summary>
  331. /// <param name="guid">
  332. /// the GUID of the RCS
  333. /// </param>
  334. /// <returns>Returns file path</returns>
  335. const TCHAR* getRcsFilePath(const AcString& guid) const;
  336. /// <summary>
  337. /// Gets the list which contains all RCS file path
  338. /// </summary>
  339. /// <param name="list">
  340. /// array used to contain all RCS file path
  341. /// </param>
  342. void getAllRcsFilePaths(AcStringArray& list) const;
  343. private:
  344. PointCloudDefExImp* m_pImp;
  345. static int m_nVersion;
  346. };
  347. class PointCloudDefReactorExImp;
  348. //////////////////////////////////////////////////////////////////////////////
  349. /// <summary>
  350. /// The AcDbPointCloudDefReactorEx class is used to notify AcDbPointCloudEx
  351. /// entities of relevant modifications to their associated AcDbPointCloudDefEx
  352. /// object. It is a persistent reactor of AcDbPointCloudDefEx object, used to
  353. /// connect AcDbPointCloudEx entities.
  354. ///
  355. /// Specifically, modification of the AcDbPointCloudDefEx object triggers the
  356. /// redraw of each of its dependent AcDbPointCloudEx entities.
  357. /// Erasing the AcDbPointCloudDefEx object triggers the erasing of its dependent
  358. /// AcDbPointCloudEx entities.
  359. /// </summary>
  360. class ACDB_PORT AcDbPointCloudDefReactorEx : public AcDbObject
  361. {
  362. public:
  363. /// <summary>
  364. /// Returns the class version number that indicates which version of
  365. /// AcDbPointCloudEx this object represents. This is primarily used during
  366. /// filing operations to determine what data to read or write.
  367. /// </summary>
  368. static int classVersion();
  369. /// <summary>
  370. /// This method is used to temporarily disable notification of AcDbPointCloudEx
  371. /// entities when an AcDbPointCloudDefEx object is modified or erased.
  372. ///
  373. /// If enable is set to Adesk::kTrue, normal reactor operation is turned on.
  374. /// If set to Adesk::kFalse, reactor notification is turned off.
  375. /// </summary>
  376. /// <param name="bEnable">
  377. /// Input Boolean to enable/disable notification
  378. /// </param>
  379. static void setEnable(Adesk::Boolean bEnable);
  380. /// <summary>
  381. /// Returns a Boolean value whether the notification is enabled or disabled.
  382. /// </summary>
  383. static Adesk::Boolean isEnabled();
  384. ACRX_DECLARE_MEMBERS(AcDbPointCloudDefReactorEx);
  385. /// <summary>
  386. /// Default constructor
  387. /// </summary>
  388. AcDbPointCloudDefReactorEx();
  389. /// <summary>
  390. /// Destructor
  391. /// </summary>
  392. virtual ~AcDbPointCloudDefReactorEx();
  393. // Overridden methods from AcDbObject
  394. //
  395. /// <summary>
  396. /// This function is called by dwgIn(). Its purpose is to allow the object to read in its data.
  397. /// </summary>
  398. /// <param name="pFiler">
  399. /// Pointer to a filer to use to read in the object's data
  400. /// </param>
  401. /// <returns>
  402. /// Returns Acad::eOk if successful.
  403. /// </returns>
  404. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
  405. /// <summary>
  406. /// This function is called by dwgOut(). Its purpose is to allow the object to write out its data.
  407. /// </summary>
  408. /// <param name="pFiler">
  409. /// Pointer to a filer to use to write out the object's data
  410. /// </param>
  411. /// <returns>
  412. /// Returns Acad::eOk if successful.
  413. /// </returns>
  414. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  415. /// <summary>
  416. /// This function is called by dxfIn(). Its purpose is to allow the object to read in its data.
  417. /// </summary>
  418. /// <param name="pFiler">
  419. /// Pointer to a filer to use to read in the object's data
  420. /// </param>
  421. /// <returns>
  422. /// Returns Acad::eOk if successful.
  423. /// </returns>
  424. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
  425. /// <summary>
  426. /// This function is called by dxfOut(). Its purpose is to allow the object to write out its data.
  427. /// </summary>
  428. /// <param name="pFiler">
  429. /// Pointer to filer to use to write out the object's data
  430. /// </param>
  431. /// <returns>
  432. /// Returns Acad::eOk if successful.
  433. /// </returns>
  434. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
  435. // Notification
  436. //
  437. /// <summary>
  438. /// This method is called when the AcDbPointCloudDefEx object is deleted.
  439. /// It responds by deleting the AcDbPointCloudEx entity that owns the reactor.
  440. ///
  441. /// A pErasing value of Adesk::kTrue indicates the definition object is being erased.
  442. /// A value of Adesk::kFalse indicates that the object is being restored (unerased).
  443. /// </summary>
  444. /// <param name="dbObj">
  445. /// Pointer to the AcDbPointCloudDefEx object sending the notification
  446. /// </param>
  447. /// <param name="pErasing">
  448. /// Boolean indicating the erasing status
  449. /// </param>
  450. virtual void erased(const AcDbObject* dbObj,
  451. Adesk::Boolean pErasing = true);
  452. /// <summary>
  453. /// This method is called when the AcDbPointCloudDefEx object is modified.
  454. /// It responds by redrawing the AcDbPointCloudEx entity that owns the reactor.
  455. /// </summary>
  456. /// <param name="dbObj">
  457. /// Pointer to the AcDbPointCloudDefEx object sending the notification
  458. /// </param>
  459. virtual void modified(const AcDbObject* dbObj);
  460. private:
  461. static int m_version;
  462. static Adesk::Boolean m_bIsEnabled;
  463. PointCloudDefReactorExImp* m_pImp;
  464. };