#include "StdMeshers_NumberOfSegments.hxx"#include "StdMeshers_Distribution.hxx"#include "SMESHDS_SubMesh.hxx"#include "SMESH_Mesh.hxx"#include <ExprIntrp_GenExp.hxx>#include <Expr_Array1OfNamedUnknown.hxx>#include <Expr_NamedUnknown.hxx>#include <TColStd_Array1OfReal.hxx>#include <TCollection_AsciiString.hxx>#include <TopExp.hxx>#include <TopTools_IndexedMapOfShape.hxx>#include <Standard_Failure.hxx>#include <Basics_Utils.hxx>
Go to the source code of this file.
Functions | |
| bool | isCorrectArg (const Handle(Expr_GeneralExpression)&expr) |
| check if only 't' is unknown variable in expression | |
| bool | process (const TCollection_AsciiString &str, int convMode, bool &syntax, bool &args, bool &non_neg, bool &non_zero, bool &singulars, double &sing_point) |
| this function parses the expression 'str' in order to check if syntax is correct ( result in 'syntax' ) and if only 't' is unknown variable in expression ( result in 'args' ) | |
| ostream & | operator<< (ostream &save, StdMeshers_NumberOfSegments &hyp) |
| istream & | operator>> (istream &load, StdMeshers_NumberOfSegments &hyp) |
Variables | |
| const double | PRECISION = 1e-7 |
| bool isCorrectArg | ( | const Handle(Expr_GeneralExpression)& | expr | ) |
check if only 't' is unknown variable in expression
Definition at line 295 of file StdMeshers_NumberOfSegments.cxx.
References SMESH.DownCast(), Handle(), ex21_lamp.name, and SMESH_AdvancedEditor.res.
Referenced by StdMeshersGUI_DistrPreview.init(), isCorrectArg(), and process().
{
Handle( Expr_NamedUnknown ) sub = Handle( Expr_NamedUnknown )::DownCast( expr );
if( !sub.IsNull() )
return sub->GetName()=="t";
bool res = true;
for( int i=1, n=expr->NbSubExpressions(); i<=n && res; i++ )
{
Handle( Expr_GeneralExpression ) sub = expr->SubExpression( i );
Handle( Expr_NamedUnknown ) name = Handle( Expr_NamedUnknown )::DownCast( sub );
if( !name.IsNull() )
{
if( name->GetName()!="t" )
res = false;
}
else
res = isCorrectArg( sub );
}
return res;
}
| ostream& operator<< | ( | std::ostream & | save, |
| StdMeshers_NumberOfSegments & | hyp | ||
| ) |
Definition at line 657 of file StdMeshers_NumberOfSegments.cxx.
References StdMeshers_NumberOfSegments.SaveTo().
{
return hyp.SaveTo( save );
}
| istream& operator>> | ( | std::istream & | load, |
| StdMeshers_NumberOfSegments & | hyp | ||
| ) |
Definition at line 668 of file StdMeshers_NumberOfSegments.cxx.
References StdMeshers_NumberOfSegments.LoadFrom().
{
return hyp.LoadFrom( load );
}
| bool process | ( | const TCollection_AsciiString & | str, |
| int | convMode, | ||
| bool & | syntax, | ||
| bool & | args, | ||
| bool & | non_neg, | ||
| bool & | non_zero, | ||
| bool & | singulars, | ||
| double & | sing_point | ||
| ) |
this function parses the expression 'str' in order to check if syntax is correct ( result in 'syntax' ) and if only 't' is unknown variable in expression ( result in 'args' )
Definition at line 322 of file StdMeshers_NumberOfSegments.cxx.
References Handle(), isCorrectArg(), PRECISION, and SMESH_AdvancedEditor.res.
Referenced by StdMeshers_NumberOfSegments.SetExpressionFunction().
{
Kernel_Utils::Localizer loc;
bool parsed_ok = true;
Handle( ExprIntrp_GenExp ) myExpr;
try {
#ifdef NO_CAS_CATCH
OCC_CATCH_SIGNALS;
#endif
myExpr = ExprIntrp_GenExp::Create();
myExpr->Process( str.ToCString() );
} catch(Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
parsed_ok = false;
}
syntax = false;
args = false;
if( parsed_ok && myExpr->IsDone() )
{
syntax = true;
args = isCorrectArg( myExpr->Expression() );
}
bool res = parsed_ok && syntax && args;
if( !res )
myExpr.Nullify();
non_neg = true;
singulars = false;
non_zero = false;
if( res )
{
FunctionExpr f( str.ToCString(), convMode );
const int max = 500;
for( int i=0; i<=max; i++ )
{
double t = double(i)/double(max), val;
if( !f.value( t, val ) )
{
sing_point = t;
singulars = true;
break;
}
if( val<0 )
{
non_neg = false;
break;
}
if( val>PRECISION )
non_zero = true;
}
}
return res && non_neg && non_zero && ( !singulars );
}
| const double PRECISION = 1e-7 |
Definition at line 57 of file StdMeshers_NumberOfSegments.cxx.
Referenced by process(), StdMeshers_NumberOfSegments.SetScaleFactor(), and StdMeshers_NumberOfSegments.SetTableFunction().