diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 31df8e4e31..9384790627 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -35,6 +35,8 @@ # endif # include # include +# include +# include #endif #ifdef FC_OS_WIN32 @@ -1117,7 +1119,17 @@ Application::TransactionSignaller::~TransactionSignaller() { int64_t Application::applicationPid() { - return QCoreApplication::applicationPid(); + static int64_t randomNumber = []() { + auto tp = std::chrono::high_resolution_clock::now(); + auto dur = tp.time_since_epoch(); + auto seed = dur.count(); + std::mt19937 generator(static_cast(seed)); + constexpr int64_t minValue {1}; + constexpr int64_t maxValue {1000000}; + std::uniform_int_distribution distribution(minValue, maxValue); + return distribution(generator); + }(); + return randomNumber; } std::string Application::getHomePath() diff --git a/src/App/PreCompiled.h b/src/App/PreCompiled.h index 86389849a5..b421ee048b 100644 --- a/src/App/PreCompiled.h +++ b/src/App/PreCompiled.h @@ -69,6 +69,7 @@ // STL #include +#include #include #include #include diff --git a/src/Mod/Draft/importAirfoilDAT.py b/src/Mod/Draft/importAirfoilDAT.py index eb83199fbc..13e3d3d047 100644 --- a/src/Mod/Draft/importAirfoilDAT.py +++ b/src/Mod/Draft/importAirfoilDAT.py @@ -5,8 +5,7 @@ # # This module provides support for importing airfoil .dat files '''@package importAirfoilDAT -\ingroup DRAFT -\brief Airfoil (.dat) file importer +Airfoil (.dat) file importer This module provides support for importing airfoil .dat files. ''' diff --git a/src/Mod/Draft/importOCA.py b/src/Mod/Draft/importOCA.py index d1d2e61411..d88ad488ff 100644 --- a/src/Mod/Draft/importOCA.py +++ b/src/Mod/Draft/importOCA.py @@ -3,8 +3,7 @@ # \ingroup DRAFT # \brief OCA (Open CAD Format) file importer & exporter '''@package importOCA -\ingroup DRAFT -\brief OCA (Open CAD Format) file importer & exporter +OCA (Open CAD Format) file importer & exporter This module provides support for importing from and exporting to the OCA format or GCAD format from GCAD3D (http://www.gcad3d.org/). diff --git a/src/Mod/Fem/femmesh/meshtools.py b/src/Mod/Fem/femmesh/meshtools.py index 6783b264bd..9faffc1c1e 100644 --- a/src/Mod/Fem/femmesh/meshtools.py +++ b/src/Mod/Fem/femmesh/meshtools.py @@ -113,6 +113,9 @@ def get_femnodes_by_refshape(femmesh, ref): nodes += femmesh.getNodesByFace(r) elif r.ShapeType == "Solid": nodes += femmesh.getNodesBySolid(r) + elif r.ShapeType == "Compound": + for s in r.Solids: + nodes += femmesh.getNodesBySolid(s) else: FreeCAD.Console.PrintMessage(" No Vertice, Edge, Face or Solid as reference shapes!\n") return nodes @@ -1749,42 +1752,51 @@ def get_reference_group_elements(obj, aPart): childs = r[1] # FreeCAD.Console.PrintMessage("{}\n".format(parent)) # FreeCAD.Console.PrintMessage("{}\n".format(childs)) - for child in childs: - ref_shape = parent.getSubObject(child) - FreeCAD.Console.PrintLog(f"{ref_shape}\n") - found_element = geomtools.find_element_in_shape(aShape, ref_shape) - if found_element is not None: - elements.append(found_element) - else: - FreeCAD.Console.PrintError( - "Problem: For the geometry of the " - "following shape was no Shape found: {}\n".format(ref_shape) - ) - FreeCAD.Console.PrintMessage(" " + obj.Name + "\n") - FreeCAD.Console.PrintMessage(" " + str(obj.References) + "\n") - FreeCAD.Console.PrintMessage(" " + r[0].Name + "\n") - if parent.Name != aPart.Name: - FreeCAD.Console.PrintError( - "The reference Shape is not a child " - "nor it is the shape the mesh is made of. : {}\n".format(ref_shape) - ) - FreeCAD.Console.PrintMessage( - f"{aPart.Name}--> Name of the Feature we where searching in.\n" - ) - FreeCAD.Console.PrintMessage( - "{} --> Name of the parent Feature of reference Shape " - "(Use the same as in the line before and you " - "will have less trouble :-) !!!!!!).\n".format(parent.Name) - ) - # import Part - # Part.show(aShape) - # Part.show(ref_shape) + + for child1 in childs: + ref_shape1 = parent.getSubObject(child1) + subchilds = [ + ref_shape1, + ] + if ( + ref_shape1.ShapeType == "Compound" + ): # if user selects a compound, add all the solids in it + subchilds = ref_shape1.Solids + for ref_shape in subchilds: + FreeCAD.Console.PrintLog(f"{ref_shape}\n") + found_element = geomtools.find_element_in_shape(aShape, ref_shape) + if found_element is not None: + elements.append(found_element) else: - FreeCAD.Console.PrintError("This should not happen, please debug!\n") - # in this case we would not have needed to use the - # is_same_geometry() inside geomtools.find_element_in_shape() - # AFAIK we could have used the Part methods isPartner() or even isSame() - # We're going to find out when we need to debug this :-)! + FreeCAD.Console.PrintError( + "Problem: For the geometry of the " + "following shape was no Shape found: {}\n".format(ref_shape) + ) + FreeCAD.Console.PrintMessage(" " + obj.Name + "\n") + FreeCAD.Console.PrintMessage(" " + str(obj.References) + "\n") + FreeCAD.Console.PrintMessage(" " + r[0].Name + "\n") + if parent.Name != aPart.Name: + FreeCAD.Console.PrintError( + "The reference Shape is not a child " + "nor it is the shape the mesh is made of. : {}\n".format(ref_shape) + ) + FreeCAD.Console.PrintMessage( + f"{aPart.Name}--> Name of the Feature we where searching in.\n" + ) + FreeCAD.Console.PrintMessage( + "{} --> Name of the parent Feature of reference Shape " + "(Use the same as in the line before and you " + "will have less trouble :-) !!!!!!).\n".format(parent.Name) + ) + # import Part + # Part.show(aShape) + # Part.show(ref_shape) + else: + FreeCAD.Console.PrintError("This should not happen, please debug!\n") + # in this case we would not have needed to use the + # is_same_geometry() inside geomtools.find_element_in_shape() + # AFAIK we could have used the Part methods isPartner() or even isSame() + # We're going to find out when we need to debug this :-)! return (key, sorted(elements)) diff --git a/src/Mod/Fem/femtaskpanels/base_femmeshtaskpanel.py b/src/Mod/Fem/femtaskpanels/base_femmeshtaskpanel.py index 5ab36ebdd4..6175eba378 100644 --- a/src/Mod/Fem/femtaskpanels/base_femmeshtaskpanel.py +++ b/src/Mod/Fem/femtaskpanels/base_femmeshtaskpanel.py @@ -29,7 +29,6 @@ __url__ = "https://www.freecad.org" # \ingroup FEM # \brief base task panel for mesh object -import time from abc import ABC, abstractmethod from PySide import QtCore @@ -79,6 +78,11 @@ class _BaseMeshTaskPanel(base_femtaskpanel._BaseTaskPanel, ABC): QtCore.SIGNAL("finished(int,QProcess::ExitStatus)"), self.process_finished, ) + QtCore.QObject.connect( + self.tool.process, + QtCore.SIGNAL("finished(int,QProcess::ExitStatus)"), + self.stop_timer, + ) QtCore.QObject.connect( self.tool.process, QtCore.SIGNAL("readyReadStandardOutput()"), @@ -171,7 +175,6 @@ class _BaseMeshTaskPanel(base_femtaskpanel._BaseTaskPanel, ABC): QtGui.QApplication.restoreOverrideCursor() if self.tool.process.state() != QtCore.QProcess.ProcessState.NotRunning: self.tool.process.kill() - self._thread.quit() FreeCAD.Console.PrintWarning("Process aborted\n") else: return super().reject() @@ -189,19 +192,17 @@ class _BaseMeshTaskPanel(base_femtaskpanel._BaseTaskPanel, ABC): self.run_mesher() def update_timer_text(self): - if ( - self._thread.isRunning() - or self.tool.process.state() != QtCore.QProcess.ProcessState.NotRunning - ): - self.text_time.setText(f"Time: {time.time() - self.time_start:4.1f}") - else: - self.timer.stop() - QtGui.QApplication.restoreOverrideCursor() + self.text_time.setText(f"Time: {self.elapsed.elapsed()/1000:4.1f} s") + + def stop_timer(self, code, status): + self.timer.stop() + QtGui.QApplication.restoreOverrideCursor() def run_mesher(self): + self.elapsed = QtCore.QElapsedTimer() + self.elapsed.start() + self.update_timer_text() self.timer.start(100) - self.time_start = time.time() - self.text_time.setText(f"Time: {time.time() - self.time_start:4.1f}: ") self._thread.start() diff --git a/src/Mod/Fem/femtools/checksanalysis.py b/src/Mod/Fem/femtools/checksanalysis.py index f3fd2e0767..3e7e10e69a 100644 --- a/src/Mod/Fem/femtools/checksanalysis.py +++ b/src/Mod/Fem/femtools/checksanalysis.py @@ -109,6 +109,8 @@ def check_member_for_solver_calculix(analysis, solver, mesh, member): mat_ref_shty = "" for m in member.mats_linear: ref_shty = femutils.get_refshape_type(m["Object"]) + if ref_shty == "Compound": + ref_shty = "Solid" if not mat_ref_shty: mat_ref_shty = ref_shty if mat_ref_shty and ref_shty and ref_shty != mat_ref_shty: diff --git a/src/Mod/Import/App/ExportOCAF.cpp b/src/Mod/Import/App/ExportOCAF.cpp index 6b73a08ff2..8daa0cd823 100644 --- a/src/Mod/Import/App/ExportOCAF.cpp +++ b/src/Mod/Import/App/ExportOCAF.cpp @@ -446,14 +446,28 @@ void ExportOCAF::pushNode(int root_id, std::vector& hierarchical_label, std::vector& hierarchical_loc) { - TDF_Label root; - TDF_Label node; - root = hierarchical_label.at(root_id - 1); - node = hierarchical_label.at(node_id - 1); + auto isValidIndex = [&](std::size_t root, std::size_t node) { + // NOLINTBEGIN + if (root >= hierarchical_label.size()) { + return false; + } + if (node >= hierarchical_label.size() || node >= hierarchical_loc.size()) { + return false; + } - XCAFDoc_DocumentTool::ShapeTool(root)->AddComponent(root, - node, - hierarchical_loc.at(node_id - 1)); + return true; + // NOLINTEND + }; + if (isValidIndex(root_id - 1, node_id - 1)) { + TDF_Label root; + TDF_Label node; + TopLoc_Location locn; + root = hierarchical_label.at(root_id - 1); + node = hierarchical_label.at(node_id - 1); + locn = hierarchical_loc.at(node_id - 1); + + XCAFDoc_DocumentTool::ShapeTool(root)->AddComponent(root, node, locn); + } } // ---------------------------------------------------------------------------- diff --git a/src/Mod/PartDesign/Gui/ViewProviderBoolean.cpp b/src/Mod/PartDesign/Gui/ViewProviderBoolean.cpp index b0dbb910cf..b2fa6acbf5 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBoolean.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBoolean.cpp @@ -120,11 +120,14 @@ bool ViewProviderBoolean::onDelete(const std::vector &s) return ViewProvider::onDelete(s); } -void ViewProviderBoolean::attach(App::DocumentObject* obj) { +void ViewProviderBoolean::attach(App::DocumentObject* obj) +{ PartGui::ViewProviderPartExt::attach(obj); +} - //set default display mode to override the "Group" display mode - setDisplayMode("Flat Lines"); +const char* ViewProviderBoolean::getDefaultDisplayMode() const +{ + return "Flat Lines"; } void ViewProviderBoolean::onChanged(const App::Property* prop) { diff --git a/src/Mod/PartDesign/Gui/ViewProviderBoolean.h b/src/Mod/PartDesign/Gui/ViewProviderBoolean.h index 5cf6a72361..1f8a114d0a 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBoolean.h +++ b/src/Mod/PartDesign/Gui/ViewProviderBoolean.h @@ -49,6 +49,7 @@ public: bool onDelete(const std::vector &) override; void attach(App::DocumentObject*) override; + const char* getDefaultDisplayMode() const override; void onChanged(const App::Property* prop) override; protected: