All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent ef997f2259
commit 9fe130cd73
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -23,24 +23,24 @@
***************************************************************************/
# include <BRepBuilderAPI_MakeSolid.hxx>
# include <BRepClass3d.hxx>
# include <BRepGProp.hxx>
# include <BRepLib.hxx>
# include <BRepOffset_MakeOffset.hxx>
# include <GProp_GProps.hxx>
# include <GProp_PrincipalProps.hxx>
# include <Precision.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS.hxx>
# include <TopoDS_CompSolid.hxx>
# include <TopoDS_Shell.hxx>
# include <TopoDS_Solid.hxx>
# include <gp_Ax1.hxx>
# include <gp_Dir.hxx>
# include <gp_Pnt.hxx>
# include <Standard_Failure.hxx>
# include <Standard_Version.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepClass3d.hxx>
#include <BRepGProp.hxx>
#include <BRepLib.hxx>
#include <BRepOffset_MakeOffset.hxx>
#include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_CompSolid.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Failure.hxx>
#include <Standard_Version.hxx>
#include <Base/GeometryPyCXX.h>
@@ -67,7 +67,7 @@ std::string TopoShapeSolidPy::representation() const
return str.str();
}
PyObject *TopoShapeSolidPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
PyObject* TopoShapeSolidPy::PyMake(struct _typeobject*, PyObject*, PyObject*)
{
// create a new instance of TopoShapeSolidPy and the Twin object
return new TopoShapeSolidPy(new TopoShape);
@@ -83,9 +83,10 @@ int TopoShapeSolidPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &obj))
PyObject* obj;
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &obj)) {
return -1;
}
try {
getTopoShapePtr()->makeElementSolid(*static_cast<TopoShapePy*>(obj)->getTopoShapePtr());
@@ -113,7 +114,7 @@ Py::Object TopoShapeSolidPy::getCenterOfMass() const
GProp_GProps props;
BRepGProp::VolumeProperties(getTopoShapePtr()->getShape(), props);
gp_Pnt c = props.CentreOfMass();
return Py::Vector(Base::Vector3d(c.X(),c.Y(),c.Z()));
return Py::Vector(Base::Vector3d(c.X(), c.Y(), c.Z()));
}
Py::Object TopoShapeSolidPy::getMatrixOfInertia() const
@@ -122,9 +123,9 @@ Py::Object TopoShapeSolidPy::getMatrixOfInertia() const
BRepGProp::VolumeProperties(getTopoShapePtr()->getShape(), props);
gp_Mat m = props.MatrixOfInertia();
Base::Matrix4D mat;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
mat[i][j] = m(i+1,j+1);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
mat[i][j] = m(i + 1, j + 1);
}
}
return Py::Matrix(mat);
@@ -134,8 +135,8 @@ Py::Object TopoShapeSolidPy::getStaticMoments() const
{
GProp_GProps props;
BRepGProp::VolumeProperties(getTopoShapePtr()->getShape(), props);
Standard_Real lx,ly,lz;
props.StaticMoments(lx,ly,lz);
Standard_Real lx, ly, lz;
props.StaticMoments(lx, ly, lz);
Py::Tuple tuple(3);
tuple.setItem(0, Py::Float(lx));
tuple.setItem(1, Py::Float(ly));
@@ -152,27 +153,33 @@ Py::Dict TopoShapeSolidPy::getPrincipalProperties() const
Py::Dict dict;
dict.setItem("SymmetryAxis", Py::Boolean(pprops.HasSymmetryAxis() ? true : false));
dict.setItem("SymmetryPoint", Py::Boolean(pprops.HasSymmetryPoint() ? true : false));
Standard_Real lx,ly,lz;
pprops.Moments(lx,ly,lz);
Standard_Real lx, ly, lz;
pprops.Moments(lx, ly, lz);
Py::Tuple tuple(3);
tuple.setItem(0, Py::Float(lx));
tuple.setItem(1, Py::Float(ly));
tuple.setItem(2, Py::Float(lz));
dict.setItem("Moments",tuple);
dict.setItem("FirstAxisOfInertia",Py::Vector(Base::convertTo
<Base::Vector3d>(pprops.FirstAxisOfInertia())));
dict.setItem("SecondAxisOfInertia",Py::Vector(Base::convertTo
<Base::Vector3d>(pprops.SecondAxisOfInertia())));
dict.setItem("ThirdAxisOfInertia",Py::Vector(Base::convertTo
<Base::Vector3d>(pprops.ThirdAxisOfInertia())));
dict.setItem("Moments", tuple);
dict.setItem(
"FirstAxisOfInertia",
Py::Vector(Base::convertTo<Base::Vector3d>(pprops.FirstAxisOfInertia()))
);
dict.setItem(
"SecondAxisOfInertia",
Py::Vector(Base::convertTo<Base::Vector3d>(pprops.SecondAxisOfInertia()))
);
dict.setItem(
"ThirdAxisOfInertia",
Py::Vector(Base::convertTo<Base::Vector3d>(pprops.ThirdAxisOfInertia()))
);
Standard_Real Rxx,Ryy,Rzz;
pprops.RadiusOfGyration(Rxx,Ryy,Rzz);
Standard_Real Rxx, Ryy, Rzz;
pprops.RadiusOfGyration(Rxx, Ryy, Rzz);
Py::Tuple rog(3);
rog.setItem(0, Py::Float(Rxx));
rog.setItem(1, Py::Float(Ryy));
rog.setItem(2, Py::Float(Rzz));
dict.setItem("RadiusOfGyration",rog);
dict.setItem("RadiusOfGyration", rog);
return dict;
}
@@ -180,28 +187,30 @@ Py::Object TopoShapeSolidPy::getOuterShell() const
{
TopoDS_Shell shell;
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
if (!shape.IsNull() && shape.ShapeType() == TopAbs_SOLID)
if (!shape.IsNull() && shape.ShapeType() == TopAbs_SOLID) {
shell = BRepClass3d::OuterShell(TopoDS::Solid(shape));
}
TopoShape res;
res.setShape(shell);
res.mapSubElement(*getTopoShapePtr());
return shape2pyshape(res);
}
PyObject* TopoShapeSolidPy::getMomentOfInertia(PyObject *args) const
PyObject* TopoShapeSolidPy::getMomentOfInertia(PyObject* args) const
{
PyObject *p,*d;
if (!PyArg_ParseTuple(args, "O!O!",&Base::VectorPy::Type,&p
,&Base::VectorPy::Type,&d))
PyObject *p, *d;
if (!PyArg_ParseTuple(args, "O!O!", &Base::VectorPy::Type, &p, &Base::VectorPy::Type, &d)) {
return nullptr;
Base::Vector3d pnt = Py::Vector(p,false).toVector();
Base::Vector3d dir = Py::Vector(d,false).toVector();
}
Base::Vector3d pnt = Py::Vector(p, false).toVector();
Base::Vector3d dir = Py::Vector(d, false).toVector();
try {
GProp_GProps props;
BRepGProp::VolumeProperties(getTopoShapePtr()->getShape(), props);
double r = props.MomentOfInertia(gp_Ax1(Base::convertTo<gp_Pnt>(pnt),
Base::convertTo<gp_Dir>(dir)));
double r = props.MomentOfInertia(
gp_Ax1(Base::convertTo<gp_Pnt>(pnt), Base::convertTo<gp_Dir>(dir))
);
return PyFloat_FromDouble(r);
}
catch (Standard_Failure& e) {
@@ -211,20 +220,21 @@ PyObject* TopoShapeSolidPy::getMomentOfInertia(PyObject *args) const
}
}
PyObject* TopoShapeSolidPy::getRadiusOfGyration(PyObject *args) const
PyObject* TopoShapeSolidPy::getRadiusOfGyration(PyObject* args) const
{
PyObject *p,*d;
if (!PyArg_ParseTuple(args, "O!O!",&Base::VectorPy::Type,&p
,&Base::VectorPy::Type,&d))
PyObject *p, *d;
if (!PyArg_ParseTuple(args, "O!O!", &Base::VectorPy::Type, &p, &Base::VectorPy::Type, &d)) {
return nullptr;
Base::Vector3d pnt = Py::Vector(p,false).toVector();
Base::Vector3d dir = Py::Vector(d,false).toVector();
}
Base::Vector3d pnt = Py::Vector(p, false).toVector();
Base::Vector3d dir = Py::Vector(d, false).toVector();
try {
GProp_GProps props;
BRepGProp::VolumeProperties(getTopoShapePtr()->getShape(), props);
double r = props.RadiusOfGyration(gp_Ax1(Base::convertTo<gp_Pnt>(pnt),
Base::convertTo<gp_Dir>(dir)));
double r = props.RadiusOfGyration(
gp_Ax1(Base::convertTo<gp_Pnt>(pnt), Base::convertTo<gp_Dir>(dir))
);
return PyFloat_FromDouble(r);
}
catch (Standard_Failure& e) {
@@ -234,16 +244,24 @@ PyObject* TopoShapeSolidPy::getRadiusOfGyration(PyObject *args) const
}
}
PyObject* TopoShapeSolidPy::offsetFaces(PyObject *args) const
PyObject* TopoShapeSolidPy::offsetFaces(PyObject* args) const
{
PyObject *obj;
PyObject* obj;
Standard_Real offset;
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
BRepOffset_MakeOffset builder;
// Set here an offset value higher than the tolerance
builder.Initialize(shape,1.0,Precision::Confusion(),BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Intersection);
TopExp_Explorer xp(shape,TopAbs_FACE);
builder.Initialize(
shape,
1.0,
Precision::Confusion(),
BRepOffset_Skin,
Standard_False,
Standard_False,
GeomAbs_Intersection
);
TopExp_Explorer xp(shape, TopAbs_FACE);
while (xp.More()) {
// go through all faces and set offset to zero
builder.SetOffsetOnFace(TopoDS::Face(xp.Current()), 0.0);
@@ -251,13 +269,14 @@ PyObject* TopoShapeSolidPy::offsetFaces(PyObject *args) const
}
bool paramOK = false;
if (PyArg_ParseTuple(args, "Od", &obj,&offset)) {
if (PyArg_ParseTuple(args, "Od", &obj, &offset)) {
paramOK = true;
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
// set offset of the requested faces
const TopoDS_Shape& face = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
const TopoDS_Shape& face
= static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->getShape();
builder.SetOffsetOnFace(TopoDS::Face(face), offset);
}
}
@@ -270,7 +289,8 @@ PyObject* TopoShapeSolidPy::offsetFaces(PyObject *args) const
for (Py::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {
if (PyObject_TypeCheck((*it).first.ptr(), &(Part::TopoShapePy::Type))) {
// set offset of the requested faces
const TopoDS_Shape& face = static_cast<TopoShapePy*>((*it).first.ptr())->getTopoShapePtr()->getShape();
const TopoDS_Shape& face
= static_cast<TopoShapePy*>((*it).first.ptr())->getTopoShapePtr()->getShape();
Standard_Real value = (double)Py::Float((*it).second.ptr());
builder.SetOffsetOnFace(TopoDS::Face(face), value);
}
@@ -296,7 +316,7 @@ PyObject* TopoShapeSolidPy::offsetFaces(PyObject *args) const
}
}
PyObject *TopoShapeSolidPy::getCustomAttributes(const char* /*attr*/) const
PyObject* TopoShapeSolidPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}