PD: modernize C++: use range-based for loop
This commit is contained in:
@@ -541,8 +541,8 @@ void Body::onDocumentRestored()
|
||||
bool Body::isSolid()
|
||||
{
|
||||
std::vector<App::DocumentObject *> features = getFullModel();
|
||||
for (auto it = features.begin(); it!=features.end(); ++it){
|
||||
if (isSolidFeature((*it)))
|
||||
for (auto feature : features){
|
||||
if (isSolidFeature(feature))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -265,8 +265,8 @@ void FeatureExtrude::generateTaperedPrism(TopoDS_Shape& prism,
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
for (std::list<TopoDS_Shape>::iterator it = drafts.begin(); it != drafts.end(); ++it)
|
||||
builder.Add(comp, *it);
|
||||
for (const auto & draft : drafts)
|
||||
builder.Add(comp, draft);
|
||||
prism = comp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ App::DocumentObjectExecReturn *Fillet::execute()
|
||||
try {
|
||||
BRepFilletAPI_MakeFillet mkFillet(baseShape.getShape());
|
||||
|
||||
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it->c_str()));
|
||||
for (const auto & it : SubNames) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it.c_str()));
|
||||
mkFillet.Add(radius, edge);
|
||||
}
|
||||
|
||||
|
||||
@@ -954,10 +954,10 @@ double Hole::getThreadClassClearance() const
|
||||
|
||||
// Calculate how much clearance to add based on Thread tolerance class and pitch
|
||||
if (ThreadClass.getValueAsString()[1] == 'G') {
|
||||
for (unsigned int i = 0; i < ThreadClass_ISOmetric_data_size; i++) {
|
||||
double p = ThreadClass_ISOmetric_data[i][0];
|
||||
for (auto it : ThreadClass_ISOmetric_data) {
|
||||
double p = it[0];
|
||||
if (pitch <= p) {
|
||||
return ThreadClass_ISOmetric_data[i][1];
|
||||
return it[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -988,10 +988,10 @@ double Hole::getThreadRunout(int mode) const
|
||||
default:
|
||||
throw Base::ValueError("Unsupported argument");
|
||||
}
|
||||
for (unsigned int i = 0; i < ThreadRunout_size; i++) {
|
||||
double p = ThreadRunout[i][0];
|
||||
for (auto it : ThreadRunout) {
|
||||
double p = it[0];
|
||||
if (pitch <= p) {
|
||||
return sf * ThreadRunout[i][1];
|
||||
return sf * it[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,10 @@ void MultiTransform::positionBySupport()
|
||||
{
|
||||
PartDesign::Transformed::positionBySupport();
|
||||
std::vector<App::DocumentObject*> transFeatures = Transformations.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator f = transFeatures.begin();
|
||||
f != transFeatures.end(); ++f) {
|
||||
if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
for (auto f : transFeatures) {
|
||||
if (!(f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
throw Base::TypeError("Transformation features must be subclasses of Transformed");
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(*f);
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(f);
|
||||
transFeature->Placement.setValue(this->Placement.getValue());
|
||||
|
||||
// To avoid that a linked transform feature stays touched after a recompute
|
||||
|
||||
@@ -536,10 +536,8 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector<std::st
|
||||
//getContinuousEdges(shape, subedge);
|
||||
|
||||
BRepBuilderAPI_MakeWire mkWire;
|
||||
for (std::vector<std::string>::const_iterator it = subedge.begin();
|
||||
it != subedge.end();
|
||||
++it) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
|
||||
for (const auto & it : subedge) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it.c_str());
|
||||
mkWire.Add(TopoDS::Edge(subshape));
|
||||
}
|
||||
path = mkWire.Wire();
|
||||
|
||||
@@ -749,49 +749,49 @@ void ProfileBased::remapSupportShape(const TopoDS_Shape & newShape)
|
||||
shape.setShape(sh);
|
||||
|
||||
std::vector<App::DocumentObject*> refs = this->getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = refs.begin(); it != refs.end(); ++it) {
|
||||
for (auto ref : refs) {
|
||||
std::vector<App::Property*> props;
|
||||
(*it)->getPropertyList(props);
|
||||
for (std::vector<App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
|
||||
if (!(*jt)->isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
|
||||
ref->getPropertyList(props);
|
||||
for (auto prop : props) {
|
||||
if (!prop->isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
|
||||
continue;
|
||||
App::PropertyLinkSub* link = static_cast<App::PropertyLinkSub*>(*jt);
|
||||
App::PropertyLinkSub* link = static_cast<App::PropertyLinkSub*>(prop);
|
||||
if (link->getValue() != this)
|
||||
continue;
|
||||
std::vector<std::string> subValues = link->getSubValues();
|
||||
std::vector<std::string> newSubValues;
|
||||
|
||||
for (std::vector<std::string>::iterator it = subValues.begin(); it != subValues.end(); ++it) {
|
||||
for (auto & subValue : subValues) {
|
||||
std::string shapetype;
|
||||
if (it->compare(0, 4, "Face") == 0) {
|
||||
if (subValue.compare(0, 4, "Face") == 0) {
|
||||
shapetype = "Face";
|
||||
}
|
||||
else if (it->compare(0, 4, "Edge") == 0) {
|
||||
else if (subValue.compare(0, 4, "Edge") == 0) {
|
||||
shapetype = "Edge";
|
||||
}
|
||||
else if (it->compare(0, 6, "Vertex") == 0) {
|
||||
else if (subValue.compare(0, 6, "Vertex") == 0) {
|
||||
shapetype = "Vertex";
|
||||
}
|
||||
else {
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
TopoDS_Shape element;
|
||||
try {
|
||||
element = shape.getSubShape(it->c_str());
|
||||
element = shape.getSubShape(subValue.c_str());
|
||||
}
|
||||
catch (Standard_Failure&) {
|
||||
// This shape doesn't even exist, so no chance to do some tests
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// as very first test check if old face and new face are parallel planes
|
||||
TopoDS_Shape newElement = Part::TopoShape(newShape).getSubShape(it->c_str());
|
||||
TopoDS_Shape newElement = Part::TopoShape(newShape).getSubShape(subValue.c_str());
|
||||
if (isParallelPlane(element, newElement)) {
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@@ -824,7 +824,7 @@ void ProfileBased::remapSupportShape(const TopoDS_Shape & newShape)
|
||||
|
||||
// the new shape couldn't be found so keep the old sub-name
|
||||
if (!success)
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
}
|
||||
|
||||
link->setValue(this, newSubValues);
|
||||
|
||||
@@ -88,8 +88,8 @@ App::DocumentObjectExecReturn *Thickness::execute()
|
||||
|
||||
TopTools_ListOfShape closingFaces;
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it->c_str()));
|
||||
for (const auto & it : subStrings) {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it.c_str()));
|
||||
closingFaces.Append(face);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,14 +248,14 @@ App::DocumentObjectExecReturn *Transformed::execute()
|
||||
// Original separately. This way it is easier to discover what feature causes a fuse/cut
|
||||
// to fail. The downside is that performance suffers when there are many originals. But it seems
|
||||
// safe to assume that in most cases there are few originals and many transformations
|
||||
for (std::vector<App::DocumentObject*>::const_iterator o = originals.begin(); o != originals.end(); ++o)
|
||||
for (auto original : originals)
|
||||
{
|
||||
// Extract the original shape and determine whether to cut or to fuse
|
||||
Part::TopoShape fuseShape;
|
||||
Part::TopoShape cutShape;
|
||||
|
||||
if ((*o)->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
PartDesign::FeatureAddSub* feature = static_cast<PartDesign::FeatureAddSub*>(*o);
|
||||
if (original->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
PartDesign::FeatureAddSub* feature = static_cast<PartDesign::FeatureAddSub*>(original);
|
||||
feature->getAddSubShape(fuseShape, cutShape);
|
||||
if (fuseShape.isNull() && cutShape.isNull())
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Shape of additive/subtractive feature is empty"));
|
||||
|
||||
Reference in New Issue
Block a user