fix Coverity issues

This commit is contained in:
wmayer 2016-08-20 17:21:01 +02:00
parent ae663b3b51
commit d80c05e186
18 changed files with 133 additions and 136 deletions

View File

@ -105,7 +105,7 @@ App::DocumentObjectExecReturn *LuxProject::execute(void)
const std::vector<App::DocumentObject*> &Grp = Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
if ((*It)->getTypeId().isDerivedFrom(Raytracing::RaySegment::getClassTypeId())) {
Raytracing::RaySegment *View = dynamic_cast<Raytracing::RaySegment *>(*It);
Raytracing::RaySegment *View = static_cast<Raytracing::RaySegment *>(*It);
ofile << View->Result.getValue();
ofile << endl;
}

View File

@ -99,7 +99,7 @@ App::DocumentObjectExecReturn *RayProject::execute(void)
const std::vector<App::DocumentObject*> &Grp = Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
if ((*It)->getTypeId().isDerivedFrom(Raytracing::RaySegment::getClassTypeId())) {
Raytracing::RaySegment *View = dynamic_cast<Raytracing::RaySegment *>(*It);
Raytracing::RaySegment *View = static_cast<Raytracing::RaySegment *>(*It);
ofile << View->Result.getValue();
ofile << endl << endl << endl;
}

View File

@ -369,9 +369,6 @@ Gui::Action * CmdRaytracingNewPovrayProject::createAction(void)
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* defaultAction = 0;
int defaultId = 0;
std::string path = App::Application::getResourceDir();
path += "Mod/Raytracing/Templates/";
QDir dir(QString::fromUtf8(path.c_str()), QString::fromLatin1("*.pov"));
@ -385,11 +382,7 @@ Gui::Action * CmdRaytracingNewPovrayProject::createAction(void)
_pcAction = pcAction;
languageChange();
if (defaultAction) {
pcAction->setIcon(defaultAction->icon());
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(pcAction->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}
@ -767,9 +760,6 @@ Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* defaultAction = 0;
int defaultId = 0;
std::string path = App::Application::getResourceDir();
path += "Mod/Raytracing/Templates/";
QDir dir(QString::fromUtf8(path.c_str()), QString::fromLatin1("*.lxs"));
@ -783,11 +773,7 @@ Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
_pcAction = pcAction;
languageChange();
if (defaultAction) {
pcAction->setIcon(defaultAction->icon());
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(pcAction->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}

View File

@ -45,6 +45,7 @@ using namespace Reen;
SplineBasisfunction::SplineBasisfunction(int iSize)
: _vKnotVector(0,iSize-1)
, _iOrder(1)
{
}
@ -557,6 +558,8 @@ ParameterCorrection::ParameterCorrection(unsigned usUOrder, unsigned usVOrder,
, _usVOrder(usVOrder)
, _usUCtrlpoints(usUCtrlpoints)
, _usVCtrlpoints(usVCtrlpoints)
, _pvcPoints(0)
, _pvcUVParam(0)
, _vCtrlPntsOfSurf(0,usUCtrlpoints-1,0,usVCtrlpoints-1)
, _vUKnots(0,usUCtrlpoints-usUOrder+1)
, _vVKnots(0,usVCtrlpoints-usVOrder+1)

View File

@ -142,13 +142,14 @@ void Trajectory::deleteLast(unsigned int n)
}
void Trajectory::generateTrajectory(void)
{
if(vpcWaypoints.size()==0)return;
if (vpcWaypoints.size()==0)
return;
// delete the old and create a new one
if(pcTrajectory) delete (pcTrajectory);
if (pcTrajectory)
delete (pcTrajectory);
pcTrajectory = new KDL::Trajectory_Composite();
// pointer to the pieces while iterating
@ -162,70 +163,72 @@ void Trajectory::generateTrajectory(void)
// handle the first waypoint special
bool first=true;
for(std::vector<Waypoint*>::const_iterator it = vpcWaypoints.begin();it!=vpcWaypoints.end();++it){
if(first){
for (std::vector<Waypoint*>::const_iterator it = vpcWaypoints.begin();it!=vpcWaypoints.end();++it) {
if (first) {
Last = toFrame((*it)->EndPos);
first = false;
}else{
}
else {
// destinct the type of movement
switch((*it)->Type){
case Waypoint::LINE:
case Waypoint::PTP:{
KDL::Frame Next = toFrame((*it)->EndPos);
// continues the movement until no continus waypoint or the end
bool Cont = (*it)->Cont && !(it==--vpcWaypoints.end());
// start of a continue block
if(Cont && pcRoundComp==0){
pcRoundComp = new KDL::Path_RoundedComposite(3,
3,
new KDL::RotationalInterpolation_SingleAxis()
);
// the velocity of the first waypoint is used
pcVelPrf = new KDL::VelocityProfile_Trap((*it)->Velocity,(*it)->Accelaration);
pcRoundComp->Add(Last);
pcRoundComp->Add(Next);
// continue a continues block
}else if (Cont && pcRoundComp){
pcRoundComp->Add(Next);
case Waypoint::LINE:
case Waypoint::PTP:{
KDL::Frame Next = toFrame((*it)->EndPos);
// continues the movement until no continus waypoint or the end
bool Cont = (*it)->Cont && !(it==--vpcWaypoints.end());
// start of a continue block
if (Cont && pcRoundComp==0) {
pcRoundComp = new KDL::Path_RoundedComposite(3, 3,
new KDL::RotationalInterpolation_SingleAxis());
// the velocity of the first waypoint is used
pcVelPrf = new KDL::VelocityProfile_Trap((*it)->Velocity,(*it)->Accelaration);
pcRoundComp->Add(Last);
pcRoundComp->Add(Next);
// continue a continues block
}
else if (Cont && pcRoundComp) {
pcRoundComp->Add(Next);
// end a continous block
}else if (Cont==false && pcRoundComp){
// add the last one
pcRoundComp->Add(Next);
pcRoundComp->Finish();
pcVelPrf->SetProfile(0,pcRoundComp->PathLength());
pcTrak = new KDL::Trajectory_Segment(pcRoundComp,pcVelPrf);
pcRoundComp = 0;
}
else if (Cont==false && pcRoundComp) {
// add the last one
pcRoundComp->Add(Next);
pcRoundComp->Finish();
pcVelPrf->SetProfile(0,pcRoundComp->PathLength());
pcTrak = new KDL::Trajectory_Segment(pcRoundComp,pcVelPrf);
pcRoundComp = 0;
// normal block
}else if (Cont==false && pcRoundComp==0){
pcPath = new KDL::Path_Line(Last,
Next,
new KDL::RotationalInterpolation_SingleAxis(),
1.0,
true
);
pcVelPrf = new KDL::VelocityProfile_Trap((*it)->Velocity,(*it)->Accelaration);
pcVelPrf->SetProfile(0,pcPath->PathLength());
pcTrak = new KDL::Trajectory_Segment(pcPath,pcVelPrf);
}
Last = Next;
break;}
case Waypoint::WAIT:
break;
default:
break;
}
else if (Cont==false && pcRoundComp==0){
pcPath = new KDL::Path_Line(Last,
Next,
new KDL::RotationalInterpolation_SingleAxis(),
1.0,
true
);
pcVelPrf = new KDL::VelocityProfile_Trap((*it)->Velocity,(*it)->Accelaration);
pcVelPrf->SetProfile(0,pcPath->PathLength());
pcTrak = new KDL::Trajectory_Segment(pcPath,pcVelPrf);
}
Last = Next;
break;}
case Waypoint::WAIT:
break;
default:
break;
}
// add the segment if no continous block is runing
if(!pcRoundComp)
// add the segment if no continous block is running
if (!pcRoundComp)
pcTrajectory->Add(pcTrak);
}
}
}catch (KDL::Error &e) {
}
catch (KDL::Error &e) {
throw Base::Exception(e.Description());
}
}
std::string Trajectory::getUniqueWaypointName(const char *Name) const

View File

@ -62,9 +62,6 @@
</Documentation>
<Parameter Name="Waypoints" Type="List"/>
</Attribute>
<ClassDeclarations>
bool touched;
</ClassDeclarations>
</PythonExport>
</GenerateModel>

View File

@ -28,10 +28,9 @@
#include "Mod/Robot/App/Trajectory.h"
// inclusion of the generated files (generated out of TrajectoryPy.xml)
#include "TrajectoryPy.h"
#include "TrajectoryPy.cpp"
#include "WaypointPy.h"
#include <Mod/Robot/App/TrajectoryPy.h>
#include <Mod/Robot/App/TrajectoryPy.cpp>
#include <Mod/Robot/App/WaypointPy.h>
using namespace Robot;

View File

@ -56,21 +56,33 @@ using namespace KDL;
TYPESYSTEM_SOURCE(Robot::Waypoint , Base::Persistence);
Waypoint::Waypoint( const char* name,
const Base::Placement &endPos,
WaypointType type,
float velocity,
float accelaration,
bool cont,
unsigned int tool,
unsigned int base)
Waypoint::Waypoint(const char* name,
const Base::Placement &endPos,
WaypointType type,
float velocity,
float accelaration,
bool cont,
unsigned int tool,
unsigned int base)
:Name(name),Type(type),Velocity(velocity),Accelaration(accelaration),Cont(cont),Tool(tool),Base(base),EndPos(endPos)
: Name(name)
, Type(type)
, Velocity(velocity)
, Accelaration(accelaration)
, Cont(cont)
, Tool(tool)
, Base(base)
, EndPos(endPos)
{
}
Waypoint::Waypoint()
:Velocity(1000.0),Accelaration(100.0),Cont(false),Tool(0),Base(0)
: Type(UNDEF)
, Velocity(1000.0)
, Accelaration(100.0)
, Cont(false)
, Tool(0)
, Base(0)
{
}

View File

@ -61,9 +61,9 @@ public:
~Waypoint();
// from base class
// from base class
virtual unsigned int getMemSize (void) const;
virtual void Save (Base::Writer &/*writer*/) const;
virtual void Save (Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);

View File

@ -72,17 +72,17 @@ void CmdRobotExportKukaCompact::activated(int iMsg)
Robot::RobotObject *pcRobotObject=0;
if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[0].pObject);
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[1].pObject);
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[1].pObject);
std::string RoboName = pcRobotObject->getNameInDocument();
Robot::TrajectoryObject *pcTrajectoryObject=0;
if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
std::string TrakName = pcTrajectoryObject->getNameInDocument();
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
//std::string TrakName = pcTrajectoryObject->getNameInDocument();
QStringList filter;
filter << QString::fromLatin1("%1 (*.src)").arg(QObject::tr("KRL file"));
@ -134,17 +134,17 @@ void CmdRobotExportKukaFull::activated(int iMsg)
Robot::RobotObject *pcRobotObject=0;
if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[0].pObject);
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[1].pObject);
std::string RoboName = pcRobotObject->getNameInDocument();
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[1].pObject);
//std::string RoboName = pcRobotObject->getNameInDocument();
Robot::TrajectoryObject *pcTrajectoryObject=0;
if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
std::string TrakName = pcTrajectoryObject->getNameInDocument();
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
//std::string TrakName = pcTrajectoryObject->getNameInDocument();
QStringList filter;
filter << QString::fromLatin1("%1 (*.src)").arg(QObject::tr("KRL file"));

View File

@ -117,16 +117,16 @@ void CmdRobotInsertWaypoint::activated(int iMsg)
Robot::RobotObject *pcRobotObject=0;
if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[0].pObject);
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId())
pcRobotObject = dynamic_cast<Robot::RobotObject*>(Sel[1].pObject);
pcRobotObject = static_cast<Robot::RobotObject*>(Sel[1].pObject);
std::string RoboName = pcRobotObject->getNameInDocument();
Robot::TrajectoryObject *pcTrajectoryObject=0;
if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[1].pObject);
std::string TrakName = pcTrajectoryObject->getNameInDocument();
openCommand("Insert waypoint");
@ -179,7 +179,7 @@ void CmdRobotInsertWaypointPreselect::activated(int iMsg)
Robot::TrajectoryObject *pcTrajectoryObject;
if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId())
pcTrajectoryObject = dynamic_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
pcTrajectoryObject = static_cast<Robot::TrajectoryObject*>(Sel[0].pObject);
else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select one Trajectory object."));

View File

@ -98,7 +98,7 @@ TrajectorySimulate::TrajectorySimulate(Robot::RobotObject *pcRobotObject,Robot::
QObject::connect( timeSlider ,SIGNAL(valueChanged(int) ), this, SLOT(valueChanged(int)) );
// get the view provider
ViewProv = dynamic_cast<ViewProviderRobotObject*>(Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject) );
ViewProv = static_cast<ViewProviderRobotObject*>(Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject) );
setTo();
}

View File

@ -37,7 +37,7 @@ PROPERTY_SOURCE(RobotGui::ViewProviderEdge2TracObject, RobotGui::ViewProviderTra
bool ViewProviderEdge2TracObject::doubleClicked(void)
{
Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(dynamic_cast<Robot::Edge2TracObject *>(getObject()));
Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(static_cast<Robot::Edge2TracObject *>(getObject()));
Gui::Control().showDialog(dlg);
return true;
}
@ -45,7 +45,7 @@ bool ViewProviderEdge2TracObject::doubleClicked(void)
bool ViewProviderEdge2TracObject::setEdit(int ModNum)
{
Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(dynamic_cast<Robot::Edge2TracObject *>(getObject()));
Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(static_cast<Robot::Edge2TracObject *>(getObject()));
Gui::Control().showDialog(dlg);
return true;
}

View File

@ -71,7 +71,7 @@ protected:
SoGroup * pcOffRoot;
SoGroup * pcTcpRoot;
SoTransform * pcTcpTransform;
//SoTransform * pcTcpTransform;
//SoTrackballDragger * pcDragger;
SoJackDragger * pcDragger;

View File

@ -45,7 +45,7 @@ PROPERTY_SOURCE(RobotGui::ViewProviderTrajectoryDressUp, RobotGui::ViewProviderT
bool ViewProviderTrajectoryDressUp::setEdit(int ModNum)
{
Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryDressUp(dynamic_cast<Robot::TrajectoryDressUpObject *>(getObject()));
Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryDressUp(static_cast<Robot::TrajectoryDressUpObject *>(getObject()));
Gui::Control().showDialog(dlg);
return true;
}

View File

@ -186,7 +186,7 @@ void SketcherValidation::on_findButton_clicked()
for (std::size_t i=0; i<geom.size(); i++) {
Part::Geometry* g = geom[i];
if (g->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *segm = dynamic_cast<const Part::GeomLineSegment*>(g);
const Part::GeomLineSegment *segm = static_cast<const Part::GeomLineSegment*>(g);
VertexIds id;
id.GeoId = (int)i;
id.PosId = Sketcher::start;
@ -198,7 +198,7 @@ void SketcherValidation::on_findButton_clicked()
vertexIds.push_back(id);
}
else if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *segm = dynamic_cast<const Part::GeomArcOfCircle*>(g);
const Part::GeomArcOfCircle *segm = static_cast<const Part::GeomArcOfCircle*>(g);
VertexIds id;
id.GeoId = (int)i;
id.PosId = Sketcher::start;
@ -210,7 +210,7 @@ void SketcherValidation::on_findButton_clicked()
vertexIds.push_back(id);
}
else if (g->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) {
const Part::GeomArcOfEllipse *segm = dynamic_cast<const Part::GeomArcOfEllipse*>(g);
const Part::GeomArcOfEllipse *segm = static_cast<const Part::GeomArcOfEllipse*>(g);
VertexIds id;
id.GeoId = (int)i;
id.PosId = Sketcher::start;
@ -375,7 +375,7 @@ void SketcherValidation::on_findReversed_clicked()
Part::Geometry* g = geom[i];
//only arcs of circles need to be repaired. Arcs of ellipse were so broken there should be nothing to repair from.
if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *segm = dynamic_cast<const Part::GeomArcOfCircle*>(g);
const Part::GeomArcOfCircle *segm = static_cast<const Part::GeomArcOfCircle*>(g);
if(segm->isReversedInXY()){
points.push_back(segm->getStartPoint(/*emulateCCW=*/true));
points.push_back(segm->getEndPoint(/*emulateCCW=*/true));

View File

@ -393,7 +393,6 @@ protected:
bool relative;
std::string oldWb;
int antiAliasing;
Gui::Rubberband* rubberband;
App::Part* parentPart = nullptr;

View File

@ -108,8 +108,6 @@ private:
out << "Server failed to listen at address " << addr << " and port " << port;
throw Py::RuntimeError(out.str());
}
return Py::None();
}
Py::Object registerServerFirewall(const Py::Tuple& args)