mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-15 10:08:34 +05:00
GDD:
- fix documentation of ConvertToQuadratic (inform about theForce3d parameter) - New function PrintDoubleValue added in PluginUtils
This commit is contained in:
parent
13325ec615
commit
5fbfcdf41e
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,14 @@ public:
|
|||||||
_PTR(Study) getMyStudy();
|
_PTR(Study) getMyStudy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////
|
||||||
|
// Utility functions
|
||||||
|
//////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace PluginUtils
|
||||||
|
{
|
||||||
|
GEOMSELECTIONTOOLS_EXPORT QString PrintDoubleValue( double, int = 16 );
|
||||||
|
};
|
||||||
|
|
||||||
#endif // _GEOMSELECTIONTOOLS_H_
|
#endif // _GEOMSELECTIONTOOLS_H_
|
||||||
|
|
||||||
|
@ -540,12 +540,18 @@ public:
|
|||||||
// theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
|
// theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
|
||||||
|
|
||||||
void ConvertToQuadratic(const bool theForce3d);
|
void ConvertToQuadratic(const bool theForce3d);
|
||||||
//converts all mesh to quadratic one, deletes old elements, replacing
|
// Converts all mesh to quadratic one, deletes old elements, replacing
|
||||||
//them with quadratic ones with the same id.
|
// 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();
|
bool ConvertFromQuadratic();
|
||||||
//converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
|
// Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
|
||||||
//them with ordinary mesh elements with the same id.
|
// them with ordinary mesh elements with the same id.
|
||||||
|
// Returns true in case of success, false otherwise.
|
||||||
|
|
||||||
static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
||||||
const SMDS_MeshElement* elemInGroups,
|
const SMDS_MeshElement* elemInGroups,
|
||||||
|
@ -2768,6 +2768,9 @@ class Mesh:
|
|||||||
|
|
||||||
## Converts the mesh to quadratic, deletes old elements, replacing
|
## Converts the mesh to quadratic, deletes old elements, replacing
|
||||||
# them with quadratic with the same id.
|
# 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
|
# @ingroup l2_modif_tofromqu
|
||||||
def ConvertToQuadratic(self, theForce3d):
|
def ConvertToQuadratic(self, theForce3d):
|
||||||
self.editor.ConvertToQuadratic(theForce3d)
|
self.editor.ConvertToQuadratic(theForce3d)
|
||||||
|
Loading…
Reference in New Issue
Block a user