Small cleanups

This commit is contained in:
bgbsww
2024-01-22 16:13:53 -05:00
parent 5586c52069
commit 6ec676799d
2 changed files with 18 additions and 16 deletions

View File

@@ -181,28 +181,30 @@ void Part::FaceMaker::postBuild() {
this->myTopoShape.setShape(this->myShape);
this->myTopoShape.Hasher = this->MyHasher;
this->myTopoShape.mapSubElement(this->mySourceShapes);
int i = 0;
int index = 0;
const char *op = this->MyOp;
if(!op)
op = Part::OpCodes::Face;
const auto &faces = this->myTopoShape.getSubTopoShapes(TopAbs_FACE);
// name the face using the edges of its outer wire
for(auto &face : faces) {
++i;
++index;
TopoShape wire = face.splitWires();
wire.mapSubElement(face);
std::set<ElementName> edgeNames;
int count = wire.countSubShapes(TopAbs_EDGE);
for(int i=1;i<=count;++i) {
for (int index2 = 1; index2 <= count; ++index2) {
Data::ElementIDRefs sids;
Data::MappedName name = face.getMappedName(
Data::IndexedName::fromConst("Edge",i), false, &sids);
if(!name)
Data::MappedName name =
face.getMappedName(Data::IndexedName::fromConst("Edge", index2), false, &sids);
if (!name) {
continue;
edgeNames.emplace(wire.getElementHistory(name),name,sids);
}
edgeNames.emplace(wire.getElementHistory(name), name, sids);
}
if(edgeNames.empty())
if (edgeNames.empty()) {
continue;
}
std::vector<Data::MappedName> names;
Data::ElementIDRefs sids;
@@ -211,7 +213,7 @@ void Part::FaceMaker::postBuild() {
names.push_back(edgeNames.begin()->name);
sids = edgeNames.begin()->sids;
this->myTopoShape.setElementComboName(
Data::IndexedName::fromConst("Face",i),names,op,nullptr,&sids);
Data::IndexedName::fromConst("Face",index),names,op,nullptr,&sids);
}
this->myTopoShape.initCache(true);
this->Done();

View File

@@ -257,7 +257,7 @@ public:
bool analyze(bool runBopCheck, std::ostream&) const;
bool isClosed() const;
bool isCoplanar(const TopoShape& other, double tol = -1) const;
bool findPlane(gp_Pln& pln, double tol = -1) const;
bool findPlane(gp_Pln& plane, double tol = -1) const;
/// Returns true if the expansion of the shape is infinite, false otherwise
bool isInfinite() const;
/// Checks whether the shape is a planar face
@@ -679,7 +679,7 @@ public:
TopoShape& makeElementFace(const std::vector<TopoShape>& shapes,
const char* op = nullptr,
const char* maker = nullptr,
const gp_Pln* pln = nullptr);
const gp_Pln* plane = nullptr);
/** Make a planar face with the input wire or edge
*
* @param shape: input shape. Can be either edge, wire, or compound of
@@ -688,7 +688,7 @@ public:
* the operation
* @param maker: optional type name of the face maker. If not given,
* default to "Part::FaceMakerBullseye"
* @param pln: optional plane of the face.
* @param plane: optional plane of the face.
*
* @return The function creates a planar face. The original content of this
* TopoShape is discarded and replaced with the new shape. The
@@ -699,23 +699,23 @@ public:
TopoShape& makeElementFace(const TopoShape& shape,
const char* op = nullptr,
const char* maker = nullptr,
const gp_Pln* pln = nullptr);
const gp_Pln* plane = nullptr);
/** Make a planar face using this shape
*
* @param op: optional string to be encoded into topo naming for indicating
* the operation
* @param maker: optional type name of the face maker. If not given,
* default to "Part::FaceMakerBullseye"
* @param pln: optional plane of the face.
* @param plane: optional plane of the face.
*
* @return The function returns a new planar face made using the wire or edge
* inside this shape. The shape itself is not modified.
*/
TopoShape makeElementFace(const char* op = nullptr,
const char* maker = nullptr,
const gp_Pln* pln = nullptr) const
const gp_Pln* plane = nullptr) const
{
return TopoShape(0, Hasher).makeElementFace(*this, op, maker, pln);
return TopoShape(0, Hasher).makeElementFace(*this, op, maker, plane);
}
/// Filling style when making a BSpline face