Toponaming/Part: Add deprecation comments, clean up code

This commit is contained in:
bgbsww
2024-04-07 12:39:32 -04:00
parent 231a638fc7
commit 942ebd58f0
17 changed files with 594 additions and 326 deletions

View File

@@ -1319,6 +1319,7 @@ template<> PyObject* Part::FeaturePython::getPyObject() {
template class PartExport FeaturePythonT<Part::Feature>;
}
// TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible.
std::vector<Part::cutFaces> Part::findAllFacesCutBy(
const TopoDS_Shape& shape, const TopoDS_Shape& face, const gp_Dir& dir)
{
@@ -1359,38 +1360,42 @@ std::vector<Part::cutFaces> Part::findAllFacesCutBy(
return result;
}
std::vector<Part::cutFaces> Part::findAllFacesCutBy(
const TopoShape& shape, const TopoShape& face, const gp_Dir& dir)
std::vector<Part::cutTopoShapeFaces>
Part::findAllFacesCutBy(const TopoShape& shape, const TopoShape& face, const gp_Dir& dir)
{
// Find the centre of gravity of the face
GProp_GProps props;
BRepGProp::SurfaceProperties(face.getShape(),props);
BRepGProp::SurfaceProperties(face.getShape(), props);
gp_Pnt cog = props.CentreOfMass();
// create a line through the centre of gravity
gp_Lin line = gce_MakeLin(cog, dir);
// Find intersection of line with all faces of the shape
std::vector<cutFaces> result;
std::vector<cutTopoShapeFaces> result;
BRepIntCurveSurface_Inter mkSection;
// TODO: Less precision than Confusion() should be OK?
for (mkSection.Init(shape.getShape(), line, Precision::Confusion()); mkSection.More(); mkSection.Next()) {
for (mkSection.Init(shape.getShape(), line, Precision::Confusion()); mkSection.More();
mkSection.Next()) {
gp_Pnt iPnt = mkSection.Pnt();
double dsq = cog.SquareDistance(iPnt);
if (dsq < Precision::Confusion())
continue; // intersection with original face
if (dsq < Precision::Confusion()) {
continue; // intersection with original face
}
// Find out which side of the original face the intersection is on
gce_MakeDir mkDir(cog, iPnt);
if (!mkDir.IsDone())
continue; // some error (appears highly unlikely to happen, though...)
if (!mkDir.IsDone()) {
continue; // some error (appears highly unlikely to happen, though...)
}
if (mkDir.Value().IsOpposite(dir, Precision::Confusion()))
continue; // wrong side of face (opposite to extrusion direction)
if (mkDir.Value().IsOpposite(dir, Precision::Confusion())) {
continue; // wrong side of face (opposite to extrusion direction)
}
cutFaces newF;
cutTopoShapeFaces newF;
newF.face = mkSection.Face();
newF.face.mapSubElement(shape);
newF.distsq = dsq;