mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-06 12:57:35 +08:00
Replace two-step initialization (default constructor + Initialize) with direct construction for 8 non-copyable/non-movable property and grid evaluator classes. Objects are now always in a valid state after construction. Refactored classes: - GeomProp_Curve, GeomProp_Surface (TKG3d) - Geom2dProp_Curve (TKG2d) - BRepProp_Curve, BRepProp_Surface (TKBRep) - GeomGridEval_Curve, GeomGridEval_Surface (TKG3d) - Geom2dGridEval_Curve (TKG2d) Changes per class: - Remove default constructor and IsInitialized() method. - Add constructors matching each former Initialize overload. - Rename Initialize to protected initialization method for internal and derived class use. All callers updated across production code (Extrema, BndLib, IntCurveSurface, IntPatch, HLRBRep, GeomGridEval derived classes) and test files to use constructor-based initialization.
116 lines
3.8 KiB
C++
116 lines
3.8 KiB
C++
// Copyright (c) 2025 OPEN CASCADE SAS
|
|
//
|
|
// This file is part of Open CASCADE Technology software library.
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify it under
|
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
// by the Free Software Foundation, with special exception defined in the file
|
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
// distribution for complete text of the license and disclaimer of any warranty.
|
|
//
|
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
// commercial license or contractual agreement.
|
|
|
|
#include <BRepProp_Surface.hxx>
|
|
|
|
#include <TopoDS_Face.hxx>
|
|
|
|
//==================================================================================================
|
|
|
|
BRepProp_Surface::BRepProp_Surface(const TopoDS_Face& theFace)
|
|
{
|
|
initialization(theFace);
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
BRepProp_Surface::BRepProp_Surface(const BRepAdaptor_Surface& theSurface)
|
|
{
|
|
initialization(theSurface);
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
BRepProp_Surface::BRepProp_Surface(const occ::handle<BRepAdaptor_Surface>& theSurface)
|
|
{
|
|
initialization(theSurface);
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
void BRepProp_Surface::initialization(const TopoDS_Face& theFace)
|
|
{
|
|
if (theFace.IsNull())
|
|
{
|
|
myOwned.Nullify();
|
|
myPtr = nullptr;
|
|
return;
|
|
}
|
|
myOwned = new BRepAdaptor_Surface(theFace);
|
|
myPtr = myOwned.get();
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
void BRepProp_Surface::initialization(const BRepAdaptor_Surface& theSurface)
|
|
{
|
|
myOwned.Nullify();
|
|
myPtr = &theSurface;
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
void BRepProp_Surface::initialization(const occ::handle<BRepAdaptor_Surface>& theSurface)
|
|
{
|
|
myOwned = theSurface;
|
|
myPtr = myOwned.get();
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
GeomProp::SurfaceNormalResult BRepProp_Surface::Normal(const double theU,
|
|
const double theV,
|
|
const double theTol) const
|
|
{
|
|
if (myPtr == nullptr)
|
|
{
|
|
return {{}, false};
|
|
}
|
|
gp_Pnt aPnt;
|
|
gp_Vec aD1U, aD1V;
|
|
myPtr->D1(theU, theV, aPnt, aD1U, aD1V);
|
|
return GeomProp::ComputeSurfaceNormal(aD1U, aD1V, theTol);
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
GeomProp::SurfaceCurvatureResult BRepProp_Surface::Curvatures(const double theU,
|
|
const double theV,
|
|
const double theTol) const
|
|
{
|
|
if (myPtr == nullptr)
|
|
{
|
|
return {};
|
|
}
|
|
gp_Pnt aPnt;
|
|
gp_Vec aD1U, aD1V, aD2U, aD2V, aD2UV;
|
|
myPtr->D2(theU, theV, aPnt, aD1U, aD1V, aD2U, aD2V, aD2UV);
|
|
return GeomProp::ComputeSurfaceCurvatures(aD1U, aD1V, aD2U, aD2V, aD2UV, theTol);
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
GeomProp::MeanGaussianResult BRepProp_Surface::MeanGaussian(const double theU,
|
|
const double theV,
|
|
const double theTol) const
|
|
{
|
|
if (myPtr == nullptr)
|
|
{
|
|
return {};
|
|
}
|
|
gp_Pnt aPnt;
|
|
gp_Vec aD1U, aD1V, aD2U, aD2V, aD2UV;
|
|
myPtr->D2(theU, theV, aPnt, aD1U, aD1V, aD2U, aD2V, aD2UV);
|
|
return GeomProp::ComputeMeanGaussian(aD1U, aD1V, aD2U, aD2V, aD2UV, theTol);
|
|
}
|