| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <Inventor/SoDB.h>
|
| | #include <Inventor/SoInput.h>
|
| | #include <Inventor/annex/ForeignFiles/SoSTLFileKit.h>
|
| | #include <Inventor/nodes/SoSeparator.h>
|
| |
|
| | #include <QApplication>
|
| |
|
| | #include <Base/Console.h>
|
| | #include <Base/Interpreter.h>
|
| | #include <Base/PyObjectBase.h>
|
| | #include <Gui/Application.h>
|
| | #include <Gui/BitmapFactory.h>
|
| | #include <Gui/Language/Translator.h>
|
| | #include <Gui/WidgetFactory.h>
|
| |
|
| | #include "DlgEvaluateMeshImp.h"
|
| | #include "DlgSettingsImportExportImp.h"
|
| | #include "DlgSettingsMeshView.h"
|
| | #include "PropertyEditorMesh.h"
|
| | #include "SoFCIndexedFaceSet.h"
|
| | #include "SoFCMeshObject.h"
|
| | #include "SoPolygon.h"
|
| | #include "ThumbnailExtension.h"
|
| | #include "ViewProvider.h"
|
| | #include "ViewProviderCurvature.h"
|
| | #include "ViewProviderDefects.h"
|
| | #include "ViewProviderMeshFaceSet.h"
|
| | #include "ViewProviderPython.h"
|
| | #include "ViewProviderTransform.h"
|
| | #include "ViewProviderTransformDemolding.h"
|
| | #include "Workbench.h"
|
| |
|
| |
|
| |
|
| | void CreateMeshCommands();
|
| |
|
| | void loadMeshResource()
|
| | {
|
| |
|
| | Q_INIT_RESOURCE(Mesh);
|
| | Q_INIT_RESOURCE(Mesh_translation);
|
| | Gui::Translator::instance()->refresh();
|
| | }
|
| |
|
| | namespace MeshGui
|
| | {
|
| | class Module: public Py::ExtensionModule<Module>
|
| | {
|
| | public:
|
| | Module()
|
| | : Py::ExtensionModule<Module>("MeshGui")
|
| | {
|
| | add_varargs_method("convertToSTL", &Module::convertToSTL, "Convert a scene into an STL.");
|
| | initialize("This module is the MeshGui module.");
|
| | }
|
| |
|
| | private:
|
| | Py::Object convertToSTL(const Py::Tuple& args)
|
| | {
|
| | char* inname {};
|
| | char* 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);
|
| | PyMem_Free(outname);
|
| |
|
| | bool ok = false;
|
| | SoInput in;
|
| | if (in.openFile(inputName.c_str())) {
|
| | SoSeparator* node = SoDB::readAll(&in);
|
| | if (node) {
|
| | node->ref();
|
| | SoSTLFileKit* stlKit = new SoSTLFileKit();
|
| | stlKit->ref();
|
| | ok = stlKit->readScene(node);
|
| | stlKit->writeFile(outputName.c_str());
|
| | stlKit->unref();
|
| | node->unref();
|
| | }
|
| | }
|
| |
|
| | return Py::Boolean(ok);
|
| | }
|
| | };
|
| |
|
| | PyObject* initModule()
|
| | {
|
| | return Base::Interpreter().addModule(new Module);
|
| | }
|
| |
|
| | }
|
| |
|
| |
|
| | PyMOD_INIT_FUNC(MeshGui)
|
| | {
|
| | if (!Gui::Application::Instance) {
|
| | PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
| | PyMOD_Return(nullptr);
|
| | }
|
| |
|
| |
|
| | try {
|
| | Base::Interpreter().loadModule("Mesh");
|
| | }
|
| | catch (const Base::Exception& e) {
|
| | PyErr_SetString(PyExc_ImportError, e.what());
|
| | PyMOD_Return(nullptr);
|
| | }
|
| | PyObject* mod = MeshGui::initModule();
|
| | Base::Console().log("Loading GUI of Mesh module… done\n");
|
| |
|
| |
|
| | CreateMeshCommands();
|
| | if (qApp) {
|
| | (void)new MeshGui::CleanupHandler;
|
| | }
|
| |
|
| |
|
| |
|
| | try {
|
| | Base::Interpreter().runString("import MeshFlatteningCommand");
|
| | }
|
| | catch (Base::PyException& err) {
|
| | err.reportException();
|
| | }
|
| |
|
| |
|
| | (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);
|
| |
|
| |
|
| |
|
| | MeshGui::SoFCMeshObjectElement ::initClass();
|
| | MeshGui::SoSFMeshObject ::initClass();
|
| | MeshGui::SoFCMeshObjectNode ::initClass();
|
| | MeshGui::SoFCMeshObjectShape ::initClass();
|
| | MeshGui::SoFCMeshSegmentShape ::initClass();
|
| | MeshGui::SoFCMeshObjectBoundary ::initClass();
|
| | MeshGui::SoFCMaterialEngine ::initClass();
|
| | MeshGui::SoFCIndexedFaceSet ::initClass();
|
| | MeshGui::SoFCMeshPickNode ::initClass();
|
| | MeshGui::SoFCMeshGridNode ::initClass();
|
| | MeshGui::SoPolygon ::initClass();
|
| | MeshGui::PropertyMeshKernelItem ::init();
|
| | MeshGui::ViewProviderMesh ::init();
|
| | MeshGui::ViewProviderMeshObject ::init();
|
| | MeshGui::ViewProviderIndexedFaceSet ::init();
|
| | MeshGui::ViewProviderMeshFaceSet ::init();
|
| | MeshGui::ViewProviderPython ::init();
|
| | MeshGui::ViewProviderExport ::init();
|
| | MeshGui::ViewProviderMeshCurvature ::init();
|
| | MeshGui::ViewProviderMeshTransform ::init();
|
| | MeshGui::ViewProviderMeshTransformDemolding ::init();
|
| | MeshGui::ViewProviderMeshDefects ::init();
|
| | MeshGui::ViewProviderMeshOrientation ::init();
|
| | MeshGui::ViewProviderMeshNonManifolds ::init();
|
| | MeshGui::ViewProviderMeshNonManifoldPoints ::init();
|
| | MeshGui::ViewProviderMeshDuplicatedFaces ::init();
|
| | MeshGui::ViewProviderMeshDuplicatedPoints ::init();
|
| | MeshGui::ViewProviderMeshDegenerations ::init();
|
| | MeshGui::ViewProviderMeshIndices ::init();
|
| | MeshGui::ViewProviderMeshSelfIntersections ::init();
|
| | MeshGui::ViewProviderMeshFolds ::init();
|
| | MeshGui::Workbench ::init();
|
| | Gui::ViewProviderBuilder::add(
|
| | Mesh::PropertyMeshKernel::getClassTypeId(),
|
| | MeshGui::ViewProviderMeshFaceSet::getClassTypeId());
|
| |
|
| |
|
| | loadMeshResource();
|
| |
|
| |
|
| | PyMOD_Return(mod);
|
| | }
|
| |
|