#include <SMESH_ControlsDef.hxx>

Public Member Functions | |
| RangeOfIds () | |
| virtual void | SetMesh (const SMDS_Mesh *theMesh) |
| virtual bool | IsSatisfy (long theNodeId) |
| virtual SMDSAbs_ElementType | GetType () const |
| virtual void | SetType (SMDSAbs_ElementType theType) |
| bool | AddToRange (long theEntityId) |
| void | GetRangeStr (TCollection_AsciiString &) |
| bool | SetRangeStr (const TCollection_AsciiString &) |
Protected Attributes | |
| const SMDS_Mesh * | myMesh |
| TColStd_SequenceOfInteger | myMin |
| TColStd_SequenceOfInteger | myMax |
| TColStd_MapOfInteger | myIds |
| SMDSAbs_ElementType | myType |
Definition at line 499 of file SMESH_ControlsDef.hxx.
| RangeOfIds::RangeOfIds | ( | ) |
Definition at line 2614 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myMesh, SMESH.Controls.RangeOfIds.myType, and SMDSAbs_All.
{
myMesh = 0;
myType = SMDSAbs_All;
}
| bool RangeOfIds::AddToRange | ( | long | theEntityId | ) |
Definition at line 2633 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myIds.
{
myIds.Add( theEntityId );
return true;
}
| void RangeOfIds::GetRangeStr | ( | TCollection_AsciiString & | theResStr | ) |
Definition at line 2644 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myIds, SMESH.Controls.RangeOfIds.myMax, and SMESH.Controls.RangeOfIds.myMin.
{
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 );
}
}
| SMDSAbs_ElementType RangeOfIds::GetType | ( | ) | const [virtual] |
Implements SMESH.Controls.Predicate.
Definition at line 2770 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myType.
{
return myType;
}
| bool RangeOfIds::IsSatisfy | ( | long | theNodeId | ) | [virtual] |
Implements SMESH.Controls.Predicate.
Definition at line 2788 of file SMESH_Controls.cxx.
References SMDS_Mesh.FindElement(), SMDS_Mesh.FindNode(), SMDS_MeshElement.GetType(), SMESH.Controls.RangeOfIds.myIds, SMESH.Controls.RangeOfIds.myMax, SMESH.Controls.RangeOfIds.myMesh, SMESH.Controls.RangeOfIds.myMin, SMESH.Controls.RangeOfIds.myType, SMDSAbs_All, and SMDSAbs_Node.
{
if ( !myMesh )
return false;
if ( myType == SMDSAbs_Node )
{
if ( myMesh->FindNode( theId ) == 0 )
return false;
}
else
{
const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
if ( anElem == 0 || (myType != anElem->GetType() && myType != SMDSAbs_All ))
return false;
}
if ( myIds.Contains( theId ) )
return true;
for ( int i = 1, n = myMin.Length(); i <= n; i++ )
if ( theId >= myMin( i ) && theId <= myMax( i ) )
return true;
return false;
}
| void RangeOfIds::SetMesh | ( | const SMDS_Mesh * | theMesh | ) | [virtual] |
Implements SMESH.Controls.Functor.
Definition at line 2624 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myMesh.
{
myMesh = theMesh;
}
| bool RangeOfIds::SetRangeStr | ( | const TCollection_AsciiString & | theStr | ) |
Definition at line 2719 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myIds, SMESH.Controls.RangeOfIds.myMax, and SMESH.Controls.RangeOfIds.myMin.
{
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;
}
| void RangeOfIds::SetType | ( | SMDSAbs_ElementType | theType | ) | [virtual] |
Definition at line 2779 of file SMESH_Controls.cxx.
References SMESH.Controls.RangeOfIds.myType.
{
myType = theType;
}
TColStd_MapOfInteger SMESH.Controls.RangeOfIds.myIds [protected] |
Definition at line 517 of file SMESH_ControlsDef.hxx.
Referenced by SMESH.Controls.RangeOfIds.AddToRange(), SMESH.Controls.RangeOfIds.GetRangeStr(), SMESH.Controls.RangeOfIds.IsSatisfy(), and SMESH.Controls.RangeOfIds.SetRangeStr().
TColStd_SequenceOfInteger SMESH.Controls.RangeOfIds.myMax [protected] |
Definition at line 516 of file SMESH_ControlsDef.hxx.
Referenced by SMESH.Controls.RangeOfIds.GetRangeStr(), SMESH.Controls.RangeOfIds.IsSatisfy(), and SMESH.Controls.RangeOfIds.SetRangeStr().
const SMDS_Mesh* SMESH.Controls.RangeOfIds.myMesh [protected] |
Definition at line 513 of file SMESH_ControlsDef.hxx.
Referenced by SMESH.Controls.RangeOfIds.IsSatisfy(), SMESH.Controls.RangeOfIds.RangeOfIds(), and SMESH.Controls.RangeOfIds.SetMesh().
TColStd_SequenceOfInteger SMESH.Controls.RangeOfIds.myMin [protected] |
Definition at line 515 of file SMESH_ControlsDef.hxx.
Referenced by SMESH.Controls.RangeOfIds.GetRangeStr(), SMESH.Controls.RangeOfIds.IsSatisfy(), and SMESH.Controls.RangeOfIds.SetRangeStr().
SMDSAbs_ElementType SMESH.Controls.RangeOfIds.myType [protected] |
Definition at line 519 of file SMESH_ControlsDef.hxx.
Referenced by SMESH.Controls.RangeOfIds.GetType(), SMESH.Controls.RangeOfIds.IsSatisfy(), SMESH.Controls.RangeOfIds.RangeOfIds(), and SMESH.Controls.RangeOfIds.SetType().