implement ArcOfParabola2d

This commit is contained in:
wmayer 2016-11-25 18:11:37 +01:00
parent ffa942486a
commit c817c3334e
14 changed files with 35 additions and 76 deletions

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2014 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2014 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -12,9 +12,8 @@
Constructor="true">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
<UserDocu>Describes a portion of an parabola</UserDocu>
<UserDocu>Describes a portion of a parabola</UserDocu>
</Documentation>
<!--
<Attribute Name="Focal" ReadOnly="false">
<Documentation>
<UserDocu>The focal length of the parabola.</UserDocu>
@ -27,6 +26,5 @@
</Documentation>
<Parameter Name="Parabola" Type="Object"/>
</Attribute>
-->
</PythonExport>
</GenerateModel>

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2014 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -23,21 +23,19 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <gp_Parab.hxx>
# include <Geom_Parabola.hxx>
# include <GC_MakeArcOfParabola.hxx>
# include <gce_MakeParab.hxx>
# include <Geom_TrimmedCurve.hxx>
# include <gp_Parab2d.hxx>
# include <Geom2d_Parabola.hxx>
# include <GCE2d_MakeArcOfParabola.hxx>
# include <Geom2d_TrimmedCurve.hxx>
#endif
#include <Mod/Part/App/Geometry2d.h>
#include <Mod/Part/App/Geom2d/ArcOfParabola2dPy.h>
#include <Mod/Part/App/Geom2d/ArcOfParabola2dPy.cpp>
#include <Mod/Part/App/ParabolaPy.h>
#include <Mod/Part/App/Geom2d/Parabola2dPy.h>
#include <Mod/Part/App/OCCError.h>
#include <Base/GeometryPyCXX.h>
#include <Base/VectorPy.h>
using namespace Part;
@ -46,39 +44,7 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et);
// returns a string which represents the object e.g. when printed in python
std::string ArcOfParabola2dPy::representation(void) const
{
#if 0
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
(getGeomArcOfParabolaPtr()->handle());
Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve());
gp_Ax1 axis = parabola->Axis();
gp_Dir dir = axis.Direction();
gp_Pnt loc = axis.Location();
Standard_Real fFocal = parabola->Focal();
Standard_Real u1 = trim->FirstParameter();
Standard_Real u2 = trim->LastParameter();
gp_Dir normal = parabola->Axis().Direction();
gp_Dir xdir = parabola->XAxis().Direction();
gp_Ax2 xdirref(loc, normal); // this is a reference XY for the parabola
Standard_Real fAngleXU = -xdir.AngleWithRef(xdirref.XDirection(),normal);
std::stringstream str;
str << "ArcOfParabola (";
str << "Focal : " << fFocal << ", ";
str << "AngleXU : " << fAngleXU << ", ";
str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), ";
str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << "), ";
str << "Parameter : (" << u1 << ", " << u2 << ")";
str << ")";
return str.str();
#else
return "";
#endif
return "<ArcOfParabola2d object>";
}
PyObject *ArcOfParabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
@ -90,23 +56,20 @@ PyObject *ArcOfParabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *
// constructor method
int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
{
#if 1
return 0;
#else
PyObject* o;
double u1, u2;
PyObject *sense=Py_True;
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::ParabolaPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Parabola2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
try {
Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast
(static_cast<ParabolaPy*>(o)->getGeomParabolaPtr()->handle());
GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
Handle_Geom2d_Parabola parabola = Handle_Geom2d_Parabola::DownCast
(static_cast<Parabola2dPy*>(o)->getGeom2dParabolaPtr()->handle());
GCE2d_MakeArcOfParabola arc(parabola->Parab2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;
}
getGeomArcOfParabolaPtr()->setHandle(arc.Value());
getGeom2dArcOfParabolaPtr()->setHandle(arc.Value());
return 0;
}
catch (Standard_Failure) {
@ -122,29 +85,28 @@ int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
// All checks failed
PyErr_SetString(PyExc_TypeError,
"ArcOfParabola constructor expects an parabola curve and a parameter range");
"ArcOfParabola2d constructor expects an parabola curve and a parameter range");
return -1;
#endif
}
#if 0
Py::Float ArcOfParabola2dPy::getFocal(void) const
{
return Py::Float(getGeomArcOfParabolaPtr()->getFocal());
return Py::Float(getGeom2dArcOfParabolaPtr()->getFocal());
}
void ArcOfParabola2dPy::setFocal(Py::Float arg)
{
getGeomArcOfParabolaPtr()->setFocal((double)arg);
getGeom2dArcOfParabolaPtr()->setFocal((double)arg);
}
Py::Object ArcOfParabola2dPy::getParabola(void) const
{
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
(getGeomArcOfParabolaPtr()->handle());
Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve());
return Py::Object(new ParabolaPy(new GeomParabola(parabola)), true);
Handle_Geom2d_TrimmedCurve trim = Handle_Geom2d_TrimmedCurve::DownCast
(getGeom2dArcOfParabolaPtr()->handle());
Handle_Geom2d_Parabola parabola = Handle_Geom2d_Parabola::DownCast(trim->BasisCurve());
return Py::asObject(new Parabola2dPy(new Geom2dParabola(parabola)));
}
#endif
PyObject *ArcOfParabola2dPy::getCustomAttributes(const char* ) const
{
return 0;

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -23,10 +23,9 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Geom_Parabola.hxx>
# include <Geom2d_Parabola.hxx>
#endif
#include <Base/VectorPy.h>
#include <Base/GeometryPyCXX.h>
#include <Mod/Part/App/OCCError.h>