add class GeomArcOfConic to reduce code duplication
This commit is contained in:
@@ -780,6 +780,162 @@ bool GeomConic::isReversed() const
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomArcOfConic,Part::GeomCurve)
|
||||
|
||||
GeomArcOfConic::GeomArcOfConic()
|
||||
{
|
||||
}
|
||||
|
||||
GeomArcOfConic::~GeomArcOfConic()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfConic::getStartPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return XYZ of the arc's starting point.
|
||||
*/
|
||||
Base::Vector3d GeomArcOfConic::getStartPoint(bool emulateCCWXY) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
gp_Pnt pnt = curve->StartPoint();
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed())
|
||||
pnt = curve->EndPoint();
|
||||
}
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfConic::getEndPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return
|
||||
*/
|
||||
Base::Vector3d GeomArcOfConic::getEndPoint(bool emulateCCWXY) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
gp_Pnt pnt = curve->EndPoint();
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed())
|
||||
pnt = curve->StartPoint();
|
||||
}
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfConic::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
gp_Ax1 axis = conic->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfConic::getLocation(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
gp_Ax1 axis = conic->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomArcOfConic::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
|
||||
try {
|
||||
conic->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
void GeomArcOfConic::setLocation(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
|
||||
try {
|
||||
conic->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfConic::isReversed
|
||||
* \return tests if an arc that lies in XY plane is reversed (i.e. drawn from
|
||||
* startpoint to endpoint in CW direction instead of CCW.). Returns True if the
|
||||
* arc is CW and false if CCW.
|
||||
*/
|
||||
bool GeomArcOfConic::isReversed() const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
assert(!conic.IsNull());
|
||||
return conic->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfConic::getAngleXU
|
||||
* \return The angle between ellipse's major axis (in direction to focus1) and
|
||||
* X axis of a default axis system in the plane of ellipse. The angle is
|
||||
* counted CCW as seen when looking at the ellipse so that ellipse's axis is
|
||||
* pointing at you. Note that this function may give unexpected results when
|
||||
* the ellipse is in XY, but reversed, because the X axis of the default axis
|
||||
* system is reversed compared to the global X axis. This angle, in conjunction
|
||||
* with ellipse's axis, fully defines the orientation of the ellipse.
|
||||
*/
|
||||
double GeomArcOfConic::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
|
||||
gp_Pnt center = conic->Axis().Location();
|
||||
gp_Dir normal = conic->Axis().Direction();
|
||||
gp_Dir xdir = conic->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return -xdir.AngleWithRef(xdirref.XDirection(),normal);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfConic::setAngleXU complements getAngleXU.
|
||||
*/
|
||||
void GeomArcOfConic::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
|
||||
try {
|
||||
gp_Pnt center = conic->Axis().Location();
|
||||
gp_Dir normal = conic->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
conic->SetPosition(xdirref);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomCircle,Part::GeomConic)
|
||||
|
||||
GeomCircle::GeomCircle()
|
||||
@@ -897,7 +1053,7 @@ PyObject *GeomCircle::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfCircle,Part::GeomCurve)
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfCircle,Part::GeomArcOfConic)
|
||||
|
||||
GeomArcOfCircle::GeomArcOfCircle()
|
||||
{
|
||||
@@ -935,64 +1091,12 @@ Geometry *GeomArcOfCircle::clone(void) const
|
||||
return copy;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfCircle::getStartPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return XYZ of the arc's starting point.
|
||||
*/
|
||||
Base::Vector3d GeomArcOfCircle::getStartPoint(bool emulateCCWXY) const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->StartPoint();
|
||||
if(emulateCCWXY)
|
||||
if(isReversedInXY())
|
||||
pnt = this->myCurve->EndPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfCircle::getEndPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return
|
||||
*/
|
||||
Base::Vector3d GeomArcOfCircle::getEndPoint(bool emulateCCWXY) const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->EndPoint();
|
||||
if(emulateCCWXY)
|
||||
if(isReversedInXY())
|
||||
pnt = this->myCurve->StartPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfCircle::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
double GeomArcOfCircle::getRadius(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
return circle->Radius();
|
||||
}
|
||||
|
||||
void GeomArcOfCircle::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
circle->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
void GeomArcOfCircle::setRadius(double Radius)
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
@@ -1019,17 +1123,19 @@ void GeomArcOfCircle::setRadius(double Radius)
|
||||
*/
|
||||
void GeomArcOfCircle::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
{
|
||||
u = myCurve->FirstParameter();
|
||||
v = myCurve->LastParameter();
|
||||
if(emulateCCWXY){
|
||||
Handle_Geom_Circle cir = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
double angleXU = -cir->Position().XDirection().AngleWithRef(gp_Dir(1.0,0.0,0.0), gp_Dir(0.0,0.0,1.0));
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
u = curve->FirstParameter();
|
||||
v = curve->LastParameter();
|
||||
if (emulateCCWXY){
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
double angleXU = -conic->Position().XDirection().AngleWithRef(gp_Dir(1.0,0.0,0.0), gp_Dir(0.0,0.0,1.0));
|
||||
double u1 = u, v1 = v;//the true arc curve parameters, cached. u,v will contain the rotation-corrected and swapped angles.
|
||||
if(cir->Axis().Direction().Z() > 0.0){
|
||||
if (conic->Axis().Direction().Z() > 0.0){
|
||||
//normal CCW arc
|
||||
u = u1 + angleXU;
|
||||
v = v1 + angleXU;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//reversed (CW) arc
|
||||
u = angleXU - v1;
|
||||
v = angleXU - u1;
|
||||
@@ -1039,9 +1145,7 @@ void GeomArcOfCircle::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
v += 2*M_PI;
|
||||
if (v-u > 2*M_PI)
|
||||
v -= 2*M_PI;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1055,24 +1159,25 @@ void GeomArcOfCircle::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
*/
|
||||
void GeomArcOfCircle::setRange(double u, double v, bool emulateCCWXY)
|
||||
{
|
||||
|
||||
try {
|
||||
if(emulateCCWXY){
|
||||
Handle_Geom_Circle cir = Handle_Geom_Circle::DownCast(myCurve->BasisCurve());
|
||||
double angleXU = -cir->Position().XDirection().AngleWithRef(gp_Dir(1.0,0.0,0.0), gp_Dir(0.0,0.0,1.0));
|
||||
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
|
||||
if (emulateCCWXY){
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(curve->BasisCurve());
|
||||
double angleXU = -conic->Position().XDirection().AngleWithRef(gp_Dir(1.0,0.0,0.0), gp_Dir(0.0,0.0,1.0));
|
||||
double u1 = u, v1 = v;//the values that were passed, ccw angles from X axis. u,v will contain the rotation-corrected and swapped angles.
|
||||
if(cir->Axis().Direction().Z() > 0.0){
|
||||
if (conic->Axis().Direction().Z() > 0.0){
|
||||
//normal CCW arc
|
||||
u = u1 - angleXU;
|
||||
v = v1 - angleXU;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//reversed (CW) arc
|
||||
u = angleXU - v1;
|
||||
v = angleXU - u1;
|
||||
}
|
||||
}
|
||||
|
||||
myCurve->SetTrim(u, v);
|
||||
curve->SetTrim(u, v);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
@@ -1080,19 +1185,6 @@ void GeomArcOfCircle::setRange(double u, double v, bool emulateCCWXY)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfCircle::isReversedInXY
|
||||
* \return tests if an arc that lies in XY plane is reversed (i.e. drawn from
|
||||
* startpoint to endpoint in CW direction instead of CCW.). Returns True if the
|
||||
* arc is CW and false if CCW.
|
||||
*/
|
||||
bool GeomArcOfCircle::isReversedInXY() const
|
||||
{
|
||||
Handle_Geom_Circle c = Handle_Geom_Circle::DownCast( myCurve->BasisCurve() );
|
||||
assert(!c.IsNull());
|
||||
return c->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomArcOfCircle::getMemSize (void) const
|
||||
{
|
||||
@@ -1373,7 +1465,7 @@ void GeomEllipse::setHandle(const Handle_Geom_Ellipse &e)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfEllipse,Part::GeomCurve)
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfEllipse,Part::GeomArcOfConic)
|
||||
|
||||
GeomArcOfEllipse::GeomArcOfEllipse()
|
||||
{
|
||||
@@ -1411,59 +1503,6 @@ Geometry *GeomArcOfEllipse::clone(void) const
|
||||
return copy;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::getStartPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return XYZ of the arc's starting point.
|
||||
*/
|
||||
Base::Vector3d GeomArcOfEllipse::getStartPoint(bool emulateCCWXY) const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->StartPoint();
|
||||
if(emulateCCWXY)
|
||||
if(isReversedInXY())
|
||||
pnt = this->myCurve->EndPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::getEndPoint
|
||||
* \param emulateCCWXY: if true, the arc will pretent to be a CCW arc in XY plane.
|
||||
* For this to work, the arc must lie in XY plane (i.e. Axis is either +Z or -Z).
|
||||
* \return XYZ of the arc's starting point.
|
||||
*/
|
||||
Base::Vector3d GeomArcOfEllipse::getEndPoint(bool emulateCCWXY) const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->EndPoint();
|
||||
if(emulateCCWXY)
|
||||
if(isReversedInXY())
|
||||
pnt = this->myCurve->StartPoint();
|
||||
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfEllipse::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(myCurve->BasisCurve());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomArcOfEllipse::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
ellipse->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomArcOfEllipse::getMajorRadius(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(myCurve->BasisCurve());
|
||||
@@ -1502,56 +1541,6 @@ void GeomArcOfEllipse::setMinorRadius(double Radius)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::getAngleXU
|
||||
* \return The angle between ellipse's major axis (in direction to focus1) and
|
||||
* X axis of a default axis system in the plane of ellipse. The angle is
|
||||
* counted CCW as seen when looking at the ellipse so that ellipse's axis is
|
||||
* pointing at you. Note that this function may give unexpected results when
|
||||
* the ellipse is in XY, but reversed, because the X axis of the default axis
|
||||
* system is reversed compared to the global X axis. This angle, in conjunction
|
||||
* with ellipse's axis, fully defines the orientation of the ellipse.
|
||||
*/
|
||||
double GeomArcOfEllipse::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(myCurve->BasisCurve());
|
||||
|
||||
gp_Pnt center = ellipse->Axis().Location();
|
||||
gp_Dir normal = ellipse->Axis().Direction();
|
||||
gp_Dir xdir = ellipse->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return -xdir.AngleWithRef(xdirref.XDirection(),normal);
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::setAngleXU complements getAngleXU.
|
||||
*/
|
||||
void GeomArcOfEllipse::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
gp_Pnt center = ellipse->Axis().Location();
|
||||
gp_Dir normal = ellipse->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
ellipse->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::getMajorAxisDir
|
||||
* \return the direction vector (unit-length) of major axis of the ellipse. The
|
||||
@@ -1594,18 +1583,6 @@ void GeomArcOfEllipse::setMajorAxisDir(Base::Vector3d newdir)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::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 GeomArcOfEllipse::isReversedInXY() const
|
||||
{
|
||||
Handle_Geom_Ellipse c = Handle_Geom_Ellipse::DownCast( myCurve->BasisCurve() );
|
||||
assert(!c.IsNull());
|
||||
return c->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfEllipse::getRange
|
||||
* \param u [out] start angle of the arc, in radians.
|
||||
@@ -1617,8 +1594,8 @@ void GeomArcOfEllipse::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
{
|
||||
u = myCurve->FirstParameter();
|
||||
v = myCurve->LastParameter();
|
||||
if(emulateCCWXY){
|
||||
if(isReversedInXY()){
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed()) {
|
||||
std::swap(u,v);
|
||||
u = -u; v = -v;
|
||||
if (v < u)
|
||||
@@ -1639,8 +1616,8 @@ void GeomArcOfEllipse::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
void GeomArcOfEllipse::setRange(double u, double v, bool emulateCCWXY)
|
||||
{
|
||||
try {
|
||||
if(emulateCCWXY){
|
||||
if(isReversedInXY()){
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed()) {
|
||||
std::swap(u,v);
|
||||
u = -u; v = -v;
|
||||
}
|
||||
@@ -1751,7 +1728,6 @@ PyObject *GeomArcOfEllipse::getPyObject(void)
|
||||
return new ArcOfEllipsePy(static_cast<GeomArcOfEllipse*>(this->clone()));
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomHyperbola,Part::GeomConic)
|
||||
@@ -1903,7 +1879,7 @@ PyObject *GeomHyperbola::getPyObject(void)
|
||||
}
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfHyperbola,Part::GeomCurve)
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfHyperbola,Part::GeomArcOfConic)
|
||||
|
||||
GeomArcOfHyperbola::GeomArcOfHyperbola()
|
||||
{
|
||||
@@ -1942,40 +1918,6 @@ Geometry *GeomArcOfHyperbola::clone(void) const
|
||||
return copy;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfHyperbola::getStartPoint() const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->StartPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfHyperbola::getEndPoint() const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->EndPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfHyperbola::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
gp_Ax1 axis = h->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomArcOfHyperbola::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
h->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomArcOfHyperbola::getMajorRadius(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
@@ -2014,43 +1956,6 @@ void GeomArcOfHyperbola::setMinorRadius(double Radius)
|
||||
}
|
||||
}
|
||||
|
||||
double GeomArcOfHyperbola::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
gp_Pnt center = h->Axis().Location();
|
||||
gp_Dir normal = h->Axis().Direction();
|
||||
gp_Dir xdir = h->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return -xdir.AngleWithRef(xdirref.XDirection(),normal);
|
||||
|
||||
}
|
||||
|
||||
void GeomArcOfHyperbola::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
gp_Pnt center = h->Axis().Location();
|
||||
gp_Dir normal = h->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
h->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomArcOfHyperbola::getMajorAxisDir
|
||||
* \return the direction vector (unit-length) of major axis of the hyperbola. The
|
||||
@@ -2094,24 +1999,12 @@ void GeomArcOfHyperbola::setMajorAxisDir(Base::Vector3d newdir)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \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
|
||||
{
|
||||
try {
|
||||
if(emulateCCWXY){
|
||||
if(isReversedInXY()){
|
||||
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() );
|
||||
if (emulateCCWXY){
|
||||
if (isReversed()) {
|
||||
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
assert(!c.IsNull());
|
||||
c->Reverse();
|
||||
}
|
||||
@@ -2131,9 +2024,9 @@ void GeomArcOfHyperbola::setRange(double u, double v, bool emulateCCWXY)
|
||||
try {
|
||||
myCurve->SetTrim(u, v);
|
||||
|
||||
if(emulateCCWXY){
|
||||
if(isReversedInXY()){
|
||||
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() );
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed()) {
|
||||
Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast(myCurve->BasisCurve());
|
||||
assert(!c.IsNull());
|
||||
c->Reverse();
|
||||
}
|
||||
@@ -2145,8 +2038,6 @@ void GeomArcOfHyperbola::setRange(double u, double v, bool emulateCCWXY)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomArcOfHyperbola::getMemSize (void) const
|
||||
{
|
||||
@@ -2374,7 +2265,7 @@ PyObject *GeomParabola::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfParabola,Part::GeomCurve)
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfParabola,Part::GeomArcOfConic)
|
||||
|
||||
GeomArcOfParabola::GeomArcOfParabola()
|
||||
{
|
||||
@@ -2412,40 +2303,6 @@ Geometry *GeomArcOfParabola::clone(void) const
|
||||
return copy;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfParabola::getStartPoint() const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->StartPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfParabola::getEndPoint() const
|
||||
{
|
||||
gp_Pnt pnt = this->myCurve->EndPoint();
|
||||
return Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
}
|
||||
|
||||
Base::Vector3d GeomArcOfParabola::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
gp_Ax1 axis = p->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomArcOfParabola::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
try {
|
||||
p->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomArcOfParabola::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
@@ -2465,53 +2322,41 @@ void GeomArcOfParabola::setFocal(double length)
|
||||
}
|
||||
}
|
||||
|
||||
double GeomArcOfParabola::getAngleXU(void) const
|
||||
void GeomArcOfParabola::getRange(double& u, double& v, bool /*emulateCCWXY*/) const
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
gp_Pnt center = p->Axis().Location();
|
||||
gp_Dir normal = p->Axis().Direction();
|
||||
gp_Dir xdir = p->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return -xdir.AngleWithRef(xdirref.XDirection(),normal);
|
||||
|
||||
}
|
||||
|
||||
void GeomArcOfParabola::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
|
||||
#if 0
|
||||
try {
|
||||
gp_Pnt center = p->Axis().Location();
|
||||
gp_Dir normal = p->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
p->SetPosition(xdirref);
|
||||
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed()) {
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
assert(!c.IsNull());
|
||||
c->Reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GeomArcOfParabola::getRange(double& u, double& v) const
|
||||
{
|
||||
u = myCurve->FirstParameter();
|
||||
v = myCurve->LastParameter();
|
||||
}
|
||||
|
||||
void GeomArcOfParabola::setRange(double u, double v)
|
||||
void GeomArcOfParabola::setRange(double u, double v, bool /*emulateCCWXY*/)
|
||||
{
|
||||
try {
|
||||
myCurve->SetTrim(u, v);
|
||||
#if 0
|
||||
if (emulateCCWXY) {
|
||||
if (isReversed()) {
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast(myCurve->BasisCurve());
|
||||
assert(!c.IsNull());
|
||||
c->Reverse();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
||||
Reference in New Issue
Block a user