Sketcher: Fix: Arc of Hyperbola (#27656)
* Sketcher: Fix: Arc of Hyperbola
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added minor grater than major radius support
* Fixed merge errors
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Improved comments and added a confused points check for S1 and S2 distance.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added compile check for occ version and check before getting minor radius.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Apply suggestions from code review
OCC version check
Co-authored-by: Chris Hennes <[email protected]>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Hennes <[email protected]>
(cherry picked from commit 9abe7b4af1)
This commit is contained in:
committed by
github-actions[bot]
parent
35ef0a3fd3
commit
de275eba0c
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <GC_MakeHyperbola.hxx>
|
||||
#include <Geom_Hyperbola.hxx>
|
||||
|
||||
#include <Standard_Version.hxx>
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/PyWrapParseTupleAndKeywords.h>
|
||||
@@ -97,11 +97,39 @@ int HyperbolaPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
|
||||
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
|
||||
Base::Vector3d v3 = static_cast<Base::VectorPy*>(pV3)->value();
|
||||
|
||||
|
||||
#if OCC_VERSION_HEX < 0x080000
|
||||
// This is a workaround do to fault in OCCT.
|
||||
// It is fixed in OCCT 8.0.0,
|
||||
gp_Pnt S1(v1.x, v1.y, v1.z);
|
||||
gp_Pnt S2(v2.x, v2.y, v2.z);
|
||||
gp_Pnt Center(v3.x, v3.y, v3.z);
|
||||
|
||||
if (S1.Distance(Center) < gp::Resolution() || S2.Distance(Center) < gp::Resolution()
|
||||
|| S1.Distance(S2) < gp::Resolution()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(gce_ConfusedPoints));
|
||||
return -1;
|
||||
}
|
||||
|
||||
gp_Dir XAxis(S1.XYZ() - Center.XYZ());
|
||||
gp_Lin centerLine(Center, XAxis);
|
||||
double majorRadius = S1.Distance(Center);
|
||||
double minorRadius = centerLine.Distance(S2);
|
||||
if (minorRadius < gp::Resolution()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(gce_ColinearPoints));
|
||||
return -1;
|
||||
}
|
||||
gp_Dir norm(XAxis.Crossed(gp_Dir(S2.XYZ() - Center.XYZ())));
|
||||
GC_MakeHyperbola me(gp_Ax2(Center, norm, XAxis), majorRadius, minorRadius);
|
||||
#else
|
||||
GC_MakeHyperbola me(
|
||||
gp_Pnt(v1.x, v1.y, v1.z),
|
||||
gp_Pnt(v2.x, v2.y, v2.z),
|
||||
gp_Pnt(v3.x, v3.y, v3.z)
|
||||
);
|
||||
#endif
|
||||
|
||||
if (!me.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(me.Status()));
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user