Salome HOME
GDD:
authorgdd <gdd>
Tue, 21 Sep 2010 13:48:27 +0000 (13:48 +0000)
committergdd <gdd>
Tue, 21 Sep 2010 13:48:27 +0000 (13:48 +0000)
- fix documentation of ConvertToQuadratic (inform about theForce3d parameter)
- New function PrintDoubleValue added in PluginUtils

src/PluginUtils/GeomSelectionTools.cxx
src/PluginUtils/GeomSelectionTools.h
src/SMESH/SMESH_MeshEditor.hxx
src/SMESH_SWIG/smeshDC.py

index a5297332461825677b8823e7c132b96f8e13c8e7..f6240c980ef08b1946717b752b9f69a855194903 100644 (file)
@@ -297,5 +297,47 @@ GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation(TopoDS_Shape S)
 }
 
 
+//////////////////////////////////////////
+// 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;
+}
 
index 0995556f194ab1c5c2d9f9fd67224e081e8569a9..d00a2ba22394fd6ffda6f20f5b8bb799c303f952 100644 (file)
@@ -78,6 +78,14 @@ public:
   _PTR(Study) getMyStudy();
 };
 
+//////////////////////////////////////////
+// Utility functions
+//////////////////////////////////////////
+
+namespace PluginUtils
+{
+  GEOMSELECTIONTOOLS_EXPORT QString PrintDoubleValue( double, int = 16 );
+};
 
 #endif // _GEOMSELECTIONTOOLS_H_
 
index 3855080f38a74472f166c3fd3c20bad6043f1405..f191158fd6717f7e762ae895abfb3a5438009e00 100644 (file)
@@ -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,
index d524cf81e4255d48949b13e33e63b748f949d64f..7987385f53683a84ab7d050c44091ee619d4975c 100644 (file)
@@ -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)