23
#include "PreCompiled.h"
25
#include <Inventor/SoDB.h>
26
#include <Inventor/SoInput.h>
27
#include <Inventor/annex/ForeignFiles/SoSTLFileKit.h>
28
#include <Inventor/nodes/SoSeparator.h>
30
#include <QApplication>
33
#include <Base/Console.h>
34
#include <Base/Interpreter.h>
35
#include <Base/PyObjectBase.h>
36
#include <Gui/Application.h>
37
#include <Gui/BitmapFactory.h>
38
#include <Gui/Language/Translator.h>
39
#include <Gui/WidgetFactory.h>
41
#include "DlgEvaluateMeshImp.h"
42
#include "DlgSettingsImportExportImp.h"
43
#include "DlgSettingsMeshView.h"
44
#include "PropertyEditorMesh.h"
45
#include "SoFCIndexedFaceSet.h"
46
#include "SoFCMeshObject.h"
48
#include "ThumbnailExtension.h"
49
#include "ViewProvider.h"
50
#include "ViewProviderCurvature.h"
51
#include "ViewProviderDefects.h"
52
#include "ViewProviderMeshFaceSet.h"
53
#include "ViewProviderPython.h"
54
#include "ViewProviderTransform.h"
55
#include "ViewProviderTransformDemolding.h"
61
void CreateMeshCommands();
63
void loadMeshResource()
66
Q_INIT_RESOURCE(Mesh);
67
Q_INIT_RESOURCE(Mesh_translation);
68
Gui::Translator::instance()->refresh();
73
class Module: public Py::ExtensionModule<Module>
77
: Py::ExtensionModule<Module>("MeshGui")
79
add_varargs_method("convertToSTL", &Module::convertToSTL, "Convert a scene into an STL.");
80
initialize("This module is the MeshGui module.");
84
Py::Object convertToSTL(const Py::Tuple& args)
88
if (!PyArg_ParseTuple(args.ptr(), "etet", "utf-8", &inname, "utf-8", &outname)) {
89
throw Py::Exception();
91
std::string inputName = std::string(inname);
93
std::string outputName = std::string(outname);
98
if (in.openFile(inputName.c_str())) {
99
SoSeparator* node = SoDB::readAll(&in);
102
SoSTLFileKit* stlKit = new SoSTLFileKit();
104
ok = stlKit->readScene(node);
105
stlKit->writeFile(outputName.c_str());
111
return Py::Boolean(ok);
115
PyObject* initModule()
117
return Base::Interpreter().addModule(new Module);
123
PyMOD_INIT_FUNC(MeshGui)
125
if (!Gui::Application::Instance) {
126
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
127
PyMOD_Return(nullptr);
132
Base::Interpreter().loadModule("Mesh");
134
catch (const Base::Exception& e) {
135
PyErr_SetString(PyExc_ImportError, e.what());
136
PyMOD_Return(nullptr);
138
PyObject* mod = MeshGui::initModule();
139
Base::Console().Log("Loading GUI of Mesh module... done\n");
142
Gui::BitmapFactory().addXPM("mesh_fillhole", mesh_fillhole);
145
CreateMeshCommands();
147
(void)new MeshGui::CleanupHandler;
153
Base::Interpreter().runString("import MeshFlatteningCommand");
155
catch (Base::PyException& err) {
156
err.ReportException();
160
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsMeshView>(
161
QT_TRANSLATE_NOOP("QObject", "Display"));
162
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsImportExport>(
163
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
165
Mesh::Extension3MFFactory::addProducer(new MeshGui::ThumbnailExtensionProducer);
169
MeshGui::SoFCMeshObjectElement ::initClass();
170
MeshGui::SoSFMeshObject ::initClass();
171
MeshGui::SoFCMeshObjectNode ::initClass();
172
MeshGui::SoFCMeshObjectShape ::initClass();
173
MeshGui::SoFCMeshSegmentShape ::initClass();
174
MeshGui::SoFCMeshObjectBoundary ::initClass();
175
MeshGui::SoFCMaterialEngine ::initClass();
176
MeshGui::SoFCIndexedFaceSet ::initClass();
177
MeshGui::SoFCMeshPickNode ::initClass();
178
MeshGui::SoFCMeshGridNode ::initClass();
179
MeshGui::SoPolygon ::initClass();
180
MeshGui::PropertyMeshKernelItem ::init();
181
MeshGui::ViewProviderMesh ::init();
182
MeshGui::ViewProviderMeshObject ::init();
183
MeshGui::ViewProviderIndexedFaceSet ::init();
184
MeshGui::ViewProviderMeshFaceSet ::init();
185
MeshGui::ViewProviderPython ::init();
186
MeshGui::ViewProviderExport ::init();
187
MeshGui::ViewProviderMeshCurvature ::init();
188
MeshGui::ViewProviderMeshTransform ::init();
189
MeshGui::ViewProviderMeshTransformDemolding ::init();
190
MeshGui::ViewProviderMeshDefects ::init();
191
MeshGui::ViewProviderMeshOrientation ::init();
192
MeshGui::ViewProviderMeshNonManifolds ::init();
193
MeshGui::ViewProviderMeshNonManifoldPoints ::init();
194
MeshGui::ViewProviderMeshDuplicatedFaces ::init();
195
MeshGui::ViewProviderMeshDuplicatedPoints ::init();
196
MeshGui::ViewProviderMeshDegenerations ::init();
197
MeshGui::ViewProviderMeshIndices ::init();
198
MeshGui::ViewProviderMeshSelfIntersections ::init();
199
MeshGui::ViewProviderMeshFolds ::init();
200
MeshGui::Workbench ::init();
201
Gui::ViewProviderBuilder::add(
202
Mesh::PropertyMeshKernel::getClassTypeId(),
203
MeshGui::ViewProviderMeshFaceSet::getClassTypeId());