1
/***************************************************************************
2
* Copyright (c) 2010 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_RectangularTrimmedSurface.hxx>
30
// inclusion of the generated files (generated out of RectangularTrimmedSurfacePy.xml)
31
#include "GeometryCurvePy.h"
32
#include "RectangularTrimmedSurfacePy.h"
33
#include "RectangularTrimmedSurfacePy.cpp"
38
// returns a string which represents the object e.g. when printed in python
39
std::string RectangularTrimmedSurfacePy::representation() const
41
return {"<RectangularTrimmedSurface object>"};
44
PyObject *RectangularTrimmedSurfacePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
46
// create a new instance of RectangularTrimmedSurfacePy and the Twin object
47
return new RectangularTrimmedSurfacePy(new GeomTrimmedSurface);
51
int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
55
PyObject *usense=Py_True, *vsense=Py_True;
56
if (PyArg_ParseTuple(args, "O!dddd|O!O!",&(Part::GeometrySurfacePy::Type),&surf,
57
&u1,&u2,&v1,&v2,&PyBool_Type,&usense,&PyBool_Type,&vsense)) {
58
getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface(
59
Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(surf)->
60
getGeomSurfacePtr()->handle()),
62
Base::asBoolean(usense),
63
Base::asBoolean(vsense)
70
PyObject *utrim=Py_False, *sense=Py_True;
71
if (PyArg_ParseTuple(args, "O!ddO!|O!",&(Part::GeometrySurfacePy::Type),&surf,
72
¶m1,¶m2,&PyBool_Type,&utrim,&PyBool_Type,&sense)) {
73
Standard_Boolean UTrim = Base::asBoolean(utrim);
74
Standard_Boolean Sense = Base::asBoolean(sense);
75
getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface(
76
Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(surf)->
77
getGeomSurfacePtr()->handle()),
78
param1, param2, UTrim, Sense
83
PyErr_SetString(PartExceptionOCCError, "A surface and the trim parameters must be given");
87
PyObject* RectangularTrimmedSurfacePy::setTrim(PyObject *args)
89
double u1, u2, v1, v2;
90
if (!PyArg_ParseTuple(args, "dddd", &u1, &u2, &v1, &v2))
94
Handle(Geom_RectangularTrimmedSurface) surf = Handle(Geom_RectangularTrimmedSurface)::DownCast
95
(getGeometryPtr()->handle());
97
PyErr_SetString(PyExc_TypeError, "geometry is not a surface");
101
surf->SetTrim(u1, u2, v1, v2);
104
catch (const Standard_Failure& e) {
105
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
110
Py::Object RectangularTrimmedSurfacePy::getBasisSurface() const
112
Handle(Geom_RectangularTrimmedSurface) surf = Handle(Geom_RectangularTrimmedSurface)::DownCast
113
(getGeometryPtr()->handle());
115
throw Py::TypeError("geometry is not a surface");
118
std::unique_ptr<GeomSurface> geo(makeFromSurface(surf->BasisSurface()));
119
return Py::asObject(geo->getPyObject());
122
PyObject *RectangularTrimmedSurfacePy::getCustomAttributes(const char* /*attr*/) const
127
int RectangularTrimmedSurfacePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)