Fix mixed line endings

This commit is contained in:
Zheng, Lei
2022-04-26 21:45:10 +08:00
committed by Chris Hennes
parent 2753dd4ca7
commit 3ef438eaf0
66 changed files with 344 additions and 344 deletions

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <boost/regex.hpp>
# include <boost/regex.hpp>
# include <BRepMesh_IncrementalMesh.hxx>
# include <BRepBuilderAPI_Copy.hxx>
# include <BRepBuilderAPI_MakeVertex.hxx>
@@ -136,7 +136,7 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
PY_TRY {
if(PyObject_TypeCheck(pcObj,&TopoShapePy::Type)) {
shape = *static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
}
}
else {
Py::Sequence list(pcObj);
bool first = true;
@@ -154,7 +154,7 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
}
}
}
}
}
_PY_CATCH_OCC(return(-1))
getTopoShapePtr()->setShape(shape.getShape());
@@ -264,7 +264,7 @@ PyObject* TopoShapePy::removeShape(PyObject *args)
std::vector<TopoDS_Shape> shapes;
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::TopoShape sh(*it);
shapes.push_back(sh.extensionObject()->getTopoShapePtr()->getShape());
shapes.push_back(sh.extensionObject()->getTopoShapePtr()->getShape());
}
PyTypeObject* type = this->GetType();
PyObject* inst = type->tp_new(type, this, nullptr);
@@ -283,7 +283,7 @@ PyObject* TopoShapePy::read(PyObject *args)
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return nullptr;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -311,12 +311,12 @@ PyObject* TopoShapePy::writeInventor(PyObject * args, PyObject * keywds)
std::stringstream result;
BRepMesh_IncrementalMesh(getTopoShapePtr()->getShape(),dev);
if (mode == 0) {
if (mode == 0) {
getTopoShapePtr()->exportFaceSet(dev, angle, faceColors, result);
}
else if (mode == 1) {
}
else if (mode == 1) {
getTopoShapePtr()->exportLineSet(result);
}
}
else {
getTopoShapePtr()->exportFaceSet(dev, angle, faceColors, result);
getTopoShapePtr()->exportLineSet(result);
@@ -331,7 +331,7 @@ PyObject* TopoShapePy::exportIges(PyObject *args)
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return nullptr;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -352,7 +352,7 @@ PyObject* TopoShapePy::exportStep(PyObject *args)
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return nullptr;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -590,7 +590,7 @@ PyObject* TopoShapePy::exportStl(PyObject *args)
char* Name;
if (!PyArg_ParseTuple(args, "et|d","utf-8",&Name,&deflection))
return nullptr;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -613,14 +613,14 @@ PyObject* TopoShapePy::exportStl(PyObject *args)
PyObject* TopoShapePy::extrude(PyObject *args)
{
PyObject *pVec;
if (!PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &pVec))
return nullptr;
if (!PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &pVec))
return nullptr;
try {
Base::Vector3d vec = static_cast<Base::VectorPy*>(pVec)->value();
TopoDS_Shape shape = this->getTopoShapePtr()->makePrism(gp_Vec(vec.x,vec.y,vec.z));
TopAbs_ShapeEnum type = shape.ShapeType();
switch (type) {
switch (type) {
case TopAbs_COMPOUND:
return new TopoShapeCompoundPy(new TopoShape(shape));
case TopAbs_COMPSOLID:
@@ -642,7 +642,7 @@ PyObject* TopoShapePy::extrude(PyObject *args)
default:
break;
}
PyErr_SetString(PartExceptionOCCError, "extrusion for this shape type not supported");
return nullptr;
}
@@ -656,16 +656,16 @@ PyObject* TopoShapePy::revolve(PyObject *args)
{
PyObject *pPos,*pDir;
double d=360;
if (!PyArg_ParseTuple(args, "O!O!|d", &(Base::VectorPy::Type), &pPos, &(Base::VectorPy::Type), &pDir,&d))
if (!PyArg_ParseTuple(args, "O!O!|d", &(Base::VectorPy::Type), &pPos, &(Base::VectorPy::Type), &pDir,&d))
return nullptr;
try {
const TopoDS_Shape& input = this->getTopoShapePtr()->getShape();
if (input.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "empty shape cannot be revolved");
return nullptr;
}
TopExp_Explorer xp;
xp.Init(input,TopAbs_SOLID);
if (xp.More()) {
@@ -677,14 +677,14 @@ PyObject* TopoShapePy::revolve(PyObject *args)
PyErr_SetString(PartExceptionOCCError, "shape must not contain compound solids");
return nullptr;
}
Base::Vector3d pos = static_cast<Base::VectorPy*>(pPos)->value();
Base::Vector3d dir = static_cast<Base::VectorPy*>(pDir)->value();
TopoDS_Shape shape = this->getTopoShapePtr()->revolve(
gp_Ax1(gp_Pnt(pos.x,pos.y,pos.z), gp_Dir(dir.x,dir.y,dir.z)),d*(M_PI/180));
TopAbs_ShapeEnum type = shape.ShapeType();
switch (type) {
switch (type) {
case TopAbs_COMPOUND:
return new TopoShapeCompoundPy(new TopoShape(shape));
case TopAbs_COMPSOLID:
@@ -706,7 +706,7 @@ PyObject* TopoShapePy::revolve(PyObject *args)
default:
break;
}
PyErr_SetString(PartExceptionOCCError, "revolution for this shape type not supported");
return nullptr;
}
@@ -721,7 +721,7 @@ PyObject* TopoShapePy::check(PyObject *args)
PyObject* runBopCheck = Py_False;
if (!PyArg_ParseTuple(args, "|O!", &(PyBool_Type), &runBopCheck))
return nullptr;
if (!getTopoShapePtr()->getShape().IsNull()) {
std::stringstream str;
if (!getTopoShapePtr()->analyze(PyObject_IsTrue(runBopCheck) ? true : false, str)) {
@@ -812,7 +812,7 @@ PyObject* TopoShapePy::multiFuse(PyObject *args)
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O|d", &pcObj, &tolerance))
return nullptr;
std::vector<TopoDS_Shape> shapeVec;
Py::Sequence shapeSeq(pcObj);
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
@@ -1135,7 +1135,7 @@ PyObject* TopoShapePy::generalFuse(PyObject *args)
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O|d", &pcObj, &tolerance))
return nullptr;
std::vector<TopoDS_Shape> shapeVec;
Py::Sequence shapeSeq(pcObj);
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
@@ -1195,7 +1195,7 @@ PyObject* TopoShapePy::childShapes(PyObject *args)
{
PyObject* cumOri = Py_True;
PyObject* cumLoc = Py_True;
if (!PyArg_ParseTuple(args, "|O!O!", &(PyBool_Type), &cumOri, &(PyBool_Type), &cumLoc))
if (!PyArg_ParseTuple(args, "|O!O!", &(PyBool_Type), &cumOri, &(PyBool_Type), &cumLoc))
return nullptr;
try {
@@ -1213,7 +1213,7 @@ PyObject* TopoShapePy::childShapes(PyObject *args)
if (!aChild.IsNull()) {
TopAbs_ShapeEnum type = aChild.ShapeType();
PyObject* pyChild = nullptr;
switch (type) {
switch (type) {
case TopAbs_COMPOUND:
pyChild = new TopoShapeCompoundPy(new TopoShape(aChild));
break;
@@ -1258,32 +1258,32 @@ PyObject* TopoShapePy::childShapes(PyObject *args)
}
namespace Part {
// Containers to associate TopAbs_ShapeEnum values to each TopoShape*Py class
const std::vector<std::pair<PyTypeObject*, TopAbs_ShapeEnum>> vecTypeShape = {
{&TopoShapeCompoundPy::Type, TopAbs_COMPOUND},
{&TopoShapeCompSolidPy::Type, TopAbs_COMPSOLID},
{&TopoShapeSolidPy::Type, TopAbs_SOLID},
{&TopoShapeShellPy::Type, TopAbs_SHELL},
{&TopoShapeFacePy::Type, TopAbs_FACE},
{&TopoShapeWirePy::Type, TopAbs_WIRE},
{&TopoShapeEdgePy::Type, TopAbs_EDGE},
{&TopoShapeVertexPy::Type, TopAbs_VERTEX},
{&TopoShapePy::Type, TopAbs_SHAPE}
};
const std::map<PyTypeObject*, TopAbs_ShapeEnum> mapTypeShape(
vecTypeShape.begin(), vecTypeShape.end());
// Returns shape type of a Python type. Similar to TopAbs::ShapeTypeFromString.
// Returns TopAbs_SHAPE if pyType is not a subclass of any of the TopoShape*Py.
static TopAbs_ShapeEnum ShapeTypeFromPyType(PyTypeObject* pyType)
{
for (auto it = vecTypeShape.begin(); it != vecTypeShape.end(); ++it) {
if (PyType_IsSubtype(pyType, it->first))
return it->second;
}
return TopAbs_SHAPE;
};
// Containers to associate TopAbs_ShapeEnum values to each TopoShape*Py class
const std::vector<std::pair<PyTypeObject*, TopAbs_ShapeEnum>> vecTypeShape = {
{&TopoShapeCompoundPy::Type, TopAbs_COMPOUND},
{&TopoShapeCompSolidPy::Type, TopAbs_COMPSOLID},
{&TopoShapeSolidPy::Type, TopAbs_SOLID},
{&TopoShapeShellPy::Type, TopAbs_SHELL},
{&TopoShapeFacePy::Type, TopAbs_FACE},
{&TopoShapeWirePy::Type, TopAbs_WIRE},
{&TopoShapeEdgePy::Type, TopAbs_EDGE},
{&TopoShapeVertexPy::Type, TopAbs_VERTEX},
{&TopoShapePy::Type, TopAbs_SHAPE}
};
const std::map<PyTypeObject*, TopAbs_ShapeEnum> mapTypeShape(
vecTypeShape.begin(), vecTypeShape.end());
// Returns shape type of a Python type. Similar to TopAbs::ShapeTypeFromString.
// Returns TopAbs_SHAPE if pyType is not a subclass of any of the TopoShape*Py.
static TopAbs_ShapeEnum ShapeTypeFromPyType(PyTypeObject* pyType)
{
for (auto it = vecTypeShape.begin(); it != vecTypeShape.end(); ++it) {
if (PyType_IsSubtype(pyType, it->first))
return it->second;
}
return TopAbs_SHAPE;
};
}
PyObject* TopoShapePy::ancestorsOfType(PyObject *args)
@@ -1303,11 +1303,11 @@ PyObject* TopoShapePy::ancestorsOfType(PyObject *args)
}
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
TopTools_IndexedDataMapOfShapeListOfShape mapOfShapeShape;
TopExp::MapShapesAndAncestors(model, shape.ShapeType(), shapetype, mapOfShapeShape);
@@ -1354,7 +1354,7 @@ PyObject* TopoShapePy::removeInternalWires(PyObject *args)
PyObject* TopoShapePy::mirror(PyObject *args)
{
PyObject *v1, *v2;
if (!PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type),&v1, &(Base::VectorPy::Type),&v2))
if (!PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type),&v1, &(Base::VectorPy::Type),&v2))
return nullptr;
Base::Vector3d base = Py::Vector(v1,false).toVector();
@@ -1402,7 +1402,7 @@ PyObject* TopoShapePy::transformShape(PyObject *args)
this->getTopoShapePtr()->transformShape(mat, PyObject_IsTrue(copy) ? true : false,
PyObject_IsTrue(checkScale));
return IncRef();
}
}
PY_CATCH_OCC
}
@@ -1416,14 +1416,14 @@ PyObject* TopoShapePy::transformed(PyObject *args, PyObject *keywds)
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O!|OOs", kwlist,
&Base::MatrixPy::Type, &pymat,&copy,&checkScale,&op))
return nullptr;
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(pymat)->value();
(void)op;
PY_TRY {
TopoShape s(*getTopoShapePtr());
s.transformShape(mat,PyObject_IsTrue(copy),PyObject_IsTrue(checkScale));
return Py::new_reference_to(shape2pyshape(s));
}
}
PY_CATCH_OCC
}
@@ -1451,7 +1451,7 @@ PyObject* TopoShapePy::translate(PyObject *args)
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Move(loc);
getTopoShapePtr()->setShape(shape);
return IncRef();
}
@@ -1480,9 +1480,9 @@ PyObject* TopoShapePy::rotate(PyObject *args)
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Move(loc);
getTopoShapePtr()->setShape(shape);
return IncRef();
}
}
PY_CATCH_OCC
}
@@ -1516,23 +1516,23 @@ PyObject* TopoShapePy::scale(PyObject *args)
getTopoShapePtr()->setShape(BRepScale.Shape());
}
return IncRef();
}
}
PY_CATCH_OCC
}
PyObject* TopoShapePy::translated(PyObject *args)
PyObject* TopoShapePy::translated(PyObject *args)
{
Py::Object pyobj(shape2pyshape(*getTopoShapePtr()));
return static_cast<TopoShapePy*>(pyobj.ptr())->translate(args);
}
PyObject* TopoShapePy::rotated(PyObject *args)
PyObject* TopoShapePy::rotated(PyObject *args)
{
Py::Object pyobj(shape2pyshape(*getTopoShapePtr()));
return static_cast<TopoShapePy*>(pyobj.ptr())->rotate(args);
}
PyObject* TopoShapePy::scaled(PyObject *args)
PyObject* TopoShapePy::scaled(PyObject *args)
{
Py::Object pyobj(shape2pyshape(*getTopoShapePtr()));
return static_cast<TopoShapePy*>(pyobj.ptr())->scale(args);
@@ -1675,9 +1675,9 @@ PyObject* TopoShapePy::makeThickness(PyObject *args)
PyObject* inter = Py_False;
PyObject* self_inter = Py_False;
short offsetMode = 0, join = 0;
if (!PyArg_ParseTuple(args, "Odd|O!O!hh", &obj, &offset, &tolerance,
&(PyBool_Type), &inter, &(PyBool_Type), &self_inter, &offsetMode, &join))
return nullptr;
if (!PyArg_ParseTuple(args, "Odd|O!O!hh", &obj, &offset, &tolerance,
&(PyBool_Type), &inter, &(PyBool_Type), &self_inter, &offsetMode, &join))
return nullptr;
try {
TopTools_ListOfShape facesToRemove;
@@ -1707,7 +1707,7 @@ PyObject* TopoShapePy::makeOffsetShape(PyObject *args, PyObject *keywds)
PyObject* self_inter = Py_False;
PyObject* fill = Py_False;
short offsetMode = 0, join = 0;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd|O!O!hhO!", kwlist, &offset, &tolerance,
if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd|O!O!hhO!", kwlist, &offset, &tolerance,
&(PyBool_Type), &inter, &(PyBool_Type), &self_inter, &offsetMode, &join, &(PyBool_Type), &fill))
return nullptr;
@@ -1732,9 +1732,9 @@ PyObject* TopoShapePy::makeOffset2D(PyObject *args, PyObject *keywds)
PyObject* openResult = Py_False;
PyObject* inter = Py_False;
short join = 0;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|hO!O!O!", kwlist, &offset, &join,
&(PyBool_Type), &fill, &(PyBool_Type), &openResult, &(PyBool_Type), &inter))
return nullptr;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|hO!O!O!", kwlist, &offset, &join,
&(PyBool_Type), &fill, &(PyBool_Type), &openResult, &(PyBool_Type), &inter))
return nullptr;
try {
TopoDS_Shape resultShape = this->getTopoShapePtr()->makeOffset2D(offset, join,
@@ -1754,8 +1754,8 @@ PyObject* TopoShapePy::reverse(PyObject *args)
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Reverse();
getTopoShapePtr()->setShape(shape);
Py_Return;
Py_Return;
}
PyObject* TopoShapePy::reversed(PyObject *args)
@@ -1791,7 +1791,7 @@ PyObject* TopoShapePy::complement(PyObject *args)
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Complement();
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1803,7 +1803,7 @@ PyObject* TopoShapePy::nullify(PyObject *args)
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Nullify();
getTopoShapePtr()->setShape(shape);
Py_Return;
}
@@ -1811,7 +1811,7 @@ PyObject* TopoShapePy::isNull(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
bool null = getTopoShapePtr()->isNull();
return Py_BuildValue("O", (null ? Py_True : Py_False));
}
@@ -1820,7 +1820,7 @@ PyObject* TopoShapePy::isClosed(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
try {
if (getTopoShapePtr()->getShape().IsNull())
Standard_Failure::Raise("Cannot determine the 'Closed'' flag of an empty shape");
@@ -1840,7 +1840,7 @@ PyObject* TopoShapePy::isEqual(PyObject *args)
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));
}
@@ -1852,7 +1852,7 @@ PyObject* TopoShapePy::isSame(PyObject *args)
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));
}
@@ -1864,7 +1864,7 @@ PyObject* TopoShapePy::isPartner(PyObject *args)
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));
}
@@ -1872,10 +1872,10 @@ PyObject* TopoShapePy::isValid(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
PY_TRY {
return Py_BuildValue("O", (getTopoShapePtr()->isValid() ? Py_True : Py_False));
}
}
PY_CATCH_OCC
}
@@ -1885,11 +1885,11 @@ PyObject* TopoShapePy::isCoplanar(PyObject *args)
double tol = -1;
if (!PyArg_ParseTuple(args, "O!|d", &TopoShapePy::Type, &pyObj, &tol))
return nullptr;
PY_TRY {
return Py::new_reference_to(Py::Boolean(getTopoShapePtr()->isCoplanar(
*static_cast<TopoShapePy*>(pyObj)->getTopoShapePtr(),tol)));
}
}
PY_CATCH_OCC
}
@@ -1909,13 +1909,13 @@ PyObject* TopoShapePy::findPlane(PyObject *args)
double tol = -1;
if (!PyArg_ParseTuple(args, "|d", &tol))
return nullptr;
PY_TRY {
gp_Pln pln;
if(getTopoShapePtr()->findPlane(pln,tol))
return new PlanePy(new GeomPlane(new Geom_Plane(pln)));
Py_Return;
}
}
PY_CATCH_OCC
}
@@ -1924,7 +1924,7 @@ PyObject* TopoShapePy::fix(PyObject *args)
double prec, mintol, maxtol;
if (!PyArg_ParseTuple(args, "ddd", &prec, &mintol, &maxtol))
return nullptr;
try {
return Py_BuildValue("O", (getTopoShapePtr()->fix(prec, mintol, maxtol) ? Py_True : Py_False));
}
@@ -1939,7 +1939,7 @@ PyObject* TopoShapePy::hashCode(PyObject *args)
int upper = IntegerLast();
if (!PyArg_ParseTuple(args, "|i",&upper))
return nullptr;
int hc = getTopoShapePtr()->getShape().HashCode(upper);
return Py_BuildValue("i", hc);
}
@@ -1950,7 +1950,7 @@ PyObject* TopoShapePy::tessellate(PyObject *args)
PyObject* ok = Py_False;
if (!PyArg_ParseTuple(args, "f|O!",&tolerance,&PyBool_Type,&ok))
return nullptr;
try {
std::vector<Base::Vector3d> Points;
std::vector<Data::ComplexGeoData::Facet> Facets;
@@ -1987,9 +1987,9 @@ PyObject* TopoShapePy::project(PyObject *args)
BRepAlgo_NormalProjection algo;
algo.Init(this->getTopoShapePtr()->getShape());
if (!PyArg_ParseTuple(args, "O", &obj))
if (!PyArg_ParseTuple(args, "O", &obj))
return nullptr;
try {
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
@@ -1998,7 +1998,7 @@ PyObject* TopoShapePy::project(PyObject *args)
algo.Add(shape);
}
}
algo.Compute3d(Standard_True);
algo.SetLimit(Standard_True);
algo.SetParams(1.e-6, 1.e-6, GeomAbs_C1, 14, 16);
@@ -2015,9 +2015,9 @@ PyObject* TopoShapePy::project(PyObject *args)
PyObject* TopoShapePy::makeParallelProjection(PyObject *args)
{
PyObject *pShape, *pDir;
if (!PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir))
if (!PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir))
return nullptr;
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->getShape();
@@ -2035,9 +2035,9 @@ PyObject* TopoShapePy::makeParallelProjection(PyObject *args)
PyObject* TopoShapePy::makePerspectiveProjection(PyObject *args)
{
PyObject *pShape, *pDir;
if (!PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir))
return nullptr;
if (!PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir))
return nullptr;
try {
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(pShape)->getTopoShapePtr()->getShape();
@@ -2078,9 +2078,9 @@ PyObject* TopoShapePy::reflectLines(PyObject *args, PyObject *kwds)
PyObject* pPos = nullptr;
PyObject* pUp = nullptr;
PyObject *pView;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|O!O!sO!O!", kwlist,
&Base::VectorPy::Type, &pView, &Base::VectorPy::Type, &pPos, &Base::VectorPy::Type,
&pUp, &type, &PyBool_Type, &vis, &PyBool_Type, &in3d))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|O!O!sO!O!", kwlist,
&Base::VectorPy::Type, &pView, &Base::VectorPy::Type, &pPos, &Base::VectorPy::Type,
&pUp, &type, &PyBool_Type, &vis, &PyBool_Type, &in3d))
return nullptr;
try {
@@ -2098,12 +2098,12 @@ PyObject* TopoShapePy::reflectLines(PyObject *args, PyObject *kwds)
t = HLRBRep_OutLine;
Base::Vector3d p(0.0, 0.0, 0.0);
if (pPos)
if (pPos)
p = Py::Vector(pPos,false).toVector();
Base::Vector3d u(0.0, 1.0, 0.0);
if (pUp)
if (pUp)
u = Py::Vector(pUp,false).toVector();
Base::Vector3d v = Py::Vector(pView,false).toVector();
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
HLRAppli_ReflectLines reflect(shape);
@@ -2150,9 +2150,9 @@ PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args)
getTopoShapePtr()->setFaces(Points, Facets, tolerance);
if (PyObject_IsTrue(sewShape))
getTopoShapePtr()->sewShape(tolerance);
Py_Return;
}
}
PY_CATCH_OCC
}
@@ -2160,10 +2160,10 @@ PyObject* TopoShapePy::makeWires(PyObject *args) {
const char *op = nullptr;
if (!PyArg_ParseTuple(args, "s", &op))
return nullptr;
PY_TRY {
return Py::new_reference_to(shape2pyshape(getTopoShapePtr()->makeWires(op)));
}
}
PY_CATCH_OCC
}
@@ -2257,28 +2257,28 @@ PyObject* TopoShapePy::getElement(PyObject *args)
char* input;
if (!PyArg_ParseTuple(args, "s", &input))
return nullptr;
boost::regex ex("^(Face|Edge|Vertex)[1-9][0-9]*$");
boost::regex ex("^(Face|Edge|Vertex)[1-9][0-9]*$");
try {
if (boost::regex_match(input, ex)) {
std::unique_ptr<Part::ShapeSegment> s(static_cast<Part::ShapeSegment*>
(getTopoShapePtr()->getSubElementByName(input)));
TopoDS_Shape shape = s->Shape;
switch (shape.ShapeType()) {
case TopAbs_FACE:
return new TopoShapeFacePy(new TopoShape(shape));
case TopAbs_EDGE:
return new TopoShapeEdgePy(new TopoShape(shape));
case TopAbs_VERTEX:
return new TopoShapeVertexPy(new TopoShape(shape));
default:
break;
}
if (boost::regex_match(input, ex)) {
std::unique_ptr<Part::ShapeSegment> s(static_cast<Part::ShapeSegment*>
(getTopoShapePtr()->getSubElementByName(input)));
TopoDS_Shape shape = s->Shape;
switch (shape.ShapeType()) {
case TopAbs_FACE:
return new TopoShapeFacePy(new TopoShape(shape));
case TopAbs_EDGE:
return new TopoShapeEdgePy(new TopoShape(shape));
case TopAbs_VERTEX:
return new TopoShapeVertexPy(new TopoShape(shape));
default:
break;
}
}
PyErr_SetString(PyExc_ValueError, "Invalid subelement name");
return nullptr;
PyErr_SetString(PyExc_ValueError, "Invalid subelement name");
return nullptr;
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
@@ -2291,30 +2291,30 @@ PyObject* TopoShapePy::countElement(PyObject *args)
char* input;
if (!PyArg_ParseTuple(args, "s", &input))
return nullptr;
PY_TRY {
return Py::new_reference_to(Py::Int((long)getTopoShapePtr()->countSubShapes(input)));
}
}
PY_CATCH_OCC
}
PyObject* TopoShapePy::getTolerance(PyObject *args)
{
int mode;
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
if (!PyArg_ParseTuple(args, "i|O!", &mode, &PyType_Type, &type))
return nullptr;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
ShapeAnalysis_ShapeTolerance analysis;
double tolerance = analysis.Tolerance(shape, mode, shapetype);
@@ -2329,20 +2329,20 @@ PyObject* TopoShapePy::getTolerance(PyObject *args)
PyObject* TopoShapePy::overTolerance(PyObject *args)
{
double value;
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
if (!PyArg_ParseTuple(args, "d|O!", &value, &PyType_Type, &type))
return nullptr;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
ShapeAnalysis_ShapeTolerance analysis;
Handle(TopTools_HSequenceOfShape) seq = analysis.OverTolerance(shape, value, shapetype);
@@ -2364,20 +2364,20 @@ PyObject* TopoShapePy::inTolerance(PyObject *args)
{
double valmin;
double valmax;
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
if (!PyArg_ParseTuple(args, "dd|O!", &valmin, &valmax, &PyType_Type, &type))
return nullptr;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type) ||
(shapetype != TopAbs_SHAPE && shapetype != TopAbs_VERTEX &&
shapetype != TopAbs_EDGE && shapetype != TopAbs_FACE && shapetype != TopAbs_SHELL)) {
PyErr_SetString(PyExc_TypeError, "shape type must be Shape, Vertex, Edge, Face or Shell");
return nullptr;
}
ShapeAnalysis_ShapeTolerance analysis;
Handle(TopTools_HSequenceOfShape) seq = analysis.InTolerance(shape, valmin, valmax, shapetype);
@@ -2406,7 +2406,7 @@ PyObject* TopoShapePy::globalTolerance(PyObject *args)
ShapeAnalysis_ShapeTolerance analysis;
analysis.Tolerance(shape, mode);
double tolerance = analysis.GlobalTolerance(mode);
return PyFloat_FromDouble(tolerance);
}
catch (Standard_Failure& e) {
@@ -2418,19 +2418,19 @@ PyObject* TopoShapePy::globalTolerance(PyObject *args)
PyObject* TopoShapePy::fixTolerance(PyObject *args)
{
double value;
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
if (!PyArg_ParseTuple(args, "d|O!", &value, &PyType_Type, &type))
return nullptr;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
ShapeFix_ShapeTolerance fix;
fix.SetTolerance(shape, value, shapetype);
Py_Return;
@@ -2445,18 +2445,18 @@ PyObject* TopoShapePy::limitTolerance(PyObject *args)
{
double tmin;
double tmax=0;
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
PyObject* type = reinterpret_cast<PyObject*>(&TopoShapePy::Type);
if (!PyArg_ParseTuple(args, "d|dO!", &tmin, &tmax, &PyType_Type, &type))
return nullptr;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
PyTypeObject* pyType = reinterpret_cast<PyTypeObject*>(type);
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
TopAbs_ShapeEnum shapetype = ShapeTypeFromPyType(pyType);
if (!PyType_IsSubtype(pyType, &TopoShapePy::Type)) {
PyErr_SetString(PyExc_TypeError, "type must be a Shape subtype");
return nullptr;
}
ShapeFix_ShapeTolerance fix;
Standard_Boolean ok = fix.LimitTolerance(shape, tmin, tmax, shapetype);
@@ -2496,7 +2496,7 @@ PyObject* TopoShapePy::proximity(PyObject *args)
Standard_Real tol = Precision::Confusion();
if (!PyArg_ParseTuple(args, "O!|d",&(TopoShapePy::Type), &ps2, &tol))
return nullptr;
const TopoDS_Shape& s1 = getTopoShapePtr()->getShape();
const TopoDS_Shape& s2 = static_cast<Part::TopoShapePy*>(ps2)->getTopoShapePtr()->getShape();
if (s1.IsNull()) {
@@ -2841,10 +2841,10 @@ Py::String TopoShapePy::getShapeType(void) const
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine type of null shape");
TopAbs_ShapeEnum type = sh.ShapeType();
std::string name;
switch (type) {
switch (type) {
case TopAbs_COMPOUND:
name = "Compound";
break;
@@ -2882,10 +2882,10 @@ Py::String TopoShapePy::getOrientation(void) const
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine orientation of null shape");
TopAbs_Orientation type = sh.Orientation();
std::string name;
switch (type) {
switch (type) {
case TopAbs_FORWARD:
name = "Forward";
break;
@@ -2908,7 +2908,7 @@ void TopoShapePy::setOrientation(Py::String arg)
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine orientation of null shape");
std::string name = static_cast<std::string>(arg);
TopAbs_Orientation type;
if (name == "Forward") {
@@ -2944,64 +2944,64 @@ Py::List TopoShapePy::getSubShapes(void) const
return ret;
}
template<typename T> Py::List getShapes(const TopoShape* shapePtr)
{
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(shapePtr->getShape(), mapTypeShape.at(&T::Type));
while (Ex.More()) {
M.Add(Ex.Current());
Ex.Next();
}
for (Standard_Integer k = 1; k <= M.Extent(); k++) {
const TopoDS_Shape& shape = M(k);
Base::PyObjectBase* baseObj = new T(new TopoShape(shape));
baseObj->setNotTracking();
ret.append(Py::asObject(baseObj));
}
return ret;
}
template<typename T> Py::List getShapes(const TopoShape* shapePtr)
{
Py::List ret;
TopTools_IndexedMapOfShape M;
TopExp_Explorer Ex(shapePtr->getShape(), mapTypeShape.at(&T::Type));
while (Ex.More()) {
M.Add(Ex.Current());
Ex.Next();
}
for (Standard_Integer k = 1; k <= M.Extent(); k++) {
const TopoDS_Shape& shape = M(k);
Base::PyObjectBase* baseObj = new T(new TopoShape(shape));
baseObj->setNotTracking();
ret.append(Py::asObject(baseObj));
}
return ret;
}
Py::List TopoShapePy::getFaces(void) const
{
return getShapes<TopoShapeFacePy>(getTopoShapePtr());
return getShapes<TopoShapeFacePy>(getTopoShapePtr());
}
Py::List TopoShapePy::getVertexes(void) const
{
return getShapes<TopoShapeVertexPy>(getTopoShapePtr());
return getShapes<TopoShapeVertexPy>(getTopoShapePtr());
}
Py::List TopoShapePy::getShells(void) const
{
return getShapes<TopoShapeShellPy>(getTopoShapePtr());
return getShapes<TopoShapeShellPy>(getTopoShapePtr());
}
Py::List TopoShapePy::getSolids(void) const
{
return getShapes<TopoShapeSolidPy>(getTopoShapePtr());
return getShapes<TopoShapeSolidPy>(getTopoShapePtr());
}
Py::List TopoShapePy::getCompSolids(void) const
{
return getShapes<TopoShapeCompSolidPy>(getTopoShapePtr());
return getShapes<TopoShapeCompSolidPy>(getTopoShapePtr());
}
Py::List TopoShapePy::getEdges(void) const
{
return getShapes<TopoShapeEdgePy>(getTopoShapePtr());
return getShapes<TopoShapeEdgePy>(getTopoShapePtr());
}
Py::List TopoShapePy::getWires(void) const
{
return getShapes<TopoShapeWirePy>(getTopoShapePtr());
return getShapes<TopoShapeWirePy>(getTopoShapePtr());
}
Py::List TopoShapePy::getCompounds(void) const
{
return getShapes<TopoShapeCompoundPy>(getTopoShapePtr());
return getShapes<TopoShapeCompoundPy>(getTopoShapePtr());
}
Py::Float TopoShapePy::getLength(void) const
@@ -3036,13 +3036,13 @@ Py::Float TopoShapePy::getVolume(void) const
PyObject *TopoShapePy::getCustomAttributes(const char* attr) const
{
if (!attr)
if (!attr)
return nullptr;
PY_TRY {
TopoDS_Shape res = getTopoShapePtr()->getSubShape(attr,true);
if(!res.IsNull())
return Py::new_reference_to(shape2pyshape(res));
}
}
PY_CATCH_OCC
return nullptr;
}