Part: ArcOfParabola extension to set the symmetry axis
This commit is contained in:
parent
8c83f4142b
commit
579cbb280b
|
@ -2322,6 +2322,49 @@ void GeomArcOfParabola::setFocal(double length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GeomArcOfParabola::getXAxisDir
|
||||||
|
* \return the direction vector (unit-length) of symmetry axis of the parabola. The
|
||||||
|
* direction also points to the focus.
|
||||||
|
*/
|
||||||
|
Base::Vector3d GeomArcOfParabola::getXAxisDir() const
|
||||||
|
{
|
||||||
|
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast( myCurve->BasisCurve() );
|
||||||
|
assert(!c.IsNull());
|
||||||
|
gp_Dir xdir = c->XAxis().Direction();
|
||||||
|
return Base::Vector3d(xdir.X(), xdir.Y(), xdir.Z());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GeomArcOfParabola::setXAxisDir Rotates the parabola in its plane, so
|
||||||
|
* that its symmetry axis is as close as possible to the provided direction.
|
||||||
|
* \param newdir [in] is the new direction. If the vector is small, the
|
||||||
|
* orientation of the parabola will be preserved. If the vector is not small,
|
||||||
|
* but its projection onto plane of the parabola is small, an exception will be
|
||||||
|
* thrown.
|
||||||
|
*/
|
||||||
|
void GeomArcOfParabola::setXAxisDir(Base::Vector3d newdir)
|
||||||
|
{
|
||||||
|
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast( myCurve->BasisCurve() );
|
||||||
|
assert(!c.IsNull());
|
||||||
|
#if OCC_VERSION_HEX >= 0x060504
|
||||||
|
if (newdir.Sqr() < Precision::SquareConfusion())
|
||||||
|
#else
|
||||||
|
if (newdir.Length() < Precision::Confusion())
|
||||||
|
#endif
|
||||||
|
return;//zero vector was passed. Keep the old orientation.
|
||||||
|
|
||||||
|
try {
|
||||||
|
gp_Ax2 pos = c->Position();
|
||||||
|
pos.SetXDirection(gp_Dir(newdir.x, newdir.y, newdir.z));//OCC should keep the old main Direction (Z), and change YDirection to accomodate the new XDirection.
|
||||||
|
c->SetPosition(pos);
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||||
|
throw Base::Exception(e->GetMessageString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Base::Vector3d GeomArcOfParabola::getFocus(void) const
|
Base::Vector3d GeomArcOfParabola::getFocus(void) const
|
||||||
{
|
{
|
||||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||||
|
|
|
@ -497,6 +497,9 @@ public:
|
||||||
double getFocal(void) const;
|
double getFocal(void) const;
|
||||||
void setFocal(double length);
|
void setFocal(double length);
|
||||||
|
|
||||||
|
Base::Vector3d getXAxisDir() const;
|
||||||
|
void setXAxisDir(Base::Vector3d newdir);
|
||||||
|
|
||||||
Base::Vector3d getFocus(void) const;
|
Base::Vector3d getFocus(void) const;
|
||||||
|
|
||||||
virtual void getRange(double& u, double& v, bool emulateCCWXY) const;
|
virtual void getRange(double& u, double& v, bool emulateCCWXY) const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user