From 1b46fc55b7f3d8c7adb1d98738170b21243ae236 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 18 May 2012 19:07:27 +0200 Subject: [PATCH] Mesh segmentation --- src/Mod/Mesh/App/Core/Segmentation.cpp | 14 ++++++++++++-- src/Mod/Mesh/App/Core/Segmentation.h | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Mod/Mesh/App/Core/Segmentation.cpp b/src/Mod/Mesh/App/Core/Segmentation.cpp index 450a7a067..2e86fdb17 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.cpp +++ b/src/Mod/Mesh/App/Core/Segmentation.cpp @@ -35,6 +35,10 @@ void MeshSurfaceSegment::Initialize(unsigned long) { } +void MeshSurfaceSegment::AddFacet(const MeshFacet&) +{ +} + void MeshSurfaceSegment::AddSegment(const std::vector& segm) { if (segm.size() >= minFacets) { @@ -76,10 +80,15 @@ bool MeshDistancePlanarSegment::TestFacet (const MeshFacet& face) const return false; } - fitter->AddPoint(triangle.GetGravityPoint()); return true; } +void MeshDistancePlanarSegment::AddFacet(const MeshFacet& face) +{ + MeshGeomFacet triangle = kernel.GetFacet(face); + fitter->AddPoint(triangle.GetGravityPoint()); +} + // -------------------------------------------------------- bool MeshCurvaturePlanarSegment::TestFacet (const MeshFacet &rclFacet) const @@ -153,7 +162,7 @@ bool MeshCurvatureFreeformSegment::TestFacet (const MeshFacet &rclFacet) const // -------------------------------------------------------- -MeshSurfaceVisitor::MeshSurfaceVisitor (const MeshSurfaceSegment& segm, std::vector &indices) +MeshSurfaceVisitor::MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices) : indices(indices), segm(segm) { } @@ -172,6 +181,7 @@ bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &, unsigned long ulFInd, unsigned long) { indices.push_back(ulFInd); + segm.AddFacet(face); return true; } diff --git a/src/Mod/Mesh/App/Core/Segmentation.h b/src/Mod/Mesh/App/Core/Segmentation.h index 021961001..561385c1c 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.h +++ b/src/Mod/Mesh/App/Core/Segmentation.h @@ -42,6 +42,7 @@ public: virtual ~MeshSurfaceSegment() {} virtual bool TestFacet (const MeshFacet &rclFacet) const = 0; virtual void Initialize(unsigned long); + virtual void AddFacet(const MeshFacet& rclFacet); void AddSegment(const std::vector&); const std::vector& GetSegments() const { return segments; } @@ -68,8 +69,9 @@ class MeshExport MeshDistancePlanarSegment : public MeshDistanceSurfaceSegment public: MeshDistancePlanarSegment(const MeshKernel& mesh, unsigned long minFacets, float tol); virtual ~MeshDistancePlanarSegment(); - bool TestFacet (const MeshFacet &rclFacet) const; + bool TestFacet (const MeshFacet& rclFacet) const; void Initialize(unsigned long); + void AddFacet(const MeshFacet& rclFacet); protected: Base::Vector3f basepoint; @@ -134,7 +136,7 @@ private: class MeshExport MeshSurfaceVisitor : public MeshFacetVisitor { public: - MeshSurfaceVisitor (const MeshSurfaceSegment& segm, std::vector &indices); + MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices); virtual ~MeshSurfaceVisitor (); bool AllowVisit (const MeshFacet& face, const MeshFacet&, unsigned long, unsigned long, unsigned short neighbourIndex); @@ -143,7 +145,7 @@ public: protected: std::vector &indices; - const MeshSurfaceSegment& segm; + MeshSurfaceSegment& segm; }; class MeshExport MeshSegmentAlgorithm