Coverity issues: fix Mesh, Points and Inspection module
This commit is contained in:
parent
e4f0ddad84
commit
9b013f7254
|
@ -751,8 +751,11 @@ App::DocumentObjectExecReturn* Feature::execute(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (countRMS > 0) {
|
||||
fRMS = fRMS / countRMS;
|
||||
fRMS = sqrt(fRMS);
|
||||
}
|
||||
|
||||
Base::Console().Message("RMS value for '%s' with search radius=%.4f is: %.4f\n",
|
||||
this->Label.getValue(), this->SearchRadius.getValue(), fRMS);
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ void ViewProviderInspection::updateData(const App::Property* prop)
|
|||
{
|
||||
// set to the expected size
|
||||
if (prop->getTypeId() == App::PropertyLink::getClassTypeId()) {
|
||||
App::GeoFeature* object = static_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
|
||||
App::GeoFeature* object = dynamic_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
|
||||
if (object) {
|
||||
float accuracy=0;
|
||||
Base::Type meshId = Base::Type::fromName("Mesh::Feature");
|
||||
|
@ -260,10 +260,11 @@ void ViewProviderInspection::updateData(const App::Property* prop)
|
|||
// force an update of the Inventor data nodes
|
||||
if (this->pcObject) {
|
||||
App::Property* link = this->pcObject->getPropertyByName("Actual");
|
||||
if (link) updateData(link);
|
||||
}
|
||||
if (link)
|
||||
updateData(link);
|
||||
setDistances();
|
||||
}
|
||||
}
|
||||
else if (prop->getTypeId() == App::PropertyFloat::getClassTypeId()) {
|
||||
if (strcmp(prop->getName(), "SearchRadius") == 0) {
|
||||
float fSearchRadius = ((App::PropertyFloat*)prop)->getValue();
|
||||
|
@ -281,6 +282,9 @@ SoSeparator* ViewProviderInspection::getFrontRoot(void) const
|
|||
|
||||
void ViewProviderInspection::setDistances()
|
||||
{
|
||||
if (!pcObject)
|
||||
return;
|
||||
|
||||
App::Property* pDistances = pcObject->getPropertyByName("Distances");
|
||||
if (!pDistances) {
|
||||
SoDebugError::post("ViewProviderInspection::setDistances", "Unknown property 'Distances'");
|
||||
|
|
|
@ -1570,24 +1570,24 @@ bool MeshAlgorithm::ConnectPolygons(std::list<std::vector<Base::Vector3f> > &clP
|
|||
std::list<std::pair<Base::Vector3f, Base::Vector3f> > &rclLines) const
|
||||
{
|
||||
|
||||
for(std::list< std::vector<Base::Vector3f> >::iterator OutIter = clPolyList.begin(); OutIter != clPolyList.end(); ++OutIter)
|
||||
{
|
||||
for (std::list< std::vector<Base::Vector3f> >::iterator OutIter = clPolyList.begin(); OutIter != clPolyList.end(); ++OutIter) {
|
||||
if (OutIter->empty())
|
||||
continue;
|
||||
std::pair<Base::Vector3f,Base::Vector3f> currentSort;
|
||||
float fDist = Base::Distance(OutIter->front(),OutIter->back());
|
||||
currentSort.first = OutIter->front();
|
||||
currentSort.second = OutIter->back();
|
||||
|
||||
for(std::list< std::vector<Base::Vector3f> >::iterator InnerIter = clPolyList.begin(); InnerIter != clPolyList.end(); ++InnerIter)
|
||||
{
|
||||
if(OutIter == InnerIter) continue;
|
||||
for (std::list< std::vector<Base::Vector3f> >::iterator InnerIter = clPolyList.begin(); InnerIter != clPolyList.end(); ++InnerIter) {
|
||||
if (OutIter == InnerIter)
|
||||
continue;
|
||||
|
||||
if(Base::Distance(OutIter->front(),InnerIter->front()) < fDist)
|
||||
{
|
||||
if (Base::Distance(OutIter->front(), InnerIter->front()) < fDist) {
|
||||
currentSort.second = InnerIter->front();
|
||||
fDist = Base::Distance(OutIter->front(),InnerIter->front());
|
||||
}
|
||||
if(Base::Distance(OutIter->front(),InnerIter->back()) < fDist)
|
||||
{
|
||||
|
||||
if (Base::Distance(OutIter->front(), InnerIter->back()) < fDist) {
|
||||
currentSort.second = InnerIter->back();
|
||||
fDist = Base::Distance(OutIter->front(),InnerIter->back());
|
||||
}
|
||||
|
|
|
@ -107,9 +107,11 @@ void Approximation::AddPoints(const std::list<Base::Vector3f> &rsPointList)
|
|||
Base::Vector3f Approximation::GetGravity() const
|
||||
{
|
||||
Base::Vector3f clGravity;
|
||||
if (!_vPoints.empty()) {
|
||||
for (std::list<Base::Vector3f>::const_iterator it = _vPoints.begin(); it!=_vPoints.end(); ++it)
|
||||
clGravity += *it;
|
||||
clGravity *= 1.0f / float(_vPoints.size());
|
||||
}
|
||||
return clGravity;
|
||||
}
|
||||
|
||||
|
@ -451,7 +453,7 @@ const double& QuadraticFit::GetCoeffArray() const
|
|||
|
||||
double QuadraticFit::GetCoeff(unsigned long ulIndex) const
|
||||
{
|
||||
assert( ulIndex >= 0 && ulIndex < 10 );
|
||||
assert(ulIndex < 10);
|
||||
|
||||
if( _bIsFitted )
|
||||
return _fCoeff[ ulIndex ];
|
||||
|
@ -765,6 +767,7 @@ double SurfaceFit::PolynomFit()
|
|||
// that 'sigma' becomes negative.
|
||||
if (sigma < 0)
|
||||
sigma = 0;
|
||||
if (!_vPoints.empty())
|
||||
sigma = sqrt(sigma/_vPoints.size());
|
||||
|
||||
_fLastResult = static_cast<float>(sigma);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
using namespace MeshCore;
|
||||
|
||||
|
||||
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(0)
|
||||
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(0), _ptIdx(0)
|
||||
{
|
||||
_fSaveTolerance = MeshDefinitions::_fMinPointDistanceD1;
|
||||
}
|
||||
|
|
|
@ -508,7 +508,7 @@ void MeshEvalPointManifolds::GetFacetIndices (std::vector<unsigned long> &facets
|
|||
bool MeshEvalSingleFacet::Evaluate ()
|
||||
{
|
||||
// get all non-manifolds
|
||||
MeshEvalTopology::Evaluate();
|
||||
(void)MeshEvalTopology::Evaluate();
|
||||
/*
|
||||
// for each (multiple) single linked facet there should
|
||||
// exist two valid facets sharing the same edge
|
||||
|
|
|
@ -1794,6 +1794,7 @@ bool MeshOutput::SaveBinarySTL (std::ostream &rstrOut) const
|
|||
|
||||
Base::SequencerLauncher seq("saving...", _rclMesh.CountFacets() + 1);
|
||||
|
||||
// stl_header has a length of 80
|
||||
strcpy(szInfo, stl_header.c_str());
|
||||
rstrOut.write(szInfo, std::strlen(szInfo));
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@ protected:
|
|||
MeshKernel &_resultMesh; /** Result mesh */
|
||||
OperationType _operationType; /** Set Operation Type */
|
||||
float _minDistanceToPoint; /** Minimal distance to facet corner points */
|
||||
float _saveMinMeshDistance;
|
||||
|
||||
private:
|
||||
// Helper class cutting edge to his two attached facets
|
||||
|
|
|
@ -36,7 +36,11 @@
|
|||
using namespace MeshCore;
|
||||
|
||||
|
||||
AbstractSmoothing::AbstractSmoothing(MeshKernel& m) : kernel(m)
|
||||
AbstractSmoothing::AbstractSmoothing(MeshKernel& m)
|
||||
: kernel(m)
|
||||
, tolerance(0)
|
||||
, component(Normal)
|
||||
, continuity(C0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,13 @@
|
|||
using namespace MeshCore;
|
||||
|
||||
MeshSearchNeighbours::MeshSearchNeighbours (const MeshKernel &rclM, float fSampleDistance)
|
||||
: _rclMesh(rclM),
|
||||
_rclFAry(rclM.GetFacets()),
|
||||
_rclPAry(rclM.GetPoints()),
|
||||
_clPt2Fa(rclM),
|
||||
_fSampleDistance(fSampleDistance)
|
||||
: _rclMesh(rclM)
|
||||
, _rclFAry(rclM.GetFacets())
|
||||
, _rclPAry(rclM.GetPoints())
|
||||
, _clPt2Fa(rclM)
|
||||
, _fMaxDistanceP2(0)
|
||||
, _fSampleDistance(fSampleDistance)
|
||||
, _bTooFewPoints(false)
|
||||
{
|
||||
MeshAlgorithm(_rclMesh).ResetFacetFlag(MeshFacet::MARKED);
|
||||
MeshAlgorithm(_rclMesh).ResetPointFlag(MeshPoint::MARKED);
|
||||
|
|
|
@ -409,7 +409,12 @@ namespace MeshGui {
|
|||
/* TRANSLATOR MeshGui::MeshFillHole */
|
||||
|
||||
MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent)
|
||||
: QObject(parent), myMesh(0), myNumPoints(0), myHoleFiller(hf)
|
||||
: QObject(parent)
|
||||
, myMesh(0)
|
||||
, myNumPoints(0)
|
||||
, myVertex1(0)
|
||||
, myVertex2(0)
|
||||
, myHoleFiller(hf)
|
||||
{
|
||||
myBoundariesRoot = new SoSeparator;
|
||||
myBoundariesRoot->ref();
|
||||
|
|
|
@ -78,6 +78,9 @@ unsigned char MeshSelection::cross_mask_bitmap[] = {
|
|||
MeshSelection::MeshSelection()
|
||||
: onlyPointToUserTriangles(false)
|
||||
, onlyVisibleTriangles(false)
|
||||
, addToSelection(false)
|
||||
, addComponent(false)
|
||||
, removeComponent(false)
|
||||
, activeCB(0)
|
||||
, selectionCB(0)
|
||||
, ivViewer(0)
|
||||
|
|
|
@ -588,7 +588,10 @@ void SoFCMeshObjectShape::initClass()
|
|||
SO_NODE_INIT_CLASS(SoFCMeshObjectShape, SoShape, "Shape");
|
||||
}
|
||||
|
||||
SoFCMeshObjectShape::SoFCMeshObjectShape() : renderTriangleLimit(100000), meshChanged(true)
|
||||
SoFCMeshObjectShape::SoFCMeshObjectShape()
|
||||
: renderTriangleLimit(100000)
|
||||
, meshChanged(true)
|
||||
, selectBuf(0)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCMeshObjectShape);
|
||||
setName(SoFCMeshObjectShape::getClassTypeId().getName());
|
||||
|
|
|
@ -1028,7 +1028,7 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
|
|||
std::vector<unsigned long>& indices) const
|
||||
{
|
||||
#if 1
|
||||
bool ok = true;
|
||||
const bool ok = true;
|
||||
Base::Polygon2D polygon;
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
|
@ -1890,6 +1890,8 @@ PROPERTY_SOURCE(MeshGui::ViewProviderIndexedFaceSet, MeshGui::ViewProviderMesh)
|
|||
|
||||
ViewProviderIndexedFaceSet::ViewProviderIndexedFaceSet()
|
||||
{
|
||||
pcMeshCoord = 0;
|
||||
pcMeshFaces = 0;
|
||||
}
|
||||
|
||||
ViewProviderIndexedFaceSet::~ViewProviderIndexedFaceSet()
|
||||
|
@ -1979,6 +1981,8 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshObject, MeshGui::ViewProviderMesh)
|
|||
|
||||
ViewProviderMeshObject::ViewProviderMeshObject()
|
||||
{
|
||||
pcMeshNode = 0;
|
||||
pcMeshShape = 0;
|
||||
}
|
||||
|
||||
ViewProviderMeshObject::~ViewProviderMeshObject()
|
||||
|
|
|
@ -145,7 +145,7 @@ void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshOrientation::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
pcCoords->point.deleteValues(0);
|
||||
|
@ -212,7 +212,7 @@ void ViewProviderMeshNonManifolds::showDefects(const std::vector<unsigned long>&
|
|||
{
|
||||
if ((inds.size() % 2) != 0)
|
||||
return;
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
pcCoords->point.deleteValues(0);
|
||||
|
@ -275,7 +275,7 @@ void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
pcCoords->point.deleteValues(0);
|
||||
pcCoords->point.setNum(inds.size());
|
||||
|
@ -339,7 +339,7 @@ void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
pcCoords->point.deleteValues(0);
|
||||
|
@ -404,7 +404,7 @@ void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
pcCoords->point.deleteValues(0);
|
||||
pcCoords->point.setNum(inds.size());
|
||||
|
@ -461,7 +461,7 @@ void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshDegenerations::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
pcCoords->point.deleteValues(0);
|
||||
|
@ -567,7 +567,7 @@ void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshIndices::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
if (!inds.empty()) {
|
||||
|
@ -636,7 +636,7 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned l
|
|||
{
|
||||
if (indices.size() % 2 != 0)
|
||||
return;
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
MeshCore::MeshEvalSelfIntersection eval(rMesh);
|
||||
|
||||
|
@ -714,7 +714,7 @@ void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
|
|||
|
||||
void ViewProviderMeshFolds::showDefects(const std::vector<unsigned long>& inds)
|
||||
{
|
||||
Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
|
||||
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
|
||||
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
|
||||
|
||||
pcCoords->point.deleteValues(0);
|
||||
|
|
|
@ -65,6 +65,8 @@ ViewProviderMeshTransformDemolding::ViewProviderMeshTransformDemolding()
|
|||
{
|
||||
pcTrackballDragger = new SoTrackballDragger;
|
||||
pcTrackballDragger->ref();
|
||||
pcTransformDrag = 0;
|
||||
pcColorMat = 0;
|
||||
}
|
||||
|
||||
ViewProviderMeshTransformDemolding::~ViewProviderMeshTransformDemolding()
|
||||
|
@ -122,7 +124,7 @@ void ViewProviderMeshTransformDemolding::attach(App::DocumentObject *pcFeat)
|
|||
calcNormalVector();
|
||||
calcMaterialIndex(SbRotation());
|
||||
// geting center point
|
||||
center = dynamic_cast<Feature*>(pcObject)->Mesh.getValue().getKernel().GetBoundBox().GetCenter();
|
||||
center = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel().GetBoundBox().GetCenter();
|
||||
|
||||
//SoGetBoundingBoxAction boxAction;
|
||||
//pcHighlight->getBoundingBox(&boxAction);
|
||||
|
@ -131,7 +133,7 @@ void ViewProviderMeshTransformDemolding::attach(App::DocumentObject *pcFeat)
|
|||
|
||||
void ViewProviderMeshTransformDemolding::calcNormalVector(void)
|
||||
{
|
||||
const MeshKernel& cMesh = dynamic_cast<Feature*>(pcObject)->Mesh.getValue().getKernel();
|
||||
const MeshKernel& cMesh = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel();
|
||||
|
||||
MeshFacetIterator cFIt(cMesh);
|
||||
for( cFIt.Init(); cFIt.More(); cFIt.Next())
|
||||
|
|
|
@ -298,9 +298,17 @@ void PointsGrid::CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMa
|
|||
double fVol = fVolElem * float(ulCtGrid);
|
||||
double fGridLen = float(pow((float)fVol,(float) 1.0f / 3.0f));
|
||||
|
||||
if (fGridLen > 0) {
|
||||
_ulCtGridsX = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthX() / fGridLen), 1);
|
||||
_ulCtGridsY = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthY() / fGridLen), 1);
|
||||
_ulCtGridsZ = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthZ() / fGridLen), 1);
|
||||
}
|
||||
else {
|
||||
// Degenerated grid
|
||||
_ulCtGridsX = 1;
|
||||
_ulCtGridsY = 1;
|
||||
_ulCtGridsZ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void PointsGrid::CalculateGridLength (int iCtGridPerAxis)
|
||||
|
|
Loading…
Reference in New Issue
Block a user