Foundation Classes, gp - Add constexpr/noexcept constructors and standard direction enums (#803)

- Addition of `gp_Dir::D` and `gp_Dir2d::D` enums for standard directions (X, Y, Z, NX, NY, NZ)
- Constexpr/noexcept constructors for geometric primitives (circles, cones, cylinders, etc.)
- Enhanced axis placement classes with enum-based constructors
- Replacement of hardcoded direction values throughout the codebase
This commit is contained in:
Pasukhin Dmitry
2025-11-04 16:21:59 +00:00
committed by GitHub
parent 0763d96209
commit 2cc2bfdd27
203 changed files with 1169 additions and 793 deletions
@@ -367,38 +367,38 @@ TopoDS_Face BRepFill::Face(const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2)
if (Edge1.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge1, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge1, Face, f1, l1);
}
if (Edge2.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge2, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge2, Face, f1, l1);
}
if (Closed)
{
B.UpdateEdge(Edge3,
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
Face,
T);
}
else
{
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
}
// Set the non parameter flag;
@@ -608,38 +608,38 @@ TopoDS_Shell BRepFill::Shell(const TopoDS_Wire& Wire1, const TopoDS_Wire& Wire2)
if (Edge1.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge1, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge1, Face, f1, l1);
}
if (Edge2.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge2, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge2, Face, f1, l1);
}
if (Periodic)
{
B.UpdateEdge(Edge3,
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
Face,
T);
}
else
{
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
}
// Set the non parameter flag;
@@ -682,7 +682,7 @@ void BRepFill_Evolved::ElementaryPerform(const TopoDS_Face& Sp,
TColStd_SequenceOfReal EmptySeqOfReal;
// mark of the profile.
gp_Ax3 AxeRef(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.), gp_Dir(1., 0., 0.));
gp_Ax3 AxeRef(gp_Pnt(0., 0., 0.), gp_Dir(gp_Dir::D::Z), gp_Dir(gp_Dir::D::X));
//---------------------------------------------------------------
// Construction of revolutions and tubes.
@@ -2446,7 +2446,7 @@ TopLoc_Location BRepFill_Evolved::FindLocation(const TopoDS_Face& Face) const
gp_Ax3 Axis = P->Position();
gp_Trsf T;
gp_Ax3 AxeRef(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.), gp_Dir(1., 0., 0.));
gp_Ax3 AxeRef(gp_Pnt(0., 0., 0.), gp_Dir(gp_Dir::D::Z), gp_Dir(gp_Dir::D::X));
T.SetTransformation(AxeRef, Axis);
return TopLoc_Location(T);
@@ -983,23 +983,23 @@ void BRepFill_Generator::Perform()
{
if (Edge1.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge1, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge1, new Geom2d_Line(gp_Pnt2d(0, f2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge1, Face, f1, l1);
}
if (Edge2.Orientation() == TopAbs_REVERSED)
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(-1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::NX)), Face, T);
B.Range(Edge2, Face, -l1, -f1);
}
else
{
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(1, 0)), Face, T);
B.UpdateEdge(Edge2, new Geom2d_Line(gp_Pnt2d(0, l2), gp_Dir2d(gp_Dir2d::D::X)), Face, T);
B.Range(Edge2, Face, f1, l1);
}
}
@@ -1009,15 +1009,15 @@ void BRepFill_Generator::Perform()
if (Periodic)
{
B.UpdateEdge(Edge3,
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)),
new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)),
Face,
T);
}
else
{
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(0, 1)), Face, T);
B.UpdateEdge(Edge3, new Geom2d_Line(gp_Pnt2d(f1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
B.UpdateEdge(Edge4, new Geom2d_Line(gp_Pnt2d(l1, 0), gp_Dir2d(gp_Dir2d::D::Y)), Face, T);
}
}
else
@@ -63,7 +63,7 @@ BRepFill_ShapeLaw::BRepFill_ShapeLaw(const TopoDS_Vertex& V, const Standard_Bool
{
myLaws = new (GeomFill_HArray1OfSectionLaw)(1, 1);
// gp_Pnt Origine;
gp_Dir D(1, 0, 0); // Following the normal
gp_Dir D(gp_Dir::D::X); // Following the normal
Handle(Geom_Line) L = new (Geom_Line)(BRep_Tool::Pnt(V), D);
Standard_Real Last = 2 * BRep_Tool::Tolerance(V) + Precision::PConfusion();
Handle(Geom_TrimmedCurve) TC = new (Geom_TrimmedCurve)(L, 0, Last);
@@ -216,7 +216,7 @@ TopTools_ListOfShape& losplits)
Vl.Orientation(oriVsup); BB.Add(Esup2pi,Vl); BT.Parameter(Esup2pi,Vl,pl);
gp_Pnt2d tmp = PC->Value(pf); Standard_Real v = tmp.Y();
Handle(Geom2d_Line) L2d =
new Geom2d_Line(gp_Pnt2d(-paronE,v),gp_Dir2d(1.,0.));
new Geom2d_Line(gp_Pnt2d(-paronE,v),gp_Dir2d(gp_Dir2d::D::X));
Handle(Geom2d_TrimmedCurve) PCsup2pi = new Geom2d_TrimmedCurve(L2d,paronE,pl);
TopOpeBRepDS_SetThePCurve(BB,Esup2pi,F,oriE,PCsup2pi);
@@ -593,9 +593,9 @@ void TopOpeBRepBuild_WireEdgeSet::IsUVISO(const TopoDS_Edge& E,
const gp_Dir2d& D = HL->Direction();
Standard_Real tol = Precision::Angular();
if (D.IsParallel(gp_Dir2d(0., 1.), tol))
if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::Y), tol))
uiso = Standard_True;
else if (D.IsParallel(gp_Dir2d(1., 0.), tol))
else if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::X), tol))
viso = Standard_True;
}
}
@@ -608,9 +608,9 @@ Standard_Boolean FUN_makeUisoLineOnSphe(const TopoDS_Face& F, // with geometry t
Standard_Boolean isvgrowing = (vsup - vinf > -tol);
gp_Dir2d vdir;
if (isvgrowing)
vdir = gp_Dir2d(0, 1);
vdir = gp_Dir2d(gp_Dir2d::D::Y);
else
vdir = gp_Dir2d(0, -1);
vdir = gp_Dir2d(gp_Dir2d::D::NY);
gp_Pnt2d origin(uinf, vinf);
origin.Translate(gp_Vec2d(vdir).Scaled(p3df - par3dinf));
@@ -130,11 +130,11 @@ Standard_EXPORT void FUN_ComputeGeomData(const TopoDS_Shape& F,
Standard_Real x = D1.X(), y = D1.Y(), z = D1.Z(), tol = Precision::Confusion();
Standard_Boolean nullx = (Abs(x) < tol), nully = (Abs(y) < tol), nullz = (Abs(z) < tol);
if (nullx && nully)
D2 = gp_Dir(1, 0, 0);
D2 = gp_Dir(gp_Dir::D::X);
else if (nullx && nullz)
D2 = gp_Dir(1, 0, 0);
D2 = gp_Dir(gp_Dir::D::X);
else if (nully && nullz)
D2 = gp_Dir(0, 1, 0);
D2 = gp_Dir(gp_Dir::D::Y);
else
D2 = gp_Dir(y * z, x * z, -2. * x * y);
}
@@ -1020,7 +1020,7 @@ Handle(Geom2d_Curve) TopOpeBRepTool_CurveTool::MakePCurveOnFace(const TopoDS_Sha
gp_Pnt2d po(0, -M_PI / 2);
if (maxcond)
po.SetY(M_PI / 2);
aTrsf.SetMirror(gp_Ax2d(po, gp_Dir2d(1, 0)));
aTrsf.SetMirror(gp_Ax2d(po, gp_Dir2d(gp_Dir2d::D::X)));
PCT->Transform(aTrsf);
// add translation along U direction on PI
gp_Vec2d vec(M_PI, 0);
@@ -172,7 +172,7 @@ Standard_EXPORT gp_Dir FUN_tool_ngS(const gp_Pnt2d& p2d, const Handle(Geom_Surfa
#ifdef OCCT_DEBUG
std::cout << "FUN_tool_nggeomF NYI" << std::endl;
#endif
return gp_Dir(0, 0, 1);
return gp_Dir(gp_Dir::D::Z);
}
gp_Dir udir(d1u);
@@ -331,9 +331,9 @@ Standard_Real TopOpeBRepTool_ShapeTool::PeriodizeParameter(const Standard_Real p
Standard_Real tol = Precision::Angular();
Standard_Boolean isoU = Standard_False, isoV = Standard_False;
if (D.IsParallel(gp_Dir2d(0., 1.), tol))
if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::Y), tol))
isoU = Standard_True;
else if (D.IsParallel(gp_Dir2d(1., 0.), tol))
else if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::X), tol))
isoV = Standard_True;
if (isoU)
{
@@ -52,7 +52,7 @@ Standard_EXPORT gp_Dir2d FUN_tool_nC2dINSIDES(const gp_Dir2d& tgC2d)
// X = (tgC2d,0),Y = (xx,0),Z =(0,0,1)
// ------------------------------------------------------------
gp_Dir X, Y, Z;
Z = gp_Dir(0., 0., 1.);
Z = gp_Dir(gp_Dir::D::Z);
X = gp_Dir(tgC2d.X(), tgC2d.Y(), 0.);
Y = Z ^ X;
gp_Dir2d xx(Y.X(), Y.Y());