Mesh: Apply clang-format

This commit is contained in:
wmayer
2023-09-23 00:29:09 +02:00
committed by wwmayer
parent 4e328682d9
commit 15b11bc360
78 changed files with 4221 additions and 3294 deletions

View File

@@ -15,7 +15,8 @@ Sample code for creating a mesh:
import math
def Sphere (radius, count):
def Sphere(radius, count):
"""Creates a sphere with a given radius.
bla bla bla
@@ -23,11 +24,12 @@ def Sphere (radius, count):
"""
return Ellipsoid(radius, radius, count)
def Ellipsoid (lenX, lenY, count):
def Ellipsoid(lenX, lenY, count):
polyline = []
step = math.pi / count
i = 0.0
while (i < math.pi + step / 10.0):
while i < math.pi + step / 10.0:
x = math.cos(i) * lenX
y = math.sin(i) * lenY
polyline.append([x, y])
@@ -35,53 +37,56 @@ def Ellipsoid (lenX, lenY, count):
return RotationBody(polyline, count)
def Cylinder (radius, len, closed, edgelen, count):
def Cylinder(radius, len, closed, edgelen, count):
return Cone(radius, radius, len, closed, edgelen, count)
def Cone (radius1, radius2, len, closed, edgelen, count):
def Cone(radius1, radius2, len, closed, edgelen, count):
polyline = []
if (closed):
if closed:
try:
step = radius2 / math.ceil(radius2 / edgelen)
except ZeroDivisionError:
pass
else:
i = 0.0
while (i < radius2 - step / 2.0):
while i < radius2 - step / 2.0:
polyline.append([len, i])
i = i + step
ct = math.ceil(len / edgelen)
step = len / ct
rstep = (radius1 - radius2) / ct
i = len;
i = len
r = radius2
while (i > 0.0 + step / 2.0):
while i > 0.0 + step / 2.0:
polyline.append([i, r])
i = i - step
r = r + rstep
polyline.append([0.0, radius1])
if (closed):
if closed:
try:
step = radius1 / math.ceil(radius1 / edgelen)
except ZeroDivisionError:
pass
else:
i = radius1 - step
while (i > 0.0 + step / 2.0):
while i > 0.0 + step / 2.0:
polyline.append([0.0, i])
i = i - step
polyline.append([0.0, 0.0])
return RotationBody(polyline, count)
def Toroid (radius1, radius2, count):
def Toroid(radius1, radius2, count):
polyline = []
step = math.pi * 2.0 / count
i = -math.pi
while (i < math.pi + step / 10.0):
while i < math.pi + step / 10.0:
x = radius1 + math.cos(i) * radius2
y = radius1 + math.sin(i) * radius2
polyline.append([x, y])
@@ -90,7 +95,7 @@ def Toroid (radius1, radius2, count):
return RotationBody(polyline, count)
def RotationBody (polyline, count):
def RotationBody(polyline, count):
"""Build a rotation body from a given (closed) polyline, rotation axis is the X-Axis.
Parameter: polyline: list of tuple of 2 floats (2d vector)
@@ -99,12 +104,12 @@ def RotationBody (polyline, count):
facets = []
step = math.pi * 2.0 / count
i = -math.pi;
while (i < math.pi - step / 10.0):
i = -math.pi
while i < math.pi - step / 10.0:
li = i + step
for j in range(0, len(polyline) - 1):
v1 = polyline[j]
v2 = polyline[j+1]
v2 = polyline[j + 1]
x1 = v1[0]
y1 = v1[1] * math.cos(i)
@@ -119,21 +124,22 @@ def RotationBody (polyline, count):
y4 = v2[1] * math.cos(li)
z4 = v2[1] * math.sin(li)
if (v1[1] != 0.0):
if v1[1] != 0.0:
facets.append([x1, y1, z1])
facets.append([x2, y2, z2])
facets.append([x3, y3, z3])
if (v2[1] != 0.0):
if v2[1] != 0.0:
facets.append([x2, y2, z2])
facets.append([x4, y4, z4])
facets.append([x3, y3, z3])
i = i + step
return facets;
return facets
def Cube (lenX, lenY, lenZ):
def Cube(lenX, lenY, lenZ):
hx = lenX / 2.0
hy = lenY / 2.0
hz = lenZ / 2.0
@@ -190,80 +196,83 @@ def Cube (lenX, lenY, lenZ):
return facets
def FineCube (lenX, lenY, lenZ, edgelen):
def FineCube(lenX, lenY, lenZ, edgelen):
hx = lenX / 2.0
hy = lenY / 2.0
hz = lenZ / 2.0
cx = int(max(lenX / edgelen,1))
cx = int(max(lenX / edgelen, 1))
dx = lenX / cx
cy = int(max(lenY / edgelen,1))
cy = int(max(lenY / edgelen, 1))
dy = lenY / cy
cz = int(max(lenZ / edgelen,1))
cz = int(max(lenZ / edgelen, 1))
dz = lenZ / cz
facets = []
# z
for i in range(0,cx):
for j in range(0,cy):
facets.append([-hx+(i+0)*dx, -hy+(j+0)*dy, -hz])
facets.append([-hx+(i+0)*dx, -hy+(j+1)*dy, -hz])
facets.append([-hx+(i+1)*dx, -hy+(j+1)*dy, -hz])
for i in range(0, cx):
for j in range(0, cy):
facets.append([-hx + (i + 0) * dx, -hy + (j + 0) * dy, -hz])
facets.append([-hx + (i + 0) * dx, -hy + (j + 1) * dy, -hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 1) * dy, -hz])
facets.append([-hx+(i+0)*dx, -hy+(j+0)*dy, -hz])
facets.append([-hx+(i+1)*dx, -hy+(j+1)*dy, -hz])
facets.append([-hx+(i+1)*dx, -hy+(j+0)*dy, -hz])
facets.append([-hx + (i + 0) * dx, -hy + (j + 0) * dy, -hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 1) * dy, -hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 0) * dy, -hz])
facets.append([-hx+(i+0)*dx, -hy+(j+0)*dy, hz])
facets.append([-hx+(i+1)*dx, -hy+(j+1)*dy, hz])
facets.append([-hx+(i+0)*dx, -hy+(j+1)*dy, hz])
facets.append([-hx + (i + 0) * dx, -hy + (j + 0) * dy, hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 1) * dy, hz])
facets.append([-hx + (i + 0) * dx, -hy + (j + 1) * dy, hz])
facets.append([-hx+(i+0)*dx, -hy+(j+0)*dy, hz])
facets.append([-hx+(i+1)*dx, -hy+(j+0)*dy, hz])
facets.append([-hx+(i+1)*dx, -hy+(j+1)*dy, hz])
facets.append([-hx + (i + 0) * dx, -hy + (j + 0) * dy, hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 0) * dy, hz])
facets.append([-hx + (i + 1) * dx, -hy + (j + 1) * dy, hz])
# y
for i in range(0,cx):
for j in range(0,cz):
facets.append([-hx+(i+0)*dx, -hy, -hz+(j+0)*dz])
facets.append([-hx+(i+1)*dx, -hy, -hz+(j+1)*dz])
facets.append([-hx+(i+0)*dx, -hy, -hz+(j+1)*dz])
for i in range(0, cx):
for j in range(0, cz):
facets.append([-hx + (i + 0) * dx, -hy, -hz + (j + 0) * dz])
facets.append([-hx + (i + 1) * dx, -hy, -hz + (j + 1) * dz])
facets.append([-hx + (i + 0) * dx, -hy, -hz + (j + 1) * dz])
facets.append([-hx+(i+0)*dx, -hy, -hz+(j+0)*dz])
facets.append([-hx+(i+1)*dx, -hy, -hz+(j+0)*dz])
facets.append([-hx+(i+1)*dx, -hy, -hz+(j+1)*dz])
facets.append([-hx + (i + 0) * dx, -hy, -hz + (j + 0) * dz])
facets.append([-hx + (i + 1) * dx, -hy, -hz + (j + 0) * dz])
facets.append([-hx + (i + 1) * dx, -hy, -hz + (j + 1) * dz])
facets.append([-hx+(i+0)*dx, hy, -hz+(j+0)*dz])
facets.append([-hx+(i+0)*dx, hy, -hz+(j+1)*dz])
facets.append([-hx+(i+1)*dx, hy, -hz+(j+1)*dz])
facets.append([-hx + (i + 0) * dx, hy, -hz + (j + 0) * dz])
facets.append([-hx + (i + 0) * dx, hy, -hz + (j + 1) * dz])
facets.append([-hx + (i + 1) * dx, hy, -hz + (j + 1) * dz])
facets.append([-hx+(i+0)*dx, hy, -hz+(j+0)*dz])
facets.append([-hx+(i+1)*dx, hy, -hz+(j+1)*dz])
facets.append([-hx+(i+1)*dx, hy, -hz+(j+0)*dz])
facets.append([-hx + (i + 0) * dx, hy, -hz + (j + 0) * dz])
facets.append([-hx + (i + 1) * dx, hy, -hz + (j + 1) * dz])
facets.append([-hx + (i + 1) * dx, hy, -hz + (j + 0) * dz])
# x
for i in range(0,cy):
for j in range(0,cz):
facets.append([-hx, -hy+(i+0)*dy, -hz+(j+0)*dz])
facets.append([-hx, -hy+(i+0)*dy, -hz+(j+1)*dz])
facets.append([-hx, -hy+(i+1)*dy, -hz+(j+1)*dz])
for i in range(0, cy):
for j in range(0, cz):
facets.append([-hx, -hy + (i + 0) * dy, -hz + (j + 0) * dz])
facets.append([-hx, -hy + (i + 0) * dy, -hz + (j + 1) * dz])
facets.append([-hx, -hy + (i + 1) * dy, -hz + (j + 1) * dz])
facets.append([-hx, -hy+(i+0)*dy, -hz+(j+0)*dz])
facets.append([-hx, -hy+(i+1)*dy, -hz+(j+1)*dz])
facets.append([-hx, -hy+(i+1)*dy, -hz+(j+0)*dz])
facets.append([-hx, -hy + (i + 0) * dy, -hz + (j + 0) * dz])
facets.append([-hx, -hy + (i + 1) * dy, -hz + (j + 1) * dz])
facets.append([-hx, -hy + (i + 1) * dy, -hz + (j + 0) * dz])
facets.append([hx, -hy+(i+0)*dy, -hz+(j+0)*dz])
facets.append([hx, -hy+(i+1)*dy, -hz+(j+1)*dz])
facets.append([hx, -hy+(i+0)*dy, -hz+(j+1)*dz])
facets.append([hx, -hy + (i + 0) * dy, -hz + (j + 0) * dz])
facets.append([hx, -hy + (i + 1) * dy, -hz + (j + 1) * dz])
facets.append([hx, -hy + (i + 0) * dy, -hz + (j + 1) * dz])
facets.append([hx, -hy+(i+0)*dy, -hz+(j+0)*dz])
facets.append([hx, -hy+(i+1)*dy, -hz+(j+0)*dz])
facets.append([hx, -hy+(i+1)*dy, -hz+(j+1)*dz])
facets.append([hx, -hy + (i + 0) * dy, -hz + (j + 0) * dz])
facets.append([hx, -hy + (i + 1) * dy, -hz + (j + 0) * dz])
facets.append([hx, -hy + (i + 1) * dy, -hz + (j + 1) * dz])
return facets
def main ():
Cylinder (10.0, 20.0, 1, 10, 10)
def main():
Cylinder(10.0, 20.0, 1, 10, 10)
if __name__ == "__main__":
main()

View File

@@ -47,4 +47,3 @@ INSTALL(
INSTALL(FILES ${MeshTestDataFiles} DESTINATION Mod/Mesh/App/TestData)

View File

@@ -22,12 +22,12 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/SoDB.h>
# include <Inventor/SoInput.h>
# include <Inventor/annex/ForeignFiles/SoSTLFileKit.h>
# include <Inventor/nodes/SoSeparator.h>
#include <Inventor/SoDB.h>
#include <Inventor/SoInput.h>
#include <Inventor/annex/ForeignFiles/SoSTLFileKit.h>
#include <Inventor/nodes/SoSeparator.h>
# include <QApplication>
#include <QApplication>
#endif
#include <Base/Console.h>
@@ -35,13 +35,12 @@
#include <Base/PyObjectBase.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/WidgetFactory.h>
#include <Gui/Language/Translator.h>
#include <Gui/WidgetFactory.h>
#include "DlgEvaluateMeshImp.h"
#include "DlgSettingsImportExportImp.h"
#include "DlgSettingsMeshView.h"
#include "images.h"
#include "PropertyEditorMesh.h"
#include "SoFCIndexedFaceSet.h"
#include "SoFCMeshObject.h"
@@ -55,6 +54,7 @@
#include "ViewProviderTransform.h"
#include "ViewProviderTransformDemolding.h"
#include "Workbench.h"
#include "images.h"
// use a different name to CreateCommand()
@@ -68,16 +68,16 @@ void loadMeshResource()
Gui::Translator::instance()->refresh();
}
namespace MeshGui {
class Module : public Py::ExtensionModule<Module>
namespace MeshGui
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("MeshGui")
Module()
: Py::ExtensionModule<Module>("MeshGui")
{
add_varargs_method("convertToSTL",&Module::convertToSTL,
"Convert a scene into an STL."
);
initialize("This module is the MeshGui module."); // register with Python
add_varargs_method("convertToSTL", &Module::convertToSTL, "Convert a scene into an STL.");
initialize("This module is the MeshGui module."); // register with Python
}
private:
@@ -85,8 +85,9 @@ private:
{
char* inname;
char* outname;
if (!PyArg_ParseTuple(args.ptr(), "etet","utf-8",&inname,"utf-8",&outname))
if (!PyArg_ParseTuple(args.ptr(), "etet", "utf-8", &inname, "utf-8", &outname)) {
throw Py::Exception();
}
std::string inputName = std::string(inname);
PyMem_Free(inname);
std::string outputName = std::string(outname);
@@ -95,7 +96,7 @@ private:
bool ok = false;
SoInput in;
if (in.openFile(inputName.c_str())) {
SoSeparator * node = SoDB::readAll(&in);
SoSeparator* node = SoDB::readAll(&in);
if (node) {
node->ref();
SoSTLFileKit* stlKit = new SoSTLFileKit();
@@ -116,7 +117,7 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
} // namespace MeshGui
} // namespace MeshGui
/* Python entry */
PyMOD_INIT_FUNC(MeshGui)
@@ -130,7 +131,7 @@ PyMOD_INIT_FUNC(MeshGui)
try {
Base::Interpreter().loadModule("Mesh");
}
catch(const Base::Exception& e) {
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
@@ -147,18 +148,22 @@ PyMOD_INIT_FUNC(MeshGui)
}
// try to instantiate flat-mesh commands
try{
try {
Base::Interpreter().runString("import MeshFlatteningCommand");
} catch (Base::PyException &err){
}
catch (Base::PyException& err) {
err.ReportException();
}
// register preferences pages
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsMeshView> (QT_TRANSLATE_NOOP("QObject", "Display"));
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsImportExport> ( QT_TRANSLATE_NOOP("QObject", "Import-Export") );
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsMeshView>(
QT_TRANSLATE_NOOP("QObject", "Display"));
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsImportExport>(
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
Mesh::Extension3MFFactory::addProducer(new MeshGui::ThumbnailExtensionProducer);
// clang-format off
MeshGui::SoFCMeshObjectElement ::initClass();
MeshGui::SoSFMeshObject ::initClass();
MeshGui::SoFCMeshObjectNode ::initClass();
@@ -197,6 +202,7 @@ PyMOD_INIT_FUNC(MeshGui)
// add resources and reloads the translators
loadMeshResource();
// clang-format on
PyMOD_Return(mod);
}

File diff suppressed because it is too large Load Diff

View File

@@ -41,8 +41,10 @@ DlgDecimating::DlgDecimating(QWidget* parent, Qt::WindowFlags fl)
, ui(new Ui_DlgDecimating)
{
ui->setupUi(this);
connect(ui->checkAbsoluteNumber, &QCheckBox::toggled,
this, &DlgDecimating::onCheckAbsoluteNumberToggled);
connect(ui->checkAbsoluteNumber,
&QCheckBox::toggled,
this,
&DlgDecimating::onCheckAbsoluteNumberToggled);
ui->spinBoxReduction->setMinimumWidth(60);
ui->checkAbsoluteNumber->setEnabled(false);
onCheckAbsoluteNumberToggled(false);
@@ -80,20 +82,33 @@ void DlgDecimating::onCheckAbsoluteNumberToggled(bool on)
ui->groupBoxTolerance->setDisabled(on);
if (on) {
disconnect(ui->sliderReduction, qOverload<int>(&QSlider::valueChanged), ui->spinBoxReduction, &QSpinBox::setValue);
disconnect(ui->spinBoxReduction, qOverload<int>(&QSpinBox::valueChanged), ui->sliderReduction, &QSlider::setValue);
disconnect(ui->sliderReduction,
qOverload<int>(&QSlider::valueChanged),
ui->spinBoxReduction,
&QSpinBox::setValue);
disconnect(ui->spinBoxReduction,
qOverload<int>(&QSpinBox::valueChanged),
ui->sliderReduction,
&QSlider::setValue);
ui->spinBoxReduction->setRange(1, numberOfTriangles);
ui->spinBoxReduction->setValue(numberOfTriangles * (1.0 - reduction()));
ui->spinBoxReduction->setSuffix(QString());
ui->checkAbsoluteNumber->setText(tr("Absolute number (Maximum: %1)").arg(numberOfTriangles));
ui->checkAbsoluteNumber->setText(
tr("Absolute number (Maximum: %1)").arg(numberOfTriangles));
}
else {
ui->spinBoxReduction->setRange(0, 100);
ui->spinBoxReduction->setValue(ui->sliderReduction->value());
ui->spinBoxReduction->setSuffix(QString::fromLatin1("%"));
ui->checkAbsoluteNumber->setText(tr("Absolute number"));
connect(ui->sliderReduction, qOverload<int>(&QSlider::valueChanged), ui->spinBoxReduction, &QSpinBox::setValue);
connect(ui->spinBoxReduction, qOverload<int>(&QSpinBox::valueChanged), ui->sliderReduction, &QSlider::setValue);
connect(ui->sliderReduction,
qOverload<int>(&QSlider::valueChanged),
ui->spinBoxReduction,
&QSpinBox::setValue);
connect(ui->spinBoxReduction,
qOverload<int>(&QSpinBox::valueChanged),
ui->sliderReduction,
&QSlider::setValue);
}
}
@@ -111,7 +126,7 @@ double DlgDecimating::reduction() const
double max = static_cast<double>(ui->sliderReduction->maximum());
double min = static_cast<double>(ui->sliderReduction->minimum());
double val = static_cast<double>(ui->sliderReduction->value());
return (val - min)/(max - min);
return (val - min) / (max - min);
}
// ---------------------------------------
@@ -121,8 +136,8 @@ double DlgDecimating::reduction() const
TaskDecimating::TaskDecimating()
{
widget = new DlgDecimating();
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
QPixmap(), widget->windowTitle(), false, nullptr);
Gui::TaskView::TaskBox* taskbox =
new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);

View File

@@ -24,14 +24,15 @@
#ifndef MESHGUI_DLGDECIMATING_H
#define MESHGUI_DLGDECIMATING_H
#include <QDialog>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <QDialog>
#include <memory>
namespace MeshGui {
namespace MeshGui
{
class Ui_DlgDecimating;
class DlgDecimating : public QWidget
class DlgDecimating: public QWidget
{
Q_OBJECT
@@ -55,7 +56,7 @@ private:
/**
* Embed the panel into a task dialog.
*/
class TaskDecimating : public Gui::TaskView::TaskDialog
class TaskDecimating: public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -66,14 +67,18 @@ public:
bool accept() override;
QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
{
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
}
bool isAllowedAlterDocument() const override
{ return true; }
{
return true;
}
private:
DlgDecimating* widget;
};
}
} // namespace MeshGui
#endif // MESHGUI_DLGDECIMATING_H
#endif // MESHGUI_DLGDECIMATING_H

View File

@@ -22,28 +22,28 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QDockWidget>
# include <QMessageBox>
# include <QPointer>
# include <QScrollArea>
#include <QDockWidget>
#include <QMessageBox>
#include <QPointer>
#include <QScrollArea>
#endif
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/DockWindowManager.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/WaitCursor.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Evaluation.h>
#include <Gui/WaitCursor.h>
#include <Mod/Mesh/App/Core/Degeneration.h>
#include <Mod/Mesh/App/Core/Evaluation.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "DlgEvaluateMeshImp.h"
#include "ui_DlgEvaluateMesh.h"
#include "DlgEvaluateSettings.h"
#include "ViewProviderDefects.h"
#include "ui_DlgEvaluateMesh.h"
using namespace MeshCore;
@@ -51,7 +51,7 @@ using namespace Mesh;
using namespace MeshGui;
CleanupHandler::CleanupHandler()
: QObject(qApp)
: QObject(qApp)
{
// connect to lstWindowClosed signal
connect(qApp, &QApplication::lastWindowClosed, this, &CleanupHandler::cleanup);
@@ -69,9 +69,9 @@ void CleanupHandler::cleanup()
class DlgEvaluateMeshImp::Private
{
public:
Private() : view(nullptr)
{
}
Private()
: view(nullptr)
{}
void showFoldsFunction(bool on)
{
@@ -82,15 +82,15 @@ public:
ui.repairFoldsButton->setVisible(on);
}
Ui_DlgEvaluateMesh ui{};
Ui_DlgEvaluateMesh ui {};
std::map<std::string, ViewProviderMeshDefects*> vp;
Mesh::Feature* meshFeature{nullptr};
Mesh::Feature* meshFeature {nullptr};
QPointer<Gui::View3DInventor> view;
std::vector<Mesh::FacetIndex> self_intersections;
bool enableFoldsCheck{false};
bool checkNonManfoldPoints{false};
bool strictlyDegenerated{true};
float epsilonDegenerated{0.0f};
bool enableFoldsCheck {false};
bool checkNonManfoldPoints {false};
bool strictlyDegenerated {true};
float epsilonDegenerated {0.0f};
};
/* TRANSLATOR MeshGui::DlgEvaluateMeshImp */
@@ -100,7 +100,8 @@ public:
* widget flags set to 'f'.
*/
DlgEvaluateMeshImp::DlgEvaluateMeshImp(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl), d(new Private())
: QDialog(parent, fl)
, d(new Private())
{
d->ui.setupUi(this);
setupConnections();
@@ -122,15 +123,17 @@ DlgEvaluateMeshImp::DlgEvaluateMeshImp(QWidget* parent, Qt::WindowFlags fl)
d->ui.line_8->setFrameShape(QFrame::HLine);
d->ui.line_8->setFrameShadow(QFrame::Sunken);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Mesh/Evaluation");
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh/Evaluation");
d->checkNonManfoldPoints = hGrp->GetBool("CheckNonManifoldPoints", false);
d->enableFoldsCheck = hGrp->GetBool("EnableFoldsCheck", false);
d->strictlyDegenerated = hGrp->GetBool("StrictlyDegenerated", true);
if (d->strictlyDegenerated)
if (d->strictlyDegenerated) {
d->epsilonDegenerated = 0.0f;
else
}
else {
d->epsilonDegenerated = MeshCore::MeshDefinitions::_fMinPointDistanceP2;
}
d->showFoldsFunction(d->enableFoldsCheck);
@@ -148,14 +151,15 @@ DlgEvaluateMeshImp::~DlgEvaluateMeshImp()
{
// no need to delete child widgets, Qt does it all for us
for (const auto& it : d->vp) {
if (d->view)
if (d->view) {
d->view->getViewer()->removeViewProvider(it.second);
}
delete it.second;
}
try {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Mesh/Evaluation");
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh/Evaluation");
hGrp->SetBool("CheckNonManifoldPoints", d->checkNonManfoldPoints);
hGrp->SetBool("EnableFoldsCheck", d->enableFoldsCheck);
hGrp->SetBool("StrictlyDegenerated", d->strictlyDegenerated);
@@ -169,6 +173,7 @@ DlgEvaluateMeshImp::~DlgEvaluateMeshImp()
void DlgEvaluateMeshImp::setupConnections()
{
// clang-format off
connect(d->ui.checkOrientationButton, &QCheckBox::clicked,
this, &DlgEvaluateMeshImp::onCheckOrientationButtonClicked);
connect(d->ui.analyzeOrientationButton, &QPushButton::clicked,
@@ -238,9 +243,10 @@ void DlgEvaluateMeshImp::setupConnections()
this, &DlgEvaluateMeshImp::onButtonBoxClicked);
connect(d->ui.buttonBox, &QDialogButtonBox::helpRequested,
Gui::getMainWindow(), &Gui::MainWindow::whatsThis);
// clang-format on
}
void DlgEvaluateMeshImp::changeEvent(QEvent *e)
void DlgEvaluateMeshImp::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
d->ui.retranslateUi(this);
@@ -280,7 +286,8 @@ void DlgEvaluateMeshImp::slotDeletedObject(const App::DocumentObject& Obj)
}
}
void DlgEvaluateMeshImp::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
void DlgEvaluateMeshImp::slotChangedObject(const App::DocumentObject& Obj,
const App::Property& Prop)
{
// if the current mesh object was modified update everything
if (&Obj == d->meshFeature && Prop.getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) {
@@ -291,12 +298,12 @@ void DlgEvaluateMeshImp::slotChangedObject(const App::DocumentObject& Obj, const
}
else if (Obj.getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) {
// if the label has changed update the entry in the list
if (Prop.getTypeId() == App::PropertyString::getClassTypeId() &&
strcmp(Prop.getName(), "Label") == 0) {
QString label = QString::fromUtf8(Obj.Label.getValue());
QString name = QString::fromLatin1(Obj.getNameInDocument());
int index = d->ui.meshNameButton->findData(name);
d->ui.meshNameButton->setItemText(index, label);
if (Prop.getTypeId() == App::PropertyString::getClassTypeId()
&& strcmp(Prop.getName(), "Label") == 0) {
QString label = QString::fromUtf8(Obj.Label.getValue());
QString name = QString::fromLatin1(Obj.getNameInDocument());
int index = d->ui.meshNameButton->findData(name);
d->ui.meshNameButton->setItemText(index, label);
}
}
}
@@ -321,14 +328,15 @@ void DlgEvaluateMeshImp::slotDeletedDocument(const App::Document& Doc)
void DlgEvaluateMeshImp::setMesh(Mesh::Feature* m)
{
App::Document* doc = m->getDocument();
if (doc != getDocument())
if (doc != getDocument()) {
attachDocument(doc);
}
refreshList();
int ct = d->ui.meshNameButton->count();
QString objName = QString::fromLatin1(m->getNameInDocument());
for (int i=1; i<ct; i++) {
for (int i = 1; i < ct; i++) {
if (d->ui.meshNameButton->itemData(i).toString() == objName) {
d->ui.meshNameButton->setCurrentIndex(i);
onMeshNameButtonActivated(i);
@@ -337,15 +345,17 @@ void DlgEvaluateMeshImp::setMesh(Mesh::Feature* m)
}
}
void DlgEvaluateMeshImp::addViewProvider(const char* name, const std::vector<Mesh::ElementIndex>& indices)
void DlgEvaluateMeshImp::addViewProvider(const char* name,
const std::vector<Mesh::ElementIndex>& indices)
{
removeViewProvider(name);
if (d->view) {
ViewProviderMeshDefects* vp = static_cast<ViewProviderMeshDefects*>(Base::Type::createInstanceByName(name));
ViewProviderMeshDefects* vp =
static_cast<ViewProviderMeshDefects*>(Base::Type::createInstanceByName(name));
assert(vp->getTypeId().isDerivedFrom(Gui::ViewProvider::getClassTypeId()));
vp->attach(d->meshFeature);
d->view->getViewer()->addViewProvider( vp );
d->view->getViewer()->addViewProvider(vp);
vp->showDefects(indices);
d->vp[name] = vp;
}
@@ -355,8 +365,9 @@ void DlgEvaluateMeshImp::removeViewProvider(const char* name)
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find(name);
if (it != d->vp.end()) {
if (d->view)
if (d->view) {
d->view->getViewer()->removeViewProvider(it->second);
}
delete it->second;
d->vp.erase(it);
}
@@ -365,8 +376,9 @@ void DlgEvaluateMeshImp::removeViewProvider(const char* name)
void DlgEvaluateMeshImp::removeViewProviders()
{
for (const auto& it : d->vp) {
if (d->view)
if (d->view) {
d->view->getViewer()->removeViewProvider(it.second);
}
delete it.second;
}
d->vp.clear();
@@ -377,7 +389,8 @@ void DlgEvaluateMeshImp::onMeshNameButtonActivated(int i)
QString item = d->ui.meshNameButton->itemData(i).toString();
d->meshFeature = nullptr;
std::vector<App::DocumentObject*> objs = getDocument()->getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> objs =
getDocument()->getObjectsOfType(Mesh::Feature::getClassTypeId());
for (auto obj : objs) {
if (item == QLatin1String(obj->getNameInDocument())) {
d->meshFeature = static_cast<Mesh::Feature*>(obj);
@@ -385,7 +398,7 @@ void DlgEvaluateMeshImp::onMeshNameButtonActivated(int i)
}
}
if (i== 0) {
if (i == 0) {
cleanInformation();
}
else {
@@ -395,9 +408,10 @@ void DlgEvaluateMeshImp::onMeshNameButtonActivated(int i)
void DlgEvaluateMeshImp::refreshList()
{
QVector<QPair<QString, QString> > items;
QVector<QPair<QString, QString>> items;
if (this->getDocument()) {
std::vector<App::DocumentObject*> objs = this->getDocument()->getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> objs =
this->getDocument()->getObjectsOfType(Mesh::Feature::getClassTypeId());
for (auto obj : objs) {
items.push_back(qMakePair(QString::fromUtf8(obj->Label.getValue()),
QString::fromLatin1(obj->getNameInDocument())));
@@ -406,8 +420,9 @@ void DlgEvaluateMeshImp::refreshList()
d->ui.meshNameButton->clear();
d->ui.meshNameButton->addItem(tr("No selection"));
for (const auto & item : items)
for (const auto& item : items) {
d->ui.meshNameButton->addItem(item.first, item.second);
}
d->ui.meshNameButton->setDisabled(items.empty());
cleanInformation();
}
@@ -434,17 +449,17 @@ void DlgEvaluateMeshImp::showInformation()
void DlgEvaluateMeshImp::cleanInformation()
{
d->ui.textLabel4->setText( tr("No information") );
d->ui.textLabel5->setText( tr("No information") );
d->ui.textLabel6->setText( tr("No information") );
d->ui.checkOrientationButton->setText( tr("No information") );
d->ui.checkDuplicatedFacesButton->setText( tr("No information") );
d->ui.checkDuplicatedPointsButton->setText( tr("No information") );
d->ui.checkNonmanifoldsButton->setText( tr("No information") );
d->ui.checkDegenerationButton->setText( tr("No information") );
d->ui.checkIndicesButton->setText( tr("No information") );
d->ui.checkSelfIntersectionButton->setText( tr("No information") );
d->ui.checkFoldsButton->setText( tr("No information") );
d->ui.textLabel4->setText(tr("No information"));
d->ui.textLabel5->setText(tr("No information"));
d->ui.textLabel6->setText(tr("No information"));
d->ui.checkOrientationButton->setText(tr("No information"));
d->ui.checkDuplicatedFacesButton->setText(tr("No information"));
d->ui.checkDuplicatedPointsButton->setText(tr("No information"));
d->ui.checkNonmanifoldsButton->setText(tr("No information"));
d->ui.checkDegenerationButton->setText(tr("No information"));
d->ui.checkIndicesButton->setText(tr("No information"));
d->ui.checkSelfIntersectionButton->setText(tr("No information"));
d->ui.checkFoldsButton->setText(tr("No information"));
d->ui.analyzeOrientationButton->setDisabled(true);
d->ui.repairOrientationButton->setDisabled(true);
d->ui.analyzeDuplicatedFacesButton->setDisabled(true);
@@ -485,12 +500,15 @@ void DlgEvaluateMeshImp::onRefreshButtonClicked()
void DlgEvaluateMeshImp::onCheckOrientationButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshOrientation");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshOrientation");
if (it != d->vp.end()) {
if (d->ui.checkOrientationButton->isChecked())
if (d->ui.checkOrientationButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -506,17 +524,17 @@ void DlgEvaluateMeshImp::onAnalyzeOrientationButtonClicked()
std::vector<MeshCore::FacetIndex> inds = eval.GetIndices();
if (inds.empty()) {
d->ui.checkOrientationButton->setText( tr("No flipped normals") );
d->ui.checkOrientationButton->setText(tr("No flipped normals"));
d->ui.checkOrientationButton->setChecked(false);
d->ui.repairOrientationButton->setEnabled(false);
removeViewProvider( "MeshGui::ViewProviderMeshOrientation" );
removeViewProvider("MeshGui::ViewProviderMeshOrientation");
}
else {
d->ui.checkOrientationButton->setText( tr("%1 flipped normals").arg(inds.size()) );
d->ui.checkOrientationButton->setText(tr("%1 flipped normals").arg(inds.size()));
d->ui.checkOrientationButton->setChecked(true);
d->ui.repairOrientationButton->setEnabled(true);
d->ui.repairAllTogether->setEnabled(true);
addViewProvider( "MeshGui::ViewProviderMeshOrientation", eval.GetIndices());
addViewProvider("MeshGui::ViewProviderMeshOrientation", eval.GetIndices());
}
qApp->restoreOverrideCursor();
@@ -532,9 +550,10 @@ void DlgEvaluateMeshImp::onRepairOrientationButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Harmonize normals"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()"
, docName, objName);
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()",
docName,
objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Orientation"), QString::fromLatin1(e.what()));
@@ -545,7 +564,7 @@ void DlgEvaluateMeshImp::onRepairOrientationButtonClicked()
d->ui.repairOrientationButton->setEnabled(false);
d->ui.checkOrientationButton->setChecked(false);
removeViewProvider( "MeshGui::ViewProviderMeshOrientation" );
removeViewProvider("MeshGui::ViewProviderMeshOrientation");
}
}
@@ -555,19 +574,23 @@ void DlgEvaluateMeshImp::onCheckNonmanifoldsButtonClicked()
std::map<std::string, ViewProviderMeshDefects*>::iterator it;
it = d->vp.find("MeshGui::ViewProviderMeshNonManifolds");
if (it != d->vp.end()) {
if (d->ui.checkNonmanifoldsButton->isChecked())
if (d->ui.checkNonmanifoldsButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
// non-manifold points
it = d->vp.find("MeshGui::ViewProviderMeshNonManifoldPoints");
if (it != d->vp.end()) {
if (d->ui.checkNonmanifoldsButton->isChecked())
if (d->ui.checkNonmanifoldsButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -587,8 +610,9 @@ void DlgEvaluateMeshImp::onAnalyzeNonmanifoldsButtonClicked()
if (d->checkNonManfoldPoints) {
MeshEvalPointManifolds p_eval(rMesh);
ok2 = p_eval.Evaluate();
if (!ok2)
if (!ok2) {
point_indices = p_eval.GetIndices();
}
}
if (ok1 && ok2) {
@@ -599,16 +623,18 @@ void DlgEvaluateMeshImp::onAnalyzeNonmanifoldsButtonClicked()
removeViewProvider("MeshGui::ViewProviderMeshNonManifoldPoints");
}
else {
d->ui.checkNonmanifoldsButton->setText(tr("%1 non-manifolds").arg(f_eval.CountManifolds()+point_indices.size()));
d->ui.checkNonmanifoldsButton->setText(
tr("%1 non-manifolds").arg(f_eval.CountManifolds() + point_indices.size()));
d->ui.checkNonmanifoldsButton->setChecked(true);
d->ui.repairNonmanifoldsButton->setEnabled(true);
d->ui.repairAllTogether->setEnabled(true);
if (!ok1) {
const std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> >& inds = f_eval.GetIndices();
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<Mesh::FacetIndex, Mesh::FacetIndex> >::const_iterator it;
indices.reserve(2 * inds.size());
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);
@@ -635,14 +661,18 @@ void DlgEvaluateMeshImp::onRepairNonmanifoldsButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove non-manifolds"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()"
, docName, objName);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()",
docName,
objName);
if (d->checkNonManfoldPoints) {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()"
, docName, objName);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()",
docName,
objName);
}
}
catch (const Base::Exception& e) {
@@ -664,12 +694,15 @@ void DlgEvaluateMeshImp::onRepairNonmanifoldsButtonClicked()
void DlgEvaluateMeshImp::onCheckIndicesButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshIndices");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshIndices");
if (it != d->vp.end()) {
if (d->ui.checkIndicesButton->isChecked())
if (d->ui.checkIndicesButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -698,7 +731,7 @@ void DlgEvaluateMeshImp::onAnalyzeIndicesButtonClicked()
d->ui.checkIndicesButton->setChecked(true);
d->ui.repairIndicesButton->setEnabled(true);
d->ui.repairAllTogether->setEnabled(true);
//addViewProvider("MeshGui::ViewProviderMeshIndices", rp.GetIndices());
// addViewProvider("MeshGui::ViewProviderMeshIndices", rp.GetIndices());
}
else if (!cf.Evaluate()) {
d->ui.checkIndicesButton->setText(tr("Multiple point indices"));
@@ -734,9 +767,10 @@ void DlgEvaluateMeshImp::onRepairIndicesButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Fix indices"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").fixIndices()"
, docName, objName);
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").fixIndices()",
docName,
objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Indices"), QString::fromLatin1(e.what()));
@@ -753,12 +787,15 @@ void DlgEvaluateMeshImp::onRepairIndicesButtonClicked()
void DlgEvaluateMeshImp::onCheckDegenerationButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshDegenerations");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshDegenerations");
if (it != d->vp.end()) {
if (d->ui.checkDegenerationButton->isChecked())
if (d->ui.checkDegenerationButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -800,9 +837,12 @@ void DlgEvaluateMeshImp::onRepairDegeneratedButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove degenerated faces"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)"
, docName, objName, d->epsilonDegenerated);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)",
docName,
objName,
d->epsilonDegenerated);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Degenerations"), QString::fromLatin1(e.what()));
@@ -819,12 +859,15 @@ void DlgEvaluateMeshImp::onRepairDegeneratedButtonClicked()
void DlgEvaluateMeshImp::onCheckDuplicatedFacesButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshDuplicatedFaces");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshDuplicatedFaces");
if (it != d->vp.end()) {
if (d->ui.checkDuplicatedFacesButton->isChecked())
if (d->ui.checkDuplicatedFacesButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -867,9 +910,11 @@ void DlgEvaluateMeshImp::onRepairDuplicatedFacesButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove duplicated faces"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()"
, docName, objName);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()",
docName,
objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Duplicated faces"), QString::fromLatin1(e.what()));
@@ -886,12 +931,15 @@ void DlgEvaluateMeshImp::onRepairDuplicatedFacesButtonClicked()
void DlgEvaluateMeshImp::onCheckDuplicatedPointsButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshDuplicatedPoints");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshDuplicatedPoints");
if (it != d->vp.end()) {
if (d->ui.checkDuplicatedPointsButton->isChecked())
if (d->ui.checkDuplicatedPointsButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -932,9 +980,11 @@ void DlgEvaluateMeshImp::onRepairDuplicatedPointsButtonClicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove duplicated points"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()"
, docName, objName);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()",
docName,
objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Duplicated points"), QString::fromLatin1(e.what()));
@@ -951,12 +1001,15 @@ void DlgEvaluateMeshImp::onRepairDuplicatedPointsButtonClicked()
void DlgEvaluateMeshImp::onCheckSelfIntersectionButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshSelfIntersections");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshSelfIntersections");
if (it != d->vp.end()) {
if (d->ui.checkSelfIntersectionButton->isChecked())
if (d->ui.checkSelfIntersectionButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -969,7 +1022,7 @@ void DlgEvaluateMeshImp::onAnalyzeSelfIntersectionButtonClicked()
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
MeshEvalSelfIntersection eval(rMesh);
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> > intersection;
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex>> intersection;
try {
eval.GetIntersections(intersection);
}
@@ -990,8 +1043,8 @@ void DlgEvaluateMeshImp::onAnalyzeSelfIntersectionButtonClicked()
d->ui.repairAllTogether->setEnabled(true);
std::vector<Mesh::FacetIndex> indices;
indices.reserve(2*intersection.size());
std::vector<std::pair<Mesh::FacetIndex, Mesh::FacetIndex> >::iterator it;
indices.reserve(2 * intersection.size());
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);
@@ -1027,12 +1080,15 @@ void DlgEvaluateMeshImp::onRepairSelfIntersectionButtonClicked()
void DlgEvaluateMeshImp::onCheckFoldsButtonClicked()
{
std::map<std::string, ViewProviderMeshDefects*>::iterator it = d->vp.find("MeshGui::ViewProviderMeshFolds");
std::map<std::string, ViewProviderMeshDefects*>::iterator it =
d->vp.find("MeshGui::ViewProviderMeshFolds");
if (it != d->vp.end()) {
if (d->ui.checkFoldsButton->isChecked())
if (d->ui.checkFoldsButton->isChecked()) {
it->second->show();
else
}
else {
it->second->hide();
}
}
}
@@ -1058,7 +1114,7 @@ void DlgEvaluateMeshImp::onAnalyzeFoldsButtonClicked()
removeViewProvider("MeshGui::ViewProviderMeshFolds");
}
else {
std::vector<Mesh::FacetIndex> inds = f_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());
@@ -1089,9 +1145,11 @@ void DlgEvaluateMeshImp::onRepairFoldsButtonClicked()
qApp->setOverrideCursor(Qt::WaitCursor);
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove folds"));
try {
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()"
, docName, objName);
Gui::Command::doCommand(
Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()",
docName,
objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Folds"), QString::fromLatin1(e.what()));
@@ -1123,6 +1181,7 @@ void DlgEvaluateMeshImp::onAnalyzeAllTogetherClicked()
void DlgEvaluateMeshImp::onRepairAllTogetherClicked()
{
// clang-format off
if (d->meshFeature) {
Gui::WaitCursor wc;
const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument());
@@ -1236,6 +1295,7 @@ void DlgEvaluateMeshImp::onRepairAllTogetherClicked()
doc->commitCommand();
doc->getDocument()->recompute();
}
// clang-format on
}
void DlgEvaluateMeshImp::onButtonBoxClicked(QAbstractButton* button)
@@ -1251,10 +1311,12 @@ void DlgEvaluateMeshImp::onButtonBoxClicked(QAbstractButton* button)
d->enableFoldsCheck = dlg.isFoldsChecked();
d->showFoldsFunction(d->enableFoldsCheck);
d->strictlyDegenerated = dlg.isDegeneratedFacetsChecked();
if (d->strictlyDegenerated)
if (d->strictlyDegenerated) {
d->epsilonDegenerated = 0.0f;
else
}
else {
d->epsilonDegenerated = MeshCore::MeshDefinitions::_fMinPointDistanceP2;
}
}
}
else if (type == QDialogButtonBox::Reset) {
@@ -1263,8 +1325,9 @@ void DlgEvaluateMeshImp::onButtonBoxClicked(QAbstractButton* button)
showInformation();
d->self_intersections.clear();
QList<QCheckBox*> cbs = this->findChildren<QCheckBox*>();
Q_FOREACH (QCheckBox *cb, cbs)
Q_FOREACH (QCheckBox* cb, cbs) {
cb->setChecked(false);
}
}
}
@@ -1272,16 +1335,16 @@ void DlgEvaluateMeshImp::onButtonBoxClicked(QAbstractButton* button)
/* TRANSLATOR MeshGui::DockEvaluateMeshImp */
#if 0 // needed for Qt's lupdate utility
#if 0 // needed for Qt's lupdate utility
qApp->translate("QDockWidget", "Evaluate & Repair Mesh");
#endif
DockEvaluateMeshImp* DockEvaluateMeshImp::_instance=nullptr;
DockEvaluateMeshImp* DockEvaluateMeshImp::_instance = nullptr;
DockEvaluateMeshImp* DockEvaluateMeshImp::instance()
{
// not initialized?
if(!_instance) {
if (!_instance) {
_instance = new DockEvaluateMeshImp(Gui::getMainWindow());
_instance->setSizeGripEnabled(false);
}
@@ -1289,10 +1352,10 @@ DockEvaluateMeshImp* DockEvaluateMeshImp::instance()
return _instance;
}
void DockEvaluateMeshImp::destruct ()
void DockEvaluateMeshImp::destruct()
{
if (_instance) {
DockEvaluateMeshImp *pTmp = _instance;
DockEvaluateMeshImp* pTmp = _instance;
_instance = nullptr;
delete pTmp;
}
@@ -1307,8 +1370,8 @@ bool DockEvaluateMeshImp::hasInstance()
* Constructs a DockEvaluateMeshImp which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
DockEvaluateMeshImp::DockEvaluateMeshImp( QWidget* parent, Qt::WindowFlags fl )
: DlgEvaluateMeshImp( parent, fl )
DockEvaluateMeshImp::DockEvaluateMeshImp(QWidget* parent, Qt::WindowFlags fl)
: DlgEvaluateMeshImp(parent, fl)
{
scrollArea = new QScrollArea();
scrollArea->setObjectName(QLatin1String("scrollArea"));
@@ -1320,9 +1383,9 @@ DockEvaluateMeshImp::DockEvaluateMeshImp( QWidget* parent, Qt::WindowFlags fl )
// embed this dialog into a dockable widget container
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
// use Qt macro for preparing for translation stuff (but not translating yet)
QDockWidget* dw = pDockMgr->addDockWindow("Evaluate & Repair Mesh",
scrollArea, Qt::RightDockWidgetArea);
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
QDockWidget* dw =
pDockMgr->addDockWindow("Evaluate & Repair Mesh", scrollArea, Qt::RightDockWidgetArea);
dw->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
dw->show();
}
@@ -1351,10 +1414,9 @@ void DockEvaluateMeshImp::closeEvent(QCloseEvent*)
/**
* Returns an appropriate size hint for the dock window.
*/
QSize DockEvaluateMeshImp::sizeHint () const
QSize DockEvaluateMeshImp::sizeHint() const
{
return {371, 579};
}
#include "moc_DlgEvaluateMeshImp.cpp"

View File

@@ -36,14 +36,17 @@
class QAbstractButton;
class QScrollArea;
namespace Gui {
namespace Gui
{
class View3DInventor;
}
namespace Mesh {
class Feature;
namespace Mesh
{
class Feature;
}
namespace MeshGui {
namespace MeshGui
{
class ViewProviderMeshDefects;
/**
@@ -51,7 +54,7 @@ class ViewProviderMeshDefects;
* module when the application is about to be closed.
* @author Werner Mayer
*/
class CleanupHandler : public QObject
class CleanupHandler: public QObject
{
Q_OBJECT
@@ -65,7 +68,7 @@ private:
/**
* \author Werner Mayer
*/
class DlgEvaluateMeshImp : public QDialog, public App::DocumentObserver
class DlgEvaluateMeshImp: public QDialog, public App::DocumentObserver
{
Q_OBJECT
@@ -123,7 +126,7 @@ private:
void onRefreshButtonClicked();
void onMeshNameButtonActivated(int);
void onButtonBoxClicked(QAbstractButton *);
void onButtonBoxClicked(QAbstractButton*);
protected:
void refreshList();
@@ -132,7 +135,7 @@ protected:
void addViewProvider(const char* vp, const std::vector<Mesh::ElementIndex>& indices);
void removeViewProvider(const char* vp);
void removeViewProviders();
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
class Private;
@@ -143,12 +146,12 @@ private:
* The DockEvaluateMeshImp class creates a single instance and embeds it into a dock window.
* \author Werner Mayer
*/
class DockEvaluateMeshImp : public DlgEvaluateMeshImp
class DockEvaluateMeshImp: public DlgEvaluateMeshImp
{
Q_OBJECT
protected:
explicit DockEvaluateMeshImp( QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
explicit DockEvaluateMeshImp(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
~DockEvaluateMeshImp() override;
void closeEvent(QCloseEvent* e) override;
@@ -157,13 +160,13 @@ public:
static void destruct();
static bool hasInstance();
QSize sizeHint () const override;
QSize sizeHint() const override;
private:
QScrollArea* scrollArea;
static DockEvaluateMeshImp* _instance;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_DLG_EVALUATE_MESH_IMP_H
#endif // MESHGUI_DLG_EVALUATE_MESH_IMP_H

View File

@@ -31,7 +31,8 @@ using namespace MeshGui;
/* TRANSLATOR MeshGui::DlgEvaluateSettings */
DlgEvaluateSettings::DlgEvaluateSettings(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl), ui(new Ui_DlgEvaluateSettings)
: QDialog(parent, fl)
, ui(new Ui_DlgEvaluateSettings)
{
ui->setupUi(this);
}
@@ -72,4 +73,3 @@ bool DlgEvaluateSettings::isDegeneratedFacetsChecked() const
}
#include "moc_DlgEvaluateSettings.cpp"

View File

@@ -26,14 +26,15 @@
#include <QDialog>
namespace MeshGui {
namespace MeshGui
{
class Ui_DlgEvaluateSettings;
/**
* \author Werner Mayer
*/
class DlgEvaluateSettings : public QDialog
class DlgEvaluateSettings: public QDialog
{
Q_OBJECT
@@ -54,6 +55,6 @@ private:
Ui_DlgEvaluateSettings* ui;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_DLG_EVALUATE_SETTINGS_H
#endif // MESHGUI_DLG_EVALUATE_SETTINGS_H

View File

@@ -23,8 +23,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cfloat>
# include <qmessagebox.h>
#include <cfloat>
#include <qmessagebox.h>
#endif
#include <App/Document.h>
@@ -44,6 +44,7 @@ using namespace MeshGui;
/* TRANSLATOR MeshGui::DlgRegularSolidImp */
// clang-format off
DlgRegularSolidImp::DlgRegularSolidImp(QWidget* parent, Qt::WindowFlags fl)
: QDialog( parent, fl )
, ui(new Ui_DlgRegularSolid)
@@ -217,5 +218,6 @@ void DlgRegularSolidImp::onCreateSolidButtonClicked()
QString::fromLatin1(e.what()));
}
}
// clang-format on
#include "moc_DlgRegularSolidImp.cpp"

View File

@@ -27,9 +27,10 @@
#include <QDialog>
#include <memory>
namespace MeshGui {
namespace MeshGui
{
class Ui_DlgRegularSolid;
class DlgRegularSolidImp : public QDialog
class DlgRegularSolidImp: public QDialog
{
Q_OBJECT
@@ -41,12 +42,12 @@ private:
void onCreateSolidButtonClicked();
protected:
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
std::unique_ptr<Ui_DlgRegularSolid> ui;
};
}
} // namespace MeshGui
#endif // MESHGUI_DLGREGULARSOLID_IMP_H
#endif // MESHGUI_DLGREGULARSOLID_IMP_H

View File

@@ -32,7 +32,8 @@
using namespace MeshGui;
DlgSettingsImportExport::DlgSettingsImportExport(QWidget* parent)
: PreferencePage(parent), ui(new Ui_DlgSettingsImportExport)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsImportExport)
{
ui->setupUi(this);
ui->exportAmfCompressed->setToolTip(tr("This parameter indicates whether ZIP compression\n"
@@ -47,8 +48,8 @@ DlgSettingsImportExport::~DlgSettingsImportExport()
void DlgSettingsImportExport::saveSettings()
{
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Mesh");
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh");
double value = ui->maxDeviationExport->value().getValue();
handle->SetFloat("MaxDeviationExport", value);
@@ -65,8 +66,8 @@ void DlgSettingsImportExport::saveSettings()
void DlgSettingsImportExport::loadSettings()
{
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Mesh");
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh");
double value = ui->maxDeviationExport->value().getValue();
value = handle->GetFloat("MaxDeviationExport", value);
ui->maxDeviationExport->setValue(value);
@@ -82,7 +83,7 @@ void DlgSettingsImportExport::loadSettings()
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettingsImportExport::changeEvent(QEvent *e)
void DlgSettingsImportExport::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
@@ -93,4 +94,3 @@ void DlgSettingsImportExport::changeEvent(QEvent *e)
}
#include "moc_DlgSettingsImportExportImp.cpp"

View File

@@ -24,19 +24,20 @@
#define MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
#include <Gui/PropertyPage.h>
namespace MeshGui {
namespace MeshGui
{
class Ui_DlgSettingsImportExport;
/**
* The DlgSettingsImportExportImp class implements a preference page to change settings
* for Importing and Exporting mesh objects.
*/
class DlgSettingsImportExport : public Gui::Dialog::PreferencePage
class DlgSettingsImportExport: public Gui::Dialog::PreferencePage
{
Q_OBJECT
@@ -47,13 +48,12 @@ public:
protected:
void saveSettings() override;
void loadSettings() override;
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
Ui_DlgSettingsImportExport* ui;
}; // end class DlgSettingsImportExport
} // namespace MeshGui
#endif // MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H
} // namespace MeshGui
#endif // MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H

View File

@@ -34,8 +34,8 @@ using namespace MeshGui;
* Constructs a DlgSettingsMeshView which is a child of 'parent'.
*/
DlgSettingsMeshView::DlgSettingsMeshView(QWidget* parent)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsMeshView)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsMeshView)
{
ui->setupUi(this);
ui->labelBackfaceColor->hide();
@@ -64,9 +64,9 @@ void DlgSettingsMeshView::loadSettings()
{
Base::Reference<ParameterGrp> hGrp = Gui::WindowParameter::getDefaultParameter();
hGrp = hGrp->GetGroup("View");
if (!hGrp->GetBool("EnablePreselection",true) &&
!hGrp->GetBool("EnableSelection",true))
if (!hGrp->GetBool("EnablePreselection", true) && !hGrp->GetBool("EnableSelection", true)) {
ui->checkboxBoundbox->setDisabled(true);
}
ui->checkboxRendering->onRestore();
ui->checkboxBoundbox->onRestore();
ui->buttonMeshColor->onRestore();
@@ -81,7 +81,7 @@ void DlgSettingsMeshView::loadSettings()
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettingsMeshView::changeEvent(QEvent *e)
void DlgSettingsMeshView::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);

View File

@@ -24,21 +24,22 @@
#define MESHGUI_DLGSETTINGSMESHVIEW_H
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
#include <memory>
#include <Gui/PropertyPage.h>
namespace MeshGui {
namespace MeshGui
{
class Ui_DlgSettingsMeshView;
/**
* The DlgSettingsMeshView class implements a preference page to change settings
* for display of meshes.
* @author Werner Mayer
*/
class DlgSettingsMeshView : public Gui::Dialog::PreferencePage
class DlgSettingsMeshView: public Gui::Dialog::PreferencePage
{
Q_OBJECT
@@ -49,12 +50,12 @@ public:
protected:
void saveSettings() override;
void loadSettings() override;
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
std::unique_ptr<Ui_DlgSettingsMeshView> ui;
};
} // namespace Gui
} // namespace MeshGui
#endif // MESHGUI_DLGSETTINGSMESHVIEW_H
#endif // MESHGUI_DLGSETTINGSMESHVIEW_H

View File

@@ -22,19 +22,19 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QButtonGroup>
# include <QDialogButtonBox>
#include <QButtonGroup>
#include <QDialogButtonBox>
#endif
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/WaitCursor.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Smoothing.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "DlgSmoothing.h"
#include "ui_DlgSmoothing.h"
#include "Selection.h"
#include "ui_DlgSmoothing.h"
using namespace MeshGui;
@@ -42,8 +42,10 @@ using namespace MeshGui;
/* TRANSLATOR MeshGui::DlgSmoothing */
DlgSmoothing::DlgSmoothing(QWidget* parent)
: QWidget(parent), ui(new Ui_DlgSmoothing())
: QWidget(parent)
, ui(new Ui_DlgSmoothing())
{
// clang-format off
ui->setupUi(this);
bg = new QButtonGroup(this);
bg->addButton(ui->radioButtonTaubin, 0);
@@ -62,6 +64,7 @@ DlgSmoothing::DlgSmoothing(QWidget* parent)
ui->labelLambda->setText(QString::fromUtf8("\xce\xbb"));
ui->labelMu->setText(QString::fromUtf8("\xce\xbc"));
this->resize(this->sizeHint());
// clang-format on
}
/*
@@ -102,10 +105,12 @@ double DlgSmoothing::microStep() const
DlgSmoothing::Smooth DlgSmoothing::method() const
{
if (ui->radioButtonTaubin->isChecked())
if (ui->radioButtonTaubin->isChecked()) {
return DlgSmoothing::Taubin;
else if (ui->radioButtonLaplace->isChecked())
}
else if (ui->radioButtonLaplace->isChecked()) {
return DlgSmoothing::Laplace;
}
return DlgSmoothing::None;
}
@@ -122,19 +127,17 @@ void DlgSmoothing::onCheckBoxSelectionToggled(bool on)
// ------------------------------------------------
SmoothingDialog::SmoothingDialog(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl)
: QDialog(parent, fl)
{
widget = new DlgSmoothing(this);
this->setWindowTitle(widget->windowTitle());
QVBoxLayout* hboxLayout = new QVBoxLayout(this);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
connect(buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
hboxLayout->addWidget(widget);
hboxLayout->addWidget(buttonBox);
@@ -149,28 +152,29 @@ SmoothingDialog::~SmoothingDialog() = default;
TaskSmoothing::TaskSmoothing()
{
widget = new DlgSmoothing();
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
QPixmap(), widget->windowTitle(), false, nullptr);
Gui::TaskView::TaskBox* taskbox =
new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
selection = new Selection();
selection->setObjects(Gui::Selection().getSelectionEx(nullptr, Mesh::Feature::getClassTypeId()));
selection->setObjects(
Gui::Selection().getSelectionEx(nullptr, Mesh::Feature::getClassTypeId()));
Gui::Selection().clearSelection();
Gui::TaskView::TaskBox* tasksel = new Gui::TaskView::TaskBox();
tasksel->groupLayout()->addWidget(selection);
tasksel->hide();
Content.push_back(tasksel);
connect(widget, &DlgSmoothing::toggledSelection,
tasksel, &QWidget::setVisible);
connect(widget, &DlgSmoothing::toggledSelection, tasksel, &QWidget::setVisible);
}
bool TaskSmoothing::accept()
{
std::vector<App::DocumentObject*> meshes = selection->getObjects();
if (meshes.empty())
if (meshes.empty()) {
return true;
}
Gui::WaitCursor wc;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Smoothing"));
@@ -186,44 +190,42 @@ bool TaskSmoothing::accept()
mm->getFacetsFromSelection(selection);
selection = mm->getPointsFromFacets(selection);
mm->clearFacetSelection();
if (!selection.empty())
if (!selection.empty()) {
hasSelection = true;
}
}
Mesh::MeshObject* mm = mesh->Mesh.startEditing();
switch (widget->method()) {
case MeshGui::DlgSmoothing::Taubin:
{
MeshCore::TaubinSmoothing s(mm->getKernel());
s.SetLambda(widget->lambdaStep());
s.SetMicro(widget->microStep());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
case MeshGui::DlgSmoothing::Laplace:
{
MeshCore::LaplaceSmoothing s(mm->getKernel());
s.SetLambda(widget->lambdaStep());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
case MeshGui::DlgSmoothing::MedianFilter:
{
MeshCore::MedianFilterSmoothing s(mm->getKernel());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
case MeshGui::DlgSmoothing::Taubin: {
MeshCore::TaubinSmoothing s(mm->getKernel());
s.SetLambda(widget->lambdaStep());
s.SetMicro(widget->microStep());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
case MeshGui::DlgSmoothing::Laplace: {
MeshCore::LaplaceSmoothing s(mm->getKernel());
s.SetLambda(widget->lambdaStep());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
case MeshGui::DlgSmoothing::MedianFilter: {
MeshCore::MedianFilterSmoothing s(mm->getKernel());
if (widget->smoothSelection()) {
s.SmoothPoints(widget->iterations(), selection);
}
else {
s.Smooth(widget->iterations());
}
} break;
default:
break;
}

View File

@@ -24,25 +24,27 @@
#ifndef MESHGUI_DLGSMOOTHING_H
#define MESHGUI_DLGSMOOTHING_H
#include <QDialog>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <QDialog>
#ifndef MESH_GLOBAL_H
#include <Mod/Mesh/MeshGlobal.h>
#endif
class QButtonGroup;
namespace MeshGui {
namespace MeshGui
{
class Selection;
class Ui_DlgSmoothing;
class DlgSmoothing : public QWidget
class DlgSmoothing: public QWidget
{
Q_OBJECT
public:
enum Smooth {
enum Smooth
{
None,
Taubin,
Laplace,
@@ -72,7 +74,7 @@ private:
/**
* Embed the panel into a dialog.
*/
class MeshGuiExport SmoothingDialog : public QDialog
class MeshGuiExport SmoothingDialog: public QDialog
{
Q_OBJECT
@@ -81,15 +83,25 @@ public:
~SmoothingDialog() override;
int iterations() const
{ return widget->iterations(); }
{
return widget->iterations();
}
double lambdaStep() const
{ return widget->lambdaStep(); }
{
return widget->lambdaStep();
}
double microStep() const
{ return widget->microStep(); }
{
return widget->microStep();
}
DlgSmoothing::Smooth method() const
{ return widget->method(); }
{
return widget->method();
}
bool smoothSelection() const
{ return widget->smoothSelection(); }
{
return widget->smoothSelection();
}
private:
DlgSmoothing* widget;
@@ -98,7 +110,7 @@ private:
/**
* Embed the panel into a task dialog.
*/
class TaskSmoothing : public Gui::TaskView::TaskDialog
class TaskSmoothing: public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -109,15 +121,19 @@ public:
bool accept() override;
QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
{
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
}
bool isAllowedAlterDocument() const override
{ return true; }
{
return true;
}
private:
DlgSmoothing* widget;
Selection* selection;
};
}
} // namespace MeshGui
#endif // MESHGUI_DLGSMOOTHING_H
#endif // MESHGUI_DLGSMOOTHING_H

View File

@@ -26,9 +26,9 @@
\brief The namespace of the Mesh Graphical interface layer library
This namespace includes the graphical interface of FreeCAD such as:
- The main window
- 3D View
- Tree
- The main window
- 3D View
- Tree
and so on......
*/

View File

@@ -23,27 +23,27 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <algorithm>
# include <functional>
# include <QMenu>
# include <QTimer>
#include <QMenu>
#include <QTimer>
#include <algorithm>
#include <functional>
# include <Inventor/SbLine.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/events/SoKeyboardEvent.h>
# include <Inventor/events/SoLocation2Event.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoBaseColor.h>
# include <Inventor/nodes/SoCamera.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDirectionalLight.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoFaceSet.h>
# include <Inventor/nodes/SoPickStyle.h>
# include <Inventor/nodes/SoPointSet.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoShapeHints.h>
#include <Inventor/SbLine.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/events/SoKeyboardEvent.h>
#include <Inventor/events/SoLocation2Event.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCamera.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoFaceSet.h>
#include <Inventor/nodes/SoPickStyle.h>
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoShapeHints.h>
#endif
#include <App/Application.h>
@@ -51,8 +51,8 @@
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/WaitCursor.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Algorithm.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "MeshEditor.h"
#include "SoFCMeshObject.h"
@@ -64,7 +64,9 @@ namespace sp = std::placeholders;
PROPERTY_SOURCE(MeshGui::ViewProviderFace, Gui::ViewProviderDocumentObject)
ViewProviderFace::ViewProviderFace() : mesh(nullptr), current_index(-1)
ViewProviderFace::ViewProviderFace()
: mesh(nullptr)
, current_index(-1)
{
pcCoords = new SoCoordinate3();
pcCoords->ref();
@@ -95,7 +97,7 @@ void ViewProviderFace::attach(App::DocumentObject* obj)
pointStyle->pointSize = 8.0f;
markers->addChild(pointStyle);
SoBaseColor * markcol = new SoBaseColor;
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoPointSet* marker = new SoPointSet();
markers->addChild(markcol);
@@ -108,9 +110,9 @@ void ViewProviderFace::attach(App::DocumentObject* obj)
faceStyle->style = SoDrawStyle::FILLED;
faces->addChild(faceStyle);
SoShapeHints * flathints = new SoShapeHints;
//flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
//flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
SoShapeHints* flathints = new SoShapeHints;
// flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
// flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
faces->addChild(flathints);
SoBaseColor* basecol = new SoBaseColor;
@@ -137,10 +139,12 @@ void ViewProviderFace::attach(App::DocumentObject* obj)
void ViewProviderFace::setDisplayMode(const char* ModeName)
{
if (strcmp(ModeName, "Face") == 0)
if (strcmp(ModeName, "Face") == 0) {
setDisplayMaskMode("Face");
else if (strcmp(ModeName, "Marker") == 0)
}
else if (strcmp(ModeName, "Marker") == 0) {
setDisplayMaskMode("Marker");
}
ViewProviderDocumentObject::setDisplayMode(ModeName);
}
@@ -157,7 +161,8 @@ std::vector<std::string> ViewProviderFace::getDisplayModes() const
return modes;
}
SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const
SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos,
const Gui::View3DInventorViewer* viewer) const
{
SoSeparator* root = new SoSeparator;
root->ref();
@@ -172,7 +177,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 ? pick->copy() : 0); // needs the same instance of CRT under MS Windows
return (pick ? new SoPickedPoint(*pick) : nullptr);
}
@@ -181,9 +186,9 @@ SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const Gui::V
/* TRANSLATOR MeshGui::MeshFaceAddition */
MeshFaceAddition::MeshFaceAddition(Gui::View3DInventor* parent)
: QObject(parent), faceView(new MeshGui::ViewProviderFace())
{
}
: QObject(parent)
, faceView(new MeshGui::ViewProviderFace())
{}
MeshFaceAddition::~MeshFaceAddition()
{
@@ -202,9 +207,8 @@ void MeshFaceAddition::startEditing(MeshGui::ViewProviderMesh* vp)
faceView->mesh = vp;
faceView->attach(vp->getObject());
viewer->addViewProvider(faceView);
//faceView->mesh->startEditing();
viewer->addEventCallback(SoEvent::getClassTypeId(),
MeshFaceAddition::addFacetCallback, this);
// faceView->mesh->startEditing();
viewer->addEventCallback(SoEvent::getClassTypeId(), MeshFaceAddition::addFacetCallback, this);
}
void MeshFaceAddition::finishEditing()
@@ -217,9 +221,10 @@ void MeshFaceAddition::finishEditing()
viewer->setRedirectToSceneGraphEnabled(false);
viewer->removeViewProvider(faceView);
//faceView->mesh->finishEditing();
// faceView->mesh->finishEditing();
viewer->removeEventCallback(SoEvent::getClassTypeId(),
MeshFaceAddition::addFacetCallback, this);
MeshFaceAddition::addFacetCallback,
this);
this->deleteLater();
}
@@ -252,8 +257,9 @@ void MeshFaceAddition::clearPoints()
void MeshFaceAddition::flipNormal()
{
if (faceView->index.size() < 3)
if (faceView->index.size() < 3) {
return;
}
std::swap(faceView->index[0], faceView->index[1]);
SbVec3f v1 = faceView->pcCoords->point[0];
SbVec3f v2 = faceView->pcCoords->point[1];
@@ -263,14 +269,17 @@ void MeshFaceAddition::flipNormal()
bool MeshFaceAddition::addMarkerPoint()
{
if (faceView->current_index < 0)
if (faceView->current_index < 0) {
return false;
if (faceView->index.size() >= 3)
}
if (faceView->index.size() >= 3) {
return false;
}
faceView->index.push_back(faceView->current_index);
faceView->current_index = -1;
if (faceView->index.size() == 3)
if (faceView->index.size() == 3) {
faceView->setDisplayMode("Face");
}
return true;
}
@@ -282,17 +291,20 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
if (detail->isOfType(SoFaceDetail::getClassTypeId())) {
const SoFaceDetail* fd = static_cast<const SoFaceDetail*>(detail);
Mesh::Feature* mf = static_cast<Mesh::Feature*>(faceView->mesh->getObject());
const MeshCore::MeshFacetArray& facets = mf->Mesh.getValuePtr()->getKernel().GetFacets();
const MeshCore::MeshPointArray& points = mf->Mesh.getValuePtr()->getKernel().GetPoints();
const MeshCore::MeshFacetArray& facets =
mf->Mesh.getValuePtr()->getKernel().GetFacets();
const MeshCore::MeshPointArray& points =
mf->Mesh.getValuePtr()->getKernel().GetPoints();
// is the face index valid?
int face_index = fd->getFaceIndex();
if (face_index >= (int)facets.size())
if (face_index >= (int)facets.size()) {
return;
}
// is a border facet picked?
MeshCore::MeshFacet f = facets[face_index];
if (!f.HasOpenEdge()) {
// check if a neighbour facet is at the border
bool ok=false;
bool ok = false;
for (Mesh::FacetIndex nbIndex : f._aulNeighbours) {
if (facets[nbIndex].HasOpenEdge()) {
f = facets[nbIndex];
@@ -300,8 +312,9 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
break;
}
}
if (!ok)
if (!ok) {
return;
}
}
int point_index = -1;
@@ -309,28 +322,31 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
Base::Vector3f pnt;
SbVec3f face_pnt;
for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
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] == MeshCore::FACET_INDEX_MAX ||
f._aulNeighbours[(i+2)%3] == MeshCore::FACET_INDEX_MAX) {
if (std::find(faceView->index.begin(), faceView->index.end(), index)
!= faceView->index.end()) {
continue; // already inside
}
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]));
float len = Base::DistanceP2(pnt, Base::Vector3f(vec[0], vec[1], vec[2]));
if (len < distance) {
distance = len;
point_index = index;
face_pnt.setValue(pnt.x,pnt.y,pnt.z);
face_pnt.setValue(pnt.x, pnt.y, pnt.z);
}
}
}
if (point_index < 0)
return; // picked point is rejected
if (point_index < 0) {
return; // picked point is rejected
}
int num = faceView->pcCoords->point.getNum();
if (faceView->current_index >= 0) {
num = std::max<int>(num-1, 0);
num = std::max<int>(num - 1, 0);
}
faceView->current_index = point_index;
faceView->pcCoords->point.set1Value(num, face_pnt);
@@ -339,11 +355,11 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
}
}
void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
void MeshFaceAddition::addFacetCallback(void* ud, SoEventCallback* n)
{
MeshFaceAddition* that = static_cast<MeshFaceAddition*>(ud);
ViewProviderFace* face = that->faceView;
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
ViewProviderFace* face = that->faceView;
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
// If we are in navigation mode then ignore all but key events
@@ -355,7 +371,7 @@ void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
if (ev->getTypeId() == SoLocation2Event::getClassTypeId()) {
n->setHandled();
if (face->index.size() < 3) {
SoPickedPoint * point = face->getPickedPoint(ev->getPosition(), view);
SoPickedPoint* point = face->getPickedPoint(ev->getPosition(), view);
if (point) {
that->showMarker(point);
delete point;
@@ -363,16 +379,18 @@ void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
}
}
else if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 ||
mbe->getButton() == SoMouseButtonEvent::BUTTON2 ||
mbe->getButton() == SoMouseButtonEvent::BUTTON3) {
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
|| mbe->getButton() == SoMouseButtonEvent::BUTTON2
|| mbe->getButton() == SoMouseButtonEvent::BUTTON3) {
n->setHandled();
}
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
&& mbe->getState() == SoButtonEvent::DOWN) {
that->addMarkerPoint();
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
&& mbe->getState() == SoButtonEvent::UP) {
if (face->index.size() == 3) {
QMenu menu;
QAction* add = menu.addAction(MeshFaceAddition::tr("Add triangle"));
@@ -390,7 +408,8 @@ void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
}
}
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2
&& mbe->getState() == SoButtonEvent::UP) {
QMenu menu;
QAction* fin = menu.addAction(MeshFaceAddition::tr("Finish"));
QAction* act = menu.exec(QCursor::pos());
@@ -401,9 +420,8 @@ void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
}
// toggle between edit and navigation mode
else if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const ke = static_cast<const SoKeyboardEvent *>(ev);
if (ke->getState() == SoButtonEvent::DOWN &&
ke->getKey() == SoKeyboardEvent::ESCAPE) {
const SoKeyboardEvent* const ke = static_cast<const SoKeyboardEvent*>(ev);
if (ke->getState() == SoButtonEvent::DOWN && ke->getKey() == SoKeyboardEvent::ESCAPE) {
SbBool toggle = view->isRedirectedToSceneGraph();
view->setRedirectToSceneGraph(!toggle);
n->setHandled();
@@ -413,27 +431,28 @@ void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
// ----------------------------------------------------------------------
namespace MeshGui {
// for sorting of elements
struct NofFacetsCompare
namespace MeshGui
{
// for sorting of elements
struct NofFacetsCompare
{
bool operator()(const std::vector<Mesh::PointIndex>& rclC1,
const std::vector<Mesh::PointIndex>& rclC2)
{
bool operator () (const std::vector<Mesh::PointIndex> &rclC1,
const std::vector<Mesh::PointIndex> &rclC2)
{
return rclC1.size() < rclC2.size();
}
};
}
return rclC1.size() < rclC2.size();
}
};
} // namespace MeshGui
/* TRANSLATOR MeshGui::MeshFillHole */
MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent)
: QObject(parent)
, myMesh(nullptr)
, myNumPoints(0)
, myVertex1(0)
, myVertex2(0)
, myHoleFiller(hf)
: QObject(parent)
, myMesh(nullptr)
, myNumPoints(0)
, myVertex1(0)
, myVertex2(0)
, myHoleFiller(hf)
{
myBoundariesRoot = new SoSeparator;
myBoundariesRoot->ref();
@@ -449,7 +468,7 @@ MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent)
pointStyle->pointSize = 8.0f;
myBridgeRoot->addChild(pointStyle);
SoBaseColor * markcol = new SoBaseColor;
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
myBridgeRoot->addChild(markcol);
@@ -473,13 +492,12 @@ void MeshFillHole::startEditing(MeshGui::ViewProviderMesh* vp)
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(parent());
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
//viewer->setRedirectToSceneGraph(true);
viewer->addEventCallback(SoEvent::getClassTypeId(),
MeshFillHole::fileHoleCallback, this);
//NOLINTBEGIN
// viewer->setRedirectToSceneGraph(true);
viewer->addEventCallback(SoEvent::getClassTypeId(), MeshFillHole::fileHoleCallback, this);
// NOLINTBEGIN
myConnection = App::GetApplication().signalChangedObject.connect(
std::bind(&MeshFillHole::slotChangedObject, this, sp::_1, sp::_2));
//NOLINTEND
// NOLINTEND
Gui::coinRemoveAllChildren(myBoundariesRoot);
myBoundariesRoot->addChild(viewer->getHeadlight());
@@ -497,9 +515,8 @@ void MeshFillHole::finishEditing()
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(parent());
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(false);
//viewer->setRedirectToSceneGraph(false);
viewer->removeEventCallback(SoEvent::getClassTypeId(),
MeshFillHole::fileHoleCallback, this);
// viewer->setRedirectToSceneGraph(false);
viewer->removeEventCallback(SoEvent::getClassTypeId(), MeshFillHole::fileHoleCallback, this);
myConnection.disconnect();
this->deleteLater();
static_cast<SoGroup*>(viewer->getSceneGraph())->removeChild(myBridgeRoot);
@@ -513,8 +530,9 @@ void MeshFillHole::closeBridge()
TBoundary::iterator jt = std::find(myPolygon.begin(), myPolygon.end(), myVertex2);
if (it != myPolygon.end() && jt != myPolygon.end()) {
// which iterator comes first
if (jt < it)
if (jt < it) {
std::swap(it, jt);
}
// split the boundary into two loops and take the shorter one
std::list<TBoundary> bounds;
TBoundary loop1, loop2;
@@ -522,28 +540,33 @@ void MeshFillHole::closeBridge()
loop1.insert(loop1.end(), jt, myPolygon.end());
loop2.insert(loop2.end(), it, jt);
// this happens when myVertex1 == myVertex2
if (loop2.empty())
if (loop2.empty()) {
bounds.push_back(loop1);
else if (loop1.size() < loop2.size())
}
else if (loop1.size() < loop2.size()) {
bounds.push_back(loop1);
else
}
else {
bounds.push_back(loop2);
}
App::Document* doc = myMesh->getDocument();
doc->openTransaction("Bridge && Fill hole");
Mesh::MeshObject* pMesh = myMesh->Mesh.startEditing();
bool ok = myHoleFiller.fillHoles(*pMesh, bounds, myVertex1, myVertex2);
myMesh->Mesh.finishEditing();
if (ok)
if (ok) {
doc->commitTransaction();
else
}
else {
doc->abortTransaction();
}
}
}
void MeshFillHole::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
if (&Obj == myMesh && strcmp(Prop.getName(),"Mesh") == 0) {
if (&Obj == myMesh && strcmp(Prop.getName(), "Mesh") == 0) {
Gui::coinRemoveAllChildren(myBoundariesGroup);
myVertex->point.setNum(0);
myNumPoints = 0;
@@ -564,10 +587,10 @@ void MeshFillHole::createPolygons()
myBoundaryRoot->addChild(pickStyle);
// get mesh kernel
const MeshCore::MeshKernel & rMesh = this->myMesh->Mesh.getValue().getKernel();
const MeshCore::MeshKernel& rMesh = this->myMesh->Mesh.getValue().getKernel();
// get the mesh boundaries as an array of point indices
std::list<std::vector<Mesh::PointIndex> > borders;
std::list<std::vector<Mesh::PointIndex>> borders;
MeshCore::MeshAlgorithm cAlgo(rMesh);
MeshCore::MeshPointIterator p_iter(rMesh);
cAlgo.GetMeshBorders(borders);
@@ -576,10 +599,11 @@ void MeshFillHole::createPolygons()
// sort the borders in ascending order of the number of edges
borders.sort(NofFacetsCompare());
int32_t count=0;
for (auto & border : borders) {
if (border.front() == border.back())
int32_t count = 0;
for (auto& border : borders) {
if (border.front() == border.back()) {
border.pop_back();
}
count += border.size();
}
@@ -589,7 +613,7 @@ void MeshFillHole::createPolygons()
coords->point.setNum(count);
int32_t index = 0;
for (const auto & border : borders) {
for (const auto& border : borders) {
SoPolygon* polygon = new SoPolygon();
polygon->startIndex = index;
polygon->numVertices = border.size();
@@ -597,18 +621,20 @@ void MeshFillHole::createPolygons()
myPolygons[polygon] = border;
for (Mesh::PointIndex jt : border) {
p_iter.Set(jt);
coords->point.set1Value(index++,p_iter->x,p_iter->y,p_iter->z);
coords->point.set1Value(index++, p_iter->x, p_iter->y, p_iter->z);
}
}
}
SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* root, const SbVec2s& pos*/) const
SoNode* MeshFillHole::getPickedPolygon(
const SoRayPickAction& action /*SoNode* root, const SbVec2s& pos*/) const
{
SoPolygon* poly = nullptr;
const SoPickedPointList & points = action.getPickedPointList();
for (int i=0; i < points.getLength(); i++) {
const SoPickedPoint * point = points[i];
if (point && point->getPath()->getTail()->getTypeId() == MeshGui::SoPolygon::getClassTypeId()) {
const SoPickedPointList& points = action.getPickedPointList();
for (int i = 0; i < points.getLength(); i++) {
const SoPickedPoint* point = points[i];
if (point
&& point->getPath()->getTail()->getTypeId() == MeshGui::SoPolygon::getClassTypeId()) {
// we have something picked, now check if it was an SoPolygon node
SoPolygon* node = static_cast<SoPolygon*>(point->getPath()->getTail());
if (!poly) {
@@ -624,21 +650,23 @@ SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* ro
return poly;
}
float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon,
Mesh::PointIndex& vertex_index, SbVec3f& closestPoint) const
float MeshFillHole::findClosestPoint(const SbLine& ray,
const TBoundary& polygon,
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 = MeshCore::POINT_INDEX_MAX;
const MeshCore::MeshKernel & rMesh = myMesh->Mesh.getValue().getKernel();
const MeshCore::MeshKernel& rMesh = myMesh->Mesh.getValue().getKernel();
const MeshCore::MeshPointArray& pts = rMesh.GetPoints();
for (Mesh::PointIndex it : polygon) {
SbVec3f vertex;
const Base::Vector3f& v = pts[it];
vertex.setValue(v.x,v.y,v.z);
vertex.setValue(v.x, v.y, v.z);
SbVec3f point = ray.getClosestPoint(vertex);
float distance = (vertex-point).sqrLength();
float distance = (vertex - point).sqrLength();
if (distance < minDist) {
minDist = distance;
vertex_index = it;
@@ -649,10 +677,10 @@ float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon
return minDist;
}
void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
void MeshFillHole::fileHoleCallback(void* ud, SoEventCallback* n)
{
MeshFillHole* self = static_cast<MeshFillHole*>(ud);
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
if (ev->getTypeId() == SoLocation2Event::getClassTypeId()) {
@@ -660,10 +688,12 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
SoRayPickAction rp(view->getSoRenderManager()->getViewportRegion());
rp.setPoint(ev->getPosition());
rp.setPickAll(true);
if (self->myNumPoints == 0)
if (self->myNumPoints == 0) {
rp.apply(self->myBoundariesRoot);
else
}
else {
rp.apply(self->myBoundaryRoot);
}
SoNode* node = self->getPickedPolygon(rp);
if (node) {
std::map<SoNode*, TBoundary>::iterator it = self->myPolygons.find(node);
@@ -671,29 +701,36 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
// now check which vertex of the polygon is closest to the ray
Mesh::PointIndex vertex_index;
SbVec3f closestPoint;
float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint);
float minDist =
self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint);
if (minDist < 1.0f) {
if (self->myNumPoints == 0)
if (self->myNumPoints == 0) {
self->myVertex->point.set1Value(0, closestPoint);
else
}
else {
self->myVertex->point.set1Value(1, closestPoint);
}
}
}
}
}
else if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
n->setHandled();
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
if (self->myNumPoints > 1)
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
&& mbe->getState() == SoButtonEvent::UP) {
if (self->myNumPoints > 1) {
return;
}
SoRayPickAction rp(view->getSoRenderManager()->getViewportRegion());
rp.setPoint(ev->getPosition());
rp.setPickAll(true);
if (self->myNumPoints == 0)
if (self->myNumPoints == 0) {
rp.apply(self->myBoundariesRoot);
else
}
else {
rp.apply(self->myBoundaryRoot);
}
SoNode* node = self->getPickedPolygon(rp);
if (node) {
std::map<SoNode*, TBoundary>::iterator it = self->myPolygons.find(node);
@@ -701,7 +738,10 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
// now check which vertex of the polygon is closest to the ray
Mesh::PointIndex vertex_index;
SbVec3f closestPoint;
float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint);
float minDist = self->findClosestPoint(rp.getLine(),
it->second,
vertex_index,
closestPoint);
if (minDist < 1.0f) {
if (self->myNumPoints == 0) {
self->myBoundaryRoot->addChild(node);
@@ -722,7 +762,8 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
}
}
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2
&& mbe->getState() == SoButtonEvent::UP) {
QMenu menu;
QAction* fin = menu.addAction(MeshFillHole::tr("Finish"));
QAction* act = menu.exec(QCursor::pos());

View File

@@ -38,16 +38,27 @@ class SoRayPickAction;
class SbLine;
class SbVec3f;
namespace Gui { class View3DInventor; class View3DInventorViewer;}
namespace Mesh { class MeshObject; }
namespace Mesh { class Feature; }
namespace MeshGui {
namespace Gui
{
class View3DInventor;
class View3DInventorViewer;
} // namespace Gui
namespace Mesh
{
class MeshObject;
}
namespace Mesh
{
class Feature;
}
namespace MeshGui
{
class SoFCMeshPickNode;
/** The ViewProviderFace class is used to display a single face.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderFace : public Gui::ViewProviderDocumentObject
class MeshGuiExport ViewProviderFace: public Gui::ViewProviderDocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderFace);
@@ -60,14 +71,15 @@ public:
void setDisplayMode(const char* ModeName) override;
const char* getDefaultDisplayMode() const override;
std::vector<std::string> getDisplayModes() const override;
SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const;
SoPickedPoint* getPickedPoint(const SbVec2s& pos,
const Gui::View3DInventorViewer* viewer) const;
ViewProviderMesh* mesh;
std::vector<int> index;
int current_index;
SoCoordinate3 * pcCoords;
SoFaceSet * pcFaces;
SoCoordinate3* pcCoords;
SoFaceSet* pcFaces;
SoFCMeshPickNode* pcMeshPick;
};
@@ -75,7 +87,7 @@ public:
* Display data of a mesh kernel.
* \author Werner Mayer
*/
class MeshGuiExport MeshFaceAddition : public QObject
class MeshGuiExport MeshFaceAddition: public QObject
{
Q_OBJECT
@@ -96,7 +108,7 @@ private Q_SLOTS:
private:
bool addMarkerPoint();
void showMarker(SoPickedPoint*);
static void addFacetCallback(void * ud, SoEventCallback * n);
static void addFacetCallback(void* ud, SoEventCallback* n);
private:
ViewProviderFace* faceView;
@@ -109,10 +121,12 @@ public:
virtual ~MeshHoleFiller() = default;
MeshHoleFiller(const MeshHoleFiller&) = delete;
MeshHoleFiller(MeshHoleFiller&&) = delete;
MeshHoleFiller& operator = (const MeshHoleFiller&) = delete;
MeshHoleFiller& operator = (MeshHoleFiller&&) = delete;
virtual bool fillHoles(Mesh::MeshObject&, const std::list<std::vector<Mesh::PointIndex> >&,
Mesh::PointIndex, Mesh::PointIndex)
MeshHoleFiller& operator=(const MeshHoleFiller&) = delete;
MeshHoleFiller& operator=(MeshHoleFiller&&) = delete;
virtual bool fillHoles(Mesh::MeshObject&,
const std::list<std::vector<Mesh::PointIndex>>&,
Mesh::PointIndex,
Mesh::PointIndex)
{
return false;
}
@@ -122,7 +136,7 @@ public:
* Display data of a mesh kernel.
* \author Werner Mayer
*/
class MeshGuiExport MeshFillHole : public QObject
class MeshGuiExport MeshFillHole: public QObject
{
Q_OBJECT
@@ -142,11 +156,13 @@ private:
using TBoundary = std::vector<Mesh::PointIndex>;
using Connection = boost::signals2::connection;
static void fileHoleCallback(void * ud, SoEventCallback * n);
static void fileHoleCallback(void* ud, SoEventCallback* n);
void createPolygons();
SoNode* getPickedPolygon(const SoRayPickAction& action) const;
float findClosestPoint(const SbLine& ray, const TBoundary& polygon,
Mesh::PointIndex&, SbVec3f&) const;
float findClosestPoint(const SbLine& ray,
const TBoundary& polygon,
Mesh::PointIndex&,
SbVec3f&) const;
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop);
private:
@@ -165,8 +181,7 @@ private:
Connection myConnection;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_MESHEDITOR_H
#endif // MESHGUI_MESHEDITOR_H

View File

@@ -22,15 +22,15 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <algorithm>
# include <climits>
# include <QBitmap>
#include <QBitmap>
#include <algorithm>
#include <climits>
# include <Inventor/SbBox2s.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCamera.h>
#include <Inventor/SbBox2s.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoCamera.h>
#endif
#include <App/Application.h>
@@ -44,10 +44,10 @@
#include <Gui/Utilities.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/TopoAlgorithm.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "MeshSelection.h"
#include "ViewProvider.h"
@@ -60,19 +60,19 @@ using namespace MeshGui;
#define CROSS_HOT_X 7
#define CROSS_HOT_Y 7
// clang-format off
unsigned char MeshSelection::cross_bitmap[] = {
0xc0, 0x03, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x7f, 0xfe, 0x01, 0x80,
0x01, 0x80, 0x7f, 0xfe, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0xc0, 0x03
};
0xc0, 0x03, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x7f, 0xfe, 0x01, 0x80,
0x01, 0x80, 0x7f, 0xfe, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0xc0, 0x03};
unsigned char MeshSelection::cross_mask_bitmap[] = {
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03
};
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03};
// clang-format on
MeshSelection::MeshSelection()
{
@@ -83,8 +83,9 @@ MeshSelection::~MeshSelection()
{
if (this->activeCB) {
Gui::View3DInventorViewer* viewer = this->getViewer();
if (viewer)
if (viewer) {
stopInteractiveCallback(viewer);
}
}
}
@@ -96,7 +97,7 @@ void MeshSelection::setEnabledViewerSelection(bool on)
}
}
void MeshSelection::setCallback(SoEventCallbackCB *cb)
void MeshSelection::setCallback(SoEventCallbackCB* cb)
{
selectionCB = cb;
}
@@ -120,8 +121,9 @@ std::vector<App::DocumentObject*> MeshSelection::getObjects() const
// get all objects of the active document
else {
App::Document* doc = App::GetApplication().getActiveDocument();
if (doc)
if (doc) {
objs = doc->getObjectsOfType(Mesh::Feature::getClassTypeId());
}
}
return objs;
@@ -134,8 +136,9 @@ std::list<ViewProviderMesh*> MeshSelection::getViewProviders() const
for (auto obj : objs) {
if (obj->isDerivedFrom(Mesh::Feature::getClassTypeId())) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
if (vp->isVisible())
if (vp->isVisible()) {
vps.push_back(static_cast<ViewProviderMesh*>(vp));
}
}
}
@@ -150,12 +153,14 @@ void MeshSelection::setViewer(Gui::View3DInventorViewer* v)
Gui::View3DInventorViewer* MeshSelection::getViewer() const
{
// if a special viewer was set from outside then use this
if (ivViewer)
if (ivViewer) {
return ivViewer;
}
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc)
if (!doc) {
return nullptr;
}
Gui::MDIView* view = doc->getActiveView();
if (view && view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
@@ -165,10 +170,12 @@ Gui::View3DInventorViewer* MeshSelection::getViewer() const
return nullptr;
}
void MeshSelection::startInteractiveCallback(Gui::View3DInventorViewer* viewer,SoEventCallbackCB *cb)
void MeshSelection::startInteractiveCallback(Gui::View3DInventorViewer* viewer,
SoEventCallbackCB* cb)
{
if (this->activeCB)
if (this->activeCB) {
return;
}
viewer->setEditing(true);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), cb, this);
this->activeCB = cb;
@@ -176,14 +183,15 @@ void MeshSelection::startInteractiveCallback(Gui::View3DInventorViewer* viewer,S
void MeshSelection::stopInteractiveCallback(Gui::View3DInventorViewer* viewer)
{
if (!this->activeCB)
if (!this->activeCB) {
return;
}
viewer->setEditing(false);
viewer->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), this->activeCB, this);
this->activeCB = nullptr;
}
void MeshSelection::prepareFreehandSelection(bool add,SoEventCallbackCB *cb)
void MeshSelection::prepareFreehandSelection(bool add, SoEventCallbackCB* cb)
{
// a rubberband to select a rectangle area of the meshes
Gui::View3DInventorViewer* viewer = this->getViewer();
@@ -213,7 +221,9 @@ void MeshSelection::prepareFreehandSelection(bool add,SoEventCallbackCB *cb)
viewer->setComponentCursor(custom);
};
QObject::connect(viewer, &Gui::View3DInventorViewer::devicePixelRatioChanged, setComponentCursor);
QObject::connect(viewer,
&Gui::View3DInventorViewer::devicePixelRatioChanged,
setComponentCursor);
setComponentCursor();
this->addToSelection = add;
}
@@ -266,15 +276,16 @@ bool MeshSelection::deleteSelection()
std::list<ViewProviderMesh*> views = getViewProviders();
for (auto view : views) {
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
unsigned long ct = MeshCore::MeshAlgorithm(mf->Mesh.getValue().getKernel()).
CountFacetFlag(MeshCore::MeshFacet::SELECTED);
unsigned long ct = MeshCore::MeshAlgorithm(mf->Mesh.getValue().getKernel())
.CountFacetFlag(MeshCore::MeshFacet::SELECTED);
if (ct > 0) {
selected = true;
break;
}
}
if (!selected)
return false; // nothing todo
if (!selected) {
return false; // nothing todo
}
for (auto view : views) {
view->deleteSelection();
@@ -350,14 +361,15 @@ void MeshSelection::selectComponent(int size)
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
std::vector<std::vector<Mesh::FacetIndex> > segm;
std::vector<std::vector<Mesh::FacetIndex>> segm;
MeshCore::MeshComponents comp(mo->getKernel());
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm);
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge, segm);
std::vector<Mesh::FacetIndex> faces;
for (const auto & jt : segm) {
if (jt.size() < (Mesh::FacetIndex)size)
for (const auto& jt : segm) {
if (jt.size() < (Mesh::FacetIndex)size) {
faces.insert(faces.end(), jt.begin(), jt.end());
}
}
view->addSelection(faces);
@@ -371,14 +383,15 @@ void MeshSelection::deselectComponent(int size)
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
std::vector<std::vector<Mesh::FacetIndex> > segm;
std::vector<std::vector<Mesh::FacetIndex>> segm;
MeshCore::MeshComponents comp(mo->getKernel());
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm);
comp.SearchForComponents(MeshCore::MeshComponents::OverEdge, segm);
std::vector<Mesh::FacetIndex> faces;
for (const auto & jt : segm) {
if (jt.size() > (Mesh::FacetIndex)size)
for (const auto& jt : segm) {
if (jt.size() > (Mesh::FacetIndex)size) {
faces.insert(faces.end(), jt.begin(), jt.end());
}
}
view->removeSelection(faces);
@@ -441,27 +454,30 @@ void MeshSelection::setRemoveComponentOnClick(bool on)
removeComponent = on;
}
void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
void MeshSelection::selectGLCallback(void* ud, SoEventCallback* n)
{
// When this callback function is invoked we must leave the edit mode
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
MeshSelection* self = static_cast<MeshSelection*>(ud);
self->stopInteractiveCallback(view);
n->setHandled();
std::vector<SbVec2f> polygon = view->getGLPolygon();
if (polygon.size() < 3)
if (polygon.size() < 3) {
return;
if (polygon.front() != polygon.back())
}
if (polygon.front() != polygon.back()) {
polygon.push_back(polygon.front());
}
SbVec3f pnt, dir;
view->getNearPlane(pnt, dir);
Base::Vector3f normal(dir[0],dir[1],dir[2]);
Base::Vector3f normal(dir[0], dir[1], dir[2]);
std::list<ViewProviderMesh*> views = self->getViewProviders();
for (auto vp : views) {
std::vector<Mesh::FacetIndex> faces;
const Mesh::MeshObject& mesh = static_cast<Mesh::Feature*>(vp->getObject())->Mesh.getValue();
const Mesh::MeshObject& mesh =
static_cast<Mesh::Feature*>(vp->getObject())->Mesh.getValue();
const MeshCore::MeshKernel& kernel = mesh.getKernel();
// simply get all triangles under the polygon
@@ -475,20 +491,24 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
if (self->onlyVisibleTriangles) {
const SbVec2s& sz = view->getSoRenderManager()->getViewportRegion().getWindowSize();
short width,height; sz.getValue(width,height);
short width, height;
sz.getValue(width, height);
std::vector<SbVec2s> pixelPoly = view->getPolygon();
SbBox2s rect;
for (const auto & p : pixelPoly) {
rect.extendBy(SbVec2s(p[0],height-p[1]));
for (const auto& p : pixelPoly) {
rect.extendBy(SbVec2s(p[0], height - p[1]));
}
std::vector<Mesh::FacetIndex> rf; rf.swap(faces);
std::vector<Mesh::FacetIndex> vf = vp->getVisibleFacetsAfterZoom
(rect, view->getSoRenderManager()->getViewportRegion(), view->getSoRenderManager()->getCamera());
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<Mesh::FacetIndex> > biit(faces);
std::back_insert_iterator<std::vector<Mesh::FacetIndex>> biit(faces);
std::set_intersection(vf.begin(), vf.end(), rf.begin(), rf.end(), biit);
}
@@ -507,26 +527,30 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
faces.swap(screen);
}
if (self->addToSelection)
if (self->addToSelection) {
vp->addSelection(faces);
else
}
else {
vp->removeSelection(faces);
}
}
view->redraw();
}
void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
void MeshSelection::pickFaceCallback(void* ud, SoEventCallback* n)
{
// handle only mouse button events
if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) {
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
// Mark all incoming mouse button events as handled, especially, to deactivate the selection
// node
n->getAction()->setHandled();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
const SoPickedPoint * point = n->getPickedPoint();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
&& mbe->getState() == SoButtonEvent::DOWN) {
const SoPickedPoint* point = n->getPickedPoint();
if (!point) {
Base::Console().Message("No facet picked.\n");
return;
@@ -537,28 +561,34 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
// really from the mesh we render and not from any other geometry
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath());
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId()))
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) {
return;
}
ViewProviderMesh* mesh = static_cast<ViewProviderMesh*>(vp);
MeshSelection* self = static_cast<MeshSelection*>(ud);
std::list<ViewProviderMesh*> views = self->getViewProviders();
if (std::find(views.begin(), views.end(), mesh) == views.end())
if (std::find(views.begin(), views.end(), mesh) == views.end()) {
return;
}
const SoDetail* detail = point->getDetail(/*mesh->getShapeNode()*/);
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the boundary to the picked facet
Mesh::FacetIndex uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
if (self->addToSelection) {
if (self->addComponent)
if (self->addComponent) {
mesh->selectComponent(uFacet);
else
}
else {
mesh->selectFacet(uFacet);
}
}
else {
if (self->removeComponent)
if (self->removeComponent) {
mesh->deselectComponent(uFacet);
else
}
else {
mesh->deselectFacet(uFacet);
}
}
}
}

View File

@@ -23,21 +23,23 @@
#ifndef MESHGUI_MESHSELECTION_H
#define MESHGUI_MESHSELECTION_H
#include <vector>
#include <QWidget>
#include <vector>
#include <Gui/SelectionObject.h>
#include <Inventor/nodes/SoEventCallback.h>
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
namespace Gui {
class View3DInventorViewer;
namespace Gui
{
class View3DInventorViewer;
}
namespace MeshGui {
namespace MeshGui
{
class ViewProviderMesh;
@@ -74,32 +76,32 @@ public:
void setViewer(Gui::View3DInventorViewer* v);
protected:
void setCallback(SoEventCallbackCB *cb);
void setCallback(SoEventCallbackCB* cb);
std::list<ViewProviderMesh*> getViewProviders() const;
Gui::View3DInventorViewer* getViewer() const;
void prepareFreehandSelection(bool,SoEventCallbackCB *cb);
void startInteractiveCallback(Gui::View3DInventorViewer* viewer,SoEventCallbackCB *cb);
void prepareFreehandSelection(bool, SoEventCallbackCB* cb);
void startInteractiveCallback(Gui::View3DInventorViewer* viewer, SoEventCallbackCB* cb);
void stopInteractiveCallback(Gui::View3DInventorViewer* viewer);
private:
static void selectGLCallback(void * ud, SoEventCallback * n);
static void pickFaceCallback(void * ud, SoEventCallback * n);
static void selectGLCallback(void* ud, SoEventCallback* n);
static void pickFaceCallback(void* ud, SoEventCallback* n);
private:
bool onlyPointToUserTriangles{false};
bool onlyVisibleTriangles{false};
bool addToSelection{false};
bool addComponent{false};
bool removeComponent{false};
SoEventCallbackCB *activeCB{nullptr};
SoEventCallbackCB *selectionCB{nullptr};
Gui::View3DInventorViewer* ivViewer{nullptr};
bool onlyPointToUserTriangles {false};
bool onlyVisibleTriangles {false};
bool addToSelection {false};
bool addComponent {false};
bool removeComponent {false};
SoEventCallbackCB* activeCB {nullptr};
SoEventCallbackCB* selectionCB {nullptr};
Gui::View3DInventorViewer* ivViewer {nullptr};
mutable std::vector<Gui::SelectionObject> meshObjects;
static unsigned char cross_bitmap[];
static unsigned char cross_mask_bitmap[];
};
}
} // namespace MeshGui
#endif // MESHGUI_MESHSELECTION_H
#endif // MESHGUI_MESHSELECTION_H

View File

@@ -27,19 +27,19 @@
// point at which warnings of overly long specifiers disabled (needed for VC6)
#ifdef _MSC_VER
# pragma warning( disable : 4005 )
# pragma warning( disable : 4251 )
# pragma warning( disable : 4503 )
# pragma warning( disable : 4275 )
# pragma warning( disable : 4273 )
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
#pragma warning(disable : 4005)
#pragma warning(disable : 4251)
#pragma warning(disable : 4503)
#pragma warning(disable : 4275)
#pragma warning(disable : 4273)
#pragma warning(disable : 4786) // specifier longer then 255 chars
#endif
#ifdef _PreComp_
// Gts
#ifdef FC_USE_GTS
# include <gts.h>
#include <gts.h>
#endif
// standard
@@ -56,19 +56,19 @@
// Qt Toolkit
#ifndef __QtAll__
# include <Gui/QtAll.h>
#include <Gui/QtAll.h>
#endif
// Inventor
#ifndef __InventorAll__
# include <Gui/InventorAll.h>
#include <Gui/InventorAll.h>
#endif
#elif defined(FC_OS_WIN32)
#ifndef NOMINMAX
# define NOMINMAX
#define NOMINMAX
#endif
#include <Windows.h>
#endif //_PreComp_
#endif // MESHGUI_PRECOMPILED_H
#endif // MESHGUI_PRECOMPILED_H

View File

@@ -35,18 +35,18 @@ PROPERTYITEM_SOURCE(MeshGui::PropertyMeshKernelItem)
PropertyMeshKernelItem::PropertyMeshKernelItem()
{
m_p = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
(Gui::PropertyEditor::PropertyIntegerItem::create());
m_p = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>(
Gui::PropertyEditor::PropertyIntegerItem::create());
m_p->setParent(this);
m_p->setPropertyName(QLatin1String("Points"));
this->appendChild(m_p);
m_e = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
(Gui::PropertyEditor::PropertyIntegerItem::create());
m_e = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>(
Gui::PropertyEditor::PropertyIntegerItem::create());
m_e->setParent(this);
m_e->setPropertyName(QLatin1String("Edges"));
this->appendChild(m_e);
m_f = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
(Gui::PropertyEditor::PropertyIntegerItem::create());
m_f = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>(
Gui::PropertyEditor::PropertyIntegerItem::create());
m_f->setParent(this);
m_f->setPropertyName(QLatin1String("Faces"));
this->appendChild(m_f);
@@ -72,7 +72,7 @@ QVariant PropertyMeshKernelItem::value(const App::Property*) const
ctF += (int)rMesh.CountFacets();
}
QString str = QObject::tr("[Points: %1, Edges: %2, Faces: %3]").arg(ctP).arg(ctE).arg(ctF);
QString str = QObject::tr("[Points: %1, Edges: %2, Faces: %3]").arg(ctP).arg(ctE).arg(ctF);
return {str};
}
@@ -86,7 +86,9 @@ void PropertyMeshKernelItem::setValue(const QVariant& value)
Q_UNUSED(value);
}
QWidget* PropertyMeshKernelItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
QWidget* PropertyMeshKernelItem::createEditor(QWidget* parent,
const QObject* receiver,
const char* method) const
{
Q_UNUSED(parent);
Q_UNUSED(receiver);
@@ -94,13 +96,13 @@ QWidget* PropertyMeshKernelItem::createEditor(QWidget* parent, const QObject* re
return nullptr;
}
void PropertyMeshKernelItem::setEditorData(QWidget *editor, const QVariant& data) const
void PropertyMeshKernelItem::setEditorData(QWidget* editor, const QVariant& data) const
{
Q_UNUSED(editor);
Q_UNUSED(data);
}
QVariant PropertyMeshKernelItem::editorData(QWidget *editor) const
QVariant PropertyMeshKernelItem::editorData(QWidget* editor) const
{
Q_UNUSED(editor);
return {};

View File

@@ -25,17 +25,18 @@
#include <Gui/propertyeditor/PropertyItem.h>
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
namespace MeshGui {
namespace MeshGui
{
/**
* Display data of a mesh kernel.
* \author Werner Mayer
*/
class MeshGuiExport PropertyMeshKernelItem : public Gui::PropertyEditor::PropertyItem
class MeshGuiExport PropertyMeshKernelItem: public Gui::PropertyEditor::PropertyItem
{
Q_OBJECT
Q_PROPERTY(int Points READ countPoints CONSTANT)
@@ -43,9 +44,13 @@ class MeshGuiExport PropertyMeshKernelItem : public Gui::PropertyEditor::Propert
Q_PROPERTY(int Faces READ countFaces CONSTANT)
PROPERTYITEM_HEADER
QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const override;
void setEditorData(QWidget *editor, const QVariant& data) const override;
QVariant editorData(QWidget *editor) const override;
// clang-format off
QWidget* createEditor(QWidget* parent,
const QObject* receiver,
const char* method) const override;
// clang-format on
void setEditorData(QWidget* editor, const QVariant& data) const override;
QVariant editorData(QWidget* editor) const override;
int countPoints() const;
int countEdges() const;
@@ -66,8 +71,7 @@ private:
Gui::PropertyEditor::PropertyIntegerItem* m_f;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_PROPERTYEDITOR_MESH_H
#endif // MESHGUI_PROPERTYEDITOR_MESH_H

View File

@@ -22,10 +22,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QElapsedTimer>
# include <QMessageBox>
# include <QPointer>
# include <QTextCursor>
#include <QElapsedTimer>
#include <QMessageBox>
#include <QPointer>
#include <QTextCursor>
#endif
#include <App/Application.h>
@@ -43,15 +43,17 @@
using namespace MeshGui;
class GmshWidget::Private {
class GmshWidget::Private
{
public:
explicit Private(QWidget* parent)
: gmsh(parent)
: gmsh(parent)
{
/* coverity[uninit_ctor] Members of ui are set in setupUI() */
}
void appendText(const QString& text, bool error) {
void appendText(const QString& text, bool error)
{
syntax->setParagraphType(error ? Gui::DockWnd::ReportHighlighter::Error
: Gui::DockWnd::ReportHighlighter::Message);
QTextCursor cursor(ui.outputWindow->document());
@@ -71,8 +73,8 @@ public:
};
GmshWidget::GmshWidget(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, d(new Private(parent))
: QWidget(parent, fl)
, d(new Private(parent))
{
d->ui.setupUi(this);
setupConnections();
@@ -82,7 +84,8 @@ GmshWidget::GmshWidget(QWidget* parent, Qt::WindowFlags fl)
// 2D Meshing algorithms
// https://gmsh.info/doc/texinfo/gmsh.html#index-Mesh_002eAlgorithm
enum {
enum
{
MeshAdapt = 1,
Automatic = 2,
Delaunay = 5,
@@ -108,6 +111,7 @@ GmshWidget::~GmshWidget()
void GmshWidget::setupConnections()
{
// clang-format off
connect(&d->gmsh, &QProcess::started, this, &GmshWidget::started);
connect(&d->gmsh, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this, &GmshWidget::finished);
@@ -121,9 +125,10 @@ void GmshWidget::setupConnections()
this, &GmshWidget::onKillButtonClicked);
connect(d->ui.clearButton, &QPushButton::clicked,
this, &GmshWidget::onClearButtonClicked);
// clang-format on
}
void GmshWidget::changeEvent(QEvent *e)
void GmshWidget::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
d->ui.retranslateUi(this);
@@ -177,12 +182,8 @@ void GmshWidget::accept()
// ./gmsh - -bin -2 /tmp/mesh.geo -o /tmp/best.stl
QString proc = d->ui.fileChooser->fileName();
QStringList args;
args << QLatin1String("-")
<< QLatin1String("-bin")
<< QLatin1String("-2")
<< inpFile
<< QLatin1String("-o")
<< outFile;
args << QLatin1String("-") << QLatin1String("-bin") << QLatin1String("-2") << inpFile
<< QLatin1String("-o") << outFile;
d->gmsh.start(proc, args);
d->time.start();
@@ -239,10 +240,12 @@ void GmshWidget::started()
void GmshWidget::finished(int /*exitCode*/, QProcess::ExitStatus exitStatus)
{
d->ui.killButton->setDisabled(true);
if (d->label)
if (d->label) {
d->label->close();
}
d->ui.labelTime->setText(QString::fromLatin1("%1 %2 ms").arg(tr("Time:")).arg(d->time.elapsed()));
d->ui.labelTime->setText(
QString::fromLatin1("%1 %2 ms").arg(tr("Time:")).arg(d->time.elapsed()));
if (exitStatus == QProcess::NormalExit) {
loadOutput();
}
@@ -252,11 +255,11 @@ void GmshWidget::errorOccurred(QProcess::ProcessError error)
{
QString msg;
switch (error) {
case QProcess::FailedToStart:
msg = tr("Failed to start");
break;
default:
break;
case QProcess::FailedToStart:
msg = tr("Failed to start");
break;
default:
break;
}
if (!msg.isEmpty()) {
@@ -271,12 +274,12 @@ void GmshWidget::reject()
// -------------------------------------------------
class RemeshGmsh::Private {
class RemeshGmsh::Private
{
public:
explicit Private(Mesh::Feature* mesh)
: mesh(mesh)
{
}
: mesh(mesh)
{}
public:
App::DocumentObjectWeakPtrT mesh;
@@ -286,8 +289,8 @@ public:
};
RemeshGmsh::RemeshGmsh(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl)
: GmshWidget(parent, fl)
, d(new Private(mesh))
: GmshWidget(parent, fl)
, d(new Private(mesh))
{
// Copy mesh that is used each time when applying Gmsh's remeshing function
d->copy = mesh->Mesh.getValue().getKernel();
@@ -299,6 +302,7 @@ RemeshGmsh::~RemeshGmsh() = default;
bool RemeshGmsh::writeProject(QString& inpFile, QString& outFile)
{
// clang-format off
if (!d->mesh.expired()) {
Base::FileInfo stl(d->stlFile);
MeshCore::MeshOutput output(d->copy);
@@ -358,12 +362,14 @@ bool RemeshGmsh::writeProject(QString& inpFile, QString& outFile)
}
return false;
// clang-format on
}
bool RemeshGmsh::loadOutput()
{
if (d->mesh.expired())
if (d->mesh.expired()) {
return false;
}
// Now read-in modified mesh
Base::FileInfo stl(d->stlFile);
@@ -394,8 +400,7 @@ bool RemeshGmsh::loadOutput()
TaskRemeshGmsh::TaskRemeshGmsh(Mesh::Feature* mesh)
{
widget = new RemeshGmsh(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);
}

View File

@@ -23,30 +23,33 @@
#ifndef MESHGUI_REMESHGMSH_H
#define MESHGUI_REMESHGMSH_H
#include <memory>
#include <QDialog>
#include <QProcess>
#include <memory>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
namespace Mesh {
namespace Mesh
{
class Feature;
}
namespace Gui {
namespace Gui
{
class StatusWidget;
}
namespace MeshGui {
namespace MeshGui
{
/**
* Non-modal dialog to remesh an existing mesh.
* @author Werner Mayer
*/
class MeshGuiExport GmshWidget : public QWidget
class MeshGuiExport GmshWidget: public QWidget
{
Q_OBJECT
@@ -57,7 +60,7 @@ public:
void reject();
protected:
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
int meshingAlgorithm() const;
double getAngle() const;
double getMaxSize() const;
@@ -85,12 +88,14 @@ private:
* Non-modal dialog to remesh an existing mesh.
* @author Werner Mayer
*/
class MeshGuiExport RemeshGmsh : public GmshWidget
class MeshGuiExport RemeshGmsh: public GmshWidget
{
Q_OBJECT
public:
explicit RemeshGmsh(Mesh::Feature* mesh, QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
explicit RemeshGmsh(Mesh::Feature* mesh,
QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags());
~RemeshGmsh() override;
protected:
@@ -105,7 +110,7 @@ private:
/**
* Embed the panel into a task dialog.
*/
class TaskRemeshGmsh : public Gui::TaskView::TaskDialog
class TaskRemeshGmsh: public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -116,15 +121,19 @@ public:
void clicked(int) override;
QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Apply | QDialogButtonBox::Close; }
{
return QDialogButtonBox::Apply | QDialogButtonBox::Close;
}
bool isAllowedAlterDocument() const override
{ return true; }
{
return true;
}
private:
RemeshGmsh* widget;
Gui::TaskView::TaskBox* taskbox;
};
}
} // namespace MeshGui
#endif // MESHGUI_REMESHGMSH_H
#endif // MESHGUI_REMESHGMSH_H

View File

@@ -22,7 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QPushButton>
#include <QPushButton>
#endif
#include <Gui/Application.h>
@@ -36,7 +36,7 @@
using namespace MeshGui;
RemoveComponents::RemoveComponents(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
: QWidget(parent, fl)
{
ui = new Ui_RemoveComponents;
ui->setupUi(this);
@@ -60,6 +60,7 @@ RemoveComponents::~RemoveComponents()
void RemoveComponents::setupConnections()
{
// clang-format off
connect(ui->selectRegion, &QPushButton::clicked,
this, &RemoveComponents::onSelectRegionClicked);
connect(ui->selectAll, &QPushButton::clicked,
@@ -84,9 +85,10 @@ void RemoveComponents::setupConnections()
this, &RemoveComponents::onSelectCompToggled);
connect(ui->cbDeselectComp, &QCheckBox::toggled,
this, &RemoveComponents::onDeselectCompToggled);
// clang-format on
}
void RemoveComponents::changeEvent(QEvent *e)
void RemoveComponents::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
@@ -153,15 +155,18 @@ void RemoveComponents::onDeselectCompToggled(bool on)
void RemoveComponents::deleteSelection()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc)
if (!doc) {
return;
}
// delete all selected faces
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Delete selection"));
bool ok = meshSel.deleteSelection();
if (!ok)
if (!ok) {
doc->abortCommand();
else
}
else {
doc->commitCommand();
}
}
void RemoveComponents::invertSelection()
@@ -191,21 +196,19 @@ void RemoveComponents::reject()
// -------------------------------------------------
RemoveComponentsDialog::RemoveComponentsDialog(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl)
: QDialog(parent, fl)
{
widget = new RemoveComponents(this);
this->setWindowTitle(widget->windowTitle());
QVBoxLayout* hboxLayout = new QVBoxLayout(this);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Close|QDialogButtonBox::Ok);
buttonBox->setStandardButtons(QDialogButtonBox::Close | QDialogButtonBox::Ok);
QPushButton* okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setText(MeshGui::TaskRemoveComponents::tr("Delete"));
buttonBox->addButton(MeshGui::TaskRemoveComponents::tr("Invert"),
QDialogButtonBox::ActionRole);
buttonBox->addButton(MeshGui::TaskRemoveComponents::tr("Invert"), QDialogButtonBox::ActionRole);
connect(buttonBox, &QDialogButtonBox::clicked,
this, &RemoveComponentsDialog::clicked);
connect(buttonBox, &QDialogButtonBox::clicked, this, &RemoveComponentsDialog::clicked);
hboxLayout->addWidget(widget);
hboxLayout->addWidget(buttonBox);
@@ -241,8 +244,7 @@ void RemoveComponentsDialog::clicked(QAbstractButton* btn)
TaskRemoveComponents::TaskRemoveComponents()
{
widget = new RemoveComponents();
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);
}

View File

@@ -24,13 +24,14 @@
#ifndef MESHGUI_REMOVECOMPONENTS_H
#define MESHGUI_REMOVECOMPONENTS_H
#include <QDialog>
#include "MeshSelection.h"
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <Mod/Mesh/MeshGlobal.h>
#include "MeshSelection.h"
#include <QDialog>
namespace MeshGui {
namespace MeshGui
{
class Ui_RemoveComponents;
/**
@@ -38,7 +39,7 @@ class Ui_RemoveComponents;
* of a mesh and delete them.
* @author Werner Mayer
*/
class MeshGuiExport RemoveComponents : public QWidget
class MeshGuiExport RemoveComponents: public QWidget
{
Q_OBJECT
@@ -64,7 +65,7 @@ public:
void onDeselectCompToggled(bool);
protected:
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
void setupConnections();
@@ -77,12 +78,13 @@ private:
/**
* Embed the panel into a dialog.
*/
class MeshGuiExport RemoveComponentsDialog : public QDialog
class MeshGuiExport RemoveComponentsDialog: public QDialog
{
Q_OBJECT
public:
explicit RemoveComponentsDialog(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
explicit RemoveComponentsDialog(QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags());
~RemoveComponentsDialog() override;
void reject() override;
@@ -96,7 +98,7 @@ private:
/**
* Embed the panel into a task dialog.
*/
class TaskRemoveComponents : public Gui::TaskView::TaskDialog
class TaskRemoveComponents: public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -108,9 +110,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:
@@ -118,6 +124,6 @@ private:
Gui::TaskView::TaskBox* taskbox;
};
}
} // namespace MeshGui
#endif // MESHGUI_REMOVECOMPONENTS_H
#endif // MESHGUI_REMOVECOMPONENTS_H

View File

@@ -1102,7 +1102,7 @@
<location filename="../../DlgEvaluateMeshImp.cpp" line="451"/>
<source>Check failed due to folds on the surface.
Please run the command to repair folds first</source>
<translation>Kontrole het misluk weens voue op die oppervlak.
<translation>Kontrole het misluk weens voue op die oppervlak.
Gee eers die opdrag om die voue te herstel</translation>
</message>
<message>

View File

@@ -1489,7 +1489,7 @@ Amb un ombrejat pla, les normals de la superfície no es defineixen per vèrtex
If face angle &lt; crease angle, smooth shading is used</source>
<translation>Langle de plec és un angle llindar entre dues cares.
Si l'angle de la cara ≥ l'angle de plec, s'utilitza l'ombrejat de facetes
Si l'angle de la cara ≥ l'angle de plec, s'utilitza l'ombrejat de facetes
Si angle de la cara &lt; l'angle de plec, s'utilitza un ombrejat suau</translation>
</message>
</context>

View File

@@ -1369,7 +1369,7 @@
<location filename="../../DlgSettingsImportExportImp.cpp" line="38"/>
<source>This parameter indicates whether ZIP compression
is used when writing a file in AMF format</source>
<translation>Tämä parametri ilmaisee, on ZIP pakkaaminen
<translation>Tämä parametri ilmaisee, on ZIP pakkaaminen
käytössä kirjoitettaessa tiedostoa AMF muodossa</translation>
</message>
</context>
@@ -1428,7 +1428,7 @@ If not checked, it depends on the option "Enable backlight color"
will be used or black.</source>
<translation>Pinnan alareuna on renderöity samalla tavalla kuin yläpuolella.
Jos ei ole valittuna, se riippuu vaihtoehdosta "Ota taustavalo väri käyttöön"
(asetruksien osiossa Näyttö -&gt; 3D Näkymä). Joko taustavalon väriä
(asetruksien osiossa Näyttö -&gt; 3D Näkymä). Joko taustavalon väriä
käytetään tai se on musta.</translation>
</message>
<message>
@@ -2083,7 +2083,7 @@ sileämpään ulkonäköön.
<location filename="../../Command.cpp" line="281"/>
<source>OpenSCAD cannot be found on your system.
Please visit http://www.openscad.org/index.html to install it.</source>
<translation>OpenSCAD:ia ei löydy järjestelmästäsi. Käy
<translation>OpenSCAD:ia ei löydy järjestelmästäsi. Käy
http://www.openscad.org/index.html asentaaksesi sen.</translation>
</message>
</context>

View File

@@ -1427,7 +1427,7 @@ If not checked, it depends on the option "Enable backlight color"
will be used or black.</source>
<translation>Donja strana površine bit će prikazana na isti način kao gornja strana.
Ako nije potvrđeno, ovisi o opciji "Omogući boju pozadinskog osvjetljenja"
(odjeljak postavki prikaza -&gt; 3D prikaz). Koristit će se boja pozadinskog
(odjeljak postavki prikaza -&gt; 3D prikaz). Koristit će se boja pozadinskog
osvjetljenja ili crno.
</translation>
</message>
@@ -2084,7 +2084,7 @@ vodi do uglađenijeg izgleda.
<location filename="../../Command.cpp" line="281"/>
<source>OpenSCAD cannot be found on your system.
Please visit http://www.openscad.org/index.html to install it.</source>
<translation>OpenSCAD nije moguće pronaći na vašem sustavu.
<translation>OpenSCAD nije moguće pronaći na vašem sustavu.
Posjetite http://www.openscad.org/index.html da biste ga instalirali.</translation>
</message>
</context>

View File

@@ -1369,7 +1369,7 @@
<location filename="../../DlgSettingsImportExportImp.cpp" line="38"/>
<source>This parameter indicates whether ZIP compression
is used when writing a file in AMF format</source>
<translation>
<translation>
ZIP AMF </translation>
</message>
</context>

View File

@@ -1464,7 +1464,7 @@ to a smoother appearance.
<translation>Als deze optie is ingesteld, wordt de Phong-beschaduwing gebruikt, anders vlakke schaduwen.
De beschaduwing bepaalt het uiterlijk van de oppervlakken.
Bij vlakke beschaduwingen worden de oppervlaktenormen niet per eindpunt gedefinieerd, wat leidt
Bij vlakke beschaduwingen worden de oppervlaktenormen niet per eindpunt gedefinieerd, wat leidt
tot een onrealistisch uiterlijk voor gebogen oppervlakken, terwijl het gebruik van Phong-beschaduwing
tot een gladder uiterlijk leidt.
</translation>

View File

@@ -2083,7 +2083,7 @@ do gładszego wyglądu.
<location filename="../../Command.cpp" line="281"/>
<source>OpenSCAD cannot be found on your system.
Please visit http://www.openscad.org/index.html to install it.</source>
<translation>OpenSCAD nie został odnaleziony w Twoim systemie.
<translation>OpenSCAD nie został odnaleziony w Twoim systemie.
Odwiedź http://www.openscad.org/index.html żeby go zainstalować.</translation>
</message>
</context>

View File

@@ -1428,7 +1428,7 @@ If not checked, it depends on the option "Enable backlight color"
will be used or black.</source>
<translation>Donja strana površine će biti prikazana na isti način kao gornja strana.
Ako nije čekirano, zavisi od opcije Omogući boju pozadinskog osvetljenja
(Podešavanja -&gt; Prikaz -&gt; 3D prikaz). Ili će se koristiti boja pozadinskog
(Podešavanja -&gt; Prikaz -&gt; 3D prikaz). Ili će se koristiti boja pozadinskog
osvetljenja ili crna boja.</translation>
</message>
<message>

View File

@@ -1428,7 +1428,7 @@ If not checked, it depends on the option "Enable backlight color"
will be used or black.</source>
<translation>Доња страна површине ће бити приказана на исти начин као горња страна.
Ако није чекирано, зависи од опције Омогући боју позадинског осветљења
(Подешавања -&gt; Приказ -&gt; 3Д приказ). Или ће се користити боја позадинског
(Подешавања -&gt; Приказ -&gt; 3Д приказ). Или ће се користити боја позадинског
осветљења или црна боја.</translation>
</message>
<message>

View File

@@ -1464,7 +1464,7 @@ to a smoother appearance.
Затінення визначає зовнішній вигляд поверхонь.
При плоскому затіненні поверхневих стандартів не визначаються для кожної вершини, що веде
до уявного вигляду для криволінійних поверхонь під час використання відтінків Phong
до уявного вигляду для криволінійних поверхонь під час використання відтінків Phong
до більш гладкого вигляду.</translation>
</message>
<message>

View File

@@ -1489,7 +1489,7 @@ Amb un ombrejat pla, les normals de la superfície no es defineixen per vèrtex
If face angle &lt; crease angle, smooth shading is used</source>
<translation>Langle de plec és un angle llindar entre dues cares.
Si l'angle de la cara l'angle de plec, s'utilitza l'ombrejat de facetes
Si l'angle de la cara l'angle de plec, s'utilitza l'ombrejat de facetes
Si angle de la cara &lt; l'angle de plec, s'utilitza un ombrejat suau</translation>
</message>
</context>

View File

@@ -22,7 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <sstream>
#endif
#include <App/Application.h>
@@ -40,7 +40,8 @@
using namespace MeshGui;
Segmentation::Segmentation(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl), myMesh(mesh)
: QWidget(parent, fl)
, myMesh(mesh)
{
ui = new Ui_Segmentation;
ui->setupUi(this);
@@ -83,22 +84,34 @@ void Segmentation::accept()
std::vector<MeshCore::MeshSurfaceSegmentPtr> segm;
if (ui->groupBoxFree->isChecked()) {
segm.emplace_back(std::make_shared<MeshCore::MeshCurvatureFreeformSegment>
(meshCurv.GetCurvature(), ui->numFree->value(),
ui->tol1Free->value(), ui->tol2Free->value(),
ui->crv1Free->value(), ui->crv2Free->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshCurvatureFreeformSegment>(meshCurv.GetCurvature(),
ui->numFree->value(),
ui->tol1Free->value(),
ui->tol2Free->value(),
ui->crv1Free->value(),
ui->crv2Free->value()));
}
if (ui->groupBoxCyl->isChecked()) {
segm.emplace_back(std::make_shared<MeshCore::MeshCurvatureCylindricalSegment>
(meshCurv.GetCurvature(), ui->numCyl->value(), ui->tol1Cyl->value(), ui->tol2Cyl->value(), ui->crvCyl->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshCurvatureCylindricalSegment>(meshCurv.GetCurvature(),
ui->numCyl->value(),
ui->tol1Cyl->value(),
ui->tol2Cyl->value(),
ui->crvCyl->value()));
}
if (ui->groupBoxSph->isChecked()) {
segm.emplace_back(std::make_shared<MeshCore::MeshCurvatureSphericalSegment>
(meshCurv.GetCurvature(), ui->numSph->value(), ui->tolSph->value(), ui->crvSph->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshCurvatureSphericalSegment>(meshCurv.GetCurvature(),
ui->numSph->value(),
ui->tolSph->value(),
ui->crvSph->value()));
}
if (ui->groupBoxPln->isChecked()) {
segm.emplace_back(std::make_shared<MeshCore::MeshCurvaturePlanarSegment>
(meshCurv.GetCurvature(), ui->numPln->value(), ui->tolPln->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshCurvaturePlanarSegment>(meshCurv.GetCurvature(),
ui->numPln->value(),
ui->tolPln->value()));
}
finder.FindSegments(segm);
@@ -107,16 +120,17 @@ 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);
for (const auto & it : segm) {
for (const auto& it : segm) {
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
for (const auto & jt : data) {
for (const auto& jt : data) {
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();
@@ -130,7 +144,7 @@ void Segmentation::accept()
document->commitTransaction();
}
void Segmentation::changeEvent(QEvent *e)
void Segmentation::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
@@ -145,8 +159,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);
}

View File

@@ -28,25 +28,31 @@
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
// forward declarations
namespace Mesh { class Feature; }
namespace Mesh
{
class Feature;
}
namespace MeshGui {
namespace MeshGui
{
class Ui_Segmentation;
class MeshGuiExport Segmentation : public QWidget
class MeshGuiExport Segmentation: public QWidget
{
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:
Ui_Segmentation* ui;
@@ -56,7 +62,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);
@@ -65,13 +71,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 MeshGui
#endif // MESHGUI_SEGMENTATION_H
#endif // MESHGUI_SEGMENTATION_H

View File

@@ -22,13 +22,13 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <sstream>
# include <QDialog>
# include <QDoubleSpinBox>
# include <QMessageBox>
# include <QPointer>
# include <QVBoxLayout>
#include <QDialog>
#include <QDoubleSpinBox>
#include <QMessageBox>
#include <QPointer>
#include <QVBoxLayout>
#endif
#include <App/Application.h>
@@ -46,13 +46,15 @@
using namespace MeshGui;
namespace MeshGui {
class PlaneFitParameter : public FitParameter
namespace MeshGui
{
class PlaneFitParameter: public FitParameter
{
public:
PlaneFitParameter() = default;
~PlaneFitParameter() override = default;
std::vector<float> getParameter(FitParameter::Points pts) const override {
std::vector<float> getParameter(FitParameter::Points pts) const override
{
std::vector<float> values;
MeshCore::PlaneFit fit;
fit.AddPoints(pts.points);
@@ -70,12 +72,13 @@ public:
}
};
class CylinderFitParameter : public FitParameter
class CylinderFitParameter: public FitParameter
{
public:
CylinderFitParameter() = default;
~CylinderFitParameter() override = default;
std::vector<float> getParameter(FitParameter::Points pts) const override {
std::vector<float> getParameter(FitParameter::Points pts) const override
{
std::vector<float> values;
MeshCore::CylinderFit fit;
fit.AddPoints(pts.points);
@@ -106,16 +109,26 @@ public:
// Only for testing purposes
try {
float height = Base::Distance(base, top);
Gui::Command::doCommand(Gui::Command::App,
"cyl = App.ActiveDocument.addObject('Part::Cylinder', 'Cylinder')\n"
"cyl.Radius = %f\n"
"cyl.Height = %f\n"
"cyl.Placement = App.Placement(App.Vector(%f,%f,%f), App.Rotation(App.Vector(0,0,1), App.Vector(%f,%f,%f)))\n",
radius, height, base.x, base.y, base.z, axis.x, axis.y, axis.z);
Gui::Command::doCommand(
Gui::Command::App,
"cyl = App.ActiveDocument.addObject('Part::Cylinder', 'Cylinder')\n"
"cyl.Radius = %f\n"
"cyl.Height = %f\n"
"cyl.Placement = App.Placement(App.Vector(%f,%f,%f), "
"App.Rotation(App.Vector(0,0,1), App.Vector(%f,%f,%f)))\n",
radius,
height,
base.x,
base.y,
base.z,
axis.x,
axis.y,
axis.z);
Gui::Command::doCommand(Gui::Command::App,
"axis = cyl.Placement.Rotation.multVec(App.Vector(0,0,1))\n"
"print('Final axis: ({}, {}, {})'.format(axis.x, axis.y, axis.z))\n");
Gui::Command::doCommand(
Gui::Command::App,
"axis = cyl.Placement.Rotation.multVec(App.Vector(0,0,1))\n"
"print('Final axis: ({}, {}, {})'.format(axis.x, axis.y, axis.z))\n");
}
catch (...) {
}
@@ -125,12 +138,13 @@ public:
}
};
class SphereFitParameter : public FitParameter
class SphereFitParameter: public FitParameter
{
public:
SphereFitParameter() = default;
~SphereFitParameter() override = default;
std::vector<float> getParameter(FitParameter::Points pts) const override {
std::vector<float> getParameter(FitParameter::Points pts) const override
{
std::vector<float> values;
MeshCore::SphereFit fit;
fit.AddPoints(pts.points);
@@ -145,10 +159,12 @@ public:
return values;
}
};
}
} // namespace MeshGui
ParametersDialog::ParametersDialog(std::vector<float>& val, FitParameter* fitPar,
ParameterList par, Mesh::Feature* mesh,
ParametersDialog::ParametersDialog(std::vector<float>& val,
FitParameter* fitPar,
ParameterList par,
Mesh::Feature* mesh,
QWidget* parent)
: QDialog(parent)
, values(val)
@@ -158,54 +174,54 @@ ParametersDialog::ParametersDialog(std::vector<float>& val, FitParameter* fitPar
{
this->setWindowTitle(tr("Surface fit"));
QGridLayout *gridLayout;
QGridLayout* gridLayout;
gridLayout = new QGridLayout(this);
QGroupBox *groupBox;
QGroupBox* groupBox;
groupBox = new QGroupBox(this);
groupBox->setTitle(tr("Parameters"));
gridLayout->addWidget(groupBox, 0, 0, 1, 1);
QGroupBox *selectBox;
QGroupBox* selectBox;
selectBox = new QGroupBox(this);
selectBox->setTitle(tr("Selection"));
gridLayout->addWidget(selectBox, 1, 0, 1, 1);
QVBoxLayout *selectLayout;
QVBoxLayout* selectLayout;
selectLayout = new QVBoxLayout(selectBox);
QPushButton *regionButton;
QPushButton* regionButton;
regionButton = new QPushButton(this);
regionButton->setText(tr("Region"));
regionButton->setObjectName(QString::fromLatin1("region"));
selectLayout->addWidget(regionButton);
QPushButton *singleButton;
QPushButton* singleButton;
singleButton = new QPushButton(this);
singleButton->setText(tr("Triangle"));
singleButton->setObjectName(QString::fromLatin1("single"));
selectLayout->addWidget(singleButton);
QPushButton *clearButton;
QPushButton* clearButton;
clearButton = new QPushButton(this);
clearButton->setText(tr("Clear"));
clearButton->setObjectName(QString::fromLatin1("clear"));
selectLayout->addWidget(clearButton);
QPushButton *computeButton;
QPushButton* computeButton;
computeButton = new QPushButton(this);
computeButton->setText(tr("Compute"));
computeButton->setObjectName(QString::fromLatin1("compute"));
gridLayout->addWidget(computeButton, 2, 0, 1, 1);
QDialogButtonBox *buttonBox;
QDialogButtonBox* buttonBox;
buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
gridLayout->addWidget(buttonBox, 3, 0, 1, 1);
int index = 0;
QGridLayout *layout;
QGridLayout* layout;
layout = new QGridLayout(groupBox);
for (const auto& it : parameter) {
QLabel* label = new QLabel(groupBox);
@@ -221,12 +237,14 @@ ParametersDialog::ParametersDialog(std::vector<float>& val, FitParameter* fitPar
++index;
}
// clang-format off
connect(buttonBox, &QDialogButtonBox::accepted, this, &ParametersDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ParametersDialog::reject);
connect(regionButton, &QPushButton::clicked, this, &ParametersDialog::onRegionClicked);
connect(singleButton, &QPushButton::clicked, this, &ParametersDialog::onSingleClicked);
connect(clearButton, &QPushButton::clicked, this, &ParametersDialog::onClearClicked);
connect(computeButton, &QPushButton::clicked, this, &ParametersDialog::onComputeClicked);
// clang-format on
Gui::SelectionObject obj(mesh);
std::vector<Gui::SelectionObject> sel;
@@ -277,7 +295,7 @@ void ParametersDialog::onComputeClicked()
values = fitParameter->getParameter(fitpts);
if (values.size() == spinBoxes.size()) {
for (std::size_t i=0; i<values.size(); i++) {
for (std::size_t i = 0; i < values.size(); i++) {
spinBoxes[i]->setValue(values[i]);
}
}
@@ -285,15 +303,18 @@ void ParametersDialog::onComputeClicked()
meshSel.clearSelection();
}
else {
QMessageBox::warning(this, tr("No selection"), tr("Before fitting the surface select an area."));
QMessageBox::warning(this,
tr("No selection"),
tr("Before fitting the surface select an area."));
}
}
void ParametersDialog::accept()
{
std::vector<float> v;
for (auto it : spinBoxes)
for (auto it : spinBoxes) {
v.push_back(it->value());
}
values = v;
QDialog::accept();
}
@@ -309,7 +330,8 @@ void ParametersDialog::reject()
/* TRANSLATOR MeshGui::SegmentationBestFit */
SegmentationBestFit::SegmentationBestFit(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl), myMesh(mesh)
: QWidget(parent, fl)
, myMesh(mesh)
{
ui = new Ui_SegmentationBestFit;
ui->setupUi(this);
@@ -336,12 +358,14 @@ SegmentationBestFit::~SegmentationBestFit()
void SegmentationBestFit::setupConnections()
{
// clang-format off
connect(ui->planeParameters, &QPushButton::clicked,
this, &SegmentationBestFit::onPlaneParametersClicked);
connect(ui->cylinderParameters, &QPushButton::clicked,
this, &SegmentationBestFit::onCylinderParametersClicked);
connect(ui->sphereParameters, &QPushButton::clicked,
this, &SegmentationBestFit::onSphereParametersClicked);
// clang-format on
}
void SegmentationBestFit::onPlaneParametersClicked()
@@ -362,10 +386,9 @@ void SegmentationBestFit::onPlaneParametersClicked()
list.push_back(std::make_pair(axis + z, p[5]));
static QPointer<QDialog> dialog = nullptr;
if (!dialog)
dialog = new ParametersDialog(planeParameter,
new PlaneFitParameter,
list, myMesh, this);
if (!dialog) {
dialog = new ParametersDialog(planeParameter, new PlaneFitParameter, list, myMesh, this);
}
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
@@ -387,13 +410,13 @@ void SegmentationBestFit::onCylinderParametersClicked()
list.push_back(std::make_pair(axis + x, p[3]));
list.push_back(std::make_pair(axis + y, p[4]));
list.push_back(std::make_pair(axis + z, p[5]));
list.push_back(std::make_pair(radius, p[6]));
list.push_back(std::make_pair(radius, p[6]));
static QPointer<QDialog> dialog = nullptr;
if (!dialog)
dialog = new ParametersDialog(cylinderParameter,
new CylinderFitParameter,
list, myMesh, this);
if (!dialog) {
dialog =
new ParametersDialog(cylinderParameter, new CylinderFitParameter, list, myMesh, this);
}
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
@@ -411,13 +434,12 @@ void SegmentationBestFit::onSphereParametersClicked()
list.push_back(std::make_pair(base + x, p[0]));
list.push_back(std::make_pair(base + y, p[1]));
list.push_back(std::make_pair(base + z, p[2]));
list.push_back(std::make_pair(radius, p[3]));
list.push_back(std::make_pair(radius, p[3]));
static QPointer<QDialog> dialog = nullptr;
if (!dialog)
dialog = new ParametersDialog(sphereParameter,
new SphereFitParameter,
list, myMesh, this);
if (!dialog) {
dialog = new ParametersDialog(sphereParameter, new SphereFitParameter, list, myMesh, this);
}
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
@@ -434,44 +456,49 @@ void SegmentationBestFit::accept()
MeshCore::AbstractSurfaceFit* fitter;
if (cylinderParameter.size() == 7) {
std::vector<float>& p = cylinderParameter;
fitter = new MeshCore::CylinderSurfaceFit(
Base::Vector3f(p[0],p[1],p[2]),
Base::Vector3f(p[3],p[4],p[5]),
p[6]);
fitter = new MeshCore::CylinderSurfaceFit(Base::Vector3f(p[0], p[1], p[2]),
Base::Vector3f(p[3], p[4], p[5]),
p[6]);
}
else {
fitter = new MeshCore::CylinderSurfaceFit;
}
segm.emplace_back(std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>
(fitter, kernel, ui->numCyl->value(), ui->tolCyl->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>(fitter,
kernel,
ui->numCyl->value(),
ui->tolCyl->value()));
}
if (ui->groupBoxSph->isChecked()) {
MeshCore::AbstractSurfaceFit* fitter;
if (sphereParameter.size() == 4) {
std::vector<float>& p = sphereParameter;
fitter = new MeshCore::SphereSurfaceFit(
Base::Vector3f(p[0],p[1],p[2]),
p[3]);
fitter = new MeshCore::SphereSurfaceFit(Base::Vector3f(p[0], p[1], p[2]), p[3]);
}
else {
fitter = new MeshCore::SphereSurfaceFit;
}
segm.emplace_back(std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>
(fitter, kernel, ui->numSph->value(), ui->tolSph->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>(fitter,
kernel,
ui->numSph->value(),
ui->tolSph->value()));
}
if (ui->groupBoxPln->isChecked()) {
MeshCore::AbstractSurfaceFit* fitter;
if (planeParameter.size() == 6) {
std::vector<float>& p = planeParameter;
fitter = new MeshCore::PlaneSurfaceFit(
Base::Vector3f(p[0],p[1],p[2]),
Base::Vector3f(p[3],p[4],p[5]));
fitter = new MeshCore::PlaneSurfaceFit(Base::Vector3f(p[0], p[1], p[2]),
Base::Vector3f(p[3], p[4], p[5]));
}
else {
fitter = new MeshCore::PlaneSurfaceFit;
}
segm.emplace_back(std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>
(fitter, kernel, ui->numPln->value(), ui->tolPln->value()));
segm.emplace_back(
std::make_shared<MeshCore::MeshDistanceGenericSurfaceFitSegment>(fitter,
kernel,
ui->numPln->value(),
ui->tolPln->value()));
}
finder.FindSegments(segm);
@@ -480,16 +507,17 @@ void SegmentationBestFit::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);
for (const auto & it : segm) {
for (const auto& it : segm) {
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
for (const auto & jt : data) {
for (const auto& jt : data) {
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();
@@ -503,7 +531,7 @@ void SegmentationBestFit::accept()
document->commitTransaction();
}
void SegmentationBestFit::changeEvent(QEvent *e)
void SegmentationBestFit::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
@@ -518,8 +546,7 @@ void SegmentationBestFit::changeEvent(QEvent *e)
TaskSegmentationBestFit::TaskSegmentationBestFit(Mesh::Feature* mesh)
{
widget = new SegmentationBestFit(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);
}

View File

@@ -23,28 +23,33 @@
#ifndef MESHGUI_SEGMENTATIONBESTFIT_H
#define MESHGUI_SEGMENTATIONBESTFIT_H
#include <list>
#include <QDialog>
#include <list>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <Mod/Mesh/MeshGlobal.h>
#include "MeshSelection.h"
#include <Mod/Mesh/MeshGlobal.h>
class QDoubleSpinBox;
// forward declarations
namespace Mesh { class Feature; }
namespace Mesh
{
class Feature;
}
namespace MeshGui {
namespace MeshGui
{
class Ui_SegmentationBestFit;
class FitParameter
{
public:
struct Points {
struct Points
{
std::vector<Base::Vector3f> points;
std::vector<Base::Vector3f> normals;
};
@@ -52,15 +57,17 @@ public:
virtual std::vector<float> getParameter(Points) const = 0;
};
using ParameterList = std::list<std::pair<QString, float> >;
class ParametersDialog : public QDialog
using ParameterList = std::list<std::pair<QString, float>>;
class ParametersDialog: public QDialog
{
Q_OBJECT
public:
ParametersDialog(std::vector<float>&, FitParameter*,
ParameterList, Mesh::Feature* mesh,
QWidget* parent=nullptr);
ParametersDialog(std::vector<float>&,
FitParameter*,
ParameterList,
Mesh::Feature* mesh,
QWidget* parent = nullptr);
~ParametersDialog() override;
void accept() override;
void reject() override;
@@ -80,17 +87,19 @@ private:
std::vector<QDoubleSpinBox*> spinBoxes;
};
class MeshGuiExport SegmentationBestFit : public QWidget
class MeshGuiExport SegmentationBestFit: public QWidget
{
Q_OBJECT
public:
explicit SegmentationBestFit(Mesh::Feature* mesh, QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
explicit SegmentationBestFit(Mesh::Feature* mesh,
QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags());
~SegmentationBestFit() override;
void accept();
protected:
void changeEvent(QEvent *e) override;
void changeEvent(QEvent* e) override;
private:
void setupConnections();
@@ -110,7 +119,7 @@ private:
/**
* Embed the panel into a task dialog.
*/
class TaskSegmentationBestFit : public Gui::TaskView::TaskDialog
class TaskSegmentationBestFit: public Gui::TaskView::TaskDialog
{
public:
explicit TaskSegmentationBestFit(Mesh::Feature* mesh);
@@ -119,13 +128,15 @@ public:
bool accept() override;
QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
{
return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
}
private:
SegmentationBestFit* widget;
Gui::TaskView::TaskBox* taskbox;
};
}
} // namespace MeshGui
#endif // MESHGUI_SEGMENTATIONBESTFIT_H
#endif // MESHGUI_SEGMENTATIONBESTFIT_H

View File

@@ -31,7 +31,8 @@ using namespace MeshGui;
/* TRANSLATOR MeshGui::Selection */
Selection::Selection(QWidget* parent)
: QWidget(parent), ui(new Ui_Selection())
: QWidget(parent)
, ui(new Ui_Selection())
{
ui->setupUi(this);
setupConnections();
@@ -56,6 +57,7 @@ Selection::~Selection()
void Selection::setupConnections()
{
// clang-format off
connect(ui->addSelection, &QPushButton::clicked,
this, &Selection::onAddSelectionClicked);
connect(ui->clearSelection, &QPushButton::clicked,
@@ -64,6 +66,7 @@ void Selection::setupConnections()
this, &Selection::onVisibleTrianglesToggled);
connect(ui->screenTriangles, &QPushButton::clicked,
this, &Selection::onScreenTrianglesToggled);
// clang-format on
}
void Selection::setObjects(const std::vector<Gui::SelectionObject>& o)

View File

@@ -23,18 +23,19 @@
#ifndef MESHGUI_SELECTION_H
#define MESHGUI_SELECTION_H
#include <vector>
#include <QWidget>
#include <vector>
#include <Gui/SelectionObject.h>
#include "MeshSelection.h"
namespace MeshGui {
namespace MeshGui
{
class Ui_Selection;
class Selection : public QWidget
class Selection: public QWidget
{
Q_OBJECT
@@ -57,6 +58,6 @@ private:
Ui_Selection* ui;
};
}
} // namespace MeshGui
#endif // MESHGUI_SELECTION_H
#endif // MESHGUI_SELECTION_H

File diff suppressed because it is too large Load Diff

View File

@@ -39,21 +39,24 @@ using GLuint = unsigned int;
using GLint = int;
using GLfloat = float;
namespace MeshGui {
namespace MeshGui
{
class MeshRenderer
{
public:
MeshRenderer();
~MeshRenderer();
void generateGLArrays(SoGLRenderAction*, SoMaterialBindingElement::Binding binding,
std::vector<float>& vertex, std::vector<int32_t>& index);
void renderFacesGLArray(SoGLRenderAction *action);
void renderCoordsGLArray(SoGLRenderAction *action);
bool canRenderGLArray(SoGLRenderAction *action) const;
void generateGLArrays(SoGLRenderAction*,
SoMaterialBindingElement::Binding binding,
std::vector<float>& vertex,
std::vector<int32_t>& index);
void renderFacesGLArray(SoGLRenderAction* action);
void renderCoordsGLArray(SoGLRenderAction* action);
bool canRenderGLArray(SoGLRenderAction* action) const;
bool matchMaterial(SoState*) const;
void update();
bool needUpdate(SoGLRenderAction *action);
bool needUpdate(SoGLRenderAction* action);
static bool shouldRenderDirectly(bool);
private:
@@ -68,7 +71,7 @@ private:
*
* @author Werner Mayer
*/
class MeshGuiExport SoFCMaterialEngine : public SoEngine
class MeshGuiExport SoFCMaterialEngine: public SoEngine
{
SO_ENGINE_HEADER(SoFCMaterialEngine);
@@ -82,7 +85,7 @@ public:
private:
~SoFCMaterialEngine() override;
void evaluate() override;
void inputChanged(SoField *) override;
void inputChanged(SoField*) override;
};
/**
@@ -92,7 +95,8 @@ private:
*
* @author Werner Mayer
*/
class MeshGuiExport SoFCIndexedFaceSet : public SoIndexedFaceSet {
class MeshGuiExport SoFCIndexedFaceSet: public SoIndexedFaceSet
{
using inherited = SoIndexedFaceSet;
SO_NODE_HEADER(SoFCIndexedFaceSet);
@@ -109,38 +113,37 @@ public:
protected:
// Force using the reference count mechanism.
~SoFCIndexedFaceSet() override = default;
void GLRender(SoGLRenderAction *action) override;
void drawFaces(SoGLRenderAction *action);
void drawCoords(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
void GLRender(SoGLRenderAction* action) override;
void drawFaces(SoGLRenderAction* action);
void drawCoords(const SoGLCoordinateElement* const vertexlist,
const int32_t* vertexindices,
int numindices,
const SbVec3f *normals,
const int32_t *normalindices,
SoMaterialBundle *materials,
const int32_t *matindices,
const SbVec3f* normals,
const int32_t* normalindices,
SoMaterialBundle* materials,
const int32_t* matindices,
const int32_t binding,
const SoTextureCoordinateBundle * const texcoords,
const int32_t *texindices);
const SoTextureCoordinateBundle* const texcoords,
const int32_t* texindices);
void doAction(SoAction * action) override;
void doAction(SoAction* action) override;
private:
void startSelection(SoAction * action);
void stopSelection(SoAction * action);
void renderSelectionGeometry(const SbVec3f *);
void startVisibility(SoAction * action);
void stopVisibility(SoAction * action);
void renderVisibleFaces(const SbVec3f *);
void startSelection(SoAction* action);
void stopSelection(SoAction* action);
void renderSelectionGeometry(const SbVec3f*);
void startVisibility(SoAction* action);
void stopVisibility(SoAction* action);
void renderVisibleFaces(const SbVec3f*);
void generateGLArrays(SoGLRenderAction * action);
void generateGLArrays(SoGLRenderAction* action);
private:
MeshRenderer render;
GLuint *selectBuf{nullptr};
GLuint* selectBuf {nullptr};
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_SOFCINDEXEDFACESET_H
#endif // MESHGUI_SOFCINDEXEDFACESET_H

File diff suppressed because it is too large Load Diff

View File

@@ -23,12 +23,12 @@
#ifndef MESHGUI_SOFCMESHOBJECT_H
#define MESHGUI_SOFCMESHOBJECT_H
#include <Inventor/fields/SoSField.h>
#include <Inventor/elements/SoReplacedElement.h>
#include <Inventor/fields/SoSFUInt32.h>
#include <Inventor/fields/SoSFVec3f.h>
#include <Inventor/fields/SoSFVec3s.h>
#include <Inventor/fields/SoSField.h>
#include <Inventor/nodes/SoShape.h>
#include <Inventor/elements/SoReplacedElement.h>
#include <Mod/Mesh/App/Mesh.h>
@@ -36,14 +36,21 @@ using GLuint = unsigned int;
using GLint = int;
using GLfloat = float;
namespace MeshCore { class MeshFacetGrid; }
namespace MeshCore
{
class MeshFacetGrid;
}
namespace MeshGui {
namespace MeshGui
{
class MeshGuiExport SoSFMeshObject : public SoSField {
class MeshGuiExport SoSFMeshObject: public SoSField
{
using inherited = SoSField;
SO_SFIELD_HEADER(SoSFMeshObject, Base::Reference<const Mesh::MeshObject>, Base::Reference<const Mesh::MeshObject>)
SO_SFIELD_HEADER(SoSFMeshObject,
Base::Reference<const Mesh::MeshObject>,
Base::Reference<const Mesh::MeshObject>)
public:
static void initClass();
@@ -53,7 +60,8 @@ public:
// -------------------------------------------------------
class MeshGuiExport SoFCMeshObjectElement : public SoReplacedElement {
class MeshGuiExport SoFCMeshObjectElement: public SoReplacedElement
{
using inherited = SoReplacedElement;
SO_ELEMENT_HEADER(SoFCMeshObjectElement);
@@ -61,20 +69,21 @@ class MeshGuiExport SoFCMeshObjectElement : public SoReplacedElement {
public:
static void initClass();
void init(SoState * state) override;
static void set(SoState * const state, SoNode * const node, const Mesh::MeshObject * const mesh);
static const Mesh::MeshObject * get(SoState * const state);
static const SoFCMeshObjectElement * getInstance(SoState * state);
void print(FILE * file) const override;
void init(SoState* state) override;
static void set(SoState* const state, SoNode* const node, const Mesh::MeshObject* const mesh);
static const Mesh::MeshObject* get(SoState* const state);
static const SoFCMeshObjectElement* getInstance(SoState* state);
void print(FILE* file) const override;
protected:
~SoFCMeshObjectElement() override;
const Mesh::MeshObject *mesh;
const Mesh::MeshObject* mesh;
};
// -------------------------------------------------------
class MeshGuiExport SoFCMeshPickNode : public SoNode {
class MeshGuiExport SoFCMeshPickNode: public SoNode
{
using inherited = SoNode;
SO_NODE_HEADER(SoFCMeshPickNode);
@@ -82,23 +91,24 @@ class MeshGuiExport SoFCMeshPickNode : public SoNode {
public:
static void initClass();
SoFCMeshPickNode();
void notify(SoNotList *) override;
void notify(SoNotList*) override;
SoSFMeshObject mesh;
void rayPick(SoRayPickAction * action) override;
void pick(SoPickAction * action) override;
void rayPick(SoRayPickAction* action) override;
void pick(SoPickAction* action) override;
protected:
~SoFCMeshPickNode() override;
private:
MeshCore::MeshFacetGrid* meshGrid{nullptr};
MeshCore::MeshFacetGrid* meshGrid {nullptr};
};
// -------------------------------------------------------
class MeshGuiExport SoFCMeshGridNode : public SoNode {
class MeshGuiExport SoFCMeshGridNode: public SoNode
{
using inherited = SoNode;
SO_NODE_HEADER(SoFCMeshGridNode);
@@ -106,7 +116,7 @@ class MeshGuiExport SoFCMeshGridNode : public SoNode {
public:
static void initClass();
SoFCMeshGridNode();
void GLRender(SoGLRenderAction * action) override;
void GLRender(SoGLRenderAction* action) override;
SoSFVec3f minGrid;
SoSFVec3f maxGrid;
@@ -118,7 +128,8 @@ protected:
// -------------------------------------------------------
class MeshGuiExport SoFCMeshObjectNode : public SoNode {
class MeshGuiExport SoFCMeshObjectNode: public SoNode
{
using inherited = SoNode;
SO_NODE_HEADER(SoFCMeshObjectNode);
@@ -129,12 +140,12 @@ public:
SoSFMeshObject mesh;
void doAction(SoAction * action) override;
void GLRender(SoGLRenderAction * action) override;
void callback(SoCallbackAction * action) override;
void getBoundingBox(SoGetBoundingBoxAction * action) override;
void pick(SoPickAction * action) override;
void getPrimitiveCount(SoGetPrimitiveCountAction * action) override;
void doAction(SoAction* action) override;
void GLRender(SoGLRenderAction* action) override;
void callback(SoCallbackAction* action) override;
void getBoundingBox(SoGetBoundingBoxAction* action) override;
void pick(SoPickAction* action) override;
void getPrimitiveCount(SoGetPrimitiveCountAction* action) override;
protected:
~SoFCMeshObjectNode() override;
@@ -160,7 +171,8 @@ protected:
*
* @author Werner Mayer
*/
class MeshGuiExport SoFCMeshObjectShape : public SoShape {
class MeshGuiExport SoFCMeshObjectShape: public SoShape
{
using inherited = SoShape;
SO_NODE_HEADER(SoFCMeshObjectShape);
@@ -172,22 +184,23 @@ public:
unsigned int renderTriangleLimit;
protected:
void doAction(SoAction * action) override;
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction * action) override;
void rayPick (SoRayPickAction *action) override;
void generatePrimitives(SoAction *action) override;
SoDetail * createTriangleDetail(SoRayPickAction * action,
const SoPrimitiveVertex * v1,
const SoPrimitiveVertex * v2,
const SoPrimitiveVertex * v3,
SoPickedPoint * pp) override;
void doAction(SoAction* action) override;
void GLRender(SoGLRenderAction* action) override;
void computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction* action) override;
void rayPick(SoRayPickAction* action) override;
void generatePrimitives(SoAction* action) override;
SoDetail* createTriangleDetail(SoRayPickAction* action,
const SoPrimitiveVertex* v1,
const SoPrimitiveVertex* v2,
const SoPrimitiveVertex* v3,
SoPickedPoint* pp) override;
// Force using the reference count mechanism.
~SoFCMeshObjectShape() override;
private:
enum Binding {
enum Binding
{
OVERALL = 0,
PER_FACE_INDEXED,
PER_VERTEX_INDEXED,
@@ -195,33 +208,37 @@ private:
};
private:
void notify(SoNotList * list) override;
Binding findMaterialBinding(SoState * const state) const;
void notify(SoNotList* list) override;
Binding findMaterialBinding(SoState* const state) const;
// Draw faces
void drawFaces(const Mesh::MeshObject *, SoMaterialBundle* mb, Binding bind,
SbBool needNormals, SbBool ccw) const;
void drawPoints(const Mesh::MeshObject *, SbBool needNormals, SbBool ccw) const;
unsigned int countTriangles(SoAction * action) const;
void drawFaces(const Mesh::MeshObject*,
SoMaterialBundle* mb,
Binding bind,
SbBool needNormals,
SbBool ccw) const;
void drawPoints(const Mesh::MeshObject*, SbBool needNormals, SbBool ccw) const;
unsigned int countTriangles(SoAction* action) const;
void startSelection(SoAction * action, const Mesh::MeshObject*);
void stopSelection(SoAction * action, const Mesh::MeshObject*);
void startSelection(SoAction* action, const Mesh::MeshObject*);
void stopSelection(SoAction* action, const Mesh::MeshObject*);
void renderSelectionGeometry(const Mesh::MeshObject*);
void generateGLArrays(SoState * state);
void renderFacesGLArray(SoGLRenderAction *action);
void renderCoordsGLArray(SoGLRenderAction *action);
void generateGLArrays(SoState* state);
void renderFacesGLArray(SoGLRenderAction* action);
void renderCoordsGLArray(SoGLRenderAction* action);
private:
GLuint *selectBuf{nullptr};
GLfloat modelview[16]{};
GLfloat projection[16]{};
GLuint* selectBuf {nullptr};
GLfloat modelview[16] {};
GLfloat projection[16] {};
// Vertex array handling
std::vector<int32_t> index_array;
std::vector<float> vertex_array;
SbBool updateGLArray{false};
SbBool updateGLArray {false};
};
class MeshGuiExport SoFCMeshSegmentShape : public SoShape {
class MeshGuiExport SoFCMeshSegmentShape: public SoShape
{
using inherited = SoShape;
SO_NODE_HEADER(SoFCMeshSegmentShape);
@@ -234,15 +251,16 @@ public:
unsigned int renderTriangleLimit;
protected:
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction * action) override;
void generatePrimitives(SoAction *action) override;
void GLRender(SoGLRenderAction* action) override;
void computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction* action) override;
void generatePrimitives(SoAction* action) override;
// Force using the reference count mechanism.
~SoFCMeshSegmentShape() override = default;
private:
enum Binding {
enum Binding
{
OVERALL = 0,
PER_FACE_INDEXED,
PER_VERTEX_INDEXED,
@@ -250,14 +268,18 @@ private:
};
private:
Binding findMaterialBinding(SoState * const state) const;
Binding findMaterialBinding(SoState* const state) const;
// Draw faces
void drawFaces(const Mesh::MeshObject *, SoMaterialBundle* mb, Binding bind,
SbBool needNormals, SbBool ccw) const;
void drawPoints(const Mesh::MeshObject *, SbBool needNormals, SbBool ccw) const;
void drawFaces(const Mesh::MeshObject*,
SoMaterialBundle* mb,
Binding bind,
SbBool needNormals,
SbBool ccw) const;
void drawPoints(const Mesh::MeshObject*, SbBool needNormals, SbBool ccw) const;
};
class MeshGuiExport SoFCMeshObjectBoundary : public SoShape {
class MeshGuiExport SoFCMeshObjectBoundary: public SoShape
{
using inherited = SoShape;
SO_NODE_HEADER(SoFCMeshObjectBoundary);
@@ -267,19 +289,18 @@ public:
SoFCMeshObjectBoundary();
protected:
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction * action) override;
void generatePrimitives(SoAction *action) override;
void GLRender(SoGLRenderAction* action) override;
void computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center) override;
void getPrimitiveCount(SoGetPrimitiveCountAction* action) override;
void generatePrimitives(SoAction* action) override;
// Force using the reference count mechanism.
~SoFCMeshObjectBoundary() override = default;
private:
void drawLines(const Mesh::MeshObject *) const ;
void drawLines(const Mesh::MeshObject*) const;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_SOFCMESHOBJECT_H
#endif // MESHGUI_SOFCMESHOBJECT_H

View File

@@ -22,23 +22,23 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <Windows.h>
# endif
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# endif
# include <algorithm>
# include <cfloat>
#ifdef FC_OS_WIN32
#include <Windows.h>
#endif
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include <algorithm>
#include <cfloat>
# include <Inventor/actions/SoGLRenderAction.h>
# include <Inventor/bundles/SoMaterialBundle.h>
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
# include <Inventor/elements/SoCoordinateElement.h>
# include <Inventor/elements/SoLazyElement.h>
# include <Inventor/misc/SoState.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/bundles/SoMaterialBundle.h>
#include <Inventor/bundles/SoTextureCoordinateBundle.h>
#include <Inventor/elements/SoCoordinateElement.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/misc/SoState.h>
#endif
#include "SoPolygon.h"
@@ -66,17 +66,18 @@ SoPolygon::SoPolygon()
/**
* Renders the polygon.
*/
void SoPolygon::GLRender(SoGLRenderAction *action)
void SoPolygon::GLRender(SoGLRenderAction* action)
{
if (shouldGLRender(action) && render.getValue())
{
SoState* state = action->getState();
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
if (!coords)
if (shouldGLRender(action) && render.getValue()) {
SoState* state = action->getState();
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
if (!coords) {
return;
const SbVec3f * points = coords->getArrayPtr3();
if (!points)
}
const SbVec3f* points = coords->getArrayPtr3();
if (!points) {
return;
}
SoMaterialBundle mb(action);
SoTextureCoordinateBundle tb(action, true, false);
@@ -91,18 +92,19 @@ void SoPolygon::GLRender(SoGLRenderAction *action)
/**
* Renders the polygon.
*/
void SoPolygon::drawPolygon(const SbVec3f * points,int32_t len) const
void SoPolygon::drawPolygon(const SbVec3f* points, int32_t len) const
{
glLineWidth(3.0f);
int32_t beg = startIndex.getValue();
int32_t cnt = numVertices.getValue();
int32_t end = beg + cnt;
if (end > len)
return; // wrong setup, too few points
if (end > len) {
return; // wrong setup, too few points
}
// draw control mesh
glBegin(GL_LINES);
for (int32_t i = beg; i < end; ++i) {
int32_t j = (i-beg+1) % cnt + beg;
int32_t j = (i - beg + 1) % cnt + beg;
glVertex3fv(points[i].getValue());
glVertex3fv(points[j].getValue());
}
@@ -112,11 +114,10 @@ void SoPolygon::drawPolygon(const SbVec3f * points,int32_t len) const
/**
* Calculates picked point based on primitives generated by subclasses.
*/
void
SoPolygon::rayPick(SoRayPickAction * action)
void SoPolygon::rayPick(SoRayPickAction* action)
{
//if (this->shouldRayPick(action)) {
// this->computeObjectSpaceRay(action);
// if (this->shouldRayPick(action)) {
// this->computeObjectSpaceRay(action);
// const SoBoundingBoxCache* bboxcache = getBoundingBoxCache();
// if (!bboxcache || !bboxcache->isValid(action->getState()) ||
@@ -128,43 +129,43 @@ SoPolygon::rayPick(SoRayPickAction * action)
}
void SoPolygon::generatePrimitives(SoAction* /*action*/)
{
}
{}
/**
* Sets the bounding box of the mesh to \a box and its center to \a center.
*/
void SoPolygon::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
void SoPolygon::computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center)
{
SoState* state = action->getState();
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
if (!coords)
SoState* state = action->getState();
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
if (!coords) {
return;
const SbVec3f * points = coords->getArrayPtr3();
if (!points)
}
const SbVec3f* points = coords->getArrayPtr3();
if (!points) {
return;
float maxX=-FLT_MAX, minX=FLT_MAX,
maxY=-FLT_MAX, minY=FLT_MAX,
maxZ=-FLT_MAX, minZ=FLT_MAX;
}
float maxX = -FLT_MAX, minX = FLT_MAX, maxY = -FLT_MAX, minY = FLT_MAX, maxZ = -FLT_MAX,
minZ = FLT_MAX;
int32_t len = coords->getNum();
int32_t beg = startIndex.getValue();
int32_t cnt = numVertices.getValue();
int32_t end = beg + cnt;
if (end <= len) {
for (int32_t i=beg; i<end; i++) {
maxX = std::max<float>(maxX,points[i][0]);
minX = std::min<float>(minX,points[i][0]);
maxY = std::max<float>(maxY,points[i][1]);
minY = std::min<float>(minY,points[i][1]);
maxZ = std::max<float>(maxZ,points[i][2]);
minZ = std::min<float>(minZ,points[i][2]);
for (int32_t i = beg; i < end; i++) {
maxX = std::max<float>(maxX, points[i][0]);
minX = std::min<float>(minX, points[i][0]);
maxY = std::max<float>(maxY, points[i][1]);
minY = std::min<float>(minY, points[i][1]);
maxZ = std::max<float>(maxZ, points[i][2]);
minZ = std::min<float>(minZ, points[i][2]);
}
box.setBounds(minX,minY,minZ,maxX,maxY,maxZ);
center.setValue(0.5f*(minX+maxX),0.5f*(minY+maxY),0.5f*(minZ+maxZ));
box.setBounds(minX, minY, minZ, maxX, maxY, maxZ);
center.setValue(0.5f * (minX + maxX), 0.5f * (minY + maxY), 0.5f * (minZ + maxZ));
}
else {
box.setBounds(SbVec3f(0,0,0), SbVec3f(0,0,0));
center.setValue(0.0f,0.0f,0.0f);
box.setBounds(SbVec3f(0, 0, 0), SbVec3f(0, 0, 0));
center.setValue(0.0f, 0.0f, 0.0f);
}
}

View File

@@ -28,13 +28,15 @@
#include <Inventor/fields/SoSFInt32.h>
#include <Inventor/nodes/SoShape.h>
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
namespace MeshGui {
namespace MeshGui
{
class MeshGuiExport SoPolygon : public SoShape {
class MeshGuiExport SoPolygon: public SoShape
{
using inherited = SoShape;
SO_NODE_HEADER(SoPolygon);
@@ -45,22 +47,21 @@ public:
SoSFInt32 startIndex;
SoSFInt32 numVertices;
SoSFBool highlight;
SoSFBool render;
SoSFBool highlight;
SoSFBool render;
protected:
~SoPolygon() override = default;
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void rayPick (SoRayPickAction *action) override;
void generatePrimitives(SoAction *action) override;
void GLRender(SoGLRenderAction* action) override;
void computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center) override;
void rayPick(SoRayPickAction* action) override;
void generatePrimitives(SoAction* action) override;
private:
void drawPolygon(const SbVec3f *,int32_t) const;
void drawPolygon(const SbVec3f*, int32_t) const;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_SOPOLYGON_H
#endif // MESHGUI_SOPOLYGON_H

View File

@@ -22,16 +22,16 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QBuffer>
# include <QByteArray>
#include <QBuffer>
#include <QByteArray>
# include <Inventor/SbRotation.h>
# include <Inventor/SbViewportRegion.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDirectionalLight.h>
# include <Inventor/nodes/SoIndexedFaceSet.h>
# include <Inventor/nodes/SoOrthographicCamera.h>
# include <Inventor/nodes/SoSeparator.h>
#include <Inventor/SbRotation.h>
#include <Inventor/SbViewportRegion.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
#include <Inventor/nodes/SoSeparator.h>
#endif
#include <Gui/SoFCOffscreenRenderer.h>
@@ -42,7 +42,7 @@
using namespace MeshGui;
Mesh::Extension3MF::Resource ThumbnailExtension3MF::addMesh(const Mesh::MeshObject &mesh)
Mesh::Extension3MF::Resource ThumbnailExtension3MF::addMesh(const Mesh::MeshObject& mesh)
{
SoCoordinate3* coord = new SoCoordinate3();
SoIndexedFaceSet* faces = new SoIndexedFaceSet();
@@ -78,7 +78,8 @@ Mesh::Extension3MF::Resource ThumbnailExtension3MF::addMesh(const Mesh::MeshObje
Mesh::Extension3MF::Resource res;
res.extension = "png";
res.contentType = "image/png";
res.relationshipType = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
res.relationshipType =
"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
res.fileContent = std::string(data.data(), data.size());
setContentName(res);

View File

@@ -23,14 +23,16 @@
#ifndef MESHGUI_THUMBNAIL_EXTENSION_H
#define MESHGUI_THUMBNAIL_EXTENSION_H
#include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/App/Exporter.h>
#include <Mod/Mesh/MeshGlobal.h>
namespace MeshGui {
namespace MeshGui
{
class ThumbnailExtension3MF : public Mesh::Extension3MF {
class ThumbnailExtension3MF: public Mesh::Extension3MF
{
public:
Mesh::Extension3MF::Resource addMesh(const Mesh::MeshObject & mesh) override;
Mesh::Extension3MF::Resource addMesh(const Mesh::MeshObject& mesh) override;
private:
void setContentName(Mesh::Extension3MF::Resource&);
@@ -39,15 +41,18 @@ private:
int index = 0;
};
class ThumbnailExtensionProducer : public Mesh::Extension3MFProducer {
class ThumbnailExtensionProducer: public Mesh::Extension3MFProducer
{
public:
Mesh::AbstractFormatExtensionPtr create() const override {
Mesh::AbstractFormatExtensionPtr create() const override
{
return std::make_shared<ThumbnailExtension3MF>();
}
void initialize() override {}
void initialize() override
{}
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_THUMBNAIL_EXTENSION_H
#endif // MESHGUI_THUMBNAIL_EXTENSION_H

File diff suppressed because it is too large Load Diff

View File

@@ -27,8 +27,8 @@
#include <Gui/ViewProviderBuilder.h>
#include <Gui/ViewProviderGeometryObject.h>
#include <Mod/Mesh/App/Types.h>
#include <Mod/Mesh/App/Core/Elements.h>
#include <Mod/Mesh/App/Types.h>
class SoGroup;
@@ -49,35 +49,41 @@ class SbVec2f;
class SbBox2s;
class SbPlane;
namespace App {
class Color;
class PropertyColorList;
namespace App
{
class Color;
class PropertyColorList;
} // namespace App
namespace Base
{
class ViewProjMethod;
}
namespace Base {
class ViewProjMethod;
}
namespace Gui {
class View3DInventorViewer;
class SoFCSelection;
}
namespace Gui
{
class View3DInventorViewer;
class SoFCSelection;
} // namespace Gui
namespace MeshCore {
class MeshKernel;
struct Material;
}
namespace MeshCore
{
class MeshKernel;
struct Material;
} // namespace MeshCore
namespace Mesh {
namespace Mesh
{
class PropertyMaterial;
}
namespace MeshGui {
namespace MeshGui
{
class SoFCMeshObjectNode;
class SoFCMeshObjectShape;
class MeshGuiExport ViewProviderMeshBuilder : public Gui::ViewProviderBuilder
class MeshGuiExport ViewProviderMeshBuilder: public Gui::ViewProviderBuilder
{
public:
ViewProviderMeshBuilder() = default;
@@ -90,7 +96,7 @@ public:
* The ViewProviderExport class creates an empty node.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderExport : public Gui::ViewProviderDocumentObject
class MeshGuiExport ViewProviderExport: public Gui::ViewProviderDocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderExport);
@@ -99,7 +105,10 @@ public:
~ViewProviderExport() override;
QIcon getIcon() const override;
SoSeparator* getRoot() const override {return nullptr;}
SoSeparator* getRoot() const override
{
return nullptr;
}
std::vector<std::string> getDisplayModes() const override;
const char* getDefaultDisplayMode() const override;
};
@@ -109,7 +118,7 @@ public:
* and many algorithms to work on or edit the mesh.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMesh : public Gui::ViewProviderGeometryObject
class MeshGuiExport ViewProviderMesh: public Gui::ViewProviderGeometryObject
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMesh);
@@ -127,24 +136,33 @@ public:
App::PropertyEnumeration Lighting;
App::PropertyColor LineColor;
void attach(App::DocumentObject *) override;
void attach(App::DocumentObject*) override;
void updateData(const App::Property*) override;
bool useNewSelectionModel() const override {return false;}
Gui::SoFCSelection* getHighlightNode() const { return pcHighlight; }
bool useNewSelectionModel() const override
{
return false;
}
Gui::SoFCSelection* getHighlightNode() const
{
return pcHighlight;
}
QIcon getIcon() const override;
/// Sets the correct display mode
void setDisplayMode(const char* ModeName) override;
/// returns a list of all possible modes
std::vector<std::string> getDisplayModes() const override;
bool exportToVrml(const char* filename, const MeshCore::Material&, bool binary=false) const;
void exportMesh(const char* filename, const char* fmt=nullptr) const;
bool exportToVrml(const char* filename, const MeshCore::Material&, bool binary = false) const;
void exportMesh(const char* filename, const char* fmt = nullptr) const;
void setupContextMenu(QMenu*, QObject*, const char*) override;
/// Get the python wrapper for that ViewProvider
PyObject* getPyObject() override;
/** @name Editing */
//@{
bool doubleClicked() override{ return false; }
bool doubleClicked() override
{
return false;
}
bool isFacetSelected(Mesh::FacetIndex facet);
void selectComponent(Mesh::FacetIndex facet);
void deselectComponent(Mesh::FacetIndex facet);
@@ -158,13 +176,18 @@ public:
void deleteSelection();
bool hasSelection() const;
void getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
const Base::ViewProjMethod& proj, SbBool inner,
const Base::ViewProjMethod& proj,
SbBool inner,
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>
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
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 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. */
@@ -182,8 +205,10 @@ protected:
void onChanged(const App::Property* prop) override;
virtual void showOpenEdges(bool);
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
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(Mesh::FacetIndex facet);
virtual void fillHole(Mesh::FacetIndex facet);
virtual void selectArea(short, short, short, short, const SbViewportRegion&, SoCamera*);
@@ -212,42 +237,45 @@ protected:
virtual SoNode* getCoordNode() const;
public:
static void faceInfoCallback(void * ud, SoEventCallback * n);
static void fillHoleCallback(void * ud, SoEventCallback * n);
static void markPartCallback(void * ud, SoEventCallback * n);
static void clipMeshCallback(void * ud, SoEventCallback * n);
static void trimMeshCallback(void * ud, SoEventCallback * n);
static void partMeshCallback(void * ud, SoEventCallback * n);
static void segmMeshCallback(void * ud, SoEventCallback * n);
static void selectGLCallback(void * ud, SoEventCallback * n);
static void faceInfoCallback(void* ud, SoEventCallback* n);
static void fillHoleCallback(void* ud, SoEventCallback* n);
static void markPartCallback(void* ud, SoEventCallback* n);
static void clipMeshCallback(void* ud, SoEventCallback* n);
static void trimMeshCallback(void* ud, SoEventCallback* n);
static void partMeshCallback(void* ud, SoEventCallback* n);
static void segmMeshCallback(void* ud, SoEventCallback* n);
static void selectGLCallback(void* ud, SoEventCallback* n);
/// Creates a tool mesh from the previous picked polygon on the viewer
static bool createToolMesh(const std::vector<SbVec2f>& rclPoly, const SbViewVolume& vol,
const Base::Vector3f& rcNormal, std::vector<MeshCore::MeshGeomFacet>&);
static bool createToolMesh(const std::vector<SbVec2f>& rclPoly,
const SbViewVolume& vol,
const Base::Vector3f& rcNormal,
std::vector<MeshCore::MeshGeomFacet>&);
private:
static void renderGLCallback(void * ud, SoAction * a);
static void boxZoom(const SbBox2s& box, const SbViewportRegion & vp, SoCamera* cam);
static void renderGLCallback(void* ud, SoAction* a);
static void boxZoom(const SbBox2s& box, const SbViewportRegion& vp, SoCamera* cam);
static void panCamera(SoCamera*, float, const SbPlane&, const SbVec2f&, const SbVec2f&);
protected:
enum class HighlighMode {
enum class HighlighMode
{
None,
Component,
Segment,
Color
};
//NOLINTBEGIN
// NOLINTBEGIN
HighlighMode highlightMode;
Gui::SoFCSelection * pcHighlight{nullptr};
SoGroup * pcShapeGroup{nullptr};
SoDrawStyle * pcLineStyle{nullptr};
SoDrawStyle * pcPointStyle{nullptr};
SoSeparator * pcOpenEdge{nullptr};
SoBaseColor * pOpenColor{nullptr};
SoMaterial * pLineColor{nullptr};
SoShapeHints * pShapeHints{nullptr};
SoMaterialBinding * pcMatBinding{nullptr};
//NOLINTEND
Gui::SoFCSelection* pcHighlight {nullptr};
SoGroup* pcShapeGroup {nullptr};
SoDrawStyle* pcLineStyle {nullptr};
SoDrawStyle* pcPointStyle {nullptr};
SoSeparator* pcOpenEdge {nullptr};
SoBaseColor* pOpenColor {nullptr};
SoMaterial* pLineColor {nullptr};
SoShapeHints* pShapeHints {nullptr};
SoMaterialBinding* pcMatBinding {nullptr};
// NOLINTEND
private:
static App::PropertyFloatConstraint::Constraints floatRange;
@@ -261,7 +289,7 @@ private:
* to render the mesh data structure.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderIndexedFaceSet : public ViewProviderMesh
class MeshGuiExport ViewProviderIndexedFaceSet: public ViewProviderMesh
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderIndexedFaceSet);
@@ -269,7 +297,7 @@ public:
ViewProviderIndexedFaceSet();
~ViewProviderIndexedFaceSet() override;
void attach(App::DocumentObject *) override;
void attach(App::DocumentObject*) override;
/// Update the Mesh representation
void updateData(const App::Property*) override;
@@ -279,8 +307,8 @@ protected:
SoNode* getCoordNode() const override;
private:
SoCoordinate3 * pcMeshCoord;
SoIndexedFaceSet * pcMeshFaces;
SoCoordinate3* pcMeshCoord;
SoIndexedFaceSet* pcMeshFaces;
};
/**
@@ -288,7 +316,7 @@ private:
* to directly render the mesh data structure.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshObject : public ViewProviderMesh
class MeshGuiExport ViewProviderMeshObject: public ViewProviderMesh
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshObject);
@@ -296,7 +324,7 @@ public:
ViewProviderMeshObject();
~ViewProviderMeshObject() override;
void attach(App::DocumentObject *pcFeat) override;
void attach(App::DocumentObject* pcFeat) override;
void updateData(const App::Property*) override;
protected:
@@ -305,12 +333,11 @@ protected:
void showOpenEdges(bool) override;
private:
SoFCMeshObjectNode * pcMeshNode;
SoFCMeshObjectShape * pcMeshShape;
SoFCMeshObjectNode* pcMeshNode;
SoFCMeshObjectShape* pcMeshShape;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDERMESH_H
#endif // MESHGUI_VIEWPROVIDERMESH_H

View File

@@ -22,26 +22,26 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <algorithm>
# include <iomanip>
# include <ios>
# include <sstream>
# include <QCursor>
# include <QMenu>
#include <QCursor>
#include <QMenu>
#include <algorithm>
#include <iomanip>
#include <ios>
#include <sstream>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/actions/SoSearchAction.h>
# include <Inventor/events/SoLocation2Event.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedFaceSet.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoShapeHints.h>
# include <Inventor/sensors/SoIdleSensor.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/actions/SoSearchAction.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/events/SoLocation2Event.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoShapeHints.h>
#include <Inventor/sensors/SoIdleSensor.h>
#endif
# include <boost/range/adaptors.hpp>
#include <boost/range/adaptors.hpp>
#include <App/Annotation.h>
#include <App/Document.h>
@@ -114,8 +114,8 @@ ViewProviderMeshCurvature::ViewProviderMeshCurvature()
mat.transparency = trans[0];
}
ADD_PROPERTY(TextureMaterial,(mat));
SelectionStyle.setValue(1); // BBOX
ADD_PROPERTY(TextureMaterial, (mat));
SelectionStyle.setValue(1); // BBOX
}
ViewProviderMeshCurvature::~ViewProviderMeshCurvature()
@@ -131,9 +131,15 @@ void ViewProviderMeshCurvature::onChanged(const App::Property* prop)
{
if (prop == &TextureMaterial) {
const App::Material& Mat = TextureMaterial.getValue();
pcColorMat->ambientColor.setValue(Mat.ambientColor.r,Mat.ambientColor.g,Mat.ambientColor.b);
pcColorMat->specularColor.setValue(Mat.specularColor.r,Mat.specularColor.g,Mat.specularColor.b);
pcColorMat->emissiveColor.setValue(Mat.emissiveColor.r,Mat.emissiveColor.g,Mat.emissiveColor.b);
pcColorMat->ambientColor.setValue(Mat.ambientColor.r,
Mat.ambientColor.g,
Mat.ambientColor.b);
pcColorMat->specularColor.setValue(Mat.specularColor.r,
Mat.specularColor.g,
Mat.specularColor.b);
pcColorMat->emissiveColor.setValue(Mat.emissiveColor.r,
Mat.emissiveColor.g,
Mat.emissiveColor.b);
pcColorMat->shininess.setValue(Mat.shininess);
pcColorMat->transparency.setValue(Mat.transparency);
}
@@ -160,58 +166,62 @@ void ViewProviderMeshCurvature::init(const Mesh::PropertyCurvatureList* pCurvInf
aMinValues.reserve(fCurvInfo.size());
aMaxValues.reserve(fCurvInfo.size());
for (const auto & jt : fCurvInfo) {
aMinValues.push_back( jt.fMinCurvature );
aMaxValues.push_back( jt.fMaxCurvature );
for (const auto& jt : fCurvInfo) {
aMinValues.push_back(jt.fMinCurvature);
aMaxValues.push_back(jt.fMaxCurvature);
}
if ( aMinValues.empty() || aMaxValues.empty() )
return; // no values inside
if (aMinValues.empty() || aMaxValues.empty()) {
return; // no values inside
}
float fMin = *std::min_element( aMinValues.begin(), aMinValues.end() );
float fMax = *std::max_element( aMinValues.begin(), aMinValues.end() );
float fMin = *std::min_element(aMinValues.begin(), aMinValues.end());
float fMax = *std::max_element(aMinValues.begin(), aMinValues.end());
// histogram over all values
std::map<int, int> aHistogram;
for (float aMinValue : aMinValues) {
int grp = (int)(10.0f*( aMinValue - fMin )/( fMax - fMin ));
int grp = (int)(10.0f * (aMinValue - fMin) / (fMax - fMin));
aHistogram[grp]++;
}
float fRMin=-1.0f;
for (const auto & mIt : aHistogram) {
if ( (float)mIt.second / (float)aMinValues.size() > 0.15f ) {
fRMin = mIt.first * ( fMax - fMin )/10.0f + fMin;
float fRMin = -1.0f;
for (const auto& mIt : aHistogram) {
if ((float)mIt.second / (float)aMinValues.size() > 0.15f) {
fRMin = mIt.first * (fMax - fMin) / 10.0f + fMin;
break;
}
}
fMin = *std::min_element( aMaxValues.begin(), aMaxValues.end() );
fMax = *std::max_element( aMaxValues.begin(), aMaxValues.end() );
fMin = *std::min_element(aMaxValues.begin(), aMaxValues.end());
fMax = *std::max_element(aMaxValues.begin(), aMaxValues.end());
// histogram over all values
aHistogram.clear();
for (float aMaxValue : aMaxValues) {
int grp = (int)(10.0f*( aMaxValue - fMin )/( fMax - fMin ));
int grp = (int)(10.0f * (aMaxValue - fMin) / (fMax - fMin));
aHistogram[grp]++;
}
float fRMax=1.0f;
for ( std::map<int, int>::reverse_iterator rIt2 = aHistogram.rbegin(); rIt2 != aHistogram.rend(); ++rIt2 ) {
if ( (float)rIt2->second / (float)aMaxValues.size() > 0.15f ) {
fRMax = rIt2->first * ( fMax - fMin )/10.0f + fMin;
float fRMax = 1.0f;
for (std::map<int, int>::reverse_iterator rIt2 = aHistogram.rbegin(); rIt2 != aHistogram.rend();
++rIt2) {
if ((float)rIt2->second / (float)aMaxValues.size() > 0.15f) {
fRMax = rIt2->first * (fMax - fMin) / 10.0f + fMin;
break;
}
}
float fAbs = std::max<float>(fabs(fRMin), fabs(fRMax));
fRMin = -fAbs;
fRMax = fAbs;
fMin = fRMin; fMax = fRMax;
pcColorBar->setRange( fMin, fMax, 3 );
fRMax = fAbs;
fMin = fRMin;
fMax = fRMax;
pcColorBar->setRange(fMin, fMax, 3);
}
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj,
const App::Property& Prop)
{
// we get this for any object for that a property has changed. Thus, we must regard that object
// which is linked by our link property
@@ -222,26 +232,27 @@ void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj
const Mesh::MeshObject& kernel = mesh.getValue();
pcColorMat->diffuseColor.setNum((int)kernel.countPoints());
pcColorMat->transparency.setNum((int)kernel.countPoints());
static_cast<Mesh::Curvature*>(pcObject)->Source.touch(); // make sure to recompute the feature
static_cast<Mesh::Curvature*>(pcObject)
->Source.touch(); // make sure to recompute the feature
}
}
}
void ViewProviderMeshCurvature::attach(App::DocumentObject *pcFeat)
void ViewProviderMeshCurvature::attach(App::DocumentObject* pcFeat)
{
// creates the standard viewing modes
inherited::attach(pcFeat);
attachDocument(pcFeat->getDocument());
SoShapeHints * flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
SoShapeHints* flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
SoGroup* pcColorShadedRoot = new SoGroup();
pcColorShadedRoot->addChild(flathints);
// color shaded
SoDrawStyle *pcFlatStyle = new SoDrawStyle();
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
pcFlatStyle->style = SoDrawStyle::FILLED;
pcColorShadedRoot->addChild(pcFlatStyle);
@@ -254,8 +265,9 @@ void ViewProviderMeshCurvature::attach(App::DocumentObject *pcFeat)
addDisplayMaskMode(pcColorShadedRoot, "ColorShaded");
// Check for an already existing color bar
Gui::SoFCColorBar* pcBar = ((Gui::SoFCColorBar*)findFrontRootOfType( Gui::SoFCColorBar::getClassTypeId() ));
if ( pcBar ) {
Gui::SoFCColorBar* pcBar =
((Gui::SoFCColorBar*)findFrontRootOfType(Gui::SoFCColorBar::getClassTypeId()));
if (pcBar) {
float fMin = pcColorBar->getMinValue();
float fMax = pcColorBar->getMaxValue();
@@ -276,7 +288,8 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
{
// set to the expected size
if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
Mesh::Feature* object = static_cast<const App::PropertyLink*>(prop)->getValue<Mesh::Feature*>();
Mesh::Feature* object =
static_cast<const App::PropertyLink*>(prop)->getValue<Mesh::Feature*>();
Gui::coinRemoveAllChildren(this->pcLinkRoot);
if (object) {
const Mesh::MeshObject& kernel = object->Mesh.getValue();
@@ -289,15 +302,18 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
ViewProviderMesh* view = static_cast<ViewProviderMesh*>(pDoc->getViewProvider(object));
this->pcLinkRoot->addChild(view->getHighlightNode());
Base::Placement p = static_cast<Mesh::Feature*>(view->getObject())->Placement.getValue();
Base::Placement p =
static_cast<Mesh::Feature*>(view->getObject())->Placement.getValue();
ViewProviderMesh::updateTransform(p, pcTransform);
}
}
else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) {
const Mesh::PropertyCurvatureList* curv = static_cast<const Mesh::PropertyCurvatureList*>(prop);
if (curv->getSize() < 3) // invalid array
const Mesh::PropertyCurvatureList* curv =
static_cast<const Mesh::PropertyCurvatureList*>(prop);
if (curv->getSize() < 3) { // invalid array
return;
#if 0 // FIXME: Do not always change the range
}
#if 0 // FIXME: Do not always change the range
init(curv); // init color bar
#endif
setActiveMode();
@@ -311,7 +327,7 @@ SoSeparator* ViewProviderMeshCurvature::getFrontRoot() const
void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
{
using PropertyMap = std::map<std::string,App::Property*>;
using PropertyMap = std::map<std::string, App::Property*>;
Mesh::PropertyCurvatureList* pCurvInfo = nullptr;
PropertyMap Map;
pcObject->getPropertyMap(Map);
@@ -321,8 +337,9 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
return (type == Mesh::PropertyCurvatureList::getClassTypeId());
});
if (it == Map.end())
return; // cannot display this feature type due to missing curvature property
if (it == Map.end()) {
return; // cannot display this feature type due to missing curvature property
}
pCurvInfo = static_cast<Mesh::PropertyCurvatureList*>(it->second);
@@ -367,23 +384,23 @@ QIcon ViewProviderMeshCurvature::getIcon() const
void ViewProviderMeshCurvature::setDisplayMode(const char* ModeName)
{
if ( strcmp("Mean curvature",ModeName)==0 ) {
if (strcmp("Mean curvature", ModeName) == 0) {
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MeanCurvature);
setDisplayMaskMode("ColorShaded");
}
else if ( strcmp("Gaussian curvature",ModeName)==0 ) {
else if (strcmp("Gaussian curvature", ModeName) == 0) {
setVertexCurvatureMode(Mesh::PropertyCurvatureList::GaussCurvature);
setDisplayMaskMode("ColorShaded");
}
else if ( strcmp("Maximum curvature",ModeName)==0 ) {
else if (strcmp("Maximum curvature", ModeName) == 0) {
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MaxCurvature);
setDisplayMaskMode("ColorShaded");
}
else if ( strcmp("Minimum curvature",ModeName)==0 ) {
else if (strcmp("Minimum curvature", ModeName) == 0) {
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MinCurvature);
setDisplayMaskMode("ColorShaded");
}
else if ( strcmp("Absolute curvature",ModeName)==0 ) {
else if (strcmp("Absolute curvature", ModeName) == 0) {
setVertexCurvatureMode(Mesh::PropertyCurvatureList::AbsCurvature);
setDisplayMaskMode("ColorShaded");
}
@@ -410,23 +427,28 @@ std::vector<std::string> ViewProviderMeshCurvature::getDisplayModes() const
return StrList;
}
void ViewProviderMeshCurvature::OnChange(Base::Subject<int> &/*rCaller*/,int /*rcReason*/)
void ViewProviderMeshCurvature::OnChange(Base::Subject<int>& /*rCaller*/, int /*rcReason*/)
{
setActiveMode();
}
namespace MeshGui {
namespace MeshGui
{
class Annotation
{
public:
Annotation(Gui::ViewProviderDocumentObject* vp,
const QString& s,const SbVec3f& p, const SbVec3f& n)
: vp(vp), s(s), p(p), n(n)
{
}
const QString& s,
const SbVec3f& p,
const SbVec3f& n)
: vp(vp)
, s(s)
, p(p)
, n(n)
{}
static void run(void * data, SoSensor * sensor)
static void run(void* data, SoSensor* sensor)
{
Annotation* self = static_cast<Annotation*>(data);
self->show();
@@ -438,33 +460,34 @@ public:
{
App::Document* doc = vp->getObject()->getDocument();
std::vector<App::DocumentObject*> groups = doc->getObjectsOfType
(App::DocumentObjectGroup::getClassTypeId());
std::vector<App::DocumentObject*> groups =
doc->getObjectsOfType(App::DocumentObjectGroup::getClassTypeId());
App::DocumentObjectGroup* group = nullptr;
std::string internalname = "CurvatureGroup";
for (const auto & it : groups) {
for (const auto& it : groups) {
if (internalname == it->getNameInDocument()) {
group = static_cast<App::DocumentObjectGroup*>(it);
break;
}
}
if (!group) {
group = static_cast<App::DocumentObjectGroup*>(doc->addObject
("App::DocumentObjectGroup",internalname.c_str()));
group = static_cast<App::DocumentObjectGroup*>(
doc->addObject("App::DocumentObjectGroup", internalname.c_str()));
}
App::AnnotationLabel* anno = static_cast<App::AnnotationLabel*>
(group->addObject("App::AnnotationLabel", internalname.c_str()));
App::AnnotationLabel* anno = static_cast<App::AnnotationLabel*>(
group->addObject("App::AnnotationLabel", internalname.c_str()));
QStringList lines = s.split(QLatin1String("\n"));
std::vector<std::string> text;
for (const auto & line : lines)
for (const auto& line : lines) {
text.emplace_back((const char*)line.toLatin1());
}
anno->LabelText.setValues(text);
std::stringstream str;
str << "Curvature info (" << group->Group.getSize() << ")";
anno->Label.setValue(str.str());
anno->BasePosition.setValue(p[0],p[1],p[2]);
anno->TextPosition.setValue(n[0],n[1],n[2]);
anno->BasePosition.setValue(p[0], p[1], p[2]);
anno->TextPosition.setValue(n[0], n[1], n[2]);
}
private:
@@ -474,18 +497,20 @@ private:
SbVec3f n;
};
}
} // namespace MeshGui
void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n)
void ViewProviderMeshCurvature::curvatureInfoCallback(void* ud, SoEventCallback* n)
{
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(ev);
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
// Mark all incoming mouse button events as handled, especially, to deactivate the selection
// node
n->getAction()->setHandled();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2
&& mbe->getState() == SoButtonEvent::UP) {
n->setHandled();
// context-menu
QMenu menu;
@@ -505,8 +530,9 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
view->removeEventCallback(SoEvent::getClassTypeId(), curvatureInfoCallback, ud);
}
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
const SoPickedPoint * point = n->getPickedPoint();
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
&& mbe->getState() == SoButtonEvent::UP) {
const SoPickedPoint* point = n->getPickedPoint();
if (!point) {
Base::Console().Message("No facet picked.\n");
return;
@@ -517,12 +543,14 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
// really from the mesh we render and not from any other geometry
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath());
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
if (!vp
|| !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) {
return;
}
ViewProviderMeshCurvature* self = static_cast<ViewProviderMeshCurvature*>(vp);
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail *>(detail);
const SoFaceDetail* facedetail = static_cast<const SoFaceDetail*>(detail);
// get the curvature info of the three points of the picked facet
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
@@ -543,31 +571,34 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
}
}
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
const SoPickedPoint * point = n->getPickedPoint();
if (!point)
const SoPickedPoint* point = n->getPickedPoint();
if (!point) {
return;
}
n->setHandled();
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
// really from the mesh we render and not from any other geometry
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath());
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) {
return;
}
ViewProviderMeshCurvature* that = static_cast<ViewProviderMeshCurvature*>(vp);
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail *>(detail);
const SoFaceDetail* facedetail = static_cast<const SoFaceDetail*>(detail);
// get the curvature info of the three points of the picked facet
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
int index3 = facedetail->getPoint(2)->getCoordinateIndex();
std::string info = that->curvatureInfo(false, index1, index2, index3);
Gui::getMainWindow()->setPaneText(1,QString::fromLatin1(info.c_str()));
Gui::getMainWindow()->setPaneText(1, QString::fromLatin1(info.c_str()));
}
}
}
std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, int index2, int index3) const
std::string
ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, int index2, int index3) const
{
// get the curvature info of the three points of the picked facet
App::Property* prop = pcObject->getPropertyByName("CurvInfo");
@@ -577,9 +608,11 @@ std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, in
const Mesh::CurvatureInfo& cVal1 = (*curv)[index1];
const Mesh::CurvatureInfo& cVal2 = (*curv)[index2];
const Mesh::CurvatureInfo& cVal3 = (*curv)[index3];
float fVal1 = 0.0f; float fVal2 = 0.0f; float fVal3 = 0.0f;
float fVal1 = 0.0f;
float fVal2 = 0.0f;
float fVal3 = 0.0f;
bool print=true;
bool print = true;
std::string mode = getActiveDisplayMode();
if (mode == "Minimum curvature") {
fVal1 = cVal1.fMinCurvature;
@@ -592,19 +625,22 @@ std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, in
fVal3 = cVal3.fMaxCurvature;
}
else if (mode == "Gaussian curvature") {
fVal1 = cVal1.fMaxCurvature*cVal1.fMinCurvature;
fVal2 = cVal2.fMaxCurvature*cVal2.fMinCurvature;
fVal3 = cVal3.fMaxCurvature*cVal3.fMinCurvature;
fVal1 = cVal1.fMaxCurvature * cVal1.fMinCurvature;
fVal2 = cVal2.fMaxCurvature * cVal2.fMinCurvature;
fVal3 = cVal3.fMaxCurvature * cVal3.fMinCurvature;
}
else if (mode == "Mean curvature") {
fVal1 = 0.5f*(cVal1.fMaxCurvature+cVal1.fMinCurvature);
fVal2 = 0.5f*(cVal2.fMaxCurvature+cVal2.fMinCurvature);
fVal3 = 0.5f*(cVal3.fMaxCurvature+cVal3.fMinCurvature);
fVal1 = 0.5f * (cVal1.fMaxCurvature + cVal1.fMinCurvature);
fVal2 = 0.5f * (cVal2.fMaxCurvature + cVal2.fMinCurvature);
fVal3 = 0.5f * (cVal3.fMaxCurvature + cVal3.fMinCurvature);
}
else if (mode == "Absolute curvature") {
fVal1 = fabs(cVal1.fMaxCurvature) > fabs(cVal1.fMinCurvature) ? cVal1.fMaxCurvature : cVal1.fMinCurvature;
fVal2 = fabs(cVal2.fMaxCurvature) > fabs(cVal2.fMinCurvature) ? cVal2.fMaxCurvature : cVal2.fMinCurvature;
fVal3 = fabs(cVal3.fMaxCurvature) > fabs(cVal3.fMinCurvature) ? cVal3.fMaxCurvature : cVal3.fMinCurvature;
fVal1 = fabs(cVal1.fMaxCurvature) > fabs(cVal1.fMinCurvature) ? cVal1.fMaxCurvature
: cVal1.fMinCurvature;
fVal2 = fabs(cVal2.fMaxCurvature) > fabs(cVal2.fMinCurvature) ? cVal2.fMaxCurvature
: cVal2.fMinCurvature;
fVal3 = fabs(cVal3.fMaxCurvature) > fabs(cVal3.fMinCurvature) ? cVal3.fMaxCurvature
: cVal3.fMinCurvature;
}
else {
print = false;

View File

@@ -40,26 +40,30 @@ class SoPath;
class SoLocateHighlight;
class SoTransformerManip;
namespace Gui {
class SoFCColorBar;
class View3DInventorViewer;
namespace Gui
{
class SoFCColorBar;
class View3DInventorViewer;
} // namespace Gui
namespace Mesh
{
class PropertyCurvatureList;
}
namespace Mesh {
class PropertyCurvatureList;
}
namespace MeshGui
{
namespace MeshGui {
/** The ViewProviderMeshCurvature class is associated to the mesh curvature feature. It allows to display the most known types of
* curvatures, such as Gaussian curvature, mean curvature, minimum and maximum curvature.
* Moreover a color bar is also added to the scene.
/** The ViewProviderMeshCurvature class is associated to the mesh curvature feature. It allows to
* display the most known types of curvatures, such as Gaussian curvature, mean curvature, minimum
* and maximum curvature. Moreover a color bar is also added to the scene.
*
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshCurvature : public Gui::ViewProviderDocumentObject,
public App::DocumentObserver,
public Base::Observer<int> {
class MeshGuiExport ViewProviderMeshCurvature: public Gui::ViewProviderDocumentObject,
public App::DocumentObserver,
public Base::Observer<int>
{
using inherited = Gui::ViewProviderDocumentObject;
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshCurvature);
@@ -70,9 +74,13 @@ public:
App::PropertyMaterial TextureMaterial;
/// Extracts the mesh data from the feature \a pcFeature and creates an Inventor node \a SoNode with these data.
/// Extracts the mesh data from the feature \a pcFeature and creates an Inventor node \a SoNode
/// with these data.
void attach(App::DocumentObject* pcFeature) override;
bool useNewSelectionModel() const override {return false;}
bool useNewSelectionModel() const override
{
return false;
}
/// Sets the viewing mode
void setDisplayMode(const char* ModeName) override;
/// get the default display mode
@@ -83,8 +91,9 @@ public:
void updateData(const App::Property*) override;
/// Returns a pixmap for the associated feature type
QIcon getIcon() const override;
/// Once the color bar settinhs has been changed this method gets called to update the feature's representation
void OnChange(Base::Subject<int> &rCaller,int rcReason) override;
/// Once the color bar settinhs has been changed this method gets called to update the feature's
/// representation
void OnChange(Base::Subject<int>& rCaller, int rcReason) override;
/// Returns a color bar
SoSeparator* getFrontRoot() const override;
/// Hide the object in the view
@@ -93,7 +102,7 @@ public:
void show() override;
public:
static void curvatureInfoCallback(void * ud, SoEventCallback * n);
static void curvatureInfoCallback(void* ud, SoEventCallback* n);
protected:
void onChanged(const App::Property* prop) override;
@@ -102,23 +111,22 @@ protected:
void touchShapeNode();
private:
void init(const Mesh::PropertyCurvatureList *prop);
void init(const Mesh::PropertyCurvatureList* prop);
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) override;
protected:
SoMaterial * pcColorMat;
SoGroup * pcLinkRoot;
SoMaterial* pcColorMat;
SoGroup* pcLinkRoot;
Gui::SoFCColorBar* pcColorBar;
SoDrawStyle * pcColorStyle;
SoSeparator * pcColorRoot;
SoDrawStyle* pcColorStyle;
SoSeparator* pcColorRoot;
private:
static bool addflag;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDER_MESH_CURVATURE_H
#endif // MESHGUI_VIEWPROVIDER_MESH_CURVATURE_H

View File

@@ -22,22 +22,22 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoBaseColor.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoFaceSet.h>
# include <Inventor/nodes/SoLineSet.h>
# include <Inventor/nodes/SoMarkerSet.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoShapeHints.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoFaceSet.h>
#include <Inventor/nodes/SoLineSet.h>
#include <Inventor/nodes/SoMarkerSet.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoShapeHints.h>
#endif
#include <App/Application.h>
#include <Base/Parameter.h>
#include <Gui/Inventor/MarkerBitmaps.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Degeneration.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "ViewProviderDefects.h"
@@ -59,7 +59,7 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshFolds, MeshGui::ViewProviderMeshDefects
ViewProviderMeshDefects::ViewProviderMeshDefects()
{
ADD_PROPERTY(LineWidth,(2.0f));
ADD_PROPERTY(LineWidth, (2.0f));
pcCoords = new SoCoordinate3();
pcCoords->ref();
@@ -80,8 +80,9 @@ void ViewProviderMeshDefects::onChanged(const App::Property* prop)
if (prop == &LineWidth) {
pcDrawStyle->lineWidth = LineWidth.getValue();
}
// Visibility changes must be handled here because in the base class it changes the attribute of the feature
// and thus affects the visibility of the mesh view provider which is undesired behaviour
// Visibility changes must be handled here because in the base class it changes the attribute of
// the feature and thus affects the visibility of the mesh view provider which is undesired
// behaviour
else if (prop == &Visibility) {
Visibility.getValue() ? show() : hide();
}
@@ -105,7 +106,7 @@ ViewProviderMeshOrientation::~ViewProviderMeshOrientation()
void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcFaceRoot = new SoGroup();
@@ -113,24 +114,28 @@ void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
pcFlatStyle->style = SoDrawStyle::FILLED;
pcFaceRoot->addChild(pcFlatStyle);
SoShapeHints * flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
SoShapeHints* flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pcFaceRoot->addChild(flathints);
// Draw faces
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcFaces);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -142,19 +147,19 @@ void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
pcCoords->point.setNum(3 * inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
int i=0;
int j=0;
int i = 0;
int j = 0;
for (Mesh::ElementIndex ind : inds) {
cF.Set(ind);
for (auto cP : cF->_aclPoints) {
// move a bit in opposite normal direction to overlay the original faces
cP -= 0.001f * cF->GetNormal();
pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
}
pcFaces->numVertices.set1Value(j++, 3);
}
@@ -177,7 +182,7 @@ ViewProviderMeshNonManifolds::~ViewProviderMeshNonManifolds()
void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcLineRoot = new SoGroup();
pcDrawStyle->lineWidth = 3;
@@ -185,18 +190,22 @@ void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.0f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcLines);
pcLineRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -205,22 +214,24 @@ void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
void ViewProviderMeshNonManifolds::showDefects(const std::vector<Mesh::ElementIndex>& inds)
{
if ((inds.size() % 2) != 0)
if ((inds.size() % 2) != 0) {
return;
}
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(inds.size());
MeshCore::MeshPointIterator cP(rMesh);
int i=0;
int j=0;
for (std::vector<Mesh::ElementIndex>::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
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
++it; // go to end point
cP.Set(*it);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
pcLines->numVertices.set1Value(j++, 2);
}
@@ -242,7 +253,7 @@ ViewProviderMeshNonManifoldPoints::~ViewProviderMeshNonManifoldPoints()
void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcPointRoot = new SoGroup();
pcDrawStyle->pointSize = 3;
@@ -250,18 +261,22 @@ void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
// Draw points
SoSeparator* pointsep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
pointsep->addChild(basecol);
pointsep->addChild(pcCoords);
pointsep->addChild(pcPoints);
pcPointRoot->addChild(pointsep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
pointsep->addChild(markcol);
pointsep->addChild(marker);
@@ -271,14 +286,14 @@ void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(inds.size());
MeshCore::MeshPointIterator cP(rMesh);
int i = 0;
for (Mesh::ElementIndex ind : inds) {
cP.Set(ind);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
}
setDisplayMaskMode("Point");
@@ -299,7 +314,7 @@ ViewProviderMeshDuplicatedFaces::~ViewProviderMeshDuplicatedFaces()
void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcFaceRoot = new SoGroup();
@@ -307,25 +322,29 @@ void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
pcFlatStyle->style = SoDrawStyle::FILLED;
pcFaceRoot->addChild(pcFlatStyle);
SoShapeHints * flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
SoShapeHints* flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pcFaceRoot->addChild(flathints);
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.0f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcFaces);
pcFaceRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -335,19 +354,19 @@ void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
pcCoords->point.setNum(3 * inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
int i=0;
int j=0;
int i = 0;
int j = 0;
for (Mesh::ElementIndex ind : inds) {
cF.Set(ind);
for (auto cP : cF->_aclPoints) {
// move a bit in normal direction to overlay the original faces
cP += 0.001f * cF->GetNormal();
pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
}
pcFaces->numVertices.set1Value(j++, 3);
}
@@ -370,7 +389,7 @@ ViewProviderMeshDuplicatedPoints::~ViewProviderMeshDuplicatedPoints()
void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcPointRoot = new SoGroup();
pcDrawStyle->pointSize = 3;
@@ -378,18 +397,22 @@ void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
// Draw points
SoSeparator* pointsep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
pointsep->addChild(basecol);
pointsep->addChild(pcCoords);
pointsep->addChild(pcPoints);
pcPointRoot->addChild(pointsep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
pointsep->addChild(markcol);
pointsep->addChild(marker);
@@ -399,14 +422,14 @@ void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(inds.size());
MeshCore::MeshPointIterator cP(rMesh);
int i = 0;
for (Mesh::ElementIndex ind : inds) {
cP.Set(ind);
pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
}
setDisplayMaskMode("Point");
@@ -427,7 +450,7 @@ ViewProviderMeshDegenerations::~ViewProviderMeshDegenerations()
void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcLineRoot = new SoGroup();
pcDrawStyle->lineWidth = 3;
@@ -435,18 +458,22 @@ void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcLines);
pcLineRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -456,13 +483,13 @@ void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(2*inds.size());
pcCoords->point.setNum(2 * inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
int i=0;
int j=0;
int i = 0;
int j = 0;
for (Mesh::ElementIndex ind : inds) {
cF.Set(ind);
const MeshCore::MeshPoint& rE0 = cF->_aclPoints[0];
@@ -474,32 +501,38 @@ void ViewProviderMeshDegenerations::showDefects(const std::vector<Mesh::ElementI
// set a small tolerance to get a non-degenerated line
float eps = 0.005f;
Base::Vector3f cP1, cP2;
cP1.Set(rE1.x+eps,rE1.y+eps,rE1.z+eps);
cP2.Set(rE2.x-eps,rE2.y-eps,rE2.z-eps);
pcCoords->point.set1Value(i++,cP1.x,cP1.y,cP1.z);
pcCoords->point.set1Value(i++,cP2.x,cP2.y,cP2.z);
cP1.Set(rE1.x + eps, rE1.y + eps, rE1.z + eps);
cP2.Set(rE2.x - eps, rE2.y - eps, rE2.z - eps);
pcCoords->point.set1Value(i++, cP1.x, cP1.y, cP1.z);
pcCoords->point.set1Value(i++, cP2.x, cP2.y, cP2.z);
}
else if (rE0 == rE1) {
pcCoords->point.set1Value(i++,rE1.x,rE1.y,rE1.z);
pcCoords->point.set1Value(i++,rE2.x,rE2.y,rE2.z);
pcCoords->point.set1Value(i++, rE1.x, rE1.y, rE1.z);
pcCoords->point.set1Value(i++, rE2.x, rE2.y, rE2.z);
}
else if (rE1 == rE2) {
pcCoords->point.set1Value(i++,rE2.x,rE2.y,rE2.z);
pcCoords->point.set1Value(i++,rE0.x,rE0.y,rE0.z);
pcCoords->point.set1Value(i++, rE2.x, rE2.y, rE2.z);
pcCoords->point.set1Value(i++, rE0.x, rE0.y, rE0.z);
}
else if (rE2 == rE0) {
pcCoords->point.set1Value(i++,rE0.x,rE0.y,rE0.z);
pcCoords->point.set1Value(i++,rE1.x,rE1.y,rE1.z);
pcCoords->point.set1Value(i++, rE0.x, rE0.y, rE0.z);
pcCoords->point.set1Value(i++, rE1.x, rE1.y, rE1.z);
}
else {
for (int j=0; j<3; j++) {
Base::Vector3f cVec1 = cF->_aclPoints[(j+1)%3] - cF->_aclPoints[j];
Base::Vector3f cVec2 = cF->_aclPoints[(j+2)%3] - cF->_aclPoints[j];
for (int j = 0; j < 3; j++) {
Base::Vector3f cVec1 = cF->_aclPoints[(j + 1) % 3] - cF->_aclPoints[j];
Base::Vector3f cVec2 = cF->_aclPoints[(j + 2) % 3] - cF->_aclPoints[j];
// adjust the neighbourhoods and point indices
if (cVec1 * cVec2 < 0.0f) {
pcCoords->point.set1Value(i++,cF->_aclPoints[(j+1)%3].x,cF->_aclPoints[(j+1)%3].y,cF->_aclPoints[(j+1)%3].z);
pcCoords->point.set1Value(i++,cF->_aclPoints[(j+2)%3].x,cF->_aclPoints[(j+2)%3].y,cF->_aclPoints[(j+2)%3].z);
pcCoords->point.set1Value(i++,
cF->_aclPoints[(j + 1) % 3].x,
cF->_aclPoints[(j + 1) % 3].y,
cF->_aclPoints[(j + 1) % 3].z);
pcCoords->point.set1Value(i++,
cF->_aclPoints[(j + 2) % 3].x,
cF->_aclPoints[(j + 2) % 3].y,
cF->_aclPoints[(j + 2) % 3].z);
break;
}
}
@@ -526,7 +559,7 @@ ViewProviderMeshIndices::~ViewProviderMeshIndices()
void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcFaceRoot = new SoGroup();
@@ -534,25 +567,29 @@ void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
pcFlatStyle->style = SoDrawStyle::FILLED;
pcFaceRoot->addChild(pcFlatStyle);
SoShapeHints * flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
SoShapeHints* flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pcFaceRoot->addChild(flathints);
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcFaces);
pcFaceRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -562,20 +599,20 @@ void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
if (!inds.empty()) {
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
pcCoords->point.setNum(3 * inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
int i=0;
int j=0;
int i = 0;
int j = 0;
for (Mesh::ElementIndex ind : inds) {
cF.Set(ind);
for (auto cP : cF->_aclPoints) {
// move a bit in opposite normal direction to overlay the original faces
cP -= 0.001f * cF->GetNormal();
pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
}
pcFaces->numVertices.set1Value(j++, 3);
}
@@ -599,7 +636,7 @@ ViewProviderMeshSelfIntersections::~ViewProviderMeshSelfIntersections()
void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcLineRoot = new SoGroup();
pcDrawStyle->lineWidth = 3;
@@ -607,18 +644,22 @@ void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcLines);
pcLineRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -627,30 +668,33 @@ void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
void ViewProviderMeshSelfIntersections::showDefects(const std::vector<Mesh::ElementIndex>& indices)
{
if (indices.size() % 2 != 0)
if (indices.size() % 2 != 0) {
return;
}
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
MeshCore::MeshEvalSelfIntersection eval(rMesh);
std::vector<std::pair<Mesh::ElementIndex, Mesh::ElementIndex> > intersection;
std::vector<std::pair<Mesh::ElementIndex, Mesh::ElementIndex>> intersection;
std::vector<Mesh::ElementIndex>::const_iterator it;
for (it = indices.begin(); it != indices.end(); ) {
Mesh::ElementIndex id1 = *it; ++it;
Mesh::ElementIndex id2 = *it; ++it;
intersection.emplace_back(id1,id2);
for (it = indices.begin(); it != indices.end();) {
Mesh::ElementIndex id1 = *it;
++it;
Mesh::ElementIndex id2 = *it;
++it;
intersection.emplace_back(id1, id2);
}
std::vector<std::pair<Base::Vector3f, Base::Vector3f> > lines;
std::vector<std::pair<Base::Vector3f, Base::Vector3f>> lines;
eval.GetIntersections(intersection, lines);
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(2*lines.size());
int i=0;
int j=0;
for (const auto & line : lines) {
pcCoords->point.set1Value(i++,line.first.x,line.first.y,line.first.z);
pcCoords->point.set1Value(i++,line.second.x,line.second.y,line.second.z);
pcCoords->point.setNum(2 * lines.size());
int i = 0;
int j = 0;
for (const auto& line : lines) {
pcCoords->point.set1Value(i++, line.first.x, line.first.y, line.first.z);
pcCoords->point.set1Value(i++, line.second.x, line.second.y, line.second.z);
pcLines->numVertices.set1Value(j++, 2);
}
@@ -672,7 +716,7 @@ ViewProviderMeshFolds::~ViewProviderMeshFolds()
void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
ViewProviderDocumentObject::attach(pcFeat);
SoGroup* pcFaceRoot = new SoGroup();
@@ -680,25 +724,29 @@ void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
pcFlatStyle->style = SoDrawStyle::FILLED;
pcFaceRoot->addChild(pcFlatStyle);
SoShapeHints * flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
SoShapeHints* flathints = new SoShapeHints;
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pcFaceRoot->addChild(flathints);
// Draw lines
SoSeparator* linesep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
SoBaseColor* basecol = new SoBaseColor;
basecol->rgb.setValue(1.0f, 0.0f, 0.0f);
linesep->addChild(basecol);
linesep->addChild(pcCoords);
linesep->addChild(pcFaces);
pcFaceRoot->addChild(linesep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoBaseColor* markcol = new SoBaseColor;
markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("PLUS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 7));
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"PLUS",
App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("MarkerSize", 7));
linesep->addChild(markcol);
linesep->addChild(marker);
@@ -708,19 +756,19 @@ void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
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();
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
pcCoords->point.deleteValues(0);
pcCoords->point.setNum(3*inds.size());
pcCoords->point.setNum(3 * inds.size());
MeshCore::MeshFacetIterator cF(rMesh);
int i=0;
int j=0;
int i = 0;
int j = 0;
for (Mesh::ElementIndex ind : inds) {
cF.Set(ind);
for (auto cP : cF->_aclPoints) {
// move a bit in normal direction to overlay the original faces
cP += 0.001f * cF->GetNormal();
pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
}
pcFaces->numVertices.set1Value(j++, 3);
}

View File

@@ -30,13 +30,15 @@ class SoPointSet;
class SoLineSet;
class SoFaceSet;
namespace MeshGui {
namespace MeshGui
{
/** The ViewProviderMeshDefects class is used to display the most known types of defects of a polymesh.
* In subclasses defects like non-manifolds, wrong oriented facets, degenerated facets, duplicates, .... are displayed.
/** The ViewProviderMeshDefects class is used to display the most known types of defects of a
* polymesh. In subclasses defects like non-manifolds, wrong oriented facets, degenerated facets,
* duplicates, .... are displayed.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshDefects : public Gui::ViewProviderDocumentObject
class MeshGuiExport ViewProviderMeshDefects: public Gui::ViewProviderDocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshDefects);
@@ -56,14 +58,15 @@ protected:
/// get called by the container whenever a property has been changed
void onChanged(const App::Property* prop) override;
SoCoordinate3 * pcCoords;
SoDrawStyle * pcDrawStyle;
SoCoordinate3* pcCoords;
SoDrawStyle* pcDrawStyle;
};
/** The ViewProviderMeshOrientation class displays wrong oriented facets (i.e. flipped normals) in orange.
/** The ViewProviderMeshOrientation class displays wrong oriented facets (i.e. flipped normals) in
* orange.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshOrientation : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshOrientation: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshOrientation);
@@ -81,7 +84,7 @@ protected:
/** The ViewProviderMeshNonManifolds class displays edges with more than two faces attached in red.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshNonManifolds : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshNonManifolds: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshNonManifolds);
@@ -99,7 +102,7 @@ protected:
/** The ViewProviderMeshNonManifoldPoints class displays non-manifold vertexes in red.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshNonManifoldPoints : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshNonManifoldPoints: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshNonManifoldPoints);
@@ -117,7 +120,7 @@ protected:
/** The ViewProviderMeshDuplicatedFaces class displays duplicated faces in red.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshDuplicatedFaces : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshDuplicatedFaces: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshDuplicatedFaces);
@@ -132,10 +135,11 @@ protected:
SoFaceSet* pcFaces;
};
/** The ViewProviderMeshDegenerations class displays degenerated faces to a line or even a point in orange.
/** The ViewProviderMeshDegenerations class displays degenerated faces to a line or even a point in
* orange.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshDegenerations : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshDegenerations: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshDegenerations);
@@ -150,7 +154,7 @@ protected:
SoLineSet* pcLines;
};
class MeshGuiExport ViewProviderMeshDuplicatedPoints : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshDuplicatedPoints: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshDuplicatedPoints);
@@ -165,7 +169,7 @@ protected:
SoPointSet* pcPoints;
};
class MeshGuiExport ViewProviderMeshIndices : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshIndices: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshIndices);
@@ -183,7 +187,7 @@ protected:
/** The ViewProviderMeshSelfIntersections class displays lines of self-intersections.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshSelfIntersections : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshSelfIntersections: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshSelfIntersections);
@@ -198,7 +202,7 @@ protected:
SoLineSet* pcLines;
};
class MeshGuiExport ViewProviderMeshFolds : public ViewProviderMeshDefects
class MeshGuiExport ViewProviderMeshFolds: public ViewProviderMeshDefects
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshFolds);
@@ -213,8 +217,7 @@ protected:
SoFaceSet* pcFaces;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDER_MESH_DEFECTS_H
#endif // MESHGUI_VIEWPROVIDER_MESH_DEFECTS_H

View File

@@ -22,26 +22,26 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <algorithm>
#include <algorithm>
# include <Inventor/nodes/SoBaseColor.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedLineSet.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoSeparator.h>
#endif
#include <App/Document.h>
#include <Gui/Selection.h>
#include <Gui/Window.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "ViewProviderMeshFaceSet.h"
#include "SoFCIndexedFaceSet.h"
#include "SoFCMeshObject.h"
#include "ViewProviderMeshFaceSet.h"
using namespace MeshGui;
@@ -77,7 +77,7 @@ ViewProviderMeshFaceSet::~ViewProviderMeshFaceSet()
pcMeshFaces->unref();
}
void ViewProviderMeshFaceSet::attach(App::DocumentObject *pcFeat)
void ViewProviderMeshFaceSet::attach(App::DocumentObject* pcFeat)
{
ViewProviderMesh::attach(pcFeat);
@@ -85,11 +85,13 @@ void ViewProviderMeshFaceSet::attach(App::DocumentObject *pcFeat)
pcShapeGroup->addChild(pcMeshFaces);
// read the threshold from the preferences
Base::Reference<ParameterGrp> hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh");
Base::Reference<ParameterGrp> hGrp =
Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh");
int size = hGrp->GetInt("RenderTriangleLimit", -1);
if (size > 0) {
pcMeshShape->renderTriangleLimit = (unsigned int)(pow(10.0f,size));
static_cast<SoFCIndexedFaceSet*>(pcMeshFaces)->renderTriangleLimit = (unsigned int)(pow(10.0f,size));
pcMeshShape->renderTriangleLimit = (unsigned int)(pow(10.0f, size));
static_cast<SoFCIndexedFaceSet*>(pcMeshFaces)->renderTriangleLimit =
(unsigned int)(pow(10.0f, size));
}
}
@@ -97,7 +99,8 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop)
{
ViewProviderMesh::updateData(prop);
if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) {
const Mesh::MeshObject* mesh = static_cast<const Mesh::PropertyMeshKernel*>(prop)->getValuePtr();
const Mesh::MeshObject* mesh =
static_cast<const Mesh::PropertyMeshKernel*>(prop)->getValuePtr();
bool direct = MeshRenderer::shouldRenderDirectly(mesh->countFacets() > this->triangleCount);
if (direct) {
@@ -130,10 +133,12 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop)
showOpenEdges(OpenEdges.getValue());
std::vector<Mesh::FacetIndex> selection;
mesh->getFacetsFromSelection(selection);
if (selection.empty())
if (selection.empty()) {
unhighlightSelection();
else
}
else {
highlightSelection();
}
}
}
@@ -160,15 +165,16 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show)
pcOpenEdge->addChild(lines);
// Build up the lines with indices to the list of vertices 'pcMeshCoord'
int index=0;
const MeshCore::MeshKernel& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue().getKernel();
int index = 0;
const MeshCore::MeshKernel& rMesh =
static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue().getKernel();
const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets();
for (const auto & rFace : rFaces) {
for (int i=0; i<3; i++) {
for (const auto& rFace : rFaces) {
for (int i = 0; i < 3; i++) {
if (rFace._aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) {
lines->coordIndex.set1Value(index++,rFace._aulPoints[i]);
lines->coordIndex.set1Value(index++,rFace._aulPoints[(i+1)%3]);
lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX);
lines->coordIndex.set1Value(index++, rFace._aulPoints[i]);
lines->coordIndex.set1Value(index++, rFace._aulPoints[(i + 1) % 3]);
lines->coordIndex.set1Value(index++, SO_END_LINE_INDEX);
}
}
}
@@ -181,14 +187,16 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show)
SoShape* ViewProviderMeshFaceSet::getShapeNode() const
{
if (directRendering)
if (directRendering) {
return this->pcMeshShape;
}
return this->pcMeshFaces;
}
SoNode* ViewProviderMeshFaceSet::getCoordNode() const
{
if (directRendering)
if (directRendering) {
return this->pcMeshNode;
}
return this->pcMeshCoord;
}

View File

@@ -25,7 +25,8 @@
#include <Mod/Mesh/Gui/ViewProvider.h>
namespace MeshGui {
namespace MeshGui
{
class SoFCIndexedFaceSet;
/**
@@ -46,7 +47,7 @@ class SoFCIndexedFaceSet;
* For more details @see SoFCMeshNode and SoFCMeshFaceSet.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderMeshFaceSet : public ViewProviderMesh
class MeshGuiExport ViewProviderMeshFaceSet: public ViewProviderMesh
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshFaceSet);
@@ -54,7 +55,7 @@ public:
ViewProviderMeshFaceSet();
~ViewProviderMeshFaceSet() override;
void attach(App::DocumentObject *pcFeat) override;
void attach(App::DocumentObject* pcFeat) override;
void updateData(const App::Property*) override;
protected:
@@ -65,14 +66,13 @@ protected:
private:
bool directRendering;
unsigned long triangleCount;
SoCoordinate3 * pcMeshCoord;
SoFCIndexedFaceSet * pcMeshFaces;
SoFCMeshObjectNode * pcMeshNode;
SoFCMeshObjectShape * pcMeshShape;
SoCoordinate3* pcMeshCoord;
SoFCIndexedFaceSet* pcMeshFaces;
SoFCMeshObjectNode* pcMeshNode;
SoFCMeshObjectShape* pcMeshShape;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDERMESHFACESET_H
#endif // MESHGUI_VIEWPROVIDERMESHFACESET_H

View File

@@ -22,13 +22,15 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <sstream>
#endif
// clang-format off
#include "ViewProvider.h"
// inclusion of the generated files (generated out of ViewProviderMeshPy.xml)
#include "ViewProviderMeshPy.h"
#include "ViewProviderMeshPy.cpp"
// clang-format on
using namespace MeshGui;
@@ -42,11 +44,12 @@ std::string ViewProviderMeshPy::representation() const
return str.str();
}
PyObject* ViewProviderMeshPy::setSelection(PyObject *args)
PyObject* ViewProviderMeshPy::setSelection(PyObject* args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "O", &obj))
if (!PyArg_ParseTuple(args, "O", &obj)) {
return nullptr;
}
Py::Sequence list(obj);
std::vector<Mesh::FacetIndex> selection;
@@ -62,11 +65,12 @@ PyObject* ViewProviderMeshPy::setSelection(PyObject *args)
Py_Return;
}
PyObject* ViewProviderMeshPy::addSelection(PyObject *args)
PyObject* ViewProviderMeshPy::addSelection(PyObject* args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "O", &obj))
if (!PyArg_ParseTuple(args, "O", &obj)) {
return nullptr;
}
Py::Sequence list(obj);
std::vector<Mesh::FacetIndex> selection;
@@ -82,11 +86,12 @@ PyObject* ViewProviderMeshPy::addSelection(PyObject *args)
Py_Return;
}
PyObject* ViewProviderMeshPy::removeSelection(PyObject *args)
PyObject* ViewProviderMeshPy::removeSelection(PyObject* args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "O", &obj))
if (!PyArg_ParseTuple(args, "O", &obj)) {
return nullptr;
}
Py::Sequence list(obj);
std::vector<Mesh::FacetIndex> selection;
@@ -102,31 +107,34 @@ PyObject* ViewProviderMeshPy::removeSelection(PyObject *args)
Py_Return;
}
PyObject* ViewProviderMeshPy::invertSelection(PyObject *args)
PyObject* ViewProviderMeshPy::invertSelection(PyObject* args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
ViewProviderMesh* vp = getViewProviderMeshPtr();
vp->invertSelection();
Py_Return;
}
PyObject* ViewProviderMeshPy::clearSelection(PyObject *args)
PyObject* ViewProviderMeshPy::clearSelection(PyObject* args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
ViewProviderMesh* vp = getViewProviderMeshPtr();
vp->clearSelection();
Py_Return;
}
PyObject* ViewProviderMeshPy::highlightSegments(PyObject *args)
PyObject* ViewProviderMeshPy::highlightSegments(PyObject* args)
{
PyObject* list;
if (!PyArg_ParseTuple(args, "O", &list))
if (!PyArg_ParseTuple(args, "O", &list)) {
return nullptr;
}
App::PropertyColorList colors;
colors.setPyObject(list);
@@ -136,7 +144,7 @@ PyObject* ViewProviderMeshPy::highlightSegments(PyObject *args)
Py_Return;
}
PyObject *ViewProviderMeshPy::getCustomAttributes(const char* /*attr*/) const
PyObject* ViewProviderMeshPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}

View File

@@ -21,15 +21,15 @@
***************************************************************************/
#include "PreCompiled.h"
#include "ViewProviderPython.h"
#include "PreCompiled.h"
namespace Gui {
namespace Gui
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(MeshGui::ViewProviderPython, MeshGui::ViewProviderMeshFaceSet)
/// @endcond
// explicit template instantiation
template class MeshGuiExport ViewProviderPythonFeatureT<MeshGui::ViewProviderMeshFaceSet>;
}
} // namespace Gui

View File

@@ -27,12 +27,12 @@
#include <Gui/ViewProviderPythonFeature.h>
#include <Mod/Mesh/Gui/ViewProviderMeshFaceSet.h>
namespace MeshGui {
namespace MeshGui
{
using ViewProviderPython = Gui::ViewProviderPythonFeatureT<ViewProviderMeshFaceSet>;
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDERPYTHON_H
#endif // MESHGUI_VIEWPROVIDERPYTHON_H

View File

@@ -22,11 +22,11 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoNormalBinding.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/manips/SoTransformerManip.h>
#include <Inventor/manips/SoTransformerManip.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/nodes/SoSeparator.h>
#endif
#include <Gui/SoFCSelection.h>
@@ -42,60 +42,59 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransform, MeshGui::ViewProviderMesh)
ViewProviderMeshTransform::ViewProviderMeshTransform()
{
pcTransformerDragger = new SoTransformerManip();
pcTransformerDragger->ref();
pcTransformerDragger = new SoTransformerManip();
pcTransformerDragger->ref();
}
ViewProviderMeshTransform::~ViewProviderMeshTransform()
{
pcTransformerDragger->unref();
pcTransformerDragger->unref();
}
void ViewProviderMeshTransform::attach(App::DocumentObject *pcFeat)
void ViewProviderMeshTransform::attach(App::DocumentObject* pcFeat)
{
// creates the standard viewing modes
ViewProviderMesh::attach(pcFeat);
// creates the standard viewing modes
ViewProviderMesh::attach(pcFeat);
SoSeparator* pcEditRoot = new SoSeparator();
SoSeparator* pcEditRoot = new SoSeparator();
// flat shaded (Normal) ------------------------------------------
SoDrawStyle *pcFlatStyle = new SoDrawStyle();
pcFlatStyle->style = SoDrawStyle::FILLED;
SoNormalBinding* pcBinding = new SoNormalBinding();
pcBinding->value=SoNormalBinding::PER_FACE;
// flat shaded (Normal) ------------------------------------------
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
pcFlatStyle->style = SoDrawStyle::FILLED;
SoNormalBinding* pcBinding = new SoNormalBinding();
pcBinding->value = SoNormalBinding::PER_FACE;
pcEditRoot->addChild(pcTransformerDragger);
pcEditRoot->addChild(pcFlatStyle);
pcEditRoot->addChild(pcShapeMaterial);
pcEditRoot->addChild(pcBinding);
pcEditRoot->addChild(pcHighlight);
pcEditRoot->addChild(pcTransformerDragger);
pcEditRoot->addChild(pcFlatStyle);
pcEditRoot->addChild(pcShapeMaterial);
pcEditRoot->addChild(pcBinding);
pcEditRoot->addChild(pcHighlight);
// adding to the switch
addDisplayMaskMode(pcEditRoot, "Edit");
// adding to the switch
addDisplayMaskMode(pcEditRoot, "Edit");
}
void ViewProviderMeshTransform::updateData(const App::Property* prop)
{
ViewProviderMesh::updateData(prop);
ViewProviderMesh::updateData(prop);
}
void ViewProviderMeshTransform::setDisplayMode(const char* ModeName)
{
if ( strcmp("Transform",ModeName) == 0 )
setDisplayMaskMode("Edit");
ViewProviderMesh::setDisplayMode(ModeName);
if (strcmp("Transform", ModeName) == 0) {
setDisplayMaskMode("Edit");
}
ViewProviderMesh::setDisplayMode(ModeName);
}
const char* ViewProviderMeshTransform::getDefaultDisplayMode() const
{
return "Transform";
return "Transform";
}
std::vector<std::string> ViewProviderMeshTransform::getDisplayModes() const
{
std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes();
StrList.emplace_back("Transform");
return StrList;
std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes();
StrList.emplace_back("Transform");
return StrList;
}

View File

@@ -36,45 +36,45 @@ class SoPath;
class SoLocateHighlight;
class SoTransformerManip;
namespace Gui {
class View3DInventorViewer;
namespace Gui
{
class View3DInventorViewer;
}
namespace MeshGui {
namespace MeshGui
{
/** Like Mesh viewprovider but with manipulator
*/
class ViewProviderMeshTransform : public ViewProviderMesh
class ViewProviderMeshTransform: public ViewProviderMesh
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshTransform);
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshTransform);
public:
ViewProviderMeshTransform();
~ViewProviderMeshTransform() override;
ViewProviderMeshTransform();
~ViewProviderMeshTransform() override;
/**
* Extracts the mesh data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject *) override;
/**
* Extracts the mesh data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject*) override;
/// set the viewing mode
void setDisplayMode(const char* ModeName) override;
/// get the default display mode
const char* getDefaultDisplayMode() const override;
/// returns a list of all possible modes
std::vector<std::string> getDisplayModes() const override;
/// Update the Mesh representation
void updateData(const App::Property*) override;
/// set the viewing mode
void setDisplayMode(const char* ModeName) override;
/// get the default display mode
const char* getDefaultDisplayMode() const override;
/// returns a list of all possible modes
std::vector<std::string> getDisplayModes() const override;
/// Update the Mesh representation
void updateData(const App::Property*) override;
protected:
SoTransformerManip *pcTransformerDragger;
SoTransformerManip* pcTransformerDragger;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESHGUI_VIEWPROVIDERMESHTRANSFORM_H
#endif // MESHGUI_VIEWPROVIDERMESHTRANSFORM_H

View File

@@ -22,30 +22,30 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedFaceSet.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Inventor/draggers/SoTrackballDragger.h>
# include <Inventor/nodes/SoAntiSquish.h>
# include <Inventor/nodes/SoSurroundScale.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/manips/SoTransformerManip.h>
#include <Inventor/draggers/SoTrackballDragger.h>
#include <Inventor/manips/SoTransformerManip.h>
#include <Inventor/nodes/SoAntiSquish.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoMaterialBinding.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSurroundScale.h>
#endif
#include <Base/Console.h>
#include <Gui/SoFCSelection.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "ViewProviderTransformDemolding.h"
using Mesh::Feature;
using MeshCore::MeshKernel;
using MeshCore::MeshFacetIterator;
using MeshCore::MeshGeomFacet;
using MeshCore::MeshKernel;
using namespace MeshGui;
@@ -54,95 +54,94 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransformDemolding, MeshGui::ViewProvid
ViewProviderMeshTransformDemolding::ViewProviderMeshTransformDemolding()
{
pcTrackballDragger = new SoTrackballDragger;
pcTrackballDragger->ref();
pcTransformDrag = nullptr;
pcColorMat = nullptr;
pcTrackballDragger = new SoTrackballDragger;
pcTrackballDragger->ref();
pcTransformDrag = nullptr;
pcColorMat = nullptr;
}
ViewProviderMeshTransformDemolding::~ViewProviderMeshTransformDemolding()
{
pcTrackballDragger->unref();
pcTrackballDragger->unref();
}
void ViewProviderMeshTransformDemolding::attach(App::DocumentObject *pcFeat)
void ViewProviderMeshTransformDemolding::attach(App::DocumentObject* pcFeat)
{
// creates the standard viewing modes
ViewProviderMesh::attach(pcFeat);
// creates the standard viewing modes
ViewProviderMesh::attach(pcFeat);
SoGroup* pcDemoldRoot = new SoGroup();
SoGroup* pcDemoldRoot = new SoGroup();
SoDrawStyle *pcFlatStyle = new SoDrawStyle();
pcFlatStyle->style = SoDrawStyle::FILLED;
pcDemoldRoot->addChild(pcFlatStyle);
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
pcFlatStyle->style = SoDrawStyle::FILLED;
pcDemoldRoot->addChild(pcFlatStyle);
// dragger
SoSeparator * surroundsep = new SoSeparator;
// dragger
SoSeparator* surroundsep = new SoSeparator;
SoSurroundScale * ss = new SoSurroundScale;
ss->numNodesUpToReset = 1;
ss->numNodesUpToContainer = 2;
surroundsep->addChild(ss);
SoSurroundScale* ss = new SoSurroundScale;
ss->numNodesUpToReset = 1;
ss->numNodesUpToContainer = 2;
surroundsep->addChild(ss);
SoAntiSquish * antisquish = new SoAntiSquish;
antisquish->sizing = SoAntiSquish::AVERAGE_DIMENSION ;
surroundsep->addChild(antisquish);
SoAntiSquish* antisquish = new SoAntiSquish;
antisquish->sizing = SoAntiSquish::AVERAGE_DIMENSION;
surroundsep->addChild(antisquish);
pcTrackballDragger->addValueChangedCallback(sValueChangedCallback,this);
pcTrackballDragger->addFinishCallback (sDragEndCallback,this);
surroundsep->addChild(pcTrackballDragger);
pcTrackballDragger->addValueChangedCallback(sValueChangedCallback, this);
pcTrackballDragger->addFinishCallback(sDragEndCallback, this);
surroundsep->addChild(pcTrackballDragger);
pcTransformDrag = new SoTransform();
pcTransformDrag = new SoTransform();
SoMaterialBinding* pcMatBinding = new SoMaterialBinding;
//pcMatBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
pcMatBinding->value = SoMaterialBinding::PER_FACE_INDEXED;
pcColorMat = new SoMaterial;
pcColorMat->diffuseColor.set1Value(0, 1,1,0);
pcColorMat->diffuseColor.set1Value(1, 1,0,0);
pcColorMat->diffuseColor.set1Value(2, 0,1,0);
pcDemoldRoot->addChild(surroundsep);
pcDemoldRoot->addChild(pcTransformDrag);
pcDemoldRoot->addChild(pcColorMat);
pcDemoldRoot->addChild(pcMatBinding);
pcDemoldRoot->addChild(pcHighlight);
SoMaterialBinding* pcMatBinding = new SoMaterialBinding;
// pcMatBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
pcMatBinding->value = SoMaterialBinding::PER_FACE_INDEXED;
pcColorMat = new SoMaterial;
pcColorMat->diffuseColor.set1Value(0, 1, 1, 0);
pcColorMat->diffuseColor.set1Value(1, 1, 0, 0);
pcColorMat->diffuseColor.set1Value(2, 0, 1, 0);
// adding to the switch
addDisplayMaskMode(pcDemoldRoot, "Demold");
pcDemoldRoot->addChild(surroundsep);
pcDemoldRoot->addChild(pcTransformDrag);
pcDemoldRoot->addChild(pcColorMat);
pcDemoldRoot->addChild(pcMatBinding);
pcDemoldRoot->addChild(pcHighlight);
calcNormalVector();
calcMaterialIndex(SbRotation());
// getting center point
center = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel().GetBoundBox().GetCenter();
// adding to the switch
addDisplayMaskMode(pcDemoldRoot, "Demold");
//SoGetBoundingBoxAction boxAction;
//pcHighlight->getBoundingBox(&boxAction);
//SbVector3f Center = boxAction->getCenter();
calcNormalVector();
calcMaterialIndex(SbRotation());
// getting center point
center = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel().GetBoundBox().GetCenter();
// SoGetBoundingBoxAction boxAction;
// pcHighlight->getBoundingBox(&boxAction);
// SbVector3f Center = boxAction->getCenter();
}
void ViewProviderMeshTransformDemolding::calcNormalVector()
{
const MeshKernel& cMesh = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel();
const MeshKernel& cMesh = static_cast<Feature*>(pcObject)->Mesh.getValue().getKernel();
MeshFacetIterator cFIt(cMesh);
for( cFIt.Init(); cFIt.More(); cFIt.Next())
{
const MeshGeomFacet& rFace = *cFIt;
MeshFacetIterator cFIt(cMesh);
for (cFIt.Init(); cFIt.More(); cFIt.Next()) {
const MeshGeomFacet& rFace = *cFIt;
Base::Vector3f norm(rFace.GetNormal());
normalVector.emplace_back(norm.x,norm.y,norm.z);
}
Base::Vector3f norm(rFace.GetNormal());
normalVector.emplace_back(norm.x, norm.y, norm.z);
}
}
void ViewProviderMeshTransformDemolding::calcMaterialIndex(const SbRotation &rot)
void ViewProviderMeshTransformDemolding::calcMaterialIndex(const SbRotation& rot)
{
SbVec3f Up(0, 0, 1), result;
int i = 0;
for (std::vector<SbVec3f>::const_iterator it = normalVector.begin(); it != normalVector.end(); ++it, i++)
{
for (std::vector<SbVec3f>::const_iterator it = normalVector.begin(); it != normalVector.end();
++it, i++) {
rot.multVec(*it, result);
float Angle = acos((result.dot(Up)) / (result.length() * Up.length())) * (180 / M_PI);
@@ -159,58 +158,58 @@ void ViewProviderMeshTransformDemolding::calcMaterialIndex(const SbRotation &rot
}
}
void ViewProviderMeshTransformDemolding::sValueChangedCallback(void *This, SoDragger *)
void ViewProviderMeshTransformDemolding::sValueChangedCallback(void* This, SoDragger*)
{
static_cast<ViewProviderMeshTransformDemolding*>(This)->valueChangedCallback();
static_cast<ViewProviderMeshTransformDemolding*>(This)->valueChangedCallback();
}
void ViewProviderMeshTransformDemolding::sDragEndCallback(void *This, SoDragger *)
void ViewProviderMeshTransformDemolding::sDragEndCallback(void* This, SoDragger*)
{
static_cast<ViewProviderMeshTransformDemolding*>(This)->DragEndCallback();
static_cast<ViewProviderMeshTransformDemolding*>(This)->DragEndCallback();
}
void ViewProviderMeshTransformDemolding::DragEndCallback()
{
SbRotation rot = pcTrackballDragger->rotation.getValue();
calcMaterialIndex(rot);
Base::Console().Log("View: Finish dragging\n");
SbRotation rot = pcTrackballDragger->rotation.getValue();
calcMaterialIndex(rot);
Base::Console().Log("View: Finish dragging\n");
}
void ViewProviderMeshTransformDemolding::valueChangedCallback()
{
//Base::Console().Log("Value change Callback\n");
//setTransformation(pcTrackballDragger->getMotionMatrix());
//pcTransform->rotation = pcTrackballDragger->rotation;
SbMatrix temp;
SbRotation rot = pcTrackballDragger->rotation.getValue();
// Base::Console().Log("Value change Callback\n");
// setTransformation(pcTrackballDragger->getMotionMatrix());
// pcTransform->rotation = pcTrackballDragger->rotation;
SbMatrix temp;
SbRotation rot = pcTrackballDragger->rotation.getValue();
//calcMaterialIndex(rot);
// calcMaterialIndex(rot);
temp.setTransform( SbVec3f(0,0,0), // no transformation
rot, // rotation from the dragger
SbVec3f(1,1,1), // no scaling
SbRotation() , // no scaling orientation
SbVec3f(center.x,center.y,center.z)); // center of rotation
pcTransformDrag->setMatrix( temp );
temp.setTransform(SbVec3f(0, 0, 0), // no transformation
rot, // rotation from the dragger
SbVec3f(1, 1, 1), // no scaling
SbRotation(), // no scaling orientation
SbVec3f(center.x, center.y, center.z)); // center of rotation
pcTransformDrag->setMatrix(temp);
}
void ViewProviderMeshTransformDemolding::setDisplayMode(const char* ModeName)
{
if ( strcmp("Demold",ModeName) == 0 )
setDisplayMaskMode("Demold");
ViewProviderMesh::setDisplayMode(ModeName);
if (strcmp("Demold", ModeName) == 0) {
setDisplayMaskMode("Demold");
}
ViewProviderMesh::setDisplayMode(ModeName);
}
const char* ViewProviderMeshTransformDemolding::getDefaultDisplayMode() const
{
return "Demold";
return "Demold";
}
std::vector<std::string> ViewProviderMeshTransformDemolding::getDisplayModes() const
{
std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes();
StrList.emplace_back("Demold");
return StrList;
std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes();
StrList.emplace_back("Demold");
return StrList;
}

View File

@@ -40,56 +40,56 @@ class SbRotation;
class SoTrackballDragger;
class SoTransformerManip;
namespace Gui {
class View3DInventorViewer;
namespace Gui
{
class View3DInventorViewer;
}
namespace MeshGui {
namespace MeshGui
{
/** Like Mesh viewprovider but with manipulator
*/
class ViewProviderMeshTransformDemolding : public ViewProviderMesh
class ViewProviderMeshTransformDemolding: public ViewProviderMesh
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshTransformDemolding);
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderMeshTransformDemolding);
public:
ViewProviderMeshTransformDemolding();
~ViewProviderMeshTransformDemolding() override;
ViewProviderMeshTransformDemolding();
~ViewProviderMeshTransformDemolding() override;
/**
* Extracts the mesh data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject *) override;
/**
* Extracts the mesh data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject*) override;
/// set the viewing mode
void setDisplayMode(const char* ModeName) override;
/// get the default display mode
const char* getDefaultDisplayMode() const override;
/// returns a list of all possible modes
std::vector<std::string> getDisplayModes() const override;
/// set the viewing mode
void setDisplayMode(const char* ModeName) override;
/// get the default display mode
const char* getDefaultDisplayMode() const override;
/// returns a list of all possible modes
std::vector<std::string> getDisplayModes() const override;
protected:
void calcMaterialIndex(const SbRotation &rot);
void calcNormalVector();
void calcMaterialIndex(const SbRotation& rot);
void calcNormalVector();
static void sValueChangedCallback(void *, SoDragger *);
void valueChangedCallback();
static void sValueChangedCallback(void*, SoDragger*);
void valueChangedCallback();
static void sDragEndCallback(void *, SoDragger *);
void DragEndCallback();
SoTrackballDragger *pcTrackballDragger;
SoTransform *pcTransformDrag;
SoMaterial *pcColorMat;
std::vector<SbVec3f> normalVector;
Base::Vector3f center;
static void sDragEndCallback(void*, SoDragger*);
void DragEndCallback();
SoTrackballDragger* pcTrackballDragger;
SoTransform* pcTransformDrag;
SoMaterial* pcColorMat;
std::vector<SbVec3f> normalVector;
Base::Vector3f center;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESGUI_VIEWPROVIDERMESHTRANSFORMDEMOLDING_H
#endif // MESGUI_VIEWPROVIDERMESHTRANSFORMDEMOLDING_H

View File

@@ -22,16 +22,16 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QGroupBox>
# include <QLabel>
#include <QGroupBox>
#include <QLabel>
#endif
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/MenuManager.h>
#include <Gui/Selection.h>
#include <Gui/ToolBarManager.h>
#include <Gui/TaskView/TaskView.h>
#include <Gui/ToolBarManager.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "Workbench.h"
@@ -39,7 +39,7 @@
using namespace MeshGui;
#if 0 // needed for Qt's lupdate utility
#if 0 // needed for Qt's lupdate utility
qApp->translate("Workbench", "Analyze");
qApp->translate("Workbench", "Boolean");
qApp->translate("Workbench", "&Meshes");
@@ -57,10 +57,11 @@ TYPESYSTEM_SOURCE(MeshGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench() = default;
class MeshInfoWatcher : public Gui::TaskView::TaskWatcher, public Gui::SelectionObserver
class MeshInfoWatcher: public Gui::TaskView::TaskWatcher, public Gui::SelectionObserver
{
public:
MeshInfoWatcher() : TaskWatcher(nullptr)
MeshInfoWatcher()
: TaskWatcher(nullptr)
{
labelPoints = new QLabel();
labelPoints->setText(tr("Number of points:"));
@@ -82,7 +83,7 @@ public:
QGroupBox* box = new QGroupBox();
box->setTitle(tr("Mesh info box"));
//box->setAutoFillBackground(true);
// box->setAutoFillBackground(true);
QGridLayout* grid = new QGridLayout(box);
grid->addWidget(labelPoints, 0, 0);
grid->addWidget(numPoints, 0, 1);
@@ -94,8 +95,8 @@ public:
grid->addWidget(labelMax, 3, 0);
grid->addWidget(numMax, 3, 1);
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
QPixmap(), tr("Mesh info"), false, nullptr);
Gui::TaskView::TaskBox* taskbox =
new Gui::TaskView::TaskBox(QPixmap(), tr("Mesh info"), false, nullptr);
taskbox->groupLayout()->addWidget(box);
Content.push_back(taskbox);
}
@@ -106,7 +107,7 @@ public:
void onSelectionChanged(const Gui::SelectionChanges&) override
{
Base::BoundBox3d bbox;
unsigned long countPoints=0, countFacets=0;
unsigned long countPoints = 0, countFacets = 0;
std::vector<Mesh::Feature*> mesh = Gui::Selection().getObjectsOfType<Mesh::Feature>();
for (auto it : mesh) {
countPoints += it->Mesh.getValue().countPoints();
@@ -117,10 +118,8 @@ public:
if (countPoints > 0) {
numPoints->setText(QString::number(countPoints));
numFacets->setText(QString::number(countFacets));
numMin->setText(tr("X: %1\tY: %2\tZ: %3")
.arg(bbox.MinX).arg(bbox.MinY).arg(bbox.MinZ));
numMax->setText(tr("X: %1\tY: %2\tZ: %3")
.arg(bbox.MaxX).arg(bbox.MaxY).arg(bbox.MaxZ));
numMin->setText(tr("X: %1\tY: %2\tZ: %3").arg(bbox.MinX).arg(bbox.MinY).arg(bbox.MinZ));
numMax->setText(tr("X: %1\tY: %2\tZ: %3").arg(bbox.MaxX).arg(bbox.MaxY).arg(bbox.MaxZ));
}
else {
numPoints->setText(QString::fromLatin1(""));
@@ -154,15 +153,16 @@ void Workbench::deactivated()
{
Gui::Workbench::deactivated();
removeTaskWatcher();
}
void Workbench::setupContextMenu(const char* recipient,Gui::MenuItem* item) const
void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const
{
StdWorkbench::setupContextMenu( recipient, item );
if (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
{
*item << "Separator" << "Mesh_Import" << "Mesh_Export" << "Mesh_VertexCurvature";
StdWorkbench::setupContextMenu(recipient, item);
if (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
*item << "Separator"
<< "Mesh_Import"
<< "Mesh_Export"
<< "Mesh_VertexCurvature";
}
}
@@ -171,13 +171,17 @@ Gui::MenuItem* Workbench::setupMenuBar() const
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
Gui::MenuItem* item = root->findItem("&Windows");
Gui::MenuItem* mesh = new Gui::MenuItem;
root->insertItem( item, mesh );
root->insertItem(item, mesh);
// analyze
Gui::MenuItem* analyze = new Gui::MenuItem;
analyze->setCommand("Analyze");
*analyze << "Mesh_Evaluation" << "Mesh_EvaluateFacet" << "Mesh_CurvatureInfo" << "Separator"
<< "Mesh_EvaluateSolid" << "Mesh_BoundingBox";
*analyze << "Mesh_Evaluation"
<< "Mesh_EvaluateFacet"
<< "Mesh_CurvatureInfo"
<< "Separator"
<< "Mesh_EvaluateSolid"
<< "Mesh_BoundingBox";
// boolean
Gui::MenuItem* boolean = new Gui::MenuItem;
@@ -191,7 +195,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
cutting->setCommand("Cutting");
*cutting << "Mesh_PolyCut"
<< "Mesh_PolyTrim"
//<< "Mesh_PolySegm"
//<< "Mesh_PolySegm"
<< "Mesh_TrimByPlane"
<< "Mesh_SectionByPlane"
<< "Mesh_CrossSections";
@@ -201,9 +205,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Mesh_Export"
<< "Mesh_FromPartShape"
<< "Mesh_RemeshGmsh"
<< "Separator"
<< analyze
<< "Mesh_VertexCurvature"
<< "Separator" << analyze << "Mesh_VertexCurvature"
<< "Mesh_HarmonizeNormals"
<< "Mesh_FlipNormals"
<< "Separator"
@@ -219,18 +221,17 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Mesh_Decimating"
<< "Mesh_Scale"
<< "Separator"
<< "Mesh_BuildRegularSolid"
<< boolean
<< cutting
<< "Separator"
<< "Mesh_BuildRegularSolid" << boolean << cutting << "Separator"
<< "Mesh_Merge"
<< "Mesh_SplitComponents"
<< "Separator";
Gui::CommandManager& mgr = Gui::Application::Instance->commandManager();
if (mgr.getCommandByName("MeshPart_CreateFlatMesh"))
if (mgr.getCommandByName("MeshPart_CreateFlatMesh")) {
*mesh << "MeshPart_CreateFlatMesh";
if (mgr.getCommandByName("MeshPart_CreateFlatFace"))
}
if (mgr.getCommandByName("MeshPart_CreateFlatFace")) {
*mesh << "MeshPart_CreateFlatFace";
}
return root;
}
@@ -298,14 +299,17 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
Gui::ToolBarItem* root = new Gui::ToolBarItem;
Gui::ToolBarItem* mesh;
mesh = new Gui::ToolBarItem( root );
mesh = new Gui::ToolBarItem(root);
mesh->setCommand("Mesh tools");
*mesh << "Mesh_Import" << "Mesh_Export" << "Mesh_PolyCut";
*mesh << "Mesh_Import"
<< "Mesh_Export"
<< "Mesh_PolyCut";
mesh = new Gui::ToolBarItem( root );
mesh = new Gui::ToolBarItem(root);
mesh->setCommand("Mesh test suite");
*mesh << "Mesh_Demolding" << "Mesh_Transform" << "Separator" ;
*mesh << "Mesh_Demolding"
<< "Mesh_Transform"
<< "Separator";
return root;
}

View File

@@ -25,33 +25,34 @@
#include <Gui/Workbench.h>
#ifndef MESH_GLOBAL_H
# include <Mod/Mesh/MeshGlobal.h>
#include <Mod/Mesh/MeshGlobal.h>
#endif
namespace MeshGui {
namespace MeshGui
{
/**
* @author Werner Mayer
*/
class MeshGuiExport Workbench : public Gui::StdWorkbench
class MeshGuiExport Workbench: public Gui::StdWorkbench
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
Workbench();
Workbench();
void activated() override;
void deactivated() override;
void setupContextMenu(const char* recipient, Gui::MenuItem*) const override;
void activated() override;
void deactivated() override;
void setupContextMenu(const char* recipient, Gui::MenuItem*) const override;
protected:
Gui::MenuItem* setupMenuBar() const override;
Gui::ToolBarItem* setupToolBars() const override;
Gui::ToolBarItem* setupCommandBars() const override;
Gui::MenuItem* setupMenuBar() const override;
Gui::ToolBarItem* setupToolBars() const override;
Gui::ToolBarItem* setupCommandBars() const override;
};
} // namespace MeshGui
} // namespace MeshGui
#endif // MESH_WORKBENCH_H
#endif // MESH_WORKBENCH_H

View File

@@ -1,3 +1,4 @@
// clang-format off
/* XPM */
static const char *mesh_fillhole[]={
"32 32 3 1",
@@ -36,4 +37,4 @@ static const char *mesh_fillhole[]={
"................................",
"................................",
"................................"};
// clang-format on

View File

@@ -21,4 +21,4 @@ FreeCAD.addExportType("Additive Manufacturing Format (*.amf)", "Mesh")
FreeCAD.addExportType("Simple Model Format (*.smf)", "Mesh")
FreeCAD.addExportType("3D Manufacturing Format (*.3mf)", "Mesh")
FreeCAD.__unit_test__ += [ "MeshTestsApp" ]
FreeCAD.__unit_test__ += ["MeshTestsApp"]

View File

@@ -5,46 +5,54 @@
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de> *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Lesser General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************/
# ***************************************************************************
# * Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * FreeCAD 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 Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
class MeshWorkbench (Workbench):
class MeshWorkbench(Workbench):
"Mesh workbench object"
def __init__(self):
self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Mesh/Resources/icons/MeshWorkbench.svg"
self.__class__.Icon = (
FreeCAD.getResourceDir() + "Mod/Mesh/Resources/icons/MeshWorkbench.svg"
)
self.__class__.MenuText = "Mesh"
self.__class__.ToolTip = "Mesh workbench"
def Initialize(self):
import Mesh
import MeshGui
try:
import flatmesh
import MeshFlatteningCommand
except ImportError as e:
import FreeCAD
FreeCAD.Console.PrintLog((str(e)))
def GetClassName(self):
return "MeshGui::Workbench"
Gui.addWorkbench(MeshWorkbench())

View File

@@ -27,8 +27,8 @@ __doc__ = "Enum types"
from enum import IntEnum
class Binding(IntEnum):
OVERALL = 0
PER_VERTEX = 1
PER_FACE = 2

View File

@@ -29,19 +29,19 @@
// Mesh
#ifndef MeshExport
#ifdef Mesh_EXPORTS
# define MeshExport FREECAD_DECL_EXPORT
#define MeshExport FREECAD_DECL_EXPORT
#else
# define MeshExport FREECAD_DECL_IMPORT
#define MeshExport FREECAD_DECL_IMPORT
#endif
#endif
// MeshGui
#ifndef MeshGuiExport
#ifdef MeshGui_EXPORTS
# define MeshGuiExport FREECAD_DECL_EXPORT
#define MeshGuiExport FREECAD_DECL_EXPORT
#else
# define MeshGuiExport FREECAD_DECL_IMPORT
#define MeshGuiExport FREECAD_DECL_IMPORT
#endif
#endif
#endif //MESH_GLOBAL_H
#endif // MESH_GLOBAL_H

View File

@@ -2,4 +2,3 @@
* \ingroup CWORKBENCHES
* \brief Tools to work with polygon meshes
*/