Version: 6.3.1
Functions | Variables

src/SMESH_I/SMESH_2smeshpy.cxx File Reference

#include "SMESH_2smeshpy.hxx"
#include "utilities.h"
#include "SMESH_PythonDump.hxx"
#include "SMESH_NoteBook.hxx"
#include "Resource_DataMapOfAsciiStringAsciiString.hxx"
#include "SMESH_Gen_i.hxx"
Include dependency graph for SMESH_2smeshpy.cxx:

Go to the source code of this file.

Functions

 IMPLEMENT_STANDARD_HANDLE (_pyObject, Standard_Transient)
 IMPLEMENT_STANDARD_HANDLE (_pyCommand, Standard_Transient)
 IMPLEMENT_STANDARD_HANDLE (_pyGen, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pyMesh, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pySubMesh, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pyMeshEditor, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pyHypothesis, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pySelfEraser, _pyObject)
 IMPLEMENT_STANDARD_HANDLE (_pyAlgorithm, _pyHypothesis)
 IMPLEMENT_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis)
 IMPLEMENT_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis)
 IMPLEMENT_STANDARD_RTTIEXT (_pyObject, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT (_pyCommand, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT (_pyGen, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pyMesh, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pySubMesh, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pyMeshEditor, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pyHypothesis, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pySelfEraser, _pyObject)
 IMPLEMENT_STANDARD_RTTIEXT (_pyAlgorithm, _pyHypothesis)
 IMPLEMENT_STANDARD_RTTIEXT (_pyComplexParamHypo, _pyHypothesis)
 IMPLEMENT_STANDARD_RTTIEXT (_pyNumberOfSegmentsHyp, _pyHypothesis)
 IMPLEMENT_STANDARD_RTTIEXT (_pyLayerDistributionHypo, _pyHypothesis)
 IMPLEMENT_STANDARD_RTTIEXT (_pySegmentLengthAroundVertexHyp, _pyHypothesis)
static Handle (_pyGen) theGen
 Container of commands into which the initial script is split.
 Handle (_pyCommand) _pyGen
 Convert a command using a specific converter.
 Handle (_pyHypothesis) _pyGen
 Find hypothesis by ID (entry)
 Handle (_pySubMesh) _pyGen
 Find subMesh by ID (entry)
static bool isWord (const char c, const bool dotIsWord)
 Check if char is a word part.

Variables

static TCollection_AsciiString theEmptyString

Function Documentation

static Handle ( _pyGen  ) [static]

Container of commands into which the initial script is split.

It also contains data coresponding to SMESH_Gen contents

Handle ( _pyCommand  )

Convert a command using a specific converter.

Set command be last in list of commands.

Parameters:
theCommand- the command to convert
theCmd- Command to be last

Definition at line 227 of file SMESH_2smeshpy.cxx.

References SMESH_2smeshpy.GenName(), _pyCommand.GetArg(), _pyCommand.GetNbArgs(), _pyCommand.GetString(), Handle(), SMESH_demo_hexa2_upd.hyp, PAL_MESH_041_mesh.mesh, MESSAGE, and _pyCommand.SetArg().

{
  // store theCommand in the sequence
  myCommands.push_back( new _pyCommand( theCommand, ++myNbCommands ));

  Handle(_pyCommand) aCommand = myCommands.back();
#ifdef DUMP_CONVERSION
  MESSAGE ( "## COM " << myNbCommands << ": "<< aCommand->GetString() );
#endif

  _pyID objID = aCommand->GetObject();

  if ( objID.IsEmpty() )
    return aCommand;

  // SMESH_Gen method?
  if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName()) {
    this->Process( aCommand );
    return aCommand;
  }

  // SMESH_Mesh method?
  map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.find( objID );
  if ( id_mesh != myMeshes.end() )
  {
    // check for mesh editor object
    if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
      _pyID editorID = aCommand->GetResultValue();
      Handle(_pyMeshEditor) editor = new _pyMeshEditor( aCommand );
      myMeshEditors.insert( make_pair( editorID, editor ));
      return aCommand;
    } 
    // check for SubMesh objects
    else if ( aCommand->GetMethod() == "GetSubMesh" ) { // SubMesh creation
      _pyID subMeshID = aCommand->GetResultValue();
      Handle(_pySubMesh) subMesh = new _pySubMesh( aCommand );
      myObjects.insert( make_pair( subMeshID, subMesh ));
    }
    
    id_mesh->second->Process( aCommand );
    return aCommand;
  }

  // SMESH_MeshEditor method?
  map< _pyID, Handle(_pyMeshEditor) >::iterator id_editor = myMeshEditors.find( objID );
  if ( id_editor != myMeshEditors.end() )
  {
    id_editor->second->Process( aCommand );
    TCollection_AsciiString processedCommand = aCommand->GetString();
    // some commands of SMESH_MeshEditor create meshes
    if ( aCommand->GetMethod().Search("MakeMesh") != -1 ) {
      Handle(_pyMesh) mesh = new _pyMesh( aCommand, aCommand->GetResultValue() );
      aCommand->GetString() = processedCommand; // discard changes made by _pyMesh
      myMeshes.insert( make_pair( mesh->GetID(), mesh ));
    }
    if ( aCommand->GetMethod() == "MakeBoundaryMesh") {
      _pyID meshID = aCommand->GetResultValue(0);
      if ( !myMeshes.count( meshID ) )
      {
        Handle(_pyMesh) mesh = new _pyMesh( aCommand, meshID );
        aCommand->GetString() = processedCommand; // discard changes made by _pyMesh
        myMeshes.insert( make_pair( meshID, mesh ));
      }
    }
    return aCommand;
  }
  // SMESH_Hypothesis method?
  list< Handle(_pyHypothesis) >::iterator hyp = myHypos.begin();
  for ( ; hyp != myHypos.end(); ++hyp )
    if ( !(*hyp)->IsAlgo() && objID == (*hyp)->GetID() ) {
      (*hyp)->Process( aCommand );
      return aCommand;
    }

  // other object method?
  map< _pyID, Handle(_pyObject) >::iterator id_obj = myObjects.find( objID );
  if ( id_obj != myObjects.end() ) {
    id_obj->second->Process( aCommand );
    return aCommand;
  }
//   if ( theCommand.Search( "aFilterManager" ) != -1 ) {
//     if ( theCommand.Search( "CreateFilterManager" ) != -1 )
//       myFilterManager = new _pySelfEraser( aCommand );
//     else if ( !myFilterManager.IsNull() )
//       myFilterManager->Process( aCommand );
//     return aCommand;
//   }

  // Add access to a wrapped mesh
  AddMeshAccessorMethod( aCommand );

  // Add access to a wrapped algorithm
  //  AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ???

  // PAL12227. PythonDump was not updated at proper time; result is
  //     aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1))
  // TypeError: __init__() takes exactly 11 arguments (10 given)
  char wrongCommand[] = "SMESH.Filter.Criterion(";
  if ( int beg = theCommand.Location( wrongCommand, 1, theCommand.Length() ))
  {
    _pyCommand tmpCmd( theCommand.SubString( beg, theCommand.Length() ), -1);
    // there must be 10 arguments, 5-th arg ThresholdID is missing,
    const int wrongNbArgs = 9, missingArg = 5;
    if ( tmpCmd.GetNbArgs() == wrongNbArgs )
    {
      for ( int i = wrongNbArgs; i > missingArg; --i )
        tmpCmd.SetArg( i + 1, tmpCmd.GetArg( i ));
      tmpCmd.SetArg(  missingArg, "''");
      aCommand->GetString().Trunc( beg - 1 );
      aCommand->GetString() += tmpCmd.GetString();
    }
  }
  return aCommand;
}
Handle ( _pyHypothesis  )

Find hypothesis by ID (entry)

Creates algorithm or hypothesis.

Find algorithm the created algorithm.

Parameters:
theHypID- The hypothesis ID
Return values:
Handle(_pyHypothesis)- The found hypothesis
Parameters:
theGeom- The shape ID the algorithm was created on
theMesh- The mesh ID that created the algorithm
dim- The algo dimension
Return values:
Handle(_pyHypothesis)- The found algo
Parameters:
theCreationCmd- The engine command creating a hypothesis
Return values:
Handle(_pyHypothesis)- Result _pyHypothesis

Definition at line 544 of file SMESH_2smeshpy.cxx.

References Handle(), and SMESH_demo_hexa2_upd.hyp.

{
  list< Handle(_pyHypothesis) >::iterator hyp = myHypos.begin();
  for ( ; hyp != myHypos.end(); ++hyp )
    if ( !hyp->IsNull() && theHypID == (*hyp)->GetID() )
      return *hyp;
  return Handle(_pyHypothesis)();
}
Handle ( _pySubMesh  )

Find subMesh by ID (entry)

Parameters:
theSubMeshID- The subMesh ID
Return values:
Handle(_pySubMesh)- The found subMesh

Definition at line 585 of file SMESH_2smeshpy.cxx.

References SMESH.DownCast(), and Handle().

{
  map< _pyID, Handle(_pyObject) >::iterator id_subMesh = myObjects.find(theSubMeshID);
  if ( id_subMesh != myObjects.end() )
    return Handle(_pySubMesh)::DownCast( id_subMesh->second );
  return Handle(_pySubMesh)();
}
IMPLEMENT_STANDARD_HANDLE ( _pyCommand  ,
Standard_Transient   
)
IMPLEMENT_STANDARD_HANDLE ( _pyMesh  ,
_pyObject   
)
IMPLEMENT_STANDARD_HANDLE ( _pySelfEraser  ,
_pyObject   
)
IMPLEMENT_STANDARD_HANDLE ( _pyAlgorithm  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_HANDLE ( _pySubMesh  ,
_pyObject   
)
IMPLEMENT_STANDARD_HANDLE ( _pyComplexParamHypo  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_HANDLE ( _pyNumberOfSegmentsHyp  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_HANDLE ( _pyGen  ,
_pyObject   
)
IMPLEMENT_STANDARD_HANDLE ( _pyMeshEditor  ,
_pyObject   
)
IMPLEMENT_STANDARD_HANDLE ( _pyObject  ,
Standard_Transient   
)
IMPLEMENT_STANDARD_HANDLE ( _pyHypothesis  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyMesh  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyGen  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pySelfEraser  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyAlgorithm  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyNumberOfSegmentsHyp  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyLayerDistributionHypo  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyObject  ,
Standard_Transient   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyCommand  ,
Standard_Transient   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyMeshEditor  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pySegmentLengthAroundVertexHyp  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyComplexParamHypo  ,
_pyHypothesis   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pySubMesh  ,
_pyObject   
)
IMPLEMENT_STANDARD_RTTIEXT ( _pyHypothesis  ,
_pyObject   
)
static bool isWord ( const char  c,
const bool  dotIsWord 
) [static]

Check if char is a word part.

Parameters:
c- The character to check
Return values:
bool- The check result

Definition at line 2218 of file SMESH_2smeshpy.cxx.

Referenced by _pyCommand.GetWord().

{
  return
    !isspace(c) && c != ',' && c != '=' && c != ')' && c != '(' && ( dotIsWord || c != '.');
}

Variable Documentation

TCollection_AsciiString theEmptyString [static]

Definition at line 76 of file SMESH_2smeshpy.cxx.

Referenced by _pyCommand.GetResultValue(), and _pyCommand.GetWord().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS