1
/***************************************************************************
2
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
# include <Geom_OffsetSurface.hxx>
30
#include "OffsetSurfacePy.h"
31
#include "OffsetSurfacePy.cpp"
36
// returns a string which represents the object e.g. when printed in python
37
std::string OffsetSurfacePy::representation() const
39
return "<OffsetSurface object>";
42
PyObject *OffsetSurfacePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
44
// create a new instance of OffsetSurfacePy and the Twin object
45
return new OffsetSurfacePy(new GeomOffsetSurface);
49
int OffsetSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
53
if (!PyArg_ParseTuple(args, "O!d",
54
&(GeometryPy::Type), &pGeom,
58
GeometryPy* pcGeo = static_cast<GeometryPy*>(pGeom);
59
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
60
(pcGeo->getGeometryPtr()->handle());
62
PyErr_SetString(PyExc_TypeError, "geometry is not a surface");
67
Handle(Geom_OffsetSurface) surf2 = new Geom_OffsetSurface(surf, offset);
68
getGeomOffsetSurfacePtr()->setHandle(surf2);
71
catch (Standard_Failure& e) {
73
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
78
Py::Float OffsetSurfacePy::getOffsetValue() const
80
Handle(Geom_OffsetSurface) surf = Handle(Geom_OffsetSurface)::DownCast(getGeometryPtr()->handle());
81
return Py::Float(surf->Offset());
84
void OffsetSurfacePy::setOffsetValue(Py::Float arg)
86
Handle(Geom_OffsetSurface) surf = Handle(Geom_OffsetSurface)::DownCast(getGeometryPtr()->handle());
87
surf->SetOffsetValue((double)arg);
90
Py::Object OffsetSurfacePy::getBasisSurface() const
92
Handle(Geom_OffsetSurface) surf = Handle(Geom_OffsetSurface)::DownCast
93
(getGeometryPtr()->handle());
95
throw Py::TypeError("geometry is not a surface");
98
std::unique_ptr<GeomSurface> geo(makeFromSurface(surf->BasisSurface()));
99
return Py::asObject(geo->getPyObject());
102
void OffsetSurfacePy::setBasisSurface(Py::Object arg)
104
PyObject* p = arg.ptr();
105
if (PyObject_TypeCheck(p, &(GeometryPy::Type))) {
106
GeometryPy* pcGeo = static_cast<GeometryPy*>(p);
107
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
108
(pcGeo->getGeometryPtr()->handle());
110
throw Py::TypeError("geometry is not a surface");
114
Handle(Geom_OffsetSurface) surf2 = Handle(Geom_OffsetSurface)::DownCast
115
(getGeometryPtr()->handle());
116
surf2->SetBasisSurface(surf);
118
catch (Standard_Failure& e) {
119
throw Py::RuntimeError(e.GetMessageString());
124
PyObject *OffsetSurfacePy::getCustomAttributes(const char* /*attr*/) const
129
int OffsetSurfacePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)