Mesh segmentation
This commit is contained in:
parent
d6b6f6b379
commit
87f1e93fea
|
@ -41,6 +41,7 @@ public:
|
||||||
: minFacets(minFacets) {}
|
: minFacets(minFacets) {}
|
||||||
virtual ~MeshSurfaceSegment() {}
|
virtual ~MeshSurfaceSegment() {}
|
||||||
virtual bool TestFacet (const MeshFacet &rclFacet) const = 0;
|
virtual bool TestFacet (const MeshFacet &rclFacet) const = 0;
|
||||||
|
virtual const char* GetType() const = 0;
|
||||||
virtual void Initialize(unsigned long);
|
virtual void Initialize(unsigned long);
|
||||||
virtual void AddFacet(const MeshFacet& rclFacet);
|
virtual void AddFacet(const MeshFacet& rclFacet);
|
||||||
void AddSegment(const std::vector<unsigned long>&);
|
void AddSegment(const std::vector<unsigned long>&);
|
||||||
|
@ -70,6 +71,7 @@ public:
|
||||||
MeshDistancePlanarSegment(const MeshKernel& mesh, unsigned long minFacets, float tol);
|
MeshDistancePlanarSegment(const MeshKernel& mesh, unsigned long minFacets, float tol);
|
||||||
virtual ~MeshDistancePlanarSegment();
|
virtual ~MeshDistancePlanarSegment();
|
||||||
bool TestFacet (const MeshFacet& rclFacet) const;
|
bool TestFacet (const MeshFacet& rclFacet) const;
|
||||||
|
const char* GetType() const { return "Plane"; }
|
||||||
void Initialize(unsigned long);
|
void Initialize(unsigned long);
|
||||||
void AddFacet(const MeshFacet& rclFacet);
|
void AddFacet(const MeshFacet& rclFacet);
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ public:
|
||||||
MeshCurvaturePlanarSegment(const std::vector<CurvatureInfo>& ci, unsigned long minFacets, float tol)
|
MeshCurvaturePlanarSegment(const std::vector<CurvatureInfo>& ci, unsigned long minFacets, float tol)
|
||||||
: MeshCurvatureSurfaceSegment(ci, minFacets), tolerance(tol) {}
|
: MeshCurvatureSurfaceSegment(ci, minFacets), tolerance(tol) {}
|
||||||
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
||||||
|
virtual const char* GetType() const { return "Plane"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float tolerance;
|
float tolerance;
|
||||||
|
@ -109,6 +112,7 @@ public:
|
||||||
float tolMin, float tolMax, float radius)
|
float tolMin, float tolMax, float radius)
|
||||||
: MeshCurvatureSurfaceSegment(ci, minFacets), toleranceMin(tolMin), toleranceMax(tolMax) { curvature = 1/radius;}
|
: MeshCurvatureSurfaceSegment(ci, minFacets), toleranceMin(tolMin), toleranceMax(tolMax) { curvature = 1/radius;}
|
||||||
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
||||||
|
virtual const char* GetType() const { return "Cylinder"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float curvature;
|
float curvature;
|
||||||
|
@ -122,6 +126,7 @@ public:
|
||||||
MeshCurvatureSphericalSegment(const std::vector<CurvatureInfo>& ci, unsigned long minFacets, float tol, float radius)
|
MeshCurvatureSphericalSegment(const std::vector<CurvatureInfo>& ci, unsigned long minFacets, float tol, float radius)
|
||||||
: MeshCurvatureSurfaceSegment(ci, minFacets), tolerance(tol) { curvature = 1/radius;}
|
: MeshCurvatureSurfaceSegment(ci, minFacets), tolerance(tol) { curvature = 1/radius;}
|
||||||
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
||||||
|
virtual const char* GetType() const { return "Sphere"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float curvature;
|
float curvature;
|
||||||
|
@ -136,6 +141,7 @@ public:
|
||||||
: MeshCurvatureSurfaceSegment(ci, minFacets), c1(c1), c2(c2),
|
: MeshCurvatureSurfaceSegment(ci, minFacets), c1(c1), c2(c2),
|
||||||
toleranceMin(tolMin), toleranceMax(tolMax) {}
|
toleranceMin(tolMin), toleranceMax(tolMax) {}
|
||||||
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
virtual bool TestFacet (const MeshFacet &rclFacet) const;
|
||||||
|
virtual const char* GetType() const { return "Freeform"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float c1, c2;
|
float c1, c2;
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
|
# include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Segmentation.h"
|
#include "Segmentation.h"
|
||||||
#include "ui_Segmentation.h"
|
#include "ui_Segmentation.h"
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
|
#include <App/DocumentObjectGroup.h>
|
||||||
|
|
||||||
#include <Mod/Mesh/App/Core/Segmentation.h>
|
#include <Mod/Mesh/App/Core/Segmentation.h>
|
||||||
#include <Mod/Mesh/App/Core/Curvature.h>
|
#include <Mod/Mesh/App/Core/Curvature.h>
|
||||||
|
@ -89,18 +91,32 @@ void Segmentation::accept()
|
||||||
finder.FindSegments(segm);
|
finder.FindSegments(segm);
|
||||||
|
|
||||||
App::Document* document = App::GetApplication().getActiveDocument();
|
App::Document* document = App::GetApplication().getActiveDocument();
|
||||||
|
document->openTransaction("Segmentation");
|
||||||
|
|
||||||
|
std::string internalname = "Segments_";
|
||||||
|
internalname += myMesh->getNameInDocument();
|
||||||
|
App::DocumentObjectGroup* group = static_cast<App::DocumentObjectGroup*>(document->addObject
|
||||||
|
("App::DocumentObjectGroup", internalname.c_str()));
|
||||||
|
std::string labelname = "Segments ";
|
||||||
|
labelname += myMesh->Label.getValue();
|
||||||
|
group->Label.setValue(labelname);
|
||||||
for (std::vector<MeshCore::MeshSurfaceSegment*>::iterator it = segm.begin(); it != segm.end(); ++it) {
|
for (std::vector<MeshCore::MeshSurfaceSegment*>::iterator it = segm.begin(); it != segm.end(); ++it) {
|
||||||
const std::vector<MeshCore::MeshSegment>& data = (*it)->GetSegments();
|
const std::vector<MeshCore::MeshSegment>& data = (*it)->GetSegments();
|
||||||
for (std::vector<MeshCore::MeshSegment>::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
|
for (std::vector<MeshCore::MeshSegment>::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
|
||||||
Mesh::MeshObject* segment = mesh->meshFromSegment(*jt);
|
Mesh::MeshObject* segment = mesh->meshFromSegment(*jt);
|
||||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(document->addObject("Mesh::Feature", "Segment"));
|
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||||
feaMesh->swap(*segment);
|
feaMesh->swap(*segment);
|
||||||
feaSegm->Mesh.finishEditing();
|
feaSegm->Mesh.finishEditing();
|
||||||
delete segment;
|
delete segment;
|
||||||
|
|
||||||
|
std::stringstream label;
|
||||||
|
label << feaSegm->Label.getValue() << " (" << (*it)->GetType() << ")";
|
||||||
|
feaSegm->Label.setValue(label.str());
|
||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
document->commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segmentation::changeEvent(QEvent *e)
|
void Segmentation::changeEvent(QEvent *e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user