Back to index

salome-smesh  6.5.0
Public Member Functions
SMESH::RangeOfIds Interface Reference

Abstract logical functor (predicate) "RangeOfIds". More...

import "SMESH_Filter.idl";

Inheritance diagram for SMESH::RangeOfIds:
Inheritance graph
[legend]
Collaboration diagram for SMESH::RangeOfIds:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void SetRange (in long_array theIds)
boolean SetRangeStr (in string theRange)
string GetRangeStr ()
void SetElementType (in ElementType theType)
boolean IsSatisfy (in long thEntityId)
void SetMesh (in SMESH_Mesh theMesh)
FunctorType GetFunctorType ()
ElementType GetElementType ()

Detailed Description

Abstract logical functor (predicate) "RangeOfIds".

Verify whether an Entity Id belongs to defined sequence of id's

Definition at line 350 of file SMESH_Filter.idl.


Member Function Documentation

Here is the caller graph for this function:

Definition at line 2771 of file SMESH_Controls.cxx.

{
  theResStr.Clear();

  TColStd_SequenceOfInteger     anIntSeq;
  TColStd_SequenceOfAsciiString aStrSeq;

  TColStd_MapIteratorOfMapOfInteger anIter( myIds );
  for ( ; anIter.More(); anIter.Next() )
  {
    int anId = anIter.Key();
    TCollection_AsciiString aStr( anId );
    anIntSeq.Append( anId );
    aStrSeq.Append( aStr );
  }

  for ( int i = 1, n = myMin.Length(); i <= n; i++ )
  {
    int aMinId = myMin( i );
    int aMaxId = myMax( i );

    TCollection_AsciiString aStr;
    if ( aMinId != IntegerFirst() )
      aStr += aMinId;

    aStr += "-";

    if ( aMaxId != IntegerLast() )
      aStr += aMaxId;

    // find position of the string in result sequence and insert string in it
    if ( anIntSeq.Length() == 0 )
    {
      anIntSeq.Append( aMinId );
      aStrSeq.Append( aStr );
    }
    else
    {
      if ( aMinId < anIntSeq.First() )
      {
        anIntSeq.Prepend( aMinId );
        aStrSeq.Prepend( aStr );
      }
      else if ( aMinId > anIntSeq.Last() )
      {
        anIntSeq.Append( aMinId );
        aStrSeq.Append( aStr );
      }
      else
        for ( int j = 1, k = anIntSeq.Length(); j <= k; j++ )
          if ( aMinId < anIntSeq( j ) )
          {
            anIntSeq.InsertBefore( j, aMinId );
            aStrSeq.InsertBefore( j, aStr );
            break;
          }
    }
  }

  if ( aStrSeq.Length() == 0 )
    return;

  theResStr = aStrSeq( 1 );
  for ( int j = 2, k = aStrSeq.Length(); j <= k; j++  )
  {
    theResStr += ",";
    theResStr += aStrSeq( j );
  }
}
boolean SMESH::Predicate::IsSatisfy ( in long  thEntityId) [inherited]
void SMESH::Functor::SetMesh ( in SMESH_Mesh  theMesh) [inherited]
bool RangeOfIds::SetRangeStr ( in string  theRange)

Definition at line 2846 of file SMESH_Controls.cxx.

{
  myMin.Clear();
  myMax.Clear();
  myIds.Clear();

  TCollection_AsciiString aStr = theStr;
  aStr.RemoveAll( ' ' );
  aStr.RemoveAll( '\t' );

  for ( int aPos = aStr.Search( ",," ); aPos != -1; aPos = aStr.Search( ",," ) )
    aStr.Remove( aPos, 2 );

  TCollection_AsciiString tmpStr = aStr.Token( ",", 1 );
  int i = 1;
  while ( tmpStr != "" )
  {
    tmpStr = aStr.Token( ",", i++ );
    int aPos = tmpStr.Search( '-' );

    if ( aPos == -1 )
    {
      if ( tmpStr.IsIntegerValue() )
        myIds.Add( tmpStr.IntegerValue() );
      else
        return false;
    }
    else
    {
      TCollection_AsciiString aMaxStr = tmpStr.Split( aPos );
      TCollection_AsciiString aMinStr = tmpStr;

      while ( aMinStr.Search( "-" ) != -1 ) aMinStr.RemoveAll( '-' );
      while ( aMaxStr.Search( "-" ) != -1 ) aMaxStr.RemoveAll( '-' );

      if ( (!aMinStr.IsEmpty() && !aMinStr.IsIntegerValue()) ||
           (!aMaxStr.IsEmpty() && !aMaxStr.IsIntegerValue()) )
        return false;

      myMin.Append( aMinStr.IsEmpty() ? IntegerFirst() : aMinStr.IntegerValue() );
      myMax.Append( aMaxStr.IsEmpty() ? IntegerLast()  : aMaxStr.IntegerValue() );
    }
  }

  return true;
}

The documentation for this interface was generated from the following files: