dbSubD.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. // Name: dbsubd.h
  12. //
  13. // Description: AcDbSubDMesh api class declaration
  14. //
  15. ///////////////////////////////////////////////////////////////////////////////
  16. #pragma once
  17. #include "dbmain.h"
  18. #pragma pack(push, 8)
  19. class AcDbSurface;
  20. class AcGiFaceData;
  21. class AcGiMapper;
  22. ///////////////////////////////////////////////////////////////////////////////
  23. // class AcDbSubDMesh
  24. //
  25. class ACDB_PORT AcDbSubDMesh: public AcDbEntity
  26. {
  27. ACDB_DECLARE_MEMBERS(AcDbSubDMesh);
  28. public:
  29. AcDbSubDMesh ();
  30. virtual ~AcDbSubDMesh ();
  31. ///////////////////////////////////////////////////////////////////////////
  32. // Methods for AcDbSubDMesh
  33. ///////////////////////////////////////////////////////////////////////////
  34. //
  35. Acad::ErrorStatus setSubDMesh (const AcGePoint3dArray& vertexArray,
  36. const AcArray<Adesk::Int32>& faceArray,
  37. int subDLevel);
  38. Acad::ErrorStatus setSphere (double radius,
  39. int divAxis,
  40. int divHeight,
  41. int subDLevel);
  42. Acad::ErrorStatus setCylinder (double majorRadius,
  43. double minorRadius,
  44. double height,
  45. int divAxis,
  46. int divHeight,
  47. int divCap,
  48. int subDLevel);
  49. Acad::ErrorStatus setCone (double majorRadius,
  50. double minorRadius,
  51. double height,
  52. int divAxis,
  53. int divHeight,
  54. int divCap,
  55. double radiusRatio,
  56. int subDLevel);
  57. Acad::ErrorStatus setTorus (double majorRadius,
  58. int divSection,
  59. int divSweepPath,
  60. double sectionRadiusRatio,
  61. double sectionRotate,
  62. int subDLevel);
  63. Acad::ErrorStatus setBox (double xLen,
  64. double yLen,
  65. double zLen,
  66. int divX,
  67. int divY,
  68. int divZ,
  69. int subDLevel);
  70. Acad::ErrorStatus setWedge (double xLen,
  71. double yLen,
  72. double zLen,
  73. int divLength,
  74. int divWidth,
  75. int divHeight,
  76. int divSlope,
  77. int divCap,
  78. int subDLevel);
  79. Acad::ErrorStatus setPyramid (double radius,
  80. double height,
  81. int divLength,
  82. int divHeight,
  83. int divCap,
  84. int nSides,
  85. double radiusRatio,
  86. int subDLevel);
  87. Acad::ErrorStatus subdDivideUp ();
  88. Acad::ErrorStatus subdDivideDown ();
  89. Acad::ErrorStatus subdRefine ();
  90. Acad::ErrorStatus subdRefine (const AcDbFullSubentPathArray& subentPaths);
  91. Acad::ErrorStatus subdLevel (Adesk::Int32& result) const;
  92. Acad::ErrorStatus splitFace (const AcDbSubentId& subentFaceId,
  93. const AcDbSubentId& subent0,
  94. const AcGePoint3d& point0,
  95. const AcDbSubentId& subent1,
  96. const AcGePoint3d& point1);
  97. Acad::ErrorStatus extrudeFaces (const AcDbFullSubentPathArray& subentPaths,
  98. double length,
  99. const AcGeVector3d& dir,
  100. double taper);
  101. Acad::ErrorStatus extrudeFaces (const AcDbFullSubentPathArray& subentPaths,
  102. const AcGePoint3dArray& alongPath,
  103. double taper);
  104. Acad::ErrorStatus extrudeConnectedFaces (const AcDbFullSubentPathArray& subentPaths,
  105. double length,
  106. const AcGeVector3d& dir,
  107. double taper);
  108. Acad::ErrorStatus extrudeConnectedFaces (const AcDbFullSubentPathArray& subentPaths,
  109. const AcGePoint3dArray& alongPath,
  110. double taper);
  111. Acad::ErrorStatus mergeFaces (const AcDbFullSubentPathArray& subentPaths);
  112. Acad::ErrorStatus collapse (const AcDbSubentId& subent);
  113. Acad::ErrorStatus cap (const AcDbFullSubentPathArray& edgePaths);
  114. Acad::ErrorStatus spin (const AcDbSubentId& subent);
  115. Acad::ErrorStatus isWatertight (bool& result) const;
  116. Acad::ErrorStatus numOfFaces (Adesk::Int32& result) const;
  117. Acad::ErrorStatus numOfSubDividedFaces (Adesk::Int32& result) const;
  118. Acad::ErrorStatus numOfSubDividedFacesAt (const AcDbFullSubentPathArray& subentPaths, Adesk::Int32& result) const;
  119. Acad::ErrorStatus numOfVertices (Adesk::Int32& result) const;
  120. Acad::ErrorStatus numOfSubDividedVertices (Adesk::Int32& result) const;
  121. Acad::ErrorStatus numOfEdges (Adesk::Int32& result) const;
  122. Acad::ErrorStatus getVertices (AcGePoint3dArray& vertexArray) const;
  123. Acad::ErrorStatus getEdgeArray (AcArray<Adesk::Int32>& edgeArray) const;
  124. Acad::ErrorStatus getFaceArray (AcArray<Adesk::Int32>& faceArray) const;
  125. Acad::ErrorStatus getNormalArray (AcGeVector3dArray& normalArray) const;
  126. Acad::ErrorStatus getSubDividedVertices (AcGePoint3dArray& vertexArray) const;
  127. Acad::ErrorStatus getSubDividedFaceArray (AcArray<Adesk::Int32>& faceArray) const;
  128. Acad::ErrorStatus getSubDividedNormalArray(AcGeVector3dArray& normalArray) const;
  129. Acad::ErrorStatus getVertexAt (Adesk::Int32 nIndex, AcGePoint3d& vertex) const;
  130. Acad::ErrorStatus setVertexAt (Adesk::Int32 nIndex, const AcGePoint3d& vertex);
  131. Acad::ErrorStatus getVertexAt (const AcDbSubentId& id, AcGePoint3d& vertex) const;
  132. Acad::ErrorStatus setVertexAt (const AcDbSubentId& id, const AcGePoint3d& vertex);
  133. Acad::ErrorStatus getSubDividedVertexAt (Adesk::Int32 nIndex, AcGePoint3d& vertex) const;
  134. Acad::ErrorStatus getSubDividedVertexAt (const AcDbSubentId& id, AcGePoint3d& vertex) const;
  135. Acad::ErrorStatus setCrease (double creaseVal);
  136. Acad::ErrorStatus setCrease (const AcDbFullSubentPathArray& subentPaths, double creaseVal);
  137. Acad::ErrorStatus getCrease (const AcDbFullSubentPathArray& subentPaths, AcArray<double>& result) const;
  138. Acad::ErrorStatus getCrease (const AcDbSubentId& id, double& result) const;
  139. Acad::ErrorStatus getAdjacentSubentPath (const AcDbFullSubentPath& path,
  140. AcDb::SubentType type,
  141. AcDbFullSubentPathArray& subentPaths) const;
  142. Acad::ErrorStatus getSubentPath (Adesk::Int32 nIndex,
  143. AcDb::SubentType type,
  144. AcDbFullSubentPathArray& subentPaths) const;
  145. Acad::ErrorStatus convertToSurface (bool bConvertAsSmooth, const AcDbSubentId& id, AcDbSurface*& pSurface) const;
  146. Acad::ErrorStatus convertToSurface (bool bConvertAsSmooth, bool optimize, AcDbSurface*& pSurface) const;
  147. Acad::ErrorStatus convertToSolid (bool bConvertAsSmooth, bool optimize, AcDb3dSolid*& pSolid) const;
  148. Acad::ErrorStatus getSubentColor (const AcDbSubentId& id, AcCmColor& color) const;
  149. Acad::ErrorStatus setSubentColor (const AcDbSubentId& id, const AcCmColor& color);
  150. Acad::ErrorStatus getSubentMaterial (const AcDbSubentId& id, AcDbObjectId& material) const;
  151. Acad::ErrorStatus setSubentMaterial (const AcDbSubentId& id, const AcDbObjectId& material);
  152. Acad::ErrorStatus getSubentMaterialMapper (const AcDbSubentId& id, AcGiMapper& mapper) const;
  153. Acad::ErrorStatus setSubentMaterialMapper (const AcDbSubentId& id, const AcGiMapper& mapper);
  154. Acad::ErrorStatus getFacePlane (const AcDbSubentId& id, AcGePlane& facePlane) const;
  155. Acad::ErrorStatus computeVolume (double &retVolume) const;
  156. Acad::ErrorStatus computeSurfaceArea (double &retSurfArea) const;
  157. ///////////////////////////////////////////////////////////////////////////
  158. // Overridden methods from AcDbEntity
  159. ///////////////////////////////////////////////////////////////////////////
  160. //
  161. virtual void dragStatus (const AcDb::DragStat status);
  162. virtual Acad::ErrorStatus subGetClassID (CLSID* pClsid) const;
  163. ///////////////////////////////////////////////////////////////////////////
  164. // Overridden methods from AcGiDrawable
  165. ///////////////////////////////////////////////////////////////////////////
  166. //
  167. virtual bool bounds ( AcDbExtents& retBounds ) const;
  168. ///////////////////////////////////////////////////////////////////////////
  169. // Internal use
  170. ///////////////////////////////////////////////////////////////////////////
  171. //
  172. Acad::ErrorStatus setSphere (const AcGeMatrix3d& xForm,
  173. int divAxis,
  174. int divHeight,
  175. int subDLevel);
  176. Acad::ErrorStatus setCylinder (const AcGeMatrix3d& xForm,
  177. int divAxis,
  178. int divHeight,
  179. int divCap,
  180. int subDLevel);
  181. Acad::ErrorStatus setCone (const AcGeMatrix3d& xForm,
  182. int divAxis,
  183. int divHeight,
  184. int divCap,
  185. double radiusRatio,
  186. int subDLevel);
  187. Acad::ErrorStatus setTorus (const AcGeMatrix3d& xForm,
  188. int divSection,
  189. int divSweepPath,
  190. double sectionRadiusRatio,
  191. double sectionRotate,
  192. int subDLevel);
  193. Acad::ErrorStatus setBox (const AcGeMatrix3d& xForm,
  194. int divX,
  195. int divY,
  196. int divZ,
  197. int subDLevel);
  198. Acad::ErrorStatus setWedge (const AcGeMatrix3d& xForm,
  199. int divLength,
  200. int divWidth,
  201. int divHeight,
  202. int divSlope,
  203. int divCap,
  204. int subDLevel);
  205. Acad::ErrorStatus setPyramid (const AcGeMatrix3d& xForm,
  206. int divLength,
  207. int divHeight,
  208. int divCap,
  209. int nSides,
  210. double radiusRatio,
  211. int subDLevel);
  212. Acad::ErrorStatus computeRayIntersection (const AcGePoint3d &rayStart,
  213. const AcGeVector3d &rayDir,
  214. AcArray<AcDbSubentId> &retSubents,
  215. AcArray<double> &retIntersectDist,
  216. AcGePoint3dArray& retIntersectPoint) const;
  217. Acad::ErrorStatus setVertexNormalArray(AcGeVector3dArray &arr);
  218. Acad::ErrorStatus setVertexTextureArray(AcGePoint3dArray &arr);
  219. Acad::ErrorStatus setVertexColorArray(AcArray<AcCmEntityColor> &arr);
  220. Acad::ErrorStatus getVertexNormalArray(AcGeVector3dArray &arr);
  221. Acad::ErrorStatus getVertexTextureArray(AcGePoint3dArray &arr);
  222. Acad::ErrorStatus getVertexColorArray(AcArray<AcCmEntityColor> &arr);
  223. };
  224. ///////////////////////////////////////////////////////////////////////////
  225. // Global API functions
  226. ///////////////////////////////////////////////////////////////////////////
  227. //
  228. struct MeshFaceterSettings
  229. {
  230. double faceterDevSurface;
  231. double faceterDevNormal;
  232. double faceterGridRatio;
  233. double faceterMaxEdgeLength;
  234. Adesk::UInt16 faceterMaxGrid;
  235. Adesk::UInt16 faceterMinUGrid; // Unused
  236. Adesk::UInt16 faceterMinVGrid; // Unused
  237. Adesk::Int16 faceterMeshType;
  238. };
  239. typedef struct MeshFaceterSettings AcDbFaceterSettings;
  240. ACDB_PORT Acad::ErrorStatus acdbGetObjectMesh(AcDbObject *pObj,
  241. const AcDbFaceterSettings *faceter,
  242. AcGePoint3dArray& vertexArray,
  243. AcArray<Adesk::Int32>& faceArray,
  244. AcGiFaceData*& faceData);
  245. #pragma pack(pop)