CppCheck fixes, Errors Warnings and performance

This commit is contained in:
Jacob Støren 2015-11-27 16:37:26 +01:00
parent 6fdc975464
commit 7b9f2b41ed
16 changed files with 45 additions and 39 deletions

View File

@ -1346,7 +1346,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
}
// If multiple cases are present, invoke launchProcess() which will set next current case, and run script on this case
if (m_currentCaseIds.size() > 0)
if (!m_currentCaseIds.empty())
{
launchProcess(m_currentProgram, m_currentArguments);
}
@ -1365,7 +1365,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
if (m_workerProcess == NULL)
{
// If multiple cases are present, pop the first case ID from the list and set as current case
if (m_currentCaseIds.size() > 0)
if (!m_currentCaseIds.empty())
{
int nextCaseId = m_currentCaseIds.front();
m_currentCaseIds.pop_front();
@ -2170,16 +2170,16 @@ void RiaApplication::executeCommandObjects()
{
toBeRemoved->redo();
it++;
++it;
m_commandQueue.remove(toBeRemoved);
}
else
{
it++;
++it;
}
}
if (m_commandQueue.size() > 0)
if (!m_commandQueue.empty())
{
std::list< RimCommandObject* >::iterator it = m_commandQueue.begin();

View File

@ -920,7 +920,7 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
/// Inverse distance interpolation of the supplied points and distance weights for
/// the contributing points which are closest above, and closest below
//--------------------------------------------------------------------------------------------------
cvf::Vec3d interpolate3DPosition(const std::vector<SegmentPositionContribution> positions)
cvf::Vec3d interpolate3DPosition(const std::vector<SegmentPositionContribution>& positions)
{
std::vector<SegmentPositionContribution> filteredPositions;
filteredPositions.reserve(positions.size());
@ -1480,7 +1480,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
while (posContribIt != segmentIdToPositionContrib.end())
{
bottomPositions[posContribIt->first] = interpolate3DPosition(posContribIt->second);
posContribIt++;
++posContribIt;
}
// Distribute the positions to the resultpoints stored in the wellResultBranch.m_branchResultPoints

View File

@ -122,7 +122,7 @@ bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderMockModel::RifReaderMockModel()
RifReaderMockModel::RifReaderMockModel() : m_reservoir(NULL)
{
/*
m_cellResults.push_back("Dummy results");

View File

@ -144,10 +144,9 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo(
}
float edgeColor;
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
float edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast<cvf::StructGridInterface::FaceType>(cubeFaceIdx));
@ -244,10 +243,9 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim
size_t cellIndex = quadToCellFaceMapper->cellIndex(quadIdx);
float edgeColor;
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
float edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast<cvf::StructGridInterface::FaceType>(cubeFaceIdx));

View File

@ -1028,11 +1028,11 @@ void RivCrossSectionGeometryGenerator::calculateArrays()
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
int triangleCount = planeHexIntersectionMC(plane,
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
planeHexIntersectionMC(plane,
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
std::vector<ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;

View File

@ -83,7 +83,6 @@ private:
float m_opacityLevel;
cvf::Color3f m_defaultColor;
bool m_showNativeFaces;
bool m_showOppositeFaces;
bool m_showLabel;

View File

@ -244,7 +244,7 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m
}
std::list<RivPipeBranchData>::iterator it;
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); it++)
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it)
{
if (it->m_surfacePart.notNull())
{

View File

@ -180,7 +180,7 @@ void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
if (m_needsTransformUpdate) buildWellPipeParts();
std::list<RivPipeBranchData>::iterator it;
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); it++)
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it)
{
if (it->m_surfacePart.notNull())
{

View File

@ -93,6 +93,8 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig()
CAF_PDM_InitFieldNoDefault(&m_statisticsTimeRange, "StatisticsTimeRange", "Statistics Time Range", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_statisticsCellRange, "StatisticsCellRange", "Statistics Cell Range", "", "", "");
//m_statisticsCellRange.uiCapability()->setUiHidden(true);
m_isVisCellStatUpToDate = false;
}
//--------------------------------------------------------------------------------------------------

View File

@ -33,7 +33,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseCellResultsData::RigCaseCellResultsData(RigMainGrid* ownerGrid)
RigCaseCellResultsData::RigCaseCellResultsData(RigMainGrid* ownerGrid) : m_activeCellInfo(NULL)
{
CVF_ASSERT(ownerGrid != NULL);
m_ownerMainGrid = ownerGrid;
@ -182,7 +182,7 @@ std::vector<double>& RigCaseCellResultsData::cellScalarResults(size_t scalarResu
size_t RigCaseCellResultsData::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const
{
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->m_resultType == type && it->m_resultName == resultName)
{
@ -313,7 +313,7 @@ QStringList RigCaseCellResultsData::resultNames(RimDefines::ResultCatType resTyp
{
QStringList varList;
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->m_resultType == resType )
{
@ -497,7 +497,7 @@ RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromP
bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const
{
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->m_gridScalarResultIndex == scalarResultIndex)
{
@ -514,7 +514,7 @@ bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const
void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex)
{
std::vector<ResultInfo>::iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->m_gridScalarResultIndex == scalarResultIndex)
{

View File

@ -156,14 +156,14 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchId];
std::list< RigWellResultPoint >::iterator sEndIt;
size_t rStartIdx;
size_t rEndIdx;
size_t rStartIdx = -1;
size_t rEndIdx = -1;
// First detect if we have cells on the start of the result frame, that is not in the static frame
{
sEndIt = stBranch.begin();
bool found = false;
if (stBranch.size())
if (!stBranch.empty())
{
for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
{

View File

@ -214,7 +214,7 @@ void RigWellLogExtractor::populateReturnArrays(std::map<RigMDCellIdxEnterLeaveKe
cvf::Trace::show(cvf::String("Well log from :") + m_wellCaseErrorMsgName + (" Discards a point at MD: ") + cvf::String::number((double)(it1->first.measuredDepth)));
// Found that 10 to 11 is not connected, and not 10 to 12 either
it1++; // Discard 10 and jump to 11 and hope that recovers us
++it1; // Discard 10 and jump to 11 and hope that recovers us
continue;
}

View File

@ -106,7 +106,7 @@ bool RigWellLogFile::open(const QString& fileName, QString* errorMessage)
const std::map<std::string, std::vector<double> >& contLogs = well->GetContLog();
std::map<std::string, std::vector<double> >::const_iterator itCL;
for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++)
for (itCL = contLogs.begin(); itCL != contLogs.end(); ++itCL)
{
QString logName = QString::fromStdString(itCL->first);
wellLogNames.append(logName);

View File

@ -198,7 +198,7 @@ GeometryTools::IntersectionStatus inPlaneLineIntersect(
}
double normDist32 = e12*p32 / length34;
double normDist31 = -e12*p13 / length34;
//double normDist31 = -e12*p13 / length34;
// Set up fractions along lines to the edge2 vertex actually touching edge 1.
/// if two, select the one furthest from the start
@ -471,8 +471,8 @@ cvf::Vec3d GeometryTools::barycentricCoords(const cvf::Vec3d& t0, const cvf::Ve
cvf::Vec3d m = (t1 - t0 ^ t2 - t0);
// Absolute components for determining projection plane
int X = 0, Y = 1, Z = 2;
Z = findClosestAxis(m);
int X = 0, Y = 1;
int Z = findClosestAxis(m);
switch (Z)
{
case 0: X = 1; Y = 2; break; // x is largest, project to the yz plane
@ -590,6 +590,8 @@ void GeometryTools::addMidEdgeNodes(std::list<std::pair<cvf::uint, bool> >* poly
polygon->insert(polygon->end(), std::make_pair((cvf::uint)midPointIndex, true));
++it;
if (it == polygon->end()) break;
}
}
@ -745,7 +747,7 @@ bool EarClipTesselator::calculateTriangles( std::vector<size_t>* triangleIndices
while (numVertices > 2)
{
// if we loop, it is probably a non-simple polygon
if (count <= 0 )
if (count == 0 )
{
// Triangulate: ERROR - probable bad polygon!
return false;
@ -877,7 +879,7 @@ double EarClipTesselator::calculateProjectedPolygonArea() const
A += (*m_nodeCoords)[*p][m_X] * (*m_nodeCoords)[*q][m_Y] - (*m_nodeCoords)[*q][m_X]*(*m_nodeCoords)[*p][m_Y];
p = q;
q++;
++q;
}
return A*0.5;
@ -975,10 +977,10 @@ bool FanEarClipTesselator::calculateTriangles(std::vector<size_t>* triangles)
std::list< std::list<size_t> > restPolygons;
bool wasPreviousTriangleValid = true;
for (it1 = m_polygonIndices.begin(); it1 != m_polygonIndices.end(); it1++)
for (it1 = m_polygonIndices.begin(); it1 != m_polygonIndices.end(); ++it1)
{
it2 = it1;
it2++;
++it2;
if (it2 == m_polygonIndices.end()) it2 = m_polygonIndices.begin();

View File

@ -11,7 +11,8 @@ QWidget(parent, f)
m_minPercentile = HUGE_VAL;
m_maxPercentile = HUGE_VAL;
m_mean = HUGE_VAL;
m_min = HUGE_VAL;
m_max = -HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------

View File

@ -91,7 +91,11 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) : QObject(ownerViewer), m_viewer(ownerViewer)
RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
: QObject(ownerViewer),
m_viewer(ownerViewer),
m_currentGridIdx(-1),
m_currentCellIndex(-1)
{
}