Mesh: define the typenames FacetIndex and PointIndex to distinguish between facet and point related indexes

This commit is contained in:
wmayer
2021-09-14 23:01:29 +02:00
parent ce285ea265
commit 33f3fa6865
91 changed files with 2057 additions and 2254 deletions
File diff suppressed because it is too large Load Diff
+84 -84
View File
@@ -58,7 +58,7 @@ public:
/// Construction
MeshAlgorithm (const MeshKernel &rclM) : _rclMesh(rclM) { }
/// Destruction
~MeshAlgorithm (void) { }
~MeshAlgorithm () { }
public:
/**
@@ -70,7 +70,7 @@ public:
* occasionally.
*/
bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes,
unsigned long &rulFacet) const;
FacetIndex &rulFacet) const;
/**
* Searches for the nearest facet to the ray defined by
* (\a rclPt, \a rclDir).
@@ -80,7 +80,7 @@ public:
* used for a lot of tests.
*/
bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const MeshFacetGrid &rclGrid,
Base::Vector3f &rclRes, unsigned long &rulFacet) const;
Base::Vector3f &rclRes, FacetIndex &rulFacet) const;
/**
* Searches for the nearest facet to the ray defined by
* (\a rclPt, \a rclDir).
@@ -90,8 +90,8 @@ public:
* the attached mesh. So the caller must ensure that the indices are valid
* facets.
*/
bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector<unsigned long> &raulFacets,
Base::Vector3f &rclRes, unsigned long &rulFacet) const;
bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector<FacetIndex> &raulFacets,
Base::Vector3f &rclRes, FacetIndex &rulFacet) const;
/**
* Searches for the nearest facet to the ray defined by (\a rclPt, \a rclDir). The point \a rclRes holds
* the intersection point with the ray and the nearest facet with index \a rulFacet.
@@ -99,13 +99,13 @@ public:
* \note This method is optimized by using a grid. So this method can be used for a lot of tests.
*/
bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea,
const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, unsigned long &rulFacet) const;
const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, FacetIndex &rulFacet) const;
/**
* Searches for the first facet of the grid element (\a rclGrid) in that the point \a rclPt lies into which is a distance not
* higher than \a fMaxDistance. Of no such facet is found \a rulFacet is undefined and false is returned, otherwise true.
* \note If the point \a rclPt is outside of the grid \a rclGrid nothing is done.
*/
bool FirstFacetToVertex(const Base::Vector3f &rclPt, float fMaxDistance, const MeshFacetGrid &rclGrid, unsigned long &rulFacet) const;
bool FirstFacetToVertex(const Base::Vector3f &rclPt, float fMaxDistance, const MeshFacetGrid &rclGrid, FacetIndex &rulFacet) const;
/**
* Checks from the viewpoint \a rcView if the vertex \a rcVertex is visible or it is hidden by a facet.
* If the vertex is visible true is returned, false otherwise.
@@ -135,11 +135,11 @@ public:
* Returns all boundaries of the mesh. This method does basically the same as above unless that it returns the point indices
* of the boundaries.
*/
void GetMeshBorders (std::list<std::vector<unsigned long> > &rclBorders) const;
void GetMeshBorders (std::list<std::vector<PointIndex> > &rclBorders) const;
/**
* Returns all boundaries of a subset the mesh defined by \a raulInd.
*/
void GetFacetBorders (const std::vector<unsigned long> &raulInd, std::list<std::vector<Base::Vector3f> > &rclBorders) const;
void GetFacetBorders (const std::vector<FacetIndex> &raulInd, std::list<std::vector<Base::Vector3f> > &rclBorders) const;
/**
* Returns all boundaries of a subset the mesh defined by \a raulInd. This method does basically the same as above unless
* that it returns the point indices of the boundaries.
@@ -148,18 +148,18 @@ public:
* orientation even if the mesh is topologically correct. You should let the default value unless you exactly
* know what you do.
*/
void GetFacetBorders (const std::vector<unsigned long> &raulInd, std::list<std::vector<unsigned long> > &rclBorders,
void GetFacetBorders (const std::vector<FacetIndex> &raulInd, std::list<std::vector<PointIndex> > &rclBorders,
bool ignoreOrientation = false) const;
/**
* Returns the boundary of the mesh to the facet \a uFacet. If this facet does not have an open edge the returned
* boundary is empty.
*/
void GetMeshBorder(unsigned long uFacet, std::list<unsigned long>& rBorder) const;
void GetMeshBorder(FacetIndex uFacet, std::list<PointIndex>& rBorder) const;
/**
* Boundaries that consist of several loops must be split in several independent boundaries
* to perform e.g. a polygon triangulation algorithm on them.
*/
void SplitBoundaryLoops( std::list<std::vector<unsigned long> >& aBorders );
void SplitBoundaryLoops( std::list<std::vector<PointIndex> >& aBorders );
/**
* Fills up the single boundary if it is a hole with high quality triangles and a maximum area of \a fMaxArea.
* The triangulation information is stored in \a rFaces and \a rPoints.
@@ -172,14 +172,14 @@ public:
* @note If the number of geometric points exceeds the number of boundary indices then the triangulation algorithm has
* introduced new points which are added to the end of \a rPoints.
*/
bool FillupHole(const std::vector<unsigned long>& boundary,
bool FillupHole(const std::vector<PointIndex>& boundary,
AbstractPolygonTriangulator& cTria,
MeshFacetArray& rFaces, MeshPointArray& rPoints,
int level, const MeshRefPointToFacets* pP2FStructure=0) const;
int level, const MeshRefPointToFacets* pP2FStructure=nullptr) const;
/** Sets to all facets in \a raulInds the properties in raulProps.
* \note Both arrays must have the same size.
*/
void SetFacetsProperty(const std::vector<unsigned long> &raulInds, const std::vector<unsigned long> &raulProps) const;
void SetFacetsProperty(const std::vector<FacetIndex> &raulInds, const std::vector<unsigned long> &raulProps) const;
/** Sets to all facets the flag \a tF. */
void SetFacetFlag (MeshFacet::TFlagType tF) const;
/** Sets to all points the flag \a tF. */
@@ -189,23 +189,23 @@ public:
/** Resets of all points the flag \a tF. */
void ResetPointFlag (MeshPoint::TFlagType tF) const;
/** Sets to all facets in \a raulInds the flag \a tF. */
void SetFacetsFlag (const std::vector<unsigned long> &raulInds, MeshFacet::TFlagType tF) const;
void SetFacetsFlag (const std::vector<FacetIndex> &raulInds, MeshFacet::TFlagType tF) const;
/** Sets to all points in \a raulInds the flag \a tF. */
void SetPointsFlag (const std::vector<unsigned long> &raulInds, MeshPoint::TFlagType tF) const;
void SetPointsFlag (const std::vector<PointIndex> &raulInds, MeshPoint::TFlagType tF) const;
/** Gets all facets in \a raulInds with the flag \a tF. */
void GetFacetsFlag (std::vector<unsigned long> &raulInds, MeshFacet::TFlagType tF) const;
void GetFacetsFlag (std::vector<FacetIndex> &raulInds, MeshFacet::TFlagType tF) const;
/** Gets all points in \a raulInds with the flag \a tF. */
void GetPointsFlag (std::vector<unsigned long> &raulInds, MeshPoint::TFlagType tF) const;
void GetPointsFlag (std::vector<PointIndex> &raulInds, MeshPoint::TFlagType tF) const;
/** Resets from all facets in \a raulInds the flag \a tF. */
void ResetFacetsFlag (const std::vector<unsigned long> &raulInds, MeshFacet::TFlagType tF) const;
void ResetFacetsFlag (const std::vector<FacetIndex> &raulInds, MeshFacet::TFlagType tF) const;
/** Resets from all points in \a raulInds the flag \a tF. */
void ResetPointsFlag (const std::vector<unsigned long> &raulInds, MeshPoint::TFlagType tF) const;
void ResetPointsFlag (const std::vector<PointIndex> &raulInds, MeshPoint::TFlagType tF) const;
/** Count all facets with the flag \a tF. */
unsigned long CountFacetFlag (MeshFacet::TFlagType tF) const;
/** Count all points with the flag \a tF. */
unsigned long CountPointFlag (MeshPoint::TFlagType tF) const;
/** Returns all geometric points from the facets in \a rvecIndices. */
void PointsFromFacetsIndices (const std::vector<unsigned long> &rvecIndices, std::vector<Base::Vector3f> &rvecPoints) const;
void PointsFromFacetsIndices (const std::vector<FacetIndex> &rvecIndices, std::vector<Base::Vector3f> &rvecPoints) const;
/**
* Returns the indices of all facets that have at least one point that lies inside the tool mesh. The direction
* \a dir is used to try to foraminate the facets of the tool mesh and counts the number of foraminated facets.
@@ -213,11 +213,11 @@ public:
* @note The tool mesh must be a valid solid.
* @note It's not tested if \a rToolMesh is a valid solid. In case it is not the result is undefined.
*/
void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector<unsigned long> &raclCutted ) const;
void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector<FacetIndex> &raclCutted ) const;
/**
* Does basically the same as method above except it uses a mesh grid to speed up the computation.
*/
void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, const MeshFacetGrid& rGrid, std::vector<unsigned long> &raclCutted ) const;
void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, const MeshFacetGrid& rGrid, std::vector<FacetIndex> &raclCutted ) const;
/**
* Checks whether the bounding box \a rBox is surrounded by the attached mesh which must be a solid.
* The direction \a rcDir is used to try to foraminate the facets of the tool mesh and counts the number of foraminated facets.
@@ -234,34 +234,34 @@ public:
* This algorithm is optimized by using a grid.
*/
void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &rclRes) const;
bool bInner, std::vector<FacetIndex> &rclRes) const;
/**
* Does the same as the above method unless that it doesn't use a grid.
*/
void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &rclRes) const;
bool bInner, std::vector<FacetIndex> &rclRes) const;
/**
* Determines all facets of the given array \a raclFacetIndices that lie at the edge or that
* have at least neighbour facet that is not inside the array. The resulting array \a raclResultIndices
* is not be deleted before the algorithm starts. \a usLevel indicates how often the algorithm is
* repeated.
*/
void CheckBorderFacets (const std::vector<unsigned long> &raclFacetIndices,
std::vector<unsigned long> &raclResultIndices, unsigned short usLevel = 1) const;
void CheckBorderFacets (const std::vector<FacetIndex> &raclFacetIndices,
std::vector<FacetIndex> &raclResultIndices, unsigned short usLevel = 1) const;
/**
* Invokes CheckBorderFacets() to get all border facets of \a raclFacetIndices. Then the content of
* \a raclFacetIndices is replaced by all facets that can be deleted.
* \note The mesh structure is not modified by this method. This is in the responsibility of the user.
*/
void CutBorderFacets (std::vector<unsigned long> &raclFacetIndices, unsigned short usLevel = 1) const;
void CutBorderFacets (std::vector<FacetIndex> &raclFacetIndices, unsigned short usLevel = 1) const;
/** Returns the number of border edges */
unsigned long CountBorderEdges() const;
/**
* Determines all border points as indices of the facets in \a raclFacetIndices. The points are unsorted.
*/
void GetBorderPoints (const std::vector<unsigned long> &raclFacetIndices, std::set<unsigned long> &raclResultPointsIndices) const;
void GetBorderPoints (const std::vector<FacetIndex> &raclFacetIndices, std::set<PointIndex> &raclResultPointsIndices) const;
/** Computes the surface of the mesh. */
float Surface (void) const;
float Surface () const;
/** Subsamples the mesh with point distance \a fDist and stores the points in \a rclPoints. */
void SubSampleByDist (float fDist, std::vector<Base::Vector3f> &rclPoints) const;
/**
@@ -275,15 +275,15 @@ public:
* Searches for all facets that intersect the "search tube" with radius \a r around the polyline.
*/
void SearchFacetsFromPolyline (const std::vector<Base::Vector3f> &rclPolyline, float fRadius,
const MeshFacetGrid& rclGrid, std::vector<unsigned long> &rclResultFacetsIndices) const;
const MeshFacetGrid& rclGrid, std::vector<FacetIndex> &rclResultFacetsIndices) const;
/** Projects a point directly to the mesh (means nearest facet), the result is the facet index and
* the foraminate point, use second version with grid for more performance.
*/
bool NearestPointFromPoint (const Base::Vector3f &rclPt, unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
bool NearestPointFromPoint (const Base::Vector3f &rclPt, FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
bool NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid,
unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
bool NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, float fMaxSearchArea,
unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const;
/** Cuts the mesh with a plane. The result is a list of polylines. */
bool CutWithPlane (const Base::Vector3f &clBase, const Base::Vector3f &clNormal, const MeshFacetGrid &rclGrid,
std::list<std::vector<Base::Vector3f> > &rclResult, float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
@@ -292,12 +292,12 @@ public:
* The plane is defined by it normalized normal and the signed distance to the origin.
*/
void GetFacetsFromPlane (const MeshFacetGrid &rclGrid, const Base::Vector3f& clNormal, float dist,
const Base::Vector3f &rclLeft, const Base::Vector3f &rclRight, std::vector<unsigned long> &rclRes) const;
const Base::Vector3f &rclLeft, const Base::Vector3f &rclRight, std::vector<FacetIndex> &rclRes) const;
/** Returns true if the distance from the \a rclPt to the facet \a ulFacetIdx is less than \a fMaxDistance.
* If this restriction is met \a rfDistance is set to the actual distance, otherwise false is returned.
*/
bool Distance (const Base::Vector3f &rclPt, unsigned long ulFacetIdx, float fMaxDistance, float &rfDistance) const;
bool Distance (const Base::Vector3f &rclPt, FacetIndex ulFacetIdx, float fMaxDistance, float &rfDistance) const;
/**
* Calculates the minimum grid length so that not more elements than \a maxElements will be created when the grid gets
* built up. The minimum grid length must be at least \a fLength.
@@ -311,12 +311,12 @@ protected:
bool ConnectPolygons(std::list<std::vector<Base::Vector3f> > &clPolyList, std::list<std::pair<Base::Vector3f,
Base::Vector3f> > &rclLines) const;
/** Searches the nearest facet in \a raulFacets to the ray (\a rclPt, \a rclDir). */
bool RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector<unsigned long> &raulFacets,
Base::Vector3f &rclRes, unsigned long &rulFacet, float fMaxAngle = Mathf::PI) const;
bool RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector<FacetIndex> &raulFacets,
Base::Vector3f &rclRes, FacetIndex &rulFacet, float fMaxAngle = Mathf::PI) const;
/**
* Splits the boundary \a rBound in several loops and append this loops to the list of borders.
*/
void SplitBoundaryLoops( const std::vector<unsigned long>& rBound, std::list<std::vector<unsigned long> >& aBorders );
void SplitBoundaryLoops( const std::vector<PointIndex>& rBound, std::list<std::vector<PointIndex> >& aBorders );
protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */
@@ -327,17 +327,17 @@ class MeshExport MeshCollector
public:
MeshCollector(){}
virtual ~MeshCollector(){}
virtual void Append(const MeshCore::MeshKernel&, unsigned long index) = 0;
virtual void Append(const MeshCore::MeshKernel&, FacetIndex index) = 0;
};
class MeshExport PointCollector : public MeshCollector
{
public:
PointCollector(std::vector<unsigned long>& ind) : indices(ind){}
PointCollector(std::vector<PointIndex>& ind) : indices(ind){}
virtual ~PointCollector(){}
virtual void Append(const MeshCore::MeshKernel& kernel, unsigned long index)
virtual void Append(const MeshCore::MeshKernel& kernel, FacetIndex index)
{
unsigned long ulP1, ulP2, ulP3;
PointIndex ulP1, ulP2, ulP3;
kernel.GetFacetPoints(index, ulP1, ulP2, ulP3);
indices.push_back(ulP1);
indices.push_back(ulP2);
@@ -345,21 +345,21 @@ public:
}
private:
std::vector<unsigned long>& indices;
std::vector<PointIndex>& indices;
};
class MeshExport FacetCollector : public MeshCollector
{
public:
FacetCollector(std::vector<unsigned long>& ind) : indices(ind){}
FacetCollector(std::vector<FacetIndex>& ind) : indices(ind){}
virtual ~FacetCollector(){}
void Append(const MeshCore::MeshKernel&, unsigned long index)
void Append(const MeshCore::MeshKernel&, FacetIndex index)
{
indices.push_back(index);
}
private:
std::vector<unsigned long>& indices;
std::vector<FacetIndex>& indices;
};
/**
@@ -375,30 +375,30 @@ public:
MeshRefPointToFacets (const MeshKernel &rclM) : _rclMesh(rclM)
{ Rebuild(); }
/// Destruction
~MeshRefPointToFacets (void)
~MeshRefPointToFacets ()
{ }
/// Rebuilds up data structure
void Rebuild (void);
const std::set<unsigned long>& operator[] (unsigned long) const;
std::vector<unsigned long> GetIndices(unsigned long, unsigned long) const;
std::vector<unsigned long> GetIndices(unsigned long, unsigned long, unsigned long) const;
MeshFacetArray::_TConstIterator GetFacet (unsigned long) const;
std::set<unsigned long> NeighbourPoints(const std::vector<unsigned long>& , int level) const;
std::set<unsigned long> NeighbourPoints(unsigned long) const;
void Neighbours (unsigned long ulFacetInd, float fMaxDist, MeshCollector& collect) const;
Base::Vector3f GetNormal(unsigned long) const;
void AddNeighbour(unsigned long, unsigned long);
void RemoveNeighbour(unsigned long, unsigned long);
void RemoveFacet(unsigned long);
void Rebuild ();
const std::set<FacetIndex>& operator[] (PointIndex) const;
std::vector<FacetIndex> GetIndices(PointIndex, PointIndex) const;
std::vector<FacetIndex> GetIndices(PointIndex, PointIndex, PointIndex) const;
MeshFacetArray::_TConstIterator GetFacet (FacetIndex) const;
std::set<PointIndex> NeighbourPoints(const std::vector<PointIndex>& , int level) const;
std::set<PointIndex> NeighbourPoints(PointIndex) const;
void Neighbours (FacetIndex ulFacetInd, float fMaxDist, MeshCollector& collect) const;
Base::Vector3f GetNormal(PointIndex) const;
void AddNeighbour(PointIndex, FacetIndex);
void RemoveNeighbour(PointIndex, FacetIndex);
void RemoveFacet(FacetIndex);
protected:
void SearchNeighbours(const MeshFacetArray& rFacets, unsigned long index, const Base::Vector3f &rclCenter,
float fMaxDist, std::set<unsigned long> &visit, MeshCollector& collect) const;
void SearchNeighbours(const MeshFacetArray& rFacets, FacetIndex index, const Base::Vector3f &rclCenter,
float fMaxDist, std::set<FacetIndex> &visit, MeshCollector& collect) const;
protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */
std::vector<std::set<unsigned long> > _map;
std::vector<std::set<FacetIndex> > _map;
};
/**
@@ -414,20 +414,20 @@ public:
MeshRefFacetToFacets (const MeshKernel &rclM) : _rclMesh(rclM)
{ Rebuild(); }
/// Destruction
~MeshRefFacetToFacets (void)
~MeshRefFacetToFacets ()
{ }
/// Rebuilds up data structure
void Rebuild (void);
void Rebuild ();
/// Returns a set of facets sharing one or more points with the facet with
/// index \a ulFacetIndex.
const std::set<unsigned long>& operator[] (unsigned long) const;
const std::set<FacetIndex>& operator[] (FacetIndex) const;
/// Returns an array of common facets of the passed facet indexes.
std::vector<unsigned long> GetIndices(unsigned long, unsigned long) const;
std::vector<FacetIndex> GetIndices(FacetIndex, FacetIndex) const;
protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */
std::vector<std::set<unsigned long> > _map;
std::vector<std::set<FacetIndex> > _map;
};
/**
@@ -443,20 +443,20 @@ public:
MeshRefPointToPoints (const MeshKernel &rclM) : _rclMesh(rclM)
{ Rebuild(); }
/// Destruction
~MeshRefPointToPoints (void)
~MeshRefPointToPoints ()
{ }
/// Rebuilds up data structure
void Rebuild (void);
const std::set<unsigned long>& operator[] (unsigned long) const;
Base::Vector3f GetNormal(unsigned long) const;
float GetAverageEdgeLength(unsigned long) const;
void AddNeighbour(unsigned long, unsigned long);
void RemoveNeighbour(unsigned long, unsigned long);
void Rebuild ();
const std::set<PointIndex>& operator[] (PointIndex) const;
Base::Vector3f GetNormal(PointIndex) const;
float GetAverageEdgeLength(PointIndex) const;
void AddNeighbour(PointIndex, PointIndex);
void RemoveNeighbour(PointIndex, PointIndex);
protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */
std::vector<std::set<unsigned long> > _map;
std::vector<std::set<PointIndex> > _map;
};
/**
@@ -472,12 +472,12 @@ public:
MeshRefEdgeToFacets (const MeshKernel &rclM) : _rclMesh(rclM)
{ Rebuild(); }
/// Destruction
~MeshRefEdgeToFacets (void)
~MeshRefEdgeToFacets ()
{ }
/// Rebuilds up data structure
void Rebuild (void);
const std::pair<unsigned long, unsigned long>& operator[] (const MeshEdge&) const;
void Rebuild ();
const std::pair<FacetIndex, FacetIndex>& operator[] (const MeshEdge&) const;
protected:
class EdgeOrder {
@@ -494,7 +494,7 @@ protected:
return false;
}
};
typedef std::pair<unsigned long, unsigned long> MeshFacetPair;
typedef std::pair<FacetIndex, FacetIndex> MeshFacetPair;
const MeshKernel &_rclMesh; /**< The mesh kernel. */
std::map<MeshEdge, MeshFacetPair, EdgeOrder> _map;
};
@@ -511,12 +511,12 @@ public:
MeshRefNormalToPoints (const MeshKernel &rclM) : _rclMesh(rclM)
{ Rebuild(); }
/// Destruction
~MeshRefNormalToPoints (void)
~MeshRefNormalToPoints ()
{ }
/// Rebuilds up data structure
void Rebuild (void);
const Base::Vector3f& operator[] (unsigned long) const;
void Rebuild ();
const Base::Vector3f& operator[] (PointIndex) const;
protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */
+3 -3
View File
@@ -117,7 +117,7 @@ Base::Vector3f Approximation::GetGravity() const
return clGravity;
}
unsigned long Approximation::CountPoints() const
std::size_t Approximation::CountPoints() const
{
return _vPoints.size();
}
@@ -418,7 +418,7 @@ Base::BoundBox3f PlaneFit::GetBoundings() const
{
Base::BoundBox3f bbox;
std::vector<Base::Vector3f> pts = GetLocalPoints();
for (auto it : pts)
for (const auto& it : pts)
bbox.Add(it);
return bbox;
}
@@ -462,7 +462,7 @@ const double& QuadraticFit::GetCoeffArray() const
return _fCoeff[0];
}
double QuadraticFit::GetCoeff(unsigned long ulIndex) const
double QuadraticFit::GetCoeff(std::size_t ulIndex) const
{
assert(ulIndex < 10);
+2 -2
View File
@@ -147,7 +147,7 @@ public:
* Determines the number of the current added points.
* @return Number of points
*/
unsigned long CountPoints() const;
std::size_t CountPoints() const;
/**
* Deletes the inserted points and frees any allocated resources.
*/
@@ -280,7 +280,7 @@ public:
* @param ulIndex Number of coefficient (0..9)
* @return double value of coefficient
*/
double GetCoeff(unsigned long ulIndex) const;
double GetCoeff(std::size_t ulIndex) const;
/**
* Get the quadric coefficients as reference to the
* internal array
+9 -9
View File
@@ -38,12 +38,12 @@
using namespace MeshCore;
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(0), _ptIdx(0)
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(nullptr), _ptIdx(0)
{
_fSaveTolerance = MeshDefinitions::_fMinPointDistanceD1;
}
MeshBuilder::~MeshBuilder (void)
MeshBuilder::~MeshBuilder ()
{
MeshDefinitions::_fMinPointDistanceD1 = _fSaveTolerance;
delete this->_seq;
@@ -156,7 +156,7 @@ void MeshBuilder::AddFacet (Base::Vector3f* facetPoints, unsigned char flag, uns
void MeshBuilder::SetNeighbourhood ()
{
std::set<Edge> edges;
unsigned long facetIdx = 0;
FacetIndex facetIdx = 0;
for (MeshFacetArray::_TIterator it = _meshKernel._aclFacetArray.begin(); it != _meshKernel._aclFacetArray.end(); ++it)
{
@@ -218,7 +218,7 @@ void MeshBuilder::RemoveUnreferencedPoints()
void MeshBuilder::Finish (bool freeMemory)
{
// now we can resize the vertex array to the exact size and copy the vertices with their correct positions in the array
unsigned long i=0;
PointIndex i=0;
_meshKernel._aclPointArray.resize(_pointsIterator.size());
for ( std::vector<MeshPointIterator>::iterator it = _pointsIterator.begin(); it != _pointsIterator.end(); ++it)
_meshKernel._aclPointArray[i++] = *(it->first);
@@ -244,7 +244,7 @@ void MeshBuilder::Finish (bool freeMemory)
if ( cap > siz+siz/20 )
{
try {
unsigned long i=0;
FacetIndex i=0;
MeshFacetArray faces(siz);
for ( MeshFacetArray::_TIterator it = _meshKernel._aclFacetArray.begin(); it != _meshKernel._aclFacetArray.end(); ++it )
faces[i++]=*it;
@@ -290,7 +290,7 @@ MeshFastBuilder::MeshFastBuilder(MeshKernel &rclM) : _meshKernel(rclM), p(new Pr
{
}
MeshFastBuilder::~MeshFastBuilder(void)
MeshFastBuilder::~MeshFastBuilder()
{
delete p;
}
@@ -335,18 +335,18 @@ void MeshFastBuilder::Finish ()
int threads = std::max(1, QThread::idealThreadCount());
MeshCore::parallel_sort(verts.begin(), verts.end(), std::less<Private::Vertex>(), threads);
QVector<unsigned long> indices(ulCtPts);
QVector<FacetIndex> indices(ulCtPts);
size_type vertex_count = 0;
for (QVector<Private::Vertex>::iterator v = verts.begin(); v != verts.end(); ++v) {
if (!vertex_count || *v != verts[vertex_count-1])
verts[vertex_count++] = *v;
indices[v->i] = static_cast<unsigned long>(vertex_count - 1);
indices[v->i] = static_cast<FacetIndex>(vertex_count - 1);
}
size_type ulCt = verts.size()/3;
MeshFacetArray rFacets(static_cast<unsigned long>(ulCt));
MeshFacetArray rFacets(static_cast<FacetIndex>(ulCt));
for (size_type i=0; i < ulCt; ++i) {
rFacets[static_cast<size_t>(i)]._aulPoints[0] = indices[3*i];
rFacets[static_cast<size_t>(i)]._aulPoints[1] = indices[3*i + 1];
+6 -4
View File
@@ -64,9 +64,11 @@ private:
class Edge
{
public:
unsigned long pt1, pt2, facetIdx;
PointIndex pt1;
PointIndex pt2;
FacetIndex facetIdx;
Edge (unsigned long p1, unsigned long p2, unsigned long idx)
Edge (PointIndex p1, PointIndex p2, FacetIndex idx)
{
facetIdx = idx;
if (p1 > p2)
@@ -113,7 +115,7 @@ private:
public:
MeshBuilder(MeshKernel &rclM);
~MeshBuilder(void);
~MeshBuilder();
/**
* Set the tolerance for the comparison of points. Normally you don't need to set the tolerance.
@@ -189,7 +191,7 @@ private:
public:
typedef int size_type;
MeshFastBuilder(MeshKernel &rclM);
~MeshFastBuilder(void);
~MeshFastBuilder();
/** Initializes the class. Must be done before adding facets
* @param ctFacets count of facets.
+11 -11
View File
@@ -54,10 +54,10 @@ MeshCurvature::MeshCurvature(const MeshKernel& kernel)
: myKernel(kernel), myMinPoints(20), myRadius(0.5f)
{
mySegment.resize(kernel.CountFacets());
std::generate(mySegment.begin(), mySegment.end(), Base::iotaGen<unsigned long>(0));
std::generate(mySegment.begin(), mySegment.end(), Base::iotaGen<FacetIndex>(0));
}
MeshCurvature::MeshCurvature(const MeshKernel& kernel, const std::vector<unsigned long>& segm)
MeshCurvature::MeshCurvature(const MeshKernel& kernel, const std::vector<FacetIndex>& segm)
: myKernel(kernel), myMinPoints(20), myRadius(0.5f), mySegment(segm)
{
}
@@ -72,7 +72,7 @@ void MeshCurvature::ComputePerFace(bool parallel)
if (!parallel) {
Base::SequencerLauncher seq("Curvature estimation", mySegment.size());
for (std::vector<unsigned long>::iterator it = mySegment.begin(); it != mySegment.end(); ++it) {
for (std::vector<FacetIndex>::iterator it = mySegment.begin(); it != mySegment.end(); ++it) {
CurvatureInfo info = face.Compute(*it);
myCurvature.push_back(info);
seq.next();
@@ -343,10 +343,10 @@ namespace MeshCore {
class FitPointCollector : public MeshCollector
{
public:
FitPointCollector(std::set<unsigned long>& ind) : indices(ind){}
virtual void Append(const MeshCore::MeshKernel& kernel, unsigned long index)
FitPointCollector(std::set<PointIndex>& ind) : indices(ind){}
virtual void Append(const MeshCore::MeshKernel& kernel, FacetIndex index)
{
unsigned long ulP1, ulP2, ulP3;
PointIndex ulP1, ulP2, ulP3;
kernel.GetFacetPoints(index, ulP1, ulP2, ulP3);
indices.insert(ulP1);
indices.insert(ulP2);
@@ -354,7 +354,7 @@ public:
}
private:
std::set<unsigned long>& indices;
std::set<PointIndex>& indices;
};
}
@@ -365,15 +365,15 @@ FacetCurvature::FacetCurvature(const MeshKernel& kernel, const MeshRefPointToFac
{
}
CurvatureInfo FacetCurvature::Compute(unsigned long index) const
CurvatureInfo FacetCurvature::Compute(FacetIndex index) const
{
Base::Vector3f rkDir0, rkDir1, rkPnt;
Base::Vector3f rkDir0, rkDir1;
Base::Vector3f rkNormal;
MeshGeomFacet face = myKernel.GetFacet(index);
Base::Vector3f face_gravity = face.GetGravityPoint();
Base::Vector3f face_normal = face.GetNormal();
std::set<unsigned long> point_indices;
std::set<PointIndex> point_indices;
FitPointCollector collect(point_indices);
float searchDist = myRadius;
@@ -391,7 +391,7 @@ CurvatureInfo FacetCurvature::Compute(unsigned long index) const
std::vector<Base::Vector3f> fitPoints;
const MeshPointArray& verts = myKernel.GetPoints();
fitPoints.reserve(point_indices.size());
for (std::set<unsigned long>::iterator it = point_indices.begin(); it != point_indices.end(); ++it) {
for (std::set<PointIndex>::iterator it = point_indices.begin(); it != point_indices.end(); ++it) {
fitPoints.push_back(verts[*it] - face_gravity);
}
+4 -3
View File
@@ -25,6 +25,7 @@
#include <vector>
#include <Base/Vector3D.h>
#include "Definitions.h"
namespace MeshCore {
@@ -42,7 +43,7 @@ class MeshExport FacetCurvature
{
public:
FacetCurvature(const MeshKernel& kernel, const MeshRefPointToFacets& search, float, unsigned long);
CurvatureInfo Compute(unsigned long index) const;
CurvatureInfo Compute(FacetIndex index) const;
private:
const MeshKernel& myKernel;
@@ -55,7 +56,7 @@ class MeshExport MeshCurvature
{
public:
MeshCurvature(const MeshKernel& kernel);
MeshCurvature(const MeshKernel& kernel, const std::vector<unsigned long>& segm);
MeshCurvature(const MeshKernel& kernel, const std::vector<FacetIndex>& segm);
float GetRadius() const { return myRadius; }
void SetRadius(float r) { myRadius = r; }
void ComputePerFace(bool parallel);
@@ -66,7 +67,7 @@ private:
const MeshKernel& myKernel;
unsigned long myMinPoints;
float myRadius;
std::vector<unsigned long> mySegment;
std::vector<FacetIndex> mySegment;
std::vector<CurvatureInfo> myCurvature;
};
+1 -1
View File
@@ -40,7 +40,7 @@ float MeshDefinitions::_fMinEdgeLength = MESH_MIN_EDGE_LEN;
bool MeshDefinitions::_bRemoveMinLength = MESH_REMOVE_MIN_LEN;
float MeshDefinitions::_fMinEdgeAngle = Base::toRadians<float>(MESH_MIN_EDGE_ANGLE);
MeshDefinitions::MeshDefinitions (void)
MeshDefinitions::MeshDefinitions ()
{
}
+12 -2
View File
@@ -28,6 +28,8 @@
#include <Mod/Mesh/MeshGlobal.h>
#endif
#include <climits>
// default values
#define MESH_MIN_PT_DIST 1.0e-6f
#define MESH_MIN_EDGE_LEN 1.0e-3f
@@ -54,6 +56,14 @@
namespace MeshCore {
// type definitions
using ElementIndex = unsigned long;
const ElementIndex ELEMENT_INDEX_MAX = ULONG_MAX;
using FacetIndex = ElementIndex;
const FacetIndex FACET_INDEX_MAX = ULONG_MAX;
using PointIndex = ElementIndex;
const PointIndex POINT_INDEX_MAX = ULONG_MAX;
template <class Prec>
class Math
{
@@ -71,8 +81,8 @@ typedef Math<double> Mathd;
class MeshExport MeshDefinitions
{
public:
MeshDefinitions (void);
virtual ~MeshDefinitions (void)
MeshDefinitions ();
virtual ~MeshDefinitions ()
{}
static float _fMinPointDistance;
+91 -189
View File
@@ -63,12 +63,12 @@ bool MeshEvalInvalids::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalInvalids::GetIndices() const
std::vector<FacetIndex> MeshEvalInvalids::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
const MeshPointArray& rPoints = _rclMesh.GetPoints();
unsigned long ind=0;
FacetIndex ind=0;
for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++ )
{
if ( !it->IsValid() )
@@ -144,7 +144,7 @@ bool MeshEvalDuplicatePoints::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalDuplicatePoints::GetIndices() const
std::vector<PointIndex> MeshEvalDuplicatePoints::GetIndices() const
{
//Note: We must neither use map or set to get duplicated indices because
//the sort algorithms deliver different results compared to std::sort of
@@ -157,7 +157,7 @@ std::vector<unsigned long> MeshEvalDuplicatePoints::GetIndices() const
}
// if there are two adjacent vertices which have the same coordinates
std::vector<unsigned long> aInds;
std::vector<PointIndex> aInds;
Vertex_EqualTo pred;
std::sort(vertices.begin(), vertices.end(), Vertex_Less());
@@ -187,21 +187,20 @@ bool MeshFixDuplicatePoints::Fixup()
}
// get the indices of adjacent vertices which have the same coordinates
std::vector<unsigned long> aInds;
std::sort(vertices.begin(), vertices.end(), Vertex_Less());
Vertex_EqualTo pred;
std::vector<VertexIterator>::iterator next = vertices.begin();
std::map<unsigned long, unsigned long> mapPointIndex;
std::vector<unsigned long> pointIndices;
std::map<PointIndex, PointIndex> mapPointIndex;
std::vector<PointIndex> pointIndices;
while (next < vertices.end()) {
next = std::adjacent_find(next, vertices.end(), pred);
if (next < vertices.end()) {
std::vector<VertexIterator>::iterator first = next;
unsigned long first_index = *first - rPoints.begin();
PointIndex first_index = *first - rPoints.begin();
++next;
while (next < vertices.end() && pred(*first, *next)) {
unsigned long next_index = *next - rPoints.begin();
PointIndex next_index = *next - rPoints.begin();
mapPointIndex[next_index] = first_index;
pointIndices.push_back(next_index);
++next;
@@ -213,7 +212,7 @@ bool MeshFixDuplicatePoints::Fixup()
MeshFacetArray& rFacets = _rclMesh._aclFacetArray;
for (MeshFacetArray::_TIterator it = rFacets.begin(); it != rFacets.end(); ++it) {
for (int i=0; i<3; i++) {
std::map<unsigned long, unsigned long>::iterator pt = mapPointIndex.find(it->_aulPoints[i]);
std::map<PointIndex, PointIndex>::iterator pt = mapPointIndex.find(it->_aulPoints[i]);
if (pt != mapPointIndex.end())
it->_aulPoints[i] = pt->second;
}
@@ -239,9 +238,9 @@ bool MeshEvalNaNPoints::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalNaNPoints::GetIndices() const
std::vector<PointIndex> MeshEvalNaNPoints::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<PointIndex> 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))
@@ -253,7 +252,7 @@ std::vector<unsigned long> MeshEvalNaNPoints::GetIndices() const
bool MeshFixNaNPoints::Fixup()
{
std::vector<unsigned long> aInds;
std::vector<PointIndex> 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))
@@ -280,13 +279,13 @@ struct MeshFacet_Less
bool operator()(const FaceIterator& x,
const FaceIterator& y) const
{
unsigned long tmp;
unsigned long x0 = x->_aulPoints[0];
unsigned long x1 = x->_aulPoints[1];
unsigned long x2 = x->_aulPoints[2];
unsigned long y0 = y->_aulPoints[0];
unsigned long y1 = y->_aulPoints[1];
unsigned long y2 = y->_aulPoints[2];
PointIndex tmp;
PointIndex x0 = x->_aulPoints[0];
PointIndex x1 = x->_aulPoints[1];
PointIndex x2 = x->_aulPoints[2];
PointIndex y0 = y->_aulPoints[0];
PointIndex y1 = y->_aulPoints[1];
PointIndex y2 = y->_aulPoints[2];
if (x0 > x1)
{ tmp = x0; x0 = x1; x1 = tmp; }
@@ -351,7 +350,7 @@ bool MeshEvalDuplicateFacets::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalDuplicateFacets::GetIndices() const
std::vector<FacetIndex> MeshEvalDuplicateFacets::GetIndices() const
{
#if 1
const MeshFacetArray& rFacets = _rclMesh.GetFacets();
@@ -362,7 +361,7 @@ std::vector<unsigned long> MeshEvalDuplicateFacets::GetIndices() const
}
// if there are two adjacent faces which references the same vertices
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
MeshFacet_EqualTo pred;
std::sort(faces.begin(), faces.end(), MeshFacet_Less());
@@ -378,9 +377,9 @@ std::vector<unsigned long> MeshEvalDuplicateFacets::GetIndices() const
return aInds;
#else
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long uIndex=0;
FacetIndex uIndex=0;
// get all facets
std::set<FaceIterator, MeshFacet_Less > aFaceSet;
@@ -398,8 +397,8 @@ std::vector<unsigned long> MeshEvalDuplicateFacets::GetIndices() const
bool MeshFixDuplicateFacets::Fixup()
{
unsigned long uIndex=0;
std::vector<unsigned long> aRemoveFaces;
FacetIndex uIndex=0;
std::vector<FacetIndex> aRemoveFaces;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
// get all facets
@@ -422,7 +421,7 @@ bool MeshFixDuplicateFacets::Fixup()
bool MeshEvalInternalFacets::Evaluate()
{
_indices.clear();
unsigned long uIndex=0;
FacetIndex uIndex=0;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
// get all facets
@@ -470,9 +469,9 @@ unsigned long MeshEvalDegeneratedFacets::CountEdgeTooSmall (float fMinEdgeLength
return k;
}
std::vector<unsigned long> MeshEvalDegeneratedFacets::GetIndices() const
std::vector<FacetIndex> MeshEvalDegeneratedFacets::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
MeshFacetIterator it(_rclMesh);
for (it.Init(); it.More(); it.Next()) {
if (it->IsDegenerated(fEpsilon))
@@ -489,10 +488,9 @@ bool MeshFixDegeneratedFacets::Fixup()
MeshFacetIterator it(_rclMesh);
for (it.Init(); it.More(); it.Next()) {
if (it->IsDegenerated(fEpsilon)) {
unsigned long uCt = _rclMesh.CountFacets();
unsigned long uId = it.Position();
cTopAlg.RemoveDegeneratedFacet(uId);
if (uCt != _rclMesh.CountFacets()) {
FacetIndex uId = it.Position();
bool removed = cTopAlg.RemoveDegeneratedFacet(uId);
if (removed) {
// due to a modification of the array the iterator became invalid
it.Set(uId-1);
}
@@ -562,18 +560,18 @@ bool MeshRemoveNeedles::Fixup()
ce._toPoint = rclFAry[faceedge.first]._aulPoints[(faceedge.second+1)%3];
ce._removeFacets.push_back(faceedge.first);
unsigned long neighbour = rclFAry[faceedge.first]._aulNeighbours[faceedge.second];
if (neighbour != ULONG_MAX)
FacetIndex neighbour = rclFAry[faceedge.first]._aulNeighbours[faceedge.second];
if (neighbour != FACET_INDEX_MAX)
ce._removeFacets.push_back(neighbour);
std::set<unsigned long> vf = vf_it[ce._fromPoint];
std::set<FacetIndex> vf = vf_it[ce._fromPoint];
vf.erase(faceedge.first);
if (neighbour != ULONG_MAX)
if (neighbour != FACET_INDEX_MAX)
vf.erase(neighbour);
ce._changeFacets.insert(ce._changeFacets.begin(), vf.begin(), vf.end());
// get adjacent points
std::set<unsigned long> vv;
std::set<PointIndex> vv;
vv = vf_it.NeighbourPoints(ce._fromPoint);
ce._adjacentFrom.insert(ce._adjacentFrom.begin(), vv.begin(),vv.end());
vv = vf_it.NeighbourPoints(ce._toPoint);
@@ -598,98 +596,6 @@ bool MeshRemoveNeedles::Fixup()
}
return true;
#if 0
unsigned long ulCtLastLoop, ulCtFacets = _rclMesh.CountFacets();
const MeshFacetArray &rclFAry = _rclMesh.GetFacets();
const MeshPointArray &rclPAry = _rclMesh.GetPoints();
MeshFacetArray::_TConstIterator f_beg = rclFAry.begin();
// repeat until no facet can be removed
do {
MeshRefPointToFacets clPt2Facets(_rclMesh);
rclFAry.ResetInvalid();
rclPAry.ResetInvalid();
rclPAry.ResetFlag(MeshPoint::VISIT);
std::set<std::pair<unsigned long, unsigned long> > aclPtDelList;
MeshFacetIterator clFIter(_rclMesh);
for (clFIter.Init(); clFIter.More(); clFIter.Next()) {
MeshGeomFacet clSFacet = *clFIter;
Base::Vector3f clP0 = clSFacet._aclPoints[0];
Base::Vector3f clP1 = clSFacet._aclPoints[1];
Base::Vector3f clP2 = clSFacet._aclPoints[2];
Base::Vector3f clE01 = clP1 - clP0;
Base::Vector3f clE12 = clP2 - clP1;
Base::Vector3f clE20 = clP2 - clP0;
MeshFacet clFacet = clFIter.GetIndices();
unsigned long ulP0 = clFacet._aulPoints[0];
unsigned long ulP1 = clFacet._aulPoints[1];
unsigned long ulP2 = clFacet._aulPoints[2];
if (Base::Distance(clP0, clP1) < fMinEdgeLength) {
// delete point P1 on P0
aclPtDelList.insert(std::make_pair
(std::min<unsigned long>(ulP1, ulP0), std::max<unsigned long>(ulP1, ulP0)));
clFIter.SetFlag(MeshFacet::INVALID);
}
else if (Base::Distance(clP1, clP2) < fMinEdgeLength) {
// delete point P2 on P1
aclPtDelList.insert(std::make_pair
(std::min<unsigned long>(ulP2, ulP1), std::max<unsigned long>(ulP2, ulP1)));
clFIter.SetFlag(MeshFacet::INVALID);
}
else if (Base::Distance(clP2, clP0) < fMinEdgeLength) {
// delete point P0 on P2
aclPtDelList.insert(std::make_pair
(std::min<unsigned long>(ulP0, ulP2), std::max<unsigned long>(ulP0, ulP2)));
clFIter.SetFlag(MeshFacet::INVALID);
}
}
#if 0
// remove points, fix indices
for (std::set<std::pair<unsigned long, unsigned long> >::iterator pI = aclPtDelList.begin();
pI != aclPtDelList.end(); ++pI) {
// one of the point pairs is already processed
if ((rclPAry[pI->first].IsFlag(MeshPoint::VISIT) == true) ||
(rclPAry[pI->second].IsFlag(MeshPoint::VISIT) == true))
continue;
rclPAry[pI->first].SetFlag(MeshPoint::VISIT);
rclPAry[pI->second].SetFlag(MeshPoint::VISIT);
rclPAry[pI->second].SetInvalid();
// Redirect all point-indices to the new neighbour point of all facets referencing the
// deleted point
const std::set<unsigned long>& faces = clPt2Facets[pI->second];
for (std::set<unsigned long>::const_iterator pF = faces.begin(); pF != faces.end(); ++pF) {
const MeshFacet &rclF = f_beg[*pF];
for (int i = 0; i < 3; i++) {
// if (rclF._aulPoints[i] == pI->second)
// rclF._aulPoints[i] = pI->first;
}
// Delete facets with two identical corners
if ((rclF._aulPoints[0] == rclF._aulPoints[1]) ||
(rclF._aulPoints[0] == rclF._aulPoints[2]) ||
(rclF._aulPoints[1] == rclF._aulPoints[2])) {
rclF.SetInvalid();
}
}
}
#endif
ulCtLastLoop = _rclMesh.CountFacets();
_rclMesh.RemoveInvalids();
}
while (ulCtLastLoop > _rclMesh.CountFacets());
_rclMesh.RebuildNeighbours();
return ulCtFacets > _rclMesh.CountFacets();
#endif
}
// ----------------------------------------------------------------------
@@ -754,9 +660,9 @@ bool MeshFixCaps::Fixup()
if (distP2P4/distP2P3 < fSplitFactor || distP3P4/distP2P3 < fSplitFactor)
continue;
unsigned long facetpos = facevertex.first;
unsigned long neighbour = rclFAry[facetpos]._aulNeighbours[(facevertex.second+1)%3];
if (neighbour != ULONG_MAX)
FacetIndex facetpos = facevertex.first;
FacetIndex neighbour = rclFAry[facetpos]._aulNeighbours[(facevertex.second+1)%3];
if (neighbour != FACET_INDEX_MAX)
topAlg.SwapEdge(facetpos, neighbour);
}
@@ -779,12 +685,12 @@ bool MeshEvalDeformedFacets::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalDeformedFacets::GetIndices() const
std::vector<FacetIndex> MeshEvalDeformedFacets::GetIndices() const
{
float fCosMinAngle = cos(fMinAngle);
float fCosMaxAngle = cos(fMaxAngle);
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
MeshFacetIterator it(_rclMesh);
for (it.Init(); it.More(); it.Next()) {
if (it->IsDeformed(fCosMinAngle, fCosMaxAngle))
@@ -825,8 +731,8 @@ bool MeshFixDeformedFacets::Fixup()
float fCosAngle = fCosAngles[i];
if (fCosAngle < fCosMaxAngle) {
const MeshFacet& face = it.GetReference();
unsigned long uNeighbour = face._aulNeighbours[(i+1)%3];
if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
FacetIndex uNeighbour = face._aulNeighbours[(i+1)%3];
if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
cTopAlg.SwapEdge(it.Position(), uNeighbour);
done = true;
}
@@ -844,14 +750,14 @@ bool MeshFixDeformedFacets::Fixup()
if (fCosAngle > fCosMinAngle) {
const MeshFacet& face = it.GetReference();
unsigned long uNeighbour = face._aulNeighbours[j];
if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
FacetIndex uNeighbour = face._aulNeighbours[j];
if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
cTopAlg.SwapEdge(it.Position(), uNeighbour);
break;
}
uNeighbour = face._aulNeighbours[(j+2)%3];
if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) {
cTopAlg.SwapEdge(it.Position(), uNeighbour);
break;
}
@@ -879,9 +785,9 @@ bool MeshFixMergeFacets::Fixup()
if (vv_it[i].size() == 3 && vf_it[i].size() == 3) {
VertexCollapse vc;
vc._point = i;
const std::set<unsigned long>& adjPts = vv_it[i];
const std::set<PointIndex>& adjPts = vv_it[i];
vc._circumPoints.insert(vc._circumPoints.begin(), adjPts.begin(), adjPts.end());
const std::set<unsigned long>& adjFts = vf_it[i];
const std::set<FacetIndex>& adjFts = vf_it[i];
vc._circumFacets.insert(vc._circumFacets.begin(), adjFts.begin(), adjFts.end());
topAlg.CollapseVertex(vc);
}
@@ -904,16 +810,16 @@ bool MeshEvalDentsOnSurface::Evaluate()
Base::Vector3f tmp;
unsigned long ctPoints = _rclMesh.CountPoints();
for (unsigned long index=0; index < ctPoints; index++) {
std::vector<unsigned long> point;
std::vector<PointIndex> point;
point.push_back(index);
// get the local neighbourhood of the point
std::set<unsigned long> nb = clPt2Facets.NeighbourPoints(point,1);
const std::set<unsigned long>& faces = clPt2Facets[index];
std::set<PointIndex> nb = clPt2Facets.NeighbourPoints(point,1);
const std::set<FacetIndex>& faces = clPt2Facets[index];
for (std::set<unsigned long>::iterator pt = nb.begin(); pt != nb.end(); ++pt) {
for (std::set<PointIndex>::iterator pt = nb.begin(); pt != nb.end(); ++pt) {
const MeshPoint& mp = rPntAry[*pt];
for (std::set<unsigned long>::const_iterator
for (std::set<FacetIndex>::const_iterator
ft = faces.begin(); ft != faces.end(); ++ft) {
// the point must not be part of the facet we test
if (f_beg[*ft]._aulPoints[0] == *pt)
@@ -925,7 +831,7 @@ bool MeshEvalDentsOnSurface::Evaluate()
// is the point projectable onto the facet?
rTriangle = _rclMesh.GetFacet(f_beg[*ft]);
if (rTriangle.IntersectWithLine(mp,rTriangle.GetNormal(),tmp)) {
const std::set<unsigned long>& f = clPt2Facets[*pt];
const std::set<FacetIndex>& f = clPt2Facets[*pt];
this->indices.insert(this->indices.end(), f.begin(), f.end());
break;
}
@@ -941,7 +847,7 @@ bool MeshEvalDentsOnSurface::Evaluate()
return this->indices.empty();
}
std::vector<unsigned long> MeshEvalDentsOnSurface::GetIndices() const
std::vector<FacetIndex> MeshEvalDentsOnSurface::GetIndices() const
{
return this->indices;
}
@@ -961,7 +867,7 @@ bool MeshFixDentsOnSurface::Fixup()
{
MeshEvalDentsOnSurface eval(_rclMesh);
if (!eval.Evaluate()) {
std::vector<unsigned long> inds = eval.GetIndices();
std::vector<FacetIndex> inds = eval.GetIndices();
_rclMesh.DeleteFacets(inds);
}
@@ -977,10 +883,10 @@ bool MeshEvalFoldsOnSurface::Evaluate()
unsigned long ct=0;
for (MeshFacetArray::const_iterator it = rFAry.begin(); it != rFAry.end(); ++it, ct++) {
for (int i=0; i<3; i++) {
unsigned long n1 = it->_aulNeighbours[i];
unsigned long n2 = it->_aulNeighbours[(i+1)%3];
FacetIndex n1 = it->_aulNeighbours[i];
FacetIndex n2 = it->_aulNeighbours[(i+1)%3];
Base::Vector3f v1 =_rclMesh.GetFacet(*it).GetNormal();
if (n1 != ULONG_MAX && n2 != ULONG_MAX) {
if (n1 != FACET_INDEX_MAX && n2 != FACET_INDEX_MAX) {
Base::Vector3f v2 = _rclMesh.GetFacet(n1).GetNormal();
Base::Vector3f v3 = _rclMesh.GetFacet(n2).GetNormal();
if (v2 * v3 > 0.0f) {
@@ -1001,7 +907,7 @@ bool MeshEvalFoldsOnSurface::Evaluate()
return this->indices.empty();
}
std::vector<unsigned long> MeshEvalFoldsOnSurface::GetIndices() const
std::vector<FacetIndex> MeshEvalFoldsOnSurface::GetIndices() const
{
return this->indices;
}
@@ -1017,7 +923,7 @@ bool MeshEvalFoldsOnBoundary::Evaluate()
for (MeshFacetArray::_TConstIterator it = rFacAry.begin(); it != rFacAry.end(); ++it) {
if (it->CountOpenEdges() == 2) {
for (int i=0; i<3; i++) {
if (it->_aulNeighbours[i] != ULONG_MAX) {
if (it->_aulNeighbours[i] != FACET_INDEX_MAX) {
MeshGeomFacet f1 = _rclMesh.GetFacet(*it);
MeshGeomFacet f2 = _rclMesh.GetFacet(it->_aulNeighbours[i]);
float cos_angle = f1.GetNormal() * f2.GetNormal();
@@ -1031,7 +937,7 @@ bool MeshEvalFoldsOnBoundary::Evaluate()
return this->indices.empty();
}
std::vector<unsigned long> MeshEvalFoldsOnBoundary::GetIndices() const
std::vector<FacetIndex> MeshEvalFoldsOnBoundary::GetIndices() const
{
return this->indices;
}
@@ -1040,7 +946,7 @@ bool MeshFixFoldsOnBoundary::Fixup()
{
MeshEvalFoldsOnBoundary eval(_rclMesh);
if (!eval.Evaluate()) {
std::vector<unsigned long> inds = eval.GetIndices();
std::vector<FacetIndex> inds = eval.GetIndices();
_rclMesh.DeleteFacets(inds);
}
@@ -1059,9 +965,9 @@ bool MeshEvalFoldOversOnSurface::Evaluate()
Base::Vector3f n1, n2;
for (f_it = facets.begin(); f_it != f_end; ++f_it) {
for (int i=0; i<3; i++) {
unsigned long index1 = f_it->_aulNeighbours[i];
unsigned long index2 = f_it->_aulNeighbours[(i+1)%3];
if (index1 != ULONG_MAX && index2 != ULONG_MAX) {
FacetIndex index1 = f_it->_aulNeighbours[i];
FacetIndex index2 = f_it->_aulNeighbours[(i+1)%3];
if (index1 != FACET_INDEX_MAX && index2 != FACET_INDEX_MAX) {
// if the topology is correct but the normals flip from
// two neighbours we have a fold
if (f_it->HasSameOrientation(f_beg[index1]) &&
@@ -1093,7 +999,7 @@ bool MeshEvalBorderFacet::Evaluate()
for (f_it = facets.begin(); f_it != f_end; ++f_it) {
bool ok = true;
for (int i=0; i<3; i++) {
unsigned long index = f_it->_aulPoints[i];
PointIndex index = f_it->_aulPoints[i];
if (vv_it[index].size() == vf_it[index].size()) {
ok = false;
break;
@@ -1112,11 +1018,11 @@ bool MeshEvalBorderFacet::Evaluate()
bool MeshEvalRangeFacet::Evaluate()
{
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long ulCtFacets = rFaces.size();
FacetIndex ulCtFacets = rFaces.size();
for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
for (int i = 0; i < 3; i++) {
if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < ULONG_MAX)) {
if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < FACET_INDEX_MAX)) {
return false;
}
}
@@ -1125,16 +1031,16 @@ bool MeshEvalRangeFacet::Evaluate()
return true;
}
std::vector<unsigned long> MeshEvalRangeFacet::GetIndices() const
std::vector<FacetIndex> MeshEvalRangeFacet::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long ulCtFacets = rFaces.size();
FacetIndex ulCtFacets = rFaces.size();
unsigned long ind=0;
FacetIndex ind=0;
for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++) {
for (int i = 0; i < 3; i++) {
if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < ULONG_MAX)) {
if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < FACET_INDEX_MAX)) {
aInds.push_back(ind);
break;
}
@@ -1155,25 +1061,25 @@ bool MeshFixRangeFacet::Fixup()
bool MeshEvalRangePoint::Evaluate()
{
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long ulCtPoints = _rclMesh.CountPoints();
PointIndex ulCtPoints = _rclMesh.CountPoints();
for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](unsigned long i) { return i >= ulCtPoints; }) < it->_aulPoints + 3)
if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3)
return false;
}
return true;
}
std::vector<unsigned long> MeshEvalRangePoint::GetIndices() const
std::vector<PointIndex> MeshEvalRangePoint::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<PointIndex> aInds;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long ulCtPoints = _rclMesh.CountPoints();
PointIndex ulCtPoints = _rclMesh.CountPoints();
unsigned long ind=0;
PointIndex ind=0;
for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++) {
if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](unsigned long i) { return i >= ulCtPoints; }) < it->_aulPoints + 3)
if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3)
aInds.push_back(ind);
}
@@ -1190,10 +1096,10 @@ bool MeshFixRangePoint::Fixup()
else {
// facets with point indices out of range cannot be directly deleted because
// 'DeleteFacets' will segfault. But setting all point indices to 0 works.
std::vector<unsigned long> invalid = eval.GetIndices();
std::vector<PointIndex> invalid = eval.GetIndices();
if (!invalid.empty()) {
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
for (std::vector<unsigned long>::iterator it = invalid.begin(); it != invalid.end(); ++it) {
for (std::vector<PointIndex>::iterator it = invalid.begin(); it != invalid.end(); ++it) {
MeshFacet& face = const_cast<MeshFacet&>(rFaces[*it]);
face._aulPoints[0] = 0;
face._aulPoints[1] = 0;
@@ -1214,25 +1120,21 @@ bool MeshEvalCorruptedFacets::Evaluate()
for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it ) {
// dupicated point indices
if ((it->_aulPoints[0] == it->_aulPoints[1]) ||
(it->_aulPoints[1] == it->_aulPoints[2]) ||
(it->_aulPoints[2] == it->_aulPoints[0]))
if (it->IsDegenerated())
return false;
}
return true;
}
std::vector<unsigned long> MeshEvalCorruptedFacets::GetIndices() const
std::vector<FacetIndex> MeshEvalCorruptedFacets::GetIndices() const
{
std::vector<unsigned long> aInds;
std::vector<FacetIndex> aInds;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
unsigned long ind=0;
FacetIndex ind=0;
for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++ ) {
if ((it->_aulPoints[0] == it->_aulPoints[1]) ||
(it->_aulPoints[1] == it->_aulPoints[2]) ||
(it->_aulPoints[2] == it->_aulPoints[0]))
if (it->IsDegenerated())
aInds.push_back(ind);
}
@@ -1246,7 +1148,7 @@ bool MeshFixCorruptedFacets::Fixup()
MeshFacetIterator it(_rclMesh);
for ( it.Init(); it.More(); it.Next() )
{
if ( it->Area() <= FLOAT_EPS )
if ( it.GetReference().IsDegenerated() )
{
unsigned long uId = it.Position();
bool removed = cTopAlg.RemoveCorruptedFacet(uId);
@@ -1254,7 +1156,7 @@ bool MeshFixCorruptedFacets::Fixup()
// due to a modification of the array the iterator became invalid
it.Set(uId-1);
}
}
}
+21 -21
View File
@@ -62,7 +62,7 @@ public:
/**
* Returns the indices of all invalid facets or facets whose points are invalid.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
};
/**
@@ -113,7 +113,7 @@ public:
/**
* Returns the indices of all duplicated points.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<PointIndex> GetIndices() const;
};
/**
@@ -161,7 +161,7 @@ public:
/**
* Returns the indices of all NaN points.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<PointIndex> GetIndices() const;
};
/**
@@ -211,7 +211,7 @@ public:
/**
* Returns the indices of all duplicated facets.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
};
/**
@@ -258,11 +258,11 @@ public:
/**
* Return the indices.
*/
const std::vector<unsigned long>& GetIndices() const
const std::vector<FacetIndex>& GetIndices() const
{ return _indices; }
private:
std::vector<unsigned long> _indices;
std::vector<FacetIndex> _indices;
};
/**
@@ -297,7 +297,7 @@ public:
/**
* Returns the indices of all corrupt facets.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
float fEpsilon;
@@ -417,7 +417,7 @@ public:
/**
* Returns the indices of deformed facets.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
float fMinAngle; /**< If an angle of a facet is lower than fMinAngle it's considered as deformed. */
@@ -493,10 +493,10 @@ public:
~MeshEvalDentsOnSurface() {}
bool Evaluate();
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
};
class MeshExport MeshFixDentsOnSurface : public MeshValidation
@@ -520,10 +520,10 @@ public:
~MeshEvalFoldsOnSurface() {}
bool Evaluate();
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
};
/**
@@ -539,10 +539,10 @@ public:
~MeshEvalFoldsOnBoundary() {}
bool Evaluate();
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
};
class MeshExport MeshFixFoldsOnBoundary : public MeshValidation
@@ -565,11 +565,11 @@ public:
~MeshEvalFoldOversOnSurface() {}
bool Evaluate();
std::vector<unsigned long> GetIndices() const
std::vector<FacetIndex> GetIndices() const
{ return this->indices; }
private:
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
};
/**
@@ -580,13 +580,13 @@ private:
class MeshExport MeshEvalBorderFacet : public MeshEvaluation
{
public:
MeshEvalBorderFacet (const MeshKernel &rclB, std::vector<unsigned long>& f)
MeshEvalBorderFacet (const MeshKernel &rclB, std::vector<FacetIndex>& f)
: MeshEvaluation(rclB), _facets(f) {}
virtual ~MeshEvalBorderFacet () {}
bool Evaluate();
protected:
std::vector<unsigned long>& _facets;
std::vector<FacetIndex>& _facets;
};
// ----------------------------------------------------
@@ -618,7 +618,7 @@ public:
/**
* Returns the indices of all facets with invalid neighbour indices.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
};
/**
@@ -666,7 +666,7 @@ public:
/**
* Returns the indices of all facets with invalid point indices.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<PointIndex> GetIndices() const;
};
/**
@@ -715,7 +715,7 @@ public:
/**
* Returns the indices of all corrupt facets.
*/
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
};
/**
+15 -15
View File
@@ -44,7 +44,7 @@ MeshPointArray::MeshPointArray(const MeshPointArray& ary)
{
}
unsigned long MeshPointArray::Get (const MeshPoint &rclPoint)
PointIndex MeshPointArray::Get (const MeshPoint &rclPoint)
{
iterator clIter;
@@ -52,17 +52,17 @@ unsigned long MeshPointArray::Get (const MeshPoint &rclPoint)
if (clIter != end())
return clIter - begin();
else
return ULONG_MAX;
return POINT_INDEX_MAX;
}
unsigned long MeshPointArray::GetOrAddIndex (const MeshPoint &rclPoint)
PointIndex MeshPointArray::GetOrAddIndex (const MeshPoint &rclPoint)
{
unsigned long ulIndex;
PointIndex ulIndex;
if ((ulIndex = Get(rclPoint)) == ULONG_MAX)
if ((ulIndex = Get(rclPoint)) == POINT_INDEX_MAX)
{
push_back(rclPoint);
return static_cast<unsigned long>(size() - 1);
return static_cast<PointIndex>(size() - 1);
}
else
return ulIndex;
@@ -83,7 +83,7 @@ void MeshPointArray::SetProperty (unsigned long ulVal) const
for (_TConstIterator pP = begin(); pP != end(); ++pP) pP->SetProperty(ulVal);
}
void MeshPointArray::ResetInvalid (void) const
void MeshPointArray::ResetInvalid () const
{
for (_TConstIterator pP = begin(); pP != end(); ++pP) pP->ResetInvalid();
}
@@ -110,9 +110,9 @@ MeshFacetArray::MeshFacetArray(const MeshFacetArray& ary)
void MeshFacetArray::Erase (_TIterator pIter)
{
unsigned long i, *pulN;
FacetIndex i, *pulN;
_TIterator pPass, pEnd;
unsigned long ulInd = pIter - begin();
FacetIndex ulInd = pIter - begin();
erase(pIter);
pPass = begin();
pEnd = end();
@@ -121,14 +121,14 @@ void MeshFacetArray::Erase (_TIterator pIter)
for (i = 0; i < 3; i++)
{
pulN = &pPass->_aulNeighbours[i];
if ((*pulN > ulInd) && (*pulN != ULONG_MAX))
if ((*pulN > ulInd) && (*pulN != FACET_INDEX_MAX))
(*pulN)--;
}
pPass++;
}
}
void MeshFacetArray::TransposeIndices (unsigned long ulOrig, unsigned long ulNew)
void MeshFacetArray::TransposeIndices (PointIndex ulOrig, PointIndex ulNew)
{
_TIterator pIter = begin(), pEnd = end();
@@ -139,7 +139,7 @@ void MeshFacetArray::TransposeIndices (unsigned long ulOrig, unsigned long ulNew
}
}
void MeshFacetArray::DecrementIndices (unsigned long ulIndex)
void MeshFacetArray::DecrementIndices (PointIndex ulIndex)
{
_TIterator pIter = begin(), pEnd = end();
@@ -165,7 +165,7 @@ void MeshFacetArray::SetProperty (unsigned long ulVal) const
for (_TConstIterator pF = begin(); pF != end(); ++pF) pF->SetProperty(ulVal);
}
void MeshFacetArray::ResetInvalid (void) const
void MeshFacetArray::ResetInvalid () const
{
for (_TConstIterator pF = begin(); pF != end(); ++pF) pF->ResetInvalid();
}
@@ -352,7 +352,7 @@ void MeshGeomEdge::ClosestPointsToLine(const Base::Vector3f &linePt, const Base:
// -----------------------------------------------------------------
MeshGeomFacet::MeshGeomFacet (void)
MeshGeomFacet::MeshGeomFacet ()
: _bNormalCalculated(false),
_ucFlag(0), _ulProp(0)
{
@@ -497,7 +497,7 @@ void MeshGeomFacet::Enlarge (float fDist)
{
Base::Vector3f clM, clU, clV, clPNew[3];
float fA, fD;
unsigned long i, ulP1, ulP2, ulP3;
PointIndex i, ulP1, ulP2, ulP3;
for (i = 0; i < 3; i++)
{
+80 -80
View File
@@ -54,7 +54,7 @@ class MeshExport MeshHelpEdge
{
public:
inline bool operator == (const MeshHelpEdge &rclEdge) const;
unsigned long _ulIndex[2]; // point indices
PointIndex _ulIndex[2]; // point indices
};
/**
@@ -64,28 +64,28 @@ public:
class MeshExport MeshIndexEdge
{
public:
unsigned long _ulFacetIndex; // Facet index
FacetIndex _ulFacetIndex; // Facet index
unsigned short _ausCorner[2]; // corner point indices of the facet
};
/** MeshEdge just a pair of two point indices */
typedef std::pair<unsigned long, unsigned long> MeshEdge;
typedef std::pair<PointIndex, PointIndex> MeshEdge;
struct MeshExport EdgeCollapse
{
unsigned long _fromPoint;
unsigned long _toPoint;
std::vector<unsigned long> _adjacentFrom; // adjacent points to _fromPoint
std::vector<unsigned long> _adjacentTo; // adjacent points to _toPoint
std::vector<unsigned long> _removeFacets;
std::vector<unsigned long> _changeFacets;
PointIndex _fromPoint;
PointIndex _toPoint;
std::vector<PointIndex> _adjacentFrom; // adjacent points to _fromPoint
std::vector<PointIndex> _adjacentTo; // adjacent points to _toPoint
std::vector<FacetIndex> _removeFacets;
std::vector<FacetIndex> _changeFacets;
};
struct MeshExport VertexCollapse
{
unsigned long _point;
std::vector<unsigned long> _circumPoints;
std::vector<unsigned long> _circumFacets;
PointIndex _point;
std::vector<PointIndex> _circumPoints;
std::vector<FacetIndex> _circumFacets;
};
/**
@@ -108,11 +108,11 @@ public:
/** @name Construction */
//@{
MeshPoint (void) : _ucFlag(0), _ulProp(0) { }
MeshPoint () : _ucFlag(0), _ulProp(0) { }
inline MeshPoint (float x, float y, float z);
inline MeshPoint (const Base::Vector3f &rclPt);
inline MeshPoint (const MeshPoint &rclPt);
~MeshPoint (void) { }
~MeshPoint () { }
//@}
public:
@@ -126,11 +126,11 @@ public:
{ const_cast<MeshPoint*>(this)->_ucFlag &= ~static_cast<unsigned char>(tF); }
bool IsFlag (TFlagType tF) const
{ return (_ucFlag & static_cast<unsigned char>(tF)) == static_cast<unsigned char>(tF); }
void ResetInvalid (void) const
void ResetInvalid () const
{ ResetFlag(INVALID); }
void SetInvalid (void) const
void SetInvalid () const
{ SetFlag(INVALID); }
bool IsValid (void) const
bool IsValid () const
{ return !IsFlag(INVALID); }
void SetProperty(unsigned long uP) const
{ const_cast<MeshPoint*>(this)->_ulProp = uP; }
@@ -156,7 +156,7 @@ public:
class MeshExport MeshGeomEdge
{
public:
MeshGeomEdge (void) : _bBorder(false) {}
MeshGeomEdge () : _bBorder(false) {}
/** Checks if the edge is inside the bounding box or intersects with it. */
bool ContainedByOrIntersectBoundingBox (const Base::BoundBox3f &rclBB ) const;
@@ -199,7 +199,7 @@ public:
* \li neighbour or edge number of 0 is defined by corner 0 and 1
* \li neighbour or edge number of 1 is defined by corner 1 and 2
* \li neighbour or edge number of 2 is defined by corner 2 and 0
* \li neighbour index is set to ULONG_MAX if there is no neighbour facet
* \li neighbour index is set to FACET_INDEX_MAX if there is no neighbour facet
*
* Note: The status flag SEGMENT mark a facet to be part of certain subset, a segment.
* This flag must not be set by any algorithm unless it adds or removes facets to a segment.
@@ -215,10 +215,10 @@ public:
public:
/** @name Construction */
//@{
inline MeshFacet (void);
inline MeshFacet ();
inline MeshFacet(const MeshFacet &rclF);
inline MeshFacet(unsigned long p1,unsigned long p2,unsigned long p3,unsigned long n1=ULONG_MAX,unsigned long n2=ULONG_MAX,unsigned long n3=ULONG_MAX);
~MeshFacet (void) { }
inline MeshFacet(PointIndex p1,PointIndex p2,PointIndex p3,FacetIndex n1=FACET_INDEX_MAX,FacetIndex n2=FACET_INDEX_MAX,FacetIndex n3=FACET_INDEX_MAX);
~MeshFacet () { }
//@}
/** @name Flag state
@@ -231,7 +231,7 @@ public:
{ const_cast<MeshFacet*>(this)->_ucFlag &= ~static_cast<unsigned char>(tF); }
bool IsFlag (TFlagType tF) const
{ return (_ucFlag & static_cast<unsigned char>(tF)) == static_cast<unsigned char>(tF); }
void ResetInvalid (void) const
void ResetInvalid () const
{ ResetFlag(INVALID); }
void SetProperty(unsigned long uP) const
{ const_cast<MeshFacet*>(this)->_ulProp = uP; }
@@ -240,16 +240,16 @@ public:
* (e.g. deletion of several facets) but must not be set permanently.
* From outside the data-structure must not have invalid facets.
*/
void SetInvalid (void) const
void SetInvalid () const
{ SetFlag(INVALID); }
bool IsValid (void) const
bool IsValid () const
{ return !IsFlag(INVALID); }
//@}
// Assignment
inline MeshFacet& operator = (const MeshFacet &rclF);
inline void SetVertices(unsigned long,unsigned long,unsigned long);
inline void SetNeighbours(unsigned long,unsigned long,unsigned long);
inline void SetVertices(PointIndex,PointIndex,PointIndex);
inline void SetNeighbours(FacetIndex,FacetIndex,FacetIndex);
/**
* Returns the indices of the corner points of the given edge number.
@@ -258,17 +258,17 @@ public:
/**
* Returns the indices of the corner points of the given edge number.
*/
inline std::pair<unsigned long, unsigned long> GetEdge (unsigned short usSide) const;
inline std::pair<PointIndex, PointIndex> GetEdge (unsigned short usSide) const;
/**
* Returns the edge-number to the given index of neighbour facet.
* If \a ulNIndex is not a neighbour USHRT_MAX is returned.
*/
inline unsigned short Side (unsigned long ulNIndex) const;
inline unsigned short Side (FacetIndex ulNIndex) const;
/**
* Returns the edge-number defined by two points. If one point is
* not a corner point USHRT_MAX is returned.
*/
inline unsigned short Side (unsigned long ulP0, unsigned long P1) const;
inline unsigned short Side (PointIndex ulP0, PointIndex P1) const;
/**
* Returns the edge-number defined by the shared edge of both facets. If the facets don't
* share a common edge USHRT_MAX is returned.
@@ -284,26 +284,26 @@ public:
* by \a ulNew. If the facet does not have a corner point with this index
* nothing happens.
*/
inline void Transpose (unsigned long ulOrig, unsigned long ulNew);
inline void Transpose (PointIndex ulOrig, PointIndex ulNew);
/**
* Decrement the index for each corner point that is higher than \a ulIndex.
*/
inline void Decrement (unsigned long ulIndex);
inline void Decrement (PointIndex ulIndex);
/**
* Checks if the facets references the given point index.
*/
inline bool HasPoint(unsigned long) const;
inline bool HasPoint(PointIndex) const;
/**
* Replaces the index of the neighbour facet that is equal to \a ulOrig
* by \a ulNew. If the facet does not have a neighbourt with this index
* nothing happens.
*/
inline void ReplaceNeighbour (unsigned long ulOrig, unsigned long ulNew);
inline void ReplaceNeighbour (FacetIndex ulOrig, FacetIndex ulNew);
/**
* Checks if the neighbour exists at the given edge-number.
*/
bool HasNeighbour (unsigned short usSide) const
{ return (_aulNeighbours[usSide] != ULONG_MAX); }
{ return (_aulNeighbours[usSide] != FACET_INDEX_MAX); }
/** Counts the number of edges without neighbour. */
inline unsigned short CountOpenEdges() const;
/** Returns true if there is an edge without neighbour, otherwise false. */
@@ -315,7 +315,7 @@ public:
/** Checks whether the facet is degenerated to a line of point. */
inline bool IsDegenerated() const;
/** Flips the orientation of the facet. */
void FlipNormal (void)
void FlipNormal ()
{
std::swap(_aulPoints[1], _aulPoints[2]);
std::swap(_aulNeighbours[0], _aulNeighbours[2]);
@@ -324,8 +324,8 @@ public:
public:
unsigned char _ucFlag; /**< Flag member. */
unsigned long _ulProp; /**< Free usable property. */
unsigned long _aulPoints[3]; /**< Indices of corner points. */
unsigned long _aulNeighbours[3]; /**< Indices of neighbour facets. */
PointIndex _aulPoints[3]; /**< Indices of corner points. */
FacetIndex _aulNeighbours[3]; /**< Indices of neighbour facets. */
};
/**
@@ -338,11 +338,11 @@ public:
/** @name Construction */
//@{
/// default constructor
MeshGeomFacet (void);
MeshGeomFacet ();
/// Constructor with the corner points
MeshGeomFacet (const Base::Vector3f &v1,const Base::Vector3f &v2,const Base::Vector3f &v3);
/// Destruction
~MeshGeomFacet (void) { }
~MeshGeomFacet () { }
//@}
public:
@@ -403,7 +403,7 @@ public:
/**
* Calculates the facet normal for storing internally.
*/
inline void CalcNormal (void);
inline void CalcNormal ();
/**
* Arrange the facet normal so the both vectors have the same orientation.
*/
@@ -411,9 +411,9 @@ public:
/**
* Adjusts the facet's orientation to its normal.
*/
inline void AdjustCirculationDirection (void);
inline void AdjustCirculationDirection ();
/** Invalidate the normal. It will be recomputed when querying it. */
void NormalInvalid (void) { _bNormalCalculated = false; }
void NormalInvalid () { _bNormalCalculated = false; }
/** Query the flag state of the facet. */
bool IsFlag (MeshFacet::TFlagType tF) const
{ return (_ucFlag & static_cast<unsigned char>(tF)) == static_cast<unsigned char>(tF); }
@@ -424,13 +424,13 @@ public:
void ResetFlag (MeshFacet::TFlagType tF)
{ _ucFlag &= ~static_cast<unsigned char>(tF); }
/** Calculates the facet's gravity point. */
inline Base::Vector3f GetGravityPoint (void) const;
inline Base::Vector3f GetGravityPoint () const;
/** Returns the normal of the facet. */
inline Base::Vector3f GetNormal (void) const;
inline Base::Vector3f GetNormal () const;
/** Sets the facet's normal. */
inline void SetNormal (const Base::Vector3f &rclNormal);
/** Returns the wrapping bounding box. */
inline Base::BoundBox3f GetBoundBox (void) const;
inline Base::BoundBox3f GetBoundBox () const;
/** Calculates the perimeter of the facet. */
inline float Perimeter() const;
/** Calculates the area of a facet. */
@@ -545,13 +545,13 @@ public:
/** @name Construction */
//@{
// constructor
MeshPointArray (void) { }
MeshPointArray () { }
// constructor
MeshPointArray (unsigned long ulSize) : TMeshPointArray(ulSize) { }
MeshPointArray (PointIndex ulSize) : TMeshPointArray(ulSize) { }
/// copy-constructor
MeshPointArray (const MeshPointArray&);
// Destructor
~MeshPointArray (void) { }
~MeshPointArray () { }
//@}
/** @name Flag state
@@ -563,7 +563,7 @@ public:
/// Resets the flag for all points
void ResetFlag (MeshPoint::TFlagType tF) const;
/// Sets all points invalid
void ResetInvalid (void) const;
void ResetInvalid () const;
/// Sets the property for all points
void SetProperty (unsigned long ulVal) const;
//@}
@@ -573,15 +573,15 @@ public:
void Transform(const Base::Matrix4D&);
/**
* Searches for the first point index Two points are equal if the distance is less
* than EPSILON. If no such points is found ULONG_MAX is returned.
* than EPSILON. If no such points is found POINT_INDEX_MAX is returned.
*/
unsigned long Get (const MeshPoint &rclPoint);
PointIndex Get (const MeshPoint &rclPoint);
/**
* Searches for the first point index Two points are equal if the distance is less
* than EPSILON. If no such points is found the point is added to the array at end
* and its index is returned.
*/
unsigned long GetOrAddIndex (const MeshPoint &rclPoint);
PointIndex GetOrAddIndex (const MeshPoint &rclPoint);
};
typedef std::vector<MeshFacet> TMeshFacetArray;
@@ -599,13 +599,13 @@ public:
/** @name Construction */
//@{
/// constructor
MeshFacetArray (void) { }
MeshFacetArray () { }
/// constructor
MeshFacetArray (unsigned long ulSize) : TMeshFacetArray(ulSize) { }
MeshFacetArray (FacetIndex ulSize) : TMeshFacetArray(ulSize) { }
/// copy-constructor
MeshFacetArray (const MeshFacetArray&);
/// destructor
~MeshFacetArray (void) { }
~MeshFacetArray () { }
//@}
/** @name Flag state
@@ -618,7 +618,7 @@ public:
/// Resets the flag for all facets.
void ResetFlag (MeshFacet::TFlagType tF) const;
/// Sets all facets invalid
void ResetInvalid (void) const;
void ResetInvalid () const;
/// Sets the property for all facets
void SetProperty (unsigned long ulVal) const;
//@}
@@ -634,11 +634,11 @@ public:
/**
* Checks and flips the point indices if needed. @see MeshFacet::Transpose().
*/
void TransposeIndices (unsigned long ulOrig, unsigned long ulNew);
void TransposeIndices (PointIndex ulOrig, PointIndex ulNew);
/**
* Decrements all point indices that are higher than \a ulIndex.
*/
void DecrementIndices (unsigned long ulIndex);
void DecrementIndices (PointIndex ulIndex);
};
/**
@@ -684,7 +684,7 @@ public:
* that is equal to \a old by \a now. If the facet does not have a corner
* point with this index nothing happens.
*/
void Transpose(unsigned long pos, unsigned long old, unsigned long now)
void Transpose(PointIndex pos, PointIndex old, PointIndex now)
{
rFacets[pos].Transpose(old, now);
}
@@ -765,14 +765,14 @@ inline float MeshGeomFacet::DistancePlaneToPoint (const Base::Vector3f &rclPoint
return float(fabs(rclPoint.DistanceToPlane(_aclPoints[0], GetNormal())));
}
inline void MeshGeomFacet::CalcNormal (void)
inline void MeshGeomFacet::CalcNormal ()
{
_clNormal = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]);
_clNormal.Normalize();
_bNormalCalculated = true;
}
inline Base::Vector3f MeshGeomFacet::GetNormal (void) const
inline Base::Vector3f MeshGeomFacet::GetNormal () const
{
if (_bNormalCalculated == false)
const_cast<MeshGeomFacet*>(this)->CalcNormal();
@@ -795,19 +795,19 @@ inline void MeshGeomFacet::ArrangeNormal (const Base::Vector3f &rclN)
_clNormal = -_clNormal;
}
inline Base::Vector3f MeshGeomFacet::GetGravityPoint (void) const
inline Base::Vector3f MeshGeomFacet::GetGravityPoint () const
{
return (1.0f / 3.0f) * (_aclPoints[0] + _aclPoints[1] + _aclPoints[2]);
}
inline void MeshGeomFacet::AdjustCirculationDirection (void)
inline void MeshGeomFacet::AdjustCirculationDirection ()
{
Base::Vector3f clN = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]);
if ((clN * _clNormal) < 0.0f)
std::swap(_aclPoints[1], _aclPoints[2]);
}
inline Base::BoundBox3f MeshGeomFacet::GetBoundBox (void) const
inline Base::BoundBox3f MeshGeomFacet::GetBoundBox () const
{
return Base::BoundBox3f(_aclPoints, 3);
}
@@ -857,12 +857,12 @@ inline bool MeshGeomFacet::IntersectWithPlane (const Base::Vector3f &rclBase, co
(bD0 == (_aclPoints[2].DistanceToPlane(rclBase, rclNormal) > 0.0f)));
}
inline MeshFacet::MeshFacet (void)
inline MeshFacet::MeshFacet ()
: _ucFlag(0),
_ulProp(0)
{
memset(_aulNeighbours, 0xff, sizeof(unsigned long) * 3);
memset(_aulPoints, 0xff, sizeof(unsigned long) * 3);
memset(_aulNeighbours, 0xff, sizeof(FacetIndex) * 3);
memset(_aulPoints, 0xff, sizeof(PointIndex) * 3);
}
inline MeshFacet::MeshFacet(const MeshFacet &rclF)
@@ -878,8 +878,8 @@ inline MeshFacet::MeshFacet(const MeshFacet &rclF)
_aulNeighbours[2] = rclF._aulNeighbours[2];
}
inline MeshFacet::MeshFacet(unsigned long p1,unsigned long p2,unsigned long p3,
unsigned long n1,unsigned long n2,unsigned long n3)
inline MeshFacet::MeshFacet(PointIndex p1,PointIndex p2,PointIndex p3,
FacetIndex n1,FacetIndex n2,FacetIndex n3)
: _ucFlag(0),
_ulProp(0)
{
@@ -908,14 +908,14 @@ inline MeshFacet& MeshFacet::operator = (const MeshFacet &rclF)
return *this;
}
void MeshFacet::SetVertices(unsigned long p1,unsigned long p2,unsigned long p3)
void MeshFacet::SetVertices(PointIndex p1,PointIndex p2,PointIndex p3)
{
_aulPoints[0] = p1;
_aulPoints[1] = p2;
_aulPoints[2] = p3;
}
void MeshFacet::SetNeighbours(unsigned long n1,unsigned long n2,unsigned long n3)
void MeshFacet::SetNeighbours(FacetIndex n1,FacetIndex n2,FacetIndex n3)
{
_aulNeighbours[0] = n1;
_aulNeighbours[1] = n2;
@@ -928,12 +928,12 @@ inline void MeshFacet::GetEdge (unsigned short usSide, MeshHelpEdge &rclEdge) co
rclEdge._ulIndex[1] = _aulPoints[(usSide+1) % 3];
}
inline std::pair<unsigned long, unsigned long> MeshFacet::GetEdge (unsigned short usSide) const
inline std::pair<PointIndex, PointIndex> MeshFacet::GetEdge (unsigned short usSide) const
{
return std::pair<unsigned long, unsigned long>(_aulPoints[usSide], _aulPoints[(usSide+1)%3]);
return std::pair<PointIndex, PointIndex>(_aulPoints[usSide], _aulPoints[(usSide+1)%3]);
}
inline void MeshFacet::Transpose (unsigned long ulOrig, unsigned long ulNew)
inline void MeshFacet::Transpose (PointIndex ulOrig, PointIndex ulNew)
{
if (_aulPoints[0] == ulOrig)
_aulPoints[0] = ulNew;
@@ -943,14 +943,14 @@ inline void MeshFacet::Transpose (unsigned long ulOrig, unsigned long ulNew)
_aulPoints[2] = ulNew;
}
inline void MeshFacet::Decrement (unsigned long ulIndex)
inline void MeshFacet::Decrement (PointIndex ulIndex)
{
if (_aulPoints[0] > ulIndex) _aulPoints[0]--;
if (_aulPoints[1] > ulIndex) _aulPoints[1]--;
if (_aulPoints[2] > ulIndex) _aulPoints[2]--;
}
inline bool MeshFacet::HasPoint(unsigned long ulIndex) const
inline bool MeshFacet::HasPoint(PointIndex ulIndex) const
{
if (_aulPoints[0] == ulIndex)
return true;
@@ -961,7 +961,7 @@ inline bool MeshFacet::HasPoint(unsigned long ulIndex) const
return false;
}
inline void MeshFacet::ReplaceNeighbour (unsigned long ulOrig, unsigned long ulNew)
inline void MeshFacet::ReplaceNeighbour (FacetIndex ulOrig, FacetIndex ulNew)
{
if (_aulNeighbours[0] == ulOrig)
_aulNeighbours[0] = ulNew;
@@ -1011,7 +1011,7 @@ inline bool MeshFacet::IsDegenerated() const
return false;
}
inline unsigned short MeshFacet::Side (unsigned long ulNIndex) const
inline unsigned short MeshFacet::Side (FacetIndex ulNIndex) const
{
if (_aulNeighbours[0] == ulNIndex)
return 0;
@@ -1023,7 +1023,7 @@ inline unsigned short MeshFacet::Side (unsigned long ulNIndex) const
return USHRT_MAX;
}
inline unsigned short MeshFacet::Side (unsigned long ulP0, unsigned long ulP1) const
inline unsigned short MeshFacet::Side (PointIndex ulP0, PointIndex ulP1) const
{
if (_aulPoints[0] == ulP0) {
if (_aulPoints[1] == ulP1)
+75 -74
View File
@@ -52,7 +52,7 @@ MeshOrientationVisitor::MeshOrientationVisitor() : _nonuniformOrientation(false)
}
bool MeshOrientationVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long ulLevel)
FacetIndex ulFInd, unsigned long ulLevel)
{
(void)ulFInd;
(void)ulLevel;
@@ -69,13 +69,13 @@ bool MeshOrientationVisitor::HasNonUnifomOrientedFacets() const
return _nonuniformOrientation;
}
MeshOrientationCollector::MeshOrientationCollector(std::vector<unsigned long>& aulIndices, std::vector<unsigned long>& aulComplement)
MeshOrientationCollector::MeshOrientationCollector(std::vector<FacetIndex>& aulIndices, std::vector<FacetIndex>& aulComplement)
: _aulIndices(aulIndices), _aulComplement(aulComplement)
{
}
bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long ulLevel)
FacetIndex ulFInd, unsigned long ulLevel)
{
(void)ulLevel;
// different orientation of rclFacet and rclFrom
@@ -104,13 +104,13 @@ bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet
return true;
}
MeshSameOrientationCollector::MeshSameOrientationCollector(std::vector<unsigned long>& aulIndices)
MeshSameOrientationCollector::MeshSameOrientationCollector(std::vector<FacetIndex>& aulIndices)
: _aulIndices(aulIndices)
{
}
bool MeshSameOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long ulLevel)
FacetIndex ulFInd, unsigned long ulLevel)
{
// different orientation of rclFacet and rclFrom
(void)ulLevel;
@@ -139,7 +139,7 @@ bool MeshEvalOrientation::Evaluate ()
MeshFacetArray::_TConstIterator iEnd = rFAry.end();
for (MeshFacetArray::_TConstIterator it = iBeg; it != iEnd; ++it) {
for (int i = 0; i < 3; i++) {
if (it->_aulNeighbours[i] != ULONG_MAX) {
if (it->_aulNeighbours[i] != FACET_INDEX_MAX) {
const MeshFacet& rclFacet = iBeg[it->_aulNeighbours[i]];
for (int j = 0; j < 3; j++) {
if (it->_aulPoints[i] == rclFacet._aulPoints[j]) {
@@ -156,7 +156,7 @@ bool MeshEvalOrientation::Evaluate ()
return true;
}
unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned long>& inds) const
unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<FacetIndex>& inds) const
{
// All faces with wrong orientation (i.e. adjacent faces with a normal flip and their neighbours)
// build a segment and are marked as TMP0. Now we check all border faces of the segments with
@@ -166,10 +166,10 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned
// algorithm fail to detect the faces with wrong orientation.
const MeshFacetArray& rFAry = _rclMesh.GetFacets();
MeshFacetArray::_TConstIterator iBeg = rFAry.begin();
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
const MeshFacet& f = iBeg[*it];
for (int i = 0; i < 3; i++) {
if (f._aulNeighbours[i] != ULONG_MAX) {
if (f._aulNeighbours[i] != FACET_INDEX_MAX) {
const MeshFacet& n = iBeg[f._aulNeighbours[i]];
if (f.IsFlag(MeshFacet::TMP0) && !n.IsFlag(MeshFacet::TMP0)) {
for (int j = 0; j < 3; j++) {
@@ -183,15 +183,15 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned
}
}
return ULONG_MAX;
return FACET_INDEX_MAX;
}
std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
std::vector<FacetIndex> MeshEvalOrientation::GetIndices() const
{
unsigned long ulStartFacet, ulVisited;
FacetIndex ulStartFacet, ulVisited;
if (_rclMesh.CountFacets() == 0)
return std::vector<unsigned long>();
return std::vector<FacetIndex>();
// reset VISIT flags
MeshAlgorithm cAlg(_rclMesh);
@@ -205,10 +205,10 @@ std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
ulStartFacet = 0;
std::vector<unsigned long> uIndices, uComplement;
std::vector<FacetIndex> uIndices, uComplement;
MeshOrientationCollector clHarmonizer(uIndices, uComplement);
while (ulStartFacet != ULONG_MAX) {
while (ulStartFacet != FACET_INDEX_MAX) {
unsigned long wrongFacets = uIndices.size();
uComplement.clear();
@@ -234,7 +234,7 @@ std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
if (iTri < iEnd)
ulStartFacet = iTri - iBeg;
else
ulStartFacet = ULONG_MAX;
ulStartFacet = FACET_INDEX_MAX;
}
// in some very rare cases where we have some strange artifacts in the mesh structure
@@ -242,23 +242,23 @@ std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
cAlg.ResetFacetFlag(MeshFacet::TMP0);
cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0);
ulStartFacet = HasFalsePositives(uIndices);
while (ulStartFacet != ULONG_MAX) {
while (ulStartFacet != FACET_INDEX_MAX) {
cAlg.ResetFacetsFlag(uIndices, MeshFacet::VISIT);
std::vector<unsigned long> falsePos;
std::vector<FacetIndex> falsePos;
MeshSameOrientationCollector coll(falsePos);
_rclMesh.VisitNeighbourFacets(coll, ulStartFacet);
std::sort(uIndices.begin(), uIndices.end());
std::sort(falsePos.begin(), falsePos.end());
std::vector<unsigned long> diff;
std::back_insert_iterator<std::vector<unsigned long> > biit(diff);
std::vector<FacetIndex> diff;
std::back_insert_iterator<std::vector<FacetIndex> > biit(diff);
std::set_difference(uIndices.begin(), uIndices.end(), falsePos.begin(), falsePos.end(), biit);
uIndices = diff;
cAlg.ResetFacetFlag(MeshFacet::TMP0);
cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0);
unsigned long current = ulStartFacet;
FacetIndex current = ulStartFacet;
ulStartFacet = HasFalsePositives(uIndices);
if (current == ulStartFacet)
break; // avoid an endless loop
@@ -312,7 +312,8 @@ namespace MeshCore {
struct Edge_Index
{
unsigned long p0, p1, f;
PointIndex p0, p1;
FacetIndex f;
};
struct Edge_Less
@@ -347,8 +348,8 @@ bool MeshEvalTopology::Evaluate ()
for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) {
for (int i = 0; i < 3; i++) {
Edge_Index item;
item.p0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.f = pI - rclFAry.begin();
edges.push_back(item);
}
@@ -360,12 +361,12 @@ bool MeshEvalTopology::Evaluate ()
std::sort(edges.begin(), edges.end(), Edge_Less());
// search for non-manifold edges
unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX;
PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX;
nonManifoldList.clear();
nonManifoldFacets.clear();
int count = 0;
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
std::vector<Edge_Index>::iterator pE;
for (pE = edges.begin(); pE != edges.end(); ++pE) {
if (p0 == pE->p0 && p1 == pE->p1) {
@@ -391,7 +392,7 @@ bool MeshEvalTopology::Evaluate ()
}
// generate indexed edge list which tangents non-manifolds
void MeshEvalTopology::GetFacetManifolds (std::vector<unsigned long> &raclFacetIndList) const
void MeshEvalTopology::GetFacetManifolds (std::vector<FacetIndex> &raclFacetIndList) const
{
raclFacetIndList.clear();
const MeshFacetArray& rclFAry = _rclMesh.GetFacets();
@@ -399,9 +400,9 @@ void MeshEvalTopology::GetFacetManifolds (std::vector<unsigned long> &raclFacetI
for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) {
for (int i = 0; i < 3; i++) {
unsigned long ulPt0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
std::pair<unsigned long,unsigned long> edge = std::make_pair(ulPt0, ulPt1);
PointIndex ulPt0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
PointIndex ulPt1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
std::pair<PointIndex,PointIndex> edge = std::make_pair(ulPt0, ulPt1);
if (std::find(nonManifoldList.begin(), nonManifoldList.end(), edge) != nonManifoldList.end())
raclFacetIndList.push_back(pI - rclFAry.begin());
@@ -430,11 +431,11 @@ bool MeshFixTopology::Fixup ()
#else
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
deletedFaces.reserve(3 * nonManifoldList.size()); // allocate some memory
std::list<std::vector<unsigned long> >::const_iterator it;
std::list<std::vector<FacetIndex> >::const_iterator it;
for (it = nonManifoldList.begin(); it != nonManifoldList.end(); ++it) {
std::vector<unsigned long> non_mf;
std::vector<FacetIndex> non_mf;
non_mf.reserve(it->size());
for (std::vector<unsigned long>::const_iterator jt = it->begin(); jt != it->end(); ++jt) {
for (std::vector<FacetIndex>::const_iterator jt = it->begin(); jt != it->end(); ++jt) {
// facet is only connected with one edge and there causes a non-manifold
unsigned short numOpenEdges = rFaces[*jt].CountOpenEdges();
if (numOpenEdges == 2)
@@ -474,10 +475,10 @@ bool MeshEvalPointManifolds::Evaluate ()
MeshCore::MeshRefPointToFacets vf_it(_rclMesh);
unsigned long ctPoints = _rclMesh.CountPoints();
for (unsigned long index=0; index < ctPoints; index++) {
for (PointIndex index=0; index < ctPoints; index++) {
// get the local neighbourhood of the point
const std::set<unsigned long>& nf = vf_it[index];
const std::set<unsigned long>& np = vv_it[index];
const std::set<FacetIndex>& nf = vf_it[index];
const std::set<PointIndex>& np = vv_it[index];
std::set<unsigned long>::size_type sp, sf;
sp = np.size();
@@ -487,7 +488,7 @@ bool MeshEvalPointManifolds::Evaluate ()
// for a non-manifold point the number of adjacent points is higher by more than one than the number of shared faces
if (sp > sf + 1) {
nonManifoldPoints.push_back(index);
std::vector<unsigned long> faces;
std::vector<FacetIndex> faces;
faces.insert(faces.end(), nf.begin(), nf.end());
this->facetsOfNonManifoldPoints.push_back(faces);
}
@@ -496,9 +497,9 @@ bool MeshEvalPointManifolds::Evaluate ()
return this->nonManifoldPoints.empty();
}
void MeshEvalPointManifolds::GetFacetIndices (std::vector<unsigned long> &facets) const
void MeshEvalPointManifolds::GetFacetIndices (std::vector<FacetIndex> &facets) const
{
std::list<std::vector<unsigned long> >::const_iterator it;
std::list<std::vector<FacetIndex> >::const_iterator it;
for (it = facetsOfNonManifoldPoints.begin(); it != facetsOfNonManifoldPoints.end(); ++it) {
facets.insert(facets.end(), it->begin(), it->end());
}
@@ -576,11 +577,11 @@ bool MeshEvalSingleFacet::Evaluate ()
bool MeshFixSingleFacet::Fixup ()
{
std::vector<unsigned long> aulInvalids;
std::vector<FacetIndex> aulInvalids;
// MeshFacetArray& raFacets = _rclMesh._aclFacetArray;
for ( std::vector<std::list<unsigned long> >::const_iterator it=_raclManifoldList.begin();it!=_raclManifoldList.end();++it )
for ( std::vector<std::list<FacetIndex> >::const_iterator it=_raclManifoldList.begin();it!=_raclManifoldList.end();++it )
{
for ( std::list<unsigned long>::const_iterator it2 = it->begin(); it2 != it->end(); ++it2 )
for ( std::list<FacetIndex>::const_iterator it2 = it->begin(); it2 != it->end(); ++it2 )
{
aulInvalids.push_back(*it2);
// MeshFacet& rF = raFacets[*it2];
@@ -614,7 +615,7 @@ bool MeshEvalSelfIntersection::Evaluate ()
Base::SequencerLauncher seq("Checking for self-intersections...", ulGridX*ulGridY*ulGridZ);
for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) {
//Get the facet indices, belonging to the current grid unit
std::vector<unsigned long> aulGridElements;
std::vector<FacetIndex> aulGridElements;
clGridIter.GetElements(aulGridElements);
seq.next();
@@ -623,12 +624,12 @@ bool MeshEvalSelfIntersection::Evaluate ()
MeshGeomFacet facet1, facet2;
Base::Vector3f pt1, pt2;
for (std::vector<unsigned long>::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) {
for (std::vector<FacetIndex>::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) {
const Base::BoundBox3f& box1 = boxes[*it];
cMFI.Set(*it);
facet1 = *cMFI;
const MeshFacet& rface1 = rFaces[*it];
for (std::vector<unsigned long>::iterator jt = it; jt != aulGridElements.end(); ++jt) {
for (std::vector<FacetIndex>::iterator jt = it; jt != aulGridElements.end(); ++jt) {
if (jt == it) // the identical facet
continue;
// If the facets share a common vertex we do not check for self-intersections because they
@@ -665,7 +666,7 @@ bool MeshEvalSelfIntersection::Evaluate ()
return true;
}
void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsigned long, unsigned long> >& indices,
void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<FacetIndex, FacetIndex> >& indices,
std::vector<std::pair<Base::Vector3f, Base::Vector3f> >& intersection) const
{
intersection.reserve(indices.size());
@@ -673,7 +674,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsi
MeshFacetIterator cMF2(_rclMesh);
Base::Vector3f pt1, pt2;
std::vector<std::pair<unsigned long, unsigned long> >::const_iterator it;
std::vector<std::pair<FacetIndex, FacetIndex> >::const_iterator it;
for (it = indices.begin(); it != indices.end(); ++it) {
cMF1.Set(it->first);
cMF2.Set(it->second);
@@ -689,7 +690,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsi
}
}
void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned long, unsigned long> >& intersection) const
void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<FacetIndex, FacetIndex> >& intersection) const
{
// Contains bounding boxes for every facet
std::vector<Base::BoundBox3f> boxes;
@@ -711,7 +712,7 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned l
Base::SequencerLauncher seq("Checking for self-intersections...", ulGridX*ulGridY*ulGridZ);
for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) {
//Get the facet indices, belonging to the current grid unit
std::vector<unsigned long> aulGridElements;
std::vector<FacetIndex> aulGridElements;
clGridIter.GetElements(aulGridElements);
seq.next(true);
@@ -720,12 +721,12 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned l
MeshGeomFacet facet1, facet2;
Base::Vector3f pt1, pt2;
for (std::vector<unsigned long>::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) {
for (std::vector<FacetIndex>::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) {
const Base::BoundBox3f& box1 = boxes[*it];
cMFI.Set(*it);
facet1 = *cMFI;
const MeshFacet& rface1 = rFaces[*it];
for (std::vector<unsigned long>::iterator jt = it; jt != aulGridElements.end(); ++jt) {
for (std::vector<FacetIndex>::iterator jt = it; jt != aulGridElements.end(); ++jt) {
if (jt == it) // the identical facet
continue;
// If the facets share a common vertex we do not check for self-intersections because they
@@ -759,11 +760,11 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned l
}
}
std::vector<unsigned long> MeshFixSelfIntersection::GetFacets() const
std::vector<FacetIndex> MeshFixSelfIntersection::GetFacets() const
{
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
for (std::vector<std::pair<unsigned long, unsigned long> >::const_iterator
for (std::vector<std::pair<FacetIndex, FacetIndex> >::const_iterator
it = selfIntersectons.begin(); it != selfIntersectons.end(); ++it) {
unsigned short numOpenEdges1 = rFaces[it->first].CountOpenEdges();
unsigned short numOpenEdges2 = rFaces[it->second].CountOpenEdges();
@@ -819,8 +820,8 @@ bool MeshEvalNeighbourhood::Evaluate ()
for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) {
for (int i = 0; i < 3; i++) {
Edge_Index item;
item.p0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.f = pI - rclFAry.begin();
edges.push_back(item);
}
@@ -831,8 +832,8 @@ bool MeshEvalNeighbourhood::Evaluate ()
// sort the edges
std::sort(edges.begin(), edges.end(), Edge_Less());
unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX;
unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX;
PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX;
PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX;
int count = 0;
std::vector<Edge_Index>::iterator pE;
for (pE = edges.begin(); pE != edges.end(); ++pE) {
@@ -858,7 +859,7 @@ bool MeshEvalNeighbourhood::Evaluate ()
const MeshFacet& rFace = rclFAry[f0];
unsigned short side = rFace.Side(p0,p1);
// should be "open edge" but isn't marked as such
if (rFace._aulNeighbours[side] != ULONG_MAX)
if (rFace._aulNeighbours[side] != FACET_INDEX_MAX)
return false;
}
@@ -872,9 +873,9 @@ bool MeshEvalNeighbourhood::Evaluate ()
return true;
}
std::vector<unsigned long> MeshEvalNeighbourhood::GetIndices() const
std::vector<FacetIndex> MeshEvalNeighbourhood::GetIndices() const
{
std::vector<unsigned long> inds;
std::vector<FacetIndex> inds;
const MeshFacetArray& rclFAry = _rclMesh.GetFacets();
std::vector<Edge_Index> edges;
edges.reserve(3*rclFAry.size());
@@ -885,8 +886,8 @@ std::vector<unsigned long> MeshEvalNeighbourhood::GetIndices() const
for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) {
for (int i = 0; i < 3; i++) {
Edge_Index item;
item.p0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.f = pI - rclFAry.begin();
edges.push_back(item);
}
@@ -897,8 +898,8 @@ std::vector<unsigned long> MeshEvalNeighbourhood::GetIndices() const
// sort the edges
std::sort(edges.begin(), edges.end(), Edge_Less());
unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX;
unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX;
PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX;
PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX;
int count = 0;
std::vector<Edge_Index>::iterator pE;
for (pE = edges.begin(); pE != edges.end(); ++pE) {
@@ -926,7 +927,7 @@ std::vector<unsigned long> MeshEvalNeighbourhood::GetIndices() const
const MeshFacet& rFace = rclFAry[f0];
unsigned short side = rFace.Side(p0,p1);
// should be "open edge" but isn't marked as such
if (rFace._aulNeighbours[side] != ULONG_MAX)
if (rFace._aulNeighbours[side] != FACET_INDEX_MAX)
inds.push_back(f0);
}
@@ -950,7 +951,7 @@ bool MeshFixNeighbourhood::Fixup()
return true;
}
void MeshKernel::RebuildNeighbours (unsigned long index)
void MeshKernel::RebuildNeighbours (FacetIndex index)
{
std::vector<Edge_Index> edges;
edges.reserve(3 * (this->_aclFacetArray.size() - index));
@@ -961,8 +962,8 @@ void MeshKernel::RebuildNeighbours (unsigned long index)
for (pI = pB + index; pI != this->_aclFacetArray.end(); ++pI) {
for (int i = 0; i < 3; i++) {
Edge_Index item;
item.p0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.p1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
item.f = pI - pB;
edges.push_back(item);
}
@@ -973,8 +974,8 @@ void MeshKernel::RebuildNeighbours (unsigned long index)
int threads = std::max(1, QThread::idealThreadCount());
MeshCore::parallel_sort(edges.begin(), edges.end(), Edge_Less(), threads);
unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX;
unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX;
PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX;
PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX;
int count = 0;
std::vector<Edge_Index>::iterator pE;
for (pE = edges.begin(); pE != edges.end(); ++pE) {
@@ -996,7 +997,7 @@ void MeshKernel::RebuildNeighbours (unsigned long index)
else if (count == 1) {
MeshFacet& rFace = this->_aclFacetArray[f0];
unsigned short side = rFace.Side(p0,p1);
rFace._aulNeighbours[side] = ULONG_MAX;
rFace._aulNeighbours[side] = FACET_INDEX_MAX;
}
p0 = pE->p0;
@@ -1019,11 +1020,11 @@ void MeshKernel::RebuildNeighbours (unsigned long index)
else if (count == 1) {
MeshFacet& rFace = this->_aclFacetArray[f0];
unsigned short side = rFace.Side(p0,p1);
rFace._aulNeighbours[side] = ULONG_MAX;
rFace._aulNeighbours[side] = FACET_INDEX_MAX;
}
}
void MeshKernel::RebuildNeighbours (void)
void MeshKernel::RebuildNeighbours ()
{
// complete rebuild
RebuildNeighbours(0);
+33 -33
View File
@@ -95,7 +95,7 @@ public:
MeshOrientationVisitor();
/** Returns false after the first inconsistence is found, true otherwise. */
bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long );
bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long );
bool HasNonUnifomOrientedFacets() const;
private:
@@ -110,15 +110,15 @@ private:
class MeshExport MeshOrientationCollector : public MeshOrientationVisitor
{
public:
MeshOrientationCollector(std::vector<unsigned long>& aulIndices,
std::vector<unsigned long>& aulComplement);
MeshOrientationCollector(std::vector<FacetIndex>& aulIndices,
std::vector<FacetIndex>& aulComplement);
/** Returns always true and collects the indices with wrong orientation. */
bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long);
bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long);
private:
std::vector<unsigned long>& _aulIndices;
std::vector<unsigned long>& _aulComplement;
std::vector<FacetIndex>& _aulIndices;
std::vector<FacetIndex>& _aulComplement;
};
/**
@@ -127,12 +127,12 @@ private:
class MeshExport MeshSameOrientationCollector : public MeshOrientationVisitor
{
public:
MeshSameOrientationCollector(std::vector<unsigned long>& aulIndices);
MeshSameOrientationCollector(std::vector<FacetIndex>& aulIndices);
/** Returns always true and collects the indices with wrong orientation. */
bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long);
bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long);
private:
std::vector<unsigned long>& _aulIndices;
std::vector<FacetIndex>& _aulIndices;
};
/**
@@ -145,10 +145,10 @@ public:
MeshEvalOrientation (const MeshKernel& rclM);
~MeshEvalOrientation();
bool Evaluate ();
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
private:
unsigned long HasFalsePositives(const std::vector<unsigned long>&) const;
unsigned long HasFalsePositives(const std::vector<FacetIndex>&) const;
};
/**
@@ -192,14 +192,14 @@ public:
virtual ~MeshEvalTopology () {}
virtual bool Evaluate ();
void GetFacetManifolds (std::vector<unsigned long> &raclFacetIndList) const;
void GetFacetManifolds (std::vector<FacetIndex> &raclFacetIndList) const;
unsigned long CountManifolds() const;
const std::vector<std::pair<unsigned long, unsigned long> >& GetIndices() const { return nonManifoldList; }
const std::list<std::vector<unsigned long> >& GetFacets() const { return nonManifoldFacets; }
const std::vector<std::pair<FacetIndex, FacetIndex> >& GetIndices() const { return nonManifoldList; }
const std::list<std::vector<FacetIndex> >& GetFacets() const { return nonManifoldFacets; }
protected:
std::vector<std::pair<unsigned long, unsigned long> > nonManifoldList;
std::list<std::vector<unsigned long> > nonManifoldFacets;
std::vector<std::pair<FacetIndex, FacetIndex> > nonManifoldList;
std::list<std::vector<FacetIndex> > nonManifoldFacets;
};
/**
@@ -209,16 +209,16 @@ protected:
class MeshExport MeshFixTopology : public MeshValidation
{
public:
MeshFixTopology (MeshKernel &rclB, const std::list<std::vector<unsigned long> >& mf)
MeshFixTopology (MeshKernel &rclB, const std::list<std::vector<FacetIndex> >& mf)
: MeshValidation(rclB), nonManifoldList(mf) {}
virtual ~MeshFixTopology () {}
bool Fixup();
const std::vector<unsigned long>& GetDeletedFaces() const { return deletedFaces; }
const std::vector<FacetIndex>& GetDeletedFaces() const { return deletedFaces; }
protected:
std::vector<unsigned long> deletedFaces;
const std::list<std::vector<unsigned long> >& nonManifoldList;
std::vector<FacetIndex> deletedFaces;
const std::list<std::vector<FacetIndex> >& nonManifoldList;
};
// ----------------------------------------------------
@@ -236,14 +236,14 @@ public:
virtual ~MeshEvalPointManifolds () {}
virtual bool Evaluate ();
void GetFacetIndices (std::vector<unsigned long> &facets) const;
const std::list<std::vector<unsigned long> >& GetFacetIndices () const { return facetsOfNonManifoldPoints; }
const std::vector<unsigned long>& GetIndices() const { return nonManifoldPoints; }
void GetFacetIndices (std::vector<FacetIndex> &facets) const;
const std::list<std::vector<FacetIndex> >& GetFacetIndices () const { return facetsOfNonManifoldPoints; }
const std::vector<FacetIndex>& GetIndices() const { return nonManifoldPoints; }
unsigned long CountManifolds() const { return static_cast<unsigned long>(nonManifoldPoints.size()); }
protected:
std::vector<unsigned long> nonManifoldPoints;
std::list<std::vector<unsigned long> > facetsOfNonManifoldPoints;
std::vector<FacetIndex> nonManifoldPoints;
std::list<std::vector<FacetIndex> > facetsOfNonManifoldPoints;
};
// ----------------------------------------------------
@@ -270,13 +270,13 @@ public:
class MeshExport MeshFixSingleFacet : public MeshValidation
{
public:
MeshFixSingleFacet (MeshKernel &rclB, const std::vector<std::list<unsigned long> >& mf)
MeshFixSingleFacet (MeshKernel &rclB, const std::vector<std::list<FacetIndex> >& mf)
: MeshValidation(rclB), _raclManifoldList(mf) {}
virtual ~MeshFixSingleFacet () {}
bool Fixup();
protected:
const std::vector<std::list<unsigned long> >& _raclManifoldList;
const std::vector<std::list<FacetIndex> >& _raclManifoldList;
};
// ----------------------------------------------------
@@ -293,10 +293,10 @@ public:
/// Evaluate the mesh and return if true if there are self intersections
bool Evaluate ();
/// collect all intersection lines
void GetIntersections(const std::vector<std::pair<unsigned long, unsigned long> >&,
void GetIntersections(const std::vector<std::pair<FacetIndex, FacetIndex> >&,
std::vector<std::pair<Base::Vector3f, Base::Vector3f> >&) const;
/// collect the index of all facets with self intersections
void GetIntersections(std::vector<std::pair<unsigned long, unsigned long> >&) const;
void GetIntersections(std::vector<std::pair<FacetIndex, FacetIndex> >&) const;
};
/**
@@ -306,14 +306,14 @@ public:
class MeshExport MeshFixSelfIntersection : public MeshValidation
{
public:
MeshFixSelfIntersection (MeshKernel &rclB, const std::vector<std::pair<unsigned long, unsigned long> >& si)
MeshFixSelfIntersection (MeshKernel &rclB, const std::vector<std::pair<FacetIndex, FacetIndex> >& si)
: MeshValidation(rclB), selfIntersectons(si) {}
virtual ~MeshFixSelfIntersection () {}
std::vector<unsigned long> GetFacets() const;
std::vector<FacetIndex> GetFacets() const;
bool Fixup();
private:
const std::vector<std::pair<unsigned long, unsigned long> >& selfIntersectons;
const std::vector<std::pair<FacetIndex, FacetIndex> >& selfIntersectons;
};
// ----------------------------------------------------
@@ -329,7 +329,7 @@ public:
MeshEvalNeighbourhood (const MeshKernel &rclB) : MeshEvaluation(rclB) {}
~MeshEvalNeighbourhood () {}
bool Evaluate ();
std::vector<unsigned long> GetIndices() const;
std::vector<FacetIndex> GetIndices() const;
};
/**
+38 -38
View File
@@ -45,8 +45,8 @@ MeshGrid::MeshGrid (const MeshKernel &rclM)
{
}
MeshGrid::MeshGrid (void)
: _pclMesh(NULL),
MeshGrid::MeshGrid ()
: _pclMesh(nullptr),
_ulCtElements(0),
_ulCtGridsX(MESH_CT_GRID), _ulCtGridsY(MESH_CT_GRID), _ulCtGridsZ(MESH_CT_GRID),
_fGridLenX(0.0f), _fGridLenY(0.0f), _fGridLenZ(0.0f),
@@ -60,10 +60,10 @@ void MeshGrid::Attach (const MeshKernel &rclM)
RebuildGrid();
}
void MeshGrid::Clear (void)
void MeshGrid::Clear ()
{
_aulGrid.clear();
_pclMesh = NULL;
_pclMesh = nullptr;
}
void MeshGrid::Rebuild (unsigned long ulX, unsigned long ulY, unsigned long ulZ)
@@ -89,9 +89,9 @@ void MeshGrid::Rebuild (int iCtGridPerAxis)
RebuildGrid();
}
void MeshGrid::InitGrid (void)
void MeshGrid::InitGrid ()
{
assert(_pclMesh != NULL);
assert(_pclMesh != nullptr);
unsigned long i, j;
@@ -138,7 +138,7 @@ void MeshGrid::InitGrid (void)
}
}
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<unsigned long> &raulElements,
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<ElementIndex> &raulElements,
bool bDelDoubles) const
{
unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ;
@@ -170,7 +170,7 @@ unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<unsig
return raulElements.size();
}
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<unsigned long> &raulElements,
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<ElementIndex> &raulElements,
const Base::Vector3f &rclOrg, float fMaxDist, bool bDelDoubles) const
{
unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ;
@@ -205,7 +205,7 @@ unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector<unsig
return raulElements.size();
}
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::set<unsigned long> &raulElements) const
unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::set<ElementIndex> &raulElements) const
{
unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ;
@@ -450,7 +450,7 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis)
}
}
void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set<unsigned long> &raclInd) const
void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set<ElementIndex> &raclInd) const
{
raclInd.clear();
Base::BoundBox3f clBB = GetBoundBox();
@@ -563,7 +563,7 @@ void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set<uns
}
void MeshGrid::GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ,
unsigned long ulDistance, std::set<unsigned long> &raclInd) const
unsigned long ulDistance, std::set<ElementIndex> &raclInd) const
{
int nX1 = std::max<int>(0, int(ulX) - int(ulDistance));
int nY1 = std::max<int>(0, int(ulY) - int(ulDistance));
@@ -643,9 +643,9 @@ void MeshGrid::GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ,
}
unsigned long MeshGrid::GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ,
std::set<unsigned long> &raclInd) const
std::set<ElementIndex> &raclInd) const
{
const std::set<unsigned long> &rclSet = _aulGrid[ulX][ulY][ulZ];
const std::set<ElementIndex> &rclSet = _aulGrid[ulX][ulY][ulZ];
if (rclSet.size() > 0)
{
raclInd.insert(rclSet.begin(), rclSet.end());
@@ -655,7 +655,7 @@ unsigned long MeshGrid::GetElements (unsigned long ulX, unsigned long ulY, unsig
return 0;
}
unsigned long MeshGrid::GetElements(const Base::Vector3f &rclPoint, std::vector<unsigned long>& aulFacets) const
unsigned long MeshGrid::GetElements(const Base::Vector3f &rclPoint, std::vector<ElementIndex>& aulFacets) const
{
unsigned long ulX, ulY, ulZ;
if (!CheckPosition(rclPoint, ulX, ulY, ulZ))
@@ -728,9 +728,9 @@ void MeshFacetGrid::Validate (const MeshKernel &rclMesh)
RebuildGrid();
}
void MeshFacetGrid::Validate (void)
void MeshFacetGrid::Validate ()
{
if (_pclMesh == NULL)
if (_pclMesh == nullptr)
return;
if (_pclMesh->CountFacets() != _ulCtElements)
@@ -748,9 +748,9 @@ bool MeshFacetGrid::Verify() const
MeshFacetIterator cF(*_pclMesh);
for ( it.Init(); it.More(); it.Next() )
{
std::vector<unsigned long> aulElements;
std::vector<ElementIndex> aulElements;
it.GetElements( aulElements );
for ( std::vector<unsigned long>::iterator itF = aulElements.begin(); itF != aulElements.end(); ++itF )
for ( std::vector<ElementIndex>::iterator itF = aulElements.begin(); itF != aulElements.end(); ++itF )
{
cF.Set( *itF );
if ( cF->IntersectBoundingBox( it.GetBoundBox() ) == false )
@@ -761,7 +761,7 @@ bool MeshFacetGrid::Verify() const
return true;
}
void MeshFacetGrid::RebuildGrid (void)
void MeshFacetGrid::RebuildGrid ()
{
_ulCtElements = _pclMesh->CountFacets();
@@ -781,7 +781,7 @@ void MeshFacetGrid::RebuildGrid (void)
unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt) const
{
unsigned long ulFacetInd = ULONG_MAX;
ElementIndex ulFacetInd = ELEMENT_INDEX_MAX;
float fMinDist = FLOAT_MAX;
Base::BoundBox3f clBB = GetBoundBox();
@@ -897,8 +897,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt
unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, float fMaxSearchArea) const
{
std::vector<unsigned long> aulFacets;
unsigned long ulFacetInd = ULONG_MAX;
std::vector<ElementIndex> aulFacets;
ElementIndex ulFacetInd = ELEMENT_INDEX_MAX;
float fMinDist = fMaxSearchArea;
MeshAlgorithm clFTool(*_pclMesh);
@@ -908,7 +908,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt
Inside(clBB, aulFacets, rclPt, fMaxSearchArea, true);
for (std::vector<unsigned long>::const_iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI)
for (std::vector<ElementIndex>::const_iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI)
{
float fDist;
@@ -924,7 +924,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt
void MeshFacetGrid::SearchNearestFacetInHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ,
unsigned long ulDistance, const Base::Vector3f &rclPt,
unsigned long &rulFacetInd, float &rfMinDist) const
ElementIndex &rulFacetInd, float &rfMinDist) const
{
int nX1 = std::max<int>(0, int(ulX) - int(ulDistance));
int nY1 = std::max<int>(0, int(ulY) - int(ulDistance));
@@ -1005,10 +1005,10 @@ void MeshFacetGrid::SearchNearestFacetInHull (unsigned long ulX, unsigned long u
void MeshFacetGrid::SearchNearestFacetInGrid(unsigned long ulX, unsigned long ulY, unsigned long ulZ,
const Base::Vector3f &rclPt, float &rfMinDist,
unsigned long &rulFacetInd) const
ElementIndex &rulFacetInd) const
{
const std::set<unsigned long> &rclSet = _aulGrid[ulX][ulY][ulZ];
for (std::set<unsigned long>::const_iterator pI = rclSet.begin(); pI != rclSet.end(); ++pI)
const std::set<ElementIndex> &rclSet = _aulGrid[ulX][ulY][ulZ];
for (std::set<ElementIndex>::const_iterator pI = rclSet.begin(); pI != rclSet.end(); ++pI)
{
float fDist = _pclMesh->GetFacet(*pI).DistanceToPoint(rclPt);
if (fDist < rfMinDist)
@@ -1027,7 +1027,7 @@ MeshPointGrid::MeshPointGrid (const MeshKernel &rclM)
RebuildGrid();
}
MeshPointGrid::MeshPointGrid (void)
MeshPointGrid::MeshPointGrid ()
: MeshGrid()
{
}
@@ -1053,7 +1053,7 @@ MeshPointGrid::MeshPointGrid (const MeshKernel &rclM, float fGridLen)
std::max<unsigned long>(static_cast<unsigned long>(clBBMesh.LengthZ() / fGridLen), 1));
}
void MeshPointGrid::AddPoint (const MeshPoint &rclPt, unsigned long ulPtIndex, float fEpsilon)
void MeshPointGrid::AddPoint (const MeshPoint &rclPt, ElementIndex ulPtIndex, float fEpsilon)
{
(void)fEpsilon;
unsigned long ulX, ulY, ulZ;
@@ -1070,9 +1070,9 @@ void MeshPointGrid::Validate (const MeshKernel &rclMesh)
RebuildGrid();
}
void MeshPointGrid::Validate (void)
void MeshPointGrid::Validate ()
{
if (_pclMesh == NULL)
if (_pclMesh == nullptr)
return;
if (_pclMesh->CountPoints() != _ulCtElements)
@@ -1090,9 +1090,9 @@ bool MeshPointGrid::Verify() const
MeshPointIterator cP(*_pclMesh);
for ( it.Init(); it.More(); it.Next() )
{
std::vector<unsigned long> aulElements;
std::vector<ElementIndex> aulElements;
it.GetElements( aulElements );
for ( std::vector<unsigned long>::iterator itP = aulElements.begin(); itP != aulElements.end(); ++itP )
for ( std::vector<ElementIndex>::iterator itP = aulElements.begin(); itP != aulElements.end(); ++itP )
{
cP.Set( *itP );
if ( it.GetBoundBox().IsInBox( *cP ) == false )
@@ -1103,7 +1103,7 @@ bool MeshPointGrid::Verify() const
return true;
}
void MeshPointGrid::RebuildGrid (void)
void MeshPointGrid::RebuildGrid ()
{
_ulCtElements = _pclMesh->CountPoints();
@@ -1127,7 +1127,7 @@ void MeshPointGrid::Pos (const Base::Vector3f &rclPoint, unsigned long &rulX, un
rulZ = static_cast<unsigned long>((rclPoint.z - _fMinZ) / _fGridLenZ);
}
unsigned long MeshPointGrid::FindElements (const Base::Vector3f &rclPoint, std::set<unsigned long>& aulElements) const
unsigned long MeshPointGrid::FindElements (const Base::Vector3f &rclPoint, std::set<ElementIndex>& aulElements) const
{
unsigned long ulX, ulY, ulZ;
Pos(rclPoint, ulX, ulY, ulZ);
@@ -1154,7 +1154,7 @@ MeshGridIterator::MeshGridIterator (const MeshGrid &rclG)
}
bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea,
std::vector<unsigned long> &raulElements)
std::vector<ElementIndex> &raulElements)
{
bool ret = InitOnRay (rclPt, rclDir, raulElements);
_fMaxSearchArea = fMaxSearchArea;
@@ -1162,7 +1162,7 @@ bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vecto
}
bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir,
std::vector<unsigned long> &raulElements)
std::vector<ElementIndex> &raulElements)
{
// needed in NextOnRay() to avoid an infinite loop
_cSearchPositions.clear();
@@ -1200,7 +1200,7 @@ bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vecto
return _bValidRay;
}
bool MeshGridIterator::NextOnRay (std::vector<unsigned long> &raulElements)
bool MeshGridIterator::NextOnRay (std::vector<ElementIndex> &raulElements)
{
if (_bValidRay == false)
return false; // nicht initialisiert oder Strahl ausgetreten
+42 -74
View File
@@ -60,12 +60,12 @@ protected:
/// Construction
MeshGrid (const MeshKernel &rclM);
/// Construction
MeshGrid (void);
MeshGrid ();
//@}
public:
/// Destruction
virtual ~MeshGrid (void) { }
virtual ~MeshGrid () { }
public:
/** Attaches the mesh kernel to this grid, an already attached mesh gets detached. The grid gets rebuilt
@@ -81,21 +81,21 @@ public:
/** @name Search */
//@{
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector<unsigned long> &raulElements, bool bDelDoubles = true) const;
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector<ElementIndex> &raulElements, bool bDelDoubles = true) const;
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::set<unsigned long> &raulElementss) const;
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::set<ElementIndex> &raulElementss) const;
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector<unsigned long> &raulElements,
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector<ElementIndex> &raulElements,
const Base::Vector3f &rclOrg, float fMaxDist, bool bDelDoubles = true) const;
/** Searches for the nearest grids that contain elements from a point, the result are grid indices. */
void SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set<unsigned long> &rclInd) const;
void SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set<ElementIndex> &rclInd) const;
//@}
/** @name Getters */
//@{
/** Returns the indices of the elements in the given grid. */
unsigned long GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set<unsigned long> &raclInd) const;
unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector<unsigned long>& aulFacets) const;
unsigned long GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set<ElementIndex> &raclInd) const;
unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector<ElementIndex>& aulFacets) const;
//@}
/** Returns the lengths of the grid elements in x,y and z direction. */
@@ -110,9 +110,9 @@ public:
/** Returns the bounding box of a given grid element. */
inline Base::BoundBox3f GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const;
/** Returns the bounding box of the whole. */
inline Base::BoundBox3f GetBoundBox (void) const;
inline Base::BoundBox3f GetBoundBox () const;
/** Returns an extended bounding box of the mesh object. */
inline Base::BoundBox3f GetMeshBoundBox (void) const;
inline Base::BoundBox3f GetMeshBoundBox () const;
//@}
/** Returns an index for the given grid position. If the specified triple is not a valid grid position ULONG_MAX is returned.
* If the index is valid than its value is between zero and the number of grid elements. For each different grid position
@@ -140,24 +140,24 @@ public:
/** Checks if this is a valid grid position. */
inline bool CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const;
/** Get the indices of all elements lying in the grids around a given grid with distance \a ulDistance. */
void GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set<unsigned long> &raclInd) const;
void GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set<ElementIndex> &raclInd) const;
protected:
/** Initializes the size of the internal structure. */
virtual void InitGrid (void);
virtual void InitGrid ();
/** Deletes the grid structure. */
virtual void Clear (void);
virtual void Clear ();
/** Calculates the grid length dependent on maximum number of grids. */
virtual void CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids);
/** Calculates the grid length dependent on the number of grids per axis. */
virtual void CalculateGridLength (int iCtGridPerAxis);
/** Rebuilds the grid structure. Must be implemented in sub-classes. */
virtual void RebuildGrid (void) = 0;
virtual void RebuildGrid () = 0;
/** Returns the number of stored elements. Must be implemented in sub-classes. */
virtual unsigned long HasElements (void) const = 0;
virtual unsigned long HasElements () const = 0;
protected:
std::vector<std::vector<std::vector<std::set<unsigned long> > > > _aulGrid; /**< Grid data structure. */
std::vector<std::vector<std::vector<std::set<ElementIndex> > > > _aulGrid; /**< Grid data structure. */
const MeshKernel* _pclMesh; /**< The mesh kernel. */
unsigned long _ulCtElements;/**< Number of grid elements for validation issues. */
unsigned long _ulCtGridsX; /**< Number of grid elements in z. */
@@ -186,7 +186,7 @@ public:
/// Construction
MeshFacetGrid (const MeshKernel &rclM);
/// Construction
MeshFacetGrid (void) : MeshGrid() { }
MeshFacetGrid () : MeshGrid() { }
/// Construction
MeshFacetGrid (const MeshKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ);
/// Construction
@@ -194,7 +194,7 @@ public:
/// Construction
MeshFacetGrid (const MeshKernel &rclM, float fGridLen);
/// Destruction
virtual ~MeshFacetGrid (void) { }
virtual ~MeshFacetGrid () { }
//@}
/** @name Search */
@@ -205,17 +205,17 @@ public:
unsigned long SearchNearestFromPoint (const Base::Vector3f &rclPt, float fMaxSearchArea) const;
/** Searches for the nearest facet in a given grid element and returns the facet index and the actual distance. */
void SearchNearestFacetInGrid(unsigned long ulX, unsigned long ulY, unsigned long ulZ, const Base::Vector3f &rclPt,
float &rfMinDist, unsigned long &rulFacetInd) const;
float &rfMinDist, ElementIndex &rulFacetInd) const;
/** Does basically the same as the method above unless that grid neighbours up to the order of \a ulDistance
* are introduced into the search. */
void SearchNearestFacetInHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance,
const Base::Vector3f &rclPt, unsigned long &rulFacetInd, float &rfMinDist) const;
const Base::Vector3f &rclPt, ElementIndex &rulFacetInd, float &rfMinDist) const;
//@}
/** Validates the grid structure and rebuilds it if needed. */
virtual void Validate (const MeshKernel &rclM);
/** Validates the grid structure and rebuilds it if needed. */
virtual void Validate (void);
virtual void Validate ();
/** Verifies the grid structure and returns false if inconsistencies are found. */
virtual bool Verify() const;
@@ -227,12 +227,12 @@ protected:
/** Adds a new facet element to the grid structure. \a rclFacet is the geometric facet and \a ulFacetIndex
* the corresponding index in the mesh kernel. The facet is added to each grid element that intersects
* the facet. */
inline void AddFacet (const MeshGeomFacet &rclFacet, unsigned long ulFacetIndex, float fEpsilon = 0.0f);
inline void AddFacet (const MeshGeomFacet &rclFacet, ElementIndex ulFacetIndex, float fEpsilon = 0.0f);
/** Returns the number of stored elements. */
unsigned long HasElements (void) const
unsigned long HasElements () const
{ return _pclMesh->CountFacets(); }
/** Rebuilds the grid structure. */
virtual void RebuildGrid (void);
virtual void RebuildGrid ();
};
/**
@@ -245,7 +245,7 @@ public:
/** @name Construction */
//@{
/// Construction
MeshPointGrid (void);
MeshPointGrid ();
/// Construction
MeshPointGrid (const MeshKernel &rclM);
/// Construction
@@ -255,29 +255,29 @@ public:
/// Construction
MeshPointGrid (const MeshKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ);
/// Destruction
virtual ~MeshPointGrid (void) {}
virtual ~MeshPointGrid () {}
//@}
/** Finds all points that lie in the same grid as the point \a rclPoint. */
unsigned long FindElements(const Base::Vector3f &rclPoint, std::set<unsigned long>& aulElements) const;
unsigned long FindElements(const Base::Vector3f &rclPoint, std::set<ElementIndex>& aulElements) const;
/** Validates the grid structure and rebuilds it if needed. */
virtual void Validate (const MeshKernel &rclM);
/** Validates the grid structure and rebuilds it if needed. */
virtual void Validate (void);
virtual void Validate ();
/** Verifies the grid structure and returns false if inconsistencies are found. */
virtual bool Verify() const;
protected:
/** Adds a new point element to the grid structure. \a rclPt is the geometric point and \a ulPtIndex
* the corresponding index in the mesh kernel. */
void AddPoint (const MeshPoint &rclPt, unsigned long ulPtIndex, float fEpsilon = 0.0f);
void AddPoint (const MeshPoint &rclPt, ElementIndex ulPtIndex, float fEpsilon = 0.0f);
/** Returns the grid numbers to the given point \a rclPoint. */
void Pos(const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const;
/** Returns the number of stored elements. */
unsigned long HasElements (void) const
unsigned long HasElements () const
{ return _pclMesh->CountPoints(); }
/** Rebuilds the grid structure. */
virtual void RebuildGrid (void);
virtual void RebuildGrid ();
};
/**
@@ -290,10 +290,10 @@ public:
/// Construction
MeshGridIterator (const MeshGrid &rclG);
/** Returns the bounding box of the current grid element. */
Base::BoundBox3f GetBoundBox (void) const
Base::BoundBox3f GetBoundBox () const
{ return _rclGrid.GetBoundBox(_ulX, _ulY, _ulZ); }
/** Returns indices of the elements in the current grid. */
void GetElements (std::vector<unsigned long> &raulElements) const
void GetElements (std::vector<ElementIndex> &raulElements) const
{
raulElements.insert(raulElements.end(), _rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(), _rclGrid._aulGrid[_ulX][_ulY][_ulZ].end());
}
@@ -305,13 +305,13 @@ public:
/** @name Iteration */
//@{
/** Sets the iterator to the first element*/
void Init (void)
void Init ()
{ _ulX = _ulY = _ulZ = 0; }
/** Checks if the iterator has not yet reached the end position. */
bool More (void) const
bool More () const
{ return (_ulZ < _rclGrid._ulCtGridsZ); }
/** Go to the next grid. */
void Next (void)
void Next ()
{
if (++_ulX >= (_rclGrid._ulCtGridsX)) _ulX = 0; else return;
if (++_ulY >= (_rclGrid._ulCtGridsY)) { _ulY = 0; _ulZ++; } else return;
@@ -321,11 +321,11 @@ public:
/** @name Tests with rays */
//@{
/** Searches for facets around the ray. */
bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, std::vector<unsigned long> &raulElements);
bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, std::vector<ElementIndex> &raulElements);
/** Searches for facets around the ray. */
bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, std::vector<unsigned long> &raulElements);
bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, std::vector<ElementIndex> &raulElements);
/** Searches for facets around the ray. */
bool NextOnRay (std::vector<unsigned long> &raulElements);
bool NextOnRay (std::vector<ElementIndex> &raulElements);
//@}
/** Returns the grid number of the current position. */
@@ -372,13 +372,13 @@ inline Base::BoundBox3f MeshGrid::GetBoundBox (unsigned long ulX, unsigned long
return Base::BoundBox3f(fX, fY, fZ, fX + _fGridLenX, fY + _fGridLenY, fZ + _fGridLenZ);
}
inline Base::BoundBox3f MeshGrid::GetBoundBox (void) const
inline Base::BoundBox3f MeshGrid::GetBoundBox () const
{
return Base::BoundBox3f(_fMinX, _fMinY, _fMinZ, _fMinX + (_fGridLenX * float(_ulCtGridsX)),
_fMinY + (_fGridLenY * float(_ulCtGridsY)), _fMinZ + (_fGridLenZ * float(_ulCtGridsZ)));
}
inline Base::BoundBox3f MeshGrid::GetMeshBoundBox (void) const
inline Base::BoundBox3f MeshGrid::GetMeshBoundBox () const
{
Base::BoundBox3f clBBenlarged = _pclMesh->GetBoundBox();
clBBenlarged.Enlarge(MESHGRID_BBOX_EXTENSION);
@@ -434,38 +434,8 @@ inline void MeshFacetGrid::PosWithCheck (const Base::Vector3f &rclPoint, unsigne
assert((rulX < _ulCtGridsX) && (rulY < _ulCtGridsY) && (rulZ < _ulCtGridsZ));
}
inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, unsigned long ulFacetIndex, float /*fEpsilon*/)
inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, ElementIndex ulFacetIndex, float /*fEpsilon*/)
{
#if 0
unsigned long i, ulX, ulY, ulZ, ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2;
ulX1 = ulY1 = ulZ1 = ULONG_MAX;
ulX2 = ulY2 = ulZ2 = 0;
for (i = 0; i < 3; i++)
{
Pos(rclFacet._aclPoints[i], ulX, ulY, ulZ);
_aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex);
ulX1 = RSmin<unsigned long>(ulX1, ulX); ulY1 = RSmin<unsigned long>(ulY1, ulY); ulZ1 = RSmin<unsigned long>(ulZ1, ulZ);
ulX2 = RSmax<unsigned long>(ulX2, ulX); ulY2 = RSmax<unsigned long>(ulY2, ulY); ulZ2 = RSmax<unsigned long>(ulZ2, ulZ);
}
// falls Facet ueber mehrere BB reicht
if ((ulX1 < ulX2) || (ulY1 < ulY2) || (ulZ1 < ulZ2))
{
for (ulX = ulX1; ulX <= ulX2; ulX++)
{
for (ulY = ulY1; ulY <= ulY2; ulY++)
{
for (ulZ = ulZ1; ulZ <= ulZ2; ulZ++)
{
if (CMeshFacetFunc::BBoxContainFacet(GetBoundBox(ulX, ulY, ulZ), rclFacet) == true)
_aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex);
}
}
}
}
#else
unsigned long ulX, ulY, ulZ;
unsigned long ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2;
@@ -510,8 +480,6 @@ inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, unsigned lon
}
else
_aulGrid[ulX1][ulY1][ulZ1].insert(ulFacetIndex);
#endif
}
} // namespace MeshCore
+19 -50
View File
@@ -36,19 +36,19 @@ namespace MeshCore {
*/
struct MeshExport MeshHelpPoint
{
inline void Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt);
inline void Set (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt);
inline bool operator < (const MeshHelpPoint &rclObj) const;
inline bool operator == (const MeshHelpPoint &rclObj) const;
unsigned long Index (void) const
FacetIndex Index () const
{ return _ulInd >> 2; }
unsigned long Corner (void) const
FacetIndex Corner () const
{ return _ulInd & 3; }
MeshPoint _clPt;
unsigned long _ulInd;
MeshPoint _clPt;
FacetIndex _ulInd;
};
/**
@@ -56,7 +56,7 @@ struct MeshExport MeshHelpPoint
*/
struct MeshPointBuilder: public std::vector<MeshHelpPoint>
{
inline void Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt);
inline void Add (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt);
};
/**
@@ -64,14 +64,14 @@ struct MeshPointBuilder: public std::vector<MeshHelpPoint>
*/
struct MeshExport MeshHelpBuilderEdge
{
unsigned long Side (void) const
FacetIndex Side () const
{ return _ulFIndex & 3; }
unsigned long Index (void) const
FacetIndex Index () const
{ return _ulFIndex >> 2; }
inline void Set (unsigned long ulInd1, unsigned long ulInd2,
unsigned long ulSide, unsigned long ulFInd);
inline void Set (PointIndex ulInd1, PointIndex ulInd2,
FacetIndex ulSide, FacetIndex ulFInd);
inline bool operator < (const MeshHelpBuilderEdge &rclObj) const;
@@ -80,8 +80,8 @@ struct MeshExport MeshHelpBuilderEdge
inline bool operator != (const MeshHelpBuilderEdge &rclObj) const;
unsigned long _ulFIndex; // facet index
unsigned long _aulInd[2]; // point index
FacetIndex _ulFIndex; // facet index
PointIndex _aulInd[2]; // point index
};
/**
@@ -90,10 +90,10 @@ struct MeshExport MeshHelpBuilderEdge
struct MeshEdgeBuilder: public std::vector<MeshHelpBuilderEdge>
{
typedef std::vector<MeshHelpBuilderEdge>::iterator _TIterator;
inline void Add (unsigned long ulInd1, unsigned long ulInd2, unsigned long ulSide, unsigned long ulFInd);
inline void Add (PointIndex ulInd1, PointIndex ulInd2, FacetIndex ulSide, FacetIndex ulFInd);
};
inline void MeshHelpPoint::Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt)
inline void MeshHelpPoint::Set (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt)
{
_ulInd = (ulFacet << 2) | ulCorner;
_clPt = rclPt;
@@ -101,21 +101,6 @@ inline void MeshHelpPoint::Set (unsigned long ulCorner, unsigned long ulFacet, c
inline bool MeshHelpPoint::operator < (const MeshHelpPoint &rclObj) const
{
// if (fabs(_clPt.x - rclObj._clPt.x) < MeshDefinitions::_fMinPointDistanceD1)
// {
// if (fabs(_clPt.y - rclObj._clPt.y) < MeshDefinitions::_fMinPointDistanceD1)
// {
// if (fabs(_clPt.z - rclObj._clPt.z) < MeshDefinitions::_fMinPointDistanceD1)
// return false;
// else
// return _clPt.z < rclObj._clPt.z;
// }
// else
// return _clPt.y < rclObj._clPt.y;
// }
// else
// return _clPt.x < rclObj._clPt.x;
if (_clPt.x == rclObj._clPt.x)
{
if (_clPt.y == rclObj._clPt.y)
@@ -130,33 +115,17 @@ inline bool MeshHelpPoint::operator < (const MeshHelpPoint &rclObj) const
inline bool MeshHelpPoint::operator == (const MeshHelpPoint &rclObj) const
{
return Base::DistanceP2(_clPt, rclObj._clPt) < MeshDefinitions::_fMinPointDistanceP2;
/*
if (fabs(_clPt.x - rclObj._clPt.x) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f))
{
if (fabs(_clPt.y - rclObj._clPt.y) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f))
{
if (fabs(_clPt.z - rclObj._clPt.z) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f))
return true;
else
return false;
}
else
return false;
}
else
return false;
*/
}
inline void MeshPointBuilder::Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt)
inline void MeshPointBuilder::Add (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt)
{
MeshHelpPoint clObj;
clObj.Set(ulCorner, ulFacet, rclPt);
push_back(clObj);
}
inline void MeshHelpBuilderEdge::Set ( unsigned long ulInd1, unsigned long ulInd2,
unsigned long ulSide, unsigned long ulFInd)
inline void MeshHelpBuilderEdge::Set (PointIndex ulInd1, PointIndex ulInd2,
FacetIndex ulSide, FacetIndex ulFInd)
{
if (ulInd1 < ulInd2)
{
@@ -190,8 +159,8 @@ inline bool MeshHelpBuilderEdge::operator != (const MeshHelpBuilderEdge &rclObj)
}
inline void MeshEdgeBuilder::Add (unsigned long ulInd1, unsigned long ulInd2,
unsigned long ulSide, unsigned long ulFInd)
inline void MeshEdgeBuilder::Add (PointIndex ulInd1, PointIndex ulInd2,
FacetIndex ulSide, FacetIndex ulFInd)
{
MeshHelpBuilderEdge clObj;
clObj.Set(ulInd1, ulInd2, ulSide, ulFInd);
+6 -10
View File
@@ -52,10 +52,7 @@ std::ostream& MeshInfo::GeneralInformation (std::ostream &rclStream) const
rclStream << "Mesh: ["
<< ulCtFc << " Faces, ";
if (ulCtEd!=ULONG_MAX)
rclStream << ulCtEd << " Edges, ";
else
rclStream << "Cannot determine number of edges, ";
rclStream << ulCtPt << " Points"
<< "]" << std::endl;
@@ -65,12 +62,11 @@ std::ostream& MeshInfo::GeneralInformation (std::ostream &rclStream) const
std::ostream& MeshInfo::DetailedPointInfo (std::ostream& rclStream) const
{
// print points
unsigned long i;
rclStream << _rclMesh.CountPoints() << " Points:" << std::endl;
MeshPointIterator pPIter(_rclMesh), pPEnd(_rclMesh);
pPIter.Begin();
pPEnd.End();
i = 0;
PointIndex i = 0;
rclStream.precision(3);
rclStream.setf(std::ios::fixed | std::ios::showpoint | std::ios::showpos);
@@ -90,7 +86,7 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const
{
// print edges
// get edges from facets
std::map<std::pair<unsigned long, unsigned long>, int > lEdges;
std::map<std::pair<PointIndex, PointIndex>, int > lEdges;
const MeshFacetArray& rFacets = _rclMesh.GetFacets();
MeshFacetArray::_TConstIterator pFIter;
@@ -100,9 +96,9 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const
const MeshFacet& rFacet = *pFIter;
for ( int j=0; j<3; j++ )
{
unsigned long ulPt0 = std::min<unsigned long>(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]);
std::pair<unsigned long, unsigned long> cEdge(ulPt0, ulPt1);
PointIndex ulPt0 = std::min<PointIndex>(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]);
PointIndex ulPt1 = std::max<PointIndex>(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]);
std::pair<PointIndex, PointIndex> cEdge(ulPt0, ulPt1);
lEdges[ cEdge ]++;
}
@@ -111,7 +107,7 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const
// print edges
rclStream << lEdges.size() << " Edges:" << std::endl;
std::map<std::pair<unsigned long, unsigned long>, int >::const_iterator pEIter;
std::map<std::pair<PointIndex, PointIndex>, int >::const_iterator pEIter;
pEIter = lEdges.begin();
rclStream.precision(3);
+2 -2
View File
@@ -37,7 +37,7 @@ class MeshExport MeshInfo
{
public:
MeshInfo (const MeshKernel &rclM);
virtual ~MeshInfo (void) {}
virtual ~MeshInfo () {}
/**
* Writes general information about the mesh structure into the stream.
*/
@@ -82,7 +82,7 @@ protected:
const MeshKernel &_rclMesh; // const reference to mesh data structure
private:
MeshInfo(void); // not accessible default constructor
MeshInfo(); // not accessible default constructor
};
+50 -50
View File
@@ -53,7 +53,7 @@ public:
/// construction
inline MeshFacetIterator (const MeshKernel &rclM);
/// construction
inline MeshFacetIterator (const MeshKernel &rclM, unsigned long ulPos);
inline MeshFacetIterator (const MeshKernel &rclM, FacetIndex ulPos);
/// construction
inline MeshFacetIterator (const MeshFacetIterator &rclI);
//@}
@@ -67,18 +67,18 @@ public:
/** @name Access methods */
//@{
/// Access to the element the iterator points to.
const MeshGeomFacet& operator*(void)
const MeshGeomFacet& operator*()
{ return Dereference(); }
/// Access to the element the iterator points to.
const MeshGeomFacet* operator->(void)
const MeshGeomFacet* operator->()
{ return &Dereference(); }
/// Increments the iterator. It points then to the next element if the
/// end is not reached.
const MeshFacetIterator& operator ++ (void)
const MeshFacetIterator& operator ++ ()
{ ++_clIter; return *this; }
/// Decrements the iterator. It points then to the previous element if the beginning
/// is not reached.
const MeshFacetIterator& operator -- (void)
const MeshFacetIterator& operator -- ()
{ --_clIter; return *this; }
/// Increments the iterator by \a k positions.
const MeshFacetIterator& operator += (int k)
@@ -98,42 +98,42 @@ public:
bool operator == (const MeshFacetIterator &rclI) const
{ return _clIter == rclI._clIter; }
/// Sets the iterator to the beginning of the array.
void Begin (void)
void Begin ()
{ _clIter = _rclFAry.begin(); }
/// Sets the iterator to the end of the array.
void End (void)
void End ()
{ _clIter = _rclFAry.end(); }
/// Returns the current position of the iterator in the array.
unsigned long Position (void) const
FacetIndex Position () const
{ return _clIter - _rclFAry.begin(); }
/// Checks if the end is already reached.
bool EndReached (void) const
bool EndReached () const
{ return !(_clIter < _rclFAry.end()); }
/// Sets the iterator to the beginning of the array.
void Init (void)
void Init ()
{ Begin(); }
/// Checks if the end is not yet reached.
bool More (void) const
bool More () const
{ return !EndReached(); }
/// Increments the iterator.
void Next (void)
void Next ()
{ operator++(); }
/// Sets the iterator to a given position.
inline bool Set (unsigned long ulIndex);
inline bool Set (FacetIndex ulIndex);
/// Returns the topologic facet.
inline MeshFacet GetIndices (void) const
inline MeshFacet GetIndices () const
{ return *_clIter; }
/// Returns the topologic facet.
inline const MeshFacet& GetReference (void) const
inline const MeshFacet& GetReference () const
{ return *_clIter; }
/// Returns iterators pointing to the current facet's neighbours.
inline void GetNeighbours (MeshFacetIterator &rclN0, MeshFacetIterator &rclN1, MeshFacetIterator &rclN2) const;
/// Sets the iterator to the current facet's neighbour of the side \a usN.
inline void SetToNeighbour (unsigned short usN);
/// Returns the property information to the current facet.
inline unsigned long GetProperty (void) const;
inline unsigned long GetProperty () const;
/// Checks if the iterator points to a valid element inside the array.
inline bool IsValid (void) const
inline bool IsValid () const
{ return (_clIter >= _rclFAry.begin()) && (_clIter < _rclFAry.end()); }
//@}
/** @name Flag state
@@ -150,7 +150,7 @@ public:
//@}
protected:
inline const MeshGeomFacet& Dereference (void);
inline const MeshGeomFacet& Dereference ();
protected:
const MeshKernel& _rclMesh;
@@ -176,7 +176,7 @@ public:
/** @name Construction */
//@{
inline MeshPointIterator (const MeshKernel &rclM);
inline MeshPointIterator (const MeshKernel &rclM, unsigned long ulPos);
inline MeshPointIterator (const MeshKernel &rclM, PointIndex ulPos);
inline MeshPointIterator (const MeshPointIterator &rclI);
//@}
@@ -189,18 +189,18 @@ public:
/** @name Access methods */
//@{
/// Access to the element the iterator points to.
const MeshPoint& operator*(void) const
const MeshPoint& operator*() const
{ return Dereference(); }
/// Access to the element the iterator points to.
const MeshPoint* operator->(void) const
const MeshPoint* operator->() const
{ return &Dereference(); }
/// Increments the iterator. It points then to the next element if the
/// end is not reached.
const MeshPointIterator& operator ++ (void)
const MeshPointIterator& operator ++ ()
{ ++_clIter; return *this; }
/// Decrements the iterator. It points then to the previous element if the beginning
/// is not reached.
const MeshPointIterator& operator -- (void)
const MeshPointIterator& operator -- ()
{ --_clIter; return *this; }
/// Assignment.
inline MeshPointIterator& operator = (const MeshPointIterator &rpI);
@@ -214,30 +214,30 @@ public:
bool operator == (const MeshPointIterator &rclI) const
{ return _clIter == rclI._clIter; }
/// Sets the iterator to the beginning of the array.
void Begin (void)
void Begin ()
{ _clIter = _rclPAry.begin(); }
/// Sets the iterator to the end of the array.
void End (void)
void End ()
{ _clIter = _rclPAry.end(); }
/// Returns the current position of the iterator in the array.
unsigned long Position (void) const
PointIndex Position () const
{ return _clIter - _rclPAry.begin(); }
/// Checks if the end is already reached.
bool EndReached (void) const
bool EndReached () const
{ return !(_clIter < _rclPAry.end()); }
/// Sets the iterator to the beginning of the array.
void Init (void)
void Init ()
{ Begin(); }
/// Checks if the end is not yet reached.
bool More (void) const
bool More () const
{ return !EndReached(); }
/// Increments the iterator.
void Next (void)
void Next ()
{ operator++(); }
/// Sets the iterator to a given position.
inline bool Set (unsigned long ulIndex);
inline bool Set (PointIndex ulIndex);
/// Checks if the iterator points to a valid element inside the array.
inline bool IsValid (void) const
inline bool IsValid () const
{ return (_clIter >= _rclPAry.begin()) && (_clIter < _rclPAry.end()); }
//@}
/** @name Flag state
@@ -254,7 +254,7 @@ public:
//@}
protected:
inline const MeshPoint& Dereference (void) const;
inline const MeshPoint& Dereference () const;
protected:
const MeshKernel& _rclMesh;
@@ -274,9 +274,9 @@ public:
inline MeshFastFacetIterator (const MeshKernel &rclM);
virtual ~MeshFastFacetIterator () {}
void Init (void) { _clIter = _rclFAry.begin(); }
inline void Next (void);
bool More (void) { return _clIter != _rclFAry.end(); }
void Init () { _clIter = _rclFAry.begin(); }
inline void Next ();
bool More () { return _clIter != _rclFAry.end(); }
Base::Vector3f _afPoints[3];
@@ -299,9 +299,9 @@ inline MeshFastFacetIterator::MeshFastFacetIterator (const MeshKernel &rclM)
{
}
inline void MeshFastFacetIterator::Next (void)
inline void MeshFastFacetIterator::Next ()
{
const unsigned long *paulPt = _clIter->_aulPoints;
const PointIndex *paulPt = _clIter->_aulPoints;
Base::Vector3f *pfPt = _afPoints;
*(pfPt++) = _rclPAry[*(paulPt++)];
*(pfPt++) = _rclPAry[*(paulPt++)];
@@ -317,7 +317,7 @@ inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM)
{
}
inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM, unsigned long ulPos)
inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM, FacetIndex ulPos)
: _rclMesh(rclM),
_rclFAry(rclM._aclFacetArray),
_rclPAry(rclM._aclPointArray),
@@ -344,10 +344,10 @@ inline void MeshFacetIterator::Transform( const Base::Matrix4D& rclTrf )
_clTrf != tmp ? _bApply = true : _bApply = false;
}
inline const MeshGeomFacet& MeshFacetIterator::Dereference (void)
inline const MeshGeomFacet& MeshFacetIterator::Dereference ()
{
MeshFacet rclF = *_clIter;
const unsigned long *paulPt = &(_clIter->_aulPoints[0]);
const PointIndex *paulPt = &(_clIter->_aulPoints[0]);
Base::Vector3f *pclPt = _clFacet._aclPoints;
*(pclPt++) = _rclPAry[*(paulPt++)];
*(pclPt++) = _rclPAry[*(paulPt++)];
@@ -364,7 +364,7 @@ inline const MeshGeomFacet& MeshFacetIterator::Dereference (void)
return _clFacet;
}
inline bool MeshFacetIterator::Set (unsigned long ulIndex)
inline bool MeshFacetIterator::Set (FacetIndex ulIndex)
{
if (ulIndex < _rclFAry.size())
{
@@ -386,24 +386,24 @@ inline MeshFacetIterator& MeshFacetIterator::operator = (const MeshFacetIterator
return *this;
}
inline unsigned long MeshFacetIterator::GetProperty (void) const
inline unsigned long MeshFacetIterator::GetProperty () const
{
return _clIter->_ulProp;
}
inline void MeshFacetIterator::GetNeighbours (MeshFacetIterator &rclN0, MeshFacetIterator &rclN1, MeshFacetIterator &rclN2) const
{
if (_clIter->_aulNeighbours[0] != ULONG_MAX)
if (_clIter->_aulNeighbours[0] != FACET_INDEX_MAX)
rclN0.Set(_clIter->_aulNeighbours[0]);
else
rclN0.End();
if (_clIter->_aulNeighbours[1] != ULONG_MAX)
if (_clIter->_aulNeighbours[1] != FACET_INDEX_MAX)
rclN1.Set(_clIter->_aulNeighbours[1]);
else
rclN1.End();
if (_clIter->_aulNeighbours[2] != ULONG_MAX)
if (_clIter->_aulNeighbours[2] != FACET_INDEX_MAX)
rclN2.Set(_clIter->_aulNeighbours[2]);
else
rclN2.End();
@@ -411,7 +411,7 @@ inline void MeshFacetIterator::GetNeighbours (MeshFacetIterator &rclN0, MeshFace
inline void MeshFacetIterator::SetToNeighbour (unsigned short usN)
{
if (_clIter->_aulNeighbours[usN] != ULONG_MAX)
if (_clIter->_aulNeighbours[usN] != FACET_INDEX_MAX)
_clIter = _rclFAry.begin() + _clIter->_aulNeighbours[usN];
else
End();
@@ -423,7 +423,7 @@ inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM)
_clIter = _rclPAry.begin();
}
inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM, unsigned long ulPos)
inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM, PointIndex ulPos)
: _rclMesh(rclM), _rclPAry(_rclMesh._aclPointArray), _bApply(false)
{
_clIter = _rclPAry.begin() + ulPos;
@@ -442,7 +442,7 @@ inline void MeshPointIterator::Transform( const Base::Matrix4D& rclTrf )
_clTrf != tmp ? _bApply = true : _bApply = false;
}
inline const MeshPoint& MeshPointIterator::Dereference (void) const
inline const MeshPoint& MeshPointIterator::Dereference () const
{ // We change only the value of the point but not the actual iterator
const_cast<MeshPointIterator*>(this)->_clPoint = *_clIter;
if ( _bApply )
@@ -450,7 +450,7 @@ inline const MeshPoint& MeshPointIterator::Dereference (void) const
return _clPoint;
}
inline bool MeshPointIterator::Set (unsigned long ulIndex)
inline bool MeshPointIterator::Set (PointIndex ulIndex)
{
if (ulIndex < _rclPAry.size())
{
+18 -18
View File
@@ -37,7 +37,7 @@ struct Point3d
{
typedef float value_type;
Point3d(const Base::Vector3f& f, unsigned long i) : p(f), i(i)
Point3d(const Base::Vector3f& f, PointIndex i) : p(f), i(i)
{
}
@@ -71,7 +71,7 @@ struct Point3d
}
Base::Vector3f p;
unsigned long i;
PointIndex i;
};
typedef KDTree::KDTree<3, Point3d> MyKDTree;
@@ -88,7 +88,7 @@ MeshKDTree::MeshKDTree() : d(new Private)
MeshKDTree::MeshKDTree(const std::vector<Base::Vector3f>& points) : d(new Private)
{
unsigned long index=0;
PointIndex index=0;
for (std::vector<Base::Vector3f>::const_iterator it = points.begin(); it != points.end(); ++it) {
d->kd_tree.insert(Point3d(*it, index++));
}
@@ -96,7 +96,7 @@ MeshKDTree::MeshKDTree(const std::vector<Base::Vector3f>& points) : d(new Privat
MeshKDTree::MeshKDTree(const MeshPointArray& points) : d(new Private)
{
unsigned long index=0;
PointIndex index=0;
for (MeshPointArray::_TConstIterator it = points.begin(); it != points.end(); ++it) {
d->kd_tree.insert(Point3d(*it, index++));
}
@@ -109,13 +109,13 @@ MeshKDTree::~MeshKDTree()
void MeshKDTree::AddPoint(Base::Vector3f& point)
{
unsigned long index=d->kd_tree.size();
PointIndex index=d->kd_tree.size();
d->kd_tree.insert(Point3d(point, index));
}
void MeshKDTree::AddPoints(const std::vector<Base::Vector3f>& points)
{
unsigned long index=d->kd_tree.size();
PointIndex index=d->kd_tree.size();
for (std::vector<Base::Vector3f>::const_iterator it = points.begin(); it != points.end(); ++it) {
d->kd_tree.insert(Point3d(*it, index++));
}
@@ -123,7 +123,7 @@ void MeshKDTree::AddPoints(const std::vector<Base::Vector3f>& points)
void MeshKDTree::AddPoints(const MeshPointArray& points)
{
unsigned long index=d->kd_tree.size();
PointIndex index=d->kd_tree.size();
for (MeshPointArray::_TConstIterator it = points.begin(); it != points.end(); ++it) {
d->kd_tree.insert(Point3d(*it, index++));
}
@@ -144,42 +144,42 @@ void MeshKDTree::Optimize()
d->kd_tree.optimize();
}
unsigned long MeshKDTree::FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float& dist) const
PointIndex MeshKDTree::FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float& dist) const
{
std::pair<MyKDTree::const_iterator, MyKDTree::distance_type> it =
d->kd_tree.find_nearest(Point3d(p,0));
if (it.first == d->kd_tree.end())
return ULONG_MAX;
unsigned long index = it.first->i;
return POINT_INDEX_MAX;
PointIndex index = it.first->i;
n = it.first->p;
dist = it.second;
return index;
}
unsigned long MeshKDTree::FindNearest(const Base::Vector3f& p, float max_dist,
Base::Vector3f& n, float& dist) const
PointIndex MeshKDTree::FindNearest(const Base::Vector3f& p, float max_dist,
Base::Vector3f& n, float& dist) const
{
std::pair<MyKDTree::const_iterator, MyKDTree::distance_type> it =
d->kd_tree.find_nearest(Point3d(p,0), max_dist);
if (it.first == d->kd_tree.end())
return ULONG_MAX;
unsigned long index = it.first->i;
return POINT_INDEX_MAX;
PointIndex index = it.first->i;
n = it.first->p;
dist = it.second;
return index;
}
unsigned long MeshKDTree::FindExact(const Base::Vector3f& p) const
PointIndex MeshKDTree::FindExact(const Base::Vector3f& p) const
{
MyKDTree::const_iterator it =
d->kd_tree.find_exact(Point3d(p,0));
if (it == d->kd_tree.end())
return ULONG_MAX;
unsigned long index = it->i;
return POINT_INDEX_MAX;
PointIndex index = it->i;
return index;
}
void MeshKDTree::FindInRange(const Base::Vector3f& p, float range, std::vector<unsigned long>& indices) const
void MeshKDTree::FindInRange(const Base::Vector3f& p, float range, std::vector<PointIndex>& indices) const
{
std::vector<Point3d> v;
d->kd_tree.find_within_range(Point3d(p,0), range, std::back_inserter(v));
+4 -4
View File
@@ -45,11 +45,11 @@ public:
void Clear();
void Optimize();
unsigned long FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float&) const;
unsigned long FindNearest(const Base::Vector3f& p, float max_dist,
PointIndex FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float&) const;
PointIndex FindNearest(const Base::Vector3f& p, float max_dist,
Base::Vector3f& n, float&) const;
unsigned long FindExact(const Base::Vector3f& p) const;
void FindInRange(const Base::Vector3f&, float, std::vector<unsigned long>&) const;
PointIndex FindExact(const Base::Vector3f& p) const;
void FindInRange(const Base::Vector3f&, float, std::vector<PointIndex>&) const;
private:
class Private;
+12 -13
View File
@@ -58,7 +58,7 @@ char *upper(char * string)
int i;
int l;
if (string != NULL) {
if (string != nullptr) {
l = std::strlen(string);
for (i=0; i<l; i++)
string[i] = toupper(string[i]);
@@ -258,8 +258,8 @@ bool MeshInput::LoadSTL (std::istream &rstrIn)
upper(szBuf);
try {
if ((strstr(szBuf, "SOLID") == NULL) && (strstr(szBuf, "FACET") == NULL) && (strstr(szBuf, "NORMAL") == NULL) &&
(strstr(szBuf, "VERTEX") == NULL) && (strstr(szBuf, "ENDFACET") == NULL) && (strstr(szBuf, "ENDLOOP") == NULL)) {
if ((strstr(szBuf, "SOLID") == nullptr) && (strstr(szBuf, "FACET") == nullptr) && (strstr(szBuf, "NORMAL") == nullptr) &&
(strstr(szBuf, "VERTEX") == nullptr) && (strstr(szBuf, "ENDFACET") == nullptr) && (strstr(szBuf, "ENDLOOP") == nullptr)) {
// probably binary STL
buf->pubseekoff(0, std::ios::beg, std::ios::in);
return LoadBinarySTL(rstrIn);
@@ -1578,7 +1578,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn)
}
// read the point indices of the facets
else if (points && line.find("INDEXEDFACESET {") != std::string::npos) {
unsigned long ulPoints[3];
PointIndex ulPoints[3];
facets = true;
unsigned long ulCt = 0;
// Get the next line and check for the index field which might begin
@@ -2062,7 +2062,6 @@ bool MeshOutput::SaveAsciiSTL (std::ostream &rstrOut) const
MeshFacetIterator clIter(_rclMesh), clEnd(_rclMesh);
clIter.Transform(this->_transform);
const MeshGeomFacet *pclFacet;
unsigned long i;
if (!rstrOut || rstrOut.bad() == true || _rclMesh.CountFacets() == 0)
return false;
@@ -2088,7 +2087,7 @@ bool MeshOutput::SaveAsciiSTL (std::ostream &rstrOut) const
rstrOut << " outer loop\n";
// vertices
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
rstrOut << " vertex " << pclFacet->_aclPoints[i].x << " "
<< pclFacet->_aclPoints[i].y << " "
<< pclFacet->_aclPoints[i].z << '\n';
@@ -2305,7 +2304,7 @@ bool MeshOutput::SaveOBJ (std::ostream &out) const
for (std::vector<Group>::const_iterator gt = _groups.begin(); gt != _groups.end(); ++gt) {
out << "g " << Base::Tools::escapedUnicodeFromUtf8(gt->name.c_str()) << '\n';
for (std::vector<unsigned long>::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) {
const MeshFacet& f = rFacets[*it];
if (first || prev != Kd[*it]) {
first = false;
@@ -2326,7 +2325,7 @@ bool MeshOutput::SaveOBJ (std::ostream &out) const
else {
for (std::vector<Group>::const_iterator gt = _groups.begin(); gt != _groups.end(); ++gt) {
out << "g " << Base::Tools::escapedUnicodeFromUtf8(gt->name.c_str()) << '\n';
for (std::vector<unsigned long>::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) {
const MeshFacet& f = rFacets[*it];
out << "f " << f._aulPoints[0]+1 << "//" << *it + 1 << " "
<< f._aulPoints[1]+1 << "//" << *it + 1 << " "
@@ -3473,7 +3472,7 @@ bool MeshOutput::SaveVRML (std::ostream &rstrOut) const
MeshCleanup::MeshCleanup(MeshPointArray& p, MeshFacetArray& f)
: pointArray(p)
, facetArray(f)
, materialArray(0)
, materialArray(nullptr)
{
}
@@ -3553,12 +3552,12 @@ void MeshCleanup::RemoveInvalidPoints()
[flag](const MeshPoint& p) { return flag(p, MeshPoint::INVALID); });
if (countInvalidPoints > 0) {
// generate array of decrements
std::vector<unsigned long> decrements;
std::vector<PointIndex> decrements;
decrements.resize(pointArray.size());
unsigned long decr = 0;
PointIndex decr = 0;
MeshPointArray::_TIterator p_end = pointArray.end();
std::vector<unsigned long>::iterator decr_it = decrements.begin();
std::vector<PointIndex>::iterator decr_it = decrements.begin();
for (MeshPointArray::_TIterator p_it = pointArray.begin(); p_it != p_end; ++p_it, ++decr_it) {
*decr_it = decr;
if (!p_it->IsValid())
@@ -3655,7 +3654,7 @@ void MeshPointFacetAdjacency::SetFacetNeighbourhood()
}
if (!success) {
facet1._aulNeighbours[i] = ULONG_MAX;
facet1._aulNeighbours[i] = FACET_INDEX_MAX;
}
}
}
+1 -1
View File
@@ -79,7 +79,7 @@ struct MeshExport Material
struct MeshExport Group
{
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
std::string name;
};
+100 -102
View File
@@ -47,7 +47,7 @@
using namespace MeshCore;
MeshKernel::MeshKernel (void)
MeshKernel::MeshKernel ()
: _bValid(true)
{
_clBoundBox.SetVoid();
@@ -115,11 +115,10 @@ MeshKernel& MeshKernel::operator += (const MeshGeomFacet &rclSFacet)
void MeshKernel::AddFacet(const MeshGeomFacet &rclSFacet)
{
unsigned long i;
MeshFacet clFacet;
// set corner points
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
_clBoundBox.Add(rclSFacet._aclPoints[i]);
clFacet._aulPoints[i] = _aclPointArray.GetOrAddIndex(rclSFacet._aclPoints[i]);
}
@@ -127,17 +126,17 @@ void MeshKernel::AddFacet(const MeshGeomFacet &rclSFacet)
// adjust orientation to normal
AdjustNormal(clFacet, rclSFacet.GetNormal());
unsigned long ulCt = _aclFacetArray.size();
FacetIndex ulCt = _aclFacetArray.size();
// set neighbourhood
unsigned long ulP0 = clFacet._aulPoints[0];
unsigned long ulP1 = clFacet._aulPoints[1];
unsigned long ulP2 = clFacet._aulPoints[2];
unsigned long ulCC = 0;
PointIndex ulP0 = clFacet._aulPoints[0];
PointIndex ulP1 = clFacet._aulPoints[1];
PointIndex ulP2 = clFacet._aulPoints[2];
FacetIndex ulCC = 0;
for (TMeshFacetArray::iterator pF = _aclFacetArray.begin(); pF != _aclFacetArray.end(); ++pF, ulCC++) {
for (int i=0; i<3;i++) {
unsigned long ulP = pF->_aulPoints[i];
unsigned long ulQ = pF->_aulPoints[(i+1)%3];
PointIndex ulP = pF->_aulPoints[i];
PointIndex ulQ = pF->_aulPoints[(i+1)%3];
if (ulQ == ulP0 && ulP == ulP1) {
clFacet._aulNeighbours[0] = ulCC;
pF->_aulNeighbours[i] = ulCt;
@@ -183,8 +182,8 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
// if the manifold check shouldn't be done then just add all faces
if (!checkManifolds) {
unsigned long countFacets = CountFacets();
unsigned long countValid = rclFAry.size();
FacetIndex countFacets = CountFacets();
FacetIndex countValid = rclFAry.size();
_aclFacetArray.reserve(countFacets + countValid);
// just add all faces now
@@ -197,8 +196,8 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
}
this->_aclPointArray.ResetInvalid();
unsigned long k = CountFacets();
std::map<std::pair<unsigned long, unsigned long>, std::list<unsigned long> > edgeMap;
FacetIndex k = CountFacets();
std::map<std::pair<PointIndex, PointIndex>, std::list<FacetIndex> > edgeMap;
for (std::vector<MeshFacet>::const_iterator pF = rclFAry.begin(); pF != rclFAry.end(); ++pF, k++) {
// reset INVALID flag for all candidates
pF->ResetFlag(MeshFacet::INVALID);
@@ -207,10 +206,10 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
assert( pF->_aulPoints[i] < countPoints );
#endif
this->_aclPointArray[pF->_aulPoints[i]].SetFlag(MeshPoint::INVALID);
unsigned long ulT0 = pF->_aulPoints[i];
unsigned long ulT1 = pF->_aulPoints[(i+1)%3];
unsigned long ulP0 = std::min<unsigned long>(ulT0, ulT1);
unsigned long ulP1 = std::max<unsigned long>(ulT0, ulT1);
PointIndex ulT0 = pF->_aulPoints[i];
PointIndex ulT1 = pF->_aulPoints[(i+1)%3];
PointIndex ulP0 = std::min<PointIndex>(ulT0, ulT1);
PointIndex ulP1 = std::max<PointIndex>(ulT0, ulT1);
edgeMap[std::make_pair(ulP0, ulP1)].push_front(k);
}
}
@@ -224,12 +223,12 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
!this->_aclPointArray[pF->_aulPoints[2]].IsFlag(MeshPoint::INVALID))
continue;
for (int i=0; i<3; i++) {
unsigned long ulT0 = pF->_aulPoints[i];
unsigned long ulT1 = pF->_aulPoints[(i+1)%3];
unsigned long ulP0 = std::min<unsigned long>(ulT0, ulT1);
unsigned long ulP1 = std::max<unsigned long>(ulT0, ulT1);
std::pair<unsigned long, unsigned long> edge = std::make_pair(ulP0, ulP1);
std::map<std::pair<unsigned long, unsigned long>, std::list<unsigned long> >::iterator pI = edgeMap.find(edge);
PointIndex ulT0 = pF->_aulPoints[i];
PointIndex ulT1 = pF->_aulPoints[(i+1)%3];
PointIndex ulP0 = std::min<PointIndex>(ulT0, ulT1);
PointIndex ulP1 = std::max<PointIndex>(ulT0, ulT1);
std::pair<PointIndex, PointIndex> edge = std::make_pair(ulP0, ulP1);
std::map<std::pair<PointIndex, PointIndex>, std::list<FacetIndex> >::iterator pI = edgeMap.find(edge);
// Does the current facet share the same edge?
if (pI != edgeMap.end()) {
pI->second.push_front(k);
@@ -240,17 +239,17 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
this->_aclPointArray.ResetInvalid();
// Now let's see for which edges we might get manifolds, if so we don't add the corresponding candidates
unsigned long countFacets = CountFacets();
std::map<std::pair<unsigned long, unsigned long>, std::list<unsigned long> >::iterator pE;
FacetIndex countFacets = CountFacets();
std::map<std::pair<PointIndex, PointIndex>, std::list<FacetIndex> >::iterator pE;
for (pE = edgeMap.begin(); pE != edgeMap.end(); ++pE)
{
if (pE->second.size() > 2)
{
for (std::list<unsigned long>::iterator it = pE->second.begin(); it != pE->second.end(); ++it)
for (std::list<FacetIndex>::iterator it = pE->second.begin(); it != pE->second.end(); ++it)
{
if (*it >= countFacets) {
// this is a candidate
unsigned long index = *it - countFacets;
FacetIndex index = *it - countFacets;
rclFAry[index].SetFlag(MeshFacet::INVALID);
}
}
@@ -260,12 +259,12 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
// Do not insert directly to the data structure because we should get the correct size of new
// facets, otherwise std::vector reallocates too much memory which can't be freed so easily
MeshIsNotFlag<MeshFacet> flag;
unsigned long countValid = std::count_if(rclFAry.begin(), rclFAry.end(), [flag](const MeshFacet& f) {
FacetIndex countValid = std::count_if(rclFAry.begin(), rclFAry.end(), [flag](const MeshFacet& f) {
return flag(f, MeshFacet::INVALID);
});
_aclFacetArray.reserve( _aclFacetArray.size() + countValid );
// now start inserting the facets to the data structure and set the correct neighbourhood as well
unsigned long startIndex = CountFacets();
FacetIndex startIndex = CountFacets();
for (std::vector<MeshFacet>::const_iterator pF = rclFAry.begin(); pF != rclFAry.end(); ++pF) {
if (!pF->IsFlag(MeshFacet::INVALID)) {
_aclFacetArray.push_back(*pF);
@@ -276,55 +275,55 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet> &rclFAry,
// resolve neighbours
for (pE = edgeMap.begin(); pE != edgeMap.end(); ++pE)
{
unsigned long ulP0 = pE->first.first;
unsigned long ulP1 = pE->first.second;
PointIndex ulP0 = pE->first.first;
PointIndex ulP1 = pE->first.second;
if (pE->second.size() == 1) // border facet
{
unsigned long ulF0 = pE->second.front();
FacetIndex ulF0 = pE->second.front();
if (ulF0 >= countFacets) {
ulF0 -= countFacets;
std::vector<MeshFacet>::const_iterator pF = rclFAry.begin() + ulF0;
if (!pF->IsFlag(MeshFacet::INVALID))
ulF0 = pF->_ulProp;
else
ulF0 = ULONG_MAX;
ulF0 = FACET_INDEX_MAX;
}
if (ulF0 != ULONG_MAX) {
if (ulF0 != FACET_INDEX_MAX) {
unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1);
assert(usSide != USHRT_MAX);
_aclFacetArray[ulF0]._aulNeighbours[usSide] = ULONG_MAX;
_aclFacetArray[ulF0]._aulNeighbours[usSide] = FACET_INDEX_MAX;
}
}
else if (pE->second.size() == 2) // normal facet with neighbour
{
// we must check if both facets are part of the mesh now
unsigned long ulF0 = pE->second.front();
FacetIndex ulF0 = pE->second.front();
if (ulF0 >= countFacets) {
ulF0 -= countFacets;
std::vector<MeshFacet>::const_iterator pF = rclFAry.begin() + ulF0;
if (!pF->IsFlag(MeshFacet::INVALID))
ulF0 = pF->_ulProp;
else
ulF0 = ULONG_MAX;
ulF0 = FACET_INDEX_MAX;
}
unsigned long ulF1 = pE->second.back();
FacetIndex ulF1 = pE->second.back();
if (ulF1 >= countFacets) {
ulF1 -= countFacets;
std::vector<MeshFacet>::const_iterator pF = rclFAry.begin() + ulF1;
if (!pF->IsFlag(MeshFacet::INVALID))
ulF1 = pF->_ulProp;
else
ulF1 = ULONG_MAX;
ulF1 = FACET_INDEX_MAX;
}
if (ulF0 != ULONG_MAX) {
if (ulF0 != FACET_INDEX_MAX) {
unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1);
assert(usSide != USHRT_MAX);
_aclFacetArray[ulF0]._aulNeighbours[usSide] = ulF1;
}
if (ulF1 != ULONG_MAX) {
if (ulF1 != FACET_INDEX_MAX) {
unsigned short usSide = _aclFacetArray[ulF1].Side(ulP0, ulP1);
assert(usSide != USHRT_MAX);
_aclFacetArray[ulF1]._aulNeighbours[usSide] = ulF0;
@@ -360,7 +359,7 @@ void MeshKernel::Merge(const MeshPointArray& rPoints, const MeshFacetArray& rFac
return; // nothing to do
std::vector<unsigned long> increments(rPoints.size());
unsigned long countFacets = this->_aclFacetArray.size();
FacetIndex countFacets = this->_aclFacetArray.size();
// Reserve the additional memory to append the new facets
this->_aclFacetArray.reserve(this->_aclFacetArray.size() + rFaces.size());
@@ -380,7 +379,7 @@ void MeshKernel::Merge(const MeshPointArray& rPoints, const MeshFacetArray& rFac
return v > 0;
});
// Reserve the additional memory to append the new points
unsigned long index = this->_aclPointArray.size();
PointIndex index = this->_aclPointArray.size();
this->_aclPointArray.reserve(this->_aclPointArray.size() + countNewPoints);
// Now we can start inserting the points and adjust the point indices of the faces
@@ -414,7 +413,7 @@ void MeshKernel::Cleanup()
meshCleanup.RemoveInvalids();
}
void MeshKernel::Clear (void)
void MeshKernel::Clear ()
{
_aclPointArray.clear();
_aclFacetArray.clear();
@@ -428,7 +427,7 @@ void MeshKernel::Clear (void)
bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter)
{
unsigned long i, j, ulNFacet, ulInd;
FacetIndex ulNFacet, ulInd;
if (rclIter._clIter >= _aclFacetArray.end())
return false;
@@ -437,12 +436,12 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter)
ulInd = rclIter._clIter - _aclFacetArray.begin();
// invalidate neighbour indices of the neighbour facet to this facet
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
ulNFacet = rclIter._clIter->_aulNeighbours[i];
if (ulNFacet != ULONG_MAX) {
for (j = 0; j < 3; j++) {
if (ulNFacet != FACET_INDEX_MAX) {
for (int j = 0; j < 3; j++) {
if (_aclFacetArray[ulNFacet]._aulNeighbours[j] == ulInd) {
_aclFacetArray[ulNFacet]._aulNeighbours[j] = ULONG_MAX;
_aclFacetArray[ulNFacet]._aulNeighbours[j] = FACET_INDEX_MAX;
break;
}
}
@@ -450,9 +449,9 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter)
}
// erase corner point if needed
for (i = 0; i < 3; i++) {
if ((rclIter._clIter->_aulNeighbours[i] == ULONG_MAX) &&
(rclIter._clIter->_aulNeighbours[(i+1)%3] == ULONG_MAX)) {
for (int i = 0; i < 3; i++) {
if ((rclIter._clIter->_aulNeighbours[i] == FACET_INDEX_MAX) &&
(rclIter._clIter->_aulNeighbours[(i+1)%3] == FACET_INDEX_MAX)) {
// no neighbours, possibly delete point
ErasePoint(rclIter._clIter->_aulPoints[(i+1)%3], ulInd);
}
@@ -464,7 +463,7 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter)
return true;
}
bool MeshKernel::DeleteFacet (unsigned long ulInd)
bool MeshKernel::DeleteFacet (FacetIndex ulInd)
{
if (ulInd >= _aclFacetArray.size())
return false;
@@ -475,7 +474,7 @@ bool MeshKernel::DeleteFacet (unsigned long ulInd)
return DeleteFacet(clIter);
}
void MeshKernel::DeleteFacets (const std::vector<unsigned long> &raulFacets)
void MeshKernel::DeleteFacets (const std::vector<FacetIndex> &raulFacets)
{
_aclPointArray.SetProperty(0);
@@ -488,7 +487,7 @@ void MeshKernel::DeleteFacets (const std::vector<unsigned long> &raulFacets)
// invalidate facet and adjust number of point references
_aclFacetArray.ResetInvalid();
for (std::vector<unsigned long>::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) {
for (std::vector<FacetIndex>::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) {
MeshFacet &rclFacet = _aclFacetArray[*pI];
rclFacet.SetInvalid();
_aclPointArray[rclFacet._aulPoints[0]]._ulProp--;
@@ -507,7 +506,7 @@ void MeshKernel::DeleteFacets (const std::vector<unsigned long> &raulFacets)
RecalcBoundBox();
}
bool MeshKernel::DeletePoint (unsigned long ulInd)
bool MeshKernel::DeletePoint (PointIndex ulInd)
{
if (ulInd >= _aclPointArray.size())
return false;
@@ -522,7 +521,7 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter)
{
MeshFacetIterator pFIter(*this), pFEnd(*this);
std::vector<MeshFacetIterator> clToDel;
unsigned long ulInd;
PointIndex ulInd;
// index of the point to delete
ulInd = rclIter._clIter - _aclPointArray.begin();
@@ -549,10 +548,10 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter)
return true;
}
void MeshKernel::DeletePoints (const std::vector<unsigned long> &raulPoints)
void MeshKernel::DeletePoints (const std::vector<PointIndex> &raulPoints)
{
_aclPointArray.ResetInvalid();
for (std::vector<unsigned long>::const_iterator pI = raulPoints.begin(); pI != raulPoints.end(); ++pI)
for (std::vector<PointIndex>::const_iterator pI = raulPoints.begin(); pI != raulPoints.end(); ++pI)
_aclPointArray[*pI].SetInvalid();
// delete facets if at least one corner point is invalid
@@ -583,9 +582,8 @@ void MeshKernel::DeletePoints (const std::vector<unsigned long> &raulPoints)
RecalcBoundBox();
}
void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, bool bOnlySetInvalid)
void MeshKernel::ErasePoint (PointIndex ulIndex, FacetIndex ulFacetIndex, bool bOnlySetInvalid)
{
unsigned long i;
std::vector<MeshFacet>::iterator pFIter, pFEnd, pFNot;
pFIter = _aclFacetArray.begin();
@@ -594,7 +592,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex,
// check all facets
while (pFIter < pFNot) {
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
if (pFIter->_aulPoints[i] == ulIndex)
return; // point still referenced ==> do not delete
}
@@ -603,7 +601,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex,
++pFIter;
while (pFIter < pFEnd) {
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
if (pFIter->_aulPoints[i] == ulIndex)
return; // point still referenced ==> do not delete
}
@@ -618,7 +616,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex,
// correct point indices of the facets
pFIter = _aclFacetArray.begin();
while (pFIter < pFEnd) {
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
if (pFIter->_aulPoints[i] > ulIndex)
pFIter->_aulPoints[i]--;
}
@@ -633,7 +631,7 @@ void MeshKernel::RemoveInvalids ()
{
std::vector<unsigned long> aulDecrements;
std::vector<unsigned long>::iterator pDIter;
unsigned long ulDec, i, k;
unsigned long ulDec;
MeshPointArray::_TIterator pPIter, pPEnd;
MeshFacetArray::_TIterator pFIter, pFEnd;
@@ -691,13 +689,13 @@ void MeshKernel::RemoveInvalids ()
pFEnd = _aclFacetArray.end();
for (pFIter = _aclFacetArray.begin(); pFIter != pFEnd; ++pFIter) {
if (pFIter->IsValid() == true) {
for (i = 0; i < 3; i++) {
k = pFIter->_aulNeighbours[i];
if (k != ULONG_MAX) {
for (int i = 0; i < 3; i++) {
FacetIndex k = pFIter->_aulNeighbours[i];
if (k != FACET_INDEX_MAX) {
if (_aclFacetArray[k].IsValid() == true)
pFIter->_aulNeighbours[i] -= aulDecrements[k];
else
pFIter->_aulNeighbours[i] = ULONG_MAX;
pFIter->_aulNeighbours[i] = FACET_INDEX_MAX;
}
}
}
@@ -722,28 +720,28 @@ void MeshKernel::RemoveInvalids ()
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
const Base::Polygon2d& rclPoly, bool bCutInner, std::vector<MeshGeomFacet> &raclFacets)
{
std::vector<unsigned long> aulFacets;
std::vector<FacetIndex> aulFacets;
MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bCutInner, aulFacets );
for (std::vector<unsigned long>::iterator i = aulFacets.begin(); i != aulFacets.end(); ++i)
for (std::vector<FacetIndex>::iterator i = aulFacets.begin(); i != aulFacets.end(); ++i)
raclFacets.push_back(GetFacet(*i));
DeleteFacets(aulFacets);
}
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
const Base::Polygon2d& rclPoly, bool bInner, std::vector<unsigned long> &raclCutted)
const Base::Polygon2d& rclPoly, bool bInner, std::vector<FacetIndex> &raclCutted)
{
MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bInner, raclCutted);
DeleteFacets(raclCutted);
}
std::vector<unsigned long> MeshKernel::GetFacetPoints(const std::vector<unsigned long>& facets) const
std::vector<PointIndex> MeshKernel::GetFacetPoints(const std::vector<FacetIndex>& facets) const
{
std::vector<unsigned long> points;
for (std::vector<unsigned long>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
unsigned long p0, p1, p2;
std::vector<PointIndex> points;
for (std::vector<FacetIndex>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
PointIndex p0, p1, p2;
GetFacetPoints(*it, p0, p1, p2);
points.push_back(p0);
points.push_back(p1);
@@ -755,11 +753,11 @@ std::vector<unsigned long> MeshKernel::GetFacetPoints(const std::vector<unsigned
return points;
}
std::vector<unsigned long> MeshKernel::GetPointFacets(const std::vector<unsigned long>& points) const
std::vector<FacetIndex> MeshKernel::GetPointFacets(const std::vector<PointIndex>& points) const
{
_aclPointArray.ResetFlag(MeshPoint::TMP0);
_aclFacetArray.ResetFlag(MeshFacet::TMP0);
for (std::vector<unsigned long>::const_iterator pI = points.begin(); pI != points.end(); ++pI)
for (std::vector<PointIndex>::const_iterator pI = points.begin(); pI != points.end(); ++pI)
_aclPointArray[*pI].SetFlag(MeshPoint::TMP0);
// mark facets if at least one corner point is marked
@@ -775,21 +773,21 @@ std::vector<unsigned long> MeshKernel::GetPointFacets(const std::vector<unsigned
}
}
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
MeshAlgorithm(*this).GetFacetsFlag(facets, MeshFacet::TMP0);
return facets;
}
std::vector<unsigned long> MeshKernel::HasFacets (const MeshPointIterator &rclIter) const
std::vector<FacetIndex> MeshKernel::HasFacets (const MeshPointIterator &rclIter) const
{
unsigned long i, ulPtInd = rclIter.Position();
PointIndex ulPtInd = rclIter.Position();
std::vector<MeshFacet>::const_iterator pFIter = _aclFacetArray.begin();
std::vector<MeshFacet>::const_iterator pFBegin = _aclFacetArray.begin();
std::vector<MeshFacet>::const_iterator pFEnd = _aclFacetArray.end();
std::vector<unsigned long> aulBelongs;
std::vector<FacetIndex> aulBelongs;
while (pFIter < pFEnd) {
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
if (pFIter->_aulPoints[i] == ulPtInd) {
aulBelongs.push_back(pFIter - pFBegin);
break;
@@ -801,20 +799,20 @@ std::vector<unsigned long> MeshKernel::HasFacets (const MeshPointIterator &rclIt
return aulBelongs;
}
MeshPointArray MeshKernel::GetPoints(const std::vector<unsigned long>& indices) const
MeshPointArray MeshKernel::GetPoints(const std::vector<PointIndex>& indices) const
{
MeshPointArray ary;
ary.reserve(indices.size());
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it)
for (std::vector<PointIndex>::const_iterator it = indices.begin(); it != indices.end(); ++it)
ary.push_back(this->_aclPointArray[*it]);
return ary;
}
MeshFacetArray MeshKernel::GetFacets(const std::vector<unsigned long>& indices) const
MeshFacetArray MeshKernel::GetFacets(const std::vector<FacetIndex>& indices) const
{
MeshFacetArray ary;
ary.reserve(indices.size());
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it)
for (std::vector<FacetIndex>::const_iterator it = indices.begin(); it != indices.end(); ++it)
ary.push_back(this->_aclFacetArray[*it]);
return ary;
}
@@ -916,7 +914,7 @@ void MeshKernel::Read (std::istream &rclIn)
it->_aulPoints[2] = v3;
// On systems where an 'unsigned long' is a 64-bit value
// the empty neighbour must be explicitly set to 'ULONG_MAX'
// the empty neighbour must be explicitly set to 'FACET_INDEX_MAX'
// because in algorithms this value is always used to check
// for open edges.
str >> v1 >> v2 >> v3;
@@ -932,17 +930,17 @@ void MeshKernel::Read (std::istream &rclIn)
if (v1 < open_edge)
it->_aulNeighbours[0] = v1;
else
it->_aulNeighbours[0] = ULONG_MAX;
it->_aulNeighbours[0] = FACET_INDEX_MAX;
if (v2 < open_edge)
it->_aulNeighbours[1] = v2;
else
it->_aulNeighbours[1] = ULONG_MAX;
it->_aulNeighbours[1] = FACET_INDEX_MAX;
if (v3 < open_edge)
it->_aulNeighbours[2] = v3;
else
it->_aulNeighbours[2] = ULONG_MAX;
it->_aulNeighbours[2] = FACET_INDEX_MAX;
}
str >> _clBoundBox.MinX >> _clBoundBox.MaxX;
@@ -1021,7 +1019,7 @@ void MeshKernel::Read (std::istream &rclIn)
for (int i=0; i<3; i++) {
if (it->_aulPoints[i] >= uCtPts)
throw Base::BadFormatError("Invalid data structure");
if (it->_aulNeighbours[i] < ULONG_MAX && it->_aulNeighbours[i] >= uCtFts)
if (it->_aulNeighbours[i] < FACET_INDEX_MAX && it->_aulNeighbours[i] >= uCtFts)
throw Base::BadFormatError("Invalid data structure");
}
}
@@ -1055,7 +1053,7 @@ void MeshKernel::Smooth(int iterations, float stepsize)
LaplaceSmoothing(*this).Smooth(iterations);
}
void MeshKernel::RecalcBoundBox (void)
void MeshKernel::RecalcBoundBox ()
{
_clBoundBox.SetVoid();
for (MeshPointArray::_TConstIterator pI = _aclPointArray.begin(); pI != _aclPointArray.end(); pI++)
@@ -1068,7 +1066,7 @@ std::vector<Base::Vector3f> MeshKernel::CalcVertexNormals() const
normals.resize(CountPoints());
unsigned long p1,p2,p3;
PointIndex p1,p2,p3;
unsigned int ct = CountFacets();
for (unsigned int pFIter = 0;pFIter < ct; pFIter++) {
GetFacetPoints(pFIter,p1,p2,p3);
@@ -1082,12 +1080,12 @@ std::vector<Base::Vector3f> MeshKernel::CalcVertexNormals() const
return normals;
}
std::vector<Base::Vector3f> MeshKernel::GetFacetNormals(const std::vector<unsigned long>& facets) const
std::vector<Base::Vector3f> MeshKernel::GetFacetNormals(const std::vector<FacetIndex>& facets) const
{
std::vector<Base::Vector3f> normals;
normals.reserve(facets.size());
for (std::vector<unsigned long>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
const MeshFacet& face = _aclFacetArray[*it];
const Base::Vector3f& p1 = _aclPointArray[face._aulPoints[0]];
@@ -1113,12 +1111,12 @@ float MeshKernel::GetSurface() const
return fSurface;
}
float MeshKernel::GetSurface( const std::vector<unsigned long>& aSegment ) const
float MeshKernel::GetSurface( const std::vector<FacetIndex>& aSegment ) const
{
float fSurface = 0.0;
MeshFacetIterator cIter(*this);
for (std::vector<unsigned long>::const_iterator it = aSegment.begin(); it != aSegment.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = aSegment.begin(); it != aSegment.end(); ++it) {
cIter.Set(*it);
fSurface += cIter->Area();
}
@@ -1196,19 +1194,19 @@ void MeshKernel::GetEdges (std::vector<MeshGeomEdge>& edges) const
MeshGeomEdge edge;
edge._aclPoints[0] = this->_aclPointArray[it2->pt1];
edge._aclPoints[1] = this->_aclPointArray[it2->pt2];
edge._bBorder = it2->facetIdx == ULONG_MAX;
edge._bBorder = it2->facetIdx == FACET_INDEX_MAX;
edges.push_back(edge);
}
}
unsigned long MeshKernel::CountEdges (void) const
unsigned long MeshKernel::CountEdges () const
{
unsigned long openEdges = 0, closedEdges = 0;
for (MeshFacetArray::_TConstIterator it = _aclFacetArray.begin(); it != _aclFacetArray.end(); ++it) {
for (int i = 0; i < 3; i++) {
if (it->_aulNeighbours[i] == ULONG_MAX)
if (it->_aulNeighbours[i] == FACET_INDEX_MAX)
openEdges++;
else
closedEdges++;
+49 -49
View File
@@ -24,7 +24,7 @@
#ifndef MESH_KERNEL_H
#define MESH_KERNEL_H
#include <assert.h>
#include <cassert>
#include <iosfwd>
#include "Elements.h"
@@ -65,11 +65,11 @@ class MeshExport MeshKernel
{
public:
/// Construction
MeshKernel (void);
MeshKernel ();
/// Construction
MeshKernel (const MeshKernel &rclMesh);
/// Destruction
~MeshKernel (void)
~MeshKernel ()
{ Clear(); }
/** @name I/O methods */
@@ -82,71 +82,71 @@ public:
/** @name Querying */
//@{
/// Returns the number of facets
unsigned long CountFacets (void) const
unsigned long CountFacets () const
{ return static_cast<unsigned long>(_aclFacetArray.size()); }
/// Returns the number of edge
unsigned long CountEdges (void) const;
unsigned long CountEdges () const;
// Returns the number of points
unsigned long CountPoints (void) const
unsigned long CountPoints () const
{ return static_cast<unsigned long>(_aclPointArray.size()); }
/// Returns the number of required memory in bytes
unsigned int GetMemSize (void) const
unsigned int GetMemSize () const
{ return static_cast<unsigned int>(_aclPointArray.size() * sizeof(MeshPoint) +
_aclFacetArray.size() * sizeof(MeshFacet)); }
/// Determines the bounding box
const Base::BoundBox3f& GetBoundBox (void) const
const Base::BoundBox3f& GetBoundBox () const
{ return _clBoundBox; }
/** Forces a recalculation of the bounding box. This method should be called after
* the removal of points.or after a transformation of the data structure.
*/
void RecalcBoundBox (void);
void RecalcBoundBox ();
/** Returns the point at the given index. This method is rather slow and should be
* called occasionally only. For fast access the MeshPointIterator interfsce should
* be used.
*/
inline MeshPoint GetPoint (unsigned long ulIndex) const;
inline MeshPoint GetPoint (PointIndex ulIndex) const;
/** Returns an array of the vertex normals of the mesh. A vertex normal gets calculated
* by summarizing the normals of the associated facets.
*/
std::vector<Base::Vector3f> CalcVertexNormals() const;
std::vector<Base::Vector3f> GetFacetNormals(const std::vector<unsigned long>&) const;
std::vector<Base::Vector3f> GetFacetNormals(const std::vector<FacetIndex>&) const;
/** Returns the facet at the given index. This method is rather slow and should be
* called occasionally only. For fast access the MeshFacetIterator interface should
* be used.
*/
inline MeshGeomFacet GetFacet (unsigned long ulIndex) const;
inline MeshGeomFacet GetFacet (FacetIndex ulIndex) const;
inline MeshGeomFacet GetFacet (const MeshFacet &rclFacet) const;
/** Returns the point indices of the given facet index. */
inline void GetFacetPoints (unsigned long ulFaIndex, unsigned long &rclP0,
unsigned long &rclP1, unsigned long &rclP2) const;
inline void GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0,
PointIndex &rclP1, PointIndex &rclP2) const;
/** Returns the point indices of the given facet indices. */
std::vector<unsigned long> GetFacetPoints(const std::vector<unsigned long>&) const;
std::vector<PointIndex> GetFacetPoints(const std::vector<FacetIndex>&) const;
/** Returns the facet indices that share the given point indices. */
std::vector<unsigned long> GetPointFacets(const std::vector<unsigned long>&) const;
std::vector<FacetIndex> GetPointFacets(const std::vector<PointIndex>&) const;
/** Returns the indices of the neighbour facets of the given facet index. */
inline void GetFacetNeighbours (unsigned long ulIndex, unsigned long &rulNIdx0,
unsigned long &rulNIdx1, unsigned long &rulNIdx2) const;
inline void GetFacetNeighbours (FacetIndex ulIndex, FacetIndex &rulNIdx0,
FacetIndex &rulNIdx1, FacetIndex &rulNIdx2) const;
/** Determines all facets that are associated to this point. This method is very
* slow and should be called occasionally only.
*/
std::vector<unsigned long> HasFacets (const MeshPointIterator &rclIter) const;
std::vector<FacetIndex> HasFacets (const MeshPointIterator &rclIter) const;
/** Returns true if the data structure is valid. */
bool IsValid (void) const
bool IsValid () const
{ return _bValid; }
/** Returns the array of all data points. */
const MeshPointArray& GetPoints (void) const { return _aclPointArray; }
const MeshPointArray& GetPoints () const { return _aclPointArray; }
/** Returns an array of points to the given indices. The indices
* must not be out of range.
*/
MeshPointArray GetPoints(const std::vector<unsigned long>&) const;
MeshPointArray GetPoints(const std::vector<PointIndex>&) const;
/** Returns a modifier for the point array */
MeshPointModifier ModifyPoints()
@@ -155,11 +155,11 @@ public:
}
/** Returns the array of all facets */
const MeshFacetArray& GetFacets (void) const { return _aclFacetArray; }
const MeshFacetArray& GetFacets () const { return _aclFacetArray; }
/** Returns an array of facets to the given indices. The indices
* must not be out of range.
*/
MeshFacetArray GetFacets(const std::vector<unsigned long>&) const;
MeshFacetArray GetFacets(const std::vector<FacetIndex>&) const;
/** Returns a modifier for the facet array */
MeshFacetModifier ModifyFacets()
@@ -179,7 +179,7 @@ public:
/** Calculates the surface area of the mesh object. */
float GetSurface() const;
/** Calculates the surface area of the segment defined by \a aSegment. */
float GetSurface( const std::vector<unsigned long>& aSegment ) const;
float GetSurface( const std::vector<FacetIndex>& aSegment ) const;
/** Calculates the volume of the mesh object. Therefore the mesh must be a solid, if not 0
* is returned.
*/
@@ -216,12 +216,12 @@ public:
* \note For the start facet \a ulStartFacet MeshFacetVisitor::Visit() does not get invoked though
* the facet gets marked as VISIT.
*/
unsigned long VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const;
unsigned long VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const;
/**
* Does basically the same as the method above unless the facets that share just a common point
* are regared as neighbours.
*/
unsigned long VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const;
unsigned long VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const;
//@}
/** @name Point visitors
@@ -243,7 +243,7 @@ public:
* \note For the start facet \a ulStartPoint MeshPointVisitor::Visit() does not get invoked though
* the point gets marked as VISIT.
*/
unsigned long VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, unsigned long ulStartPoint) const;
unsigned long VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, PointIndex ulStartPoint) const;
//@}
/** @name Iterators
@@ -346,14 +346,14 @@ public:
/**
* Does basically the same as the method above unless that the index of the facet is given.
*/
bool DeleteFacet (unsigned long ulInd);
bool DeleteFacet (FacetIndex ulInd);
/** Removes several facets from the data structure.
* @note This method overwrites the free usable property of each mesh point.
* @note This method also removes points from the structure that are no longer
* referenced by the facets.
* @note This method is very slow and should only be called occasionally.
*/
void DeleteFacets (const std::vector<unsigned long> &raulFacets);
void DeleteFacets (const std::vector<FacetIndex> &raulFacets);
/** Deletes the point the iterator points to. The deletion of a point requires the following step:
* \li Find all associated facets to this point.
* \li Delete these facets.
@@ -366,19 +366,19 @@ public:
/**
* Does basically the same as the method above unless that the index of the facet is given.
*/
bool DeletePoint (unsigned long ulInd);
bool DeletePoint (PointIndex ulInd);
/** Removes several points from the data structure.
* @note This method overwrites the free usable property of each mesh point.
*/
void DeletePoints (const std::vector<unsigned long> &raulPoints);
void DeletePoints (const std::vector<PointIndex> &raulPoints);
/** Removes all as INVALID marked points and facets from the structure. */
void RemoveInvalids ();
/** Rebuilds the neighbour indices for all facets. */
void RebuildNeighbours (void);
void RebuildNeighbours ();
/** Removes unreferenced points or facets with invalid indices from the mesh. */
void Cleanup();
/** Clears the whole data structure. */
void Clear (void);
void Clear ();
/** Replaces the current data structure with the structure built up of the array
* of triangles given in \a rclFAry.
*/
@@ -404,11 +404,11 @@ public:
*/
void Transform (const Base::Matrix4D &rclMat);
/** Moves the point at the given index along the vector \a rclTrans. */
inline void MovePoint (unsigned long ulPtIndex, const Base::Vector3f &rclTrans);
inline void MovePoint (PointIndex ulPtIndex, const Base::Vector3f &rclTrans);
/** Sets the point at the given index to the new \a rPoint. */
inline void SetPoint (unsigned long ulPtIndex, const Base::Vector3f &rPoint);
inline void SetPoint (PointIndex ulPtIndex, const Base::Vector3f &rPoint);
/** Sets the point at the given index to the new \a rPoint. */
inline void SetPoint (unsigned long ulPtIndex, float x, float y, float z);
inline void SetPoint (PointIndex ulPtIndex, float x, float y, float z);
/** Smoothes the mesh kernel. */
void Smooth(int iterations, float d_max);
/**
@@ -423,19 +423,19 @@ public:
* index number in the facet array of the mesh structure.
*/
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2d& rclPoly,
bool bCutInner, std::vector<unsigned long> &raclCutted);
bool bCutInner, std::vector<FacetIndex> &raclCutted);
//@}
protected:
/** Rebuilds the neighbour indices for subset of all facets from index \a index on. */
void RebuildNeighbours (unsigned long);
void RebuildNeighbours (FacetIndex);
/** Checks if this point is associated to no other facet and deletes if so.
* The point indices of the facets get adjusted.
* \a ulIndex is the index of the point to be deleted. \a ulFacetIndex is the index
* of the quasi deleted facet and is ignored. If \a bOnlySetInvalid is true the point
* doesn't get deleted but marked as invalid.
*/
void ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, bool bOnlySetInvalid = false);
void ErasePoint (PointIndex ulIndex, FacetIndex ulFacetIndex, bool bOnlySetInvalid = false);
/** Adjusts the facet's orierntation to the given normal direction. */
inline void AdjustNormal (MeshFacet &rclFacet, const Base::Vector3f &rclNormal);
@@ -460,13 +460,13 @@ protected:
friend class MeshTrimming;
};
inline MeshPoint MeshKernel::GetPoint (unsigned long ulIndex) const
inline MeshPoint MeshKernel::GetPoint (PointIndex ulIndex) const
{
assert(ulIndex < _aclPointArray.size());
return _aclPointArray[ulIndex];
}
inline MeshGeomFacet MeshKernel::GetFacet (unsigned long ulIndex) const
inline MeshGeomFacet MeshKernel::GetFacet (FacetIndex ulIndex) const
{
assert(ulIndex < _aclFacetArray.size());
@@ -498,8 +498,8 @@ inline MeshGeomFacet MeshKernel::GetFacet (const MeshFacet &rclFacet) const
return clFacet;
}
inline void MeshKernel::GetFacetNeighbours (unsigned long ulIndex, unsigned long &rulNIdx0,
unsigned long &rulNIdx1, unsigned long &rulNIdx2) const
inline void MeshKernel::GetFacetNeighbours (FacetIndex ulIndex, FacetIndex &rulNIdx0,
FacetIndex &rulNIdx1, FacetIndex &rulNIdx2) const
{
assert(ulIndex < _aclFacetArray.size());
@@ -508,17 +508,17 @@ inline void MeshKernel::GetFacetNeighbours (unsigned long ulIndex, unsigned long
rulNIdx2 = _aclFacetArray[ulIndex]._aulNeighbours[2];
}
inline void MeshKernel::MovePoint (unsigned long ulPtIndex, const Base::Vector3f &rclTrans)
inline void MeshKernel::MovePoint (PointIndex ulPtIndex, const Base::Vector3f &rclTrans)
{
_aclPointArray[ulPtIndex] += rclTrans;
}
inline void MeshKernel::SetPoint (unsigned long ulPtIndex, const Base::Vector3f &rPoint)
inline void MeshKernel::SetPoint (PointIndex ulPtIndex, const Base::Vector3f &rPoint)
{
_aclPointArray[ulPtIndex] = rPoint;
}
inline void MeshKernel::SetPoint (unsigned long ulPtIndex, float x, float y, float z)
inline void MeshKernel::SetPoint (PointIndex ulPtIndex, float x, float y, float z)
{
_aclPointArray[ulPtIndex].Set(x,y,z);
}
@@ -550,8 +550,8 @@ inline Base::Vector3f MeshKernel::GetGravityPoint (const MeshFacet &rclFacet) co
(p0.z+p1.z+p2.z)/3.0f);
}
inline void MeshKernel::GetFacetPoints (unsigned long ulFaIndex, unsigned long &rclP0,
unsigned long &rclP1, unsigned long &rclP2) const
inline void MeshKernel::GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0,
PointIndex &rclP1, PointIndex &rclP2) const
{
assert(ulFaIndex < _aclFacetArray.size());
const MeshFacet& rclFacet = _aclFacetArray[ulFaIndex];
+4 -5
View File
@@ -139,8 +139,8 @@ bool MeshProjection::connectLines(std::list< std::pair<Base::Vector3f, Base::Vec
}
bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid,
const Base::Vector3f& v1, unsigned long f1,
const Base::Vector3f& v2, unsigned long f2,
const Base::Vector3f& v1, FacetIndex f1,
const Base::Vector3f& v2, FacetIndex f2,
const Base::Vector3f& vd,
std::vector<Base::Vector3f>& polyline)
{
@@ -150,7 +150,7 @@ bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid,
dir.Normalize();
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
// special case: start and endpoint inside same facet
if (f1 == f2) {
@@ -172,8 +172,7 @@ bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid,
// cut all facets with plane
std::list< std::pair<Base::Vector3f, Base::Vector3f> > cutLine;
//unsigned long start = 0, end = 0;
for (std::vector<unsigned long>::iterator it = facets.begin(); it != facets.end(); ++it) {
for (std::vector<FacetIndex>::iterator it = facets.begin(); it != facets.end(); ++it) {
Base::Vector3f e1, e2;
MeshGeomFacet tria = kernel.GetFacet(*it);
if (bboxInsideRectangle(tria.GetBoundBox(), v1, v2, vd)) {
+3 -2
View File
@@ -27,6 +27,7 @@
#include <vector>
#include <Base/BoundBox.h>
#include <Base/Vector3D.h>
#include <Mod/Mesh/App/Core/Elements.h>
using Base::Vector3f;
@@ -48,8 +49,8 @@ public:
MeshProjection(const MeshKernel&);
~MeshProjection();
bool projectLineOnMesh(const MeshFacetGrid& grid, const Base::Vector3f& p1, unsigned long f1,
const Base::Vector3f& p2, unsigned long f2, const Base::Vector3f& view,
bool projectLineOnMesh(const MeshFacetGrid& grid, const Base::Vector3f& p1, FacetIndex f1,
const Base::Vector3f& p2, FacetIndex f2, const Base::Vector3f& view,
std::vector<Base::Vector3f>& polyline);
protected:
bool bboxInsideRectangle (const Base::BoundBox3f& bbox, const Base::Vector3f& p1, const Base::Vector3f& p2, const Base::Vector3f& view) const;
+17 -17
View File
@@ -31,11 +31,11 @@
using namespace MeshCore;
void MeshSurfaceSegment::Initialize(unsigned long)
void MeshSurfaceSegment::Initialize(FacetIndex)
{
}
bool MeshSurfaceSegment::TestInitialFacet(unsigned long) const
bool MeshSurfaceSegment::TestInitialFacet(FacetIndex) const
{
return true;
}
@@ -44,14 +44,14 @@ void MeshSurfaceSegment::AddFacet(const MeshFacet&)
{
}
void MeshSurfaceSegment::AddSegment(const std::vector<unsigned long>& segm)
void MeshSurfaceSegment::AddSegment(const std::vector<FacetIndex>& segm)
{
if (segm.size() >= minFacets) {
segments.push_back(segm);
}
}
MeshSegment MeshSurfaceSegment::FindSegment(unsigned long index) const
MeshSegment MeshSurfaceSegment::FindSegment(FacetIndex index) const
{
for (std::vector<MeshSegment>::const_iterator it = segments.begin(); it != segments.end(); ++it) {
if (std::find(it->begin(), it->end(), index) != it->end())
@@ -73,7 +73,7 @@ MeshDistancePlanarSegment::~MeshDistancePlanarSegment()
delete fitter;
}
void MeshDistancePlanarSegment::Initialize(unsigned long index)
void MeshDistancePlanarSegment::Initialize(FacetIndex index)
{
fitter->Clear();
@@ -312,7 +312,7 @@ SphereSurfaceFit::SphereSurfaceFit()
SphereSurfaceFit::SphereSurfaceFit(const Base::Vector3f& c, float r)
: center(c)
, radius(r)
, fitter(0)
, fitter(nullptr)
{
}
@@ -408,13 +408,13 @@ MeshDistanceGenericSurfaceFitSegment::~MeshDistanceGenericSurfaceFitSegment()
delete fitter;
}
void MeshDistanceGenericSurfaceFitSegment::Initialize(unsigned long index)
void MeshDistanceGenericSurfaceFitSegment::Initialize(FacetIndex index)
{
MeshGeomFacet triangle = kernel.GetFacet(index);
fitter->Initialize(triangle);
}
bool MeshDistanceGenericSurfaceFitSegment::TestInitialFacet(unsigned long index) const
bool MeshDistanceGenericSurfaceFitSegment::TestInitialFacet(FacetIndex index) const
{
MeshGeomFacet triangle = kernel.GetFacet(index);
for (int i=0; i<3; i++) {
@@ -511,7 +511,7 @@ bool MeshCurvatureFreeformSegment::TestFacet (const MeshFacet &rclFacet) const
// --------------------------------------------------------
MeshSurfaceVisitor::MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector<unsigned long> &indices)
MeshSurfaceVisitor::MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector<FacetIndex> &indices)
: indices(indices), segm(segm)
{
}
@@ -521,13 +521,13 @@ MeshSurfaceVisitor::~MeshSurfaceVisitor ()
}
bool MeshSurfaceVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&,
unsigned long, unsigned long, unsigned short)
FacetIndex, unsigned long, unsigned short)
{
return segm.TestFacet(face);
}
bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &,
unsigned long ulFInd, unsigned long)
FacetIndex ulFInd, unsigned long)
{
indices.push_back(ulFInd);
segm.AddFacet(face);
@@ -539,7 +539,7 @@ bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &,
void MeshSegmentAlgorithm::FindSegments(std::vector<MeshSurfaceSegmentPtr>& segm)
{
// reset VISIT flags
unsigned long startFacet;
FacetIndex startFacet;
MeshCore::MeshAlgorithm cAlgo(myKernel);
cAlgo.ResetFacetFlag(MeshCore::MeshFacet::VISIT);
@@ -550,7 +550,7 @@ void MeshSegmentAlgorithm::FindSegments(std::vector<MeshSurfaceSegmentPtr>& segm
// start from the first not visited facet
cAlgo.CountFacetFlag(MeshCore::MeshFacet::VISIT);
std::vector<unsigned long> resetVisited;
std::vector<FacetIndex> resetVisited;
for (std::vector<MeshSurfaceSegmentPtr>::iterator it = segm.begin(); it != segm.end(); ++it) {
cAlgo.ResetFacetsFlag(resetVisited, MeshCore::MeshFacet::VISIT);
@@ -563,10 +563,10 @@ void MeshSegmentAlgorithm::FindSegments(std::vector<MeshSurfaceSegmentPtr>& segm
if (iCur < iEnd)
startFacet = iCur - iBeg;
else
startFacet = ULONG_MAX;
while (startFacet != ULONG_MAX) {
startFacet = FACET_INDEX_MAX;
while (startFacet != FACET_INDEX_MAX) {
// collect all facets of the same geometry
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
(*it)->Initialize(startFacet);
if ((*it)->TestInitialFacet(startFacet))
indices.push_back(startFacet);
@@ -588,7 +588,7 @@ void MeshSegmentAlgorithm::FindSegments(std::vector<MeshSurfaceSegmentPtr>& segm
if (iCur < iEnd)
startFacet = iCur - iBeg;
else
startFacet = ULONG_MAX;
startFacet = FACET_INDEX_MAX;
}
}
}
+12 -12
View File
@@ -35,7 +35,7 @@ class PlaneFit;
class CylinderFit;
class SphereFit;
class MeshFacet;
typedef std::vector<unsigned long> MeshSegment;
typedef std::vector<FacetIndex> MeshSegment;
class MeshExport MeshSurfaceSegment
{
@@ -45,12 +45,12 @@ public:
virtual ~MeshSurfaceSegment() {}
virtual bool TestFacet (const MeshFacet &rclFacet) const = 0;
virtual const char* GetType() const = 0;
virtual void Initialize(unsigned long);
virtual bool TestInitialFacet(unsigned long) const;
virtual void Initialize(FacetIndex);
virtual bool TestInitialFacet(FacetIndex) const;
virtual void AddFacet(const MeshFacet& rclFacet);
void AddSegment(const std::vector<unsigned long>&);
void AddSegment(const std::vector<FacetIndex>&);
const std::vector<MeshSegment>& GetSegments() const { return segments; }
MeshSegment FindSegment(unsigned long) const;
MeshSegment FindSegment(FacetIndex) const;
protected:
std::vector<MeshSegment> segments;
@@ -78,7 +78,7 @@ public:
virtual ~MeshDistancePlanarSegment();
bool TestFacet (const MeshFacet& rclFacet) const;
const char* GetType() const { return "Plane"; }
void Initialize(unsigned long);
void Initialize(FacetIndex);
void AddFacet(const MeshFacet& rclFacet);
protected:
@@ -174,8 +174,8 @@ public:
virtual ~MeshDistanceGenericSurfaceFitSegment();
bool TestFacet (const MeshFacet& rclFacet) const;
const char* GetType() const { return fitter->GetType(); }
void Initialize(unsigned long);
bool TestInitialFacet(unsigned long) const;
void Initialize(FacetIndex);
bool TestInitialFacet(FacetIndex) const;
void AddFacet(const MeshFacet& rclFacet);
std::vector<float> Parameters() const;
@@ -254,15 +254,15 @@ private:
class MeshExport MeshSurfaceVisitor : public MeshFacetVisitor
{
public:
MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector<unsigned long> &indices);
MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector<FacetIndex> &indices);
virtual ~MeshSurfaceVisitor ();
bool AllowVisit (const MeshFacet& face, const MeshFacet&,
unsigned long, unsigned long, unsigned short neighbourIndex);
FacetIndex, unsigned long, unsigned short neighbourIndex);
bool Visit (const MeshFacet & face, const MeshFacet &,
unsigned long ulFInd, unsigned long);
FacetIndex ulFInd, unsigned long);
protected:
std::vector<unsigned long> &indices;
std::vector<FacetIndex> &indices;
MeshSurfaceSegment& segm;
};
+16 -16
View File
@@ -59,7 +59,7 @@ SetOperations::SetOperations (const MeshKernel &cutMesh1, const MeshKernel &cutM
{
}
SetOperations::~SetOperations (void)
SetOperations::~SetOperations ()
{
}
@@ -74,7 +74,7 @@ void SetOperations::Do ()
// _builder.clear();
//Base::Sequencer().next();
std::set<unsigned long> facetsCuttingEdge0, facetsCuttingEdge1;
std::set<FacetIndex> facetsCuttingEdge0, facetsCuttingEdge1;
Cut(facetsCuttingEdge0, facetsCuttingEdge1);
// no intersection curve of the meshes found
@@ -170,7 +170,7 @@ void SetOperations::Do ()
MeshDefinitions::SetMinPointDistance(saveMinMeshDistance);
}
void SetOperations::Cut (std::set<unsigned long>& facetsCuttingEdge0, std::set<unsigned long>& facetsCuttingEdge1)
void SetOperations::Cut (std::set<FacetIndex>& facetsCuttingEdge0, std::set<FacetIndex>& facetsCuttingEdge1)
{
MeshFacetGrid grid1(_cutMesh0, 20);
MeshFacetGrid grid2(_cutMesh1, 20);
@@ -189,24 +189,24 @@ void SetOperations::Cut (std::set<unsigned long>& facetsCuttingEdge0, std::set<u
{
if (grid1.GetCtElements(gx1, gy1, gz1) > 0)
{
std::vector<unsigned long> vecFacets2;
std::vector<FacetIndex> vecFacets2;
grid2.Inside(grid1.GetBoundBox(gx1, gy1, gz1), vecFacets2);
if (vecFacets2.size() > 0)
{
std::set<unsigned long> vecFacets1;
std::set<FacetIndex> vecFacets1;
grid1.GetElements(gx1, gy1, gz1, vecFacets1);
std::set<unsigned long>::iterator it1;
std::set<FacetIndex>::iterator it1;
for (it1 = vecFacets1.begin(); it1 != vecFacets1.end(); ++it1)
{
unsigned long fidx1 = *it1;
FacetIndex fidx1 = *it1;
MeshGeomFacet f1 = _cutMesh0.GetFacet(*it1);
std::vector<unsigned long>::iterator it2;
std::vector<FacetIndex>::iterator it2;
for (it2 = vecFacets2.begin(); it2 != vecFacets2.end(); ++it2)
{
unsigned long fidx2 = *it2;
FacetIndex fidx2 = *it2;
MeshGeomFacet f2 = _cutMesh1.GetFacet(fidx2);
MeshPoint p0, p1;
@@ -304,13 +304,13 @@ void SetOperations::Cut (std::set<unsigned long>& facetsCuttingEdge0, std::set<u
void SetOperations::TriangulateMesh (const MeshKernel &cutMesh, int side)
{
// Triangulate Mesh
std::map<unsigned long, std::list<std::set<MeshPoint>::iterator> >::iterator it1;
std::map<FacetIndex, std::list<std::set<MeshPoint>::iterator> >::iterator it1;
for (it1 = _facet2points[side].begin(); it1 != _facet2points[side].end(); ++it1)
{
std::vector<Vector3f> points;
std::set<MeshPoint> pointsSet;
unsigned long fidx = it1->first;
FacetIndex fidx = it1->first;
MeshGeomFacet f = cutMesh.GetFacet(fidx);
//if (side == 1)
@@ -468,7 +468,7 @@ void SetOperations::CollectFacets (int side, float mult)
{
if (!itf->IsFlag(MeshFacet::VISIT))
{ // Facet found, visit neighbours
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
facets.push_back(itf - rFacets.begin()); // add seed facet
CollectFacetVisitor visitor(mesh, facets, _edges, side, mult, _builder);
mesh.VisitNeighbourFacets(visitor, itf - rFacets.begin());
@@ -492,7 +492,7 @@ void SetOperations::CollectFacets (int side, float mult)
// MeshDefinitions::SetMinPointDistance(distSave);
}
SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh, std::vector<unsigned long>& facets,
SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh, std::vector<FacetIndex>& facets,
std::map<Edge, EdgeInfo>& edges, int side, float mult,
Base::Builder3D& builder)
: _facets(facets)
@@ -506,7 +506,7 @@ SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh,
}
bool SetOperations::CollectFacetVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long ulLevel)
FacetIndex ulFInd, unsigned long ulLevel)
{
(void)rclFacet;
(void)rclFrom;
@@ -517,14 +517,14 @@ bool SetOperations::CollectFacetVisitor::Visit (const MeshFacet &rclFacet, const
//static int matchCounter = 0;
bool SetOperations::CollectFacetVisitor::AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom,
unsigned long ulFInd, unsigned long ulLevel,
FacetIndex ulFInd, unsigned long ulLevel,
unsigned short neighbourIndex)
{
(void)ulFInd;
(void)ulLevel;
if (rclFacet.IsFlag(MeshFacet::MARKED) && rclFrom.IsFlag(MeshFacet::MARKED)) {
// facet connected to an edge
unsigned long pt0 = rclFrom._aulPoints[neighbourIndex], pt1 = rclFrom._aulPoints[(neighbourIndex+1)%3];
PointIndex pt0 = rclFrom._aulPoints[neighbourIndex], pt1 = rclFrom._aulPoints[(neighbourIndex+1)%3];
Edge edge(_mesh.GetPoint(pt0), _mesh.GetPoint(pt1));
std::map<Edge, EdgeInfo>::iterator it = _edges.find(edge);
+8 -8
View File
@@ -59,7 +59,7 @@ public:
/// Construction
SetOperations (const MeshKernel &cutMesh1, const MeshKernel &cutMesh2, MeshKernel &result, OperationType opType, float minDistanceToPoint = 1e-5f);
/// Destruction
virtual ~SetOperations (void);
virtual ~SetOperations ();
public:
@@ -116,7 +116,7 @@ private:
public:
int fcounter[2]; // counter of facets attacted to the edge
MeshGeomFacet facets[2][2]; // Geom-Facets attached to the edge
unsigned long facet[2]; // underlying Facet-Index
FacetIndex facet[2]; // underlying Facet-Index
EdgeInfo ()
{
@@ -146,7 +146,7 @@ private:
class CollectFacetVisitor : public MeshFacetVisitor
{
public:
std::vector<unsigned long> &_facets;
std::vector<FacetIndex> &_facets;
const MeshKernel &_mesh;
std::map<Edge, EdgeInfo> &_edges;
int _side;
@@ -154,9 +154,9 @@ private:
int _addFacets; // 0: add facets to the result 1: do not add facets to the result
Base::Builder3D& _builder;
CollectFacetVisitor (const MeshKernel& mesh, std::vector<unsigned long>& facets, std::map<Edge, EdgeInfo>& edges, int side, float mult, Base::Builder3D& builder);
bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel);
bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, unsigned long ulFInd, unsigned long ulLevel, unsigned short neighbourIndex);
CollectFacetVisitor (const MeshKernel& mesh, std::vector<FacetIndex>& facets, std::map<Edge, EdgeInfo>& edges, int side, float mult, Base::Builder3D& builder);
bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd, unsigned long ulLevel);
bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, FacetIndex ulFInd, unsigned long ulLevel, unsigned short neighbourIndex);
};
/** all points from cut */
@@ -164,14 +164,14 @@ private:
/** all edges */
std::map<Edge, EdgeInfo> _edges;
/** map from facet index to its cut points (mesh 1 and mesh 2) Key: Facet-Index Value: List of iterators of set<MeshPoint> */
std::map<unsigned long, std::list<std::set<MeshPoint>::iterator> > _facet2points[2];
std::map<FacetIndex, std::list<std::set<MeshPoint>::iterator> > _facet2points[2];
/** Facets collected from region growing */
std::vector<MeshGeomFacet> _facetsOf[2];
std::vector<MeshGeomFacet> _newMeshFacets[2];
/** Cut mesh 1 with mesh 2 */
void Cut (std::set<unsigned long>& facetsNotCuttingEdge0, std::set<unsigned long>& facetsCuttingEdge1);
void Cut (std::set<FacetIndex>& facetsNotCuttingEdge0, std::set<FacetIndex>& facetsCuttingEdge1);
/** Trianglute each facets cut with its cutting points */
void TriangulateMesh (const MeshKernel &cutMesh, int side);
/** search facets for adding (with region growing) */
+19 -19
View File
@@ -78,11 +78,11 @@ void PlaneFitSmoothing::Smooth(unsigned int iterations)
MeshCore::PlaneFit pf;
pf.AddPoint(*v_it);
center = *v_it;
const std::set<unsigned long>& cv = vv_it[v_it.Position()];
const std::set<PointIndex>& cv = vv_it[v_it.Position()];
if (cv.size() < 3)
continue;
std::set<unsigned long>::const_iterator cv_it;
std::set<PointIndex>::const_iterator cv_it;
for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) {
pf.AddPoint(v_beg[*cv_it]);
center += v_beg[*cv_it];
@@ -109,14 +109,14 @@ void PlaneFitSmoothing::Smooth(unsigned int iterations)
}
// assign values without affecting iterators
unsigned long count = kernel.CountPoints();
for (unsigned long idx = 0; idx < count; idx++) {
PointIndex count = kernel.CountPoints();
for (PointIndex idx = 0; idx < count; idx++) {
kernel.SetPoint(idx, PointArray[idx]);
}
}
}
void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector<unsigned long>& point_indices)
void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector<PointIndex>& point_indices)
{
MeshCore::MeshPoint center;
MeshCore::MeshPointArray PointArray = kernel.GetPoints();
@@ -127,16 +127,16 @@ void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector<
for (unsigned int i=0; i<iterations; i++) {
Base::Vector3f N, L;
for (std::vector<unsigned long>::const_iterator it = point_indices.begin(); it != point_indices.end(); ++it) {
for (std::vector<PointIndex>::const_iterator it = point_indices.begin(); it != point_indices.end(); ++it) {
v_it.Set(*it);
MeshCore::PlaneFit pf;
pf.AddPoint(*v_it);
center = *v_it;
const std::set<unsigned long>& cv = vv_it[v_it.Position()];
const std::set<PointIndex>& cv = vv_it[v_it.Position()];
if (cv.size() < 3)
continue;
std::set<unsigned long>::const_iterator cv_it;
std::set<PointIndex>::const_iterator cv_it;
for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) {
pf.AddPoint(v_beg[*cv_it]);
center += v_beg[*cv_it];
@@ -163,8 +163,8 @@ void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector<
}
// assign values without affecting iterators
unsigned long count = kernel.CountPoints();
for (unsigned long idx = 0; idx < count; idx++) {
PointIndex count = kernel.CountPoints();
for (PointIndex idx = 0; idx < count; idx++) {
kernel.SetPoint(idx, PointArray[idx]);
}
}
@@ -186,9 +186,9 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it,
MeshCore::MeshPointArray::_TConstIterator v_it,
v_beg = points.begin(), v_end = points.end();
unsigned long pos = 0;
PointIndex pos = 0;
for (v_it = points.begin(); v_it != v_end; ++v_it,++pos) {
const std::set<unsigned long>& cv = vv_it[pos];
const std::set<PointIndex>& cv = vv_it[pos];
if (cv.size() < 3)
continue;
if (cv.size() != vf_it[pos].size()) {
@@ -201,7 +201,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it,
w=1.0/double(n_count);
double delx=0.0,dely=0.0,delz=0.0;
std::set<unsigned long>::const_iterator cv_it;
std::set<PointIndex>::const_iterator cv_it;
for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) {
delx += w*static_cast<double>((v_beg[*cv_it]).x-v_it->x);
dely += w*static_cast<double>((v_beg[*cv_it]).y-v_it->y);
@@ -217,13 +217,13 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it,
void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it,
const MeshRefPointToFacets& vf_it, double stepsize,
const std::vector<unsigned long>& point_indices)
const std::vector<PointIndex>& point_indices)
{
const MeshCore::MeshPointArray& points = kernel.GetPoints();
MeshCore::MeshPointArray::_TConstIterator v_beg = points.begin();
for (std::vector<unsigned long>::const_iterator pos = point_indices.begin(); pos != point_indices.end(); ++pos) {
const std::set<unsigned long>& cv = vv_it[*pos];
for (std::vector<PointIndex>::const_iterator pos = point_indices.begin(); pos != point_indices.end(); ++pos) {
const std::set<PointIndex>& cv = vv_it[*pos];
if (cv.size() < 3)
continue;
if (cv.size() != vf_it[*pos].size()) {
@@ -236,7 +236,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it,
w=1.0/double(n_count);
double delx=0.0,dely=0.0,delz=0.0;
std::set<unsigned long>::const_iterator cv_it;
std::set<PointIndex>::const_iterator cv_it;
for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) {
delx += w*static_cast<double>((v_beg[*cv_it]).x-(v_beg[*pos]).x);
dely += w*static_cast<double>((v_beg[*cv_it]).y-(v_beg[*pos]).y);
@@ -260,7 +260,7 @@ void LaplaceSmoothing::Smooth(unsigned int iterations)
}
}
void LaplaceSmoothing::SmoothPoints(unsigned int iterations, const std::vector<unsigned long>& point_indices)
void LaplaceSmoothing::SmoothPoints(unsigned int iterations, const std::vector<PointIndex>& point_indices)
{
MeshCore::MeshRefPointToPoints vv_it(kernel);
MeshCore::MeshRefPointToFacets vf_it(kernel);
@@ -292,7 +292,7 @@ void TaubinSmoothing::Smooth(unsigned int iterations)
}
}
void TaubinSmoothing::SmoothPoints(unsigned int iterations, const std::vector<unsigned long>& point_indices)
void TaubinSmoothing::SmoothPoints(unsigned int iterations, const std::vector<PointIndex>& point_indices)
{
MeshCore::MeshRefPointToPoints vv_it(kernel);
MeshCore::MeshRefPointToFacets vf_it(kernel);
+6 -5
View File
@@ -25,6 +25,7 @@
#define MESH_SMOOTHING_H
#include <vector>
#include "Definitions.h"
namespace MeshCore
{
@@ -54,7 +55,7 @@ public:
/** Smooth the triangle mesh. */
virtual void Smooth(unsigned int) = 0;
virtual void SmoothPoints(unsigned int, const std::vector<unsigned long>&) = 0;
virtual void SmoothPoints(unsigned int, const std::vector<PointIndex>&) = 0;
protected:
MeshKernel& kernel;
@@ -70,7 +71,7 @@ public:
PlaneFitSmoothing(MeshKernel&);
virtual ~PlaneFitSmoothing();
void Smooth(unsigned int);
void SmoothPoints(unsigned int, const std::vector<unsigned long>&);
void SmoothPoints(unsigned int, const std::vector<PointIndex>&);
};
class MeshExport LaplaceSmoothing : public AbstractSmoothing
@@ -79,7 +80,7 @@ public:
LaplaceSmoothing(MeshKernel&);
virtual ~LaplaceSmoothing();
void Smooth(unsigned int);
void SmoothPoints(unsigned int, const std::vector<unsigned long>&);
void SmoothPoints(unsigned int, const std::vector<PointIndex>&);
void SetLambda(double l) { lambda = l;}
protected:
@@ -87,7 +88,7 @@ protected:
const MeshRefPointToFacets&, double);
void Umbrella(const MeshRefPointToPoints&,
const MeshRefPointToFacets&, double,
const std::vector<unsigned long>&);
const std::vector<PointIndex>&);
protected:
double lambda;
@@ -99,7 +100,7 @@ public:
TaubinSmoothing(MeshKernel&);
virtual ~TaubinSmoothing();
void Smooth(unsigned int);
void SmoothPoints(unsigned int, const std::vector<unsigned long>&);
void SmoothPoints(unsigned int, const std::vector<PointIndex>&);
void SetMicro(double m) { micro = m;}
protected:
+25 -25
View File
@@ -53,7 +53,7 @@ void MeshSearchNeighbours::Reinit (float fSampleDistance)
MeshAlgorithm(_rclMesh).ResetPointFlag(MeshPoint::MARKED);
}
unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector<Base::Vector3f> &raclResultPoints)
unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector<Base::Vector3f> &raclResultPoints)
{
bool bAddPoints = false;
@@ -82,12 +82,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId
while ((bFound == true) && (nCtExpandRadius < 10)) {
bFound = false;
std::set<unsigned long> aclTmp;
std::set<PointIndex> aclTmp;
aclTmp.swap(_aclOuter);
for (std::set<unsigned long>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<unsigned long> &rclISet = _clPt2Fa[*pI];
for (std::set<FacetIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
// search all facets hanging on this point
for (std::set<unsigned long>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
for (std::set<FacetIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
const MeshFacet &rclF = f_beg[*pJ];
if (rclF.IsFlag(MeshFacet::MARKED) == false) {
@@ -114,14 +114,14 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId
for (std::vector<MeshFacetArray::_TConstIterator>::iterator pF = aclTestedFacet.begin();
pF != aclTestedFacet.end(); ++pF)
(*pF)->ResetFlag(MeshFacet::MARKED);
for (std::set<unsigned long>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
for (std::set<PointIndex>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
_rclPAry[*pR].ResetFlag(MeshPoint::MARKED);
// copy points in result container
raclResultPoints.resize(_aclResult.size());
size_t i = 0;
for (std::set<unsigned long>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
raclResultPoints[i] = _rclPAry[*pI];
if (bAddPoints == true) {
@@ -133,7 +133,7 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId
return ulVisited;
}
void MeshSearchNeighbours::SampleAllFacets (void)
void MeshSearchNeighbours::SampleAllFacets ()
{
if (_aclSampledFacets.size() == _rclMesh.CountFacets())
return; // already sampled, do nothing
@@ -149,7 +149,7 @@ void MeshSearchNeighbours::SampleAllFacets (void)
}
}
unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints)
unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints)
{
SampleAllFacets();
@@ -175,12 +175,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u
while (bFound == true) {
bFound = false;
std::set<unsigned long> aclTmp;
std::set<PointIndex> aclTmp;
aclTmp.swap(_aclOuter);
for (std::set<unsigned long>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<unsigned long> &rclISet = _clPt2Fa[*pI];
for (std::set<PointIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
// search all facets hanging on this point
for (std::set<unsigned long>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
for (std::set<FacetIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
const MeshFacet &rclF = f_beg[*pJ];
if (rclF.IsFlag(MeshFacet::MARKED) == false) {
@@ -203,7 +203,7 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u
std::copy(_aclPointsResult.begin(), _aclPointsResult.end(), raclResultPoints.begin());
// facet points
for (std::set<unsigned long>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI) {
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI) {
if (InnerPoint(_rclPAry[*pI]) == true)
raclResultPoints.push_back(_rclPAry[*pI]);
}
@@ -211,12 +211,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u
return ulVisited;
}
bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, unsigned long ulFIdx)
bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetIndex ulFIdx)
{
int k = 0;
for (int i = 0; i < 3; i++) {
unsigned long ulPIdx = rclF._aulPoints[i];
PointIndex ulPIdx = rclF._aulPoints[i];
_aclOuter.insert(ulPIdx);
_aclResult.insert(ulPIdx);
@@ -251,7 +251,7 @@ bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints)
{
// add facets from current level
_aclResult.insert(_aclOuter.begin(), _aclOuter.end());
for (std::set<unsigned long>::iterator pI = _aclOuter.begin(); pI != _aclOuter.end(); ++pI)
for (std::set<PointIndex>::iterator pI = _aclOuter.begin(); pI != _aclOuter.end(); ++pI)
_rclPAry[*pI].SetFlag(MeshPoint::MARKED);
if (_aclResult.size() < ulMinPoints) {
@@ -262,9 +262,9 @@ bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints)
return false;
}
unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints, std::vector<unsigned long> &raclResultFacets)
unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints, std::vector<FacetIndex> &raclResultFacets)
{
std::set<unsigned long> aulFacetSet;
std::set<FacetIndex> aulFacetSet;
_fMaxDistanceP2 = fDistance * fDistance;
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
@@ -287,12 +287,12 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFa
while (bFound == true) {
bFound = false;
std::set<unsigned long> aclTmp;
std::set<PointIndex> aclTmp;
aclTmp.swap(_aclOuter);
for (std::set<unsigned long>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<unsigned long> &rclISet = _clPt2Fa[*pI];
for (std::set<PointIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
// search all facets hanging on this point
for (std::set<unsigned long>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
for (std::set<PointIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
const MeshFacet &rclF = f_beg[*pJ];
for (int i = 0; i < 3; i++) {
@@ -317,13 +317,13 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFa
// reset marked facets, points
for (std::vector<MeshFacetArray::_TConstIterator>::iterator pF = aclTestedFacet.begin(); pF != aclTestedFacet.end(); ++pF)
(*pF)->ResetFlag(MeshFacet::MARKED);
for (std::set<unsigned long>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
for (std::set<PointIndex>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
_rclPAry[*pR].ResetFlag(MeshPoint::MARKED);
// copy points in result container
raclResultPoints.resize(_aclResult.size());
size_t i = 0;
for (std::set<unsigned long>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
raclResultPoints[i] = _rclPAry[*pI];
// copy facets in result container
+15 -14
View File
@@ -51,18 +51,18 @@ public:
* inside a sphere of radius \a fDistance, center \a center of the original facet. This method uses the
* MARKED flags.
*/
unsigned long NeighboursFromFacet (unsigned long ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector<Base::Vector3f> &raclResultPoints);
unsigned long NeighboursFromFacet (FacetIndex ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector<Base::Vector3f> &raclResultPoints);
/** Searches for facets from the start facet, sample the neighbour facets and accumulates the points. */
unsigned long NeighboursFromSampledFacets (unsigned long ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints);
unsigned long NeighboursFromSampledFacets (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints);
/** Searches for facets from the start facet. */
unsigned long NeighboursFacetFromFacet (unsigned long ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints,
std::vector<unsigned long> &raclResultFacets);
unsigned long NeighboursFacetFromFacet (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints,
std::vector<FacetIndex> &raclResultFacets);
protected:
/** Subsamples the mesh. */
void SampleAllFacets (void);
void SampleAllFacets ();
inline bool CheckDistToFacet (const MeshFacet &rclF); // check distance to facet, add points inner radius
bool AccumulateNeighbours (const MeshFacet &rclF, unsigned long ulFIdx); // accumulate the sample neighbours facet
bool AccumulateNeighbours (const MeshFacet &rclF, FacetIndex ulFIdx); // accumulate the sample neighbours facet
inline bool InnerPoint (const Base::Vector3f &rclPt) const;
inline bool TriangleCutsSphere (const MeshFacet &rclF) const;
bool ExpandRadius (unsigned long ulMinPoints);
@@ -81,8 +81,8 @@ protected:
MeshRefPointToFacets _clPt2Fa;
float _fMaxDistanceP2; // square distance
Base::Vector3f _clCenter; // center points of start facet
std::set<unsigned long> _aclResult; // result container (point indices)
std::set<unsigned long> _aclOuter; // next searching points
std::set<PointIndex> _aclResult; // result container (point indices)
std::set<PointIndex> _aclOuter; // next searching points
std::vector<Base::Vector3f> _aclPointsResult; // result as vertex
std::vector<std::vector<Base::Vector3f> > _aclSampledFacets; // sample points from each facet
float _fSampleDistance; // distance between two sampled points
@@ -100,7 +100,7 @@ inline bool MeshSearchNeighbours::CheckDistToFacet (const MeshFacet &rclF)
for (int i = 0; i < 3; i++)
{
unsigned long ulPIdx = rclF._aulPoints[i];
PointIndex ulPIdx = rclF._aulPoints[i];
if (_rclPAry[ulPIdx].IsFlag(MeshPoint::MARKED) == false)
{
if (Base::DistanceP2(_clCenter, _rclPAry[ulPIdx]) < _fMaxDistanceP2)
@@ -146,7 +146,7 @@ class MeshFaceIterator
public:
MeshFaceIterator(const MeshKernel& mesh)
: it(mesh) {}
Base::Vector3f operator() (unsigned long index)
Base::Vector3f operator() (FacetIndex index)
{
it.Set(index);
return it->GetGravityPoint();
@@ -161,7 +161,7 @@ class MeshVertexIterator
public:
MeshVertexIterator(const MeshKernel& mesh)
: it(mesh) {}
Base::Vector3f operator() (unsigned long index)
Base::Vector3f operator() (PointIndex index)
{
it.Set(index);
return *it;
@@ -175,9 +175,10 @@ template <class T>
class MeshNearestIndexToPlane
{
public:
using Index = typename T::Index;
MeshNearestIndexToPlane(const MeshKernel& mesh, const Base::Vector3f& b, const Base::Vector3f& n)
: nearest_index(ULONG_MAX),nearest_dist(FLOAT_MAX), it(mesh), base(b), normal(n) {}
void operator() (unsigned long index)
: nearest_index(-1),nearest_dist(FLOAT_MAX), it(mesh), base(b), normal(n) {}
void operator() (Index index)
{
float dist = (float)fabs(it(index).DistanceToPlane(base, normal));
if (dist < nearest_dist) {
@@ -186,7 +187,7 @@ public:
}
}
unsigned long nearest_index;
Index nearest_index;
float nearest_dist;
private:
File diff suppressed because it is too large Load Diff
+41 -41
View File
@@ -53,7 +53,7 @@ class MeshExport MeshTopoAlgorithm
public:
// construction/destruction
MeshTopoAlgorithm (MeshKernel &rclM);
virtual ~MeshTopoAlgorithm (void);
virtual ~MeshTopoAlgorithm ();
public:
/** @name Topological Operations */
@@ -63,7 +63,7 @@ public:
* triangles. The given point must lie inside the triangle not outside or on
* an edge.
*/
bool InsertVertex(unsigned long ulFacetPos, const Base::Vector3f& rclPoint);
bool InsertVertex(FacetIndex ulFacetPos, const Base::Vector3f& rclPoint);
/**
* This method is provided for convenience. It inserts a new vertex to the
* mesh and tries to swap the common edges of the newly created facets with
@@ -73,7 +73,7 @@ public:
* edges to build more well-formed triangles.
* @see InsertVertex(), ShouldSwapEdge(), SwapEdge().
*/
bool InsertVertexAndSwapEdge(unsigned long ulFacetPos, const Base::Vector3f& rclPoint,
bool InsertVertexAndSwapEdge(FacetIndex ulFacetPos, const Base::Vector3f& rclPoint,
float fMaxAngle);
/**
* Swaps the common edge of two adjacent facets even if the operation might
@@ -83,7 +83,7 @@ public:
* facets or it might create a fold on the surface, i.e. geometric overlaps
* of several triangles.
*/
void SwapEdge(unsigned long ulFacetPos, unsigned long ulNeighbour);
void SwapEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour);
/**
* Splits the common edge of the two adjacent facets with index \a ulFacetPos
* and \a ulNeighbour. The point \a rP must lie inside of one the given facets
@@ -91,7 +91,7 @@ public:
* that two new facets get created. If \a rP is coincident with a corner point
* nothing happens.
*/
bool SplitEdge(unsigned long ulFacetPos, unsigned long ulNeighbour,
bool SplitEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour,
const Base::Vector3f& rP);
/**
* Splits the facet with index \a ulFacetPos on the edge side \a uSide into
@@ -99,7 +99,7 @@ public:
* point \a rP must be near to this edge and must not be coincident with any
* corner vertices of the facet.
*/
void SplitOpenEdge(unsigned long ulFacetPos, unsigned short uSide,
void SplitOpenEdge(FacetIndex ulFacetPos, unsigned short uSide,
const Base::Vector3f& rP);
/**
* Splits the facet with index \a ulFacetPos into up to three facets. The points
@@ -109,7 +109,7 @@ public:
* is coincident with a corner point then the facet is split into two facets.
* If both points are coincident with corner points of this facet nothing is done.
*/
void SplitFacet(unsigned long ulFacetPos, const Base::Vector3f& rP1,
void SplitFacet(FacetIndex ulFacetPos, const Base::Vector3f& rP1,
const Base::Vector3f& rP2);
/**
* Collapse a vertex. At the moment only removing inner vertexes referenced
@@ -144,7 +144,7 @@ public:
* @note While the mesh structure has invalid elements the client programmer
* must take care not to use such elements.
*/
bool CollapseEdge(unsigned long ulFacetPos, unsigned long ulNeighbour);
bool CollapseEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour);
/**
* Convenience function that passes already all needed information.
*/
@@ -166,7 +166,7 @@ public:
* @note While the mesh structure has invalid elements the client programmer
* must take care not to use such elements.
*/
bool CollapseFacet(unsigned long ulFacetPos);
bool CollapseFacet(FacetIndex ulFacetPos);
//@}
/** @name Topological Optimization */
@@ -209,24 +209,24 @@ public:
* make sure that no overlaps are created.
* @note This operation might be useful to close gaps in a mesh.
*/
bool SnapVertex(unsigned long ulFacetPos, const Base::Vector3f& rP);
bool SnapVertex(FacetIndex ulFacetPos, const Base::Vector3f& rP);
/**
* Checks whether a swap edge operation is legal, that is fulfilled if the
* two adjacent facets builds a convex polygon. If this operation is legal
* true is returned, false is returned if this operation is illegal or if
* \a ulFacetPos and \a ulNeighbour are not adjacent facets.
*/
bool IsSwapEdgeLegal(unsigned long ulFacetPos, unsigned long ulNeighbour) const;
bool IsSwapEdgeLegal(FacetIndex ulFacetPos, FacetIndex ulNeighbour) const;
/**
* Checks whether the swap edge operation is legal and whether it makes
* sense. This operation only makes sense if the maximum angle of both
* facets is decreased and if the angle between the facet normals does
* not exceed \a fMaxAngle.
*/
bool ShouldSwapEdge(unsigned long ulFacetPos, unsigned long ulNeighbour,
bool ShouldSwapEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour,
float fMaxAngle) const;
/** Computes a value for the benefit of swapping the edge. */
float SwapEdgeBenefit(unsigned long f, int e) const;
float SwapEdgeBenefit(FacetIndex f, int e) const;
/**
* Removes all invalid marked elements from the mesh structure.
*/
@@ -235,12 +235,12 @@ public:
* Removes the degenerated facet at position \a index from the mesh structure.
* A facet is degenerated if its corner points are collinear.
*/
void RemoveDegeneratedFacet(unsigned long index);
bool RemoveDegeneratedFacet(FacetIndex index);
/**
* Removes the corrupted facet at position \a index from the mesh structure.
* A facet is corrupted if the indices of its corner points are not all different.
*/
bool RemoveCorruptedFacet(unsigned long index);
bool RemoveCorruptedFacet(FacetIndex index);
/**
* Closes holes in the mesh that consists of up to \a length edges. In case a fit
* needs to be done then the points of the neighbours of \a level rings will be used.
@@ -248,24 +248,24 @@ public:
*/
void FillupHoles(unsigned long length, int level,
AbstractPolygonTriangulator&,
std::list<std::vector<unsigned long> >& aFailed);
std::list<std::vector<PointIndex> >& aFailed);
/**
* This is an overloaded method provided for convenience. It takes as first argument
* the boundaries which must be filled up.
*/
void FillupHoles(int level, AbstractPolygonTriangulator&,
const std::list<std::vector<unsigned long> >& aBorders,
std::list<std::vector<unsigned long> >& aFailed);
const std::list<std::vector<PointIndex> >& aBorders,
std::list<std::vector<PointIndex> >& aFailed);
/**
* Find holes which consists of up to \a length edges.
*/
void FindHoles(unsigned long length,
std::list<std::vector<unsigned long> >& aBorders) const;
std::list<std::vector<PointIndex> >& aBorders) const;
/**
* Find topologic independent components with maximum \a count facets
* and returns an array of the indices.
*/
void FindComponents(unsigned long count, std::vector<unsigned long>& aInds);
void FindComponents(unsigned long count, std::vector<FacetIndex>& aInds);
/**
* Removes topologic independent components with maximum \a count facets.
*/
@@ -273,11 +273,11 @@ public:
/**
* Harmonizes the normals.
*/
void HarmonizeNormals (void);
void HarmonizeNormals ();
/**
* Flips the normals.
*/
void FlipNormals (void);
void FlipNormals ();
/**
* Caching facility.
*/
@@ -288,28 +288,28 @@ private:
/**
* Splits the neighbour facet of \a ulFacetPos on side \a uSide.
*/
void SplitNeighbourFacet(unsigned long ulFacetPos, unsigned short uSide,
void SplitNeighbourFacet(FacetIndex ulFacetPos, unsigned short uSide,
const Base::Vector3f rPoint);
void SplitFacetOnOneEdge(unsigned long ulFacetPos,
void SplitFacetOnOneEdge(FacetIndex ulFacetPos,
const Base::Vector3f& rP1);
void SplitFacetOnTwoEdges(unsigned long ulFacetPos,
void SplitFacetOnTwoEdges(FacetIndex ulFacetPos,
const Base::Vector3f& rP1,
const Base::Vector3f& rP2);
void SplitFacet(unsigned long ulFacetPos, unsigned long P1,
unsigned long P2, unsigned long Pn);
void AddFacet(unsigned long P1, unsigned long P2, unsigned long P3);
void AddFacet(unsigned long P1, unsigned long P2, unsigned long P3,
unsigned long N1, unsigned long N2, unsigned long N3);
void HarmonizeNeighbours(unsigned long facet1, unsigned long facet2);
void HarmonizeNeighbours(const std::vector<unsigned long>& ulFacets);
void SplitFacet(FacetIndex ulFacetPos, PointIndex P1,
PointIndex P2, PointIndex Pn);
void AddFacet(PointIndex P1, PointIndex P2, PointIndex P3);
void AddFacet(PointIndex P1, PointIndex P2, PointIndex P3,
FacetIndex N1, FacetIndex N2, FacetIndex N3);
void HarmonizeNeighbours(FacetIndex facet1, FacetIndex facet2);
void HarmonizeNeighbours(const std::vector<FacetIndex>& ulFacets);
/**
* Returns all facets that references the point index \a uPointPos. \a uFacetPos
* is a facet that must reference this point and is added to the list as well.
*/
std::vector<unsigned long> GetFacetsToPoint(unsigned long uFacetPos,
unsigned long uPointPos) const;
std::vector<FacetIndex> GetFacetsToPoint(FacetIndex uFacetPos,
PointIndex uPointPos) const;
/** \internal */
unsigned long GetOrAddIndex (const MeshPoint &rclPoint);
PointIndex GetOrAddIndex (const MeshPoint &rclPoint);
private:
MeshKernel& _rclMesh;
@@ -321,7 +321,7 @@ private:
};
// cache
typedef std::map<Base::Vector3f,unsigned long,Vertex_Less> tCache;
typedef std::map<Base::Vector3f,PointIndex,Vertex_Less> tCache;
tCache* _cache;
};
@@ -344,21 +344,21 @@ public:
* sharing the same edge are regarded as connected, if \a tMode is \a OverPoint
* then facets sharing a common point are regarded as connected.
*/
void SearchForComponents(TMode tMode, std::vector<std::vector<unsigned long> >& aclT) const;
void SearchForComponents(TMode tMode, std::vector<std::vector<FacetIndex> >& aclT) const;
/**
* Does basically the same as the method above escept that only the faces in
* \a aSegment are regarded.
*/
void SearchForComponents(TMode tMode, const std::vector<unsigned long>& aSegment,
std::vector<std::vector<unsigned long> >& aclT) const;
void SearchForComponents(TMode tMode, const std::vector<FacetIndex>& aSegment,
std::vector<std::vector<FacetIndex> >& aclT) const;
protected:
// for sorting of elements
struct CNofFacetsCompare
{
bool operator () (const std::vector<unsigned long> &rclC1,
const std::vector<unsigned long> &rclC2)
bool operator () (const std::vector<FacetIndex> &rclC1,
const std::vector<FacetIndex> &rclC2)
{
return rclC1.size() > rclC2.size();
}
+22 -22
View File
@@ -253,7 +253,7 @@ bool AbstractPolygonTriangulator::TriangulatePolygon()
}
}
std::vector<unsigned long> AbstractPolygonTriangulator::GetInfo() const
std::vector<PointIndex> AbstractPolygonTriangulator::GetInfo() const
{
return _info;
}
@@ -292,7 +292,7 @@ bool EarClippingTriangulator::Triangulate()
_triangles.clear();
std::vector<Base::Vector3f> pts = ProjectToFitPlane();
std::vector<unsigned long> result;
std::vector<PointIndex> result;
// Invoke the triangulator to triangulate this polygon.
Triangulate::Process(pts,result);
@@ -306,7 +306,7 @@ bool EarClippingTriangulator::Triangulate()
MeshGeomFacet clFacet;
MeshFacet clTopFacet;
for (unsigned long i=0; i<tcount; i++) {
for (size_t i=0; i<tcount; i++) {
if (Triangulate::_invert) {
clFacet._aclPoints[0] = _points[result[i*3+0]];
clFacet._aclPoints[2] = _points[result[i*3+1]];
@@ -398,7 +398,7 @@ bool EarClippingTriangulator::Triangulate::Snip(const std::vector<Base::Vector3f
bool EarClippingTriangulator::Triangulate::_invert = false;
bool EarClippingTriangulator::Triangulate::Process(const std::vector<Base::Vector3f> &contour,
std::vector<unsigned long> &result)
std::vector<PointIndex> &result)
{
/* allocate and initialize list of Vertices in polygon */
@@ -483,30 +483,30 @@ bool QuasiDelaunayTriangulator::Triangulate()
// For each internal edge get the adjacent facets. When doing an edge swap we must update
// this structure.
std::map<std::pair<unsigned long, unsigned long>, std::vector<unsigned long> > aEdge2Face;
std::map<std::pair<PointIndex, PointIndex>, std::vector<FacetIndex> > aEdge2Face;
for (std::vector<MeshFacet>::iterator pI = _facets.begin(); pI != _facets.end(); ++pI) {
for (int i = 0; i < 3; i++) {
unsigned long ulPt0 = std::min<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
PointIndex ulPt0 = std::min<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
PointIndex ulPt1 = std::max<PointIndex>(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]);
// ignore borderlines of the polygon
if ((ulPt1-ulPt0)%(_points.size()-1) > 1)
aEdge2Face[std::pair<unsigned long, unsigned long>(ulPt0, ulPt1)].push_back(pI - _facets.begin());
aEdge2Face[std::pair<PointIndex, PointIndex>(ulPt0, ulPt1)].push_back(pI - _facets.begin());
}
}
// fill up this list with all internal edges and perform swap edges until this list is empty
std::list<std::pair<unsigned long, unsigned long> > aEdgeList;
std::map<std::pair<unsigned long, unsigned long>, std::vector<unsigned long> >::iterator pE;
std::list<std::pair<PointIndex, PointIndex> > aEdgeList;
std::map<std::pair<PointIndex, PointIndex>, std::vector<FacetIndex> >::iterator pE;
for (pE = aEdge2Face.begin(); pE != aEdge2Face.end(); ++pE)
aEdgeList.push_back(pE->first);
// to be sure to avoid an endless loop
unsigned long uMaxIter = 5 * aEdge2Face.size();
size_t uMaxIter = 5 * aEdge2Face.size();
// Perform a swap edge where needed
while (!aEdgeList.empty() && uMaxIter > 0) {
// get the first edge and remove it from the list
std::pair<unsigned long, unsigned long> aEdge = aEdgeList.front();
std::pair<PointIndex, PointIndex> aEdge = aEdgeList.front();
aEdgeList.pop_front();
uMaxIter--;
@@ -556,10 +556,10 @@ bool QuasiDelaunayTriangulator::Triangulate()
// adjust the edge list
for (int i=0; i<3; i++) {
std::map<std::pair<unsigned long, unsigned long>, std::vector<unsigned long> >::iterator it;
std::map<std::pair<PointIndex, PointIndex>, std::vector<FacetIndex> >::iterator it;
// first facet
unsigned long ulPt0 = std::min<unsigned long>(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]);
PointIndex ulPt0 = std::min<PointIndex>(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]);
PointIndex ulPt1 = std::max<PointIndex>(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]);
it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) );
if (it != aEdge2Face.end()) {
if (it->second[0] == pE->second[1])
@@ -570,8 +570,8 @@ bool QuasiDelaunayTriangulator::Triangulate()
}
// second facet
ulPt0 = std::min<unsigned long>(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]);
ulPt1 = std::max<unsigned long>(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]);
ulPt0 = std::min<PointIndex>(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]);
ulPt1 = std::max<PointIndex>(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]);
it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) );
if (it != aEdge2Face.end()) {
if (it->second[0] == pE->second[0])
@@ -583,9 +583,9 @@ bool QuasiDelaunayTriangulator::Triangulate()
}
// Now we must remove the edge and replace it through the new edge
unsigned long ulPt0 = std::min<unsigned long>(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]);
std::pair<unsigned long, unsigned long> aNewEdge = std::make_pair(ulPt0, ulPt1);
PointIndex ulPt0 = std::min<PointIndex>(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]);
PointIndex ulPt1 = std::max<PointIndex>(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]);
std::pair<PointIndex, PointIndex> aNewEdge = std::make_pair(ulPt0, ulPt1);
aEdge2Face[aNewEdge] = pE->second;
aEdge2Face.erase(pE);
}
@@ -664,7 +664,7 @@ bool DelaunayTriangulator::Triangulate()
// then the triangulation must have 2*N-2-H triangles and 3*N-3-H
// edges.
int iEQuantity = 0;
int* aiIndex = 0;
int* aiIndex = nullptr;
del.GetHull(iEQuantity,aiIndex);
int iUniqueVQuantity = del.GetUniqueVertexQuantity();
int iTVerify = 2*iUniqueVQuantity - 2 - iEQuantity;
@@ -680,7 +680,7 @@ bool DelaunayTriangulator::Triangulate()
for (int i = 0; i < iTQuantity; i++) {
for (int j=0; j<3; j++) {
size_t index = static_cast<size_t>(aiTVertex[static_cast<size_t>(3*i+j)]);
facet._aulPoints[j] = static_cast<unsigned long>(index);
facet._aulPoints[j] = static_cast<PointIndex>(index);
triangle._aclPoints[j].x = static_cast<float>(akVertex[index].X());
triangle._aclPoints[j].y = static_cast<float>(akVertex[index].Y());
}
+5 -5
View File
@@ -63,7 +63,7 @@ public:
/** Sets the polygon to be triangulated. */
void SetPolygon(const std::vector<Base::Vector3f>& raclPoints);
void SetIndices(const std::vector<unsigned long>& d) {_indices = d;}
void SetIndices(const std::vector<PointIndex>& d) {_indices = d;}
/** Set a verifier object that checks if the generated triangulation
* can be accepted and added to the mesh kernel.
* The triangulator takes ownership of the passed verifier.
@@ -117,7 +117,7 @@ public:
* It returns an array of the number of edges for each closed
* polygon.
*/
std::vector<unsigned long> GetInfo() const;
std::vector<PointIndex> GetInfo() const;
virtual void Discard();
/** Resets some internals. The default implementation does nothing.*/
virtual void Reset();
@@ -132,12 +132,12 @@ protected:
protected:
bool _discard;
Base::Matrix4D _inverse;
std::vector<unsigned long> _indices;
std::vector<PointIndex> _indices;
std::vector<Base::Vector3f> _points;
std::vector<Base::Vector3f> _newpoints;
std::vector<MeshGeomFacet> _triangles;
std::vector<MeshFacet> _facets;
std::vector<unsigned long> _info;
std::vector<PointIndex> _info;
TriangulationVerifier* _verifier;
};
@@ -170,7 +170,7 @@ private:
// triangulate a contour/polygon, places results in STL vector
// as series of triangles.indicating the points
static bool Process(const std::vector<Base::Vector3f> &contour,
std::vector<unsigned long> &result);
std::vector<PointIndex> &result);
// compute area of a contour/polygon
static float Area(const std::vector<Base::Vector3f> &contour);
+16 -18
View File
@@ -53,16 +53,16 @@ void MeshTrimming::SetInnerOrOuter(TMode tMode)
}
}
void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector<unsigned long> &raulFacets) const
void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector<FacetIndex> &raulFacets) const
{
std::vector<unsigned long>::iterator it;
std::vector<FacetIndex>::iterator it;
MeshFacetIterator clIter(myMesh, 0);
// cut inner: use grid to accelerate search
if (myInner) {
Base::BoundBox3f clBBox3d;
Base::BoundBox2d clViewBBox, clPolyBBox;
std::vector<unsigned long> aulAllElements;
std::vector<FacetIndex> aulAllElements;
// BBox of polygon
clPolyBBox = myPoly.CalcBoundBox();
@@ -103,13 +103,11 @@ void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector<unsigne
bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const
{
size_t i;
unsigned long j;
Base::Polygon2d clPoly;
Base::Line2d clFacLine, clPolyLine;
Base::Vector2d S;
// is corner of facet inside the polygon
for (i=0; i<3; i++) {
for (size_t i=0; i<3; i++) {
Base::Vector3f clPt2d = myProj->operator ()(rclFacet._aclPoints[i]);
if (myPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == myInner)
return true;
@@ -118,17 +116,17 @@ bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const
}
// is corner of polygon inside the facet
for (j=0; j<myPoly.GetCtVectors(); j++) {
for (size_t j=0; j<myPoly.GetCtVectors(); j++) {
if (clPoly.Contains(myPoly[j]))
return true;
}
// check for other intersections
for (j=0; j<myPoly.GetCtVectors(); j++) {
for (size_t j=0; j<myPoly.GetCtVectors(); j++) {
clPolyLine.clV1 = myPoly[j];
clPolyLine.clV2 = myPoly[(j+1)%myPoly.GetCtVectors()];
for (i=0; i<3; i++) {
for (size_t i=0; i<3; i++) {
clFacLine.clV1 = clPoly[i];
clFacLine.clV2 = clPoly[(i+1)%3];
@@ -141,7 +139,7 @@ bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const
return false;
}
bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulIndex) const
bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, FacetIndex ulIndex) const
{
const MeshFacet &rclFacet = myMesh._aclFacetArray[ulIndex];
for (int i=0; i<3; i++) {
@@ -154,7 +152,7 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulInd
return true;
}
bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& clPoint)
bool MeshTrimming::IsPolygonPointInFacet(FacetIndex ulIndex, Base::Vector3f& clPoint)
{
Base::Vector2d A, B, C, P;
float u,v,w, fDetPAC, fDetPBC, fDetPAB, fDetABC;
@@ -171,7 +169,7 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f&
C = clFacPoly[2];
fDetABC = static_cast<float>(A.x*B.y+A.y*C.x+B.x*C.y-(B.y*C.x+A.y*B.x+A.x*C.y));
for (unsigned long j=0; j<myPoly.GetCtVectors(); j++) {
for (size_t j=0; j<myPoly.GetCtVectors(); j++) {
// facet contains a polygon point -> calculate the corresponding 3d-point
if (clFacPoly.Contains(myPoly[j])) {
P = myPoly[j];
@@ -195,7 +193,7 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f&
return false;
}
bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide, std::vector<Base::Vector3f>& raclPoints) const
bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(FacetIndex ulIndex, int& iSide, std::vector<Base::Vector3f>& raclPoints) const
{
MeshGeomFacet clFac(myMesh.GetFacet(ulIndex));
Base::Vector2d S;
@@ -206,7 +204,7 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex,
// Edge with no intersection
iSide = -1;
for (unsigned long i=0; i<myPoly.GetCtVectors(); i++) {
for (size_t i=0; i<myPoly.GetCtVectors(); i++) {
// totally only four intersections allowed
if (iIntersections == 4)
break;
@@ -335,7 +333,7 @@ void MeshTrimming::AdjustFacet(MeshFacet& facet, int iInd)
}
}
bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints, std::vector<MeshGeomFacet>& aclNewFacets)
bool MeshTrimming::CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints, std::vector<MeshGeomFacet>& aclNewFacets)
{
MeshGeomFacet clFac;
@@ -603,7 +601,7 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
return true;
}
bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints, Base::Vector3f& clP3,
bool MeshTrimming::CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints, Base::Vector3f& clP3,
std::vector<MeshGeomFacet>& aclNewFacets)
{
// no valid triangulation possible
@@ -716,14 +714,14 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
return true;
}
void MeshTrimming::TrimFacets(const std::vector<unsigned long>& raulFacets, std::vector<MeshGeomFacet>& aclNewFacets)
void MeshTrimming::TrimFacets(const std::vector<FacetIndex>& raulFacets, std::vector<MeshGeomFacet>& aclNewFacets)
{
Base::Vector3f clP;
std::vector<Base::Vector3f> clIntsct;
int iSide;
Base::SequencerLauncher seq("trimming facets...", raulFacets.size());
for (std::vector<unsigned long>::const_iterator it=raulFacets.begin(); it!=raulFacets.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it=raulFacets.begin(); it!=raulFacets.end(); ++it) {
clIntsct.clear();
if (IsPolygonPointInFacet(*it, clP) == false) {
// facet must be trimmed
+7 -7
View File
@@ -46,12 +46,12 @@ public:
/**
* Checks all facets for intersection with the polygon and writes all touched facets into the vector
*/
void CheckFacets(const MeshFacetGrid& rclGrid, std::vector<unsigned long>& raulFacets) const;
void CheckFacets(const MeshFacetGrid& rclGrid, std::vector<FacetIndex>& raulFacets) const;
/**
* The facets from raulFacets will be trimmed or deleted and aclNewFacets gives the new generated facets
*/
void TrimFacets(const std::vector<unsigned long>& raulFacets, std::vector<MeshGeomFacet>& aclNewFacets);
void TrimFacets(const std::vector<FacetIndex>& raulFacets, std::vector<MeshGeomFacet>& aclNewFacets);
/**
* Setter: Trimm INNER or OUTER
@@ -67,30 +67,30 @@ private:
/**
* Checks if a facet lies totally within a polygon
*/
bool PolygonContainsCompleteFacet(bool bInner, unsigned long ulIndex) const;
bool PolygonContainsCompleteFacet(bool bInner, FacetIndex ulIndex) const;
/**
* Creates new facets from edge points of the facet
*/
bool CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints,
bool CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints,
std::vector<MeshGeomFacet>& aclNewFacets);
/**
* Creates new facets from edge points of the facet and a point inside the facet
*/
bool CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints,
bool CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector<Base::Vector3f>& raclPoints,
Base::Vector3f& clP3, std::vector<MeshGeomFacet>& aclNewFacets);
/**
* Checks if a polygon point lies within a facet
*/
bool IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& clPoint);
bool IsPolygonPointInFacet(FacetIndex ulIndex, Base::Vector3f& clPoint);
/**
* Calculates the two intersection points between polygonline and facet in 2D
* and project the points back into 3D (not very exactly)
*/
bool GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide,
bool GetIntersectionPointsOfPolygonAndFacet(FacetIndex ulIndex, int& iSide,
std::vector<Base::Vector3f>& raclPoints) const;
void AdjustFacet(MeshFacet& facet, int iInd);
+3 -3
View File
@@ -39,12 +39,12 @@ MeshTrimByPlane::~MeshTrimByPlane()
}
void MeshTrimByPlane::CheckFacets(const MeshFacetGrid& rclGrid, const Base::Vector3f& base, const Base::Vector3f& normal,
std::vector<unsigned long> &trimFacets, std::vector<unsigned long>& removeFacets) const
std::vector<FacetIndex> &trimFacets, std::vector<FacetIndex>& removeFacets) const
{
// Go through the grid and check for each cell if its bounding box intersects the plane.
// If the box is completely below the plane all facets will be kept, if it's above the
// plane all triangles will be removed.
std::vector<unsigned long> checkElements;
std::vector<FacetIndex> checkElements;
MeshGridIterator clGridIter(rclGrid);
for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) {
Base::BoundBox3f clBBox3d = clGridIter.GetBoundBox();
@@ -134,7 +134,7 @@ void MeshTrimByPlane::CreateTwoFacet(const Base::Vector3f& base, const Base::Vec
trimmedFacets.push_back(create);
}
void MeshTrimByPlane::TrimFacets(const std::vector<unsigned long>& trimFacets, const Base::Vector3f& base,
void MeshTrimByPlane::TrimFacets(const std::vector<FacetIndex>& trimFacets, const Base::Vector3f& base,
const Base::Vector3f& normal, std::vector<MeshGeomFacet>& trimmedFacets)
{
trimmedFacets.reserve(2 * trimFacets.size());
+2 -2
View File
@@ -43,12 +43,12 @@ public:
* Checks all facets for intersection with the plane and writes all touched facets into the vector
*/
void CheckFacets(const MeshFacetGrid& rclGrid, const Base::Vector3f& base, const Base::Vector3f& normal,
std::vector<unsigned long>& trimFacets, std::vector<unsigned long>& removeFacets) const;
std::vector<FacetIndex>& trimFacets, std::vector<FacetIndex>& removeFacets) const;
/**
* The facets from \a trimFacets will be trimmed or deleted and \a trimmedFacets holds the newly generated facets
*/
void TrimFacets(const std::vector<unsigned long>& trimFacets, const Base::Vector3f& base,
void TrimFacets(const std::vector<FacetIndex>& trimFacets, const Base::Vector3f& base,
const Base::Vector3f& normal, std::vector<MeshGeomFacet>& trimmedFacets);
private:
+22 -22
View File
@@ -31,12 +31,12 @@
using namespace MeshCore;
unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const
unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const
{
unsigned long ulVisited = 0, j, ulLevel = 0;
unsigned long ulCount = _aclFacetArray.size();
std::vector<unsigned long> clCurrentLevel, clNextLevel;
std::vector<unsigned long>::iterator clCurrIter;
std::vector<FacetIndex> clCurrentLevel, clNextLevel;
std::vector<FacetIndex>::iterator clCurrIter;
MeshFacetArray::_TConstIterator clCurrFacet, clNBFacet;
// pick up start point
@@ -52,7 +52,7 @@ unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, u
// visit all neighbours of the current level if not yet done
for (unsigned short i = 0; i < 3; i++) {
j = clCurrFacet->_aulNeighbours[i]; // index to neighbour facet
if (j == ULONG_MAX)
if (j == FACET_INDEX_MAX)
continue; // no neighbour facet
if (j >= ulCount)
@@ -83,28 +83,28 @@ unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, u
return ulVisited;
}
unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const
unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const
{
unsigned long ulVisited = 0, ulLevel = 0;
MeshRefPointToFacets clRPF(*this);
const MeshFacetArray& raclFAry = _aclFacetArray;
MeshFacetArray::_TConstIterator pFBegin = raclFAry.begin();
std::vector<unsigned long> aclCurrentLevel, aclNextLevel;
std::vector<FacetIndex> aclCurrentLevel, aclNextLevel;
aclCurrentLevel.push_back(ulStartFacet);
raclFAry[ulStartFacet].SetFlag(MeshFacet::VISIT);
while (aclCurrentLevel.size() > 0) {
// visit all neighbours of the current level
for (std::vector<unsigned long>::iterator pCurrFacet = aclCurrentLevel.begin(); pCurrFacet < aclCurrentLevel.end(); ++pCurrFacet) {
for (std::vector<FacetIndex>::iterator pCurrFacet = aclCurrentLevel.begin(); pCurrFacet < aclCurrentLevel.end(); ++pCurrFacet) {
for (int i = 0; i < 3; i++) {
const MeshFacet &rclFacet = raclFAry[*pCurrFacet];
const std::set<unsigned long>& raclNB = clRPF[rclFacet._aulPoints[i]];
for (std::set<unsigned long>::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) {
const std::set<FacetIndex>& raclNB = clRPF[rclFacet._aulPoints[i]];
for (std::set<FacetIndex>::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) {
if (pFBegin[*pINb].IsFlag(MeshFacet::VISIT) == false) {
// only visit if VISIT Flag not set
ulVisited++;
unsigned long ulFInd = *pINb;
FacetIndex ulFInd = *pINb;
aclNextLevel.push_back(ulFInd);
pFBegin[*pINb].SetFlag(MeshFacet::VISIT);
if (rclFVisitor.Visit(pFBegin[*pINb], raclFAry[*pCurrFacet], ulFInd, ulLevel) == false)
@@ -121,11 +121,11 @@ unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rcl
return ulVisited;
}
unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, unsigned long ulStartPoint) const
unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, PointIndex ulStartPoint) const
{
unsigned long ulVisited = 0, ulLevel = 0;
std::vector<unsigned long> aclCurrentLevel, aclNextLevel;
std::vector<unsigned long>::iterator clCurrIter;
std::vector<PointIndex> aclCurrentLevel, aclNextLevel;
std::vector<PointIndex>::iterator clCurrIter;
MeshPointArray::_TConstIterator pPBegin = _aclPointArray.begin();
MeshRefPointToPoints clNPs(*this);
@@ -135,12 +135,12 @@ unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, u
while (aclCurrentLevel.size() > 0) {
// visit all neighbours of the current level
for (clCurrIter = aclCurrentLevel.begin(); clCurrIter < aclCurrentLevel.end(); ++clCurrIter) {
const std::set<unsigned long>& raclNB = clNPs[*clCurrIter];
for (std::set<unsigned long>::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) {
const std::set<PointIndex>& raclNB = clNPs[*clCurrIter];
for (std::set<PointIndex>::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) {
if (pPBegin[*pINb].IsFlag(MeshPoint::VISIT) == false) {
// only visit if VISIT Flag not set
ulVisited++;
unsigned long ulPInd = *pINb;
PointIndex ulPInd = *pINb;
aclNextLevel.push_back(ulPInd);
pPBegin[*pINb].SetFlag(MeshPoint::VISIT);
if (rclPVisitor.Visit(pPBegin[*pINb], *(pPBegin + (*clCurrIter)), ulPInd, ulLevel) == false)
@@ -160,7 +160,7 @@ unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, u
MeshSearchNeighbourFacetsVisitor::MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh,
float fRadius,
unsigned long ulStartFacetIdx)
FacetIndex ulStartFacetIdx)
: _rclMeshBase(rclMesh),
_clCenter(rclMesh.GetFacet(ulStartFacetIdx).GetGravityPoint()),
_fRadius(fRadius),
@@ -169,7 +169,7 @@ MeshSearchNeighbourFacetsVisitor::MeshSearchNeighbourFacetsVisitor (const MeshKe
{
}
std::vector<unsigned long> MeshSearchNeighbourFacetsVisitor::GetAndReset (void)
std::vector<FacetIndex> MeshSearchNeighbourFacetsVisitor::GetAndReset ()
{
MeshAlgorithm(_rclMeshBase).ResetFacetsFlag(_vecFacets, MeshFacet::VISIT);
return _vecFacets;
@@ -177,8 +177,8 @@ std::vector<unsigned long> MeshSearchNeighbourFacetsVisitor::GetAndReset (void)
// -------------------------------------------------------------------------
MeshPlaneVisitor::MeshPlaneVisitor (const MeshKernel& mesh, unsigned long index,
float deviation, std::vector<unsigned long> &indices)
MeshPlaneVisitor::MeshPlaneVisitor (const MeshKernel& mesh, FacetIndex index,
float deviation, std::vector<FacetIndex> &indices)
: mesh(mesh), indices(indices), max_deviation(deviation), fitter(new PlaneFit)
{
MeshGeomFacet triangle = mesh.GetFacet(index);
@@ -195,7 +195,7 @@ MeshPlaneVisitor::~MeshPlaneVisitor ()
}
bool MeshPlaneVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&,
unsigned long, unsigned long, unsigned short)
FacetIndex, unsigned long, unsigned short)
{
if (!fitter->Done())
fitter->Fit();
@@ -208,7 +208,7 @@ bool MeshPlaneVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&,
}
bool MeshPlaneVisitor::Visit (const MeshFacet & face, const MeshFacet &,
unsigned long ulFInd, unsigned long)
FacetIndex ulFInd, unsigned long)
{
MeshGeomFacet triangle = mesh.GetFacet(face);
indices.push_back(ulFInd);
+17 -19
View File
@@ -24,9 +24,7 @@
#ifndef VISITOR_H
#define VISITOR_H
#ifndef MESH_GLOBAL_H
#include <Mod/Mesh/MeshGlobal.h>
#endif
#include "Definitions.h"
namespace MeshCore {
@@ -53,14 +51,14 @@ public:
* If \a true is returned the next iteration is done if there are still facets to visit.
* If \a false is returned the calling method stops immediately visiting further facets.
*/
virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd,
virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd,
unsigned long ulLevel) = 0;
/** Test before a facet will be flagged as VISIT, return false means: go on with
* visiting the facets but not this one and set not the VISIT flag
*/
virtual bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom,
unsigned long ulFInd, unsigned long ulLevel,
FacetIndex ulFInd, unsigned long ulLevel,
unsigned short neighbourIndex)
{
(void)rclFacet;
@@ -78,12 +76,12 @@ public:
class MeshExport MeshSearchNeighbourFacetsVisitor : public MeshFacetVisitor
{
public:
MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, unsigned long ulStartFacetIdx);
MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, FacetIndex ulStartFacetIdx);
virtual ~MeshSearchNeighbourFacetsVisitor () {}
/** Checks the facet if it lies inside the search radius. */
inline bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel);
inline bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd, unsigned long ulLevel);
/** Resets the VISIT flag of already visited facets. */
inline std::vector<unsigned long> GetAndReset (void);
inline std::vector<FacetIndex> GetAndReset ();
protected:
const MeshKernel& _rclMeshBase; /**< The mesh kernel. */
@@ -91,11 +89,11 @@ protected:
float _fRadius; /**< Search radius. */
unsigned long _ulCurrentLevel;
bool _bFacetsFoundInCurrentLevel;
std::vector<unsigned long> _vecFacets; /**< Found facets. */
std::vector<FacetIndex> _vecFacets; /**< Found facets. */
};
inline bool MeshSearchNeighbourFacetsVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long ulLevel)
FacetIndex ulFInd, unsigned long ulLevel)
{
(void)rclFrom;
if (ulLevel > _ulCurrentLevel) {
@@ -122,11 +120,11 @@ inline bool MeshSearchNeighbourFacetsVisitor::Visit (const MeshFacet &rclFacet,
class MeshExport MeshTopFacetVisitor : public MeshFacetVisitor
{
public:
MeshTopFacetVisitor (std::vector<unsigned long> &raulNB) : _raulNeighbours(raulNB) {}
MeshTopFacetVisitor (std::vector<FacetIndex> &raulNB) : _raulNeighbours(raulNB) {}
virtual ~MeshTopFacetVisitor () {}
/** Collects the facet indices. */
virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
unsigned long ulFInd, unsigned long)
FacetIndex ulFInd, unsigned long)
{
(void)rclFacet;
(void)rclFrom;
@@ -135,7 +133,7 @@ public:
}
protected:
std::vector<unsigned long> &_raulNeighbours; /**< Indices of all visited facets. */
std::vector<FacetIndex> &_raulNeighbours; /**< Indices of all visited facets. */
};
// -------------------------------------------------------------------------
@@ -148,18 +146,18 @@ class MeshPlaneVisitor : public MeshFacetVisitor
{
public:
MeshPlaneVisitor (const MeshKernel& mesh,
unsigned long index,
FacetIndex index,
float deviation,
std::vector<unsigned long> &indices);
std::vector<FacetIndex> &indices);
virtual ~MeshPlaneVisitor ();
bool AllowVisit (const MeshFacet& face, const MeshFacet&,
unsigned long, unsigned long, unsigned short neighbourIndex);
FacetIndex, unsigned long, unsigned short neighbourIndex);
bool Visit (const MeshFacet & face, const MeshFacet &,
unsigned long ulFInd, unsigned long);
FacetIndex ulFInd, unsigned long);
protected:
const MeshKernel& mesh;
std::vector<unsigned long> &indices;
std::vector<FacetIndex> &indices;
Base::Vector3f basepoint;
Base::Vector3f normal;
float max_deviation;
@@ -185,7 +183,7 @@ public:
* \a false is returned the calling method stops immediately visiting further points.
*/
virtual bool Visit (const MeshPoint &rclPoint, const MeshPoint &rclFrom,
unsigned long ulPInd, unsigned long ulLevel) = 0;
FacetIndex ulPInd, unsigned long ulLevel) = 0;
};
} // namespace MeshCore
+4 -4
View File
@@ -180,9 +180,9 @@ bool MergeExporter::addMesh(const char *name, const MeshObject & mesh)
for (unsigned long i=0; i<numSegm; i++) {
const Segment& segm = mesh.getSegment(i);
if (segm.isSaved()) {
std::vector<unsigned long> indices = segm.getIndices();
std::vector<FacetIndex> indices = segm.getIndices();
std::for_each( indices.begin(), indices.end(),
[countFacets] (unsigned long &v) {
[countFacets] (FacetIndex &v) {
v += countFacets;
} );
Segment new_segm(&mergingMesh, indices, true);
@@ -192,9 +192,9 @@ bool MergeExporter::addMesh(const char *name, const MeshObject & mesh)
}
} else {
// now create a segment for the added mesh
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
indices.resize(mergingMesh.countFacets() - countFacets);
std::generate(indices.begin(), indices.end(), Base::iotaGen<unsigned long>(countFacets));
std::generate(indices.begin(), indices.end(), Base::iotaGen<FacetIndex>(countFacets));
Segment segm(&mergingMesh, indices, true);
segm.setName(name);
mergingMesh.addSegment(segm);
+2 -2
View File
@@ -31,14 +31,14 @@
using namespace Mesh;
Facet::Facet(const MeshCore::MeshFacet& face, MeshObject* obj, unsigned long index)
Facet::Facet(const MeshCore::MeshFacet& face, MeshObject* obj, MeshCore::FacetIndex index)
: Index(index), Mesh(obj)
{
for (int i=0; i<3; i++) {
PIndex[i] = face._aulPoints[i];
NIndex[i] = face._aulNeighbours[i];
}
if (Mesh.isValid() && index != ULONG_MAX) {
if (Mesh.isValid() && index != MeshCore::FACET_INDEX_MAX) {
for (int i=0; i<3; i++) {
Base::Vector3d vert = Mesh->getPoint(PIndex[i]);
_aclPoints[i].Set((float)vert.x, (float)vert.y, (float)vert.z);
+5 -5
View File
@@ -43,16 +43,16 @@ class MeshObject;
class MeshExport Facet : public MeshCore::MeshGeomFacet
{
public:
Facet(const MeshCore::MeshFacet& face = MeshCore::MeshFacet(), MeshObject* obj = 0, unsigned long index = ULONG_MAX);
Facet(const MeshCore::MeshFacet& face = MeshCore::MeshFacet(), MeshObject* obj = nullptr, MeshCore::FacetIndex index = MeshCore::FACET_INDEX_MAX);
Facet(const Facet& f);
~Facet();
bool isBound(void) const {return Index != ULONG_MAX;}
bool isBound() const {return Index != MeshCore::FACET_INDEX_MAX;}
void operator = (const Facet& f);
unsigned long Index;
unsigned long PIndex[3];
unsigned long NIndex[3];
MeshCore::FacetIndex Index;
MeshCore::PointIndex PIndex[3];
MeshCore::FacetIndex NIndex[3];
Base::Reference<MeshObject> Mesh;
};
+21 -21
View File
@@ -34,7 +34,7 @@
using namespace Mesh;
// returns a string which represent the object e.g. when printed in python
std::string FacetPy::representation(void) const
std::string FacetPy::representation() const
{
FacetPy::PointerType ptr = getFacetPtr();
std::stringstream str;
@@ -72,23 +72,23 @@ int FacetPy::PyInit(PyObject* args, PyObject* /*kwds*/)
PyObject* FacetPy::unbound(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
getFacetPtr()->Index = ULONG_MAX;
getFacetPtr()->Mesh = 0;
return nullptr;
getFacetPtr()->Index = MeshCore::FACET_INDEX_MAX;
getFacetPtr()->Mesh = nullptr;
Py_Return;
}
Py::Long FacetPy::getIndex(void) const
Py::Long FacetPy::getIndex() const
{
return Py::Long((long) getFacetPtr()->Index);
}
Py::Boolean FacetPy::getBound(void) const
Py::Boolean FacetPy::getBound() const
{
return Py::Boolean(getFacetPtr()->Index != UINT_MAX);
}
Py::Object FacetPy::getNormal(void) const
Py::Object FacetPy::getNormal() const
{
Base::VectorPy* normal = new Base::VectorPy(getFacetPtr()->GetNormal());
normal->setConst();
@@ -99,7 +99,7 @@ PyObject* FacetPy::intersect(PyObject *args)
{
PyObject* object;
if (!PyArg_ParseTuple(args, "O!", &FacetPy::Type, &object))
return NULL;
return nullptr;
FacetPy *face = static_cast<FacetPy*>(object);
FacetPy::PointerType face_ptr = face->getFacetPtr();
FacetPy::PointerType this_ptr = this->getFacetPtr();
@@ -127,7 +127,7 @@ PyObject* FacetPy::intersect(PyObject *args)
return Py::new_reference_to(sct);
}
catch (const Py::Exception&) {
return 0;
return nullptr;
}
}
@@ -135,7 +135,7 @@ PyObject* FacetPy::isDegenerated(PyObject *args)
{
float fEpsilon = MeshCore::MeshDefinitions::_fMinPointDistanceP2;
if (!PyArg_ParseTuple(args, "|f", &fEpsilon))
return NULL;
return nullptr;
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -152,7 +152,7 @@ PyObject* FacetPy::isDeformed(PyObject *args)
float fMinAngle;
float fMaxAngle;
if (!PyArg_ParseTuple(args, "ff", &fMinAngle, &fMaxAngle))
return NULL;
return nullptr;
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -166,7 +166,7 @@ PyObject* FacetPy::isDeformed(PyObject *args)
return Py::new_reference_to(Py::Boolean(tria.IsDeformed(fCosOfMinAngle, fCosOfMaxAngle)));
}
Py::List FacetPy::getPoints(void) const
Py::List FacetPy::getPoints() const
{
FacetPy::PointerType face = this->getFacetPtr();
@@ -182,7 +182,7 @@ Py::List FacetPy::getPoints(void) const
return pts;
}
Py::Tuple FacetPy::getPointIndices(void) const
Py::Tuple FacetPy::getPointIndices() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound())
@@ -195,7 +195,7 @@ Py::Tuple FacetPy::getPointIndices(void) const
return idxTuple;
}
Py::Tuple FacetPy::getNeighbourIndices(void) const
Py::Tuple FacetPy::getNeighbourIndices() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -209,7 +209,7 @@ Py::Tuple FacetPy::getNeighbourIndices(void) const
return idxTuple;
}
Py::Float FacetPy::getArea(void) const
Py::Float FacetPy::getArea() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -221,7 +221,7 @@ Py::Float FacetPy::getArea(void) const
return Py::Float(tria.Area());
}
Py::Float FacetPy::getAspectRatio(void) const
Py::Float FacetPy::getAspectRatio() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -233,7 +233,7 @@ Py::Float FacetPy::getAspectRatio(void) const
return Py::Float(tria.AspectRatio());
}
Py::Float FacetPy::getAspectRatio2(void) const
Py::Float FacetPy::getAspectRatio2() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -245,7 +245,7 @@ Py::Float FacetPy::getAspectRatio2(void) const
return Py::Float(tria.AspectRatio2());
}
Py::Float FacetPy::getRoundness(void) const
Py::Float FacetPy::getRoundness() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -257,7 +257,7 @@ Py::Float FacetPy::getRoundness(void) const
return Py::Float(tria.Roundness());
}
Py::Tuple FacetPy::getCircumCircle(void) const
Py::Tuple FacetPy::getCircumCircle() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -274,7 +274,7 @@ Py::Tuple FacetPy::getCircumCircle(void) const
return tuple;
}
Py::Tuple FacetPy::getInCircle(void) const
Py::Tuple FacetPy::getInCircle() const
{
FacetPy::PointerType face = this->getFacetPtr();
if (!face->isBound()) {
@@ -293,7 +293,7 @@ Py::Tuple FacetPy::getInCircle(void) const
PyObject *FacetPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
return nullptr;
}
int FacetPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/)
+11 -11
View File
@@ -44,10 +44,10 @@ using namespace MeshCore;
PROPERTY_SOURCE(Mesh::SegmentByMesh, Mesh::Feature)
SegmentByMesh::SegmentByMesh(void)
SegmentByMesh::SegmentByMesh()
{
ADD_PROPERTY(Source ,(0));
ADD_PROPERTY(Tool ,(0));
ADD_PROPERTY(Source ,(nullptr));
ADD_PROPERTY(Tool ,(nullptr));
ADD_PROPERTY(Base ,(0.0,0.0,0.0));
ADD_PROPERTY(Normal ,(0.0,0.0,1.0));
}
@@ -63,9 +63,9 @@ short SegmentByMesh::mustExecute() const
return 0;
}
App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
App::DocumentObjectExecReturn *SegmentByMesh::execute()
{
Mesh::PropertyMeshKernel *kernel=0;
Mesh::PropertyMeshKernel *kernel=nullptr;
App::DocumentObject* mesh = Source.getValue();
if (mesh) {
App::Property* prop = mesh->getPropertyByName("Mesh");
@@ -77,7 +77,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
else if (mesh->isError())
return new App::DocumentObjectExecReturn("No valid mesh.\n");
Mesh::PropertyMeshKernel *toolmesh=0;
Mesh::PropertyMeshKernel *toolmesh=nullptr;
App::DocumentObject* tool = Tool.getValue();
if (tool) {
App::Property* prop = tool->getPropertyByName("Mesh");
@@ -106,7 +106,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
return new App::DocumentObjectExecReturn("Toolmesh is not solid.\n");
}
std::vector<unsigned long> faces;
std::vector<MeshCore::FacetIndex> faces;
std::vector<MeshGeomFacet> aFaces;
MeshAlgorithm cAlg(rMeshKernel);
@@ -121,11 +121,11 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
// so we need the nearest facet to the front clipping plane
//
float fDist = FLOAT_MAX;
unsigned long uIdx=ULONG_MAX;
MeshCore::FacetIndex uIdx = MeshCore::FACET_INDEX_MAX;
MeshFacetIterator cFIt(rMeshKernel);
// get the nearest facet to the user (front clipping plane)
for ( std::vector<unsigned long>::iterator it = faces.begin(); it != faces.end(); ++it ) {
for ( std::vector<MeshCore::FacetIndex>::iterator it = faces.begin(); it != faces.end(); ++it ) {
cFIt.Set(*it);
float dist = (float)fabs(cFIt->GetGravityPoint().DistanceToPlane( cBase, cNormal ));
if ( dist < fDist ) {
@@ -135,7 +135,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
}
// succeeded
if ( uIdx != ULONG_MAX ) {
if ( uIdx != MeshCore::FACET_INDEX_MAX ) {
// set VISIT-Flag to all outer facets
cAlg.SetFacetFlag( MeshFacet::VISIT );
cAlg.ResetFacetsFlag(faces, MeshFacet::VISIT);
@@ -149,7 +149,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
}
}
for ( std::vector<unsigned long>::iterator it = faces.begin(); it != faces.end(); ++it )
for ( std::vector<MeshCore::FacetIndex>::iterator it = faces.begin(); it != faces.end(); ++it )
aFaces.push_back( rMeshKernel.GetFacet(*it) );
std::unique_ptr<MeshObject> pcKernel(new MeshObject);
+1 -1
View File
@@ -56,7 +56,7 @@ public:
/** @name methods override Feature */
//@{
/// recalculate the Feature
App::DocumentObjectExecReturn *execute(void);
App::DocumentObjectExecReturn *execute();
short mustExecute() const;
//@}
};
+103 -103
View File
@@ -90,7 +90,7 @@ MeshObject::~MeshObject()
{
}
std::vector<const char*> MeshObject::getElementTypes(void) const
std::vector<const char*> MeshObject::getElementTypes() const
{
std::vector<const char*> temp;
temp.push_back("Face"); // that's the mesh itself
@@ -114,10 +114,10 @@ Data::Segment* MeshObject::getSubElement(const char* Type, unsigned long /*n*/)
//TODO
std::string element(Type);
if (element == "Face")
return 0;
return nullptr;
else if (element == "Segment")
return 0;
return 0;
return nullptr;
return nullptr;
}
void MeshObject::getFacesFromSubelement(const Data::Segment* /*segm*/,
@@ -142,12 +142,12 @@ void MeshObject::setTransform(const Base::Matrix4D& rclTrf)
_Mtrx = rclTrf;
}
Base::Matrix4D MeshObject::getTransform(void) const
Base::Matrix4D MeshObject::getTransform() const
{
return _Mtrx;
}
Base::BoundBox3d MeshObject::getBoundBox(void)const
Base::BoundBox3d MeshObject::getBoundBox()const
{
const_cast<MeshCore::MeshKernel&>(_kernel).RecalcBoundBox();
Base::BoundBox3f Bnd = _kernel.GetBoundBox();
@@ -266,7 +266,7 @@ double MeshObject::getVolume() const
return _kernel.GetVolume();
}
MeshPoint MeshObject::getPoint(unsigned long index) const
MeshPoint MeshObject::getPoint(PointIndex index) const
{
Base::Vector3f vertf = _kernel.GetPoint(index);
Base::Vector3d vertd(vertf.x, vertf.y, vertf.z);
@@ -304,7 +304,7 @@ void MeshObject::getPoints(std::vector<Base::Vector3d> &Points,
}
}
Mesh::Facet MeshObject::getFacet(unsigned long index) const
Mesh::Facet MeshObject::getFacet(FacetIndex index) const
{
Mesh::Facet face(_kernel.GetFacets()[index], const_cast<MeshObject*>(this), index);
return face;
@@ -331,7 +331,7 @@ void MeshObject::getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet>
}
}
unsigned int MeshObject::getMemSize (void) const
unsigned int MeshObject::getMemSize () const
{
return _kernel.GetMemSize();
}
@@ -470,7 +470,7 @@ void MeshObject::swapKernel(MeshCore::MeshKernel& kernel,
this->_segments.clear();
const MeshCore::MeshFacetArray& faces = _kernel.GetFacets();
MeshCore::MeshFacetArray::_TConstIterator it;
std::vector<unsigned long> segment;
std::vector<FacetIndex> segment;
segment.reserve(faces.size());
unsigned long prop = 0;
unsigned long index = 0;
@@ -637,7 +637,7 @@ void MeshObject::addMesh(const MeshCore::MeshKernel& kernel)
_kernel.Merge(kernel);
}
void MeshObject::deleteFacets(const std::vector<unsigned long>& removeIndices)
void MeshObject::deleteFacets(const std::vector<FacetIndex>& removeIndices)
{
if (removeIndices.empty())
return;
@@ -645,7 +645,7 @@ void MeshObject::deleteFacets(const std::vector<unsigned long>& removeIndices)
deletedFacets(removeIndices);
}
void MeshObject::deletePoints(const std::vector<unsigned long>& removeIndices)
void MeshObject::deletePoints(const std::vector<PointIndex>& removeIndices)
{
if (removeIndices.empty())
return;
@@ -653,21 +653,21 @@ void MeshObject::deletePoints(const std::vector<unsigned long>& removeIndices)
this->_segments.clear();
}
void MeshObject::deletedFacets(const std::vector<unsigned long>& remFacets)
void MeshObject::deletedFacets(const std::vector<FacetIndex>& remFacets)
{
if (remFacets.empty())
return; // nothing has changed
if (this->_segments.empty())
return; // nothing to do
// set an array with the original indices and mark the removed as ULONG_MAX
std::vector<unsigned long> f_indices(_kernel.CountFacets()+remFacets.size());
for (std::vector<unsigned long>::const_iterator it = remFacets.begin();
// set an array with the original indices and mark the removed as MeshCore::FACET_INDEX_MAX
std::vector<FacetIndex> f_indices(_kernel.CountFacets()+remFacets.size());
for (std::vector<FacetIndex>::const_iterator it = remFacets.begin();
it != remFacets.end(); ++it) {
f_indices[*it] = ULONG_MAX;
f_indices[*it] = MeshCore::FACET_INDEX_MAX;
}
unsigned long index = 0;
for (std::vector<unsigned long>::iterator it = f_indices.begin();
FacetIndex index = 0;
for (std::vector<FacetIndex>::iterator it = f_indices.begin();
it != f_indices.end(); ++it) {
if (*it == 0)
*it = index++;
@@ -676,17 +676,17 @@ void MeshObject::deletedFacets(const std::vector<unsigned long>& remFacets)
// the array serves now as LUT to set the new indices in the segments
for (std::vector<Segment>::iterator it = this->_segments.begin();
it != this->_segments.end(); ++it) {
std::vector<unsigned long> segm = it->_indices;
for (std::vector<unsigned long>::iterator jt = segm.begin();
std::vector<FacetIndex> segm = it->_indices;
for (std::vector<FacetIndex>::iterator jt = segm.begin();
jt != segm.end(); ++jt) {
*jt = f_indices[*jt];
}
// remove the invalid indices
std::sort(segm.begin(), segm.end());
std::vector<unsigned long>::iterator ft = std::find_if
(segm.begin(), segm.end(), [](unsigned long v) {
return v == ULONG_MAX;
std::vector<FacetIndex>::iterator ft = std::find_if
(segm.begin(), segm.end(), [](FacetIndex v) {
return v == MeshCore::FACET_INDEX_MAX;
});
if (ft != segm.end())
segm.erase(ft, segm.end());
@@ -696,14 +696,14 @@ void MeshObject::deletedFacets(const std::vector<unsigned long>& remFacets)
void MeshObject::deleteSelectedFacets()
{
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
MeshCore::MeshAlgorithm(this->_kernel).GetFacetsFlag(facets, MeshCore::MeshFacet::SELECTED);
deleteFacets(facets);
}
void MeshObject::deleteSelectedPoints()
{
std::vector<unsigned long> points;
std::vector<PointIndex> points;
MeshCore::MeshAlgorithm(this->_kernel).GetPointsFlag(points, MeshCore::MeshPoint::SELECTED);
deletePoints(points);
}
@@ -718,32 +718,32 @@ void MeshObject::clearPointSelection() const
MeshCore::MeshAlgorithm(this->_kernel).ResetPointFlag(MeshCore::MeshPoint::SELECTED);
}
void MeshObject::addFacetsToSelection(const std::vector<unsigned long>& inds) const
void MeshObject::addFacetsToSelection(const std::vector<FacetIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).SetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED);
}
void MeshObject::addPointsToSelection(const std::vector<unsigned long>& inds) const
void MeshObject::addPointsToSelection(const std::vector<PointIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).SetPointsFlag(inds, MeshCore::MeshPoint::SELECTED);
}
void MeshObject::removeFacetsFromSelection(const std::vector<unsigned long>& inds) const
void MeshObject::removeFacetsFromSelection(const std::vector<FacetIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).ResetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED);
}
void MeshObject::removePointsFromSelection(const std::vector<unsigned long>& inds) const
void MeshObject::removePointsFromSelection(const std::vector<PointIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).ResetPointsFlag(inds, MeshCore::MeshPoint::SELECTED);
}
void MeshObject::getFacetsFromSelection(std::vector<unsigned long>& inds) const
void MeshObject::getFacetsFromSelection(std::vector<FacetIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).GetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED);
}
void MeshObject::getPointsFromSelection(std::vector<unsigned long>& inds) const
void MeshObject::getPointsFromSelection(std::vector<PointIndex>& inds) const
{
MeshCore::MeshAlgorithm(this->_kernel).GetPointsFlag(inds, MeshCore::MeshPoint::SELECTED);
}
@@ -768,14 +768,14 @@ bool MeshObject::hasSelectedPoints() const
return (countSelectedPoints() > 0);
}
std::vector<unsigned long> MeshObject::getPointsFromFacets(const std::vector<unsigned long>& facets) const
std::vector<PointIndex> MeshObject::getPointsFromFacets(const std::vector<FacetIndex>& facets) const
{
return _kernel.GetFacetPoints(facets);
}
void MeshObject::updateMesh(const std::vector<unsigned long>& facets)
void MeshObject::updateMesh(const std::vector<FacetIndex>& facets)
{
std::vector<unsigned long> points;
std::vector<PointIndex> points;
points = _kernel.GetFacetPoints(facets);
MeshCore::MeshAlgorithm alg(_kernel);
@@ -790,16 +790,16 @@ void MeshObject::updateMesh()
alg.ResetPointFlag(MeshCore::MeshPoint::SEGMENT);
for (std::vector<Segment>::iterator it = this->_segments.begin();
it != this->_segments.end(); ++it) {
std::vector<unsigned long> points;
std::vector<PointIndex> points;
points = _kernel.GetFacetPoints(it->getIndices());
alg.SetFacetsFlag(it->getIndices(), MeshCore::MeshFacet::SEGMENT);
alg.SetPointsFlag(points, MeshCore::MeshPoint::SEGMENT);
}
}
std::vector<std::vector<unsigned long> > MeshObject::getComponents() const
std::vector<std::vector<FacetIndex> > MeshObject::getComponents() const
{
std::vector<std::vector<unsigned long> > segments;
std::vector<std::vector<FacetIndex> > segments;
MeshCore::MeshComponents comp(_kernel);
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segments);
return segments;
@@ -807,7 +807,7 @@ std::vector<std::vector<unsigned long> > MeshObject::getComponents() const
unsigned long MeshObject::countComponents() const
{
std::vector<std::vector<unsigned long> > segments;
std::vector<std::vector<FacetIndex> > segments;
MeshCore::MeshComponents comp(_kernel);
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segments);
return segments.size();
@@ -815,17 +815,17 @@ unsigned long MeshObject::countComponents() const
void MeshObject::removeComponents(unsigned long count)
{
std::vector<unsigned long> removeIndices;
std::vector<FacetIndex> removeIndices;
MeshCore::MeshTopoAlgorithm(_kernel).FindComponents(count, removeIndices);
_kernel.DeleteFacets(removeIndices);
deletedFacets(removeIndices);
}
unsigned long MeshObject::getPointDegree(const std::vector<unsigned long>& indices,
std::vector<unsigned long>& point_degree) const
unsigned long MeshObject::getPointDegree(const std::vector<FacetIndex>& indices,
std::vector<PointIndex>& point_degree) const
{
const MeshCore::MeshFacetArray& faces = _kernel.GetFacets();
std::vector<unsigned long> pointDeg(_kernel.CountPoints());
std::vector<PointIndex> pointDeg(_kernel.CountPoints());
for (MeshCore::MeshFacetArray::_TConstIterator it = faces.begin(); it != faces.end(); ++it) {
pointDeg[it->_aulPoints[0]]++;
@@ -833,14 +833,14 @@ unsigned long MeshObject::getPointDegree(const std::vector<unsigned long>& indic
pointDeg[it->_aulPoints[2]]++;
}
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
for (std::vector<PointIndex>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
const MeshCore::MeshFacet& face = faces[*it];
pointDeg[face._aulPoints[0]]--;
pointDeg[face._aulPoints[1]]--;
pointDeg[face._aulPoints[2]]--;
}
unsigned long countInvalids = std::count_if(pointDeg.begin(), pointDeg.end(), [](unsigned long v) {
unsigned long countInvalids = std::count_if(pointDeg.begin(), pointDeg.end(), [](PointIndex v) {
return v == 0;
});
@@ -851,7 +851,7 @@ unsigned long MeshObject::getPointDegree(const std::vector<unsigned long>& indic
void MeshObject::fillupHoles(unsigned long length, int level,
MeshCore::AbstractPolygonTriangulator& cTria)
{
std::list<std::vector<unsigned long> > aFailed;
std::list<std::vector<PointIndex> > aFailed;
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.FillupHoles(length, level, cTria, aFailed);
}
@@ -873,7 +873,7 @@ void MeshObject::offsetSpecial2(float fSize)
Base::Builder3D builder;
std::vector<Base::Vector3f> PointNormals= _kernel.CalcVertexNormals();
std::vector<Base::Vector3f> FaceNormals;
std::set<unsigned long> fliped;
std::set<FacetIndex> fliped;
MeshCore::MeshFacetIterator it(_kernel);
for (it.Init(); it.More(); it.Next())
@@ -908,7 +908,7 @@ void MeshObject::offsetSpecial2(float fSize)
if (fliped.size() == 0)
break;
for( std::set<unsigned long>::iterator It= fliped.begin();It!=fliped.end();++It)
for( std::set<FacetIndex>::iterator It= fliped.begin();It!=fliped.end();++It)
alg.CollapseFacet(*It);
fliped.clear();
}
@@ -917,7 +917,7 @@ void MeshObject::offsetSpecial2(float fSize)
// search for intersected facets
MeshCore::MeshEvalSelfIntersection eval(_kernel);
std::vector<std::pair<unsigned long, unsigned long> > faces;
std::vector<std::pair<FacetIndex, FacetIndex> > faces;
eval.GetIntersections(faces);
builder.saveToLog();
}
@@ -941,7 +941,7 @@ void MeshObject::offsetSpecial(float fSize, float zmax, float zmin)
}
}
void MeshObject::clear(void)
void MeshObject::clear()
{
_kernel.Clear();
this->_segments.clear();
@@ -964,7 +964,7 @@ Base::Matrix4D MeshObject::getEigenSystem(Base::Vector3d& v) const
return cMeshEval.Transform();
}
void MeshObject::movePoint(unsigned long index, const Base::Vector3d& v)
void MeshObject::movePoint(PointIndex index, const Base::Vector3d& v)
{
// v is a vector, hence we must not apply the translation part
// of the transformation to the vector
@@ -975,7 +975,7 @@ void MeshObject::movePoint(unsigned long index, const Base::Vector3d& v)
_kernel.MovePoint(index,transformToInside(vec));
}
void MeshObject::setPoint(unsigned long index, const Base::Vector3d& p)
void MeshObject::setPoint(PointIndex index, const Base::Vector3d& p)
{
_kernel.SetPoint(index,transformToInside(p));
}
@@ -997,7 +997,7 @@ void MeshObject::decimate(int targetSize)
dm.simplify(targetSize);
}
Base::Vector3d MeshObject::getPointNormal(unsigned long index) const
Base::Vector3d MeshObject::getPointNormal(PointIndex index) const
{
std::vector<Base::Vector3f> temp = _kernel.CalcVertexNormals();
Base::Vector3d normal = transformToOutside(temp[index]);
@@ -1050,7 +1050,7 @@ void MeshObject::cut(const Base::Polygon2d& polygon2d,
const Base::ViewProjMethod& proj, MeshObject::CutType type)
{
MeshCore::MeshAlgorithm meshAlg(this->_kernel);
std::vector<unsigned long> check;
std::vector<FacetIndex> check;
bool inner;
switch (type) {
@@ -1075,7 +1075,7 @@ void MeshObject::trim(const Base::Polygon2d& polygon2d,
const Base::ViewProjMethod& proj, MeshObject::CutType type)
{
MeshCore::MeshTrimming trim(this->_kernel, &proj, polygon2d);
std::vector<unsigned long> check;
std::vector<FacetIndex> check;
std::vector<MeshCore::MeshGeomFacet> triangle;
switch (type) {
@@ -1099,7 +1099,7 @@ void MeshObject::trim(const Base::Polygon2d& polygon2d,
void MeshObject::trim(const Base::Vector3f& base, const Base::Vector3f& normal)
{
MeshCore::MeshTrimByPlane trim(this->_kernel);
std::vector<unsigned long> trimFacets, removeFacets;
std::vector<FacetIndex> trimFacets, removeFacets;
std::vector<MeshCore::MeshGeomFacet> triangle;
MeshCore::MeshFacetGrid meshGrid(this->_kernel);
@@ -1230,13 +1230,13 @@ void MeshObject::optimizeEdges()
void MeshObject::splitEdges()
{
std::vector<std::pair<unsigned long, unsigned long> > adjacentFacet;
std::vector<std::pair<FacetIndex, FacetIndex> > adjacentFacet;
MeshCore::MeshAlgorithm alg(_kernel);
alg.ResetFacetFlag(MeshCore::MeshFacet::VISIT);
const MeshCore::MeshFacetArray& rFacets = _kernel.GetFacets();
for (MeshCore::MeshFacetArray::_TConstIterator pF = rFacets.begin(); pF != rFacets.end(); ++pF) {
int id=2;
if (pF->_aulNeighbours[id] != ULONG_MAX) {
if (pF->_aulNeighbours[id] != MeshCore::FACET_INDEX_MAX) {
const MeshCore::MeshFacet& rFace = rFacets[pF->_aulNeighbours[id]];
if (!pF->IsFlag(MeshCore::MeshFacet::VISIT) && !rFace.IsFlag(MeshCore::MeshFacet::VISIT)) {
pF->SetFlag(MeshCore::MeshFacet::VISIT);
@@ -1248,7 +1248,7 @@ void MeshObject::splitEdges()
MeshCore::MeshFacetIterator cIter(_kernel);
MeshCore::MeshTopoAlgorithm topalg(_kernel);
for (std::vector<std::pair<unsigned long, unsigned long> >::iterator it = adjacentFacet.begin(); it != adjacentFacet.end(); ++it) {
for (std::vector<std::pair<FacetIndex, FacetIndex> >::iterator it = adjacentFacet.begin(); it != adjacentFacet.end(); ++it) {
cIter.Set(it->first);
Base::Vector3f mid = 0.5f*(cIter->_aclPoints[0]+cIter->_aclPoints[2]);
topalg.SplitEdge(it->first, it->second, mid);
@@ -1259,62 +1259,62 @@ void MeshObject::splitEdges()
this->_segments.clear();
}
void MeshObject::splitEdge(unsigned long facet, unsigned long neighbour, const Base::Vector3f& v)
void MeshObject::splitEdge(FacetIndex facet, FacetIndex neighbour, const Base::Vector3f& v)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.SplitEdge(facet, neighbour, v);
}
void MeshObject::splitFacet(unsigned long facet, const Base::Vector3f& v1, const Base::Vector3f& v2)
void MeshObject::splitFacet(FacetIndex facet, const Base::Vector3f& v1, const Base::Vector3f& v2)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.SplitFacet(facet, v1, v2);
}
void MeshObject::swapEdge(unsigned long facet, unsigned long neighbour)
void MeshObject::swapEdge(FacetIndex facet, FacetIndex neighbour)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.SwapEdge(facet, neighbour);
}
void MeshObject::collapseEdge(unsigned long facet, unsigned long neighbour)
void MeshObject::collapseEdge(FacetIndex facet, FacetIndex neighbour)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.CollapseEdge(facet, neighbour);
std::vector<unsigned long> remFacets;
std::vector<FacetIndex> remFacets;
remFacets.push_back(facet);
remFacets.push_back(neighbour);
deletedFacets(remFacets);
}
void MeshObject::collapseFacet(unsigned long facet)
void MeshObject::collapseFacet(FacetIndex facet)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.CollapseFacet(facet);
std::vector<unsigned long> remFacets;
std::vector<FacetIndex> remFacets;
remFacets.push_back(facet);
deletedFacets(remFacets);
}
void MeshObject::collapseFacets(const std::vector<unsigned long>& facets)
void MeshObject::collapseFacets(const std::vector<FacetIndex>& facets)
{
MeshCore::MeshTopoAlgorithm alg(_kernel);
for (std::vector<unsigned long>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
alg.CollapseFacet(*it);
}
deletedFacets(facets);
}
void MeshObject::insertVertex(unsigned long facet, const Base::Vector3f& v)
void MeshObject::insertVertex(FacetIndex facet, const Base::Vector3f& v)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.InsertVertex(facet, v);
}
void MeshObject::snapVertex(unsigned long facet, const Base::Vector3f& v)
void MeshObject::snapVertex(FacetIndex facet, const Base::Vector3f& v)
{
MeshCore::MeshTopoAlgorithm topalg(_kernel);
topalg.SnapVertex(facet, v);
@@ -1323,7 +1323,7 @@ void MeshObject::snapVertex(unsigned long facet, const Base::Vector3f& v)
unsigned long MeshObject::countNonUniformOrientedFacets() const
{
MeshCore::MeshEvalOrientation cMeshEval(_kernel);
std::vector<unsigned long> inds = cMeshEval.GetIndices();
std::vector<FacetIndex> inds = cMeshEval.GetIndices();
return inds.size();
}
@@ -1359,7 +1359,7 @@ void MeshObject::removeNonManifoldPoints()
{
MeshCore::MeshEvalPointManifolds p_eval(_kernel);
if (!p_eval.Evaluate()) {
std::vector<unsigned long> faces;
std::vector<FacetIndex> faces;
p_eval.GetFacetIndices(faces);
deleteFacets(faces);
}
@@ -1373,7 +1373,7 @@ bool MeshObject::hasSelfIntersections() const
void MeshObject::removeSelfIntersections()
{
std::vector<std::pair<unsigned long, unsigned long> > selfIntersections;
std::vector<std::pair<FacetIndex, FacetIndex> > selfIntersections;
MeshCore::MeshEvalSelfIntersection cMeshEval(_kernel);
cMeshEval.GetIntersections(selfIntersections);
@@ -1383,19 +1383,19 @@ void MeshObject::removeSelfIntersections()
}
}
void MeshObject::removeSelfIntersections(const std::vector<unsigned long>& indices)
void MeshObject::removeSelfIntersections(const std::vector<FacetIndex>& indices)
{
// make sure that the number of indices is even and are in range
if (indices.size() % 2 != 0)
return;
unsigned long cntfacets = _kernel.CountFacets();
if (std::find_if(indices.begin(), indices.end(), [cntfacets](unsigned long v) { return v >= cntfacets; }) < indices.end())
if (std::find_if(indices.begin(), indices.end(), [cntfacets](FacetIndex v) { return v >= cntfacets; }) < indices.end())
return;
std::vector<std::pair<unsigned long, unsigned long> > selfIntersections;
std::vector<unsigned long>::const_iterator it;
std::vector<std::pair<FacetIndex, FacetIndex> > selfIntersections;
std::vector<FacetIndex>::const_iterator it;
for (it = indices.begin(); it != indices.end(); ) {
unsigned long id1 = *it; ++it;
unsigned long id2 = *it; ++it;
FacetIndex id1 = *it; ++it;
FacetIndex id2 = *it; ++it;
selfIntersections.emplace_back(id1,id2);
}
@@ -1408,15 +1408,15 @@ void MeshObject::removeSelfIntersections(const std::vector<unsigned long>& indic
void MeshObject::removeFoldsOnSurface()
{
std::vector<unsigned long> indices;
std::vector<FacetIndex> indices;
MeshCore::MeshEvalFoldsOnSurface s_eval(_kernel);
MeshCore::MeshEvalFoldOversOnSurface f_eval(_kernel);
f_eval.Evaluate();
std::vector<unsigned long> inds = f_eval.GetIndices();
std::vector<FacetIndex> inds = f_eval.GetIndices();
s_eval.Evaluate();
std::vector<unsigned long> inds1 = s_eval.GetIndices();
std::vector<FacetIndex> inds1 = s_eval.GetIndices();
// remove duplicates
inds.insert(inds.end(), inds1.begin(), inds1.end());
@@ -1439,7 +1439,7 @@ void MeshObject::removeFoldsOnSurface()
void MeshObject::removeFullBoundaryFacets()
{
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
if (!MeshCore::MeshEvalBorderFacet(_kernel, facets).Evaluate()) {
deleteFacets(facets);
}
@@ -1592,7 +1592,7 @@ MeshObject* MeshObject::createSphere(float radius, int sampling)
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Sphere"));
Py::Tuple args(2);
@@ -1605,7 +1605,7 @@ MeshObject* MeshObject::createSphere(float radius, int sampling)
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampling)
@@ -1615,7 +1615,7 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Ellipsoid"));
Py::Tuple args(3);
@@ -1629,7 +1629,7 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createCylinder(float radius, float length, int closed, float edgelen, int sampling)
@@ -1639,7 +1639,7 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cylinder"));
Py::Tuple args(5);
@@ -1655,7 +1655,7 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int closed, float edgelen, int sampling)
@@ -1665,7 +1665,7 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cone"));
Py::Tuple args(6);
@@ -1682,7 +1682,7 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling)
@@ -1692,7 +1692,7 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling)
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Toroid"));
Py::Tuple args(3);
@@ -1706,7 +1706,7 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling)
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createCube(float length, float width, float height)
@@ -1716,7 +1716,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height)
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cube"));
Py::Tuple args(3);
@@ -1730,7 +1730,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height)
e.clear();
}
return 0;
return nullptr;
}
MeshObject* MeshObject::createCube(float length, float width, float height, float edgelen)
@@ -1740,7 +1740,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height, floa
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
return nullptr;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("FineCube"));
Py::Tuple args(4);
@@ -1755,7 +1755,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height, floa
e.clear();
}
return 0;
return nullptr;
}
void MeshObject::addSegment(const Segment& s)
@@ -1767,10 +1767,10 @@ void MeshObject::addSegment(const Segment& s)
this->_segments.back()._modifykernel = s._modifykernel;
}
void MeshObject::addSegment(const std::vector<unsigned long>& inds)
void MeshObject::addSegment(const std::vector<FacetIndex>& inds)
{
unsigned long maxIndex = _kernel.CountFacets();
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
if (*it >= maxIndex)
throw Base::IndexError("Index out of range");
}
@@ -1788,13 +1788,13 @@ Segment& MeshObject::getSegment(unsigned long index)
return this->_segments[index];
}
MeshObject* MeshObject::meshFromSegment(const std::vector<unsigned long>& indices) const
MeshObject* MeshObject::meshFromSegment(const std::vector<FacetIndex>& indices) const
{
MeshCore::MeshFacetArray facets;
facets.reserve(indices.size());
const MeshCore::MeshPointArray& kernel_p = _kernel.GetPoints();
const MeshCore::MeshFacetArray& kernel_f = _kernel.GetFacets();
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
facets.push_back(kernel_f[*it]);
}
@@ -1847,7 +1847,7 @@ std::vector<Segment> MeshObject::getSegmentsOfType(MeshObject::GeometryType type
// ----------------------------------------------------------------------------
MeshObject::const_point_iterator::const_point_iterator(const MeshObject* mesh, unsigned long index)
MeshObject::const_point_iterator::const_point_iterator(const MeshObject* mesh, PointIndex index)
: _mesh(mesh), _p_it(mesh->getKernel())
{
this->_p_it.Set(index);
@@ -1916,7 +1916,7 @@ MeshObject::const_point_iterator& MeshObject::const_point_iterator::operator--()
// ----------------------------------------------------------------------------
MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject* mesh, unsigned long index)
MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject* mesh, FacetIndex index)
: _mesh(mesh), _f_it(mesh->getKernel())
{
this->_f_it.Set(index);
+45 -45
View File
@@ -92,7 +92,7 @@ public:
* List of different subelement types
* its NOT a list of the subelements itself
*/
virtual std::vector<const char*> getElementTypes(void) const;
virtual std::vector<const char*> getElementTypes() const;
virtual unsigned long countSubElements(const char* Type) const;
/// get the subelement by type and number
virtual Data::Segment* getSubElement(const char* Type, unsigned long) const;
@@ -105,7 +105,7 @@ public:
//@}
void setTransform(const Base::Matrix4D& rclTrf);
Base::Matrix4D getTransform(void) const;
Base::Matrix4D getTransform() const;
void transformGeometry(const Base::Matrix4D &rclMat);
/**
@@ -123,8 +123,8 @@ public:
unsigned long countEdges () const;
unsigned long countSegments() const;
bool isSolid() const;
MeshPoint getPoint(unsigned long) const;
Mesh::Facet getFacet(unsigned long) const;
MeshPoint getPoint(PointIndex) const;
Mesh::Facet getFacet(FacetIndex) const;
double getSurface() const;
double getVolume() const;
/** Get points from object with given accuracy */
@@ -133,33 +133,33 @@ public:
float Accuracy, uint16_t flags=0) const;
virtual void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
float Accuracy, uint16_t flags=0) const;
std::vector<unsigned long> getPointsFromFacets(const std::vector<unsigned long>& facets) const;
std::vector<PointIndex> getPointsFromFacets(const std::vector<FacetIndex>& facets) const;
//@}
void setKernel(const MeshCore::MeshKernel& m);
MeshCore::MeshKernel& getKernel(void)
MeshCore::MeshKernel& getKernel()
{ return _kernel; }
const MeshCore::MeshKernel& getKernel(void) const
const MeshCore::MeshKernel& getKernel() const
{ return _kernel; }
virtual Base::BoundBox3d getBoundBox(void)const;
virtual Base::BoundBox3d getBoundBox()const;
/** @name I/O */
//@{
// Implemented from Persistence
unsigned int getMemSize (void) const;
unsigned int getMemSize () const;
void Save (Base::Writer &writer) const;
void SaveDocFile (Base::Writer &writer) const;
void Restore(Base::XMLReader &reader);
void RestoreDocFile(Base::Reader &reader);
void save(const char* file,MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined,
const MeshCore::Material* mat = 0,
const char* objectname = 0) const;
const MeshCore::Material* mat = nullptr,
const char* objectname = nullptr) const;
void save(std::ostream&,MeshCore::MeshIO::Format f,
const MeshCore::Material* mat = 0,
const char* objectname = 0) const;
bool load(const char* file, MeshCore::Material* mat = 0);
bool load(std::istream&, MeshCore::MeshIO::Format f, MeshCore::Material* mat = 0);
const MeshCore::Material* mat = nullptr,
const char* objectname = nullptr) const;
bool load(const char* file, MeshCore::Material* mat = nullptr);
bool load(std::istream&, MeshCore::MeshIO::Format f, MeshCore::Material* mat = nullptr);
// Save and load in internal format
void save(std::ostream&) const;
void load(std::istream&);
@@ -192,9 +192,9 @@ public:
* this mesh object.
*/
void addMesh(const MeshCore::MeshKernel&);
void deleteFacets(const std::vector<unsigned long>& removeIndices);
void deletePoints(const std::vector<unsigned long>& removeIndices);
std::vector<std::vector<unsigned long> > getComponents() const;
void deleteFacets(const std::vector<FacetIndex>& removeIndices);
void deletePoints(const std::vector<PointIndex>& removeIndices);
std::vector<std::vector<FacetIndex> > getComponents() const;
unsigned long countComponents() const;
void removeComponents(unsigned long);
/**
@@ -203,22 +203,22 @@ public:
* The point degree information is stored in \a point_degree. The return value
* gives the number of points which will have a degree of zero.
*/
unsigned long getPointDegree(const std::vector<unsigned long>& facets,
std::vector<unsigned long>& point_degree) const;
unsigned long getPointDegree(const std::vector<FacetIndex>& facets,
std::vector<PointIndex>& point_degree) const;
void fillupHoles(unsigned long, int, MeshCore::AbstractPolygonTriangulator&);
void offset(float fSize);
void offsetSpecial2(float fSize);
void offsetSpecial(float fSize, float zmax, float zmin);
/// clears the Mesh
void clear(void);
void clear();
void transformToEigenSystem();
Base::Matrix4D getEigenSystem(Base::Vector3d& v) const;
void movePoint(unsigned long, const Base::Vector3d& v);
void setPoint(unsigned long, const Base::Vector3d& v);
void movePoint(PointIndex, const Base::Vector3d& v);
void setPoint(PointIndex, const Base::Vector3d& v);
void smooth(int iterations, float d_max);
void decimate(float fTolerance, float fReduction);
void decimate(int targetSize);
Base::Vector3d getPointNormal(unsigned long) const;
Base::Vector3d getPointNormal(PointIndex) const;
std::vector<Base::Vector3d> getPointNormals() const;
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> &sections,
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
@@ -231,16 +231,16 @@ public:
//@{
void deleteSelectedFacets();
void deleteSelectedPoints();
void addFacetsToSelection(const std::vector<unsigned long>&) const;
void addPointsToSelection(const std::vector<unsigned long>&) const;
void removeFacetsFromSelection(const std::vector<unsigned long>&) const;
void removePointsFromSelection(const std::vector<unsigned long>&) const;
void addFacetsToSelection(const std::vector<FacetIndex>&) const;
void addPointsToSelection(const std::vector<PointIndex>&) const;
void removeFacetsFromSelection(const std::vector<FacetIndex>&) const;
void removePointsFromSelection(const std::vector<PointIndex>&) const;
unsigned long countSelectedFacets() const;
bool hasSelectedFacets() const;
unsigned long countSelectedPoints() const;
bool hasSelectedPoints() const;
void getFacetsFromSelection(std::vector<unsigned long>&) const;
void getPointsFromSelection(std::vector<unsigned long>&) const;
void getFacetsFromSelection(std::vector<FacetIndex>&) const;
void getPointsFromSelection(std::vector<PointIndex>&) const;
void clearFacetSelection() const;
void clearPointSelection() const;
//@}
@@ -261,14 +261,14 @@ public:
void optimizeTopology(float);
void optimizeEdges();
void splitEdges();
void splitEdge(unsigned long, unsigned long, const Base::Vector3f&);
void splitFacet(unsigned long, const Base::Vector3f&, const Base::Vector3f&);
void swapEdge(unsigned long, unsigned long);
void collapseEdge(unsigned long, unsigned long);
void collapseFacet(unsigned long);
void collapseFacets(const std::vector<unsigned long>&);
void insertVertex(unsigned long, const Base::Vector3f& v);
void snapVertex(unsigned long, const Base::Vector3f& v);
void splitEdge(FacetIndex, FacetIndex, const Base::Vector3f&);
void splitFacet(FacetIndex, const Base::Vector3f&, const Base::Vector3f&);
void swapEdge(FacetIndex, FacetIndex);
void collapseEdge(FacetIndex, FacetIndex);
void collapseFacet(FacetIndex);
void collapseFacets(const std::vector<FacetIndex>&);
void insertVertex(FacetIndex, const Base::Vector3f& v);
void snapVertex(FacetIndex, const Base::Vector3f& v);
//@}
/** @name Mesh validation */
@@ -291,7 +291,7 @@ public:
void removeNonManifoldPoints();
bool hasSelfIntersections() const;
void removeSelfIntersections();
void removeSelfIntersections(const std::vector<unsigned long>&);
void removeSelfIntersections(const std::vector<FacetIndex>&);
void removeFoldsOnSurface();
void removeFullBoundaryFacets();
bool hasInvalidPoints() const;
@@ -302,10 +302,10 @@ public:
/** @name Mesh segments */
//@{
void addSegment(const Segment&);
void addSegment(const std::vector<unsigned long>&);
void addSegment(const std::vector<FacetIndex>&);
const Segment& getSegment(unsigned long) const;
Segment& getSegment(unsigned long);
MeshObject* meshFromSegment(const std::vector<unsigned long>&) const;
MeshObject* meshFromSegment(const std::vector<FacetIndex>&) const;
std::vector<Segment> getSegmentsOfType(GeometryType, float dev, unsigned long minFacets) const;
//@}
@@ -325,7 +325,7 @@ public:
class MeshExport const_point_iterator
{
public:
const_point_iterator(const MeshObject*, unsigned long index);
const_point_iterator(const MeshObject*, PointIndex index);
const_point_iterator(const const_point_iterator& pi);
~const_point_iterator();
@@ -346,7 +346,7 @@ public:
class MeshExport const_facet_iterator
{
public:
const_facet_iterator(const MeshObject*, unsigned long index);
const_facet_iterator(const MeshObject*, FacetIndex index);
const_facet_iterator(const const_facet_iterator& fi);
~const_facet_iterator();
@@ -387,8 +387,8 @@ public:
friend class Segment;
private:
void deletedFacets(const std::vector<unsigned long>& remFacets);
void updateMesh(const std::vector<unsigned long>&);
void deletedFacets(const std::vector<FacetIndex>& remFacets);
void updateMesh(const std::vector<FacetIndex>&);
void updateMesh();
void swapKernel(MeshCore::MeshKernel& m, const std::vector<std::string>& g);
void copySegments(const MeshObject&);
+2 -2
View File
@@ -529,11 +529,11 @@ void PropertyMeshKernel::transformGeometry(const Base::Matrix4D &rclMat)
hasSetValue();
}
void PropertyMeshKernel::setPointIndices(const std::vector<std::pair<unsigned long, Base::Vector3f> >& inds)
void PropertyMeshKernel::setPointIndices(const std::vector<std::pair<PointIndex, Base::Vector3f> >& inds)
{
aboutToSetValue();
MeshCore::MeshKernel& kernel = _meshObject->getKernel();
for (std::vector<std::pair<unsigned long, Base::Vector3f> >::const_iterator it = inds.begin(); it != inds.end(); ++it)
for (std::vector<std::pair<PointIndex, Base::Vector3f> >::const_iterator it = inds.begin(); it != inds.end(); ++it)
kernel.SetPoint(it->first, it->second);
hasSetValue();
}
+1 -1
View File
@@ -215,7 +215,7 @@ public:
void finishEditing();
/// Transform the real mesh data
void transformGeometry(const Base::Matrix4D &rclMat);
void setPointIndices( const std::vector<std::pair<unsigned long, Base::Vector3f> >& );
void setPointIndices( const std::vector<std::pair<PointIndex, Base::Vector3f> >& );
//@}
/** @name Python interface */
+18 -18
View File
@@ -756,10 +756,10 @@ PyObject* MeshPy::getInternalFacets(PyObject *args)
MeshCore::MeshEvalInternalFacets eval(kernel);
eval.Evaluate();
const std::vector<unsigned long>& indices = eval.GetIndices();
const std::vector<FacetIndex>& indices = eval.GetIndices();
Py::List ary(indices.size());
Py::List::size_type pos=0;
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
ary[pos++] = Py::Long(*it);
}
@@ -841,8 +841,8 @@ PyObject* MeshPy::getSegment(PyObject *args)
}
Py::List ary;
const std::vector<unsigned long>& segm = getMeshObjectPtr()->getSegment(index).getIndices();
for (std::vector<unsigned long>::const_iterator it = segm.begin(); it != segm.end(); ++it) {
const std::vector<FacetIndex>& segm = getMeshObjectPtr()->getSegment(index).getIndices();
for (std::vector<FacetIndex>::const_iterator it = segm.begin(); it != segm.end(); ++it) {
ary.append(Py::Long((int)*it));
}
@@ -855,7 +855,7 @@ PyObject* MeshPy::getSeparateComponents(PyObject *args)
return NULL;
Py::List meshesList;
std::vector<std::vector<unsigned long> > segs;
std::vector<std::vector<FacetIndex> > segs;
segs = getMeshObjectPtr()->getComponents();
for (unsigned int i=0; i<segs.size(); i++) {
MeshObject* mesh = getMeshObjectPtr()->meshFromSegment(segs[i]);
@@ -870,9 +870,9 @@ PyObject* MeshPy::getFacetSelection(PyObject *args)
return 0;
Py::List ary;
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
getMeshObjectPtr()->getFacetsFromSelection(facets);
for (std::vector<unsigned long>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
for (std::vector<FacetIndex>::const_iterator it = facets.begin(); it != facets.end(); ++it) {
ary.append(Py::Long((int)*it));
}
@@ -885,9 +885,9 @@ PyObject* MeshPy::getPointSelection(PyObject *args)
return 0;
Py::List ary;
std::vector<unsigned long> points;
std::vector<PointIndex> points;
getMeshObjectPtr()->getPointsFromSelection(points);
for (std::vector<unsigned long>::const_iterator it = points.begin(); it != points.end(); ++it) {
for (std::vector<PointIndex>::const_iterator it = points.begin(); it != points.end(); ++it) {
ary.append(Py::Long((int)*it));
}
@@ -900,7 +900,7 @@ PyObject* MeshPy::meshFromSegment(PyObject *args)
if (!PyArg_ParseTuple(args, "O", &list))
return 0;
std::vector<unsigned long> segment;
std::vector<FacetIndex> segment;
Py::Sequence ary(list);
for (Py::Sequence::iterator it = ary.begin(); it != ary.end(); ++it) {
Py::Long f(*it);
@@ -997,7 +997,7 @@ PyObject* MeshPy::getSelfIntersections(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
std::vector<std::pair<unsigned long, unsigned long> > selfIndices;
std::vector<std::pair<FacetIndex, FacetIndex> > selfIndices;
std::vector<std::pair<Base::Vector3f, Base::Vector3f> > selfPoints;
MeshCore::MeshEvalSelfIntersection eval(getMeshObjectPtr()->getKernel());
eval.GetIntersections(selfIndices);
@@ -1104,7 +1104,7 @@ PyObject* MeshPy::getNonUniformOrientedFacets(PyObject *args)
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
MeshCore::MeshEvalOrientation cMeshEval(kernel);
std::vector<unsigned long> inds = cMeshEval.GetIndices();
std::vector<FacetIndex> inds = cMeshEval.GetIndices();
Py::Tuple tuple(inds.size());
for (std::size_t i=0; i<inds.size(); i++) {
tuple.setItem(i, Py::Long(inds[i]));
@@ -1550,7 +1550,7 @@ PyObject* MeshPy::collapseFacets(PyObject *args)
// if no mesh is given
try {
Py::Sequence list(pcObj);
std::vector<unsigned long> facets;
std::vector<FacetIndex> facets;
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Long idx(*it);
unsigned long iIdx = static_cast<unsigned long>(idx);
@@ -1756,7 +1756,7 @@ PyObject* MeshPy::nearestFacetOnRay(PyObject *args)
(float)Py::Float(dir_t.getItem(1)),
(float)Py::Float(dir_t.getItem(2)));
unsigned long index = 0;
FacetIndex index = 0;
Base::Vector3f res;
MeshCore::MeshAlgorithm alg(getMeshObjectPtr()->getKernel());
@@ -1814,9 +1814,9 @@ PyObject* MeshPy::getPlanarSegments(PyObject *args)
Py::List s;
for (std::vector<Mesh::Segment>::iterator it = segments.begin(); it != segments.end(); ++it) {
const std::vector<unsigned long>& segm = it->getIndices();
const std::vector<FacetIndex>& segm = it->getIndices();
Py::List ary;
for (std::vector<unsigned long>::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) {
for (std::vector<FacetIndex>::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) {
ary.append(Py::Long((int)*jt));
}
s.append(ary);
@@ -1854,9 +1854,9 @@ PyObject* MeshPy::getSegmentsOfType(PyObject *args)
Py::List s;
for (std::vector<Mesh::Segment>::iterator it = segments.begin(); it != segments.end(); ++it) {
const std::vector<unsigned long>& segm = it->getIndices();
const std::vector<FacetIndex>& segm = it->getIndices();
Py::List ary;
for (std::vector<unsigned long>::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) {
for (std::vector<FacetIndex>::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) {
ary.append(Py::Long((int)*jt));
}
s.append(ary);
+12 -10
View File
@@ -85,7 +85,7 @@ void MeshTexture::apply(const Mesh::MeshObject& mesh, bool addDefaultColor, cons
if (binding == MeshCore::MeshIO::PER_VERTEX) {
diffuseColor.reserve(points.size());
for (size_t index=0; index<points.size(); index++) {
unsigned long pos = findIndex(points[index], max_dist);
PointIndex pos = findIndex(points[index], max_dist);
if (pos < countPointsRefMesh) {
diffuseColor.push_back(textureColor[pos]);
}
@@ -101,27 +101,29 @@ void MeshTexture::apply(const Mesh::MeshObject& mesh, bool addDefaultColor, cons
}
else if (binding == MeshCore::MeshIO::PER_FACE) {
// the values of the map give the point indices of the original mesh
std::vector<unsigned long> pointMap;
std::vector<PointIndex> pointMap;
pointMap.reserve(points.size());
for (size_t index=0; index<points.size(); index++) {
unsigned long pos = findIndex(points[index], max_dist);
PointIndex pos = findIndex(points[index], max_dist);
if (pos < countPointsRefMesh) {
pointMap.push_back(pos);
}
else if (addDefaultColor) {
pointMap.push_back(ULONG_MAX);
pointMap.push_back(MeshCore::POINT_INDEX_MAX);
}
}
// now determine the facet indices of the original mesh
if (pointMap.size() == points.size()) {
diffuseColor.reserve(facets.size());
for (auto it : facets) {
unsigned long index1 = pointMap[it._aulPoints[0]];
unsigned long index2 = pointMap[it._aulPoints[1]];
unsigned long index3 = pointMap[it._aulPoints[2]];
if (index1 != ULONG_MAX && index2 != ULONG_MAX && index3 != ULONG_MAX) {
std::vector<unsigned long> found = refPnt2Fac->GetIndices(index1, index2, index3);
for (const auto& it : facets) {
PointIndex index1 = pointMap[it._aulPoints[0]];
PointIndex index2 = pointMap[it._aulPoints[1]];
PointIndex index3 = pointMap[it._aulPoints[2]];
if (index1 != MeshCore::POINT_INDEX_MAX &&
index2 != MeshCore::POINT_INDEX_MAX &&
index3 != MeshCore::POINT_INDEX_MAX) {
std::vector<FacetIndex> found = refPnt2Fac->GetIndices(index1, index2, index3);
if (found.size() == 1) {
diffuseColor.push_back(textureColor[found.front()]);
}
+1 -1
View File
@@ -74,7 +74,7 @@ public:
private:
void apply(const Mesh::MeshObject& mesh, bool addDefaultColor, const App::Color& defaultColor, float max_dist, MeshCore::Material &material);
unsigned long findIndex(const Base::Vector3f& p, float max_dist) const {
PointIndex findIndex(const Base::Vector3f& p, float max_dist) const {
if (max_dist < 0.0f) {
return kdTree->FindExact(p);
}
+9 -9
View File
@@ -43,7 +43,7 @@ Segment::Segment(MeshObject* mesh, bool mod)
{
}
Segment::Segment(MeshObject* mesh, const std::vector<unsigned long>& inds, bool mod)
Segment::Segment(MeshObject* mesh, const std::vector<FacetIndex>& inds, bool mod)
: _mesh(mesh)
, _indices(inds)
, _save(false)
@@ -53,7 +53,7 @@ Segment::Segment(MeshObject* mesh, const std::vector<unsigned long>& inds, bool
_mesh->updateMesh(inds);
}
void Segment::addIndices(const std::vector<unsigned long>& inds)
void Segment::addIndices(const std::vector<FacetIndex>& inds)
{
_indices.insert(_indices.end(), inds.begin(), inds.end());
std::sort(_indices.begin(), _indices.end());
@@ -62,21 +62,21 @@ void Segment::addIndices(const std::vector<unsigned long>& inds)
_mesh->updateMesh(inds);
}
void Segment::removeIndices(const std::vector<unsigned long>& inds)
void Segment::removeIndices(const std::vector<FacetIndex>& inds)
{
// make difference
std::vector<unsigned long> result;
std::set<unsigned long> s1(_indices.begin(), _indices.end());
std::set<unsigned long> s2(inds.begin(), inds.end());
std::vector<FacetIndex> result;
std::set<FacetIndex> s1(_indices.begin(), _indices.end());
std::set<FacetIndex> s2(inds.begin(), inds.end());
std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),
std::back_insert_iterator<std::vector<unsigned long> >(result));
std::back_insert_iterator<std::vector<FacetIndex> >(result));
_indices = result;
if (_modifykernel)
_mesh->updateMesh();
}
const std::vector<unsigned long>& Segment::getIndices() const
const std::vector<FacetIndex>& Segment::getIndices() const
{
return _indices;
}
@@ -109,7 +109,7 @@ bool Segment::operator == (const Segment& s) const
// ----------------------------------------------------------------------------
Segment::const_facet_iterator::const_facet_iterator(const Segment* segm, std::vector<unsigned long>::const_iterator it)
Segment::const_facet_iterator::const_facet_iterator(const Segment* segm, std::vector<FacetIndex>::const_iterator it)
: _segment(segm), _f_it(segm->_mesh->getKernel()), _it(it)
{
this->_f_it.Set(0);
+8 -7
View File
@@ -27,6 +27,7 @@
#include <vector>
#include <string>
#include "Facet.h"
#include "Types.h"
#include "Core/Iterator.h"
namespace Mesh
@@ -38,10 +39,10 @@ class MeshExport Segment
{
public:
Segment(MeshObject*, bool mod);
Segment(MeshObject*, const std::vector<unsigned long>& inds, bool mod);
void addIndices(const std::vector<unsigned long>& inds);
void removeIndices(const std::vector<unsigned long>& inds);
const std::vector<unsigned long>& getIndices() const;
Segment(MeshObject*, const std::vector<FacetIndex>& inds, bool mod);
void addIndices(const std::vector<FacetIndex>& inds);
void removeIndices(const std::vector<FacetIndex>& inds);
const std::vector<FacetIndex>& getIndices() const;
bool isEmpty() const { return _indices.empty(); }
Segment(const Segment&);
@@ -62,7 +63,7 @@ public:
private:
MeshObject* _mesh;
std::vector<unsigned long> _indices;
std::vector<FacetIndex> _indices;
std::string _name;
std::string _color;
bool _save;
@@ -72,7 +73,7 @@ public:
class MeshExport const_facet_iterator
{
public:
const_facet_iterator(const Segment*, std::vector<unsigned long>::const_iterator);
const_facet_iterator(const Segment*, std::vector<FacetIndex>::const_iterator);
const_facet_iterator(const const_facet_iterator& fi);
~const_facet_iterator();
@@ -88,7 +89,7 @@ public:
const Segment* _segment;
Facet _facet;
MeshCore::MeshFacetIterator _f_it;
std::vector<unsigned long>::const_iterator _it;
std::vector<FacetIndex>::const_iterator _it;
};
const_facet_iterator facets_begin() const
+40
View File
@@ -0,0 +1,40 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef MESH_TYPES_H
#define MESH_TYPES_H
#include "Core/Definitions.h"
namespace Mesh
{
// type definitions
using ElementIndex = MeshCore::ElementIndex;
using FacetIndex = MeshCore::FacetIndex;
using PointIndex = MeshCore::PointIndex;
} // namespace Mesh
#endif // MESH_TYPES_H
+1 -1
View File
@@ -1845,7 +1845,7 @@ void CmdMeshSplitComponents::activated(int)
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator it = objs.begin(); it != objs.end(); ++it) {
const MeshObject& mesh = static_cast<Mesh::Feature*>(*it)->Mesh.getValue();
std::vector<std::vector<unsigned long> > comps = mesh.getComponents();
std::vector<std::vector<Mesh::FacetIndex> > comps = mesh.getComponents();
for (const auto& comp : comps) {
std::unique_ptr<MeshObject> kernel(mesh.meshFromSegment(comp));
+15 -15
View File
@@ -97,7 +97,7 @@ public:
std::map<std::string, ViewProviderMeshDefects*> vp;
Mesh::Feature* meshFeature;
QPointer<Gui::View3DInventor> view;
std::vector<unsigned long> self_intersections;
std::vector<Mesh::FacetIndex> self_intersections;
bool enableFoldsCheck;
bool checkNonManfoldPoints;
bool strictlyDegenerated;
@@ -276,7 +276,7 @@ void DlgEvaluateMeshImp::setMesh(Mesh::Feature* m)
}
}
void DlgEvaluateMeshImp::addViewProvider(const char* name, const std::vector<unsigned long>& indices)
void DlgEvaluateMeshImp::addViewProvider(const char* name, const std::vector<Mesh::ElementIndex>& indices)
{
removeViewProvider(name);
@@ -440,7 +440,7 @@ void DlgEvaluateMeshImp::on_analyzeOrientationButton_clicked()
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
MeshEvalOrientation eval(rMesh);
std::vector<unsigned long> inds = eval.GetIndices();
std::vector<MeshCore::FacetIndex> inds = eval.GetIndices();
#if 0
if (inds.empty() && !eval.Evaluate()) {
d->ui.checkOrientationButton->setText(tr("Flipped normals found"));
@@ -532,7 +532,7 @@ void DlgEvaluateMeshImp::on_analyzeNonmanifoldsButton_clicked()
MeshEvalTopology f_eval(rMesh);
bool ok1 = f_eval.Evaluate();
bool ok2 = true;
std::vector<unsigned long> point_indices;
std::vector<Mesh::PointIndex> point_indices;
if (d->checkNonManfoldPoints) {
MeshEvalPointManifolds p_eval(rMesh);
@@ -555,10 +555,10 @@ void DlgEvaluateMeshImp::on_analyzeNonmanifoldsButton_clicked()
d->ui.repairAllTogether->setEnabled(true);
if (!ok1) {
const std::vector<std::pair<unsigned long, unsigned long> >& inds = f_eval.GetIndices();
std::vector<unsigned long> indices;
const std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> >& inds = f_eval.GetIndices();
std::vector<Mesh::FacetIndex> indices;
indices.reserve(2*inds.size());
std::vector<std::pair<unsigned long, unsigned long> >::const_iterator it;
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> >::const_iterator it;
for (it = inds.begin(); it != inds.end(); ++it) {
indices.push_back(it->first);
indices.push_back(it->second);
@@ -721,7 +721,7 @@ void DlgEvaluateMeshImp::on_analyzeDegeneratedButton_clicked()
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
MeshEvalDegeneratedFacets eval(rMesh, d->epsilonDegenerated);
std::vector<unsigned long> degen = eval.GetIndices();
std::vector<Mesh::FacetIndex> degen = eval.GetIndices();
if (degen.empty()) {
d->ui.checkDegenerationButton->setText(tr("No degenerations"));
@@ -787,7 +787,7 @@ void DlgEvaluateMeshImp::on_analyzeDuplicatedFacesButton_clicked()
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
MeshEvalDuplicateFacets eval(rMesh);
std::vector<unsigned long> dupl = eval.GetIndices();
std::vector<Mesh::FacetIndex> dupl = eval.GetIndices();
if (dupl.empty()) {
d->ui.checkDuplicatedFacesButton->setText(tr("No duplicated faces"));
@@ -919,7 +919,7 @@ void DlgEvaluateMeshImp::on_analyzeSelfIntersectionButton_clicked()
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
MeshEvalSelfIntersection eval(rMesh);
std::vector<std::pair<unsigned long, unsigned long> > intersection;
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> > intersection;
try {
eval.GetIntersections(intersection);
}
@@ -939,9 +939,9 @@ void DlgEvaluateMeshImp::on_analyzeSelfIntersectionButton_clicked()
d->ui.repairSelfIntersectionButton->setEnabled(true);
d->ui.repairAllTogether->setEnabled(true);
std::vector<unsigned long> indices;
std::vector<Mesh::FacetIndex> indices;
indices.reserve(2*intersection.size());
std::vector<std::pair<unsigned long, unsigned long> >::iterator it;
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> >::iterator it;
for (it = intersection.begin(); it != intersection.end(); ++it) {
indices.push_back(it->first);
indices.push_back(it->second);
@@ -1022,9 +1022,9 @@ void DlgEvaluateMeshImp::on_analyzeFoldsButton_clicked()
removeViewProvider("MeshGui::ViewProviderMeshFolds");
}
else {
std::vector<unsigned long> inds = f_eval.GetIndices();
std::vector<unsigned long> inds1 = s_eval.GetIndices();
std::vector<unsigned long> inds2 = b_eval.GetIndices();
std::vector<Mesh::FacetIndex> inds = f_eval.GetIndices();
std::vector<Mesh::FacetIndex> inds1 = s_eval.GetIndices();
std::vector<Mesh::FacetIndex> inds2 = b_eval.GetIndices();
inds.insert(inds.end(), inds1.begin(), inds1.end());
inds.insert(inds.end(), inds2.begin(), inds2.end());
+2 -1
View File
@@ -31,6 +31,7 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObserver.h>
#include <Mod/Mesh/App/Types.h>
class QAbstractButton;
@@ -127,7 +128,7 @@ protected:
void refreshList();
void showInformation();
void cleanInformation();
void addViewProvider(const char* vp, const std::vector<unsigned long>& indices);
void addViewProvider(const char* vp, const std::vector<Mesh::ElementIndex>& indices);
void removeViewProvider(const char* vp);
void removeViewProviders();
void changeEvent(QEvent *e);
+3 -3
View File
@@ -121,7 +121,7 @@ SmoothingDialog::SmoothingDialog(QWidget* parent, Qt::WindowFlags fl)
QVBoxLayout* hboxLayout = new QVBoxLayout(this);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()),
@@ -138,7 +138,7 @@ SmoothingDialog::~SmoothingDialog()
// ---------------------------------------
/* TRANSLATOR MeshGui::TaskSmoothing */
TaskSmoothing::TaskSmoothing()
{
widget = new DlgSmoothing();
@@ -180,7 +180,7 @@ bool TaskSmoothing::accept()
bool hasSelection = false;
for (std::vector<App::DocumentObject*>::const_iterator it = meshes.begin(); it != meshes.end(); ++it) {
Mesh::Feature* mesh = static_cast<Mesh::Feature*>(*it);
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
if (widget->smoothSelection()) {
// clear the selection before editing the mesh to avoid
// to have coloured triangles when doing an 'undo'
+17 -17
View File
@@ -65,7 +65,7 @@ namespace bp = boost::placeholders;
PROPERTY_SOURCE(MeshGui::ViewProviderFace, Gui::ViewProviderDocumentObject)
ViewProviderFace::ViewProviderFace() : mesh(0), current_index(-1)
ViewProviderFace::ViewProviderFace() : mesh(nullptr), current_index(-1)
{
pcCoords = new SoCoordinate3();
pcCoords->ref();
@@ -150,7 +150,7 @@ const char* ViewProviderFace::getDefaultDisplayMode() const
return "Marker";
}
std::vector<std::string> ViewProviderFace::getDisplayModes(void) const
std::vector<std::string> ViewProviderFace::getDisplayModes() const
{
std::vector<std::string> modes;
modes.push_back("Marker");
@@ -174,7 +174,7 @@ SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const Gui::V
// returns a copy of the point
SoPickedPoint* pick = rp.getPickedPoint();
//return (pick ? pick->copy() : 0); // needs the same instance of CRT under MS Windows
return (pick ? new SoPickedPoint(*pick) : 0);
return (pick ? new SoPickedPoint(*pick) : nullptr);
}
// ----------------------------------------------------------------------
@@ -314,8 +314,8 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
int index = (int)f._aulPoints[i];
if (std::find(faceView->index.begin(), faceView->index.end(), index) != faceView->index.end())
continue; // already inside
if (f._aulNeighbours[i] == ULONG_MAX ||
f._aulNeighbours[(i+2)%3] == ULONG_MAX) {
if (f._aulNeighbours[i] == MeshCore::FACET_INDEX_MAX ||
f._aulNeighbours[(i+2)%3] == MeshCore::FACET_INDEX_MAX) {
pnt = points[index];
float len = Base::DistanceP2(pnt, Base::Vector3f(vec[0],vec[1],vec[2]));
if (len < distance) {
@@ -418,8 +418,8 @@ namespace MeshGui {
// for sorting of elements
struct NofFacetsCompare
{
bool operator () (const std::vector<unsigned long> &rclC1,
const std::vector<unsigned long> &rclC2)
bool operator () (const std::vector<Mesh::PointIndex> &rclC1,
const std::vector<Mesh::PointIndex> &rclC2)
{
return rclC1.size() < rclC2.size();
}
@@ -430,7 +430,7 @@ namespace MeshGui {
MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent)
: QObject(parent)
, myMesh(0)
, myMesh(nullptr)
, myNumPoints(0)
, myVertex1(0)
, myVertex2(0)
@@ -566,7 +566,7 @@ void MeshFillHole::createPolygons()
const MeshCore::MeshKernel & rMesh = this->myMesh->Mesh.getValue().getKernel();
// get the mesh boundaries as an array of point indices
std::list<std::vector<unsigned long> > borders;
std::list<std::vector<Mesh::PointIndex> > borders;
MeshCore::MeshAlgorithm cAlgo(rMesh);
MeshCore::MeshPointIterator p_iter(rMesh);
cAlgo.GetMeshBorders(borders);
@@ -576,7 +576,7 @@ void MeshFillHole::createPolygons()
borders.sort(NofFacetsCompare());
int32_t count=0;
for (std::list<std::vector<unsigned long> >::iterator it =
for (std::list<std::vector<Mesh::PointIndex> >::iterator it =
borders.begin(); it != borders.end(); ++it) {
if (it->front() == it->back())
it->pop_back();
@@ -589,14 +589,14 @@ void MeshFillHole::createPolygons()
coords->point.setNum(count);
int32_t index = 0;
for (std::list<std::vector<unsigned long> >::iterator it =
for (std::list<std::vector<Mesh::PointIndex> >::iterator it =
borders.begin(); it != borders.end(); ++it) {
SoPolygon* polygon = new SoPolygon();
polygon->startIndex = index;
polygon->numVertices = it->size();
myBoundariesGroup->addChild(polygon);
myPolygons[polygon] = *it;
for (std::vector<unsigned long>::iterator jt = it->begin();
for (std::vector<Mesh::PointIndex>::iterator jt = it->begin();
jt != it->end(); ++jt) {
p_iter.Set(*jt);
coords->point.set1Value(index++,p_iter->x,p_iter->y,p_iter->z);
@@ -606,7 +606,7 @@ void MeshFillHole::createPolygons()
SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* root, const SbVec2s& pos*/) const
{
SoPolygon* poly = 0;
SoPolygon* poly = nullptr;
const SoPickedPointList & points = action.getPickedPointList();
for (int i=0; i < points.getLength(); i++) {
const SoPickedPoint * point = points[i];
@@ -627,11 +627,11 @@ SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* ro
}
float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon,
unsigned long& vertex_index, SbVec3f& closestPoint) const
Mesh::PointIndex& vertex_index, SbVec3f& closestPoint) const
{
// now check which vertex of the polygon is closest to the ray
float minDist = FLT_MAX;
vertex_index = ULONG_MAX;
vertex_index = MeshCore::POINT_INDEX_MAX;
const MeshCore::MeshKernel & rMesh = myMesh->Mesh.getValue().getKernel();
const MeshCore::MeshPointArray& pts = rMesh.GetPoints();
@@ -671,7 +671,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
std::map<SoNode*, TBoundary>::iterator it = self->myPolygons.find(node);
if (it != self->myPolygons.end()) {
// now check which vertex of the polygon is closest to the ray
unsigned long vertex_index;
Mesh::PointIndex vertex_index;
SbVec3f closestPoint;
float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint);
if (minDist < 1.0f) {
@@ -701,7 +701,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
std::map<SoNode*, TBoundary>::iterator it = self->myPolygons.find(node);
if (it != self->myPolygons.end()) {
// now check which vertex of the polygon is closest to the ray
unsigned long vertex_index;
Mesh::PointIndex vertex_index;
SbVec3f closestPoint;
float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint);
if (minDist < 1.0f) {
+7 -7
View File
@@ -58,7 +58,7 @@ public:
void attach(App::DocumentObject* obj);
void setDisplayMode(const char* ModeName);
const char* getDefaultDisplayMode() const;
std::vector<std::string> getDisplayModes(void) const;
std::vector<std::string> getDisplayModes() const;
SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const;
ViewProviderMesh* mesh;
@@ -110,8 +110,8 @@ public:
virtual ~MeshHoleFiller()
{
}
virtual bool fillHoles(Mesh::MeshObject&, const std::list<std::vector<unsigned long> >&,
unsigned long, unsigned long)
virtual bool fillHoles(Mesh::MeshObject&, const std::list<std::vector<Mesh::PointIndex> >&,
Mesh::PointIndex, Mesh::PointIndex)
{
return false;
}
@@ -138,14 +138,14 @@ private Q_SLOTS:
void closeBridge();
private:
typedef std::vector<unsigned long> TBoundary;
typedef std::vector<Mesh::PointIndex> TBoundary;
typedef boost::signals2::connection Connection;
static void fileHoleCallback(void * ud, SoEventCallback * n);
void createPolygons();
SoNode* getPickedPolygon(const SoRayPickAction& action) const;
float findClosestPoint(const SbLine& ray, const TBoundary& polygon,
unsigned long&, SbVec3f&) const;
Mesh::PointIndex&, SbVec3f&) const;
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop);
private:
@@ -157,8 +157,8 @@ private:
std::map<SoNode*, TBoundary> myPolygons;
Mesh::Feature* myMesh;
int myNumPoints;
unsigned long myVertex1;
unsigned long myVertex2;
Mesh::PointIndex myVertex1;
Mesh::PointIndex myVertex2;
TBoundary myPolygon;
MeshHoleFiller& myHoleFiller;
Connection myConnection;
+20 -20
View File
@@ -254,8 +254,8 @@ void MeshSelection::fullSelection()
for (std::list<ViewProviderMesh*>::iterator it = views.begin(); it != views.end(); ++it) {
Mesh::Feature* mf = static_cast<Mesh::Feature*>((*it)->getObject());
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
std::vector<unsigned long> faces(mo->countFacets());
std::generate(faces.begin(), faces.end(), Base::iotaGen<unsigned long>(0));
std::vector<Mesh::FacetIndex> faces(mo->countFacets());
std::generate(faces.begin(), faces.end(), Base::iotaGen<Mesh::FacetIndex>(0));
(*it)->addSelection(faces);
}
}
@@ -301,12 +301,12 @@ bool MeshSelection::deleteSelectionBorder()
Mesh::Feature* mf = static_cast<Mesh::Feature*>((*it)->getObject());
// mark the selected facet as visited
std::vector<unsigned long> selection, remove;
std::set<unsigned long> borderPoints;
std::vector<Mesh::FacetIndex> selection, remove;
std::set<Mesh::PointIndex> borderPoints;
MeshCore::MeshAlgorithm meshAlg(mf->Mesh.getValue().getKernel());
meshAlg.GetFacetsFlag(selection, MeshCore::MeshFacet::SELECTED);
meshAlg.GetBorderPoints(selection, borderPoints);
std::vector<unsigned long> border;
std::vector<Mesh::PointIndex> border;
border.insert(border.begin(), borderPoints.begin(), borderPoints.end());
meshAlg.ResetFacetFlag(MeshCore::MeshFacet::VISIT);
@@ -359,13 +359,13 @@ void MeshSelection::selectComponent(int size)
Mesh::Feature* mf = static_cast<Mesh::Feature*>((*it)->getObject());
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
std::vector<std::vector<unsigned long> > segm;
std::vector<std::vector<Mesh::FacetIndex> > segm;
MeshCore::MeshComponents comp(mo->getKernel());
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm);
std::vector<unsigned long> faces;
for (std::vector<std::vector<unsigned long> >::iterator jt = segm.begin(); jt != segm.end(); ++jt) {
if (jt->size() < (unsigned long)size)
std::vector<Mesh::FacetIndex> faces;
for (std::vector<std::vector<Mesh::FacetIndex> >::iterator jt = segm.begin(); jt != segm.end(); ++jt) {
if (jt->size() < (Mesh::FacetIndex)size)
faces.insert(faces.end(), jt->begin(), jt->end());
}
@@ -380,13 +380,13 @@ void MeshSelection::deselectComponent(int size)
Mesh::Feature* mf = static_cast<Mesh::Feature*>((*it)->getObject());
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
std::vector<std::vector<unsigned long> > segm;
std::vector<std::vector<Mesh::FacetIndex> > segm;
MeshCore::MeshComponents comp(mo->getKernel());
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm);
std::vector<unsigned long> faces;
for (std::vector<std::vector<unsigned long> >::iterator jt = segm.begin(); jt != segm.end(); ++jt) {
if (jt->size() > (unsigned long)size)
std::vector<Mesh::FacetIndex> faces;
for (std::vector<std::vector<Mesh::FacetIndex> >::iterator jt = segm.begin(); jt != segm.end(); ++jt) {
if (jt->size() > (Mesh::FacetIndex)size)
faces.insert(faces.end(), jt->begin(), jt->end());
}
@@ -472,7 +472,7 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
for (std::list<ViewProviderMesh*>::iterator it = views.begin(); it != views.end(); ++it) {
ViewProviderMesh* vp = *it;
std::vector<unsigned long> faces;
std::vector<Mesh::FacetIndex> faces;
const Mesh::MeshObject& mesh = static_cast<Mesh::Feature*>((*it)->getObject())->Mesh.getValue();
const MeshCore::MeshKernel& kernel = mesh.getKernel();
@@ -494,23 +494,23 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
const SbVec2s& p = *it;
rect.extendBy(SbVec2s(p[0],height-p[1]));
}
std::vector<unsigned long> rf; rf.swap(faces);
std::vector<unsigned long> vf = vp->getVisibleFacetsAfterZoom
std::vector<Mesh::FacetIndex> rf; rf.swap(faces);
std::vector<Mesh::FacetIndex> vf = vp->getVisibleFacetsAfterZoom
(rect, view->getSoRenderManager()->getViewportRegion(), view->getSoRenderManager()->getCamera());
// get common facets of the viewport and the visible one
std::sort(vf.begin(), vf.end());
std::sort(rf.begin(), rf.end());
std::back_insert_iterator<std::vector<unsigned long> > biit(faces);
std::back_insert_iterator<std::vector<Mesh::FacetIndex> > biit(faces);
std::set_intersection(vf.begin(), vf.end(), rf.begin(), rf.end(), biit);
}
// if set filter out all triangles which do not point into user direction
if (self->onlyPointToUserTriangles) {
std::vector<unsigned long> screen;
std::vector<Mesh::FacetIndex> screen;
screen.reserve(faces.size());
MeshCore::MeshFacetIterator it_f(kernel);
for (std::vector<unsigned long>::iterator it = faces.begin(); it != faces.end(); ++it) {
for (std::vector<Mesh::FacetIndex>::iterator it = faces.begin(); it != faces.end(); ++it) {
it_f.Set(*it);
if (it_f->GetNormal() * normal > 0.0f) {
screen.push_back(*it);
@@ -560,7 +560,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
const SoDetail* detail = point->getDetail(/*mesh->getShapeNode()*/);
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the boundary to the picked facet
unsigned long uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
Mesh::FacetIndex uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
if (self->addToSelection) {
if (self->addComponent)
mesh->selectComponent(uFacet);
+1 -1
View File
@@ -262,7 +262,7 @@ void ParametersDialog::on_compute_clicked()
const Mesh::MeshObject& kernel = myMesh->Mesh.getValue();
if (kernel.hasSelectedFacets()) {
FitParameter::Points fitpts;
std::vector<unsigned long> facets, points;
std::vector<Mesh::ElementIndex> facets, points;
kernel.getFacetsFromSelection(facets);
points = kernel.getPointsFromFacets(facets);
MeshCore::MeshPointArray coords = kernel.getKernel().GetPoints(points);
+16 -16
View File
@@ -388,7 +388,7 @@ void SoFCMeshPickNode::pick(SoPickAction * action)
const SbVec3f& dir = line.getDirection();
Base::Vector3f pt(pos[0],pos[1],pos[2]);
Base::Vector3f dr(dir[0],dir[1],dir[2]);
unsigned long index;
Mesh::FacetIndex index;
if (alg.NearestFacetOnRay(pt, dr, *meshGrid, pt, index)) {
SoPickedPoint* pp = raypick->addIntersection(SbVec3f(pt.x,pt.y,pt.z));
if (pp) {
@@ -1350,7 +1350,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu
const MeshCore::MeshFacetArray & rFacets = mesh->getKernel().GetFacets();
if (mesh->countSegments() <= this->index.getValue())
return;
const std::vector<unsigned long> rSegm = mesh->getSegment
const std::vector<Mesh::FacetIndex> rSegm = mesh->getSegment
(this->index.getValue()).getIndices();
bool perVertex = (mb && bind == PER_VERTEX_INDEXED);
bool perFace = (mb && bind == PER_FACE_INDEXED);
@@ -1360,7 +1360,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu
glBegin(GL_TRIANGLES);
if (ccw) {
// counterclockwise ordering
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
{
const MeshCore::MeshFacet& f = rFacets[*it];
const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]];
@@ -1389,7 +1389,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu
}
else {
// clockwise ordering
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
{
const MeshCore::MeshFacet& f = rFacets[*it];
const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]];
@@ -1412,7 +1412,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu
}
else {
glBegin(GL_TRIANGLES);
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
{
const MeshCore::MeshFacet& f = rFacets[*it];
glVertex(rPoints[f._aulPoints[0]]);
@@ -1432,7 +1432,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need
const MeshCore::MeshFacetArray & rFacets = mesh->getKernel().GetFacets();
if (mesh->countSegments() <= this->index.getValue())
return;
const std::vector<unsigned long> rSegm = mesh->getSegment
const std::vector<Mesh::FacetIndex> rSegm = mesh->getSegment
(this->index.getValue()).getIndices();
int mod = rSegm.size()/renderTriangleLimit+1;
@@ -1444,7 +1444,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need
glBegin(GL_POINTS);
int ct=0;
if (ccw) {
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
{
if (ct%mod==0) {
const MeshCore::MeshFacet& f = rFacets[*it];
@@ -1469,7 +1469,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need
}
}
else {
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
{
if (ct%mod==0) {
const MeshCore::MeshFacet& f = rFacets[*it];
@@ -1498,7 +1498,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need
else {
glBegin(GL_POINTS);
int ct=0;
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++)
{
if (ct%mod==0) {
const MeshCore::MeshFacet& f = rFacets[*it];
@@ -1536,7 +1536,7 @@ void SoFCMeshSegmentShape::generatePrimitives(SoAction* action)
return;
if (mesh->countSegments() <= this->index.getValue())
return;
const std::vector<unsigned long> rSegm = mesh->getSegment
const std::vector<Mesh::FacetIndex> rSegm = mesh->getSegment
(this->index.getValue()).getIndices();
// get material binding
@@ -1552,7 +1552,7 @@ void SoFCMeshSegmentShape::generatePrimitives(SoAction* action)
beginShape(action, TRIANGLES, &faceDetail);
try
{
for (std::vector<unsigned long>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
for (std::vector<Mesh::FacetIndex>::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it)
{
const MeshCore::MeshFacet& f = rFacets[*it];
const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]];
@@ -1618,13 +1618,13 @@ void SoFCMeshSegmentShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &
const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state);
if (mesh && mesh->countSegments() > this->index.getValue()) {
const Mesh::Segment& segm = mesh->getSegment(this->index.getValue());
const std::vector<unsigned long>& indices = segm.getIndices();
const std::vector<Mesh::FacetIndex>& indices = segm.getIndices();
Base::BoundBox3f cBox;
if (!indices.empty()) {
const MeshCore::MeshPointArray& rPoint = mesh->getKernel().GetPoints();
const MeshCore::MeshFacetArray& rFaces = mesh->getKernel().GetFacets();
for (std::vector<unsigned long>::const_iterator it = indices.begin();
for (std::vector<Mesh::FacetIndex>::const_iterator it = indices.begin();
it != indices.end(); ++it) {
const MeshCore::MeshFacet& face = rFaces[*it];
cBox.Add(rPoint[face._aulPoints[0]]);
@@ -1709,7 +1709,7 @@ void SoFCMeshObjectBoundary::drawLines(const Mesh::MeshObject * mesh) const
glBegin(GL_LINES);
for (MeshCore::MeshFacetArray::_TConstIterator it = rFacets.begin(); it != rFacets.end(); ++it) {
for (int i=0; i<3; i++) {
if (it->_aulNeighbours[i] == ULONG_MAX) {
if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
glVertex(rPoints[it->_aulPoints[i]]);
glVertex(rPoints[it->_aulPoints[(i+1)%3]]);
}
@@ -1741,7 +1741,7 @@ void SoFCMeshObjectBoundary::generatePrimitives(SoAction* action)
for (MeshCore::MeshFacetArray::_TConstIterator it = rFacets.begin(); it != rFacets.end(); ++it)
{
for (int i=0; i<3; i++) {
if (it->_aulNeighbours[i] == ULONG_MAX) {
if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
const MeshCore::MeshPoint& v0 = rPoints[it->_aulPoints[i]];
const MeshCore::MeshPoint& v1 = rPoints[it->_aulPoints[(i+1)%3]];
@@ -1805,7 +1805,7 @@ void SoFCMeshObjectBoundary::getPrimitiveCount(SoGetPrimitiveCountAction * actio
int ctEdges=0;
for (MeshCore::MeshFacetArray::_TConstIterator jt = rFaces.begin(); jt != rFaces.end(); ++jt) {
for (int i=0; i<3; i++) {
if (jt->_aulNeighbours[i] == ULONG_MAX) {
if (jt->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
ctEdges++;
}
}
+63 -59
View File
@@ -147,14 +147,14 @@ void ViewProviderMeshBuilder::createMesh(const App::Property* prop, SoCoordinate
const MeshCore::MeshPointArray& cP = rcMesh.GetPoints();
coords->point.setNum(rcMesh.CountPoints());
SbVec3f* verts = coords->point.startEditing();
unsigned long i=0;
int i=0;
for (MeshCore::MeshPointArray::_TConstIterator it = cP.begin(); it != cP.end(); ++it, i++) {
verts[i].setValue(it->x, it->y, it->z);
}
coords->point.finishEditing();
// set the face indices
unsigned long j=0;
int j=0;
const MeshCore::MeshFacetArray& cF = rcMesh.GetFacets();
faces->coordIndex.setNum(4*rcMesh.CountFacets());
int32_t* indices = faces->coordIndex.startEditing();
@@ -1211,7 +1211,7 @@ void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n)
void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
const Base::ViewProjMethod& proj,
SbBool inner,
std::vector<unsigned long>& indices) const
std::vector<Mesh::FacetIndex>& indices) const
{
const bool ok = true;
Base::Polygon2d polygon;
@@ -1225,11 +1225,11 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
if (!inner) {
// get the indices that are completely outside
std::vector<unsigned long> complete(meshProp.getValue().countFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<unsigned long>(0));
std::vector<Mesh::FacetIndex> complete(meshProp.getValue().countFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<Mesh::FacetIndex>(0));
std::sort(indices.begin(), indices.end());
std::vector<unsigned long> complementary;
std::back_insert_iterator<std::vector<unsigned long> > biit(complementary);
std::vector<Mesh::FacetIndex> complementary;
std::back_insert_iterator<std::vector<Mesh::FacetIndex> > biit(complementary);
std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit);
indices = complementary;
}
@@ -1238,7 +1238,7 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
Base::Console().Message("The picked polygon seems to have self-overlappings. This could lead to strange results.");
}
std::vector<unsigned long> ViewProviderMesh::getFacetsOfRegion(const SbViewportRegion& select,
std::vector<Mesh::FacetIndex> ViewProviderMesh::getFacetsOfRegion(const SbViewportRegion& select,
const SbViewportRegion& region,
SoCamera* camera) const
{
@@ -1251,7 +1251,7 @@ std::vector<unsigned long> ViewProviderMesh::getFacetsOfRegion(const SbViewportR
gl.apply(root);
root->unref();
std::vector<unsigned long> faces;
std::vector<Mesh::FacetIndex> faces;
faces.insert(faces.end(), gl.indices.begin(), gl.indices.end());
return faces;
}
@@ -1315,7 +1315,7 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion & vp,
}
}
std::vector<unsigned long> ViewProviderMesh::getVisibleFacetsAfterZoom(const SbBox2s& rect,
std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacetsAfterZoom(const SbBox2s& rect,
const SbViewportRegion& vp,
SoCamera* camera) const
{
@@ -1363,7 +1363,7 @@ private:
}
std::vector<unsigned long> ViewProviderMesh::getVisibleFacets(const SbViewportRegion& vp,
std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewportRegion& vp,
SoCamera* camera) const
{
#if 0
@@ -1458,14 +1458,14 @@ std::vector<unsigned long> ViewProviderMesh::getVisibleFacets(const SbViewportRe
int width = img.width();
int height = img.height();
QRgb color=0;
std::vector<unsigned long> faces;
std::vector<Mesh::FacetIndex> faces;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
QRgb rgb = img.pixel(x,y);
rgb = rgb-(0xff << 24);
if (rgb != 0 && rgb != color) {
color = rgb;
faces.push_back((unsigned long)rgb);
faces.push_back((Mesh::FacetIndex)rgb);
}
}
}
@@ -1481,7 +1481,7 @@ void ViewProviderMesh::cutMesh(const std::vector<SbVec2f>& picked,
const Base::ViewProjMethod& proj, SbBool inner)
{
// Get the facet indices inside the tool mesh
std::vector<unsigned long> indices;
std::vector<Mesh::FacetIndex> indices;
getFacetsFromPolygon(picked, proj, inner, indices);
removeFacets(indices);
}
@@ -1510,17 +1510,17 @@ void ViewProviderMesh::splitMesh(const MeshCore::MeshKernel& toolMesh, const Bas
const MeshCore::MeshKernel& meshPropKernel = meshProp.getValue().getKernel();
// Get the facet indices inside the tool mesh
std::vector<unsigned long> indices;
std::vector<Mesh::FacetIndex> indices;
MeshCore::MeshFacetGrid cGrid(meshPropKernel);
MeshCore::MeshAlgorithm cAlg(meshPropKernel);
cAlg.GetFacetsFromToolMesh(toolMesh, normal, cGrid, indices);
if (!clip_inner) {
// get the indices that are completely outside
std::vector<unsigned long> complete(meshPropKernel.CountFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<unsigned long>(0));
std::vector<Mesh::FacetIndex> complete(meshPropKernel.CountFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<Mesh::FacetIndex>(0));
std::sort(indices.begin(), indices.end());
std::vector<unsigned long> complementary;
std::back_insert_iterator<std::vector<unsigned long> > biit(complementary);
std::vector<Mesh::FacetIndex> complementary;
std::back_insert_iterator<std::vector<Mesh::FacetIndex> > biit(complementary);
std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit);
indices = complementary;
}
@@ -1542,17 +1542,17 @@ void ViewProviderMesh::segmentMesh(const MeshCore::MeshKernel& toolMesh, const B
const MeshCore::MeshKernel& meshPropKernel = meshProp.getValue().getKernel();
// Get the facet indices inside the tool mesh
std::vector<unsigned long> indices;
std::vector<Mesh::FacetIndex> indices;
MeshCore::MeshFacetGrid cGrid(meshPropKernel);
MeshCore::MeshAlgorithm cAlg(meshPropKernel);
cAlg.GetFacetsFromToolMesh(toolMesh, normal, cGrid, indices);
if (!clip_inner) {
// get the indices that are completely outside
std::vector<unsigned long> complete(meshPropKernel.CountFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<unsigned long>(0));
std::vector<Mesh::FacetIndex> complete(meshPropKernel.CountFacets());
std::generate(complete.begin(), complete.end(), Base::iotaGen<Mesh::FacetIndex>(0));
std::sort(indices.begin(), indices.end());
std::vector<unsigned long> complementary;
std::back_insert_iterator<std::vector<unsigned long> > biit(complementary);
std::vector<Mesh::FacetIndex> complementary;
std::back_insert_iterator<std::vector<Mesh::FacetIndex> > biit(complementary);
std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit);
indices = complementary;
}
@@ -1617,7 +1617,7 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n)
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the boundary to the picked facet
const SoFaceDetail* faceDetail = static_cast<const SoFaceDetail*>(detail);
unsigned long uFacet = faceDetail->getFaceIndex();
Mesh::FacetIndex uFacet = faceDetail->getFaceIndex();
that->faceInfo(uFacet);
Gui::GLFlagWindow* flags = 0;
std::list<Gui::GLGraphicsItem*> glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
@@ -1683,7 +1683,7 @@ void ViewProviderMesh::fillHoleCallback(void * ud, SoEventCallback * n)
const SoDetail* detail = point->getDetail(that->getShapeNode());
if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) {
// get the boundary to the picked facet
unsigned long uFacet = ((SoFaceDetail*)detail)->getFaceIndex();
Mesh::FacetIndex uFacet = ((SoFaceDetail*)detail)->getFaceIndex();
that->fillHole(uFacet);
}
}
@@ -1750,14 +1750,14 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n)
const SoDetail* detail = point->getDetail(that->getShapeNode());
if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) {
// get the boundary to the picked facet
unsigned long uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
Mesh::FacetIndex uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
that->selectComponent(uFacet);
}
}
}
}
void ViewProviderMesh::faceInfo(unsigned long uFacet)
void ViewProviderMesh::faceInfo(Mesh::FacetIndex uFacet)
{
Mesh::Feature* fea = static_cast<Mesh::Feature*>(this->getObject());
const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel();
@@ -1775,28 +1775,28 @@ void ViewProviderMesh::faceInfo(unsigned long uFacet)
}
}
void ViewProviderMesh::fillHole(unsigned long uFacet)
void ViewProviderMesh::fillHole(Mesh::FacetIndex uFacet)
{
// get parameter from user settings
Base::Reference<ParameterGrp> hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh");
int level = (int)hGrp->GetInt("FillHoleLevel", 2);
// get the boundary to the picked facet
std::list<unsigned long> aBorder;
std::list<Mesh::PointIndex> aBorder;
Mesh::Feature* fea = reinterpret_cast<Mesh::Feature*>(this->getObject());
const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel();
MeshCore::MeshRefPointToFacets cPt2Fac(rKernel);
MeshCore::MeshAlgorithm meshAlg(rKernel);
meshAlg.GetMeshBorder(uFacet, aBorder);
std::vector<unsigned long> boundary(aBorder.begin(), aBorder.end());
std::list<std::vector<unsigned long> > boundaries;
std::vector<Mesh::PointIndex> boundary(aBorder.begin(), aBorder.end());
std::list<std::vector<Mesh::PointIndex> > boundaries;
boundaries.push_back(boundary);
meshAlg.SplitBoundaryLoops(boundaries);
std::vector<MeshCore::MeshFacet> newFacets;
std::vector<Base::Vector3f> newPoints;
unsigned long numberOfOldPoints = rKernel.CountPoints();
for (std::list<std::vector<unsigned long> >::iterator it = boundaries.begin(); it != boundaries.end(); ++it) {
for (std::list<std::vector<Mesh::PointIndex> >::iterator it = boundaries.begin(); it != boundaries.end(); ++it) {
if (it->size() < 3/* || it->size() > 200*/)
continue;
boundary = *it;
@@ -1863,7 +1863,12 @@ void ViewProviderMesh::resetFacetTransparency()
pcShapeMaterial->transparency.setValue(0);
}
void ViewProviderMesh::removeFacets(const std::vector<unsigned long>& facets)
/*! The triangles with the passed indices are already added to the mesh. */
void ViewProviderMesh::appendFacets(const std::vector<Mesh::FacetIndex>&)
{
}
void ViewProviderMesh::removeFacets(const std::vector<Mesh::FacetIndex>& facets)
{
// Get the attached mesh property
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
@@ -1874,7 +1879,7 @@ void ViewProviderMesh::removeFacets(const std::vector<unsigned long>& facets)
bool ok = Coloring.getValue();
if (prop && prop->getSize() == static_cast<int>(kernel->countPoints())) {
std::vector<unsigned long> pointDegree;
std::vector<Mesh::PointIndex> pointDegree;
unsigned long invalid = kernel->getPointDegree(facets, pointDegree);
if (invalid > 0) {
// switch off coloring mode
@@ -1921,9 +1926,9 @@ void ViewProviderMesh::removeFacets(const std::vector<unsigned long>& facets)
Coloring.setValue(ok);
}
void ViewProviderMesh::selectFacet(unsigned long facet)
void ViewProviderMesh::selectFacet(Mesh::FacetIndex facet)
{
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.push_back(facet);
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
@@ -1941,9 +1946,9 @@ void ViewProviderMesh::selectFacet(unsigned long facet)
}
}
void ViewProviderMesh::deselectFacet(unsigned long facet)
void ViewProviderMesh::deselectFacet(Mesh::FacetIndex facet)
{
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.push_back(facet);
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
@@ -1967,16 +1972,16 @@ void ViewProviderMesh::deselectFacet(unsigned long facet)
}
}
bool ViewProviderMesh::isFacetSelected(unsigned long facet)
bool ViewProviderMesh::isFacetSelected(Mesh::FacetIndex facet)
{
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
const MeshCore::MeshFacetArray& faces = rMesh.getKernel().GetFacets();
return faces[facet].IsFlag(MeshCore::MeshFacet::SELECTED);
}
void ViewProviderMesh::selectComponent(unsigned long uFacet)
void ViewProviderMesh::selectComponent(Mesh::FacetIndex uFacet)
{
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.push_back(uFacet);
MeshCore::MeshTopFacetVisitor clVisitor(selection);
@@ -1990,9 +1995,9 @@ void ViewProviderMesh::selectComponent(unsigned long uFacet)
highlightSelection();
}
void ViewProviderMesh::deselectComponent(unsigned long uFacet)
void ViewProviderMesh::deselectComponent(Mesh::FacetIndex uFacet)
{
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.push_back(uFacet);
MeshCore::MeshTopFacetVisitor clVisitor(selection);
@@ -2009,7 +2014,7 @@ void ViewProviderMesh::deselectComponent(unsigned long uFacet)
unhighlightSelection();
}
void ViewProviderMesh::setSelection(const std::vector<unsigned long>& indices)
void ViewProviderMesh::setSelection(const std::vector<Mesh::FacetIndex>& indices)
{
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.clearFacetSelection();
@@ -2022,7 +2027,7 @@ void ViewProviderMesh::setSelection(const std::vector<unsigned long>& indices)
highlightSelection();
}
void ViewProviderMesh::addSelection(const std::vector<unsigned long>& indices)
void ViewProviderMesh::addSelection(const std::vector<Mesh::FacetIndex>& indices)
{
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.addFacetsToSelection(indices);
@@ -2031,7 +2036,7 @@ void ViewProviderMesh::addSelection(const std::vector<unsigned long>& indices)
highlightSelection();
}
void ViewProviderMesh::removeSelection(const std::vector<unsigned long>& indices)
void ViewProviderMesh::removeSelection(const std::vector<Mesh::FacetIndex>& indices)
{
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.removeFacetsFromSelection(indices);
@@ -2051,7 +2056,7 @@ void ViewProviderMesh::invertSelection()
unsigned long num_notsel = std::count_if(faces.begin(), faces.end(), [flag](const MeshCore::MeshFacet& f) {
return flag(f, MeshCore::MeshFacet::SELECTED);
});
std::vector<unsigned long> notselect;
std::vector<Mesh::FacetIndex> notselect;
notselect.reserve(num_notsel);
MeshCore::MeshFacetArray::_TConstIterator beg = faces.begin();
MeshCore::MeshFacetArray::_TConstIterator end = faces.end();
@@ -2071,7 +2076,7 @@ void ViewProviderMesh::clearSelection()
void ViewProviderMesh::deleteSelection()
{
std::vector<unsigned long> indices;
std::vector<Mesh::FacetIndex> indices;
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
const Mesh::MeshObject& rMesh = meshProp.getValue();
rMesh.getFacetsFromSelection(indices);
@@ -2084,7 +2089,6 @@ void ViewProviderMesh::deleteSelection()
bool ViewProviderMesh::hasSelection() const
{
std::vector<unsigned long> indices;
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
const Mesh::MeshObject& rMesh = meshProp.getValue();
return rMesh.hasSelectedFacets();
@@ -2096,7 +2100,7 @@ void ViewProviderMesh::selectArea(short x, short y, short w, short h,
{
SbViewportRegion vp;
vp.setViewportPixels (x, y, w, h);
std::vector<unsigned long> faces = getFacetsOfRegion(vp, region, camera);
std::vector<Mesh::FacetIndex> faces = getFacetsOfRegion(vp, region, camera);
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.addFacetsToSelection(faces);
@@ -2107,7 +2111,7 @@ void ViewProviderMesh::selectArea(short x, short y, short w, short h,
void ViewProviderMesh::highlightSelection()
{
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.getFacetsFromSelection(selection);
if (selection.empty()) {
@@ -2125,7 +2129,7 @@ void ViewProviderMesh::highlightSelection()
SbColor* cols = pcShapeMaterial->diffuseColor.startEditing();
for (int i=0; i<uCtFacets; i++)
cols[i].setValue(c.r,c.g,c.b);
for (std::vector<unsigned long>::iterator it = selection.begin(); it != selection.end(); ++it)
for (std::vector<Mesh::FacetIndex>::iterator it = selection.begin(); it != selection.end(); ++it)
cols[*it].setValue(1.0f,0.0f,0.0f);
pcShapeMaterial->diffuseColor.finishEditing();
}
@@ -2153,7 +2157,7 @@ void ViewProviderMesh::setHighlightedComponents(bool on)
void ViewProviderMesh::highlightComponents()
{
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
std::vector<std::vector<unsigned long> > comps = rMesh.getComponents();
std::vector<std::vector<Mesh::FacetIndex> > comps = rMesh.getComponents();
// Colorize the components
pcMatBinding->value = SoMaterialBinding::PER_FACE;
@@ -2161,12 +2165,12 @@ void ViewProviderMesh::highlightComponents()
pcShapeMaterial->diffuseColor.setNum(uCtFacets);
SbColor* cols = pcShapeMaterial->diffuseColor.startEditing();
for (std::vector<std::vector<unsigned long> >::iterator it = comps.begin(); it != comps.end(); ++it) {
for (std::vector<std::vector<Mesh::FacetIndex> >::iterator it = comps.begin(); it != comps.end(); ++it) {
float fMax = (float)RAND_MAX;
float fRed = (float)rand()/fMax;
float fGrn = (float)rand()/fMax;
float fBlu = (float)rand()/fMax;
for (std::vector<unsigned long>::iterator jt = it->begin(); jt != it->end(); ++jt) {
for (std::vector<Mesh::FacetIndex>::iterator jt = it->begin(); jt != it->end(); ++jt) {
cols[*jt].setValue(fRed,fGrn,fBlu);
}
}
@@ -2213,11 +2217,11 @@ void ViewProviderMesh::highlightSegments(const std::vector<App::Color>& colors)
pcShapeMaterial->diffuseColor.setNum(uCtFacets);
SbColor* cols = pcShapeMaterial->diffuseColor.startEditing();
for (unsigned long i=0; i<numSegm; i++) {
std::vector<unsigned long> segm = rMesh.getSegment(i).getIndices();
std::vector<Mesh::FacetIndex> segm = rMesh.getSegment(i).getIndices();
float fRed = colors[i].r;
float fGrn = colors[i].g;
float fBlu = colors[i].b;
for (std::vector<unsigned long>::iterator it = segm.begin(); it != segm.end(); ++it) {
for (std::vector<Mesh::FacetIndex>::iterator it = segm.begin(); it != segm.end(); ++it) {
cols[*it].setValue(fRed,fGrn,fBlu);
}
}
@@ -2311,7 +2315,7 @@ void ViewProviderIndexedFaceSet::showOpenEdges(bool show)
const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets();
for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
for (int i=0; i<3; i++) {
if (it->_aulNeighbours[i] == ULONG_MAX) {
if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
lines->coordIndex.set1Value(index++,it->_aulPoints[i]);
lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]);
lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX);
+17 -15
View File
@@ -27,6 +27,7 @@
#include <Inventor/fields/SoSFVec2f.h>
#include <Mod/Mesh/App/Core/Elements.h>
#include <Mod/Mesh/App/Types.h>
#include <Gui/ViewProviderGeometryObject.h>
#include <Gui/ViewProviderBuilder.h>
#include <App/PropertyStandard.h>
@@ -142,27 +143,28 @@ public:
/** @name Editing */
//@{
bool doubleClicked(void){ return false; }
bool isFacetSelected(unsigned long facet);
void selectComponent(unsigned long facet);
void deselectComponent(unsigned long facet);
void selectFacet(unsigned long facet);
void deselectFacet(unsigned long facet);
void setSelection(const std::vector<unsigned long>&);
void addSelection(const std::vector<unsigned long>&);
void removeSelection(const std::vector<unsigned long>&);
bool isFacetSelected(Mesh::FacetIndex facet);
void selectComponent(Mesh::FacetIndex facet);
void deselectComponent(Mesh::FacetIndex facet);
void selectFacet(Mesh::FacetIndex facet);
void deselectFacet(Mesh::FacetIndex facet);
void setSelection(const std::vector<Mesh::FacetIndex>&);
void addSelection(const std::vector<Mesh::FacetIndex>&);
void removeSelection(const std::vector<Mesh::FacetIndex>&);
void invertSelection();
void clearSelection();
void deleteSelection();
bool hasSelection() const;
void getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
const Base::ViewProjMethod& proj, SbBool inner,
std::vector<unsigned long>& indices) const;
std::vector<unsigned long> getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacets(const SbViewportRegion&, SoCamera*) const;
std::vector<Mesh::FacetIndex>& indices) const;
std::vector<Mesh::FacetIndex> getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const;
std::vector<Mesh::FacetIndex> getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const;
std::vector<Mesh::FacetIndex> getVisibleFacets(const SbViewportRegion&, SoCamera*) const;
virtual void cutMesh(const std::vector<SbVec2f>& picked, const Base::ViewProjMethod& proj, SbBool inner);
virtual void trimMesh(const std::vector<SbVec2f>& picked, const Base::ViewProjMethod& proj, SbBool inner);
virtual void removeFacets(const std::vector<unsigned long>&);
virtual void appendFacets(const std::vector<Mesh::FacetIndex>&);
virtual void removeFacets(const std::vector<Mesh::FacetIndex>&);
/*! The size of the array must be equal to the number of facets. */
void setFacetTransparency(const std::vector<float>&);
void resetFacetTransparency();
@@ -180,8 +182,8 @@ protected:
void setOpenEdgeColorFrom(const App::Color& col);
virtual void splitMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner);
virtual void segmentMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner);
virtual void faceInfo(unsigned long facet);
virtual void fillHole(unsigned long facet);
virtual void faceInfo(Mesh::FacetIndex facet);
virtual void fillHole(Mesh::FacetIndex facet);
virtual void selectArea(short, short, short, short, const SbViewportRegion&, SoCamera*);
virtual void highlightSelection();
virtual void unhighlightSelection();
+1 -1
View File
@@ -340,7 +340,7 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
// curvature values
std::vector<float> fValues = pCurvInfo->getCurvature( mode );
unsigned long j=0;
int j=0;
for ( std::vector<float>::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++ ) {
App::Color col = pcColorBar->getColor( *jt );
pcColorMat->diffuseColor.set1Value(j, SbColor(col.r, col.g, col.b));
+38 -38
View File
@@ -149,7 +149,7 @@ void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcFaceRoot, "Face");
}
void ViewProviderMeshOrientation::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshOrientation::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
@@ -157,9 +157,9 @@ void ViewProviderMeshOrientation::showDefects(const std::vector<unsigned long>&
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cF.Set(*it);
for (int k=0; k<3; k++) {
Base::Vector3f cP = cF->_aclPoints[k];
@@ -214,7 +214,7 @@ void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcLineRoot, "Line");
}
void ViewProviderMeshNonManifolds::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshNonManifolds::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
if ((inds.size() % 2) != 0)
return;
@@ -224,9 +224,9 @@ void ViewProviderMeshNonManifolds::showDefects(const std::vector<unsigned long>&
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(inds.size());
MeshCore::MeshPointIterator cP(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cP.Set(*it);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
++it; // go to end point
@@ -279,15 +279,15 @@ void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcPointRoot, "Point");
}
void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
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());
MeshCore::MeshPointIterator cP(rMesh);
unsigned long i = 0;
for ( std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it ) {
int i = 0;
for ( std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it ) {
cP.Set(*it);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
}
@@ -343,7 +343,7 @@ void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcFaceRoot, "Face");
}
void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
@@ -351,9 +351,9 @@ void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<unsigned lon
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cF.Set(*it);
for (int k=0; k<3; k++) {
Base::Vector3f cP = cF->_aclPoints[k];
@@ -408,15 +408,15 @@ void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcPointRoot, "Point");
}
void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
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());
MeshCore::MeshPointIterator cP(rMesh);
unsigned long i = 0;
for ( std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it ) {
int i = 0;
for ( std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it ) {
cP.Set(*it);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
}
@@ -465,7 +465,7 @@ void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcLineRoot, "Line");
}
void ViewProviderMeshDegenerations::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshDegenerations::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
@@ -473,9 +473,9 @@ void ViewProviderMeshDegenerations::showDefects(const std::vector<unsigned long>
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(2*inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cF.Set(*it);
const MeshCore::MeshPoint& rE0 = cF->_aclPoints[0];
const MeshCore::MeshPoint& rE1 = cF->_aclPoints[1];
@@ -571,7 +571,7 @@ void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcFaceRoot, "Face");
}
void ViewProviderMeshIndices::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshIndices::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
@@ -580,9 +580,9 @@ void ViewProviderMeshIndices::showDefects(const std::vector<unsigned long>& inds
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cF.Set(*it);
for (int k=0; k<3; k++) {
Base::Vector3f cP = cF->_aclPoints[k];
@@ -638,7 +638,7 @@ void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcLineRoot, "Line");
}
void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned long>& indices)
void ViewProviderMeshSelfIntersections::showDefects(const std::vector<Mesh::ElementIndex>& indices)
{
if (indices.size() % 2 != 0)
return;
@@ -646,12 +646,12 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned l
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
MeshCore::MeshEvalSelfIntersection eval(rMesh);
std::vector<std::pair<unsigned long, unsigned long> > intersection;
std::vector<unsigned long>::const_iterator it;
std::vector<std::pair<Mesh::ElementIndex, Mesh::ElementIndex> > intersection;
std::vector<Mesh::ElementIndex>::const_iterator it;
for (it = indices.begin(); it != indices.end(); ) {
unsigned long id1 = *it; ++it;
unsigned long id2 = *it; ++it;
intersection.emplace_back(id1,id2);
Mesh::ElementIndex id1 = *it; ++it;
Mesh::ElementIndex id2 = *it; ++it;
intersection.push_back(std::make_pair(id1,id2));
}
std::vector<std::pair<Base::Vector3f, Base::Vector3f> > lines;
@@ -659,8 +659,8 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned l
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(2*lines.size());
unsigned long i=0;
unsigned long j=0;
int i=0;
int j=0;
for (std::vector<std::pair<Base::Vector3f, Base::Vector3f> >::const_iterator it = lines.begin(); it != lines.end(); ++it) {
pcCoords->point.set1Value(i++,it->first.x,it->first.y,it->first.z);
pcCoords->point.set1Value(i++,it->second.x,it->second.y,it->second.z);
@@ -718,7 +718,7 @@ void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
addDisplayMaskMode(pcFaceRoot, "Face");
}
void ViewProviderMeshFolds::showDefects(const std::vector<unsigned long>& inds)
void ViewProviderMeshFolds::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
@@ -726,9 +726,9 @@ void ViewProviderMeshFolds::showDefects(const std::vector<unsigned long>& inds)
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
unsigned long i=0;
unsigned long j=0;
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
cF.Set(*it);
for (int k=0; k<3; k++) {
Base::Vector3f cP = cF->_aclPoints[k];
+10 -10
View File
@@ -50,7 +50,7 @@ public:
// Build up the initial Inventor node
virtual void attach(App::DocumentObject* pcFeature) = 0;
/// Fill up the Inventor node with data
virtual void showDefects(const std::vector<unsigned long>&) = 0;
virtual void showDefects(const std::vector<Mesh::ElementIndex>&) = 0;
protected:
/// get called by the container whenever a property has been changed
@@ -72,7 +72,7 @@ public:
virtual ~ViewProviderMeshOrientation();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoFaceSet* pcFaces;
@@ -90,7 +90,7 @@ public:
virtual ~ViewProviderMeshNonManifolds();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoLineSet* pcLines;
@@ -108,7 +108,7 @@ public:
virtual ~ViewProviderMeshNonManifoldPoints();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoPointSet* pcPoints;
@@ -126,7 +126,7 @@ public:
virtual ~ViewProviderMeshDuplicatedFaces();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoFaceSet* pcFaces;
@@ -144,7 +144,7 @@ public:
virtual ~ViewProviderMeshDegenerations();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoLineSet* pcLines;
@@ -159,7 +159,7 @@ public:
virtual ~ViewProviderMeshDuplicatedPoints();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoPointSet* pcPoints;
@@ -174,7 +174,7 @@ public:
virtual ~ViewProviderMeshIndices();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoFaceSet* pcFaces;
@@ -192,7 +192,7 @@ public:
virtual ~ViewProviderMeshSelfIntersections();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoLineSet* pcLines;
@@ -207,7 +207,7 @@ public:
virtual ~ViewProviderMeshFolds();
void attach(App::DocumentObject* pcFeature);
void showDefects(const std::vector<unsigned long>&);
void showDefects(const std::vector<Mesh::ElementIndex>&);
protected:
SoFaceSet* pcFaces;
+3 -3
View File
@@ -167,7 +167,7 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop)
}
showOpenEdges(OpenEdges.getValue());
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
mesh->getFacetsFromSelection(selection);
if (selection.empty())
unhighlightSelection();
@@ -181,7 +181,7 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show)
if (pcOpenEdge) {
// remove the node and destroy the data
pcRoot->removeChild(pcOpenEdge);
pcOpenEdge = 0;
pcOpenEdge = nullptr;
}
if (show) {
@@ -204,7 +204,7 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show)
const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets();
for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
for (int i=0; i<3; i++) {
if (it->_aulNeighbours[i] == ULONG_MAX) {
if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
lines->coordIndex.set1Value(index++,it->_aulPoints[i]);
lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]);
lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX);
+6 -6
View File
@@ -51,11 +51,11 @@ PyObject* ViewProviderMeshPy::setSelection(PyObject *args)
return 0;
Py::Sequence list(obj);
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.reserve(list.size());
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Long index(*it);
unsigned long value = static_cast<unsigned long>(index);
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
selection.push_back(value);
}
@@ -71,11 +71,11 @@ PyObject* ViewProviderMeshPy::addSelection(PyObject *args)
return 0;
Py::Sequence list(obj);
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.reserve(list.size());
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Long index(*it);
unsigned long value = static_cast<unsigned long>(index);
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
selection.push_back(value);
}
@@ -91,11 +91,11 @@ PyObject* ViewProviderMeshPy::removeSelection(PyObject *args)
return 0;
Py::Sequence list(obj);
std::vector<unsigned long> selection;
std::vector<Mesh::FacetIndex> selection;
selection.reserve(list.size());
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Long index(*it);
unsigned long value = static_cast<unsigned long>(index);
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
selection.push_back(value);
}
@@ -150,7 +150,7 @@ void ViewProviderMeshTransformDemolding::calcMaterialIndex(const SbRotation &rot
// 3.1415926535897932384626433832795
SbVec3f Up(0,0,1),result;
unsigned long i=0;
int i=0;
for( std::vector<SbVec3f>::const_iterator it=normalVector.begin();it != normalVector.end(); ++it,i++)
{
rot.multVec(*it,result);
+1 -1
View File
@@ -419,7 +419,7 @@ private:
Py::List list(o);
Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
std::vector<unsigned long> segm;
std::vector<MeshCore::FacetIndex> segm;
segm.reserve(list.size());
for (Py_ssize_t i=0; i<list.size(); i++) {
segm.push_back((long)Py::Long(list[i]));
+33 -33
View File
@@ -132,9 +132,9 @@ void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge,
(float)gpPt.Y(),
(float)gpPt.Z());
Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal;
unsigned long uStartFacetIdx,uCurFacetIdx;
unsigned long uLastFacetIdx=ULONG_MAX-1; // use another value as ULONG_MAX
unsigned long auNeighboursIdx[3];
MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx;
MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as FACET_INDEX_MAX
MeshCore::FacetIndex auNeighboursIdx[3];
bool GoOn;
if( !findStartPoint(_Mesh,cStartPoint,cResultPoint,uStartFacetIdx) )
@@ -159,7 +159,7 @@ void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge,
const Base::Vector3f& cP0 = cCurFacet._aclPoints[i];
const Base::Vector3f& cP1 = cCurFacet._aclPoints[(i+1)%3];
if ( auNeighboursIdx[i] != ULONG_MAX )
if ( auNeighboursIdx[i] != MeshCore::FACET_INDEX_MAX )
{
// calculate the normal by the edge vector and the middle between the two face normals
MeshGeomFacet N = _Mesh.GetFacet( auNeighboursIdx[i] );
@@ -227,7 +227,7 @@ void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge,
}
bool CurveProjectorShape::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex)
bool CurveProjectorShape::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex)
{
Base::Vector3f TempResultPoint;
float MinLength = FLOAT_MAX;
@@ -332,7 +332,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
str.precision(4);
str.setf(std::ios::fixed | std::ios::showpoint);
std::map<unsigned long,std::vector<Base::Vector3f> > FaceProjctMap;
std::map<MeshCore::FacetIndex,std::vector<Base::Vector3f> > FaceProjctMap;
for (unsigned long i = 0; i <= ulNbOfPoints; i++)
{
@@ -387,7 +387,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
MeshGeomFacet cCurFacet= MeshK.GetFacet(uCurFacetIdx);
MeshK.GetFacetNeighbours ( uCurFacetIdx, auNeighboursIdx[0], auNeighboursIdx[1], auNeighboursIdx[2]);
uCurFacetIdx = ULONG_MAX;
uCurFacetIdx = MeshCore::FACET_INDEX_MAX;
PointCount = 0;
for(int i=0; i<3; i++)
@@ -405,7 +405,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
}
}while(uCurFacetIdx != ULONG_MAX);
}while(uCurFacetIdx != MeshCore::FACET_INDEX_MAX);
*/
}
@@ -425,9 +425,9 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
// projection of the first point
Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z());
Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal,TempResultPoint;
unsigned long uStartFacetIdx,uCurFacetIdx;
unsigned long uLastFacetIdx=ULONG_MAX-1; // use another value as ULONG_MAX
unsigned long auNeighboursIdx[3];
MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx;
MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as FACET_INDEX_MAX
MeshCore::FacetIndex auNeighboursIdx[3];
bool GoOn;
// go through the whole Mesh, find the first projection
@@ -471,7 +471,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
for(int i=0; i<3; i++)
{
// if the i'th neighbour is valid
if ( auNeighboursIdx[i] != ULONG_MAX )
if ( auNeighboursIdx[i] != MeshCore::FACET_INDEX_MAX )
{
// try to project next interval
MeshGeomFacet N = MeshK.GetFacet( auNeighboursIdx[i] );
@@ -511,9 +511,9 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
// projection of the first point
Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z());
Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal;
unsigned long uStartFacetIdx,uCurFacetIdx;
unsigned long uLastFacetIdx=ULONG_MAX-1; // use another value as ULONG_MAX
unsigned long auNeighboursIdx[3];
MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx;
MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as FACET_INDEX_MAX
MeshCore::FacetIndex auNeighboursIdx[3];
bool GoOn;
if( !findStartPoint(MeshK,cStartPoint,cResultPoint,uStartFacetIdx) )
@@ -542,7 +542,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge,
}
*/
bool CurveProjectorSimple::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex)
bool CurveProjectorSimple::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex)
{
Base::Vector3f TempResultPoint;
float MinLength = FLOAT_MAX;
@@ -621,7 +621,7 @@ void CurveProjectorWithToolMesh::makeToolMesh( const TopoDS_Edge& aEdge,std::vec
Base::SequencerLauncher seq("Building up tool mesh...", ulNbOfPoints+1);
std::map<unsigned long,std::vector<Base::Vector3f> > FaceProjctMap;
std::map<MeshCore::FacetIndex,std::vector<Base::Vector3f> > FaceProjctMap;
for (unsigned long i = 0; i < ulNbOfPoints; i++)
{
@@ -878,7 +878,7 @@ void MeshProjection::projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
for (auto it : pointsIn) {
Base::Vector3f result;
unsigned long index;
MeshCore::FacetIndex index;
if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) {
MeshCore::MeshGeomFacet geomFacet = _rcMesh.GetFacet(index);
if (tolerance > 0 && geomFacet.IntersectPlaneWithLine(it, dir, result)) {
@@ -943,13 +943,13 @@ void MeshProjection::projectParallelToMesh (const TopoDS_Shape &aShape, const Ba
std::vector<Base::Vector3f> points;
discretize(aEdge, points, 5);
typedef std::pair<Base::Vector3f, unsigned long> HitPoint;
typedef std::pair<Base::Vector3f, MeshCore::FacetIndex> HitPoint;
std::vector<HitPoint> hitPoints;
typedef std::pair<HitPoint, HitPoint> HitPoints;
std::vector<HitPoints> hitPointPairs;
for (auto it : points) {
Base::Vector3f result;
unsigned long index;
MeshCore::FacetIndex index;
if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) {
hitPoints.emplace_back(result, index);
@@ -988,13 +988,13 @@ void MeshProjection::projectParallelToMesh (const std::vector<PolyLine> &aEdges,
for (auto it : aEdges) {
std::vector<Base::Vector3f> points = it.points;
typedef std::pair<Base::Vector3f, unsigned long> HitPoint;
typedef std::pair<Base::Vector3f, MeshCore::FacetIndex> HitPoint;
std::vector<HitPoint> hitPoints;
typedef std::pair<HitPoint, HitPoint> HitPoints;
std::vector<HitPoints> hitPointPairs;
for (auto it : points) {
Base::Vector3f result;
unsigned long index;
MeshCore::FacetIndex index;
if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) {
hitPoints.emplace_back(result, index);
@@ -1024,8 +1024,8 @@ void MeshProjection::projectParallelToMesh (const std::vector<PolyLine> &aEdges,
void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist, const MeshFacetGrid& rGrid,
std::vector<SplitEdge>& rSplitEdges ) const
{
std::vector<unsigned long> auFInds;
std::map<std::pair<unsigned long, unsigned long>, std::list<unsigned long> > pEdgeToFace;
std::vector<MeshCore::FacetIndex> auFInds;
std::map<std::pair<MeshCore::PointIndex, MeshCore::PointIndex>, std::list<MeshCore::FacetIndex> > pEdgeToFace;
const std::vector<MeshFacet>& rclFAry = _rcMesh.GetFacets();
// search the facets in the local area of the curve
@@ -1038,12 +1038,12 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist
auFInds.erase(std::unique(auFInds.begin(), auFInds.end()), auFInds.end());
// facet to edge
for ( std::vector<unsigned long>::iterator pI = auFInds.begin(); pI != auFInds.end(); ++pI ) {
for ( std::vector<MeshCore::FacetIndex>::iterator pI = auFInds.begin(); pI != auFInds.end(); ++pI ) {
const MeshFacet& rF = rclFAry[*pI];
for (int i = 0; i < 3; i++) {
unsigned long ulPt0 = std::min<unsigned long>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
unsigned long ulPt1 = std::max<unsigned long>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
pEdgeToFace[std::pair<unsigned long, unsigned long>(ulPt0, ulPt1)].push_front(*pI);
MeshCore::PointIndex ulPt0 = std::min<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
MeshCore::PointIndex ulPt1 = std::max<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
pEdgeToFace[std::pair<MeshCore::PointIndex, MeshCore::PointIndex>(ulPt0, ulPt1)].push_front(*pI);
}
}
@@ -1063,26 +1063,26 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist
MeshFacetIterator cFI( _rcMesh );
Base::SequencerLauncher seq( "Project curve on mesh", pEdgeToFace.size() );
std::map<std::pair<unsigned long, unsigned long>, std::list<unsigned long> >::iterator it;
std::map<std::pair<MeshCore::PointIndex, MeshCore::PointIndex>, std::list<MeshCore::FacetIndex> >::iterator it;
for ( it = pEdgeToFace.begin(); it != pEdgeToFace.end(); ++it ) {
seq.next();
// edge points
unsigned long uE0 = it->first.first;
MeshCore::PointIndex uE0 = it->first.first;
cPI.Set( uE0 );
Base::Vector3f cE0 = *cPI;
unsigned long uE1 = it->first.second;
MeshCore::PointIndex uE1 = it->first.second;
cPI.Set( uE1 );
Base::Vector3f cE1 = *cPI;
const std::list<unsigned long>& auFaces = it->second;
const std::list<MeshCore::FacetIndex>& auFaces = it->second;
if ( auFaces.size() > 2 )
continue; // non-manifold edge -> don't handle this
// if ( clBB.IsOut( gp_Pnt(cE0.x, cE0.y, cE0.z) ) && clBB.IsOut( gp_Pnt(cE1.x, cE1.y, cE1.z) ) )
// continue;
Base::Vector3f cEdgeNormal;
for ( std::list<unsigned long>::const_iterator itF = auFaces.begin(); itF != auFaces.end(); ++itF ) {
for ( std::list<MeshCore::FacetIndex>::const_iterator itF = auFaces.begin(); itF != auFaces.end(); ++itF ) {
cFI.Set( *itF );
cEdgeNormal += cFI->GetNormal();
}
+4 -4
View File
@@ -57,7 +57,7 @@ public:
struct FaceSplitEdge
{
unsigned long ulFaceIndex;
MeshCore::FacetIndex ulFaceIndex;
Base::Vector3f p1,p2;
};
@@ -95,7 +95,7 @@ public:
void projectCurve(const TopoDS_Edge& aEdge,
std::vector<FaceSplitEdge> &vSplitEdges);
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex);
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex);
@@ -121,7 +121,7 @@ public:
const std::vector<Base::Vector3f> &rclPoints,
std::vector<FaceSplitEdge> &vSplitEdges);
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex);
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex);
@@ -162,7 +162,7 @@ public:
/// Helper class
struct SplitEdge
{
unsigned long uE0, uE1; /**< start and endpoint of an edge */
MeshCore::PointIndex uE0, uE1; /**< start and endpoint of an edge */
Base::Vector3f cPt; /**< Point on edge (\a uE0, \a uE1) */
};
struct Edge
+3 -3
View File
@@ -67,7 +67,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
Base::Builder3D builder;
std::vector<Base::Vector3f> PointNormals= Mesh->CalcVertexNormals();
std::vector<Base::Vector3f> FaceNormals;
std::set<unsigned long> fliped;
std::set<MeshCore::FacetIndex> fliped;
MeshFacetIterator it(*Mesh);
for ( it.Init(); it.More(); it.Next() )
@@ -103,7 +103,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
if(fliped.size() == 0)
break;
for(std::set<unsigned long>::iterator It= fliped.begin();It!=fliped.end();++It)
for(std::set<MeshCore::FacetIndex>::iterator It= fliped.begin();It!=fliped.end();++It)
alg.CollapseFacet(*It);
fliped.clear();
}
@@ -112,7 +112,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
// search for intersected facets
MeshCore::MeshEvalSelfIntersection eval(*Mesh);
std::vector<std::pair<unsigned long, unsigned long> > faces;
std::vector<std::pair<MeshCore::FacetIndex, MeshCore::FacetIndex> > faces;
eval.GetIntersections(faces);
+3 -3
View File
@@ -186,7 +186,7 @@ public:
Standard_Real x2, y2, z2;
Standard_Real x3, y3, z3;
std::vector< std::vector<unsigned long> > meshSegments;
std::vector< std::vector<MeshCore::FacetIndex> > meshSegments;
std::size_t numMeshFaces = 0;
for (std::size_t i = 0; i < domains.size(); ++i) {
@@ -256,8 +256,8 @@ public:
// add a segment for the face
if (createSegm || this->segments) {
std::vector<unsigned long> segment(numDomainFaces);
std::generate(segment.begin(), segment.end(), Base::iotaGen<unsigned long>(numMeshFaces));
std::vector<MeshCore::FacetIndex> segment(numDomainFaces);
std::generate(segment.begin(), segment.end(), Base::iotaGen<MeshCore::FacetIndex>(numMeshFaces));
numMeshFaces += numDomainFaces;
meshSegments.push_back(segment);
}
+1 -1
View File
@@ -217,7 +217,7 @@ class CurveOnMeshHandler::Private
public:
struct PickedPoint
{
unsigned long facet;
MeshCore::FacetIndex facet;
SbVec3f point;
SbVec3f normal;
};
@@ -466,7 +466,7 @@ void ImageTriangulation::perform()
const MeshCore::MeshFacetArray& face = kernel.GetFacets();
MeshCore::MeshAlgorithm meshAlg(kernel);
meshAlg.SetPointFlag(MeshCore::MeshPoint::INVALID);
std::vector<unsigned long> validPoints;
std::vector<MeshCore::PointIndex> validPoints;
validPoints.reserve(face.size()*3);
for (MeshCore::MeshFacetArray::_TConstIterator it = face.begin(); it != face.end(); ++it) {
validPoints.push_back(it->_aulPoints[0]);
@@ -481,7 +481,7 @@ void ImageTriangulation::perform()
unsigned long countInvalid = meshAlg.CountPointFlag(MeshCore::MeshPoint::INVALID);
if (countInvalid > 0) {
std::vector<unsigned long> invalidPoints;
std::vector<MeshCore::PointIndex> invalidPoints;
invalidPoints.reserve(countInvalid);
meshAlg.GetPointsFlag(invalidPoints, MeshCore::MeshPoint::INVALID);
+3 -3
View File
@@ -227,8 +227,8 @@ void CmdApproxCylinder::activated(int)
// get normals
{
std::vector<unsigned long> facets(kernel.CountFacets());
std::generate(facets.begin(), facets.end(), Base::iotaGen<unsigned long>(0));
std::vector<MeshCore::FacetIndex> facets(kernel.CountFacets());
std::generate(facets.begin(), facets.end(), Base::iotaGen<MeshCore::FacetIndex>(0));
std::vector<Base::Vector3f> normals = kernel.GetFacetNormals(facets);
Base::Vector3f base = fit.GetGravity();
Base::Vector3f axis = fit.GetInitialAxisFromNormals(normals);
@@ -460,7 +460,7 @@ void CmdSegmentationFromComponents::activated(int)
group->Label.setValue(labelname);
const Mesh::MeshObject& mesh = it->Mesh.getValue();
std::vector<std::vector<unsigned long> > comps = mesh.getComponents();
std::vector<std::vector<MeshCore::FacetIndex> > comps = mesh.getComponents();
for (auto jt : comps) {
std::unique_ptr<Mesh::MeshObject> segment(mesh.meshFromSegment(jt));
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
@@ -111,7 +111,7 @@ void Segmentation::accept()
// For each planar segment compute a plane and use this then for a more accurate 2nd segmentation
if (strcmp((*it)->GetType(), "Plane") == 0) {
for (std::vector<MeshCore::MeshSegment>::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
std::vector<unsigned long> indexes = kernel.GetFacetPoints(*jt);
std::vector<MeshCore::PointIndex> indexes = kernel.GetFacetPoints(*jt);
MeshCore::PlaneFit fit;
fit.AddPoints(kernel.GetPoints(indexes));
if (fit.Fit() < FLOAT_MAX) {
@@ -213,7 +213,7 @@ void Segmentation::accept()
if (createUnused) {
// collect all facets that don't have set the flag TMP0
std::vector<unsigned long> unusedFacets;
std::vector<MeshCore::FacetIndex> unusedFacets;
algo.GetFacetsFlag(unusedFacets, MeshCore::MeshFacet::TMP0);
if (!unusedFacets.empty()) {
@@ -130,7 +130,8 @@ static void findGeometry(int minFaces, double tolerance,
if (mesh.hasSelectedFacets()) {
const MeshCore::MeshKernel& kernel = mesh.getKernel();
std::vector<unsigned long> facets, vertexes;
std::vector<MeshCore::FacetIndex> facets;
std::vector<MeshCore::PointIndex> vertexes;
mesh.getFacetsFromSelection(facets);
vertexes = mesh.getPointsFromFacets(facets);
MeshCore::MeshPointArray coords = kernel.GetPoints(vertexes);
@@ -244,7 +245,7 @@ void SegmentationManual::createSegment()
if (ct > 0) {
selected = true;
std::vector<unsigned long> facets;
std::vector<MeshCore::FacetIndex> facets;
algo.GetFacetsFlag(facets, MeshCore::MeshFacet::SELECTED);
std::unique_ptr<Mesh::MeshObject> segment(mesh.meshFromSegment(facets));