RE: apply clang format
This commit is contained in:
@@ -42,13 +42,15 @@ void loadReverseEngineeringResource()
|
||||
Gui::Translator::instance()->refresh();
|
||||
}
|
||||
|
||||
namespace ReverseEngineeringGui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
namespace ReverseEngineeringGui
|
||||
{
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("ReverseEngineeringGui")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("ReverseEngineeringGui")
|
||||
{
|
||||
initialize("This module is the ReverseEngineeringGui module."); // register with Python
|
||||
initialize("This module is the ReverseEngineeringGui module.");// register with Python
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -59,7 +61,7 @@ PyObject* initModule()
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace ReverseEngineeringGui
|
||||
}// namespace ReverseEngineeringGui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
@@ -74,7 +76,7 @@ PyMOD_INIT_FUNC(ReverseEngineeringGui)
|
||||
try {
|
||||
Base::Interpreter().loadModule("MeshGui");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
PyMOD_Return(nullptr);
|
||||
}
|
||||
@@ -86,7 +88,7 @@ PyMOD_INIT_FUNC(ReverseEngineeringGui)
|
||||
CreateReverseEngineeringCommands();
|
||||
ReverseEngineeringGui::Workbench::init();
|
||||
|
||||
// add resources and reloads the translators
|
||||
// add resources and reloads the translators
|
||||
loadReverseEngineeringResource();
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QApplication>
|
||||
# include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <sstream>
|
||||
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -41,15 +41,15 @@
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
#include <Mod/Part/App/FaceMakerCheese.h>
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/Tools.h>
|
||||
#include <Mod/Points/App/Structured.h>
|
||||
#include <Mod/ReverseEngineering/App/ApproxSurface.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
|
||||
#include "FitBSplineSurface.h"
|
||||
#include "Poisson.h"
|
||||
@@ -62,27 +62,29 @@ using namespace std;
|
||||
DEF_STD_CMD_A(CmdApproxSurface)
|
||||
|
||||
CmdApproxSurface::CmdApproxSurface()
|
||||
: Command("Reen_ApproxSurface")
|
||||
: Command("Reen_ApproxSurface")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Approximate B-spline surface...");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a B-spline surface");
|
||||
sWhatsThis = "Reen_ApproxSurface";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/FitSurface";
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Approximate B-spline surface...");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a B-spline surface");
|
||||
sWhatsThis = "Reen_ApproxSurface";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/FitSurface";
|
||||
}
|
||||
|
||||
void CmdApproxSurface::activated(int)
|
||||
{
|
||||
App::DocumentObjectT objT;
|
||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(App::GeoFeature::getClassTypeId());
|
||||
if (obj.size() != 1 || !(obj.at(0)->isDerivedFrom(Points::Feature::getClassTypeId()) ||
|
||||
obj.at(0)->isDerivedFrom(Mesh::Feature::getClassTypeId()))) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
std::vector<App::DocumentObject*> obj =
|
||||
Gui::Selection().getObjectsOfType(App::GeoFeature::getClassTypeId());
|
||||
if (obj.size() != 1
|
||||
|| !(obj.at(0)->isDerivedFrom(Points::Feature::getClassTypeId())
|
||||
|| obj.at(0)->isDerivedFrom(Mesh::Feature::getClassTypeId()))) {
|
||||
QMessageBox::warning(
|
||||
Gui::getMainWindow(),
|
||||
qApp->translate("Reen_ApproxSurface", "Wrong selection"),
|
||||
qApp->translate("Reen_ApproxSurface", "Please select a point cloud or mesh.")
|
||||
);
|
||||
qApp->translate("Reen_ApproxSurface", "Please select a point cloud or mesh."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,14 +100,14 @@ bool CmdApproxSurface::isActive()
|
||||
DEF_STD_CMD_A(CmdApproxPlane)
|
||||
|
||||
CmdApproxPlane::CmdApproxPlane()
|
||||
: Command("Reen_ApproxPlane")
|
||||
: Command("Reen_ApproxPlane")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Plane...");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a plane");
|
||||
sWhatsThis = "Reen_ApproxPlane";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Plane...");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a plane");
|
||||
sWhatsThis = "Reen_ApproxPlane";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdApproxPlane::activated(int)
|
||||
@@ -119,26 +121,29 @@ void CmdApproxPlane::activated(int)
|
||||
it->getPropertyList(List);
|
||||
for (const auto& jt : List) {
|
||||
if (jt->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
|
||||
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(jt)->getComplexData();
|
||||
const Data::ComplexGeoData* data =
|
||||
static_cast<App::PropertyComplexGeoData*>(jt)->getComplexData();
|
||||
if (data) {
|
||||
data->getPoints(aPoints, aNormals, 0.01f);
|
||||
if (!aPoints.empty())
|
||||
if (!aPoints.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aPoints.empty()) {
|
||||
// get a reference normal for the plane fit
|
||||
Base::Vector3f refNormal(0,0,0);
|
||||
Base::Vector3f refNormal(0, 0, 0);
|
||||
if (!aNormals.empty()) {
|
||||
refNormal = Base::convertTo<Base::Vector3f>(aNormals.front());
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3f> aData;
|
||||
aData.reserve(aPoints.size());
|
||||
for (const auto& jt : aPoints)
|
||||
for (const auto& jt : aPoints) {
|
||||
aData.push_back(Base::toVector<float>(jt));
|
||||
}
|
||||
MeshCore::PlaneFit fit;
|
||||
fit.AddPoints(aData);
|
||||
float sigma = fit.Fit();
|
||||
@@ -168,7 +173,9 @@ void CmdApproxPlane::activated(int)
|
||||
double q0, q1, q2, q3;
|
||||
pm.getRotation().getValue(q0, q1, q2, q3);
|
||||
|
||||
Base::Console().Log("RMS value for plane fit with %lu points: %.4f\n", aData.size(), sigma);
|
||||
Base::Console().Log("RMS value for plane fit with %lu points: %.4f\n",
|
||||
aData.size(),
|
||||
sigma);
|
||||
Base::Console().Log(" Plane base(%.4f, %.4f, %.4f)\n", base.x, base.y, base.z);
|
||||
Base::Console().Log(" Plane normal(%.4f, %.4f, %.4f)\n", norm.x, norm.y, norm.z);
|
||||
|
||||
@@ -179,7 +186,8 @@ void CmdApproxPlane::activated(int)
|
||||
str << "App.ActiveDocument.ActiveObject.Width = " << width << std::endl;
|
||||
str << "App.ActiveDocument.ActiveObject.Placement = Base.Placement("
|
||||
<< "Base.Vector(" << base.x << "," << base.y << "," << base.z << "),"
|
||||
<< "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))" << std::endl;
|
||||
<< "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))"
|
||||
<< std::endl;
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Fit plane"));
|
||||
runCommand(Gui::Command::Doc, str.str().c_str());
|
||||
@@ -191,22 +199,23 @@ void CmdApproxPlane::activated(int)
|
||||
|
||||
bool CmdApproxPlane::isActive()
|
||||
{
|
||||
if (getSelection().countObjectsOfType(App::GeoFeature::getClassTypeId()) == 1)
|
||||
if (getSelection().countObjectsOfType(App::GeoFeature::getClassTypeId()) == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdApproxCylinder)
|
||||
|
||||
CmdApproxCylinder::CmdApproxCylinder()
|
||||
: Command("Reen_ApproxCylinder")
|
||||
: Command("Reen_ApproxCylinder")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Cylinder");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a cylinder");
|
||||
sWhatsThis = "Reen_ApproxCylinder";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Cylinder");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a cylinder");
|
||||
sWhatsThis = "Reen_ApproxCylinder";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdApproxCylinder::activated(int)
|
||||
@@ -235,7 +244,7 @@ void CmdApproxCylinder::activated(int)
|
||||
float height = Base::Distance(base, top);
|
||||
|
||||
Base::Rotation rot;
|
||||
rot.setValue(Base::Vector3d(0,0,1), Base::convertTo<Base::Vector3d>(fit.GetAxis()));
|
||||
rot.setValue(Base::Vector3d(0, 0, 1), Base::convertTo<Base::Vector3d>(fit.GetAxis()));
|
||||
double q0, q1, q2, q3;
|
||||
rot.getValue(q0, q1, q2, q3);
|
||||
|
||||
@@ -246,7 +255,8 @@ void CmdApproxCylinder::activated(int)
|
||||
str << "App.ActiveDocument.ActiveObject.Height = " << height << std::endl;
|
||||
str << "App.ActiveDocument.ActiveObject.Placement = Base.Placement("
|
||||
<< "Base.Vector(" << base.x << "," << base.y << "," << base.z << "),"
|
||||
<< "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))" << std::endl;
|
||||
<< "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))"
|
||||
<< std::endl;
|
||||
|
||||
runCommand(Gui::Command::Doc, str.str().c_str());
|
||||
}
|
||||
@@ -257,22 +267,23 @@ void CmdApproxCylinder::activated(int)
|
||||
|
||||
bool CmdApproxCylinder::isActive()
|
||||
{
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdApproxSphere)
|
||||
|
||||
CmdApproxSphere::CmdApproxSphere()
|
||||
: Command("Reen_ApproxSphere")
|
||||
: Command("Reen_ApproxSphere")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Sphere");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a sphere");
|
||||
sWhatsThis = "Reen_ApproxSphere";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Sphere");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a sphere");
|
||||
sWhatsThis = "Reen_ApproxSphere";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdApproxSphere::activated(int)
|
||||
@@ -304,22 +315,23 @@ void CmdApproxSphere::activated(int)
|
||||
|
||||
bool CmdApproxSphere::isActive()
|
||||
{
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdApproxPolynomial)
|
||||
|
||||
CmdApproxPolynomial::CmdApproxPolynomial()
|
||||
: Command("Reen_ApproxPolynomial")
|
||||
: Command("Reen_ApproxPolynomial")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Polynomial surface");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a polynomial surface");
|
||||
sWhatsThis = "Reen_ApproxPolynomial";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Polynomial surface");
|
||||
sToolTipText = QT_TR_NOOP("Approximate a polynomial surface");
|
||||
sWhatsThis = "Reen_ApproxPolynomial";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdApproxPolynomial::activated(int)
|
||||
@@ -334,7 +346,8 @@ void CmdApproxPolynomial::activated(int)
|
||||
fit.AddPoints(kernel.GetPoints());
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
Base::BoundBox3f bbox = fit.GetBoundings();
|
||||
std::vector<Base::Vector3d> poles = fit.toBezier(bbox.MinX, bbox.MaxX, bbox.MinY, bbox.MaxY);
|
||||
std::vector<Base::Vector3d> poles =
|
||||
fit.toBezier(bbox.MinX, bbox.MaxX, bbox.MinY, bbox.MaxY);
|
||||
fit.Transform(poles);
|
||||
|
||||
TColgp_Array2OfPnt grid(1, 3, 1, 3);
|
||||
@@ -349,7 +362,8 @@ void CmdApproxPolynomial::activated(int)
|
||||
grid.SetValue(3, 3, Base::convertTo<gp_Pnt>(poles.at(8)));
|
||||
|
||||
Handle(Geom_BezierSurface) bezier(new Geom_BezierSurface(grid));
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Spline", "Bezier"));
|
||||
Part::Feature* part =
|
||||
static_cast<Part::Feature*>(doc->addObject("Part::Spline", "Bezier"));
|
||||
part->Shape.setValue(Part::GeomBezierSurface(bezier).toShape());
|
||||
}
|
||||
}
|
||||
@@ -359,22 +373,23 @@ void CmdApproxPolynomial::activated(int)
|
||||
|
||||
bool CmdApproxPolynomial::isActive()
|
||||
{
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSegmentation)
|
||||
|
||||
CmdSegmentation::CmdSegmentation()
|
||||
: Command("Reen_Segmentation")
|
||||
: Command("Reen_Segmentation")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Mesh segmentation...");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments");
|
||||
sWhatsThis = "Reen_Segmentation";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Mesh segmentation...");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments");
|
||||
sWhatsThis = "Reen_Segmentation";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdSegmentation::activated(int)
|
||||
@@ -390,23 +405,23 @@ void CmdSegmentation::activated(int)
|
||||
|
||||
bool CmdSegmentation::isActive()
|
||||
{
|
||||
if (Gui::Control().activeDialog())
|
||||
if (Gui::Control().activeDialog()) {
|
||||
return false;
|
||||
return Gui::Selection().countObjectsOfType
|
||||
(Mesh::Feature::getClassTypeId()) == 1;
|
||||
}
|
||||
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSegmentationManual)
|
||||
|
||||
CmdSegmentationManual::CmdSegmentationManual()
|
||||
: Command("Reen_SegmentationManual")
|
||||
: Command("Reen_SegmentationManual")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Manual segmentation...");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments manually");
|
||||
sWhatsThis = "Reen_SegmentationManual";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Manual segmentation...");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments manually");
|
||||
sWhatsThis = "Reen_SegmentationManual";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdSegmentationManual::activated(int)
|
||||
@@ -420,22 +435,23 @@ void CmdSegmentationManual::activated(int)
|
||||
|
||||
bool CmdSegmentationManual::isActive()
|
||||
{
|
||||
if (Gui::Control().activeDialog())
|
||||
if (Gui::Control().activeDialog()) {
|
||||
return false;
|
||||
}
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSegmentationFromComponents)
|
||||
|
||||
CmdSegmentationFromComponents::CmdSegmentationFromComponents()
|
||||
: Command("Reen_SegmentationFromComponents")
|
||||
: Command("Reen_SegmentationFromComponents")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("From components");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments from components");
|
||||
sWhatsThis = "Reen_SegmentationFromComponents";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("From components");
|
||||
sToolTipText = QT_TR_NOOP("Create mesh segments from components");
|
||||
sWhatsThis = "Reen_SegmentationFromComponents";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdSegmentationFromComponents::activated(int)
|
||||
@@ -447,17 +463,18 @@ void CmdSegmentationFromComponents::activated(int)
|
||||
for (auto it : sel) {
|
||||
std::string internalname = "Segments_";
|
||||
internalname += it->getNameInDocument();
|
||||
App::DocumentObjectGroup* group = static_cast<App::DocumentObjectGroup*>(doc->addObject
|
||||
("App::DocumentObjectGroup", internalname.c_str()));
|
||||
App::DocumentObjectGroup* group = static_cast<App::DocumentObjectGroup*>(
|
||||
doc->addObject("App::DocumentObjectGroup", internalname.c_str()));
|
||||
std::string labelname = "Segments ";
|
||||
labelname += it->Label.getValue();
|
||||
group->Label.setValue(labelname);
|
||||
|
||||
const Mesh::MeshObject& mesh = it->Mesh.getValue();
|
||||
std::vector<std::vector<MeshCore::FacetIndex> > comps = mesh.getComponents();
|
||||
std::vector<std::vector<MeshCore::FacetIndex>> comps = mesh.getComponents();
|
||||
for (const auto& jt : comps) {
|
||||
std::unique_ptr<Mesh::MeshObject> segment(mesh.meshFromSegment(jt));
|
||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::Feature* feaSegm =
|
||||
static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||
feaMesh->swap(*segment);
|
||||
feaSegm->Mesh.finishEditing();
|
||||
@@ -470,22 +487,23 @@ void CmdSegmentationFromComponents::activated(int)
|
||||
|
||||
bool CmdSegmentationFromComponents::isActive()
|
||||
{
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshBoundary)
|
||||
|
||||
CmdMeshBoundary::CmdMeshBoundary()
|
||||
: Command("Reen_MeshBoundary")
|
||||
: Command("Reen_MeshBoundary")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Wire from mesh boundary...");
|
||||
sToolTipText = QT_TR_NOOP("Create wire from mesh boundaries");
|
||||
sWhatsThis = "Reen_Segmentation";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Wire from mesh boundary...");
|
||||
sToolTipText = QT_TR_NOOP("Create wire from mesh boundaries");
|
||||
sWhatsThis = "Reen_Segmentation";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdMeshBoundary::activated(int)
|
||||
@@ -495,7 +513,7 @@ void CmdMeshBoundary::activated(int)
|
||||
document->openTransaction("Wire from mesh");
|
||||
for (auto it : objs) {
|
||||
const Mesh::MeshObject& mesh = it->Mesh.getValue();
|
||||
std::list<std::vector<Base::Vector3f> > bounds;
|
||||
std::list<std::vector<Base::Vector3f>> bounds;
|
||||
MeshCore::MeshAlgorithm algo(mesh.getKernel());
|
||||
algo.GetMeshBorders(bounds);
|
||||
|
||||
@@ -509,7 +527,7 @@ void CmdMeshBoundary::activated(int)
|
||||
for (const auto& bt : bounds) {
|
||||
BRepBuilderAPI_MakePolygon mkPoly;
|
||||
for (auto it = bt.rbegin(); it != bt.rend(); ++it) {
|
||||
mkPoly.Add(gp_Pnt(it->x,it->y,it->z));
|
||||
mkPoly.Add(gp_Pnt(it->x, it->y, it->z));
|
||||
}
|
||||
if (mkPoly.IsDone()) {
|
||||
builder.Add(compound, mkPoly.Wire());
|
||||
@@ -524,11 +542,13 @@ void CmdMeshBoundary::activated(int)
|
||||
}
|
||||
|
||||
if (!shape.IsNull()) {
|
||||
Part::Feature* shapeFea = static_cast<Part::Feature*>(document->addObject("Part::Feature", "Face from mesh"));
|
||||
Part::Feature* shapeFea =
|
||||
static_cast<Part::Feature*>(document->addObject("Part::Feature", "Face from mesh"));
|
||||
shapeFea->Shape.setValue(shape);
|
||||
}
|
||||
else {
|
||||
Part::Feature* shapeFea = static_cast<Part::Feature*>(document->addObject("Part::Feature", "Wire from mesh"));
|
||||
Part::Feature* shapeFea =
|
||||
static_cast<Part::Feature*>(document->addObject("Part::Feature", "Wire from mesh"));
|
||||
shapeFea->Shape.setValue(compound);
|
||||
}
|
||||
}
|
||||
@@ -537,32 +557,32 @@ void CmdMeshBoundary::activated(int)
|
||||
|
||||
bool CmdMeshBoundary::isActive()
|
||||
{
|
||||
return Gui::Selection().countObjectsOfType
|
||||
(Mesh::Feature::getClassTypeId()) > 0;
|
||||
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdPoissonReconstruction)
|
||||
|
||||
CmdPoissonReconstruction::CmdPoissonReconstruction()
|
||||
: Command("Reen_PoissonReconstruction")
|
||||
: Command("Reen_PoissonReconstruction")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Poisson...");
|
||||
sToolTipText = QT_TR_NOOP("Poisson surface reconstruction");
|
||||
sWhatsThis = "Reen_PoissonReconstruction";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Poisson...");
|
||||
sToolTipText = QT_TR_NOOP("Poisson surface reconstruction");
|
||||
sWhatsThis = "Reen_PoissonReconstruction";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdPoissonReconstruction::activated(int)
|
||||
{
|
||||
App::DocumentObjectT objT;
|
||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> obj =
|
||||
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
if (obj.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QMessageBox::warning(
|
||||
Gui::getMainWindow(),
|
||||
qApp->translate("Reen_ApproxSurface", "Wrong selection"),
|
||||
qApp->translate("Reen_ApproxSurface", "Please select a single point cloud.")
|
||||
);
|
||||
qApp->translate("Reen_ApproxSurface", "Please select a single point cloud."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -578,33 +598,34 @@ bool CmdPoissonReconstruction::isActive()
|
||||
DEF_STD_CMD_A(CmdViewTriangulation)
|
||||
|
||||
CmdViewTriangulation::CmdViewTriangulation()
|
||||
: Command("Reen_ViewTriangulation")
|
||||
: Command("Reen_ViewTriangulation")
|
||||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Structured point clouds");
|
||||
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sStatusTip = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sWhatsThis = "Reen_ViewTriangulation";
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("Structured point clouds");
|
||||
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sStatusTip = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sWhatsThis = "Reen_ViewTriangulation";
|
||||
}
|
||||
|
||||
void CmdViewTriangulation::activated(int)
|
||||
{
|
||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Points::Structured::getClassTypeId());
|
||||
addModule(App,"ReverseEngineering");
|
||||
std::vector<App::DocumentObject*> obj =
|
||||
Gui::Selection().getObjectsOfType(Points::Structured::getClassTypeId());
|
||||
addModule(App, "ReverseEngineering");
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "View triangulation"));
|
||||
try {
|
||||
for (const auto & it : obj) {
|
||||
for (const auto& it : obj) {
|
||||
App::DocumentObjectT objT(it);
|
||||
QString document = QString::fromStdString(objT.getDocumentPython());
|
||||
QString object = QString::fromStdString(objT.getObjectPython());
|
||||
|
||||
QString command = QString::fromLatin1("%1.addObject('Mesh::Feature', 'View mesh').Mesh = ReverseEngineering.viewTriangulation("
|
||||
"Points=%2.Points,"
|
||||
"Width=%2.Width,"
|
||||
"Height=%2.Height)"
|
||||
)
|
||||
.arg(document, object);
|
||||
QString command = QString::fromLatin1("%1.addObject('Mesh::Feature', 'View mesh').Mesh "
|
||||
"= ReverseEngineering.viewTriangulation("
|
||||
"Points=%2.Points,"
|
||||
"Width=%2.Width,"
|
||||
"Height=%2.Height)")
|
||||
.arg(document, object);
|
||||
runCommand(Doc, command.toLatin1());
|
||||
}
|
||||
|
||||
@@ -614,20 +635,19 @@ void CmdViewTriangulation::activated(int)
|
||||
catch (const Base::Exception& e) {
|
||||
abortCommand();
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Reen_ViewTriangulation", "View triangulation failed"),
|
||||
QString::fromLatin1(e.what())
|
||||
);
|
||||
qApp->translate("Reen_ViewTriangulation", "View triangulation failed"),
|
||||
QString::fromLatin1(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdViewTriangulation::isActive()
|
||||
{
|
||||
return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0);
|
||||
return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0);
|
||||
}
|
||||
|
||||
void CreateReverseEngineeringCommands()
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
rcCmdMgr.addCommand(new CmdApproxSurface());
|
||||
rcCmdMgr.addCommand(new CmdApproxPlane());
|
||||
rcCmdMgr.addCommand(new CmdApproxCylinder());
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <QMessageBox>
|
||||
#include <QMessageBox>
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
#include <App/ComplexGeoData.h>
|
||||
@@ -37,8 +37,8 @@
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
|
||||
#include "ui_FitBSplineSurface.h"
|
||||
#include "FitBSplineSurface.h"
|
||||
#include "ui_FitBSplineSurface.h"
|
||||
|
||||
|
||||
using namespace ReenGui;
|
||||
@@ -55,12 +55,14 @@ public:
|
||||
/* TRANSLATOR ReenGui::FitBSplineSurfaceWidget */
|
||||
|
||||
FitBSplineSurfaceWidget::FitBSplineSurfaceWidget(const App::DocumentObjectT& obj, QWidget* parent)
|
||||
: d(new Private())
|
||||
: d(new Private())
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
d->ui.setupUi(this);
|
||||
connect(d->ui.makePlacement, &QPushButton::clicked,
|
||||
this, &FitBSplineSurfaceWidget::onMakePlacementClicked);
|
||||
connect(d->ui.makePlacement,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&FitBSplineSurfaceWidget::onMakePlacementClicked);
|
||||
d->obj = obj;
|
||||
restoreSettings();
|
||||
}
|
||||
@@ -112,9 +114,12 @@ void FitBSplineSurfaceWidget::onMakePlacementClicked()
|
||||
geom->getComplexData()->getPoints(points, normals, 0.001);
|
||||
|
||||
std::vector<Base::Vector3f> data;
|
||||
std::transform(points.begin(), points.end(), std::back_inserter(data), [](const Base::Vector3d& v) {
|
||||
return Base::convertTo<Base::Vector3f>(v);
|
||||
});
|
||||
std::transform(points.begin(),
|
||||
points.end(),
|
||||
std::back_inserter(data),
|
||||
[](const Base::Vector3d& v) {
|
||||
return Base::convertTo<Base::Vector3f>(v);
|
||||
});
|
||||
MeshCore::PlaneFit fit;
|
||||
fit.AddPoints(data);
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
@@ -130,20 +135,21 @@ void FitBSplineSurfaceWidget::onMakePlacementClicked()
|
||||
double q0, q1, q2, q3;
|
||||
pm.getRotation().getValue(q0, q1, q2, q3);
|
||||
|
||||
QString argument = QString::fromLatin1("Base.Placement(Base.Vector(%1, %2, %3), Base.Rotation(%4, %5, %6, %7))")
|
||||
.arg(base.x)
|
||||
.arg(base.y)
|
||||
.arg(base.z)
|
||||
.arg(q0)
|
||||
.arg(q1)
|
||||
.arg(q2)
|
||||
.arg(q3);
|
||||
QString argument = QString::fromLatin1("Base.Placement(Base.Vector(%1, %2, "
|
||||
"%3), Base.Rotation(%4, %5, %6, %7))")
|
||||
.arg(base.x)
|
||||
.arg(base.y)
|
||||
.arg(base.z)
|
||||
.arg(q0)
|
||||
.arg(q1)
|
||||
.arg(q2)
|
||||
.arg(q3);
|
||||
|
||||
QString document = QString::fromStdString(d->obj.getDocumentPython());
|
||||
QString command =
|
||||
QString::fromLatin1(
|
||||
R"(%1.addObject("App::Placement", "Placement").Placement = %2)"
|
||||
).arg(document, argument);
|
||||
R"(%1.addObject("App::Placement", "Placement").Placement = %2)")
|
||||
.arg(document, argument);
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Placement"));
|
||||
Gui::Command::runCommand(Gui::Command::Doc, "from FreeCAD import Base");
|
||||
@@ -166,54 +172,59 @@ bool FitBSplineSurfaceWidget::accept()
|
||||
QString document = QString::fromStdString(d->obj.getDocumentPython());
|
||||
QString object = QString::fromStdString(d->obj.getObjectPython());
|
||||
|
||||
QString argument = QString::fromLatin1(
|
||||
"Points=getattr(%1, %1.getPropertyNameOfGeometry()), "
|
||||
"UDegree=%2, VDegree=%3, "
|
||||
"NbUPoles=%4, NbVPoles=%5, "
|
||||
"Smooth=%6, "
|
||||
"Weight=%7, "
|
||||
"Grad=%8, "
|
||||
"Bend=%9, "
|
||||
"Curv=%10, "
|
||||
"Iterations=%11, "
|
||||
"PatchFactor=%12, "
|
||||
"Correction=True"
|
||||
)
|
||||
.arg(object)
|
||||
.arg(d->ui.degreeU->value())
|
||||
.arg(d->ui.degreeV->value())
|
||||
.arg(d->ui.polesU->value())
|
||||
.arg(d->ui.polesV->value())
|
||||
.arg(d->ui.groupBoxSmooth->isChecked() ? QLatin1String("True") : QLatin1String("False"))
|
||||
.arg(d->ui.totalWeight->value())
|
||||
.arg(d->ui.gradient->value())
|
||||
.arg(d->ui.bending->value())
|
||||
.arg(d->ui.curvature->value())
|
||||
.arg(d->ui.iterations->value())
|
||||
.arg(d->ui.sizeFactor->value())
|
||||
;
|
||||
QString argument =
|
||||
QString::fromLatin1("Points=getattr(%1, %1.getPropertyNameOfGeometry()), "
|
||||
"UDegree=%2, VDegree=%3, "
|
||||
"NbUPoles=%4, NbVPoles=%5, "
|
||||
"Smooth=%6, "
|
||||
"Weight=%7, "
|
||||
"Grad=%8, "
|
||||
"Bend=%9, "
|
||||
"Curv=%10, "
|
||||
"Iterations=%11, "
|
||||
"PatchFactor=%12, "
|
||||
"Correction=True")
|
||||
.arg(object)
|
||||
.arg(d->ui.degreeU->value())
|
||||
.arg(d->ui.degreeV->value())
|
||||
.arg(d->ui.polesU->value())
|
||||
.arg(d->ui.polesV->value())
|
||||
.arg(d->ui.groupBoxSmooth->isChecked() ? QLatin1String("True")
|
||||
: QLatin1String("False"))
|
||||
.arg(d->ui.totalWeight->value())
|
||||
.arg(d->ui.gradient->value())
|
||||
.arg(d->ui.bending->value())
|
||||
.arg(d->ui.curvature->value())
|
||||
.arg(d->ui.iterations->value())
|
||||
.arg(d->ui.sizeFactor->value());
|
||||
if (d->ui.uvdir->isChecked()) {
|
||||
std::vector<App::Placement*> selection = Gui::Selection().getObjectsOfType<App::Placement>();
|
||||
std::vector<App::Placement*> selection =
|
||||
Gui::Selection().getObjectsOfType<App::Placement>();
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(this,
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Wrong selection"),
|
||||
tr("Please select a single placement object to get local orientation.")
|
||||
);
|
||||
tr("Please select a single placement object to get local orientation."));
|
||||
return false;
|
||||
}
|
||||
|
||||
Base::Rotation rot = selection.front()->GeoFeature::Placement.getValue().getRotation();
|
||||
Base::Vector3d u(1,0,0);
|
||||
Base::Vector3d v(0,1,0);
|
||||
Base::Vector3d u(1, 0, 0);
|
||||
Base::Vector3d v(0, 1, 0);
|
||||
rot.multVec(u, u);
|
||||
rot.multVec(v, v);
|
||||
argument += QString::fromLatin1(", UVDirs=(FreeCAD.Vector(%1,%2,%3), FreeCAD.Vector(%4,%5,%6))")
|
||||
.arg(u.x).arg(u.y).arg(u.z).arg(v.x).arg(v.y).arg(v.z);
|
||||
argument +=
|
||||
QString::fromLatin1(", UVDirs=(FreeCAD.Vector(%1,%2,%3), FreeCAD.Vector(%4,%5,%6))")
|
||||
.arg(u.x)
|
||||
.arg(u.y)
|
||||
.arg(u.z)
|
||||
.arg(v.x)
|
||||
.arg(v.y)
|
||||
.arg(v.z);
|
||||
}
|
||||
QString command = QString::fromLatin1("%1.addObject(\"Part::Spline\", \"Spline\").Shape = "
|
||||
"ReverseEngineering.approxSurface(%2).toShape()")
|
||||
.arg(document, argument)
|
||||
;
|
||||
"ReverseEngineering.approxSurface(%2).toShape()")
|
||||
.arg(document, argument);
|
||||
|
||||
Gui::WaitCursor wc;
|
||||
Gui::Command::addModule(Gui::Command::App, "ReverseEngineering");
|
||||
@@ -231,7 +242,7 @@ bool FitBSplineSurfaceWidget::accept()
|
||||
return true;
|
||||
}
|
||||
|
||||
void FitBSplineSurfaceWidget::changeEvent(QEvent *e)
|
||||
void FitBSplineSurfaceWidget::changeEvent(QEvent* e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
@@ -245,16 +256,16 @@ void FitBSplineSurfaceWidget::changeEvent(QEvent *e)
|
||||
TaskFitBSplineSurface::TaskFitBSplineSurface(const App::DocumentObjectT& obj)
|
||||
{
|
||||
widget = new FitBSplineSurfaceWidget(obj);
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
Gui::BitmapFactory().pixmap("actions/FitSurface"),
|
||||
widget->windowTitle(), true, nullptr);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/FitSurface"),
|
||||
widget->windowTitle(),
|
||||
true,
|
||||
nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
void TaskFitBSplineSurface::open()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool TaskFitBSplineSurface::accept()
|
||||
{
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
|
||||
|
||||
namespace ReenGui {
|
||||
namespace ReenGui
|
||||
{
|
||||
|
||||
class FitBSplineSurfaceWidget : public QWidget
|
||||
class FitBSplineSurfaceWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
private:
|
||||
void restoreSettings();
|
||||
void saveSettings();
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void onMakePlacementClicked();
|
||||
@@ -52,7 +53,7 @@ private:
|
||||
Private* d;
|
||||
};
|
||||
|
||||
class TaskFitBSplineSurface : public Gui::TaskView::TaskDialog
|
||||
class TaskFitBSplineSurface: public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -64,13 +65,15 @@ public:
|
||||
bool accept() override;
|
||||
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const override
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
{
|
||||
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
|
||||
}
|
||||
|
||||
private:
|
||||
FitBSplineSurfaceWidget* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace ReenGui
|
||||
}// namespace ReenGui
|
||||
|
||||
#endif // REENGUI_FITBSPLINESURFACE_H
|
||||
#endif// REENGUI_FITBSPLINESURFACE_H
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -30,8 +30,8 @@
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include "ui_Poisson.h"
|
||||
#include "Poisson.h"
|
||||
#include "ui_Poisson.h"
|
||||
|
||||
|
||||
using namespace ReenGui;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
/* TRANSLATOR ReenGui::PoissonWidget */
|
||||
|
||||
PoissonWidget::PoissonWidget(const App::DocumentObjectT& obj, QWidget* parent)
|
||||
: d(new Private())
|
||||
: d(new Private())
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
d->ui.setupUi(this);
|
||||
@@ -66,21 +66,17 @@ bool PoissonWidget::accept()
|
||||
QString document = QString::fromStdString(d->obj.getDocumentPython());
|
||||
QString object = QString::fromStdString(d->obj.getObjectPython());
|
||||
|
||||
QString argument = QString::fromLatin1(
|
||||
"Points=%1.Points, "
|
||||
"OctreeDepth=%2, "
|
||||
"SolverDivide=%3, "
|
||||
"SamplesPerNode=%4"
|
||||
)
|
||||
.arg(object)
|
||||
.arg(d->ui.octreeDepth->value())
|
||||
.arg(d->ui.solverDivide->value())
|
||||
.arg(d->ui.samplesPerNode->value())
|
||||
;
|
||||
QString argument = QString::fromLatin1("Points=%1.Points, "
|
||||
"OctreeDepth=%2, "
|
||||
"SolverDivide=%3, "
|
||||
"SamplesPerNode=%4")
|
||||
.arg(object)
|
||||
.arg(d->ui.octreeDepth->value())
|
||||
.arg(d->ui.solverDivide->value())
|
||||
.arg(d->ui.samplesPerNode->value());
|
||||
QString command = QString::fromLatin1("%1.addObject(\"Mesh::Feature\", \"Poisson\").Mesh = "
|
||||
"ReverseEngineering.poissonReconstruction(%2)")
|
||||
.arg(document, argument)
|
||||
;
|
||||
"ReverseEngineering.poissonReconstruction(%2)")
|
||||
.arg(document, argument);
|
||||
|
||||
Gui::WaitCursor wc;
|
||||
Gui::Command::addModule(Gui::Command::App, "ReverseEngineering");
|
||||
@@ -98,7 +94,7 @@ bool PoissonWidget::accept()
|
||||
return true;
|
||||
}
|
||||
|
||||
void PoissonWidget::changeEvent(QEvent *e)
|
||||
void PoissonWidget::changeEvent(QEvent* e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
@@ -112,9 +108,10 @@ void PoissonWidget::changeEvent(QEvent *e)
|
||||
TaskPoisson::TaskPoisson(const App::DocumentObjectT& obj)
|
||||
{
|
||||
widget = new PoissonWidget(obj);
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
Gui::BitmapFactory().pixmap("actions/FitSurface"),
|
||||
widget->windowTitle(), true, nullptr);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/FitSurface"),
|
||||
widget->windowTitle(),
|
||||
true,
|
||||
nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
@@ -122,8 +119,7 @@ TaskPoisson::TaskPoisson(const App::DocumentObjectT& obj)
|
||||
TaskPoisson::~TaskPoisson() = default;
|
||||
|
||||
void TaskPoisson::open()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool TaskPoisson::accept()
|
||||
{
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
|
||||
|
||||
namespace ReenGui {
|
||||
namespace ReenGui
|
||||
{
|
||||
|
||||
class PoissonWidget : public QWidget
|
||||
class PoissonWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -40,14 +41,14 @@ public:
|
||||
bool accept();
|
||||
|
||||
private:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
class TaskPoisson : public Gui::TaskView::TaskDialog
|
||||
class TaskPoisson: public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -60,13 +61,15 @@ public:
|
||||
bool accept() override;
|
||||
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const override
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
{
|
||||
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
|
||||
}
|
||||
|
||||
private:
|
||||
PoissonWidget* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace ReenGui
|
||||
}// namespace ReenGui
|
||||
|
||||
#endif // REENGUI_POISSON_H
|
||||
#endif// REENGUI_POISSON_H
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4181)
|
||||
# pragma warning(disable : 4267)
|
||||
# pragma warning(disable : 4275)
|
||||
# pragma warning(disable : 4305)
|
||||
# pragma warning(disable : 4522)
|
||||
#pragma warning(disable : 4181)
|
||||
#pragma warning(disable : 4267)
|
||||
#pragma warning(disable : 4275)
|
||||
#pragma warning(disable : 4305)
|
||||
#pragma warning(disable : 4522)
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
@@ -40,10 +40,10 @@
|
||||
#include <sstream>
|
||||
|
||||
// OpenCasCade
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
@@ -53,6 +53,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#endif //_PreComp_
|
||||
#endif//_PreComp_
|
||||
|
||||
#endif // __PRECOMPILED_GUI__
|
||||
#endif// __PRECOMPILED_GUI__
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
#include <sstream>
|
||||
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
# include <Standard_Failure.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -38,8 +38,8 @@
|
||||
#include <App/DocumentObjectGroup.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/Core/Curvature.h>
|
||||
#include <Mod/Mesh/App/Core/Segmentation.h>
|
||||
#include <Mod/Mesh/App/Core/Smoothing.h>
|
||||
@@ -54,9 +54,9 @@
|
||||
using namespace ReverseEngineeringGui;
|
||||
|
||||
Segmentation::Segmentation(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl)
|
||||
: QWidget(parent, fl)
|
||||
, ui(new Ui_Segmentation)
|
||||
, myMesh(mesh)
|
||||
: QWidget(parent, fl)
|
||||
, ui(new Ui_Segmentation)
|
||||
, myMesh(mesh)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->numPln->setRange(1, INT_MAX);
|
||||
@@ -69,8 +69,9 @@ Segmentation::~Segmentation() = default;
|
||||
|
||||
void Segmentation::accept()
|
||||
{
|
||||
if (myMesh.expired())
|
||||
if (myMesh.expired()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::WaitCursor wc;
|
||||
bool createUnused = ui->createUnused->isChecked();
|
||||
@@ -96,8 +97,10 @@ void Segmentation::accept()
|
||||
// First create segments by curavture to get the surface type
|
||||
std::vector<MeshCore::MeshSurfaceSegmentPtr> segm;
|
||||
if (ui->groupBoxPln->isChecked()) {
|
||||
segm.emplace_back(std::make_shared<MeshCore::MeshCurvaturePlanarSegment>
|
||||
(meshCurv.GetCurvature(), ui->numPln->value(), ui->curvTolPln->value()));
|
||||
segm.emplace_back(
|
||||
std::make_shared<MeshCore::MeshCurvaturePlanarSegment>(meshCurv.GetCurvature(),
|
||||
ui->numPln->value(),
|
||||
ui->curvTolPln->value()));
|
||||
}
|
||||
finder.FindSegments(segm);
|
||||
|
||||
@@ -105,7 +108,8 @@ void Segmentation::accept()
|
||||
for (const auto& it : segm) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
|
||||
|
||||
// For each planar segment compute a plane and use this then for a more accurate 2nd segmentation
|
||||
// For each planar segment compute a plane and use this then for a more accurate 2nd
|
||||
// segmentation
|
||||
if (strcmp(it->GetType(), "Plane") == 0) {
|
||||
for (const auto& jt : data) {
|
||||
std::vector<MeshCore::PointIndex> indexes = kernel.GetFacetPoints(jt);
|
||||
@@ -114,9 +118,14 @@ void Segmentation::accept()
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
Base::Vector3f base = fit.GetBase();
|
||||
Base::Vector3f axis = fit.GetNormal();
|
||||
MeshCore::AbstractSurfaceFit* fitter = new MeshCore::PlaneSurfaceFit(base, axis);
|
||||
segmSurf.emplace_back(std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>
|
||||
(fitter, kernel, ui->numPln->value(), ui->distToPln->value()));
|
||||
MeshCore::AbstractSurfaceFit* fitter =
|
||||
new MeshCore::PlaneSurfaceFit(base, axis);
|
||||
segmSurf.emplace_back(
|
||||
std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>(
|
||||
fitter,
|
||||
kernel,
|
||||
ui->numPln->value(),
|
||||
ui->distToPln->value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,8 +138,8 @@ void Segmentation::accept()
|
||||
std::string internalname = "Segments_";
|
||||
internalname += myMesh->getNameInDocument();
|
||||
|
||||
App::DocumentObjectGroup* group = static_cast<App::DocumentObjectGroup*>(document->addObject
|
||||
("App::DocumentObjectGroup", internalname.c_str()));
|
||||
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);
|
||||
@@ -140,8 +149,8 @@ void Segmentation::accept()
|
||||
|
||||
for (const auto& it : segmSurf) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
|
||||
std::shared_ptr<MeshCore::MeshDistanceGenericSurfaceFitSegment> genSegm = std::dynamic_pointer_cast
|
||||
<MeshCore::MeshDistanceGenericSurfaceFitSegment>(it);
|
||||
std::shared_ptr<MeshCore::MeshDistanceGenericSurfaceFitSegment> genSegm =
|
||||
std::dynamic_pointer_cast<MeshCore::MeshDistanceGenericSurfaceFitSegment>(it);
|
||||
|
||||
bool isPlanar = (strcmp(genSegm->GetType(), "Plane") == 0);
|
||||
for (const auto& jt : data) {
|
||||
@@ -149,7 +158,8 @@ void Segmentation::accept()
|
||||
algo.ResetFacetsFlag(jt, MeshCore::MeshFacet::TMP0);
|
||||
|
||||
Mesh::MeshObject* segment = mesh->meshFromSegment(jt);
|
||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::Feature* feaSegm =
|
||||
static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||
feaMesh->swap(*segment);
|
||||
feaSegm->Mesh.finishEditing();
|
||||
@@ -160,7 +170,7 @@ void Segmentation::accept()
|
||||
feaSegm->Label.setValue(label.str());
|
||||
|
||||
if (createCompound) {
|
||||
std::list<std::vector<Base::Vector3f> > bounds;
|
||||
std::list<std::vector<Base::Vector3f>> bounds;
|
||||
algo.GetFacetBorders(jt, bounds);
|
||||
|
||||
// Handle planar segments
|
||||
@@ -172,16 +182,22 @@ void Segmentation::accept()
|
||||
Handle(Geom_Plane) hPlane(new Geom_Plane(loc, dir));
|
||||
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (const auto & bound : bounds) {
|
||||
for (const auto& bound : bounds) {
|
||||
// project the points onto the surface
|
||||
std::vector<gp_Pnt> polygon;
|
||||
std::transform(bound.begin(), bound.end(), std::back_inserter(polygon), [&hPlane](const Base::Vector3f& v) {
|
||||
gp_Pnt p(v.x, v.y, v.z);
|
||||
return GeomAPI_ProjectPointOnSurf(p, hPlane).NearestPoint();
|
||||
});
|
||||
std::transform(
|
||||
bound.begin(),
|
||||
bound.end(),
|
||||
std::back_inserter(polygon),
|
||||
[&hPlane](const Base::Vector3f& v) {
|
||||
gp_Pnt p(v.x, v.y, v.z);
|
||||
return GeomAPI_ProjectPointOnSurf(p, hPlane).NearestPoint();
|
||||
});
|
||||
|
||||
BRepBuilderAPI_MakePolygon mkPoly;
|
||||
for (std::vector<gp_Pnt>::reverse_iterator it = polygon.rbegin(); it != polygon.rend(); ++it) {
|
||||
for (std::vector<gp_Pnt>::reverse_iterator it = polygon.rbegin();
|
||||
it != polygon.rend();
|
||||
++it) {
|
||||
mkPoly.Add(*it);
|
||||
}
|
||||
if (mkPoly.IsDone()) {
|
||||
@@ -196,12 +212,14 @@ void Segmentation::accept()
|
||||
}
|
||||
else {
|
||||
failures.push_back(feaSegm);
|
||||
Base::Console().Warning("Failed to create face from %s\n", feaSegm->Label.getValue());
|
||||
Base::Console().Warning("Failed to create face from %s\n",
|
||||
feaSegm->Label.getValue());
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure&) {
|
||||
failures.push_back(feaSegm);
|
||||
Base::Console().Error("Fatal failure to create face from %s\n", feaSegm->Label.getValue());
|
||||
Base::Console().Error("Fatal failure to create face from %s\n",
|
||||
feaSegm->Label.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,20 +233,22 @@ void Segmentation::accept()
|
||||
|
||||
if (!unusedFacets.empty()) {
|
||||
std::unique_ptr<Mesh::MeshObject> segment(mesh->meshFromSegment(unusedFacets));
|
||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Unused"));
|
||||
Mesh::Feature* feaSegm =
|
||||
static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Unused"));
|
||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||
feaMesh->swap(*segment);
|
||||
feaSegm->Mesh.finishEditing();
|
||||
}
|
||||
}
|
||||
if (createCompound) {
|
||||
Part::Feature* shapeFea = static_cast<Part::Feature*>(group->addObject("Part::Feature", "Compound"));
|
||||
Part::Feature* shapeFea =
|
||||
static_cast<Part::Feature*>(group->addObject("Part::Feature", "Compound"));
|
||||
shapeFea->Shape.setValue(compound);
|
||||
|
||||
// create a sub-group where to move the problematic segments
|
||||
if (!failures.empty()) {
|
||||
App::DocumentObjectGroup* subgroup = static_cast<App::DocumentObjectGroup*>(group->addObject
|
||||
("App::DocumentObjectGroup", "Failed"));
|
||||
App::DocumentObjectGroup* subgroup = static_cast<App::DocumentObjectGroup*>(
|
||||
group->addObject("App::DocumentObjectGroup", "Failed"));
|
||||
failures = group->removeObjects(failures);
|
||||
subgroup->Group.setValues(failures);
|
||||
}
|
||||
@@ -237,7 +257,7 @@ void Segmentation::accept()
|
||||
document->commitTransaction();
|
||||
}
|
||||
|
||||
void Segmentation::changeEvent(QEvent *e)
|
||||
void Segmentation::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -252,8 +272,7 @@ void Segmentation::changeEvent(QEvent *e)
|
||||
TaskSegmentation::TaskSegmentation(Mesh::Feature* mesh)
|
||||
{
|
||||
widget = new Segmentation(mesh);
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
QPixmap(), widget->windowTitle(), false, nullptr);
|
||||
taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
@@ -32,22 +32,28 @@
|
||||
|
||||
|
||||
// forward declarations
|
||||
namespace Mesh { class Feature; }
|
||||
namespace Mesh
|
||||
{
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace ReverseEngineeringGui {
|
||||
namespace ReverseEngineeringGui
|
||||
{
|
||||
class Ui_Segmentation;
|
||||
|
||||
class Segmentation : public QWidget
|
||||
class Segmentation: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Segmentation(Mesh::Feature* mesh, QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
explicit Segmentation(Mesh::Feature* mesh,
|
||||
QWidget* parent = nullptr,
|
||||
Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
~Segmentation() override;
|
||||
void accept();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_Segmentation> ui;
|
||||
@@ -57,7 +63,7 @@ private:
|
||||
/**
|
||||
* Embed the panel into a task dialog.
|
||||
*/
|
||||
class TaskSegmentation : public Gui::TaskView::TaskDialog
|
||||
class TaskSegmentation: public Gui::TaskView::TaskDialog
|
||||
{
|
||||
public:
|
||||
explicit TaskSegmentation(Mesh::Feature* mesh);
|
||||
@@ -66,13 +72,15 @@ public:
|
||||
bool accept() override;
|
||||
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const override
|
||||
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
|
||||
{
|
||||
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
|
||||
}
|
||||
|
||||
private:
|
||||
Segmentation* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace ReverseEngineeringGui
|
||||
|
||||
#endif // REVERSEENGINEERINGGUI_SEGMENTATION_H
|
||||
#endif// REVERSEENGINEERINGGUI_SEGMENTATION_H
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QPushButton>
|
||||
#include <QPushButton>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
#include <Mod/Mesh/App/Core/Segmentation.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
#include <Mod/Mesh/Gui/ViewProvider.h>
|
||||
@@ -42,8 +42,8 @@
|
||||
using namespace ReverseEngineeringGui;
|
||||
|
||||
SegmentationManual::SegmentationManual(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QWidget(parent, fl)
|
||||
, ui(new Ui_SegmentationManual)
|
||||
: QWidget(parent, fl)
|
||||
, ui(new Ui_SegmentationManual)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setupConnections();
|
||||
@@ -60,31 +60,47 @@ SegmentationManual::~SegmentationManual() = default;
|
||||
|
||||
void SegmentationManual::setupConnections()
|
||||
{
|
||||
connect(ui->selectRegion, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onSelectRegionClicked);
|
||||
connect(ui->selectAll, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onSelectAllClicked);
|
||||
connect(ui->selectComponents, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onSelectComponentsClicked);
|
||||
connect(ui->selectTriangle, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onSelectTriangleClicked);
|
||||
connect(ui->deselectAll, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onDeselectAllClicked);
|
||||
connect(ui->visibleTriangles, &QCheckBox::toggled,
|
||||
this, &SegmentationManual::onVisibleTrianglesToggled);
|
||||
connect(ui->screenTriangles, &QCheckBox::toggled,
|
||||
this, &SegmentationManual::onScreenTrianglesToggled);
|
||||
connect(ui->cbSelectComp, &QCheckBox::toggled,
|
||||
this, &SegmentationManual::onSelectCompToggled);
|
||||
connect(ui->planeDetect, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onPlaneDetectClicked);
|
||||
connect(ui->cylinderDetect, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onCylinderDetectClicked);
|
||||
connect(ui->sphereDetect, &QPushButton::clicked,
|
||||
this, &SegmentationManual::onSphereDetectClicked);
|
||||
connect(ui->selectRegion,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onSelectRegionClicked);
|
||||
connect(ui->selectAll, &QPushButton::clicked, this, &SegmentationManual::onSelectAllClicked);
|
||||
connect(ui->selectComponents,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onSelectComponentsClicked);
|
||||
connect(ui->selectTriangle,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onSelectTriangleClicked);
|
||||
connect(ui->deselectAll,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onDeselectAllClicked);
|
||||
connect(ui->visibleTriangles,
|
||||
&QCheckBox::toggled,
|
||||
this,
|
||||
&SegmentationManual::onVisibleTrianglesToggled);
|
||||
connect(ui->screenTriangles,
|
||||
&QCheckBox::toggled,
|
||||
this,
|
||||
&SegmentationManual::onScreenTrianglesToggled);
|
||||
connect(ui->cbSelectComp, &QCheckBox::toggled, this, &SegmentationManual::onSelectCompToggled);
|
||||
connect(ui->planeDetect,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onPlaneDetectClicked);
|
||||
connect(ui->cylinderDetect,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onCylinderDetectClicked);
|
||||
connect(ui->sphereDetect,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&SegmentationManual::onSphereDetectClicked);
|
||||
}
|
||||
|
||||
void SegmentationManual::changeEvent(QEvent *e)
|
||||
void SegmentationManual::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -131,55 +147,64 @@ void SegmentationManual::onSelectCompToggled(bool on)
|
||||
meshSel.setAddComponentOnClick(on);
|
||||
}
|
||||
|
||||
class SegmentationManual::Private {
|
||||
public:
|
||||
static void findGeometry(int minFaces, double tolerance,
|
||||
std::function<MeshCore::AbstractSurfaceFit*(const std::vector<Base::Vector3f>&,
|
||||
const std::vector<Base::Vector3f>&)> fitFunc)
|
||||
class SegmentationManual::Private
|
||||
{
|
||||
Gui::Document* gdoc = Gui::Application::Instance->activeDocument();
|
||||
if (!gdoc)
|
||||
return;
|
||||
public:
|
||||
static void findGeometry(
|
||||
int minFaces,
|
||||
double tolerance,
|
||||
std::function<MeshCore::AbstractSurfaceFit*(const std::vector<Base::Vector3f>&,
|
||||
const std::vector<Base::Vector3f>&)> fitFunc)
|
||||
{
|
||||
Gui::Document* gdoc = Gui::Application::Instance->activeDocument();
|
||||
if (!gdoc) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::Document* adoc = gdoc->getDocument();
|
||||
std::vector<Mesh::Feature*> meshes = adoc->getObjectsOfType<Mesh::Feature>();
|
||||
for (auto it : meshes) {
|
||||
MeshGui::ViewProviderMesh* vpm = static_cast<MeshGui::ViewProviderMesh*>(gdoc->getViewProvider(it));
|
||||
const Mesh::MeshObject& mesh = it->Mesh.getValue();
|
||||
App::Document* adoc = gdoc->getDocument();
|
||||
std::vector<Mesh::Feature*> meshes = adoc->getObjectsOfType<Mesh::Feature>();
|
||||
for (auto it : meshes) {
|
||||
MeshGui::ViewProviderMesh* vpm =
|
||||
static_cast<MeshGui::ViewProviderMesh*>(gdoc->getViewProvider(it));
|
||||
const Mesh::MeshObject& mesh = it->Mesh.getValue();
|
||||
|
||||
if (mesh.hasSelectedFacets()) {
|
||||
const MeshCore::MeshKernel& kernel = mesh.getKernel();
|
||||
if (mesh.hasSelectedFacets()) {
|
||||
const MeshCore::MeshKernel& kernel = mesh.getKernel();
|
||||
|
||||
std::vector<MeshCore::FacetIndex> facets;
|
||||
std::vector<MeshCore::PointIndex> vertexes;
|
||||
mesh.getFacetsFromSelection(facets);
|
||||
vertexes = mesh.getPointsFromFacets(facets);
|
||||
MeshCore::MeshPointArray coords = kernel.GetPoints(vertexes);
|
||||
std::vector<MeshCore::FacetIndex> facets;
|
||||
std::vector<MeshCore::PointIndex> vertexes;
|
||||
mesh.getFacetsFromSelection(facets);
|
||||
vertexes = mesh.getPointsFromFacets(facets);
|
||||
MeshCore::MeshPointArray coords = kernel.GetPoints(vertexes);
|
||||
|
||||
std::vector<Base::Vector3f> points, normals;
|
||||
normals = kernel.GetFacetNormals(facets);
|
||||
points.insert(points.end(), coords.begin(), coords.end());
|
||||
coords.clear();
|
||||
std::vector<Base::Vector3f> points, normals;
|
||||
normals = kernel.GetFacetNormals(facets);
|
||||
points.insert(points.end(), coords.begin(), coords.end());
|
||||
coords.clear();
|
||||
|
||||
MeshCore::AbstractSurfaceFit* surfFit = fitFunc(points, normals);
|
||||
if (surfFit) {
|
||||
MeshCore::MeshSegmentAlgorithm finder(kernel);
|
||||
MeshCore::AbstractSurfaceFit* surfFit = fitFunc(points, normals);
|
||||
if (surfFit) {
|
||||
MeshCore::MeshSegmentAlgorithm finder(kernel);
|
||||
|
||||
std::vector<MeshCore::MeshSurfaceSegmentPtr> segm;
|
||||
segm.emplace_back(std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>
|
||||
(surfFit, kernel, minFaces, tolerance));
|
||||
finder.FindSegments(segm);
|
||||
std::vector<MeshCore::MeshSurfaceSegmentPtr> segm;
|
||||
segm.emplace_back(
|
||||
std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>(
|
||||
surfFit,
|
||||
kernel,
|
||||
minFaces,
|
||||
tolerance));
|
||||
finder.FindSegments(segm);
|
||||
|
||||
for (const auto& segmIt : segm) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = segmIt->GetSegments();
|
||||
for (const auto& dataIt : data) {
|
||||
vpm->addSelection(dataIt);
|
||||
for (const auto& segmIt : segm) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = segmIt->GetSegments();
|
||||
for (const auto& dataIt : data) {
|
||||
vpm->addSelection(dataIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void SegmentationManual::onPlaneDetectClicked()
|
||||
@@ -248,8 +273,9 @@ void SegmentationManual::onSphereDetectClicked()
|
||||
void SegmentationManual::createSegment()
|
||||
{
|
||||
Gui::Document* gdoc = Gui::Application::Instance->activeDocument();
|
||||
if (!gdoc)
|
||||
if (!gdoc) {
|
||||
return;
|
||||
}
|
||||
// delete all selected faces
|
||||
App::Document* adoc = gdoc->getDocument();
|
||||
gdoc->openCommand(QT_TRANSLATE_NOOP("Command", "Segmentation"));
|
||||
@@ -269,7 +295,8 @@ void SegmentationManual::createSegment()
|
||||
algo.GetFacetsFlag(facets, MeshCore::MeshFacet::SELECTED);
|
||||
|
||||
std::unique_ptr<Mesh::MeshObject> segment(mesh.meshFromSegment(facets));
|
||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(adoc->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::Feature* feaSegm =
|
||||
static_cast<Mesh::Feature*>(adoc->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||
feaMesh->swap(*segment);
|
||||
feaMesh->clearFacetSelection();
|
||||
@@ -287,10 +314,12 @@ void SegmentationManual::createSegment()
|
||||
}
|
||||
}
|
||||
|
||||
if (!selected)
|
||||
if (!selected) {
|
||||
gdoc->abortCommand();
|
||||
else
|
||||
}
|
||||
else {
|
||||
gdoc->commitCommand();
|
||||
}
|
||||
meshSel.clearSelection();
|
||||
}
|
||||
|
||||
@@ -314,8 +343,7 @@ void SegmentationManual::reject()
|
||||
TaskSegmentationManual::TaskSegmentationManual()
|
||||
{
|
||||
widget = new SegmentationManual();
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
QPixmap(), widget->windowTitle(), false, nullptr);
|
||||
taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include <Mod/Mesh/Gui/MeshSelection.h>
|
||||
|
||||
|
||||
namespace ReverseEngineeringGui {
|
||||
namespace ReverseEngineeringGui
|
||||
{
|
||||
class Ui_SegmentationManual;
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ class Ui_SegmentationManual;
|
||||
* of a mesh.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class SegmentationManual : public QWidget
|
||||
class SegmentationManual: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
void onSphereDetectClicked();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
@@ -78,7 +79,7 @@ private:
|
||||
/**
|
||||
* Embed the panel into a task dialog.
|
||||
*/
|
||||
class TaskSegmentationManual : public Gui::TaskView::TaskDialog
|
||||
class TaskSegmentationManual: public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -90,9 +91,13 @@ public:
|
||||
void clicked(int) override;
|
||||
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const override
|
||||
{ return QDialogButtonBox::Ok | QDialogButtonBox::Close; }
|
||||
{
|
||||
return QDialogButtonBox::Ok | QDialogButtonBox::Close;
|
||||
}
|
||||
bool isAllowedAlterDocument() const override
|
||||
{ return true; }
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void modifyStandardButtons(QDialogButtonBox*) override;
|
||||
|
||||
private:
|
||||
@@ -100,6 +105,6 @@ private:
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace ReverseEngineeringGui
|
||||
|
||||
#endif // REVERSEENGINEERINGGUI_SEGMENTATIONMANUAL_H
|
||||
#endif// REVERSEENGINEERINGGUI_SEGMENTATIONMANUAL_H
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
using namespace ReverseEngineeringGui;
|
||||
|
||||
#if 0 // needed for Qt's lupdate utility
|
||||
#if 0// needed for Qt's lupdate utility
|
||||
qApp->translate("Workbench", "Reverse Engineering");
|
||||
#endif
|
||||
|
||||
@@ -49,13 +49,13 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
root->insertItem(item, reen);
|
||||
reen->setCommand("&Reverse Engineering");
|
||||
|
||||
Gui::MenuItem *reconstruct = new Gui::MenuItem();
|
||||
Gui::MenuItem* reconstruct = new Gui::MenuItem();
|
||||
reconstruct->setCommand("Surface reconstruction");
|
||||
*reconstruct << "Reen_PoissonReconstruction"
|
||||
<< "Reen_ViewTriangulation";
|
||||
*reen << reconstruct;
|
||||
|
||||
Gui::MenuItem *segm = new Gui::MenuItem();
|
||||
Gui::MenuItem* segm = new Gui::MenuItem();
|
||||
segm->setCommand("Segmentation");
|
||||
*segm << "Mesh_RemeshGmsh"
|
||||
<< "Mesh_VertexCurvature"
|
||||
@@ -67,7 +67,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
<< "Reen_MeshBoundary";
|
||||
*reen << segm;
|
||||
|
||||
Gui::MenuItem *approx = new Gui::MenuItem();
|
||||
Gui::MenuItem* approx = new Gui::MenuItem();
|
||||
approx->setCommand("Approximation");
|
||||
*approx << "Reen_ApproxPlane"
|
||||
<< "Reen_ApproxCylinder"
|
||||
@@ -75,7 +75,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
<< "Reen_ApproxPolynomial"
|
||||
<< "Separator"
|
||||
<< "Reen_ApproxSurface";
|
||||
*reen << approx;
|
||||
*reen << approx;
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
|
||||
part->setCommand("Reverse Engineering");
|
||||
*part << "Reen_ApproxSurface";
|
||||
return root;
|
||||
return root;
|
||||
}
|
||||
|
||||
Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
@@ -95,4 +95,3 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
Gui::ToolBarItem* root = new Gui::ToolBarItem;
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
|
||||
#include <Gui/Workbench.h>
|
||||
|
||||
namespace ReverseEngineeringGui {
|
||||
namespace ReverseEngineeringGui
|
||||
{
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class Workbench : public Gui::StdWorkbench
|
||||
class Workbench: public Gui::StdWorkbench
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
|
||||
@@ -45,7 +46,7 @@ protected:
|
||||
Gui::ToolBarItem* setupCommandBars() const override;
|
||||
};
|
||||
|
||||
} // namespace ReverseEngineeringGui
|
||||
}// namespace ReverseEngineeringGui
|
||||
|
||||
|
||||
#endif // REENGUI_WORKBENCH_H
|
||||
#endif// REENGUI_WORKBENCH_H
|
||||
|
||||
Reference in New Issue
Block a user