Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
50efeb1
0033787: Refactor Geom_UndefinedValue exception handling to boolean r…
claude Nov 6, 2025
94e170d
Fix exception handling: eliminate all Geom_UndefinedValue throws
claude Nov 6, 2025
1663cfa
Improve DN error handling: return base surface derivative instead of …
claude Nov 6, 2025
14659f0
Add comprehensive error handling documentation
claude Nov 6, 2025
47a541e
Refactor GeomEvaluator surface API to use std::optional return values
claude Nov 6, 2025
4010e68
Update Geom surface classes to handle std::optional return values fro…
claude Nov 6, 2025
823682a
Refactor surface API to return std::optional and move result structur…
claude Nov 6, 2025
a318570
Add dual API: keep deprecated void methods alongside new std::optiona…
claude Nov 6, 2025
2ee3282
Complete dual API for Geom_SurfaceOfRevolution and Geom_SurfaceOfLine…
claude Nov 6, 2025
a5720ef
Fix API architecture: reverse which methods are pure virtual
claude Nov 6, 2025
e7e67c4
Fix architecture: std::optional pure virtual, void non-virtual calls …
claude Nov 6, 2025
af502ef
Refactor Geom surface API: add std::optional return values (part 1/3)
claude Nov 6, 2025
c5a94b0
Refactor Geom surface API: add std::optional return values (part 2/3)
claude Nov 6, 2025
9fd5376
WIP: Start Geom_BezierSurface std::optional refactoring
claude Nov 6, 2025
6c03be3
Add non-virtual wrapper methods to Geom_Surface base class
claude Nov 6, 2025
61efc22
Remove void method duplicates from derived surface classes
claude Nov 6, 2025
79e2765
Fix critical bugs found in code review
claude Nov 6, 2025
2ea2c08
Fix surface headers: update D0/D1/D2/D3/DN declarations to std::optional
claude Nov 6, 2025
4bfe420
Remove duplicate DN declaration to fix C++ overload ambiguity
claude Nov 6, 2025
a13d8e6
Fix name hiding and remove duplicate DN wrapper
claude Nov 6, 2025
3da082c
Remove deprecated void methods from elementary surface headers
claude Nov 6, 2025
a507b05
Fix RectangularTrimmedSurface header: update to std::optional declara…
claude Nov 6, 2025
1a560aa
Remove duplicate wrapper method implementations from Geom_Surface.cxx
claude Nov 6, 2025
bae5541
Fix GeomAdaptor_Surface to use new std::optional API
claude Nov 6, 2025
5e276e2
Fix GeomEvaluator_OffsetSurface to handle std::optional DN() returns
claude Nov 7, 2025
33c5810
Fix remaining DN() calls in GeomEvaluator_OffsetSurface
claude Nov 7, 2025
d87ee16
Fix D1/D2/D3 calls in GeomEvaluator_OffsetSurface and DN in GeomLProp…
claude Nov 7, 2025
66f0a1e
Add missing Geom_BezierSurface method implementations
claude Nov 7, 2025
68e0561
Fix GeomPlate_Surface to use new std::optional API
claude Nov 7, 2025
f327708
Fix GeomPlate callers to use new std::optional API
claude Nov 7, 2025
93f5834
Fix D0/D1/D2 calls in TKGeomAlgo/GeomFill to use new std::optional API
claude Nov 7, 2025
14d2e4e
Fix GeomFill_FunctionGuide: revert GeomFill_SectionLaw::D0 call to bo…
claude Nov 8, 2025
5f77d87
Revert GeomFill_Pipe.cxx: Geom_Curve still uses void-based API
claude Nov 8, 2025
e148f26
Revert GeomFill_SectionPlacement and GeomFill_Sweep: LocationLaw uses…
claude Nov 8, 2025
19eb782
Fix NLPlate_NLPlate to use new std::optional API for Geom_Surface
claude Nov 8, 2025
012cbcc
Update ShapeExtend_CompositeSurface to use new std::optional API
claude Nov 8, 2025
711220e
Fix ShapeCustom_Surface to use new std::optional API for Geom_Surface…
claude Nov 8, 2025
9a43553
Fix ShapeCustom_SweptToElementary to use new std::optional API for Ge…
claude Nov 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 66 additions & 48 deletions src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Darboux.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ static gp_Vec DDeriv(const gp_Vec& F, const gp_Vec& DF, const gp_Vec& D2F)
//=======================================================================
// function : NormalD0
// purpose : computes Normal to Surface
// @return Standard_True if calculation is successful, Standard_False otherwise
//=======================================================================
static void NormalD0(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
Standard_Integer& OrderU,
Standard_Integer& OrderV)
static Standard_Boolean NormalD0(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
Standard_Integer& OrderU,
Standard_Integer& OrderV)
{
// gp_Vec D1U,D1V,D2U,D2V,DUV;
gp_Vec D1U, D1V;
Expand All @@ -75,7 +76,7 @@ static void NormalD0(const Standard_Real U,
OrderU = OrderV = 0;
#ifdef CHECK
if (Cont == GeomAbs_C0)
throw Geom_UndefinedValue();
return Standard_False;
#endif
gp_Pnt P;
Surf->D1(U, V, P, D1U, D1V);
Expand All @@ -87,7 +88,7 @@ static void NormalD0(const Standard_Real U,
{
if (Cont == GeomAbs_C0 || Cont == GeomAbs_C1)
{
throw Geom_UndefinedValue();
return Standard_False;
}
Standard_Integer MaxOrder = 3;
TColgp_Array2OfVec DerNUV(0, MaxOrder, 0, MaxOrder);
Expand Down Expand Up @@ -140,21 +141,23 @@ static void NormalD0(const Standard_Real U,
<< DerSurf(i, j).Y() << "," << DerSurf(i, j).Z() << std::endl;
}
#endif
throw Geom_UndefinedValue();
return Standard_False;
}
}
return Standard_True;
}

//=======================================================================
// function : NormalD1
// purpose : computes Normal to Surface and its first derivative
// @return Standard_True if calculation is successful, Standard_False otherwise
//=======================================================================
static void NormalD1(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
gp_Vec& D1UNormal,
gp_Vec& D1VNormal)
static Standard_Boolean NormalD1(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
gp_Vec& D1UNormal,
gp_Vec& D1VNormal)
{
#ifdef CHECK
GeomAbs_Shape Cont = (Surf->Surface().UContinuity() < Surf->Surface().VContinuity())
Expand Down Expand Up @@ -220,25 +223,27 @@ static void NormalD1(const Standard_Real U,
OrderU,
OrderV);
if (NStatus != CSLib_Defined)
throw Geom_UndefinedValue();
return Standard_False;

D1UNormal = CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV);
D1VNormal = CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV);
return Standard_True;
}

//=======================================================================
// function : NormalD2
// purpose : computes Normal to Surface and its first and second derivatives
// @return Standard_True if calculation is successful, Standard_False otherwise
//=======================================================================
static void NormalD2(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
gp_Vec& D1UNormal,
gp_Vec& D1VNormal,
gp_Vec& D2UNormal,
gp_Vec& D2VNormal,
gp_Vec& D2UVNormal)
static Standard_Boolean NormalD2(const Standard_Real U,
const Standard_Real V,
const Handle(Adaptor3d_Surface)& Surf,
gp_Dir& Normal,
gp_Vec& D1UNormal,
gp_Vec& D1VNormal,
gp_Vec& D2UNormal,
gp_Vec& D2VNormal,
gp_Vec& D2UVNormal)
{
#ifdef CHECK
GeomAbs_Shape Cont = (Surf->Surface().UContinuity() < Surf->Surface().VContinuity())
Expand Down Expand Up @@ -309,13 +314,14 @@ static void NormalD2(const Standard_Real U,
OrderU,
OrderV);
if (NStatus != CSLib_Defined)
throw Geom_UndefinedValue();
return Standard_False;

D1UNormal = CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV);
D1VNormal = CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV);
D2UNormal = CSLib::DNNormal(2, 0, DerNUV, OrderU, OrderV);
D2VNormal = CSLib::DNNormal(0, 2, DerNUV, OrderU, OrderV);
D2UVNormal = CSLib::DNNormal(1, 1, DerNUV, OrderU, OrderV);
return Standard_True;
}

GeomFill_Darboux::GeomFill_Darboux() {}
Expand Down Expand Up @@ -346,7 +352,8 @@ Standard_Boolean GeomFill_Darboux::D0(const Standard_Real Param,

// Normal = dS_du.Crossed(dS_dv).Normalized();
gp_Dir NormalDir;
NormalD0(C2d.X(), C2d.Y(), mySupport, NormalDir, OrderU, OrderV);
if (!NormalD0(C2d.X(), C2d.Y(), mySupport, NormalDir, OrderU, OrderV))
return Standard_False;
BiNormal.SetXYZ(NormalDir.XYZ());

mySupport->D1(C2d.X(), C2d.Y(), S, dS_du, dS_dv);
Expand Down Expand Up @@ -393,7 +400,8 @@ Standard_Boolean GeomFill_Darboux::D1(const Standard_Real Param,

gp_Dir NormalDir;
gp_Vec D1UNormal, D1VNormal;
NormalD1(C2d.X(), C2d.Y(), mySupport, NormalDir, D1UNormal, D1VNormal);
if (!NormalD1(C2d.X(), C2d.Y(), mySupport, NormalDir, D1UNormal, D1VNormal))
return Standard_False;
BiNormal.SetXYZ(NormalDir.XYZ());
DBiNormal = D1UNormal * D2d.X() + D1VNormal * D2d.Y();

Expand Down Expand Up @@ -459,15 +467,16 @@ Standard_Boolean GeomFill_Darboux::D2(const Standard_Real Param,

gp_Dir NormalDir;
gp_Vec D1UNormal, D1VNormal, D2UNormal, D2VNormal, D2UVNormal;
NormalD2(C2d.X(),
C2d.Y(),
mySupport,
NormalDir,
D1UNormal,
D1VNormal,
D2UNormal,
D2VNormal,
D2UVNormal);
if (!NormalD2(C2d.X(),
C2d.Y(),
mySupport,
NormalDir,
D1UNormal,
D1VNormal,
D2UNormal,
D2VNormal,
D2UVNormal))
return Standard_False;
BiNormal.SetXYZ(NormalDir.XYZ());
DBiNormal = D1UNormal * D2d.X() + D1VNormal * D2d.Y();
D2BiNormal = D1UNormal * D2_2d.X() + D1VNormal * D2_2d.Y() + D2UNormal * D2d.X() * D2d.X()
Expand Down Expand Up @@ -499,24 +508,33 @@ void GeomFill_Darboux::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, gp_Vec&
ATangent = gp_Vec(0, 0, 0);
ANormal = gp_Vec(0, 0, 0);
ABiNormal = gp_Vec(0, 0, 0);
Standard_Real Step = (myTrimmed->LastParameter() - myTrimmed->FirstParameter()) / Num;
Standard_Real Param;
Standard_Real Step = (myTrimmed->LastParameter() - myTrimmed->FirstParameter()) / Num;
Standard_Real Param;
Standard_Integer aSuccessCount = 0;
for (Standard_Integer i = 0; i <= Num; i++)
{
Param = myTrimmed->FirstParameter() + i * Step;
if (Param > myTrimmed->LastParameter())
Param = myTrimmed->LastParameter();
D0(Param, T, N, BN);
ATangent += T;
ANormal += N;
ABiNormal += BN;
if (D0(Param, T, N, BN))
{
ATangent += T;
ANormal += N;
ABiNormal += BN;
aSuccessCount++;
}
// Skip samples where calculation failed
}
ATangent /= Num + 1;
ANormal /= Num + 1;

ATangent.Normalize();
ABiNormal = ATangent.Crossed(ANormal).Normalized();
ANormal = ABiNormal.Crossed(ATangent);
if (aSuccessCount > 0)
{
ATangent /= aSuccessCount;
ANormal /= aSuccessCount;

ATangent.Normalize();
ABiNormal = ATangent.Crossed(ANormal).Normalized();
ANormal = ABiNormal.Crossed(ATangent);
}
}

Standard_Boolean GeomFill_Darboux::IsConstant() const
Expand Down
4 changes: 0 additions & 4 deletions src/ModelingData/TKG3d/Geom/Geom_OffsetSurface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ GeomAbs_Shape Geom_OffsetSurface::Continuity() const

void Geom_OffsetSurface::D0(const Standard_Real U, const Standard_Real V, gp_Pnt& P) const
{
#ifdef CHECK
if (myBasisSurfContinuity == GeomAbs_C0)
throw Geom_UndefinedValue();
#endif
if (equivSurf.IsNull())
myEvaluator->D0(U, V, P);
else
Expand Down
6 changes: 5 additions & 1 deletion src/ModelingData/TKG3d/Geom/Geom_UndefinedValue.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
#include <Standard_SStream.hxx>
#include <Standard_DomainError.hxx>

class Geom_UndefinedValue;
//! @deprecated This exception class is deprecated and should not be used in new code.
//! Use boolean return values or output parameters to signal errors instead.
class Standard_DEPRECATED("Use boolean return values or output parameters instead of throwing exceptions")
Geom_UndefinedValue;
DEFINE_STANDARD_HANDLE(Geom_UndefinedValue, Standard_DomainError)

#if !defined No_Exception && !defined No_Geom_UndefinedValue
//! @deprecated This macro is deprecated. Use boolean return values instead.
#define Geom_UndefinedValue_Raise_if(CONDITION, MESSAGE) \
if (CONDITION) \
throw Geom_UndefinedValue(MESSAGE);
Expand Down
Loading
Loading