In Part:Geometry:

- Fixing Hyperbola classes to get CCW emulation (like Ellipse classes).

In Sketcher:
- The Sketcher representation deals with the right branch of the Hyperbola only.
- Solver model is: Center, Focus1 (focus of the right branch), minor radius (b).
- HyperbolicArcRangeToEndPoints code is the one of Ellipse <= Awaiting DeepSOIC help ;)
- ConstraintPointOnHyperbola solver constraint is now implemented and should be working.
- No InternalAligment constraints implemented yet.
This commit is contained in:
Abdullah Tahiri
2016-01-12 15:52:14 +01:00
committed by wmayer
parent e928e418ec
commit cb5981fceb
11 changed files with 478 additions and 65 deletions

View File

@@ -2103,15 +2103,86 @@ void GeomArcOfHyperbola::setAngleXU(double angle)
}
}
void GeomArcOfHyperbola::getRange(double& u, double& v) const
/*!
* \brief GeomArcOfHyperbola::getMajorAxisDir
* \return the direction vector (unit-length) of major axis of the hyperbola. The
* direction also points to the first focus.
*/
Base::Vector3d GeomArcOfHyperbola::getMajorAxisDir() const
{
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() );
assert(!c.IsNull());
gp_Dir xdir = c->XAxis().Direction();
return Base::Vector3d(xdir.X(), xdir.Y(), xdir.Z());
}
/*!
* \brief GeomArcOfHyperbola::setMajorAxisDir Rotates the hyperbola in its plane, so
* that its major 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 ellipse will be preserved. If the vector is not small,
* but its projection onto plane of the ellipse is small, an exception will be
* thrown.
*/
void GeomArcOfHyperbola::setMajorAxisDir(Base::Vector3d newdir)
{
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::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());
}
}
/*!
* \brief GeomArcOfHyperbola::isReversedInXY tests if an arc that lies in XY plane is reversed
* (i.e. drawn from startpoint to endpoint in CW direction instead of CCW.)
* \return Returns True if the arc is CW and false if CCW.
*/
bool GeomArcOfHyperbola::isReversedInXY() const
{
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() );
assert(!c.IsNull());
return c->Axis().Direction().Z() < 0;
}
void GeomArcOfHyperbola::getRange(double& u, double& v, bool emulateCCWXY) const
{
u = myCurve->FirstParameter();
v = myCurve->LastParameter();
if(emulateCCWXY){
if(isReversedInXY()){
std::swap(u,v);
u = -u; v = -v;
if (v < u)
v += 2*M_PI;
if (v-u > 2*M_PI)
v -= 2*M_PI;
}
}
}
void GeomArcOfHyperbola::setRange(double u, double v)
void GeomArcOfHyperbola::setRange(double u, double v, bool emulateCCWXY)
{
try {
if(emulateCCWXY){
if(isReversedInXY()){
std::swap(u,v);
u = -u; v = -v;
}
}
myCurve->SetTrim(u, v);
}
catch (Standard_Failure) {
@@ -2120,6 +2191,8 @@ void GeomArcOfHyperbola::setRange(double u, double v)
}
}
// Persistence implementer
unsigned int GeomArcOfHyperbola::getMemSize (void) const
{