AcDbPointCloudCrop.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. namespace Autodesk { namespace RealityStudio { namespace SDK { namespace Interface {
  13. class ARCSpatialFilter;
  14. }}}};
  15. class AcDbPointCloudDxfHandler;
  16. /// <summary>
  17. /// This class defines a cropping boundary for the AcDbPointCloudEx entity.
  18. /// Each cropping boundary contains a plane which locates the boundary,
  19. /// a cropping type, a flag indicating whether we want what is inside
  20. /// or outside the region, another flag indicating whether the results of
  21. /// this cropping boundary should be inverted.
  22. /// </summary>
  23. class ACDB_PORT AcDbPointCloudCrop
  24. {
  25. public:
  26. /// <summary>
  27. /// This enumeration defines the crop type (i.e., the shape of the cropping region).
  28. /// </summary>
  29. enum CropType
  30. {
  31. /// <summary>
  32. /// Undefined type
  33. /// </summary>
  34. kInvalid = 0,
  35. /// <summary>
  36. /// Rectangular type
  37. /// </summary>
  38. kRectangular,
  39. /// <summary>
  40. /// Polygonal type
  41. /// </summary>
  42. kPolygonal,
  43. /// <summary>
  44. /// Circle type
  45. /// </summary>
  46. kCircular
  47. };
  48. public:
  49. /// <summary>
  50. /// Default constructor
  51. /// </summary>
  52. AcDbPointCloudCrop();
  53. /// <summary>
  54. /// Copy constructor
  55. /// </summary>
  56. /// <param name="other"> the AcDbPointCloudCrop object that will be copied. </param>
  57. AcDbPointCloudCrop(const AcDbPointCloudCrop& other);
  58. /// <summary>
  59. /// Destructor
  60. /// </summary>
  61. virtual ~AcDbPointCloudCrop();
  62. /// <summary>
  63. /// Equality operator.
  64. /// </summary>
  65. /// <param name="other"> the object to which this cropping region will be compared. </param>
  66. /// <returns>Returns true if the input object is the same as the current one, or false otherwise.</returns>
  67. bool operator == (const AcDbPointCloudCrop& other) const;
  68. /// <summary>
  69. /// Inequality operator.
  70. /// </summary>
  71. /// <param name="other"> the object to which this cropping region will be compared. </param>
  72. /// <returns>Returns true if the input object is not the same as the current one or false otherwise.</returns>
  73. bool operator != (const AcDbPointCloudCrop& other) const;
  74. /// <summary>
  75. /// Assignment operator.
  76. /// </summary>
  77. /// <param name="other"> the cropping region to which this object will be assiged. </param>
  78. /// <returns>Returns a reference of current object.</returns>
  79. AcDbPointCloudCrop& operator=(const AcDbPointCloudCrop& other);
  80. // AcDbEntity helpers used by AcDbPointCloudEx
  81. //
  82. /// <summary>
  83. /// Reads the cropping boundary information from a dwg pFiler.
  84. /// </summary>
  85. /// <param name="pFiler">Input filer to use</param>
  86. /// <returns>Returns Acad::eOk if successful or error code otherwise.</returns>
  87. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
  88. /// <summary>
  89. /// Writes out the cropping boundary information to a dwg pFiler.
  90. /// </summary>
  91. /// <param name="pFiler">Output filer to use</param>
  92. /// <returns>Returns Acad::eOk if successful or error code otherwise.</returns>
  93. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  94. /// <summary>
  95. /// Reads the cropping boundary information via from a dxf pFiler. The flags that are passed in are
  96. /// essentially data IDs.
  97. /// </summary>
  98. /// <param name="pFiler">Input filer to use</param>
  99. /// <param name="dxfInt8">Int8 flag used to read data to pFiler</param>
  100. /// <param name="dxfInt32">Int32 flag used to read data to pFile</param>
  101. /// <param name="dxfXCoord">XCoord flag used to read data to pFile</param>
  102. /// <param name="dxfNormalX">NormalX flag used to read data to pFile</param>
  103. /// <returns>Returns Acad::eOk if successful or error code otherwise.</returns>
  104. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler , Adesk::Int16& dxfInt8, Adesk::Int16& dxfInt32, Adesk::Int16& dxfXCoord, Adesk::Int16& dxfNormalX);
  105. /// <summary>
  106. /// Writes out the cropping boundary information to a dxf pFiler. The flags that are passed in are
  107. /// essentially data IDs.
  108. /// </summary>
  109. /// <param name="pFiler">Output filer to use</param>
  110. /// <param name="dxfInt8">Int8 flag used to write data to pFiler</param>
  111. /// <param name="dxfInt32">Int32 flag used to write data to pFile</param>
  112. /// <param name="dxfXCoord">XCoord flag used to write data to pFile</param>
  113. /// <param name="dxfNormalX">NormalX flag used to write data to pFile</param>
  114. /// <returns>Returns Acad::eOk if successful or error code otherwise.</returns>
  115. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler, Adesk::Int16& dxfInt8, Adesk::Int16& dxfInt32, Adesk::Int16& dxfXCoord, Adesk::Int16& dxfNormalX) const;
  116. /// <summary>
  117. /// Converts the crop boundary to an ARCSpatialFilter, which are used by internal
  118. /// data management classes.
  119. /// </summary>
  120. /// <returns>
  121. /// A pointer to an ARCSpatialFilter. The user needs to call the free() method
  122. /// to release it.
  123. /// </returns>
  124. /// <remarks> internal use </remarks>
  125. virtual Autodesk::RealityStudio::SDK::Interface::ARCSpatialFilter* toSpatialFilter() const;
  126. /// <summary>
  127. /// Draws the cropping boundary in the point cloud's model coordinate system. This method
  128. /// is called by AcDbPointCloudEx::subWorldDraw().
  129. /// </summary>
  130. /// <param name="geom">
  131. /// The reference to AcGiGeometry that was given to AcDbPointCloudEx::subWorldDraw().
  132. /// </param>
  133. /// <remarks> internal use </remarks>
  134. virtual void draw(AcGiGeometry& geom);
  135. /// <summary>
  136. /// Clears all cropping boundary information.
  137. /// </summary>
  138. void clear();
  139. /// <summary>
  140. /// Checks if this object represents a valid cropping boundary.
  141. /// </summary>
  142. /// <returns>
  143. /// Returns true if the cropping boundary is valid, or false otherwise.
  144. /// </returns>
  145. bool isValid() const;
  146. /// <summary>
  147. /// Gets the cropping boundary type for this object.
  148. /// </summary>
  149. /// <returns>
  150. /// Returns the type of point cloud crop.
  151. /// </returns>
  152. CropType type() const;
  153. /// <summary>
  154. /// Sets the cropping boundary type for this object.
  155. /// </summary>
  156. /// <param name="type"> type of point cloud crop </param>
  157. void setCropType(CropType type);
  158. /// <summary>
  159. /// Gets whether this cropping boundary is allowing points inside of itself or outside.
  160. /// </summary>
  161. /// <returns>
  162. /// Returns true if points inside this region are allowed, or false otherwise.
  163. /// </returns>
  164. bool isInside() const;
  165. /// <summary>
  166. /// Sets whether this cropping boundary is allowing points inside of itself or outside.
  167. /// The default value is inside.
  168. /// </summary>
  169. /// <param name="bInside">
  170. /// Whether to allow points inside this region.
  171. /// </param>
  172. void setInside(bool bInside);
  173. /// <summary>
  174. /// Gets whether this cropping region's results are to be inverted.
  175. /// </summary>
  176. /// <returns>
  177. /// Returns true if cropping result will be inverted, or false otherwise.
  178. /// </returns>
  179. bool isInverted() const;
  180. /// <summary>
  181. /// Sets whether this cropping region's results are to be inverted.
  182. /// </summary>
  183. /// <param name="toInvert">
  184. /// Whether to invert the cropping result.
  185. /// </param>
  186. /// <remarks>
  187. /// This property is used by AcDbPointCloudEx.
  188. /// The user can add multiple cropping boundaries to a point cloud object.
  189. /// Normally, all boundaries are resulted by intersection.
  190. /// If the flag is true, the results of all crop boundaries from the first
  191. /// added one until this current one will be reversed.
  192. /// </remarks>
  193. void setInvert(bool toInvert);
  194. /// <summary>
  195. /// Gets the plane on which this cropping boundary is defined.
  196. /// </summary>
  197. /// <param name="plane">
  198. /// The plane of this cropping boundary.
  199. /// </param>
  200. /// <returns>
  201. /// Returns true if getting the plane successfully, or false otherwise.
  202. /// </returns>
  203. bool getCropPlane(AcGePlane& plane);
  204. /// <summary>
  205. /// Sets the plane on which this cropping boundary is defined.
  206. /// </summary>
  207. /// <param name="plane">
  208. /// The plane of this cropping boundary.
  209. /// </param>
  210. void setCropPlane(const AcGePlane& plane);
  211. ///<summary>
  212. /// Returns the number of points that describe the cropping boundary.
  213. ///</summary>
  214. /// <returns>
  215. /// If the crop type is a rectangle, the count of points is 5, the first and last point are same.
  216. /// If the crop type is a polygonal, the count of points is more than 3.
  217. /// If the crop type is a circle, the count of points if 2.
  218. /// </returns>
  219. int length() const;
  220. /// <summary>
  221. /// Sets the points array for point cloud crop boundary.
  222. /// </summary>
  223. /// <param name="points">
  224. /// the array should include the start point for the type of rectangle and polygonal, for example:
  225. /// Rectangle -- first corner point, 2nd, 3rd, 4th and first corner point again.
  226. /// Polygonal -- 1st, 2nd, 3rd, and etc. points, and the last point is also 1st point again.
  227. /// Circular, there are 2 points, center point and any point which is on the circle's circumference.
  228. /// </param>
  229. void set(const AcGePoint3dArray& points);
  230. /// <summary>
  231. /// Gets a reference to the internal array of the cropping boundary points.
  232. /// </summary>
  233. /// <returns>Returns a reference to the internal array.</returns>
  234. const AcGePoint3dArray& get();
  235. public:
  236. /// <summary>
  237. /// Sets the DXF handler for a rectangular crop. The previous handler will be released.
  238. /// The handler will be used to read dxf item data and deal with some errors.
  239. /// Also, this AcDbPointCloudCrop will be responsible for releasing its DXF handler.
  240. /// </summary>
  241. /// <param name="dxfHandler">The DXF handler.</param>
  242. /// <remarks> internal use </remarks>
  243. void setDxfHandler(AcDbPointCloudDxfHandler* dxfHandler);
  244. private:
  245. // member variables
  246. CropType m_cropType;
  247. bool m_isInside;
  248. bool m_isInverted;
  249. AcGePlane m_cropPlane;
  250. AcGePoint3dArray m_point3dArray;
  251. AcDbPointCloudDxfHandler* m_dxfHandler;
  252. };