Part: Rearrange inheritance not to use ArcPy
============================================ Inheritance: Geometry - GeomPoint - GeomCurve (GeometryCurvePy) - - GeomBoundedCurve (BoundedCurvePy) - - - GeomBezierCurve (BezierCurvePy) - - - GeomBSplineCurve (BSplineCurvePy) - - - GeomTrimmedCurve (TrimmedCurvePy) - - - - GeomArcOfConic (ArcOfConicPy) - - - - - GeomArcOfCircle (ArcOfCirclePy) - - - - - GeomArcOfEllipse (ArcOfEllipsePy) - - - - - GeomArcOfHyperbola (ArcOfHyperbolaPy) - - - - - GeomArcOfParabola (ArcOfParabolaPy) - - - - GeomLineSegment (LineSegmentPy) - - GeomConic - - - GeomCircle - - - GeomEllipse - - - GeomHyperbola - - - GeomParabola - - GeomLine - - GeomOffsetCurve * Note: ArcPy is also a twinclass of c++ GeomTrimmedCurve, Python ArcPy derives from Python TrimmedCurvePy. Same functionality as before: >>> geometries = ActiveSketch.Geometry >>> line = geometries[1] >>> arc = geometries[2] >>> line <Line segment (-97.4389,42.4463,0) (-80.7887,44.5569,0) > >>> arc ArcOfCircle (Radius : 19.3111, Position : (-74.6914, -23.2165, 0), Direction : (0, 0, 1), Parameter : (1.82335, 2.71597)) >>> line.FirstParameter 0.0 >>> line.LastParameter 16.783437032695776 >>> line.setParameterRange(0,20) >>> line.LastParameter 20.0 >>> arc.StartPoint Vector (-79.51683708894876, -4.517938119394778, 0.0) >>> arc.EndPoint Vector (-92.27963885411512, -15.243140671641918, 0.0) >>> arc.setParameterRange(1.5,3) >>> arc ArcOfCircle (Radius : 19.3111, Position : (-74.6914, -23.2165, 0), Direction : (0, 0, 1), Parameter : (1.5, 3)) >>> geometries[1] = line >>> geometries[2] = arc >>> ActiveSketch.Geometry = geometries >>> ActiveSketch.solve() 0 >>>
This commit is contained in:
@@ -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="ArcPy"
|
||||
Father="TrimmedCurvePy"
|
||||
Name="ArcOfConicPy"
|
||||
PythonName="Part.ArcOfConic"
|
||||
Twin="GeomArcOfConic"
|
||||
TwinPointer="GeomArcOfConic"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/ArcPy.h"
|
||||
FatherInclude="Mod/Part/App/TrimmedCurvePy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
|
||||
@@ -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="BoundedCurvePy"
|
||||
Father="TrimmedCurvePy"
|
||||
Name="ArcPy"
|
||||
PythonName="Part.Arc"
|
||||
Twin="GeomTrimmedCurve"
|
||||
TwinPointer="GeomTrimmedCurve"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/BoundedCurvePy.h"
|
||||
FatherInclude="Mod/Part/App/TrimmedCurvePy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
@@ -29,12 +29,5 @@
|
||||
const Geom_Ellipse & value(void) const {return *getGeom_EllipsePtr();}
|
||||
</ClassDeclarations>
|
||||
-->
|
||||
<Methode Name="setParameterRange" Const="false">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Re-trims this curve to the provided parameter range ([Float=First, Float=Last])
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -197,31 +197,6 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* ArcPy::setParameterRange(PyObject * args)
|
||||
{
|
||||
Handle(Geom_Geometry) g = getGeomTrimmedCurvePtr()->handle();
|
||||
Handle(Geom_TrimmedCurve) c = Handle(Geom_TrimmedCurve)::DownCast(g);
|
||||
try {
|
||||
if (!c.IsNull()) {
|
||||
double u,v;
|
||||
u=c->FirstParameter();
|
||||
v=c->LastParameter();
|
||||
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
|
||||
return 0;
|
||||
getGeomTrimmedCurvePtr()->setRange(u,v);
|
||||
Py_Return;
|
||||
}
|
||||
}
|
||||
catch (Base::CADKernelError& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a trimmed curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PyObject *ArcPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2019 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
||||
@@ -53,6 +53,7 @@ generate_from_xml(OffsetCurvePy)
|
||||
generate_from_xml(GeometryPy)
|
||||
generate_from_xml(GeometryCurvePy)
|
||||
generate_from_xml(BoundedCurvePy)
|
||||
generate_from_xml(TrimmedCurvePy)
|
||||
generate_from_xml(GeometrySurfacePy)
|
||||
generate_from_xml(LinePy)
|
||||
generate_from_xml(LineSegmentPy)
|
||||
@@ -214,6 +215,8 @@ SET(Python_SRCS
|
||||
GeometryCurvePyImp.cpp
|
||||
BoundedCurvePy.xml
|
||||
BoundedCurvePyImp.cpp
|
||||
TrimmedCurvePy.xml
|
||||
TrimmedCurvePyImp.cpp
|
||||
GeometrySurfacePy.xml
|
||||
GeometrySurfacePyImp.cpp
|
||||
LinePy.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="ArcPy"
|
||||
Father="TrimmedCurvePy"
|
||||
Name="LineSegmentPy"
|
||||
PythonName="Part.LineSegment"
|
||||
Twin="GeomLineSegment"
|
||||
TwinPointer="GeomLineSegment"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/ArcPy.h"
|
||||
FatherInclude="Mod/Part/App/TrimmedCurvePy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
|
||||
28
src/Mod/Part/App/TrimmedCurvePy.xml
Normal file
28
src/Mod/Part/App/TrimmedCurvePy.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="BoundedCurvePy"
|
||||
Name="TrimmedCurvePy"
|
||||
PythonName="Part.TrimmedCurve"
|
||||
Twin="GeomTrimmedCurve"
|
||||
TwinPointer="GeomTrimmedCurve"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/BoundedCurvePy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Abdullah Tahiri" EMail="abdullah.tahiri.yo@gmail.com" />
|
||||
<UserDocu>
|
||||
The abstract class TrimmedCurve is the root class of all trimmed curve objects.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="setParameterRange" Const="false">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Re-trims this curve to the provided parameter range ([Float=First, Float=Last])
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
93
src/Mod/Part/App/TrimmedCurvePyImp.cpp
Normal file
93
src/Mod/Part/App/TrimmedCurvePyImp.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
#include "OCCError.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "TrimmedCurvePy.h"
|
||||
#include "TrimmedCurvePy.cpp"
|
||||
|
||||
|
||||
using namespace Part;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string TrimmedCurvePy::representation(void) const
|
||||
{
|
||||
return "<Curve object>";
|
||||
}
|
||||
|
||||
PyObject *TrimmedCurvePy::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 'BoundedCurve'.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int TrimmedCurvePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* TrimmedCurvePy::setParameterRange(PyObject * args)
|
||||
{
|
||||
Handle(Geom_Geometry) g = getGeomTrimmedCurvePtr()->handle();
|
||||
Handle(Geom_TrimmedCurve) c = Handle(Geom_TrimmedCurve)::DownCast(g);
|
||||
try {
|
||||
if (!c.IsNull()) {
|
||||
double u,v;
|
||||
u=c->FirstParameter();
|
||||
v=c->LastParameter();
|
||||
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
|
||||
return 0;
|
||||
getGeomTrimmedCurvePtr()->setRange(u,v);
|
||||
Py_Return;
|
||||
}
|
||||
}
|
||||
catch (Base::CADKernelError& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a trimmed curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject *TrimmedCurvePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TrimmedCurvePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user