#include "SMESH_Filter_i.hxx"
#include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
namespace SMESH
{
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString, const char* theArg){
- theString += Standard_CString(theArg);
- return theString;
- }
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString, int theArg){
- theString += TCollection_AsciiString(theArg);
- return theString;
+ size_t TPythonDump::myCounter = 0;
+
+ TPythonDump::
+ TPythonDump()
+ {
+ ++myCounter;
+ }
+ TPythonDump::
+ ~TPythonDump()
+ {
+ if(--myCounter == 0){
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ if(!aStudy->_is_nil()){
+ std::string aString = myStream.str();
+ TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
+ aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
+ }
+ }
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString, float theArg){
- theString += TCollection_AsciiString(theArg);
- return theString;
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::ElementType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case ALL:
+ myStream<<"ALL";
+ break;
+ case NODE:
+ myStream<<"NODE";
+ break;
+ case EDGE:
+ myStream<<"EDGE";
+ break;
+ case FACE:
+ myStream<<"FACE";
+ break;
+ case VOLUME:
+ myStream<<"VOLUME";
+ break;
+ }
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- const SMESH::long_array& theArg)
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::long_array& theArg)
{
- theString<<"[ ";
+ myStream<<"[ ";
CORBA::Long i = 1, iEnd = theArg.length();
for(; i <= iEnd; i++) {
- theString<<int(theArg[i-1]);
+ myStream<<theArg[i-1];
if(i < iEnd)
- theString<< ", ";
+ myStream<< ", ";
}
- theString<<" ]";
- return theString;
+ myStream<<" ]";
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- CORBA::Object_ptr theArg)
+ TPythonDump&
+ TPythonDump::
+ operator<<(CORBA::Object_ptr theArg)
{
CORBA::String_var aString("None");
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
}else if(!CORBA::is_nil(theArg)){
aString = SMESH_Gen_i::GetORB()->object_to_string(theArg);
}
- theString<<aString.in();
- return theString;
+ myStream<<aString.in();
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::FilterLibrary_i* theArg)
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterLibrary_i* theArg)
{
- theString += TCollection_AsciiString("aFilterLibrary_");
- theString += TCollection_AsciiString(int(theArg));
- return theString;
+ myStream<<"aFilterLibrary"<<theArg;
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::FilterManager_i* theArg)
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterManager_i* theArg)
{
- theString += TCollection_AsciiString("aFilterManager_");
- theString += TCollection_AsciiString(int(theArg));
- return theString;
+ myStream<<"aFilterManager"<<theArg;
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::Filter_i* theArg)
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Filter_i* theArg)
{
- theString += TCollection_AsciiString("aFilter_");
- theString += TCollection_AsciiString(int(theArg));
- return theString;
+ myStream<<"aFilter"<<theArg;
+ return *this;
}
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::Functor_i* theArg)
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Functor_i* theArg)
{
FunctorType aFunctorType = theArg->GetFunctorType();
switch(aFunctorType){
case FT_AspectRatio:
- theString += TCollection_AsciiString("anAspectRatio");
+ myStream<<"anAspectRatio";
break;
case FT_AspectRatio3D:
- theString += TCollection_AsciiString("anAspectRatio3D");
+ myStream<<"anAspectRatio3D";
break;
case FT_Warping:
- theString += TCollection_AsciiString("aWarping");
+ myStream<<"aWarping";
break;
case FT_MinimumAngle:
- theString += TCollection_AsciiString("aMinimumAngle");
+ myStream<<"aMinimumAngle";
break;
case FT_Taper:
- theString += TCollection_AsciiString("aTaper");
+ myStream<<"aTaper";
break;
case FT_Skew:
- theString += TCollection_AsciiString("aSkew");
+ myStream<<"aSkew";
break;
case FT_Area:
- theString += TCollection_AsciiString("aArea");
+ myStream<<"aArea";
break;
case FT_FreeBorders:
- theString += TCollection_AsciiString("aFreeBorders");
+ myStream<<"aFreeBorders";
break;
case FT_FreeEdges:
- theString += TCollection_AsciiString("aFreeEdges");
+ myStream<<"aFreeEdges";
break;
case FT_MultiConnection:
- theString += TCollection_AsciiString("aMultiConnection");
+ myStream<<"aMultiConnection";
break;
case FT_MultiConnection2D:
- theString += TCollection_AsciiString("aMultiConnection2D");
+ myStream<<"aMultiConnection2D";
break;
case FT_Length:
- theString += TCollection_AsciiString("aLength");
+ myStream<<"aLength";
break;
case FT_Length2D:
- theString += TCollection_AsciiString("aLength");
+ myStream<<"aLength";
break;
case FT_BelongToGeom:
- theString += TCollection_AsciiString("aBelongToGeom");
+ myStream<<"aBelongToGeom";
break;
case FT_BelongToPlane:
- theString += TCollection_AsciiString("aBelongToPlane");
+ myStream<<"aBelongToPlane";
break;
case FT_BelongToCylinder:
- theString += TCollection_AsciiString("aBelongToCylinder");
+ myStream<<"aBelongToCylinder";
break;
case FT_LyingOnGeom:
- theString += TCollection_AsciiString("aLyingOnGeom");
+ myStream<<"aLyingOnGeom";
break;
case FT_RangeOfIds:
- theString += TCollection_AsciiString("aRangeOfIds");
+ myStream<<"aRangeOfIds";
break;
case FT_BadOrientedVolume:
- theString += TCollection_AsciiString("aBadOrientedVolume");
+ myStream<<"aBadOrientedVolume";
break;
case FT_LessThan:
- theString += TCollection_AsciiString("aLessThan");
+ myStream<<"aLessThan";
break;
case FT_MoreThan:
- theString += TCollection_AsciiString("aMoreThan");
+ myStream<<"aMoreThan";
break;
case FT_EqualTo:
- theString += TCollection_AsciiString("anEqualTo");
+ myStream<<"anEqualTo";
break;
case FT_LogicalNOT:
- theString += TCollection_AsciiString("aLogicalNOT");
+ myStream<<"aLogicalNOT";
break;
case FT_LogicalAND:
- theString += TCollection_AsciiString("aLogicalAND");
+ myStream<<"aLogicalAND";
break;
case FT_LogicalOR:
- theString += TCollection_AsciiString("aLogicalOR");
+ myStream<<"aLogicalOR";
break;
case FT_Undefined:
- theString += TCollection_AsciiString("anUndefined");
+ myStream<<"anUndefined";
break;
}
- theString += Standard_CString("_");
- theString += TCollection_AsciiString(int(theArg));
- return theString;
- }
-
- size_t TPythonDump::myCounter = 0;
-
- TPythonDump::
- TPythonDump()
- {
- ++myCounter;
- }
- TPythonDump::
- ~TPythonDump()
- {
- if(--myCounter == 0){
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
- if(!aStudy->_is_nil()){
- aSMESHGen->AddToPythonScript(aStudy->StudyId(),myString);
- }
- }
+ myStream<<theArg;
+ return *this;
}
}
Predicate_i*
GetPredicate( Predicate_ptr thePredicate )
{
- PortableServer::ServantBase_var aServant = SMESH_Gen_i::GetServant( thePredicate );
- return dynamic_cast<Predicate_i*>(aServant.in());
+ return DownCast<Predicate_i*>(thePredicate);
}
}
const SMDS_Mesh*
MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
{
- SMESH_Mesh_i* anImplPtr =
- dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
+ SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
}
void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
{
myNumericalFunctorPtr->SetPrecision( thePrecision );
+ TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
}
CORBA::Long NumericalFunctor_i::GetPrecision()
GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
myBelongToGeomPtr->SetGeom( aLocShape );
+ TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
}
void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
void BelongToGeom_i::SetElementType(ElementType theType){
myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
}
FunctorType BelongToGeom_i::GetFunctorType()
delete myShapeName;
myShapeName = strdup( theName );
myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+ TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
}
char* BelongToGeom_i::GetShapeName()
}
myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
+ TPythonDump()<<this<<".SetSurface("<<theGeom<<",'"<<theType<<"')";
}
void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
delete myShapeName;
myShapeName = strdup( theName );
myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
+ TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
}
char* BelongToSurface_i::GetShapeName()
void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
{
myElementsOnSurfacePtr->SetTolerance( theToler );
+ TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
}
CORBA::Double BelongToSurface_i::GetTolerance()
void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
{
BelongToSurface_i::SetSurface( theGeom, theType );
+ TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
}
FunctorType BelongToPlane_i::GetFunctorType()
void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
{
BelongToSurface_i::SetSurface( theGeom, theType );
+ TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
}
FunctorType BelongToCylinder_i::GetFunctorType()
GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
myLyingOnGeomPtr->SetGeom( aLocShape );
+ TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
}
void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
void LyingOnGeom_i::SetElementType(ElementType theType){
myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
}
FunctorType LyingOnGeom_i::GetFunctorType()
delete myShapeName;
myShapeName = strdup( theName );
myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+ TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
}
char* LyingOnGeom_i::GetShapeName()
CORBA::Long iEnd = theIds.length();
for ( CORBA::Long i = 0; i < iEnd; i++ )
myRangeOfIdsPtr->AddToRange( theIds[ i ] );
+ TPythonDump()<<this<<".SetRange("<<theIds<<")";
}
CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
{
+ TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
return myRangeOfIdsPtr->SetRangeStr(
TCollection_AsciiString( (Standard_CString)theRange ) );
}
void RangeOfIds_i::SetElementType( ElementType theType )
{
myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
}
FunctorType RangeOfIds_i::GetFunctorType()
void Comparator_i::SetMargin( CORBA::Double theValue )
{
myComparatorPtr->SetMargin( theValue );
- TPythonDump()<<this<<".SetMargin("<<float(theValue)<<")";
+ TPythonDump()<<this<<".SetMargin("<<theValue<<")";
}
CORBA::Double Comparator_i::GetMargin()
if ( myNumericalFunctor )
myNumericalFunctor->Destroy();
- myNumericalFunctor = dynamic_cast<NumericalFunctor_i*>( SMESH_Gen_i::GetServant( theFunct ).in() );
+ myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
if ( myNumericalFunctor )
{
void EqualTo_i::SetTolerance( CORBA::Double theToler )
{
myEqualToPtr->SetTolerance( theToler );
- TPythonDump()<<this<<".SetTolerance("<<float(theToler)<<")";
+ TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
}
CORBA::Double EqualTo_i::GetTolerance()
const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
long aPrecision = theCriteria[ i ].Precision;
+
+ TPythonDump()<<this<<".SetCriteria(SMESH.Filter.Criteria("<<
+ aCriterion<<","<<aCompare<<","<<aThreshold<<","<<aUnary<<","<<aBinary<<","<<
+ aTolerance<<",'"<<aThresholdStr<<"',"<<aTypeOfElem<<","<<aPrecision<<")";
SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
aRes = myFilterMgr->CreateFilter();
aRes->SetCriteria( aCriteriaVar.inout() );
-
+
+ TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
+
return aRes;
}
{
delete myFileName;
myFileName = strdup( theFileName );
+ TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
}
//=======================================================================
else
{
aSection.appendChild( aFilterItem );
+ if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
+ TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
return true;
}
}
else
{
aSection.appendChild( aFilterItem );
+ TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
return true;
}
}
return false;
aParentNode.removeChild( aFilterNode );
+ TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
return true;
}
else
{
aFilterItem.ReplaceElement( aNewItem );
+ if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
+ TPythonDump()<<this<<".Replace('"<<theFilterName<<"',"<<theNewName<<"',"<<aFilter<<")";
return true;
}
}
aWriter << myDoc;
fclose( aOutFile );
+ TPythonDump()<<this<<".Save()";
return true;
}
CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
{
myFileName = strdup ( aFileName );
+ TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
return Save();
}
std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
};
+
+namespace SMESH
+{
+ template<class T>
+ T
+ DownCast(CORBA::Object_ptr theArg)
+ {
+ return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
+ }
+}
+
+
#endif
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
-#include <TCollection_AsciiString.hxx>
+#include <sstream>
namespace SMESH
{
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- const char* theArg);
-
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- int theArg);
-
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- float theArg);
-
class FilterLibrary_i;
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::FilterLibrary_i* theArg);
-
class FilterManager_i;
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::FilterManager_i* theArg);
-
class Filter_i;
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::Filter_i* theArg);
-
class Functor_i;
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- SMESH::Functor_i* theArg);
-
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- CORBA::Object_ptr theArg);
-
- TCollection_AsciiString&
- operator<<(TCollection_AsciiString& theString,
- const SMESH::long_array& theArg);
class TPythonDump
{
- TCollection_AsciiString myString;
+ std::ostringstream myStream;
static size_t myCounter;
public:
TPythonDump();
virtual ~TPythonDump();
- template<class T>
- TCollection_AsciiString&
- operator<<(T theArg){
- return myString<<theArg;
+ TPythonDump&
+ operator<<(long int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ operator<<(int theArg){
+ myStream<<theArg;
+ return *this;
}
+
+ TPythonDump&
+ operator<<(double theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ operator<<(float theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ operator<<(const void* theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ operator<<(const char* theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ operator<<(const SMESH::ElementType& theArg);
+
+ TPythonDump&
+ operator<<(const SMESH::long_array& theArg);
+
+ TPythonDump&
+ operator<<(CORBA::Object_ptr theArg);
+
+ TPythonDump&
+ operator<<(SMESH::FilterLibrary_i* theArg);
+
+ TPythonDump&
+ operator<<(SMESH::FilterManager_i* theArg);
+
+ TPythonDump&
+ operator<<(SMESH::Filter_i* theArg);
+
+ TPythonDump&
+ operator<<(SMESH::Functor_i* theArg);
};
}