This commit adds getShape and setShape to TopoShape

This commit is contained in:
Wolfgang E. Sanyer
2016-08-02 15:59:39 -04:00
committed by wmayer
parent 5a30a43862
commit 7f4a437cc2
54 changed files with 400 additions and 372 deletions

View File

@@ -135,10 +135,10 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
getGeometryPtr()->toShape();
if (first) {
first = false;
shape._Shape = sh;
shape.setShape(sh);
}
else {
shape._Shape = shape.fuse(sh);
shape.setShape(shape.fuse(sh));
}
}
}
@@ -149,7 +149,7 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
return -1;
}
getTopoShapePtr()->_Shape = shape._Shape;
getTopoShapePtr()->setShape(shape.getShape());
}
return 0;
@@ -208,7 +208,7 @@ PyObject* TopoShapePy::copy(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
@@ -221,7 +221,7 @@ PyObject* TopoShapePy::copy(PyObject *args)
if (!shape.IsNull()) {
BRepBuilderAPI_Copy c(shape);
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->_Shape = c.Shape();
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->setShape(c.Shape());
}
return cpy;
}
@@ -231,7 +231,7 @@ PyObject* TopoShapePy::cleaned(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
@@ -246,7 +246,7 @@ PyObject* TopoShapePy::cleaned(PyObject *args)
BRepBuilderAPI_Copy c(shape);
const TopoDS_Shape& copiedShape = c.Shape();
BRepTools::Clean(copiedShape); // remove triangulation
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->_Shape = c.Shape();
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->setShape(c.Shape());
}
return cpy;
}
@@ -265,14 +265,14 @@ PyObject* TopoShapePy::replaceShape(PyObject *args)
Py::TopoShape sh1(tuple[0]);
Py::TopoShape sh2(tuple[1]);
shapes.push_back(std::make_pair(
sh1.extensionObject()->getTopoShapePtr()->_Shape,
sh2.extensionObject()->getTopoShapePtr()->_Shape)
sh1.extensionObject()->getTopoShapePtr()->getShape(),
sh2.extensionObject()->getTopoShapePtr()->getShape())
);
}
PyTypeObject* type = this->GetType();
PyObject* inst = type->tp_new(type, this, 0);
static_cast<TopoShapePy*>(inst)->getTopoShapePtr()->_Shape =
this->getTopoShapePtr()->replaceShape(shapes);
static_cast<TopoShapePy*>(inst)->getTopoShapePtr()->setShape
(this->getTopoShapePtr()->replaceShape(shapes));
return inst;
}
catch (const Py::Exception&) {
@@ -296,13 +296,13 @@ PyObject* TopoShapePy::removeShape(PyObject *args)
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::TopoShape sh(*it);
shapes.push_back(
sh.extensionObject()->getTopoShapePtr()->_Shape
sh.extensionObject()->getTopoShapePtr()->getShape()
);
}
PyTypeObject* type = this->GetType();
PyObject* inst = type->tp_new(type, this, 0);
static_cast<TopoShapePy*>(inst)->getTopoShapePtr()->_Shape =
this->getTopoShapePtr()->removeShape(shapes);
static_cast<TopoShapePy*>(inst)->getTopoShapePtr()->setShape
(this->getTopoShapePtr()->removeShape(shapes));
return inst;
}
catch (...) {
@@ -331,7 +331,7 @@ PyObject* TopoShapePy::writeInventor(PyObject * args)
return NULL;
std::stringstream result;
BRepMesh_IncrementalMesh(getTopoShapePtr()->_Shape,dev);
BRepMesh_IncrementalMesh(getTopoShapePtr()->getShape(),dev);
if (mode == 0)
getTopoShapePtr()->exportFaceSet(dev, angle, result);
else if (mode == 1)
@@ -341,7 +341,7 @@ PyObject* TopoShapePy::writeInventor(PyObject * args)
getTopoShapePtr()->exportLineSet(result);
}
// NOTE: Cleaning the triangulation may cause problems on some algorithms like BOP
//BRepTools::Clean(getTopoShapePtr()->_Shape); // remove triangulation
//BRepTools::Clean(getTopoShapePtr()->getShape()); // remove triangulation
return Py::new_reference_to(Py::String(result.str()));
}
@@ -679,7 +679,7 @@ PyObject* TopoShapePy::revolve(PyObject *args)
double d=360;
if (PyArg_ParseTuple(args, "O!O!|d", &(Base::VectorPy::Type), &pPos, &(Base::VectorPy::Type), &pDir,&d)) {
try {
const TopoDS_Shape& input = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& input = this->getTopoShapePtr()->getShape();
if (input.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "empty shape cannot be revolved");
return 0;
@@ -743,7 +743,7 @@ PyObject* TopoShapePy::check(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
if (!getTopoShapePtr()->_Shape.IsNull()) {
if (!getTopoShapePtr()->getShape().IsNull()) {
std::stringstream str;
if (!getTopoShapePtr()->analyze(str)) {
PyErr_SetString(PyExc_StandardError, str.str().c_str());
@@ -760,7 +760,7 @@ PyObject* TopoShapePy::fuse(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a fuse operation:
TopoDS_Shape fusShape = this->getTopoShapePtr()->fuse(shape);
@@ -788,7 +788,7 @@ PyObject* TopoShapePy::multiFuse(PyObject *args)
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(Part::TopoShapePy::Type))) {
shapeVec.push_back(static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->_Shape);
shapeVec.push_back(static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->getShape());
}
else {
PyErr_SetString(PyExc_TypeError, "non-shape object in sequence");
@@ -816,7 +816,7 @@ PyObject* TopoShapePy::oldFuse(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a fuse operation:
TopoDS_Shape fusShape = this->getTopoShapePtr()->oldFuse(shape);
@@ -839,7 +839,7 @@ PyObject* TopoShapePy::common(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a common operation:
TopoDS_Shape comShape = this->getTopoShapePtr()->common(shape);
@@ -862,7 +862,7 @@ PyObject* TopoShapePy::section(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a section operation:
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape);
@@ -940,7 +940,7 @@ PyObject* TopoShapePy::cut(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a cut operation:
TopoDS_Shape cutShape = this->getTopoShapePtr()->cut(shape);
@@ -968,7 +968,7 @@ PyObject* TopoShapePy::generalFuse(PyObject *args)
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(Part::TopoShapePy::Type))) {
shapeVec.push_back(static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->_Shape);
shapeVec.push_back(static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->getShape());
}
else {
PyErr_SetString(PyExc_TypeError, "non-shape object in sequence");
@@ -1030,7 +1030,7 @@ PyObject* TopoShapePy::childShapes(PyObject *args)
return NULL;
try {
TopoDS_Iterator it(getTopoShapePtr()->_Shape,
TopoDS_Iterator it(getTopoShapePtr()->getShape(),
PyObject_IsTrue(cumOri) ? Standard_True : Standard_False,
PyObject_IsTrue(cumLoc) ? Standard_True : Standard_False);
Py::List list;
@@ -1184,7 +1184,9 @@ PyObject* TopoShapePy::translate(PyObject *args)
gp_Trsf mov;
mov.SetTranslation(gp_Vec(vec.x,vec.y,vec.z));
TopLoc_Location loc(mov);
getTopoShapePtr()->_Shape.Move(loc);
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Move(loc);
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1210,7 +1212,9 @@ PyObject* TopoShapePy::rotate(PyObject *args)
gp_Trsf mov;
mov.SetRotation(axis, angle*(M_PI/180));
TopLoc_Location loc(mov);
getTopoShapePtr()->_Shape.Move(loc);
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Move(loc);
getTopoShapePtr()->setShape(shape);
Py_Return;
}
catch (const Py::Exception&) {
@@ -1242,8 +1246,8 @@ PyObject* TopoShapePy::scale(PyObject *args)
scl.SetScale(pos, factor);
BRepBuilderAPI_Transform BRepScale(scl);
bool bCopy = true;
BRepScale.Perform(getTopoShapePtr()->_Shape,bCopy);
getTopoShapePtr()->_Shape = BRepScale.Shape();
BRepScale.Perform(getTopoShapePtr()->getShape(),bCopy);
getTopoShapePtr()->setShape(BRepScale.Shape());
Py_Return;
}
catch (Standard_Failure) {
@@ -1260,12 +1264,12 @@ PyObject* TopoShapePy::makeFillet(PyObject *args)
PyObject *obj;
if (PyArg_ParseTuple(args, "ddO", &radius1, &radius2, &obj)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
BRepFilletAPI_MakeFillet mkFillet(shape);
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
if (edge.ShapeType() == TopAbs_EDGE) {
//Add edge to fillet algorithm
mkFillet.Add(radius1, radius2, TopoDS::Edge(edge));
@@ -1286,12 +1290,12 @@ PyObject* TopoShapePy::makeFillet(PyObject *args)
double radius;
if (PyArg_ParseTuple(args, "dO", &radius, &obj)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
BRepFilletAPI_MakeFillet mkFillet(shape);
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
if (edge.ShapeType() == TopAbs_EDGE) {
//Add edge to fillet algorithm
mkFillet.Add(radius, TopoDS::Edge(edge));
@@ -1320,7 +1324,7 @@ PyObject* TopoShapePy::makeChamfer(PyObject *args)
PyObject *obj;
if (PyArg_ParseTuple(args, "ddO", &radius1, &radius2, &obj)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
BRepFilletAPI_MakeChamfer mkChamfer(shape);
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
@@ -1329,7 +1333,7 @@ PyObject* TopoShapePy::makeChamfer(PyObject *args)
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
if (edge.ShapeType() == TopAbs_EDGE) {
//Add edge to fillet algorithm
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
@@ -1351,7 +1355,7 @@ PyObject* TopoShapePy::makeChamfer(PyObject *args)
double radius;
if (PyArg_ParseTuple(args, "dO", &radius, &obj)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
BRepFilletAPI_MakeChamfer mkChamfer(shape);
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
@@ -1360,7 +1364,7 @@ PyObject* TopoShapePy::makeChamfer(PyObject *args)
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& edge = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
if (edge.ShapeType() == TopAbs_EDGE) {
//Add edge to fillet algorithm
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
@@ -1403,7 +1407,7 @@ PyObject* TopoShapePy::makeThickness(PyObject *args)
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
facesToRemove.Append(shape);
}
}
@@ -1454,7 +1458,9 @@ PyObject* TopoShapePy::reverse(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
getTopoShapePtr()->_Shape.Reverse();
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Reverse();
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1463,7 +1469,9 @@ PyObject* TopoShapePy::complement(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
getTopoShapePtr()->_Shape.Complement();
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Complement();
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1472,7 +1480,9 @@ PyObject* TopoShapePy::nullify(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
getTopoShapePtr()->_Shape.Nullify();
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Nullify();
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1489,7 +1499,7 @@ PyObject* TopoShapePy::isClosed(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
if (getTopoShapePtr()->_Shape.IsNull())
if (getTopoShapePtr()->getShape().IsNull())
Standard_Failure::Raise("Cannot determine the 'Closed'' flag of an empty shape");
return Py_BuildValue("O", (getTopoShapePtr()->isClosed() ? Py_True : Py_False));
}
@@ -1505,8 +1515,8 @@ PyObject* TopoShapePy::isEqual(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
Standard_Boolean test = (getTopoShapePtr()->_Shape.IsEqual(shape));
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
Standard_Boolean test = (getTopoShapePtr()->getShape().IsEqual(shape));
return Py_BuildValue("O", (test ? Py_True : Py_False));
}
@@ -1516,8 +1526,8 @@ PyObject* TopoShapePy::isSame(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
Standard_Boolean test = getTopoShapePtr()->_Shape.IsSame(shape);
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
Standard_Boolean test = getTopoShapePtr()->getShape().IsSame(shape);
return Py_BuildValue("O", (test ? Py_True : Py_False));
}
@@ -1527,8 +1537,8 @@ PyObject* TopoShapePy::isPartner(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj))
return NULL;
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->_Shape;
Standard_Boolean test = getTopoShapePtr()->_Shape.IsPartner(shape);
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
Standard_Boolean test = getTopoShapePtr()->getShape().IsPartner(shape);
return Py_BuildValue("O", (test ? Py_True : Py_False));
}
@@ -1564,7 +1574,7 @@ PyObject* TopoShapePy::hashCode(PyObject *args)
int upper = IntegerLast();
if (!PyArg_ParseTuple(args, "|i",&upper))
return 0;
int hc = getTopoShapePtr()->_Shape.HashCode(upper);
int hc = getTopoShapePtr()->getShape().HashCode(upper);
return Py_BuildValue("i", hc);
}
@@ -1578,7 +1588,7 @@ PyObject* TopoShapePy::tessellate(PyObject *args)
std::vector<Base::Vector3d> Points;
std::vector<Data::ComplexGeoData::Facet> Facets;
if (PyObject_IsTrue(ok))
BRepTools::Clean(getTopoShapePtr()->_Shape);
BRepTools::Clean(getTopoShapePtr()->getShape());
getTopoShapePtr()->getFaces(Points, Facets,tolerance);
Py::Tuple tuple(2);
Py::List vertex;
@@ -1610,13 +1620,13 @@ PyObject* TopoShapePy::project(PyObject *args)
PyObject *obj;
BRepAlgo_NormalProjection algo;
algo.Init(this->getTopoShapePtr()->_Shape);
algo.Init(this->getTopoShapePtr()->getShape());
if (PyArg_ParseTuple(args, "O", &obj)) {
try {
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
algo.Add(shape);
}
}
@@ -1642,8 +1652,8 @@ PyObject* TopoShapePy::makeParallelProjection(PyObject *args)
PyObject *pShape, *pDir;
if (PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->getShape();
Base::Vector3d vec = Py::Vector(pDir,false).toVector();
BRepProj_Projection proj(wire, shape, gp_Dir(vec.x,vec.y,vec.z));
TopoDS_Shape projected = proj.Shape();
@@ -1664,8 +1674,8 @@ PyObject* TopoShapePy::makePerspectiveProjection(PyObject *args)
PyObject *pShape, *pDir;
if (PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir)) {
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape;
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->getShape();
Base::Vector3d vec = Py::Vector(pDir,false).toVector();
BRepProj_Projection proj(wire, shape, gp_Pnt(vec.x,vec.y,vec.z));
TopoDS_Shape projected = proj.Shape();
@@ -1742,7 +1752,7 @@ PyObject* TopoShapePy::isInside(PyObject *args)
if (!PyArg_ParseTuple(args, "O!dO!", &(Base::VectorPy::Type), &point, &tolerance, &PyBool_Type, &checkFace))
return NULL;
try {
TopoDS_Shape shape = getTopoShapePtr()->_Shape;
TopoDS_Shape shape = getTopoShapePtr()->getShape();
BRepClass3d_SolidClassifier solidClassifier(shape);
Base::Vector3d pnt = static_cast<Base::VectorPy*>(point)->value();
gp_Pnt vertex = gp_Pnt(pnt.x,pnt.y,pnt.z);
@@ -1843,8 +1853,8 @@ PyObject* TopoShapePy::proximity(PyObject *args)
Standard_Real tol = Precision::Confusion();
if (!PyArg_ParseTuple(args, "O!|d",&(TopoShapePy::Type), &ps2, &tol))
return 0;
const TopoDS_Shape& s1 = getTopoShapePtr()->_Shape;
const TopoDS_Shape& s2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr()->_Shape;
const TopoDS_Shape& s1 = getTopoShapePtr()->getShape();
const TopoDS_Shape& s2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr()->getShape();
if (s1.IsNull()) {
PyErr_SetString(PyExc_ValueError, "proximity: Shape object is invalid");
return 0;
@@ -1898,9 +1908,9 @@ PyObject* TopoShapePy::distToShape(PyObject *args)
if (!PyArg_ParseTuple(args, "O!",&(TopoShapePy::Type), &ps2))
return 0;
const TopoDS_Shape& s1 = getTopoShapePtr()->_Shape;
const TopoDS_Shape& s1 = getTopoShapePtr()->getShape();
TopoShape* ts1 = getTopoShapePtr();
const TopoDS_Shape& s2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr()->_Shape;
const TopoDS_Shape& s2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr()->getShape();
TopoShape* ts2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr();
if (s2.IsNull()) {
@@ -2010,7 +2020,7 @@ PyObject* TopoShapePy::distToShape(PyObject *args)
#if 0 // see ComplexGeoDataPy::Matrix which does the same
Py::Object TopoShapePy::getLocation(void) const
{
const TopLoc_Location& loc = getTopoShapePtr()->_Shape.Location();
const TopLoc_Location& loc = getTopoShapePtr()->getShape().Location();
gp_Trsf trf = (gp_Trsf)loc;
Base::Matrix4D mat;
mat[0][0] = trf.Value(1,1);
@@ -2043,7 +2053,7 @@ void TopoShapePy::setLocation(Py::Object o)
trf.SetRotation(gp_Ax1(gp_Pnt(), gp_Dir(axis.x, axis.y, axis.z)), angle);
trf.SetTranslationPart(gp_Vec(mat[0][3],mat[1][3],mat[2][3]));
TopLoc_Location loc(trf);
getTopoShapePtr()->_Shape.Location(loc);
getTopoShapePtr()->getShape().Location(loc);
}
else {
std::string error = std::string("type must be 'Matrix', not ");
@@ -2055,7 +2065,7 @@ void TopoShapePy::setLocation(Py::Object o)
Py::String TopoShapePy::getShapeType(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->_Shape;
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine type of null shape");
TopAbs_ShapeEnum type = sh.ShapeType();
@@ -2096,7 +2106,7 @@ Py::String TopoShapePy::getShapeType(void) const
Py::String TopoShapePy::getOrientation(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->_Shape;
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
TopAbs_Orientation type = sh.Orientation();
@@ -2122,7 +2132,7 @@ Py::String TopoShapePy::getOrientation(void) const
void TopoShapePy::setOrientation(Py::String arg)
{
TopoDS_Shape& sh = getTopoShapePtr()->_Shape;
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
std::string name = (std::string)arg;
@@ -2144,6 +2154,7 @@ void TopoShapePy::setOrientation(Py::String arg)
}
sh.Orientation(type);
getTopoShapePtr()->setShape(sh);
}
Py::List TopoShapePy::getFaces(void) const
@@ -2151,7 +2162,7 @@ Py::List TopoShapePy::getFaces(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_FACE);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_FACE);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2172,7 +2183,7 @@ Py::List TopoShapePy::getVertexes(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_VERTEX);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_VERTEX);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2193,7 +2204,7 @@ Py::List TopoShapePy::getShells(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_SHELL);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_SHELL);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2214,7 +2225,7 @@ Py::List TopoShapePy::getSolids(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_SOLID);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_SOLID);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2235,7 +2246,7 @@ Py::List TopoShapePy::getCompSolids(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_COMPSOLID);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_COMPSOLID);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2256,7 +2267,7 @@ Py::List TopoShapePy::getEdges(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_EDGE);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_EDGE);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2277,7 +2288,7 @@ Py::List TopoShapePy::getWires(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_WIRE);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_WIRE);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2298,7 +2309,7 @@ Py::List TopoShapePy::getCompounds(void) const
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(getTopoShapePtr()->_Shape,TopAbs_COMPOUND);
TopExp_Explorer Ex(getTopoShapePtr()->getShape(),TopAbs_COMPOUND);
while (Ex.More())
{
M.Add(Ex.Current());
@@ -2316,7 +2327,7 @@ Py::List TopoShapePy::getCompounds(void) const
Py::Float TopoShapePy::getLength(void) const
{
const TopoDS_Shape& shape = getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
if (shape.IsNull())
throw Py::RuntimeError("shape is invalid");
GProp_GProps props;
@@ -2326,7 +2337,7 @@ Py::Float TopoShapePy::getLength(void) const
Py::Float TopoShapePy::getArea(void) const
{
const TopoDS_Shape& shape = getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
if (shape.IsNull())
throw Py::RuntimeError("shape is invalid");
GProp_GProps props;
@@ -2336,7 +2347,7 @@ Py::Float TopoShapePy::getArea(void) const
Py::Float TopoShapePy::getVolume(void) const
{
const TopoDS_Shape& shape = getTopoShapePtr()->_Shape;
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
if (shape.IsNull())
throw Py::RuntimeError("shape is invalid");
GProp_GProps props;