dbnurbsurf.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 AcDbNurbSurface class is the interface class for representing
  16. // ASM NURBS surfaces inside AutoCAD.
  17. #pragma once
  18. #include "dbsurf.h"
  19. class AcGeKnotVector;
  20. class AcGeNurbSurface;
  21. #pragma pack(push, 8)
  22. class ACDB_PORT AcDbNurbSurface: public AcDbSurface
  23. {
  24. public:
  25. AcDbNurbSurface();
  26. AcDbNurbSurface(int uDegree, int vDegree, bool rational,
  27. int uNumControlPoints, int vNumControlPoints,
  28. const AcGePoint3dArray& ctrlPts,
  29. const AcGeDoubleArray& weights,
  30. const AcGeKnotVector& uKnots, const AcGeKnotVector& vKnots );
  31. virtual ~AcDbNurbSurface();
  32. ACDB_DECLARE_MEMBERS(AcDbNurbSurface);
  33. //////////////////////////////////////////////////////////
  34. // NURBS surface methods
  35. //////////////////////////////////////////////////////////
  36. // get/set all data
  37. Acad::ErrorStatus get (int& uDegree, int& vDegree, bool& rational,
  38. int& uNumControlPoints, int& vNumControlPoints,
  39. AcGePoint3dArray& ctrlPts,
  40. AcGeDoubleArray& weights,
  41. AcGeKnotVector& uKnots, AcGeKnotVector& vKnots) const;
  42. Acad::ErrorStatus set (int uDegree, int vDegree, bool rational,
  43. int uNumControlPoints, int vNumControlPoints,
  44. const AcGePoint3dArray& ctrlPts,
  45. const AcGeDoubleArray& weights,
  46. const AcGeKnotVector& uKnots, const AcGeKnotVector& vKnots);
  47. // get/set control points
  48. Acad::ErrorStatus getControlPoints(int& uCount, int& vCount, AcGePoint3dArray& points) const;
  49. Acad::ErrorStatus setControlPoints(int uCount, int vCount, const AcGePoint3dArray& points);
  50. Acad::ErrorStatus getControlPointAt(int uIndex, int vIndex, AcGePoint3d& point) const;
  51. Acad::ErrorStatus setControlPointAt(int uIndex, int vIndex, const AcGePoint3d& point);
  52. // get the number of control points.
  53. Acad::ErrorStatus getNumberOfControlPointsInU(int& count) const;
  54. Acad::ErrorStatus getNumberOfControlPointsInV(int& count) const;
  55. // get knots
  56. Acad::ErrorStatus getUKnots(AcGeKnotVector& knots) const;
  57. Acad::ErrorStatus getVKnots(AcGeKnotVector& knots) const;
  58. // get the number of knots in u or v
  59. Acad::ErrorStatus getNumberOfKnotsInU(int& count) const;
  60. Acad::ErrorStatus getNumberOfKnotsInV(int& count) const;
  61. Acad::ErrorStatus getWeight(int uIndex, int vIndex, double& weight ) const;
  62. Acad::ErrorStatus setWeight(int uIndex, int vIndex, double weight );
  63. // Evaluate position, first and second derivatives
  64. Acad::ErrorStatus evaluate(double u, double v, AcGePoint3d& pos) const;
  65. Acad::ErrorStatus evaluate(double u, double v, AcGePoint3d& pos, AcGeVector3d& uDeriv, AcGeVector3d& vDeriv) const;
  66. Acad::ErrorStatus evaluate(double u, double v, AcGePoint3d& pos, AcGeVector3d& uDeriv, AcGeVector3d& vDeriv,
  67. AcGeVector3d& uuDeriv, AcGeVector3d& uvDeriv, AcGeVector3d& vvDeriv) const;
  68. Acad::ErrorStatus evaluate(double u, double v, int derivDegree, AcGePoint3d& point, AcGeVector3dArray& derivatives) const;
  69. // get degree
  70. Acad::ErrorStatus getDegreeInU(int& degree) const;
  71. Acad::ErrorStatus getDegreeInV(int& degree) const;
  72. // is closed
  73. Acad::ErrorStatus isClosedInU(bool& isClosed) const;
  74. Acad::ErrorStatus isClosedInV(bool& isClosed) const;
  75. // is periodic
  76. Acad::ErrorStatus isPeriodicInU(bool& isPeriodic) const;
  77. Acad::ErrorStatus isPeriodicInV(bool& isPeriodic) const;
  78. // get period
  79. Acad::ErrorStatus getPeriodInU(double& period) const;
  80. Acad::ErrorStatus getPeriodInV(double& period) const;
  81. // test if rational
  82. Acad::ErrorStatus isRational(bool& isRational) const;
  83. // test if planar
  84. Acad::ErrorStatus isPlanar(bool& isPlanar, AcGePoint3d& ptOnSurface, AcGeVector3d& normal) const;
  85. // test if a point is on the surface
  86. Acad::ErrorStatus isPointOnSurface(const AcGePoint3d& point, bool& onSurface) const;
  87. // get normal
  88. Acad::ErrorStatus getNormal(double u, double v, AcGeVector3d& normal) const;
  89. // get the simple patches in u v direction
  90. Acad::ErrorStatus getNumberOfSpansInU(int& span) const;
  91. Acad::ErrorStatus getNumberOfSpansInV(int& span) const;
  92. // get the u and v isolines.
  93. Acad::ErrorStatus getIsolineAtU(double u, AcArray<AcDbCurve*>& lineSegments) const;
  94. Acad::ErrorStatus getIsolineAtV(double v, AcArray<AcDbCurve*>& lineSegments) const;
  95. // knot insertion
  96. Acad::ErrorStatus InsertKnotAtU(double u);
  97. Acad::ErrorStatus InsertKnotAtV(double v);
  98. // add / remove control points
  99. Acad::ErrorStatus InsertControlPointsAtU(double u, const AcGePoint3dArray& vCtrlPts, const AcGeDoubleArray& vWeights);
  100. Acad::ErrorStatus InsertControlPointsAtV(double v, const AcGePoint3dArray& uCtrlPts, const AcGeDoubleArray& uWeights);
  101. Acad::ErrorStatus RemoveControlPointsAtU(int uIndex);
  102. Acad::ErrorStatus RemoveControlPointsAtV(int vIndex);
  103. // rebuild
  104. Acad::ErrorStatus rebuild(int uDegree, int vDegree, int numUCtrlPts, int numVCtrlPts, bool bRestore = false);
  105. // adjust a point's location and tangent
  106. Acad::ErrorStatus modifyPositionAndTangent(double u, double v, const AcGePoint3d& point,
  107. const AcGeVector3d* uDeriv = NULL, const AcGeVector3d* vDeriv = NULL);
  108. // get the u and v for a point
  109. Acad::ErrorStatus getParameterOfPoint(const AcGePoint3d& point, double& u, double& v) const;
  110. // Overridden methods from AcDbEntity
  111. void dragStatus (const AcDb::DragStat status);
  112. protected:
  113. virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
  114. };
  115. #pragma pack(pop)