add class GeomConic to reduce code duplication
This commit is contained in:
@@ -69,6 +69,7 @@
|
||||
#include "Mod/Part/App/LinePy.h"
|
||||
#include "Mod/Part/App/LineSegmentPy.h"
|
||||
#include "Mod/Part/App/PointPy.h"
|
||||
#include "Mod/Part/App/ConicPy.h"
|
||||
#include "Mod/Part/App/CirclePy.h"
|
||||
#include "Mod/Part/App/EllipsePy.h"
|
||||
#include "Mod/Part/App/ArcPy.h"
|
||||
@@ -304,6 +305,7 @@ PyMODINIT_FUNC initPart()
|
||||
}
|
||||
Base::Interpreter().addType(&Part::LineSegmentPy ::Type,partModule,"LineSegment");
|
||||
Base::Interpreter().addType(&Part::PointPy ::Type,partModule,"Point");
|
||||
Base::Interpreter().addType(&Part::ConicPy ::Type,partModule,"Conic");
|
||||
Base::Interpreter().addType(&Part::CirclePy ::Type,partModule,"Circle");
|
||||
Base::Interpreter().addType(&Part::EllipsePy ::Type,partModule,"Ellipse");
|
||||
Base::Interpreter().addType(&Part::HyperbolaPy ::Type,partModule,"Hyperbola");
|
||||
@@ -457,6 +459,7 @@ PyMODINIT_FUNC initPart()
|
||||
Part::GeomCurve ::init();
|
||||
Part::GeomBezierCurve ::init();
|
||||
Part::GeomBSplineCurve ::init();
|
||||
Part::GeomConic ::init();
|
||||
Part::GeomCircle ::init();
|
||||
Part::GeomArcOfCircle ::init();
|
||||
Part::GeomArcOfEllipse ::init();
|
||||
|
||||
@@ -43,6 +43,7 @@ generate_from_xml(ArcPy)
|
||||
generate_from_xml(ArcOfCirclePy)
|
||||
generate_from_xml(ArcOfParabolaPy)
|
||||
generate_from_xml(BodyBasePy)
|
||||
generate_from_xml(ConicPy)
|
||||
generate_from_xml(CirclePy)
|
||||
generate_from_xml(ArcOfEllipsePy)
|
||||
generate_from_xml(EllipsePy)
|
||||
@@ -189,6 +190,8 @@ SET(Python_SRCS
|
||||
ArcOfParabolaPyImp.cpp
|
||||
BodyBasePy.xml
|
||||
BodyBasePyImp.cpp
|
||||
ConicPy.xml
|
||||
ConicPyImp.cpp
|
||||
CirclePy.xml
|
||||
CirclePyImp.cpp
|
||||
ArcOfEllipsePy.xml
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Father="ConicPy"
|
||||
Name="CirclePy"
|
||||
PythonName="Part.Circle"
|
||||
Twin="GeomCircle"
|
||||
TwinPointer="GeomCircle"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
FatherInclude="Mod/Part/App/ConicPy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
@@ -37,29 +37,5 @@ Part.Circle(Point1,Point2,Point3)
|
||||
</Documentation>
|
||||
<Parameter Name="Radius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the circle.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="XAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The X axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="XAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="YAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The Y axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="YAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#endif
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "CirclePy.h"
|
||||
#include "CirclePy.cpp"
|
||||
#include <Mod/Part/App/CirclePy.h>
|
||||
#include <Mod/Part/App/CirclePy.cpp>
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
@@ -174,138 +174,6 @@ void CirclePy::setRadius(Py::Float arg)
|
||||
circle->SetRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Object CirclePy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Pnt loc = circle->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void CirclePy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomCirclePtr()->setCenter(loc);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CirclePy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void CirclePy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(circle->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CirclePy::getXAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->XAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void CirclePy::setXAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = circle->Position();
|
||||
pos.SetXDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set X axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CirclePy::getYAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->YAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void CirclePy::setYAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = circle->Position();
|
||||
pos.SetYDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set Y axis");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *CirclePy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
67
src/Mod/Part/App/ConicPy.xml
Normal file
67
src/Mod/Part/App/ConicPy.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Name="ConicPy"
|
||||
PythonName="Part.Conic"
|
||||
Twin="GeomConic"
|
||||
TwinPointer="GeomConic"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>Describes an abstract conic in 3d space</UserDocu>
|
||||
</Documentation>
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Location of the conic.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Location" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Deprecated. Use Location.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
returns the eccentricity value of the conic e.
|
||||
e = 0 for a circle
|
||||
0 < e < 1 for an ellipse (e = 0 if MajorRadius = MinorRadius)
|
||||
e > 1 for a hyperbola
|
||||
e = 1 for a parabola
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the conic.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="XAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The X axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="XAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="YAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The Y axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="YAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
256
src/Mod/Part/App/ConicPyImp.cpp
Normal file
256
src/Mod/Part/App/ConicPyImp.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Geom_Conic.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
#include <Mod/Part/App/ConicPy.h>
|
||||
#include <Mod/Part/App/ConicPy.cpp>
|
||||
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ConicPy::representation(void) const
|
||||
{
|
||||
return "<Conic object>";
|
||||
}
|
||||
|
||||
PyObject *ConicPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// never create such objects with the constructor
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"You cannot create an instance of the abstract class 'Conic'.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int ConicPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py::Object ConicPy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
gp_Pnt loc = conic->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
Py::Object ConicPy::getLocation(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
gp_Pnt loc = conic->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void ConicPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomConicPtr()->setLocation(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomConicPtr()->setLocation(loc);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
void ConicPy::setLocation(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomConicPtr()->setLocation(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomConicPtr()->setLocation(loc);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Float ConicPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
return Py::Float(conic->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float ConicPy::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
|
||||
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 Py::Float(-xdir.AngleWithRef(xdirref.XDirection(),normal));
|
||||
}
|
||||
|
||||
void ConicPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
|
||||
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,arg);
|
||||
conic->SetPosition(xdirref);
|
||||
}
|
||||
|
||||
Py::Object ConicPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
gp_Ax1 axis = conic->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ConicPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(conic->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
conic->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ConicPy::getXAxis(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
gp_Ax1 axis = conic->XAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ConicPy::setXAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = conic->Position();
|
||||
pos.SetXDirection(gp_Dir(val.x, val.y, val.z));
|
||||
conic->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set X axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ConicPy::getYAxis(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
gp_Ax1 axis = conic->YAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ConicPy::setYAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(getGeomConicPtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = conic->Position();
|
||||
pos.SetYDirection(gp_Dir(val.x, val.y, val.z));
|
||||
conic->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set Y axis");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *ConicPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConicPy::setCustomAttributes(const char* , PyObject *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Father="ConicPy"
|
||||
Name="EllipsePy"
|
||||
PythonName="Part.Ellipse"
|
||||
Twin="GeomEllipse"
|
||||
TwinPointer="GeomEllipse"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
FatherInclude="Mod/Part/App/ConicPy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
@@ -47,18 +47,6 @@
|
||||
</Documentation>
|
||||
<Parameter Name="MinorRadius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The eccentricity of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Focal" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The focal distance of the ellipse.</UserDocu>
|
||||
@@ -82,17 +70,5 @@ the second focus is on the negative side.
|
||||
</Documentation>
|
||||
<Parameter Name="Focus2" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "EllipsePy.h"
|
||||
#include "EllipsePy.cpp"
|
||||
#include <Mod/Part/App/EllipsePy.h>
|
||||
#include <Mod/Part/App/EllipsePy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
@@ -151,44 +151,6 @@ void EllipsePy::setMinorRadius(Py::Float arg)
|
||||
ellipse->SetMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float EllipsePy::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
|
||||
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 Py::Float(-xdir.AngleWithRef(xdirref.XDirection(),normal));
|
||||
|
||||
}
|
||||
|
||||
void EllipsePy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
|
||||
|
||||
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,arg);
|
||||
|
||||
ellipse->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
|
||||
Py::Float EllipsePy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
return Py::Float(ellipse->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float EllipsePy::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
@@ -209,73 +171,6 @@ Py::Object EllipsePy::getFocus2(void) const
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
Py::Object EllipsePy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
gp_Pnt loc = ellipse->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void EllipsePy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
ellipse->SetLocation(gp_Pnt(loc.x, loc.y, loc.z));
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
gp_Pnt loc;
|
||||
loc.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
loc.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
loc.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
ellipse->SetLocation(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object EllipsePy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void EllipsePy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(ellipse->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
ellipse->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *EllipsePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -175,7 +175,7 @@ const char* gce_ErrorStatusText(gce_ErrorType et)
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::Geometry,Base::Persistence);
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::Geometry,Base::Persistence)
|
||||
|
||||
Geometry::Geometry()
|
||||
: Construction(false)
|
||||
@@ -208,7 +208,7 @@ void Geometry::Restore(Base::XMLReader &reader)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomPoint,Part::Geometry);
|
||||
TYPESYSTEM_SOURCE(Part::GeomPoint,Part::Geometry)
|
||||
|
||||
GeomPoint::GeomPoint()
|
||||
{
|
||||
@@ -301,7 +301,7 @@ PyObject *GeomPoint::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomCurve,Part::Geometry);
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomCurve,Part::Geometry)
|
||||
|
||||
GeomCurve::GeomCurve()
|
||||
{
|
||||
@@ -424,7 +424,7 @@ bool GeomCurve::closestParameterToBasicCurve(const Base::Vector3d& point, double
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomBezierCurve,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomBezierCurve,Part::GeomCurve)
|
||||
|
||||
GeomBezierCurve::GeomBezierCurve()
|
||||
{
|
||||
@@ -473,7 +473,7 @@ PyObject *GeomBezierCurve::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomBSplineCurve,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomBSplineCurve,Part::GeomCurve)
|
||||
|
||||
GeomBSplineCurve::GeomBSplineCurve()
|
||||
{
|
||||
@@ -662,7 +662,125 @@ PyObject *GeomBSplineCurve::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomCircle,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomConic, Part::GeomCurve)
|
||||
|
||||
GeomConic::GeomConic()
|
||||
{
|
||||
}
|
||||
|
||||
GeomConic::~GeomConic()
|
||||
{
|
||||
}
|
||||
|
||||
Base::Vector3d GeomConic::getLocation(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
gp_Ax1 axis = conic->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomConic::setLocation(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
|
||||
try {
|
||||
conic->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d GeomConic::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
gp_Ax1 axis = conic->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomConic::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
|
||||
try {
|
||||
conic->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomConic::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 GeomConic::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
|
||||
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 GeomConic::setAngleXU complements getAngleXU.
|
||||
* \param angle
|
||||
*/
|
||||
void GeomConic::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomConic::isReversed tests if an ellipse 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 GeomConic::isReversed() const
|
||||
{
|
||||
Handle_Geom_Conic conic = Handle_Geom_Conic::DownCast(handle());
|
||||
assert(!conic.IsNull());
|
||||
return conic->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomCircle,Part::GeomConic)
|
||||
|
||||
GeomCircle::GeomCircle()
|
||||
{
|
||||
@@ -691,34 +809,12 @@ Geometry *GeomCircle::clone(void) const
|
||||
return newCirc;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomCircle::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(handle());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
double GeomCircle::getRadius(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(handle());
|
||||
return circle->Radius();
|
||||
}
|
||||
|
||||
void GeomCircle::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(handle());
|
||||
|
||||
try {
|
||||
circle->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
void GeomCircle::setRadius(double Radius)
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(handle());
|
||||
@@ -734,13 +830,6 @@ void GeomCircle::setRadius(double Radius)
|
||||
}
|
||||
}
|
||||
|
||||
bool GeomCircle::isReversed() const
|
||||
{
|
||||
Handle_Geom_Circle c = myCurve;
|
||||
assert(!c.IsNull());
|
||||
return c->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomCircle::getMemSize (void) const
|
||||
{
|
||||
@@ -803,12 +892,12 @@ void GeomCircle::Restore(Base::XMLReader& reader)
|
||||
|
||||
PyObject *GeomCircle::getPyObject(void)
|
||||
{
|
||||
return new CirclePy((GeomCircle*)this->clone());
|
||||
return new CirclePy(static_cast<GeomCircle*>(this->clone()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfCircle,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfCircle,Part::GeomCurve)
|
||||
|
||||
GeomArcOfCircle::GeomArcOfCircle()
|
||||
{
|
||||
@@ -1085,7 +1174,7 @@ PyObject *GeomArcOfCircle::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomEllipse,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomEllipse,Part::GeomConic)
|
||||
|
||||
GeomEllipse::GeomEllipse()
|
||||
{
|
||||
@@ -1114,28 +1203,6 @@ Geometry *GeomEllipse::clone(void) const
|
||||
return newEllipse;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomEllipse::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(handle());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomEllipse::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(handle());
|
||||
|
||||
try {
|
||||
ellipse->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomEllipse::getMajorRadius(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(handle());
|
||||
@@ -1174,58 +1241,6 @@ void GeomEllipse::setMinorRadius(double Radius)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomEllipse::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 GeomEllipse::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(handle());
|
||||
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
gp_Dir xdir = this->myCurve->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 GeomEllipse::setAngleXU complements getAngleXU.
|
||||
* \param angle
|
||||
*/
|
||||
void GeomEllipse::setAngleXU(double angle)
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(handle());
|
||||
|
||||
try {
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
this->myCurve->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief GeomEllipse::getMajorAxisDir
|
||||
* \return the direction vector (unit-length) of major axis of the ellipse. The
|
||||
@@ -1264,20 +1279,6 @@ void GeomEllipse::setMajorAxisDir(Base::Vector3d newdir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief GeomEllipse::isReversedInXY tests if an ellipse 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 GeomEllipse::isReversedInXY() const
|
||||
{
|
||||
Handle_Geom_Ellipse c = myCurve;
|
||||
assert(!c.IsNull());
|
||||
return c->Axis().Direction().Z() < 0;
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomEllipse::getMemSize (void) const
|
||||
{
|
||||
@@ -1372,7 +1373,7 @@ void GeomEllipse::setHandle(const Handle_Geom_Ellipse &e)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfEllipse,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfEllipse,Part::GeomCurve)
|
||||
|
||||
GeomArcOfEllipse::GeomArcOfEllipse()
|
||||
{
|
||||
@@ -1753,7 +1754,7 @@ PyObject *GeomArcOfEllipse::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomHyperbola,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomHyperbola,Part::GeomConic)
|
||||
|
||||
GeomHyperbola::GeomHyperbola()
|
||||
{
|
||||
@@ -1782,28 +1783,6 @@ Geometry *GeomHyperbola::clone(void) const
|
||||
return newHyp;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomHyperbola::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(handle());
|
||||
gp_Ax1 axis = h->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomHyperbola::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(handle());
|
||||
|
||||
try {
|
||||
h->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomHyperbola::getMajorRadius(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola h = Handle_Geom_Hyperbola::DownCast(handle());
|
||||
@@ -1842,38 +1821,6 @@ void GeomHyperbola::setMinorRadius(double Radius)
|
||||
}
|
||||
}
|
||||
|
||||
double GeomHyperbola::getAngleXU(void) const
|
||||
{
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
gp_Dir xdir = this->myCurve->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 GeomHyperbola::setAngleXU(double angle)
|
||||
{
|
||||
try {
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
this->myCurve->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomHyperbola::getMemSize (void) const
|
||||
{
|
||||
@@ -1952,11 +1899,11 @@ void GeomHyperbola::Restore(Base::XMLReader& reader)
|
||||
|
||||
PyObject *GeomHyperbola::getPyObject(void)
|
||||
{
|
||||
return new HyperbolaPy((GeomHyperbola*)this->clone());
|
||||
return new HyperbolaPy(static_cast<GeomHyperbola*>(this->clone()));
|
||||
}
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfHyperbola,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfHyperbola,Part::GeomCurve)
|
||||
|
||||
GeomArcOfHyperbola::GeomArcOfHyperbola()
|
||||
{
|
||||
@@ -2298,7 +2245,7 @@ PyObject *GeomArcOfHyperbola::getPyObject(void)
|
||||
}
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomParabola,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomParabola,Part::GeomConic)
|
||||
|
||||
GeomParabola::GeomParabola()
|
||||
{
|
||||
@@ -2327,28 +2274,6 @@ Geometry *GeomParabola::clone(void) const
|
||||
return newPar;
|
||||
}
|
||||
|
||||
Base::Vector3d GeomParabola::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(handle());
|
||||
gp_Ax1 axis = p->Axis();
|
||||
const gp_Pnt& loc = axis.Location();
|
||||
return Base::Vector3d(loc.X(),loc.Y(),loc.Z());
|
||||
}
|
||||
|
||||
void GeomParabola::setCenter(const Base::Vector3d& Center)
|
||||
{
|
||||
gp_Pnt p1(Center.x,Center.y,Center.z);
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(handle());
|
||||
|
||||
try {
|
||||
p->SetLocation(p1);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
double GeomParabola::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Parabola p = Handle_Geom_Parabola::DownCast(handle());
|
||||
@@ -2368,37 +2293,6 @@ void GeomParabola::setFocal(double length)
|
||||
}
|
||||
}
|
||||
|
||||
double GeomParabola::getAngleXU(void) const
|
||||
{
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
gp_Dir xdir = this->myCurve->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 GeomParabola::setAngleXU(double angle)
|
||||
{
|
||||
try {
|
||||
gp_Pnt center = this->myCurve->Axis().Location();
|
||||
gp_Dir normal = this->myCurve->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,angle);
|
||||
|
||||
this->myCurve->SetPosition(xdirref);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeomParabola::getMemSize (void) const
|
||||
{
|
||||
@@ -2472,14 +2366,15 @@ void GeomParabola::Restore(Base::XMLReader& reader)
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *GeomParabola::getPyObject(void)
|
||||
{
|
||||
return new ParabolaPy((GeomParabola*)this->clone());
|
||||
return new ParabolaPy(static_cast<GeomParabola*>(this->clone()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfParabola,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomArcOfParabola,Part::GeomCurve)
|
||||
|
||||
GeomArcOfParabola::GeomArcOfParabola()
|
||||
{
|
||||
@@ -2957,7 +2852,7 @@ PyObject *GeomLineSegment::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomOffsetCurve,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomOffsetCurve,Part::GeomCurve)
|
||||
|
||||
GeomOffsetCurve::GeomOffsetCurve()
|
||||
{
|
||||
@@ -3006,7 +2901,7 @@ PyObject *GeomOffsetCurve::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomTrimmedCurve,Part::GeomCurve);
|
||||
TYPESYSTEM_SOURCE(Part::GeomTrimmedCurve,Part::GeomCurve)
|
||||
|
||||
GeomTrimmedCurve::GeomTrimmedCurve()
|
||||
{
|
||||
@@ -3050,7 +2945,7 @@ PyObject *GeomTrimmedCurve::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomSurface,Part::Geometry);
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomSurface,Part::Geometry)
|
||||
|
||||
GeomSurface::GeomSurface()
|
||||
{
|
||||
@@ -3099,7 +2994,7 @@ bool GeomSurface::tangentV(double u, double v, gp_Dir& dirV) const
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomBezierSurface,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomBezierSurface,Part::GeomSurface)
|
||||
|
||||
GeomBezierSurface::GeomBezierSurface()
|
||||
{
|
||||
@@ -3144,7 +3039,7 @@ PyObject *GeomBezierSurface::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomBSplineSurface,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomBSplineSurface,Part::GeomSurface)
|
||||
|
||||
GeomBSplineSurface::GeomBSplineSurface()
|
||||
{
|
||||
@@ -3203,7 +3098,7 @@ PyObject *GeomBSplineSurface::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomCylinder,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomCylinder,Part::GeomSurface)
|
||||
|
||||
GeomCylinder::GeomCylinder()
|
||||
{
|
||||
@@ -3250,7 +3145,7 @@ PyObject *GeomCylinder::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomCone,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomCone,Part::GeomSurface)
|
||||
|
||||
GeomCone::GeomCone()
|
||||
{
|
||||
@@ -3297,7 +3192,7 @@ PyObject *GeomCone::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomToroid,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomToroid,Part::GeomSurface)
|
||||
|
||||
GeomToroid::GeomToroid()
|
||||
{
|
||||
@@ -3344,7 +3239,7 @@ PyObject *GeomToroid::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomSphere,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomSphere,Part::GeomSurface)
|
||||
|
||||
GeomSphere::GeomSphere()
|
||||
{
|
||||
@@ -3391,7 +3286,7 @@ PyObject *GeomSphere::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomPlane,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomPlane,Part::GeomSurface)
|
||||
|
||||
GeomPlane::GeomPlane()
|
||||
{
|
||||
@@ -3438,7 +3333,7 @@ PyObject *GeomPlane::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomOffsetSurface,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomOffsetSurface,Part::GeomSurface)
|
||||
|
||||
GeomOffsetSurface::GeomOffsetSurface()
|
||||
{
|
||||
@@ -3487,7 +3382,7 @@ PyObject *GeomOffsetSurface::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomPlateSurface,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomPlateSurface,Part::GeomSurface)
|
||||
|
||||
GeomPlateSurface::GeomPlateSurface()
|
||||
{
|
||||
@@ -3553,7 +3448,7 @@ PyObject *GeomPlateSurface::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomTrimmedSurface,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomTrimmedSurface,Part::GeomSurface)
|
||||
|
||||
GeomTrimmedSurface::GeomTrimmedSurface()
|
||||
{
|
||||
@@ -3597,7 +3492,7 @@ PyObject *GeomTrimmedSurface::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomSurfaceOfRevolution,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomSurfaceOfRevolution,Part::GeomSurface)
|
||||
|
||||
GeomSurfaceOfRevolution::GeomSurfaceOfRevolution()
|
||||
{
|
||||
@@ -3646,7 +3541,7 @@ PyObject *GeomSurfaceOfRevolution::getPyObject(void)
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Part::GeomSurfaceOfExtrusion,Part::GeomSurface);
|
||||
TYPESYSTEM_SOURCE(Part::GeomSurfaceOfExtrusion,Part::GeomSurface)
|
||||
|
||||
GeomSurfaceOfExtrusion::GeomSurfaceOfExtrusion()
|
||||
{
|
||||
|
||||
@@ -209,7 +209,39 @@ private:
|
||||
Handle_Geom_BSplineCurve myCurve;
|
||||
};
|
||||
|
||||
class PartExport GeomCircle : public GeomCurve
|
||||
class PartExport GeomConic : public GeomCurve
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
protected:
|
||||
GeomConic();
|
||||
|
||||
public:
|
||||
virtual ~GeomConic();
|
||||
virtual Geometry *clone(void) const = 0;
|
||||
|
||||
/*!
|
||||
* \deprecated use getLocation
|
||||
* \brief getCenter
|
||||
*/
|
||||
Base::Vector3d getCenter(void) const;
|
||||
Base::Vector3d getLocation(void) const;
|
||||
void setLocation(const Base::Vector3d& Center);
|
||||
/*!
|
||||
* \deprecated use setLocation
|
||||
* \brief setCenter
|
||||
*/
|
||||
void setCenter(const Base::Vector3d& Center);
|
||||
double getAngleXU(void) const;
|
||||
void setAngleXU(double angle);
|
||||
bool isReversed() const;
|
||||
|
||||
virtual unsigned int getMemSize(void) const = 0;
|
||||
virtual PyObject *getPyObject(void) = 0;
|
||||
|
||||
const Handle_Geom_Geometry& handle() const = 0;
|
||||
};
|
||||
|
||||
class PartExport GeomCircle : public GeomConic
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
@@ -218,11 +250,8 @@ public:
|
||||
virtual ~GeomCircle();
|
||||
virtual Geometry *clone(void) const;
|
||||
|
||||
Base::Vector3d getCenter(void) const;
|
||||
double getRadius(void) const;
|
||||
void setCenter(const Base::Vector3d& Center);
|
||||
void setRadius(double Radius);
|
||||
bool isReversed() const;
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
@@ -271,7 +300,7 @@ private:
|
||||
Handle_Geom_TrimmedCurve myCurve;
|
||||
};
|
||||
|
||||
class PartExport GeomEllipse : public GeomCurve
|
||||
class PartExport GeomEllipse : public GeomConic
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
@@ -280,17 +309,12 @@ public:
|
||||
virtual ~GeomEllipse();
|
||||
virtual Geometry *clone(void) const;
|
||||
|
||||
Base::Vector3d getCenter(void) const;
|
||||
void setCenter(const Base::Vector3d& Center);
|
||||
double getMajorRadius(void) const;
|
||||
void setMajorRadius(double Radius);
|
||||
double getMinorRadius(void) const;
|
||||
void setMinorRadius(double Radius);
|
||||
double getAngleXU(void) const;
|
||||
void setAngleXU(double angle);
|
||||
Base::Vector3d getMajorAxisDir() const;
|
||||
void setMajorAxisDir(Base::Vector3d newdir);
|
||||
bool isReversedInXY() const;
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
@@ -348,7 +372,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class PartExport GeomHyperbola : public GeomCurve
|
||||
class PartExport GeomHyperbola : public GeomConic
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
@@ -357,14 +381,10 @@ public:
|
||||
virtual ~GeomHyperbola();
|
||||
virtual Geometry *clone(void) const;
|
||||
|
||||
Base::Vector3d getCenter(void) const;
|
||||
void setCenter(const Base::Vector3d& Center);
|
||||
double getMajorRadius(void) const;
|
||||
void setMajorRadius(double Radius);
|
||||
double getMinorRadius(void) const;
|
||||
void setMinorRadius(double Radius);
|
||||
double getAngleXU(void) const;
|
||||
void setAngleXU(double angle);
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
@@ -420,7 +440,7 @@ private:
|
||||
Handle_Geom_TrimmedCurve myCurve;
|
||||
};
|
||||
|
||||
class PartExport GeomParabola : public GeomCurve
|
||||
class PartExport GeomParabola : public GeomConic
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
@@ -429,12 +449,8 @@ public:
|
||||
virtual ~GeomParabola();
|
||||
virtual Geometry *clone(void) const;
|
||||
|
||||
Base::Vector3d getCenter(void) const;
|
||||
void setCenter(const Base::Vector3d& Center);
|
||||
double getFocal(void) const;
|
||||
void setFocal(double length);
|
||||
double getAngleXU(void) const;
|
||||
void setAngleXU(double angle);
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Father="ConicPy"
|
||||
Name="HyperbolaPy"
|
||||
PythonName="Part.Hyperbola"
|
||||
Twin="GeomHyperbola"
|
||||
TwinPointer="GeomHyperbola"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
FatherInclude="Mod/Part/App/ConicPy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
@@ -47,18 +47,6 @@
|
||||
</Documentation>
|
||||
<Parameter Name="MinorRadius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the hyperbola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The eccentricity of the hyperbola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Focal" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The focal distance of the hyperbola.</UserDocu>
|
||||
@@ -82,17 +70,5 @@ the second focus is on the negative side.
|
||||
</Documentation>
|
||||
<Parameter Name="Focus2" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the hyperbola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the hyperbola</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "HyperbolaPy.h"
|
||||
#include "HyperbolaPy.cpp"
|
||||
#include <Mod/Part/App/HyperbolaPy.h>
|
||||
#include <Mod/Part/App/HyperbolaPy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
@@ -151,44 +151,6 @@ void HyperbolaPy::setMinorRadius(Py::Float arg)
|
||||
hyperbola->SetMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float HyperbolaPy::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
|
||||
gp_Pnt center = hyperbola->Axis().Location();
|
||||
gp_Dir normal = hyperbola->Axis().Direction();
|
||||
gp_Dir xdir = hyperbola->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return Py::Float(-xdir.AngleWithRef(xdirref.XDirection(),normal));
|
||||
|
||||
}
|
||||
|
||||
void HyperbolaPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
|
||||
|
||||
gp_Pnt center = hyperbola->Axis().Location();
|
||||
gp_Dir normal = hyperbola->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,arg);
|
||||
|
||||
hyperbola->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
|
||||
Py::Float HyperbolaPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
return Py::Float(hyperbola->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float HyperbolaPy::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
@@ -209,73 +171,6 @@ Py::Object HyperbolaPy::getFocus2(void) const
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
Py::Object HyperbolaPy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
gp_Pnt loc = hyperbola->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void HyperbolaPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
hyperbola->SetLocation(gp_Pnt(loc.x, loc.y, loc.z));
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
gp_Pnt loc;
|
||||
loc.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
loc.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
loc.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
hyperbola->SetLocation(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object HyperbolaPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
gp_Ax1 axis = hyperbola->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void HyperbolaPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(getGeomHyperbolaPtr()->handle());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(hyperbola->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
hyperbola->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *HyperbolaPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Father="ConicPy"
|
||||
Name="ParabolaPy"
|
||||
PythonName="Part.Parabola"
|
||||
Twin="GeomParabola"
|
||||
TwinPointer="GeomParabola"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
FatherInclude="Mod/Part/App/ConicPy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
@@ -23,12 +23,6 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Returns 1. (which is the eccentricity of any parabola).</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Focal" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The focal distance is the distance between
|
||||
@@ -52,17 +46,5 @@ and its directrix. This distance is twice the focal length.
|
||||
</Documentation>
|
||||
<Parameter Name="Parameter" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Location of the parabola</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Location" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the parabola</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "ParabolaPy.h"
|
||||
#include "ParabolaPy.cpp"
|
||||
#include <Mod/Part/App/ParabolaPy.h>
|
||||
#include <Mod/Part/App/ParabolaPy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
@@ -106,12 +106,6 @@ PyObject* ParabolaPy::compute(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
Py::Float ParabolaPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_Parabola curve = Handle_Geom_Parabola::DownCast(getGeometryPtr()->handle());
|
||||
return Py::Float(curve->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float ParabolaPy::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Parabola curve = Handle_Geom_Parabola::DownCast(getGeometryPtr()->handle());
|
||||
@@ -138,83 +132,6 @@ Py::Float ParabolaPy::getParameter(void) const
|
||||
return Py::Float(curve->Parameter());
|
||||
}
|
||||
|
||||
Py::Object ParabolaPy::getLocation(void) const
|
||||
{
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
gp_Pnt loc = c->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void ParabolaPy::setLocation(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
c->SetLocation(gp_Pnt(loc.x, loc.y, loc.z));
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
gp_Pnt loc;
|
||||
loc.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
loc.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
loc.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
c->SetLocation(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ParabolaPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Parabola c = Handle_Geom_Parabola::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
gp_Dir dir = c->Axis().Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ParabolaPy::setAxis(Py::Object arg)
|
||||
{
|
||||
Standard_Real dir_x, dir_y, dir_z;
|
||||
PyObject *p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d v = static_cast<Base::VectorPy*>(p)->value();
|
||||
dir_x = v.x;
|
||||
dir_y = v.y;
|
||||
dir_z = v.z;
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
dir_x = (double)Py::Float(tuple.getItem(0));
|
||||
dir_y = (double)Py::Float(tuple.getItem(1));
|
||||
dir_z = (double)Py::Float(tuple.getItem(2));
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector' or tuple, not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
try {
|
||||
Handle_Geom_Parabola this_curv = Handle_Geom_Parabola::DownCast
|
||||
(this->getGeometryPtr()->handle());
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(this_curv->Location());
|
||||
axis.SetDirection(gp_Dir(dir_x, dir_y, dir_z));
|
||||
this_curv->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *ParabolaPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user