1
/***************************************************************************
2
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
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"
26
# include <BRep_Builder.hxx>
27
# include <Standard_Failure.hxx>
29
# include <TopoDS_CompSolid.hxx>
35
// inclusion of the generated files (generated out of TopoShapeCompSolidPy.xml)
36
#include "TopoShapeCompSolidPy.h"
37
#include "TopoShapeCompSolidPy.cpp"
38
#include "TopoShapeSolidPy.h"
39
#include "TopoShapeOpCode.h"
44
// returns a string which represents the object e.g. when printed in python
45
std::string TopoShapeCompSolidPy::representation() const
47
std::stringstream str;
48
str << "<CompSolid object at " << getTopoShapePtr() << ">";
53
PyObject *TopoShapeCompSolidPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
55
return new TopoShapeCompSolidPy(new TopoShape);
58
int TopoShapeCompSolidPy::PyInit(PyObject* args, PyObject* /*kwd*/)
60
if (PyArg_ParseTuple(args, "")) {
61
// Undefined CompSolid
62
getTopoShapePtr()->setShape(TopoDS_CompSolid());
68
if (!PyArg_ParseTuple(args, "O", &pcObj)) {
72
getTopoShapePtr()->makeElementBoolean(Part::OpCodes::Compsolid, getPyShapes(pcObj));
74
_PY_CATCH_OCC(return (-1))
78
PyObject* TopoShapeCompSolidPy::add(PyObject* args)
81
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeSolidPy::Type), &obj)) {
86
TopoDS_Shape comp = getTopoShapePtr()->getShape();
88
builder.MakeCompSolid(TopoDS::CompSolid(comp));
90
auto shapes = getPyShapes(obj);
93
for (auto& ts : shapes) {
95
builder.Add(comp, ts.getShape());
98
Standard_Failure::Raise("Cannot empty shape to compound solid");
101
auto& self = *getTopoShapePtr();
102
shapes.push_back(self);
103
TopoShape tmp(self.Tag, self.Hasher, comp);
104
tmp.mapSubElement(shapes);
108
catch (Standard_Failure& e) {
110
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
115
PyObject *TopoShapeCompSolidPy::getCustomAttributes(const char* /*attr*/) const
120
int TopoShapeCompSolidPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)