mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-09-02 01:12:36 +08:00
Coding - Modernize handle APIs and deprecate out-parameter overloads (#1185)
Introduce return-by-value APIs for handle-returning methods across touched toolkits, with nodiscard where appropriate, and keep legacy out-parameter signatures as deprecated wrappers for source compatibility. - Add new return-by-value overloads for previously output-parameter methods in key classes across ApplicationFramework, DataExchange, ModelingAlgorithms, ModelingData, and Visualization - Mark legacy output-parameter methods as deprecated and route them through the new overloads - Update call sites to use the new APIs and simplify temporary-variable patterns - Extend method documentation in OCCT Doxygen style with param/return sections and deprecation guidance - Apply const-correctness updates for read-only handle arguments in STEP reader related interfaces - Preserve compatibility for deprecated public wrappers by keeping exported out-of-line definitions where needed - Perform minor cleanup of comments and parameter naming consistency No functional behavior change is intended; this is an API modernization and migration-facilitation update.
This commit is contained in:
@@ -141,7 +141,7 @@ void BRepGProp::LinearProperties(const TopoDS_Shape& S,
|
||||
bool IsGeom = BRep_Tool::IsGeometric(aE);
|
||||
if (UseTriangulation || !IsGeom)
|
||||
{
|
||||
BRepGProp_MeshCinert::PreparePolygon(aE, theNodes);
|
||||
theNodes = BRepGProp_MeshCinert::PreparePolygon(aE);
|
||||
}
|
||||
if (!theNodes.IsNull())
|
||||
{
|
||||
|
||||
@@ -644,6 +644,16 @@ static void GetCurveKnots(const double theMin,
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
occ::handle<NCollection_HArray1<double>> BRepGProp_Face::GetUKnots(const double theUMin,
|
||||
const double theUMax) const
|
||||
{
|
||||
occ::handle<NCollection_HArray1<double>> theUKnots;
|
||||
GetUKnots(theUMin, theUMax, theUKnots);
|
||||
return theUKnots;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepGProp_Face::GetUKnots(const double theUMin,
|
||||
const double theUMax,
|
||||
occ::handle<NCollection_HArray1<double>>& theUKnots) const
|
||||
@@ -705,6 +715,16 @@ void BRepGProp_Face::GetUKnots(const double theUMin
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
occ::handle<NCollection_HArray1<double>> BRepGProp_Face::GetTKnots(const double theTMin,
|
||||
const double theTMax) const
|
||||
{
|
||||
occ::handle<NCollection_HArray1<double>> theTKnots;
|
||||
GetTKnots(theTMin, theTMax, theTKnots);
|
||||
return theTKnots;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepGProp_Face::GetTKnots(const double theTMin,
|
||||
const double theTMax,
|
||||
occ::handle<NCollection_HArray1<double>>& theTKnots) const
|
||||
|
||||
@@ -134,6 +134,15 @@ public:
|
||||
//! then theUMin and lower then theUMax in increasing order.
|
||||
//! If the face is not a BSpline, the array initialized with
|
||||
//! theUMin and theUMax only.
|
||||
//! @param[in] theUMin lower U bound
|
||||
//! @param[in] theUMax upper U bound
|
||||
//! @return array of U knot values
|
||||
[[nodiscard]] Standard_EXPORT occ::handle<NCollection_HArray1<double>> GetUKnots(
|
||||
const double theUMin,
|
||||
const double theUMax) const;
|
||||
|
||||
//! @deprecated Use GetUKnots() returning handle by value instead.
|
||||
Standard_DEPRECATED("Use GetUKnots() returning handle by value instead")
|
||||
Standard_EXPORT void GetUKnots(const double theUMin,
|
||||
const double theUMax,
|
||||
occ::handle<NCollection_HArray1<double>>& theUKnots) const;
|
||||
@@ -147,6 +156,15 @@ public:
|
||||
//! theTMin and lower then theTMax in increasing order.
|
||||
//! If the face is not a BSpline, the array initialized with
|
||||
//! theTMin and theTMax only.
|
||||
//! @param[in] theTMin lower T bound
|
||||
//! @param[in] theTMax upper T bound
|
||||
//! @return array of T knot values
|
||||
[[nodiscard]] Standard_EXPORT occ::handle<NCollection_HArray1<double>> GetTKnots(
|
||||
const double theTMin,
|
||||
const double theTMax) const;
|
||||
|
||||
//! @deprecated Use GetTKnots() returning handle by value instead.
|
||||
Standard_DEPRECATED("Use GetTKnots() returning handle by value instead")
|
||||
Standard_EXPORT void GetTKnots(const double theTMin,
|
||||
const double theTMax,
|
||||
occ::handle<NCollection_HArray1<double>>& theTKnots) const;
|
||||
|
||||
@@ -131,6 +131,16 @@ void BRepGProp_MeshCinert::Perform(const NCollection_Array1<gp_Pnt>& theNodes)
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
occ::handle<NCollection_HArray1<gp_Pnt>> BRepGProp_MeshCinert::PreparePolygon(
|
||||
const TopoDS_Edge& theE)
|
||||
{
|
||||
occ::handle<NCollection_HArray1<gp_Pnt>> thePolyg;
|
||||
PreparePolygon(theE, thePolyg);
|
||||
return thePolyg;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepGProp_MeshCinert::PreparePolygon(const TopoDS_Edge& theE,
|
||||
occ::handle<NCollection_HArray1<gp_Pnt>>& thePolyg)
|
||||
{
|
||||
|
||||
@@ -43,9 +43,15 @@ public:
|
||||
//! of polylines represented by set of points.
|
||||
Standard_EXPORT void Perform(const NCollection_Array1<gp_Pnt>& theNodes);
|
||||
|
||||
//! Prepare set of 3d points on base of any available edge polygons:
|
||||
//! 3D polygon, polygon on triangulation, 2d polygon on surface
|
||||
//! If edge has no polygons, array thePolyg is left unchanged
|
||||
//! Prepares set of 3d points on base of any available edge polygons:
|
||||
//! 3D polygon, polygon on triangulation, 2d polygon on surface.
|
||||
//! @param[in] theE the edge to extract polygon from
|
||||
//! @return array of 3D points, or null handle if edge has no polygons
|
||||
[[nodiscard]] Standard_EXPORT static occ::handle<NCollection_HArray1<gp_Pnt>> PreparePolygon(
|
||||
const TopoDS_Edge& theE);
|
||||
|
||||
//! @deprecated Use PreparePolygon() returning handle by value instead.
|
||||
Standard_DEPRECATED("Use PreparePolygon() returning handle by value instead")
|
||||
Standard_EXPORT static void PreparePolygon(const TopoDS_Edge& theE,
|
||||
occ::handle<NCollection_HArray1<gp_Pnt>>& thePolyg);
|
||||
};
|
||||
|
||||
@@ -56,10 +56,9 @@ bool BRepGProp_TFunction::Value(const double X, double& F)
|
||||
{
|
||||
const double tolU = 1.e-9;
|
||||
|
||||
gp_Pnt2d aP2d;
|
||||
gp_Vec2d aV2d;
|
||||
double aUMax;
|
||||
occ::handle<NCollection_HArray1<double>> anUKnots;
|
||||
gp_Pnt2d aP2d;
|
||||
gp_Vec2d aV2d;
|
||||
double aUMax;
|
||||
|
||||
mySurface.D12d(X, aP2d, aV2d);
|
||||
aUMax = aP2d.X();
|
||||
@@ -70,13 +69,13 @@ bool BRepGProp_TFunction::Value(const double X, double& F)
|
||||
return true;
|
||||
}
|
||||
|
||||
mySurface.GetUKnots(myUMin, aUMax, anUKnots);
|
||||
occ::handle<NCollection_HArray1<double>> aUKnots = mySurface.GetUKnots(myUMin, aUMax);
|
||||
myUFunction.SetVParam(aP2d.Y());
|
||||
|
||||
// Compute the integral from myUMin to aUMax of myUFunction.
|
||||
int i;
|
||||
double aCoeff = aV2d.Y();
|
||||
// int aNbUIntervals = anUKnots->Length() - 1;
|
||||
// int aNbUIntervals = aUKnots->Length() - 1;
|
||||
// double aTol = myTolerance/aNbUIntervals;
|
||||
double aTol = myTolerance;
|
||||
|
||||
@@ -116,23 +115,23 @@ bool BRepGProp_TFunction::Value(const double X, double& F)
|
||||
// else
|
||||
// aTol = 0.1;
|
||||
|
||||
int iU = anUKnots->Upper();
|
||||
int iU = aUKnots->Upper();
|
||||
int aNbPntsStart;
|
||||
int aNbMaxIter = 1000;
|
||||
math_KronrodSingleIntegration anIntegral;
|
||||
double aLocalErr = 0.;
|
||||
|
||||
i = anUKnots->Lower();
|
||||
i = aUKnots->Lower();
|
||||
F = 0.;
|
||||
|
||||
// Epmirical criterion
|
||||
aNbPntsStart = std::min(15, mySurface.UIntegrationOrder() / (anUKnots->Length() - 1) + 1);
|
||||
aNbPntsStart = std::min(15, mySurface.UIntegrationOrder() / (aUKnots->Length() - 1) + 1);
|
||||
aNbPntsStart = std::max(5, aNbPntsStart);
|
||||
|
||||
while (i < iU)
|
||||
{
|
||||
double aU1 = anUKnots->Value(i++);
|
||||
double aU2 = anUKnots->Value(i);
|
||||
double aU1 = aUKnots->Value(i++);
|
||||
double aU2 = aUKnots->Value(i);
|
||||
|
||||
if (aU2 - aU1 < tolU)
|
||||
continue;
|
||||
|
||||
@@ -354,10 +354,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface,
|
||||
aTMax = theSurface.LastParameter();
|
||||
|
||||
// Get the spans on the curve.
|
||||
occ::handle<NCollection_HArray1<double>> aTKnots;
|
||||
BRepGProp_TFunction aTFunc(theSurface, loc, IsByPoint, theCoeffs, aUMin, aCrvTol);
|
||||
|
||||
theSurface.GetTKnots(aTMin, aTMax, aTKnots);
|
||||
occ::handle<NCollection_HArray1<double>> aTKnots = theSurface.GetTKnots(aTMin, aTMax);
|
||||
|
||||
int iU = aTKnots->Upper();
|
||||
int aNbTIntervals = aTKnots->Length() - 1;
|
||||
|
||||
Reference in New Issue
Block a user