Back to index

salome-smesh  6.5.0
Functions | Variables
StdMeshers_NumberOfSegments.cxx File Reference
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Distribution.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Comment.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

Function Documentation

bool isCorrectArg ( const Handle(Expr_GeneralExpression)&  expr)

check if only 't' is unknown variable in expression

Definition at line 296 of file StdMeshers_NumberOfSegments.cxx.

{
  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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ostream& operator<< ( std::ostream &  save,
StdMeshers_NumberOfSegments &  hyp 
)

Definition at line 670 of file StdMeshers_NumberOfSegments.cxx.

{
  return hyp.SaveTo( save );
}
istream& operator>> ( std::istream &  load,
StdMeshers_NumberOfSegments &  hyp 
)

Definition at line 681 of file StdMeshers_NumberOfSegments.cxx.

{
  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 323 of file StdMeshers_NumberOfSegments.cxx.

{
  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 );
}

Here is the call graph for this function:


Variable Documentation

const double PRECISION = 1e-7

Definition at line 58 of file StdMeshers_NumberOfSegments.cxx.