}
+//////////////////////////////////////////
+// Utility functions
+//////////////////////////////////////////
+#include <QLocale>
+#include <QRegExp>
+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;
+}
_PTR(Study) getMyStudy();
};
+//////////////////////////////////////////
+// Utility functions
+//////////////////////////////////////////
+
+namespace PluginUtils
+{
+ GEOMSELECTIONTOOLS_EXPORT QString PrintDoubleValue( double, int = 16 );
+};
#endif // _GEOMSELECTIONTOOLS_H_
// 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,
## 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)