diff --git a/src/PluginUtils/GeomSelectionTools.cxx b/src/PluginUtils/GeomSelectionTools.cxx index a52973324..f6240c980 100644 --- a/src/PluginUtils/GeomSelectionTools.cxx +++ b/src/PluginUtils/GeomSelectionTools.cxx @@ -297,5 +297,47 @@ GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation(TopoDS_Shape S) } +////////////////////////////////////////// +// Utility functions +////////////////////////////////////////// +#include +#include +QString PluginUtils::PrintDoubleValue( double theValue, int thePrecision ) +{ + const double prec = 1e-12; + + if ( qAbs(theValue) < prec ) + return "0"; + + QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( thePrecision ) ); + + if ( prec > 0 ) { + int p = 0; + while ( p < thePrecision ) { + QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( p++ ) ); + double v = aRes.toDouble(); + double err = qAbs( theValue - v ); + if ( err > 0 && err <= prec ) + break; + } + } + + // remove trailing zeroes + + QRegExp expre( QString( "(%1|%2)[+-]?[0-9]+$" ).arg( QLocale().exponential().toLower(), + QLocale().exponential().toUpper() ) ); + + int idx = aRes.indexOf( expre ); + QString aResExp = ""; + if ( idx >= 0 ) { + aResExp = aRes.mid( idx ); + aRes = aRes.left( idx ); + } + + if ( aRes.contains( QLocale().decimalPoint() ) ) + aRes.remove( QRegExp( QString( "(\\%1|0)0*$" ).arg( QLocale().decimalPoint() ) ) ); + + return aRes == "-0" ? QString( "0" ) : aRes + aResExp; +} diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h index 0995556f1..d00a2ba22 100644 --- a/src/PluginUtils/GeomSelectionTools.h +++ b/src/PluginUtils/GeomSelectionTools.h @@ -78,6 +78,14 @@ public: _PTR(Study) getMyStudy(); }; +////////////////////////////////////////// +// Utility functions +////////////////////////////////////////// + +namespace PluginUtils +{ + GEOMSELECTIONTOOLS_EXPORT QString PrintDoubleValue( double, int = 16 ); +}; #endif // _GEOMSELECTIONTOOLS_H_ diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 3855080f3..f191158fd 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -540,12 +540,18 @@ public: // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2. void ConvertToQuadratic(const bool theForce3d); - //converts all mesh to quadratic one, deletes old elements, replacing - //them with quadratic ones with the same id. + // Converts all mesh to quadratic one, deletes old elements, replacing + // them with quadratic ones with the same id. + // If theForce3d = 1; this results in the medium node lying at the + // middle of the line segments connecting start and end node of a mesh + // element + // If theForce3d = 0; this results in the medium node lying at the + // geometrical edge from which the mesh element is built bool ConvertFromQuadratic(); - //converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing - //them with ordinary mesh elements with the same id. + // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing + // them with ordinary mesh elements with the same id. + // Returns true in case of success, false otherwise. static void AddToSameGroups (const SMDS_MeshElement* elemToAdd, const SMDS_MeshElement* elemInGroups, diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index d524cf81e..7987385f5 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -2768,6 +2768,9 @@ class Mesh: ## Converts the mesh to quadratic, deletes old elements, replacing # them with quadratic with the same id. + # @param theForce3d new node creation method: + # 0 - the medium node lies at the geometrical edge from which the mesh element is built + # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element # @ingroup l2_modif_tofromqu def ConvertToQuadratic(self, theForce3d): self.editor.ConvertToQuadratic(theForce3d)