Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "Grid.h"
|
||||
#include "TopoAlgorithm.h"
|
||||
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <Base/Sequencer.h>
|
||||
|
||||
using namespace MeshCore;
|
||||
@@ -228,6 +229,47 @@ bool MeshFixDuplicatePoints::Fixup()
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool MeshEvalNaNPoints::Evaluate()
|
||||
{
|
||||
const MeshPointArray& rPoints = _rclMesh.GetPoints();
|
||||
for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) {
|
||||
if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<unsigned long> MeshEvalNaNPoints::GetIndices() const
|
||||
{
|
||||
std::vector<unsigned long> aInds;
|
||||
const MeshPointArray& rPoints = _rclMesh.GetPoints();
|
||||
for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) {
|
||||
if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z))
|
||||
aInds.push_back(it - rPoints.begin());
|
||||
}
|
||||
|
||||
return aInds;
|
||||
}
|
||||
|
||||
bool MeshFixNaNPoints::Fixup()
|
||||
{
|
||||
std::vector<unsigned long> aInds;
|
||||
const MeshPointArray& rPoints = _rclMesh.GetPoints();
|
||||
for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) {
|
||||
if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z))
|
||||
aInds.push_back(it - rPoints.begin());
|
||||
}
|
||||
|
||||
// remove invalid indices
|
||||
_rclMesh.DeletePoints(aInds);
|
||||
_rclMesh.RebuildNeighbours();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace MeshCore {
|
||||
|
||||
typedef MeshFacetArray::_TConstIterator FaceIterator;
|
||||
|
||||
@@ -138,6 +138,54 @@ public:
|
||||
bool Fixup ();
|
||||
};
|
||||
|
||||
/**
|
||||
* The MeshEvalNaNPoints class searches for points with a coordinate that is NaN.
|
||||
* @see MeshFixNaNPoints
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class MeshExport MeshEvalNaNPoints : public MeshEvaluation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construction.
|
||||
*/
|
||||
MeshEvalNaNPoints (const MeshKernel &rclM) : MeshEvaluation( rclM ) { }
|
||||
/**
|
||||
* Destruction.
|
||||
*/
|
||||
~MeshEvalNaNPoints () { }
|
||||
/**
|
||||
* Returns false if a point with NaN coordinate is found.
|
||||
*/
|
||||
bool Evaluate ();
|
||||
/**
|
||||
* Returns the indices of all NaN points.
|
||||
*/
|
||||
std::vector<unsigned long> GetIndices() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* The MeshFixNaNPoints class removes all points with a coordinate that is NaN.
|
||||
* @see MeshEvalNaNPoints
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class MeshExport MeshFixNaNPoints : public MeshValidation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construction.
|
||||
*/
|
||||
MeshFixNaNPoints (MeshKernel &rclM) : MeshValidation( rclM ) { }
|
||||
/**
|
||||
* Destruction.
|
||||
*/
|
||||
~MeshFixNaNPoints () { }
|
||||
/**
|
||||
* Merges duplicated points.
|
||||
*/
|
||||
bool Fixup ();
|
||||
};
|
||||
|
||||
/**
|
||||
* The MeshEvalDuplicateFacets class searches for duplicated facets.
|
||||
* A facet is regarded as duplicated if all its point indices refer to the same location in the point array of the mesh kernel.
|
||||
|
||||
@@ -1123,6 +1123,12 @@ void MeshObject::removeFullBoundaryFacets()
|
||||
}
|
||||
}
|
||||
|
||||
void MeshObject::removeInvalidPoints()
|
||||
{
|
||||
MeshCore::MeshEvalNaNPoints nan(_kernel);
|
||||
deletePoints(nan.GetIndices());
|
||||
}
|
||||
|
||||
void MeshObject::validateIndices()
|
||||
{
|
||||
unsigned long count = _kernel.CountFacets();
|
||||
|
||||
@@ -256,6 +256,7 @@ public:
|
||||
void removeSelfIntersections(const std::vector<unsigned long>&);
|
||||
void removeFoldsOnSurface();
|
||||
void removeFullBoundaryFacets();
|
||||
void removeInvalidPoints();
|
||||
//@}
|
||||
|
||||
/** @name Mesh segments */
|
||||
|
||||
Reference in New Issue
Block a user