LGTM: [skip ci] fix: Declaration hides parameter

A local variable hides a parameter. This may be confusing. Consider renaming one of them.
This commit is contained in:
wmayer
2020-07-27 10:57:34 +02:00
parent e727cd3754
commit 44f42a8e2c
23 changed files with 153 additions and 141 deletions

View File

@@ -423,10 +423,10 @@ void SVGOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o
}
}
void SVGOutput::printGeneric(const BRepAdaptor_Curve& c, int id, std::ostream& out)
void SVGOutput::printGeneric(const BRepAdaptor_Curve& bac, int id, std::ostream& out)
{
TopLoc_Location location;
Handle(Poly_Polygon3D) polygon = BRep_Tool::Polygon3D(c.Edge(), location);
Handle(Poly_Polygon3D) polygon = BRep_Tool::Polygon3D(bac.Edge(), location);
if (!polygon.IsNull()) {
const TColgp_Array1OfPnt& nodes = polygon->Nodes();
char c = 'M';
@@ -436,13 +436,13 @@ void SVGOutput::printGeneric(const BRepAdaptor_Curve& c, int id, std::ostream& o
c = 'L';
}
out << "\" />" << endl;
} else if (c.GetType() == GeomAbs_Line) {
} else if (bac.GetType() == GeomAbs_Line) {
//BRep_Tool::Polygon3D assumes the edge has polygon representation - ie already been "tessellated"
//this is not true for all edges, especially "floating edges"
double f = c.FirstParameter();
double l = c.LastParameter();
gp_Pnt s = c.Value(f);
gp_Pnt e = c.Value(l);
double f = bac.FirstParameter();
double l = bac.LastParameter();
gp_Pnt s = bac.Value(f);
gp_Pnt e = bac.Value(l);
char c = 'M';
out << "<path id= \"" /*<< ViewName*/ << id << "\" d=\" ";
out << c << " " << s.X() << " " << s.Y()<< " " ;

View File

@@ -679,9 +679,9 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
TCollection_ExtendedString extstr = name->Get();
char* str = new char[extstr.LengthOfCString()+1];
extstr.ToUTF8CString(str);
std::string label(str);
if (!label.empty())
myNameMap[aShape.HashCode(INT_MAX)] = label;
std::string labelName(str);
if (!labelName.empty())
myNameMap[aShape.HashCode(INT_MAX)] = labelName;
delete [] str;
}

View File

@@ -772,18 +772,19 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
continue;
}
auto &info = childrenMap[obj];
if(info.plas.empty()) {
auto &childInfo = childrenMap[obj];
if (childInfo.plas.empty()) {
children.push_back(obj);
visibilities.push_back(vis);
info.shape = childShape;
childInfo.shape = childShape;
}
info.vis.push_back(vis);
info.labels.push_back(childLabel);
info.plas.emplace_back(Part::TopoShape::convert(childShape.Location().Transformation()));
childInfo.vis.push_back(vis);
childInfo.labels.push_back(childLabel);
childInfo.plas.emplace_back(Part::TopoShape::convert(childShape.Location().Transformation()));
Quantity_Color aColor;
if (aColorTool->GetColor(childShape, XCAFDoc_ColorSurf, aColor)) {
auto &color = info.colors[info.plas.size()-1];
auto &color = childInfo.colors[childInfo.plas.size()-1];
color.r = (float)aColor.Red();
color.g = (float)aColor.Green();
color.b = (float)aColor.Blue();
@@ -801,10 +802,10 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
int i=-1;
for(auto &child : children) {
++i;
auto &info = childrenMap[child];
if(info.plas.size()==1) {
child = loadShape(doc,info.labels.front(),info.shape);
getSHUOColors(info.labels.front(),shuoColors,true);
auto &childInfo = childrenMap[child];
if (childInfo.plas.size() == 1) {
child = loadShape(doc, childInfo.labels.front(), childInfo.shape);
getSHUOColors(childInfo.labels.front(), shuoColors, true);
continue;
}
@@ -815,24 +816,24 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
// link->Visibility.setValue(false);
link->setLink(-1,child);
link->ShowElement.setValue(false);
link->ElementCount.setValue(info.plas.size());
link->ElementCount.setValue(childInfo.plas.size());
auto it = myCollapsedObjects.find(child);
if(it!=myCollapsedObjects.end()) {
// child is a single component assembly that has been
// collapsed, so we have to honour its placement
for(auto &pla : info.plas)
for(auto &pla : childInfo.plas)
pla *= it->second->getValue();
}
link->PlacementList.setValue(info.plas);
link->VisibilityList.setValue(info.vis);
link->PlacementList.setValue(childInfo.plas);
link->VisibilityList.setValue(childInfo.vis);
for(auto &v : info.colors)
for(auto &v : childInfo.colors)
applyLinkColor(link,v.first,v.second);
int i=0;
std::string name = link->getNameInDocument();
name += '.';
for(auto childLabel : info.labels) {
for(auto childLabel : childInfo.labels) {
myNames.emplace(childLabel,name + std::to_string(i++));
getSHUOColors(childLabel,shuoColors,true);
}
@@ -840,7 +841,7 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
child = link;
Info objInfo;
objInfo.obj = child;
setObjectName(objInfo,info.labels.front());
setObjectName(objInfo, childInfo.labels.front());
}
}
@@ -1244,22 +1245,22 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
auto linkArray = obj->getLinkedObject(true)->getExtensionByType<App::LinkBaseExtension>(true);
if(linkArray && (linkArray->getShowElementValue() || !linkArray->getElementCountValue()))
linkArray = 0;
for(auto &sub : subs) {
App::DocumentObject *parent = 0;
for(auto &subobj : subs) {
App::DocumentObject *parentGrp = 0;
std::string childName;
auto sobj = obj->resolve(sub.c_str(),&parent,&childName);
auto sobj = obj->resolve(subobj.c_str(),&parentGrp,&childName);
if(!sobj) {
FC_WARN("Cannot find object " << obj->getFullName() << '.' << sub);
FC_WARN("Cannot find object " << obj->getFullName() << '.' << subobj);
continue;
}
int vis = -1;
if(parent) {
if(parentGrp) {
if(groupLinks.size()
&& parent->getExtensionByType<App::GroupExtension>(true,false))
&& parentGrp->getExtensionByType<App::GroupExtension>(true,false))
{
vis = groupLinks.back()->isElementVisible(childName.c_str());
}else
vis = parent->isElementVisible(childName.c_str());
vis = parentGrp->isElementVisible(childName.c_str());
}
if(vis < 0)
@@ -1268,7 +1269,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
if(!vis && !exportHidden)
continue;
TDF_Label childLabel = exportObject(obj,sub.c_str(),label,linkArray?childName.c_str():0);
TDF_Label childLabel = exportObject(obj,subobj.c_str(),label,linkArray?childName.c_str():0);
if(childLabel.IsNull())
continue;
@@ -1299,7 +1300,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
}
}
if(groupLinks.size() && groupLinks.back()==obj)
if (groupLinks.size() && groupLinks.back()==obj)
groupLinks.pop_back();
// Finished adding components. Now retrieve the computed non-located shape

View File

@@ -202,16 +202,16 @@ void ViewProviderInspection::updateData(const App::Property* prop)
// set the Distance property to the correct size to sync size of material node with number
// of vertices/points of the referenced geometry
if (object->getTypeId().isDerivedFrom(meshId)) {
App::Property* prop = object->getPropertyByName("Mesh");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
App::Property* propM = object->getPropertyByName("Mesh");
if (propM && propM->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(propM)->getComplexData();
data->getFaces(points, faces, accuracy);
}
}
else if (object->getTypeId().isDerivedFrom(shapeId)) {
App::Property* prop = object->getPropertyByName("Shape");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
App::Property* propS = object->getPropertyByName("Shape");
if (propS && propS->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(propS)->getComplexData();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
@@ -222,9 +222,9 @@ void ViewProviderInspection::updateData(const App::Property* prop)
}
}
else if (object->getTypeId().isDerivedFrom(pointId)) {
App::Property* prop = object->getPropertyByName("Points");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
App::Property* propP = object->getPropertyByName("Points");
if (propP && propP->getTypeId().isDerivedFrom(propId)) {
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(propP)->getComplexData();
std::vector<Base::Vector3d> normals;
data->getPoints(points, normals, accuracy);
}

View File

@@ -938,20 +938,20 @@ struct LMCylinderFunctor
Eigen::MatrixXd measuredValues;
// Compute 'm' errors, one for each data point, for the given parameter values in 'x'
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const
int operator()(const Eigen::VectorXd &xvec, Eigen::VectorXd &fvec) const
{
// 'x' has dimensions n x 1
// 'xvec' has dimensions n x 1
// It contains the current estimates for the parameters.
// 'fvec' has dimensions m x 1
// It will contain the error for each data point.
double aParam = x(0); // dir_x
double bParam = x(1); // dir_y
double cParam = x(2); // dir_z
double dParam = x(3); // cnt_x
double eParam = x(4); // cnt_y
double fParam = x(5); // cnt_z
double gParam = x(6); // radius
double aParam = xvec(0); // dir_x
double bParam = xvec(1); // dir_y
double cParam = xvec(2); // dir_z
double dParam = xvec(3); // cnt_x
double eParam = xvec(4); // cnt_y
double fParam = xvec(5); // cnt_z
double gParam = xvec(6); // radius
// use distance functions (fvec(i)) for cylinders as defined in the paper:
// Least-Squares Fitting Algorithms of the NIST Algorithm Testing System

View File

@@ -586,17 +586,17 @@ void CurveOnMeshHandler::closeWire()
}
}
void CurveOnMeshHandler::Private::vertexCallback(void * ud, SoEventCallback * n)
void CurveOnMeshHandler::Private::vertexCallback(void * ud, SoEventCallback * cb)
{
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(cb->getUserData());
const SoEvent* ev = cb->getEvent();
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
// set as handled
n->setHandled();
cb->setHandled();
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
const SoPickedPoint * pp = n->getPickedPoint();
const SoPickedPoint * pp = cb->getPickedPoint();
if (pp) {
CurveOnMeshHandler* self = static_cast<CurveOnMeshHandler*>(ud);
if (!self->d_ptr->wireClosed) {

View File

@@ -438,7 +438,6 @@ PyObject* GeometryPy::getExtensions(PyObject *args)
if(p) {
// we create a python copy and add it to the list
Py::Tuple args(size_t(0));
PyObject* cpy = static_cast<GeometryExtensionPy *>(p->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
PyList_SetItem( list, i, cpy);

View File

@@ -698,13 +698,13 @@ void DlgFilletEdges::changeEvent(QEvent *e)
}
}
void DlgFilletEdges::on_shapeObject_activated(int index)
void DlgFilletEdges::on_shapeObject_activated(int itemPos)
{
d->object = 0;
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
model->removeRows(0, model->rowCount());
QByteArray name = ui->shapeObject->itemData(index).toByteArray();
QByteArray name = ui->shapeObject->itemData(itemPos).toByteArray();
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc)
return;

View File

@@ -1960,8 +1960,8 @@ void prepareTransformed(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const
return;
}
else {
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
if (pcActiveBody != PartDesignGui::getBodyFor(features[0], false)) {
PartDesign::Body *activeBody = PartDesignGui::getBody(true);
if (activeBody != PartDesignGui::getBodyFor(features[0], false)) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection is not in Active Body"),
QObject::tr("Please select only one feature in an active body."));
return;

View File

@@ -71,9 +71,9 @@ PyObject* FeaturePathCompoundPy::addObject(PyObject *args)
Py::Callable method(vp.getAttr(std::string("addObject")));
// check to which method this belongs to avoid an infinite recursion
if (method.getAttr(std::string("__self__")) != Py::Object(this)) {
Py::Tuple args(1);
args[0] = Py::Object(object);
method.apply(args);
Py::Tuple arg(1);
arg[0] = Py::Object(object);
method.apply(arg);
Py_Return;
}
}
@@ -112,9 +112,9 @@ PyObject* FeaturePathCompoundPy::removeObject(PyObject *args)
Py::Callable method(vp.getAttr(std::string("removeObject")));
// check to which method this belongs to avoid an infinite recursion
if (method.getAttr(std::string("__self__")) != Py::Object(this)) {
Py::Tuple args(1);
args[0] = Py::Object(object);
method.apply(args);
Py::Tuple arg(1);
arg[0] = Py::Object(object);
method.apply(arg);
Py_Return;
}
}

View File

@@ -287,9 +287,9 @@ FillingPanel::~FillingPanel()
}
// stores object pointer, its old fill type and adjusts radio buttons according to it.
void FillingPanel::setEditedObject(Surface::Filling* obj)
void FillingPanel::setEditedObject(Surface::Filling* fea)
{
editedObject = obj;
editedObject = fea;
// get the link to the initial surface if set
App::DocumentObject* initFace = editedObject->InitialFace.getValue();

View File

@@ -144,9 +144,9 @@ FillingUnboundPanel::~FillingUnboundPanel()
}
// stores object pointer, its old fill type and adjusts radio buttons according to it.
void FillingUnboundPanel::setEditedObject(Surface::Filling* obj)
void FillingUnboundPanel::setEditedObject(Surface::Filling* fea)
{
editedObject = obj;
editedObject = fea;
// get the unbound edges, if set their adjacent faces and continuities
auto objects = editedObject->UnboundEdges.getValues();