module SMESH
{
+ interface Predicate;
+
/*!
* SMESH_Group: base interface of group object
*/
* Adds elements to the group
*/
long Add( in long_array elem_ids );
+ long AddByPredicate( in Predicate thePredicate );
/*!
* Removes elements from the group
*/
long Remove( in long_array elem_ids );
+ long RemoveByPredicate( in Predicate thePredicate );
};
/*!
return aDist;
}
- int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
+ int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId )
{
if ( theMesh == 0 )
return 0;
myPrecision = -1;
}
-void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh )
+void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
int aResult = 0;
if (GetPoints(theElementId,P)){
- double aVal;
const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
SMDSAbs_ElementType aType = anFaceElem->GetType();
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next();
- long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[3];
myMesh = 0;
}
-void BadOrientedVolume::SetMesh( SMDS_Mesh* theMesh )
+void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
myMesh = 0;
}
-void FreeBorders::SetMesh( SMDS_Mesh* theMesh )
+void FreeBorders::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
myMesh = 0;
}
-void FreeEdges::SetMesh( SMDS_Mesh* theMesh )
+void FreeEdges::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
// name : SetMesh
// Purpose : Set mesh
//=======================================================================
-void RangeOfIds::SetMesh( SMDS_Mesh* theMesh )
+void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
Comparator::~Comparator()
{}
-void Comparator::SetMesh( SMDS_Mesh* theMesh )
+void Comparator::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myFunctor )
myFunctor->SetMesh( theMesh );
return myPredicate && !myPredicate->IsSatisfy( theId );
}
-void LogicalNOT::SetMesh( SMDS_Mesh* theMesh )
+void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myPredicate )
myPredicate->SetMesh( theMesh );
LogicalBinary::~LogicalBinary()
{}
-void LogicalBinary::SetMesh( SMDS_Mesh* theMesh )
+void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myPredicate1 )
myPredicate1->SetMesh( theMesh );
myPredicate = thePredicate;
}
-
template<class TElement, class TIterator, class TPredicate>
-void FillSequence(const TIterator& theIterator,
- TPredicate& thePredicate,
- Filter::TIdSequence& theSequence)
+inline void FillSequence(const TIterator& theIterator,
+ TPredicate& thePredicate,
+ Filter::TIdSequence& theSequence)
{
if ( theIterator ) {
while( theIterator->more() ) {
}
}
-Filter::TIdSequence
-Filter::GetElementsId( SMDS_Mesh* theMesh )
+void
+Filter::
+GetElementsId( const SMDS_Mesh* theMesh,
+ PredicatePtr thePredicate,
+ TIdSequence& theSequence )
{
- TIdSequence aSequence;
- if ( !theMesh || !myPredicate ) return aSequence;
+ theSequence.clear();
+
+ if ( !theMesh || !thePredicate )
+ return;
- myPredicate->SetMesh( theMesh );
+ thePredicate->SetMesh( theMesh );
- SMDSAbs_ElementType aType = myPredicate->GetType();
+ SMDSAbs_ElementType aType = thePredicate->GetType();
switch(aType){
- case SMDSAbs_Node:{
- FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Node:
+ FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Edge:{
- FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Edge:
+ FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Face:{
- FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Face:
+ FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Volume:{
- FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Volume:
+ FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_All:{
- FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
- FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
- FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+ case SMDSAbs_All:
+ FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
+ FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
+ FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
}
- }
- return aSequence;
+}
+
+void
+Filter::GetElementsId( const SMDS_Mesh* theMesh,
+ Filter::TIdSequence& theSequence )
+{
+ GetElementsId(theMesh,myPredicate,theSequence);
}
/*
myMesh = 0;
}
-void ManifoldPart::SetMesh( SMDS_Mesh* theMesh )
+void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
process();
myMesh = 0;
}
-void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh )
+void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myMesh == theMesh )
return;
{
public:
~Functor(){}
- virtual void SetMesh( SMDS_Mesh* theMesh ) = 0;
+ virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
virtual SMDSAbs_ElementType GetType() const = 0;
};
class NumericalFunctor: public virtual Functor{
public:
NumericalFunctor();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual double GetValue( long theElementId );
virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
virtual SMDSAbs_ElementType GetType() const = 0;
static bool GetPoints(const SMDS_MeshElement* theElem,
TSequenceOfXYZ& theRes);
protected:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
long myPrecision;
};
class FreeBorders: public virtual Predicate{
public:
FreeBorders();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
protected:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
};
class BadOrientedVolume: public virtual Predicate{
public:
BadOrientedVolume();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
protected:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
};
class FreeEdges: public virtual Predicate{
public:
FreeEdges();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
void GetBoreders(TBorders& theBorders);
protected:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
};
typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
{
public:
RangeOfIds();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theNodeId );
virtual SMDSAbs_ElementType GetType() const;
virtual void SetType( SMDSAbs_ElementType theType );
bool SetRangeStr( const TCollection_AsciiString& );
protected:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
TColStd_SequenceOfInteger myMin;
TColStd_SequenceOfInteger myMax;
public:
Comparator();
virtual ~Comparator();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetMargin(double theValue);
virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
virtual bool IsSatisfy( long theElementId ) = 0;
LogicalNOT();
virtual ~LogicalNOT();
virtual bool IsSatisfy( long theElementId );
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const;
public:
LogicalBinary();
virtual ~LogicalBinary();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate1(PredicatePtr thePred);
virtual void SetPredicate2(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const;
ManifoldPart();
~ManifoldPart();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
// inoke when all parameters already set
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
TVectorOfFacePtr& theFaces ) const;
private:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myMapIds;
TColStd_MapOfInteger myMapBadGeomIds;
TVectorOfFacePtr myAllFacePtr;
public:
ElementsOnSurface();
~ElementsOnSurface();
- virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
bool isOnSurface( const SMDS_MeshNode* theNode ) const;
private:
- SMDS_Mesh* myMesh;
+ const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myIds;
SMDSAbs_ElementType myType;
Handle(Geom_Surface) mySurf;
Filter();
virtual ~Filter();
virtual void SetPredicate(PredicatePtr thePred);
+
typedef std::vector<long> TIdSequence;
- virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
-
+
+ virtual
+ void
+ GetElementsId( const SMDS_Mesh* theMesh,
+ TIdSequence& theSequence );
+
+ static
+ void
+ GetElementsId( const SMDS_Mesh* theMesh,
+ PredicatePtr thePredicate,
+ TIdSequence& theSequence );
+
protected:
PredicatePtr myPredicate;
};
/// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
/// TopoDS_Shape is unknown
///////////////////////////////////////////////////////////////////////////////
-SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S)
+SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
{
if (myShape.IsNull()) MESSAGE("myShape is NULL");
int Index = ShapeToIndex(S);
- if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end())
- return myShapeIndexToSubMesh[Index];
+ TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
+ if (anIter != myShapeIndexToSubMesh.end())
+ return anIter->second;
else
return NULL;
}
//function : ShapeToIndex
//purpose :
//=======================================================================
-int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S)
+int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
{
if (myShape.IsNull())
MESSAGE("myShape is NULL");
const TopoDS_Shape & S);
TopoDS_Shape ShapeToMesh() const;
bool HasMeshElements(const TopoDS_Shape & S);
- SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
+ SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const;
SMESHDS_SubMesh * MeshElements(const int Index);
std::list<int> SubMeshIndices();
const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
SMESHDS_Script * GetScript();
void ClearScript();
- int ShapeToIndex(const TopoDS_Shape & aShape);
+ int ShapeToIndex(const TopoDS_Shape & aShape) const;
TopoDS_Shape IndexToShape(int ShapeIndex);
SMESHDS_SubMesh * NewSubMesh(int Index);
int myMeshID;
TopoDS_Shape myShape;
+
+ typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;
+ TShapeIndexToSubMesh myShapeIndexToSubMesh;
+
TopTools_IndexedMapOfShape myIndexToShape;
- std::map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
- std::set<SMESHDS_GroupBase*> myGroups;
+
+ typedef std::set<SMESHDS_GroupBase*> TGroups;
+ TGroups myGroups;
+
SMESHDS_Script* myScript;
};
LIB_SRC = \
SMESH_Gen_i.cxx \
SMESH_Gen_i_1.cxx \
- SMESH_Gen_i_DumpPython.cxx \
+ SMESH_DumpPython.cxx \
SMESH_Mesh_i.cxx \
SMESH_MEDMesh_i.cxx \
SMESH_MEDFamily_i.cxx \
--- /dev/null
+// File : SMESH_Gen_i_DumpPython.cxx
+// Created : Thu Mar 24 17:17:59 2005
+// Author : Julia DOROVSKIKH
+// Module : SMESH
+// $Header : $
+
+#include "SMESH_PythonDump.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Filter_i.hxx"
+
+#include <TColStd_HSequenceOfInteger.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;
+ }
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString, float theArg){
+ theString += TCollection_AsciiString(theArg);
+ return theString;
+ }
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString,
+ const SMESH::long_array& theArg)
+ {
+ theString<<"[ ";
+ CORBA::Long i = 1, iEnd = theArg.length();
+ for(; i <= iEnd; i++) {
+ theString<<int(theArg[i-1]);
+ if(i < iEnd)
+ theString<< ", ";
+ }
+ theString<<" ]";
+ return theString;
+ }
+
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString,
+ CORBA::Object_ptr theArg)
+ {
+ CORBA::String_var aString("None");
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+ if(!aSObject->_is_nil()){
+ aString = aSObject->GetID();
+ }else if(!CORBA::is_nil(theArg)){
+ aString = SMESH_Gen_i::GetORB()->object_to_string(theArg);
+ }
+ theString<<aString.in();
+ return theString;
+ }
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString,
+ SMESH::FilterLibrary_i* theArg)
+ {
+ theString += TCollection_AsciiString("aFilterLibrary_");
+ theString += TCollection_AsciiString(int(theArg));
+ return theString;
+ }
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString,
+ SMESH::FilterManager_i* theArg)
+ {
+ theString += TCollection_AsciiString("aFilterManager_");
+ theString += TCollection_AsciiString(int(theArg));
+ return theString;
+ }
+
+ TCollection_AsciiString&
+ operator<<(TCollection_AsciiString& theString,
+ SMESH::Functor_i* theArg)
+ {
+ FunctorType aFunctorType = theArg->GetFunctorType();
+ switch(aFunctorType){
+ case FT_AspectRatio:
+ theString += TCollection_AsciiString("anAspectRatio");
+ break;
+ case FT_AspectRatio3D:
+ theString += TCollection_AsciiString("anAspectRatio3D");
+ break;
+ case FT_Warping:
+ theString += TCollection_AsciiString("aWarping");
+ break;
+ case FT_MinimumAngle:
+ theString += TCollection_AsciiString("aMinimumAngle");
+ break;
+ case FT_Taper:
+ theString += TCollection_AsciiString("aTaper");
+ break;
+ case FT_Skew:
+ theString += TCollection_AsciiString("aSkew");
+ break;
+ case FT_Area:
+ theString += TCollection_AsciiString("aArea");
+ break;
+ case FT_FreeBorders:
+ theString += TCollection_AsciiString("aFreeBorders");
+ break;
+ case FT_FreeEdges:
+ theString += TCollection_AsciiString("aFreeEdges");
+ break;
+ case FT_MultiConnection:
+ theString += TCollection_AsciiString("aMultiConnection");
+ break;
+ case FT_MultiConnection2D:
+ theString += TCollection_AsciiString("aMultiConnection2D");
+ break;
+ case FT_Length:
+ theString += TCollection_AsciiString("aLength");
+ break;
+ case FT_Length2D:
+ theString += TCollection_AsciiString("aLength");
+ break;
+ case FT_BelongToGeom:
+ theString += TCollection_AsciiString("aBelongToGeom");
+ break;
+ case FT_BelongToPlane:
+ theString += TCollection_AsciiString("aBelongToPlane");
+ break;
+ case FT_BelongToCylinder:
+ theString += TCollection_AsciiString("aBelongToCylinder");
+ break;
+ case FT_LyingOnGeom:
+ theString += TCollection_AsciiString("aLyingOnGeom");
+ break;
+ case FT_RangeOfIds:
+ theString += TCollection_AsciiString("aRangeOfIds");
+ break;
+ case FT_BadOrientedVolume:
+ theString += TCollection_AsciiString("aBadOrientedVolume");
+ break;
+ case FT_LessThan:
+ theString += TCollection_AsciiString("aLessThan");
+ break;
+ case FT_MoreThan:
+ theString += TCollection_AsciiString("aMoreThan");
+ break;
+ case FT_EqualTo:
+ theString += TCollection_AsciiString("anEqualTo");
+ break;
+ case FT_LogicalNOT:
+ theString += TCollection_AsciiString("aLogicalNOT");
+ break;
+ case FT_LogicalAND:
+ theString += TCollection_AsciiString("aLogicalAND");
+ break;
+ case FT_LogicalOR:
+ theString += TCollection_AsciiString("aLogicalOR");
+ break;
+ case FT_Undefined:
+ theString += TCollection_AsciiString("anUndefined");
+ break;
+ }
+ theString += Standard_CString("_");
+ theString += TCollection_AsciiString(int(theArg));
+ return theString;
+ }
+
+ TPythonDump::
+ ~TPythonDump()
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ if(!aStudy->_is_nil()){
+ aSMESHGen->AddToPythonScript(aStudy->StudyId(),myString);
+ }
+ }
+}
+
+//=======================================================================
+//function : DumpPython
+//purpose :
+//=======================================================================
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean& isValidScript)
+{
+ SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+ if (CORBA::is_nil(aStudy))
+ return new Engines::TMPFile(0);
+
+ SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
+ if (CORBA::is_nil(aSO))
+ return new Engines::TMPFile(0);
+
+ // Map study entries to object names
+ Resource_DataMapOfAsciiStringAsciiString aMap;
+ TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
+
+ SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
+ for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
+ SALOMEDS::SObject_var aValue = Itr->Value();
+
+ TCollection_AsciiString aName (aValue->GetName());
+ if (aName.Length() > 0) {
+ int p, p2 = 1, e = aName.Length();
+ while ((p = aName.FirstLocationNotInSet(s, p2, e))) {
+ aName.SetValue(p, '_');
+ p2 = p;
+ }
+ aMap.Bind(TCollection_AsciiString(aValue->GetID()), aName);
+ }
+ }
+
+ // Get trace of restored study
+ //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
+ TCollection_AsciiString aSavedTrace (oldValue);
+
+ // Add trace of API methods calls and replace study entries by names
+ bool aValidScript;
+ //TCollection_AsciiString aScript = myGen.DumpPython
+ TCollection_AsciiString aScript = DumpPython_impl
+ (aStudy->StudyId(), aMap, isPublished, aValidScript, aSavedTrace);
+
+ int aLen = aScript.Length();
+ unsigned char* aBuffer = new unsigned char[aLen+1];
+ strcpy((char*)aBuffer, aScript.ToCString());
+
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
+ isValidScript = aValidScript;
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ * AddToPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
+{
+ if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
+ myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
+ }
+ myPythonScripts[theStudyID]->Append(theString);
+}
+
+//=============================================================================
+/*!
+ * RemoveLastFromPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
+{
+ if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+ int aLen = myPythonScripts[theStudyID]->Length();
+ myPythonScripts[theStudyID]->Remove(aLen);
+ }
+}
+
+//=======================================================================
+//function : AddToCurrentPyScript
+//purpose :
+//=======================================================================
+
+void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString)
+{
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ if (aStudy->_is_nil()) return;
+ aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString);
+}
+
+
+//=======================================================================
+//function : AddObject
+//purpose : add object to script string
+//=======================================================================
+
+TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
+ CORBA::Object_ptr theObject)
+{
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_var aSO =
+ aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
+ if ( !aSO->_is_nil() )
+ theStr += aSO->GetID();
+ else if ( !CORBA::is_nil( theObject ) )
+ theStr += GetORB()->object_to_string( theObject );
+ else
+ theStr += "None";
+
+ return theStr;
+}
+
+//=======================================================================
+//function : SavePython
+//purpose :
+//=======================================================================
+void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
+{
+ // Dump trace of API methods calls
+ TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
+
+ // Check contents of PythonObject attribute
+ SALOMEDS::SObject_var aSO = theStudy->FindComponent(ComponentDataType());
+ //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
+ SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
+ TCollection_AsciiString oldScript (oldValue);
+
+ if (oldScript.Length() > 0) {
+ oldScript += "\n";
+ oldScript += aScript;
+ } else {
+ oldScript = aScript;
+ }
+
+ // Store in PythonObject attribute
+ SALOMEDS::AttributePythonObject::_narrow(anAttr)->SetObject(oldScript.ToCString(), 1);
+
+ // Clean trace of API methods calls
+ CleanPythonTrace(theStudy->StudyId());
+}
+
+
+// impl
+
+
+//=============================================================================
+/*!
+ * FindEntries: Returns a sequence of start/end positions of entries in the string
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
+{
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ Standard_Integer aLen = theString.Length();
+ Standard_Boolean isFound = Standard_False;
+
+ char* arr = theString.ToCString();
+ Standard_Integer i = 0, j;
+
+ while(i < aLen) {
+ int c = (int)arr[i];
+ j = i+1;
+ if(c >= 48 && c <= 57) { //Is digit?
+
+ isFound = Standard_False;
+ while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
+ c = (int)arr[j++];
+ if(c == 58) isFound = Standard_True;
+ }
+
+ if (isFound) {
+ int prev = (i < 1) ? 0 : (int)arr[i - 1];
+ // last char should be a diggit,
+ // previous char should not be '"'.
+ if (arr[j-2] != 58 && prev != 34) {
+ aSeq->Append(i+1); // +1 because AsciiString starts from 1
+ aSeq->Append(j-1);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * DumpPython
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
+ (int theStudyID,
+ Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ bool isPublished,
+ bool& aValidScript,
+ const TCollection_AsciiString& theSavedTrace)
+{
+ TCollection_AsciiString aScript;
+ aScript += "import salome\n";
+ aScript += "import geompy\n\n";
+ aScript += "import SMESH\n";
+ aScript += "import StdMeshers\n\n";
+ aScript += "#import GEOM module\n";
+ aScript += "import string\n";
+ aScript += "import os\n";
+ aScript += "import sys\n";
+ aScript += "sys.path.append( os.path.dirname(__file__) )\n";
+ aScript += "exec(\"from \"+string.replace(__name__,\"SMESH\",\"GEOM\")+\" import *\")\n\n";
+
+ aScript += "def RebuildData(theStudy):";
+ aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")";
+ if ( isPublished )
+ aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
+ else
+ aScript += "\n\tsmesh.SetCurrentStudy(None)";
+
+ Standard_Integer posToInertGlobalVars = aScript.Length();
+ TCollection_AsciiString globalVars;
+
+ // Dump trace of restored study
+ if (theSavedTrace.Length() > 0) {
+ aScript += "\n";
+ aScript += theSavedTrace;
+ }
+
+ // Dump trace of API methods calls
+ TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID);
+ if (aNewLines.Length() > 0) {
+ aScript += "\n";
+ aScript += aNewLines;
+ }
+
+ // Find entries to be replaced by names
+ Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
+ Standard_Integer aLen = aSeq->Length();
+
+ if (aLen == 0)
+ return aScript;
+
+ // Replace entries by the names
+ GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
+ TColStd_SequenceOfAsciiString seqRemoved;
+ Resource_DataMapOfAsciiStringAsciiString mapRemoved;
+ Resource_DataMapOfAsciiStringAsciiString aNames;
+ Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
+ TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
+
+ for (Standard_Integer i = 1; i <= aLen; i += 2) {
+ anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
+ anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
+ if (theObjectNames.IsBound(anEntry)) {
+ aName = theObjectNames.Find(anEntry);
+ if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+ // diff objects have same name - make a new name
+ TCollection_AsciiString aName2;
+ Standard_Integer i = 0;
+ do {
+ aName2 = aName + "_" + ++i;
+ } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+ aName = aName2;
+ theObjectNames(anEntry) = aName;
+ }
+ } else {
+ // is a GEOM object?
+ aName = geom->GetDumpName( anEntry.ToCString() );
+ if ( aName.IsEmpty() ) {
+ // ? Removed Object ?
+ do {
+ aName = aBaseName + TCollection_AsciiString(++objectCounter);
+ } while (theObjectNames.IsBound(aName));
+ seqRemoved.Append(aName);
+ mapRemoved.Bind(anEntry, "1");
+ }
+ theObjectNames.Bind(anEntry, aName);
+ }
+ theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
+
+ anUpdatedScript += aName;
+ aNames.Bind(aName, "1");
+ aStart = aSeq->Value(i + 1) + 1;
+ }
+
+ // add final part of aScript
+ if (aSeq->Value(aLen) < aScriptLength)
+ anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
+
+ // Remove removed objects
+ anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()";
+ for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
+ anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
+ anUpdatedScript += seqRemoved.Value(ir);
+ anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)";
+ }
+ anUpdatedScript += "\n";
+
+ // Set object names
+ anUpdatedScript += "\n\tisGUIMode = ";
+ anUpdatedScript += isPublished;
+ anUpdatedScript += "\n\tif isGUIMode:";
+ anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
+ anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
+ anUpdatedScript += "\n";
+
+ Resource_DataMapOfAsciiStringAsciiString mapEntries;
+ for (Standard_Integer i = 1; i <= aLen; i += 2) {
+ anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
+ if (theObjectNames.IsBound(anEntry) &&
+ !mapEntries.IsBound(anEntry) &&
+ !mapRemoved.IsBound(anEntry)) {
+ aName = theObjectNames.Find(anEntry);
+ mapEntries.Bind(anEntry, aName);
+ anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID(";
+ anUpdatedScript += aName + "), \"" + aName + "\")";
+ }
+ }
+ anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
+
+ anUpdatedScript += "\n\n\tpass\n";
+
+ aValidScript = true;
+
+ return anUpdatedScript;
+}
+
+//=============================================================================
+/*!
+ * GetNewPythonLines
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
+{
+ TCollection_AsciiString aScript;
+
+ // Dump trace of API methods calls
+ if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++) {
+ aScript += "\n\t";
+ aScript += aPythonScript->Value(istr);
+ }
+ aScript += "\n";
+ }
+
+ return aScript;
+}
+
+//=============================================================================
+/*!
+ * CleanPythonTrace
+ */
+//=============================================================================
+void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
+{
+ TCollection_AsciiString aScript;
+
+ // Clean trace of API methods calls
+ if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+ myPythonScripts[theStudyID]->Clear();
+ }
+}
#include "SMESH_Filter_i.hxx"
#include "SMESH_Gen_i.hxx"
+#include "SMESH_PythonDump.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx"
using namespace SMESH;
using namespace SMESH::Controls;
+
+namespace SMESH
+{
+ Predicate_i*
+ GetPredicate( Predicate_ptr thePredicate )
+ {
+ PortableServer::ServantBase_var aServant = SMESH_Gen_i::GetServant( thePredicate );
+ return dynamic_cast<Predicate_i*>(aServant.in());
+ }
+}
+
+
/*
Class : BelongToGeom
Description : Predicate for verifying whether entiy belong to
myType(SMDSAbs_All)
{}
-void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh )
+void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
{
- myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
+ myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
}
void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
myShape = theShape;
}
-static bool IsContains( SMESHDS_Mesh* theMeshDS,
+static bool IsContains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
return myShape;
}
-SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS()
+const SMESHDS_Mesh*
+Controls::BelongToGeom::
+GetMeshDS() const
{
return myMeshDS;
}
myType(SMDSAbs_All)
{}
-void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh )
+void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
{
- myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
+ myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
}
void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
return myShape;
}
-SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS()
+const SMESHDS_Mesh*
+Controls::LyingOnGeom::
+GetMeshDS() const
{
return myMeshDS;
}
-bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS,
+bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
AUXILIARY METHODS
*/
-static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
+inline
+const SMDS_Mesh*
+MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
{
SMESH_Mesh_i* anImplPtr =
dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
}
-static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList )
+inline
+SMESH::long_array*
+toArray( const TColStd_ListOfInteger& aList )
{
SMESH::long_array_var anArray = new SMESH::long_array;
anArray->length( aList.Extent() );
return anArray._retn();
}
-static inline SMESH::double_array* toArray( const TColStd_ListOfReal& aList )
+inline
+SMESH::double_array*
+toArray( const TColStd_ListOfReal& aList )
{
SMESH::double_array_var anArray = new SMESH::double_array;
anArray->length( aList.Extent() );
void Comparator_i::SetMargin( CORBA::Double theValue )
{
myComparatorPtr->SetMargin( theValue );
+ TPythonDump()<<this<<".SetMargin("<<float(theValue)<<")";
}
CORBA::Double Comparator_i::GetMargin()
{
myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
myNumericalFunctor->Register();
+ TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
}
}
myPredicate->Destroy();
}
-void LogicalNOT_i::SetPredicate( Predicate_ptr thePred )
+void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
{
if ( myPredicate )
myPredicate->Destroy();
- myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePred ).in() );
+ myPredicate = SMESH::GetPredicate(thePredicate);
if ( myPredicate ){
myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
if ( myPredicate1 )
myPredicate1->Destroy();
- myPredicate1 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+ myPredicate1 = SMESH::GetPredicate(thePredicate);
if ( myPredicate1 ){
myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
if ( myPredicate2 )
myPredicate2->Destroy();
- myPredicate2 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+ myPredicate2 = SMESH::GetPredicate(thePredicate);
if ( myPredicate2 ){
myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
{
SMESH::Area_i* aServant = new SMESH::Area_i();
SMESH::Area_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
return anObj._retn();
}
{
SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
SMESH::MoreThan_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
return anObj._retn();
}
{
SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
SMESH::FilterManager_var anObj = aFilter->_this();
+ TPythonDump()<<aFilter<<" = smesh.CreateFilterManager()";
return anObj._retn();
}
if ( myPredicate )
myPredicate->Destroy();
- myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+ myPredicate = SMESH::GetPredicate(thePredicate);
if ( myPredicate )
{
// name : Filter_i::GetElementsId
// Purpose : Get ids of entities
//=======================================================================
+void
+Filter_i::
+GetElementsId( Predicate_i* thePredicate,
+ const SMDS_Mesh* theMesh,
+ Controls::Filter::TIdSequence& theSequence )
+{
+ Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
+}
+
+void
+Filter_i::
+GetElementsId( Predicate_i* thePredicate,
+ SMESH_Mesh_ptr theMesh,
+ Controls::Filter::TIdSequence& theSequence )
+{
+ if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
+ Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
+}
+
SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh )
{
- SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh);
- Controls::Filter::TIdSequence aSequence = myFilter.GetElementsId(aMesh);
+ Controls::Filter::TIdSequence aSequence;
+ GetElementsId(myPredicate,theMesh,aSequence);
SMESH::long_array_var anArray = new SMESH::long_array;
long i = 0, iEnd = aSequence.size();
namespace SMESH
{
-namespace Controls
-{
-
-/*
- Class : BelongToGeom
- Description : Predicate for verifying whether entiy belong to
- specified geometrical support
-*/
-class BelongToGeom: public virtual Predicate
-{
-public:
- BelongToGeom();
-
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual void SetGeom( const TopoDS_Shape& theShape );
-
- virtual bool IsSatisfy( long theElementId );
-
- virtual void SetType( SMDSAbs_ElementType theType );
- virtual SMDSAbs_ElementType GetType() const;
-
- TopoDS_Shape GetShape();
- SMESHDS_Mesh* GetMeshDS();
-
-private:
- TopoDS_Shape myShape;
- SMESHDS_Mesh* myMeshDS;
- SMDSAbs_ElementType myType;
-};
-typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
-
-/*
- Class : LyingOnGeom
- Description : Predicate for verifying whether entiy lying or partially lying on
- specified geometrical support
-*/
-class LyingOnGeom: public virtual Predicate
-{
-public:
- LyingOnGeom();
+ namespace Controls
+ {
+
+ /*
+ Class : BelongToGeom
+ Description : Predicate for verifying whether entiy belong to
+ specified geometrical support
+ */
+ class BelongToGeom: public virtual Predicate
+ {
+ public:
+ BelongToGeom();
+
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual void SetGeom( const TopoDS_Shape& theShape );
+
+ virtual bool IsSatisfy( long theElementId );
+
+ virtual void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ TopoDS_Shape GetShape();
+ const SMESHDS_Mesh* GetMeshDS() const;
+
+ private:
+ TopoDS_Shape myShape;
+ const SMESHDS_Mesh* myMeshDS;
+ SMDSAbs_ElementType myType;
+ };
+ typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
+
+ /*
+ Class : LyingOnGeom
+ Description : Predicate for verifying whether entiy lying or partially lying on
+ specified geometrical support
+ */
+ class LyingOnGeom: public virtual Predicate
+ {
+ public:
+ LyingOnGeom();
+
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual void SetGeom( const TopoDS_Shape& theShape );
+
+ virtual bool IsSatisfy( long theElementId );
+
+ virtual void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ TopoDS_Shape GetShape();
+ const SMESHDS_Mesh* GetMeshDS() const;
+
+ virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
+ const TopoDS_Shape& theShape,
+ const SMDS_MeshElement* theElem,
+ TopAbs_ShapeEnum theFindShapeEnum,
+ TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
+ private:
+ TopoDS_Shape myShape;
+ const SMESHDS_Mesh* myMeshDS;
+ SMDSAbs_ElementType myType;
+ };
+ typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
+ }
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual void SetGeom( const TopoDS_Shape& theShape );
-
- virtual bool IsSatisfy( long theElementId );
-
- virtual void SetType( SMDSAbs_ElementType theType );
- virtual SMDSAbs_ElementType GetType() const;
-
- TopoDS_Shape GetShape();
- SMESHDS_Mesh* GetMeshDS();
-
- virtual bool Contains( SMESHDS_Mesh* theMeshDS,
- const TopoDS_Shape& theShape,
- const SMDS_MeshElement* theElem,
- TopAbs_ShapeEnum theFindShapeEnum,
- TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
-private:
- TopoDS_Shape myShape;
- SMESHDS_Mesh* myMeshDS;
- SMDSAbs_ElementType myType;
-};
-typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
-}
-
-/*
- FUNCTORS
-*/
-
-/*
- Class : Functor_i
- Description : An abstact class for all functors
-*/
-class Functor_i: public virtual POA_SMESH::Functor,
- public virtual SALOME::GenericObj_i
-{
-public:
- void SetMesh( SMESH_Mesh_ptr theMesh );
- Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;}
- ElementType GetElementType();
-
-protected:
- Functor_i();
-protected:
- Controls::FunctorPtr myFunctorPtr;
-};
-
-
-/*
- Class : NumericalFunctor_i
- Description : Base class for numerical functors
-*/
-class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
- public virtual Functor_i
-{
-public:
- CORBA::Double GetValue( CORBA::Long theElementId );
- void SetPrecision( CORBA::Long thePrecision );
- CORBA::Long GetPrecision();
- Controls::NumericalFunctorPtr GetNumericalFunctor();
-
-protected:
- Controls::NumericalFunctorPtr myNumericalFunctorPtr;
-};
-
-
-/*
- Class : SMESH_MinimumAngleFunct
- Description : Functor for calculation of minimum angle
-*/
-class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
- public virtual NumericalFunctor_i
-{
-public:
- MinimumAngle_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : AspectRatio_i
- Description : Functor for calculating aspect ratio
-*/
-class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
- public virtual NumericalFunctor_i
-{
-public:
- AspectRatio_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : AspectRatio3D_i
- Description : Functor for calculating aspect ratio for 3D
-*/
-class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
+ /*
+ FUNCTORS
+ */
+
+ /*
+ Class : Functor_i
+ Description : An abstact class for all functors
+ */
+ class Functor_i: public virtual POA_SMESH::Functor,
+ public virtual SALOME::GenericObj_i
+ {
+ public:
+ void SetMesh( SMESH_Mesh_ptr theMesh );
+ Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;}
+ ElementType GetElementType();
+
+ protected:
+ Functor_i();
+ protected:
+ Controls::FunctorPtr myFunctorPtr;
+ };
+
+ /*
+ Class : NumericalFunctor_i
+ Description : Base class for numerical functors
+ */
+ class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
+ public virtual Functor_i
+ {
+ public:
+ CORBA::Double GetValue( CORBA::Long theElementId );
+ void SetPrecision( CORBA::Long thePrecision );
+ CORBA::Long GetPrecision();
+ Controls::NumericalFunctorPtr GetNumericalFunctor();
+
+ protected:
+ Controls::NumericalFunctorPtr myNumericalFunctorPtr;
+ };
+
+
+ /*
+ Class : SMESH_MinimumAngleFunct
+ Description : Functor for calculation of minimum angle
+ */
+ class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ MinimumAngle_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : AspectRatio_i
+ Description : Functor for calculating aspect ratio
+ */
+ class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
public virtual NumericalFunctor_i
-{
-public:
- AspectRatio3D_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : Warping_i
- Description : Functor for calculating warping
-*/
-class Warping_i: public virtual POA_SMESH::Warping,
- public virtual NumericalFunctor_i
-{
-public:
- Warping_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : Taper_i
- Description : Functor for calculating taper
-*/
-class Taper_i: public virtual POA_SMESH::Taper,
- public virtual NumericalFunctor_i
-{
-public:
- Taper_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : Skew_i
- Description : Functor for calculating skew in degrees
-*/
-class Skew_i: public virtual POA_SMESH::Skew,
- public virtual NumericalFunctor_i
-{
-public:
- Skew_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : Area_i
- Description : Functor for calculating area
-*/
-class Area_i: public virtual POA_SMESH::Area,
- public virtual NumericalFunctor_i
-{
-public:
- Area_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : Length_i
- Description : Functor for calculating length of edge
-*/
-class Length_i: public virtual POA_SMESH::Length,
- public virtual NumericalFunctor_i
-{
-public:
- Length_i();
- FunctorType GetFunctorType();
-};
+ {
+ public:
+ AspectRatio_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : AspectRatio3D_i
+ Description : Functor for calculating aspect ratio for 3D
+ */
+ class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ AspectRatio3D_i();
+ FunctorType GetFunctorType();
+ };
+
-/*
- Class : Length2D_i
- Description : Functor for calculating length of edge
-*/
-class Length2D_i: public virtual POA_SMESH::Length2D,
+ /*
+ Class : Warping_i
+ Description : Functor for calculating warping
+ */
+ class Warping_i: public virtual POA_SMESH::Warping,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ Warping_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : Taper_i
+ Description : Functor for calculating taper
+ */
+ class Taper_i: public virtual POA_SMESH::Taper,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ Taper_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : Skew_i
+ Description : Functor for calculating skew in degrees
+ */
+ class Skew_i: public virtual POA_SMESH::Skew,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ Skew_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : Area_i
+ Description : Functor for calculating area
+ */
+ class Area_i: public virtual POA_SMESH::Area,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ Area_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : Length_i
+ Description : Functor for calculating length of edge
+ */
+ class Length_i: public virtual POA_SMESH::Length,
public virtual NumericalFunctor_i
-{
-public:
- Length2D_i();
- SMESH::Length2D::Values* GetValues();
- FunctorType GetFunctorType();
-
-protected:
- Controls::Length2DPtr myLength2DPtr;
-};
-
-
-/*
- Class : MultiConnection_i
- Description : Functor for calculating number of faces conneted to the edge
-*/
-class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
- public virtual NumericalFunctor_i
-{
-public:
- MultiConnection_i();
- FunctorType GetFunctorType();
-};
-
-/*
- Class : MultiConnection2D_i
- Description : Functor for calculating number of faces conneted to the edge
-*/
-class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
+ {
+ public:
+ Length_i();
+ FunctorType GetFunctorType();
+ };
+
+ /*
+ Class : Length2D_i
+ Description : Functor for calculating length of edge
+ */
+ class Length2D_i: public virtual POA_SMESH::Length2D,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ Length2D_i();
+ SMESH::Length2D::Values* GetValues();
+ FunctorType GetFunctorType();
+
+ protected:
+ Controls::Length2DPtr myLength2DPtr;
+ };
+
+
+ /*
+ Class : MultiConnection_i
+ Description : Functor for calculating number of faces conneted to the edge
+ */
+ class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
public virtual NumericalFunctor_i
-{
-public:
- MultiConnection2D_i();
- SMESH::MultiConnection2D::Values* GetValues();
- FunctorType GetFunctorType();
-
-protected:
- Controls::MultiConnection2DPtr myMulticonnection2DPtr;
-};
-
-
-/*
- PREDICATES
-*/
-/*
- Class : Predicate_i
- Description : Base class for all predicates
-*/
-class Predicate_i: public virtual POA_SMESH::Predicate,
- public virtual Functor_i
-{
-public:
- CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
- Controls::PredicatePtr GetPredicate();
+ {
+ public:
+ MultiConnection_i();
+ FunctorType GetFunctorType();
+ };
-protected:
- Controls::PredicatePtr myPredicatePtr;
-};
-
-
-/*
- Class : BadOrientedVolume_i
- Description : Verify whether a mesh volume is incorrectly oriented from
- the point of view of MED convention
-*/
-class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
- public virtual Predicate_i
-{
- public:
- BadOrientedVolume_i();
- FunctorType GetFunctorType();
-};
-
-/*
- Class : BelongToGeom_i
- Description : Predicate for selection on geometrical support
-*/
-class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
- public virtual Predicate_i
-{
-public:
- BelongToGeom_i();
- virtual ~BelongToGeom_i();
-
- void SetGeom( GEOM::GEOM_Object_ptr theGeom );
- void SetElementType( ElementType theType );
- FunctorType GetFunctorType();
-
- void SetGeom( const TopoDS_Shape& theShape );
-
- void SetShapeName( const char* theName );
- char* GetShapeName();
-
-protected:
- Controls::BelongToGeomPtr myBelongToGeomPtr;
- char* myShapeName;
-};
-
-/*
- Class : BelongToSurface_i
- Description : Verify whether mesh element lie in pointed Geom planar object
-*/
-class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
- public virtual Predicate_i
-{
-public:
- BelongToSurface_i( const Handle(Standard_Type)& );
- virtual ~BelongToSurface_i();
-
- void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
-
- void SetShapeName( const char* theName, ElementType theType );
- char* GetShapeName();
-
- void SetTolerance( CORBA::Double );
- CORBA::Double GetTolerance();
-
-protected:
- Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr;
- char* myShapeName;
- Handle(Standard_Type) mySurfaceType;
-};
-
-/*
- Class : BelongToPlane_i
- Description : Verify whether mesh element lie in pointed Geom planar object
-*/
-class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
- public virtual BelongToSurface_i
-{
-public:
- BelongToPlane_i();
- void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
- FunctorType GetFunctorType();
-};
-
-/*
- Class : BelongToCylinder_i
- Description : Verify whether mesh element lie in pointed Geom cylindrical object
-*/
-class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
- public virtual BelongToSurface_i
-{
-public:
- BelongToCylinder_i();
- void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
- FunctorType GetFunctorType();
-};
-
-/*
- Class : LyingOnGeom_i
- Description : Predicate for selection on geometrical support(lying or partially lying)
-*/
-class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
+ /*
+ Class : MultiConnection2D_i
+ Description : Functor for calculating number of faces conneted to the edge
+ */
+ class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
+ public virtual NumericalFunctor_i
+ {
+ public:
+ MultiConnection2D_i();
+ SMESH::MultiConnection2D::Values* GetValues();
+ FunctorType GetFunctorType();
+
+ protected:
+ Controls::MultiConnection2DPtr myMulticonnection2DPtr;
+ };
+
+
+ /*
+ PREDICATES
+ */
+ /*
+ Class : Predicate_i
+ Description : Base class for all predicates
+ */
+ class Predicate_i: public virtual POA_SMESH::Predicate,
+ public virtual Functor_i
+ {
+ public:
+ CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
+ Controls::PredicatePtr GetPredicate();
+
+ protected:
+ Controls::PredicatePtr myPredicatePtr;
+ };
+
+
+ /*
+ Class : BadOrientedVolume_i
+ Description : Verify whether a mesh volume is incorrectly oriented from
+ the point of view of MED convention
+ */
+ class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
+ public virtual Predicate_i
+ {
+ public:
+ BadOrientedVolume_i();
+ FunctorType GetFunctorType();
+ };
+
+ /*
+ Class : BelongToGeom_i
+ Description : Predicate for selection on geometrical support
+ */
+ class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
+ public virtual Predicate_i
+ {
+ public:
+ BelongToGeom_i();
+ virtual ~BelongToGeom_i();
+
+ void SetGeom( GEOM::GEOM_Object_ptr theGeom );
+ void SetElementType( ElementType theType );
+ FunctorType GetFunctorType();
+
+ void SetGeom( const TopoDS_Shape& theShape );
+
+ void SetShapeName( const char* theName );
+ char* GetShapeName();
+
+ protected:
+ Controls::BelongToGeomPtr myBelongToGeomPtr;
+ char* myShapeName;
+ };
+
+ /*
+ Class : BelongToSurface_i
+ Description : Verify whether mesh element lie in pointed Geom planar object
+ */
+ class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
+ public virtual Predicate_i
+ {
+ public:
+ BelongToSurface_i( const Handle(Standard_Type)& );
+ virtual ~BelongToSurface_i();
+
+ void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+
+ void SetShapeName( const char* theName, ElementType theType );
+ char* GetShapeName();
+
+ void SetTolerance( CORBA::Double );
+ CORBA::Double GetTolerance();
+
+ protected:
+ Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr;
+ char* myShapeName;
+ Handle(Standard_Type) mySurfaceType;
+ };
+
+ /*
+ Class : BelongToPlane_i
+ Description : Verify whether mesh element lie in pointed Geom planar object
+ */
+ class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
+ public virtual BelongToSurface_i
+ {
+ public:
+ BelongToPlane_i();
+ void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+ FunctorType GetFunctorType();
+ };
+
+ /*
+ Class : BelongToCylinder_i
+ Description : Verify whether mesh element lie in pointed Geom cylindrical object
+ */
+ class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
+ public virtual BelongToSurface_i
+ {
+ public:
+ BelongToCylinder_i();
+ void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+ FunctorType GetFunctorType();
+ };
+
+ /*
+ Class : LyingOnGeom_i
+ Description : Predicate for selection on geometrical support(lying or partially lying)
+ */
+ class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
+ public virtual Predicate_i
+ {
+ public:
+ LyingOnGeom_i();
+ virtual ~LyingOnGeom_i();
+
+ void SetGeom( GEOM::GEOM_Object_ptr theGeom );
+ void SetElementType( ElementType theType );
+ FunctorType GetFunctorType();
+
+ void SetGeom( const TopoDS_Shape& theShape );
+
+ void SetShapeName( const char* theName );
+ char* GetShapeName();
+
+ protected:
+ Controls::LyingOnGeomPtr myLyingOnGeomPtr;
+ char* myShapeName;
+ };
+
+ /*
+ Class : FreeBorders_i
+ Description : Predicate for free borders
+ */
+ class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
+ public virtual Predicate_i
+ {
+ public:
+ FreeBorders_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : FreeEdges_i
+ Description : Predicate for free edges
+ */
+ class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
public virtual Predicate_i
-{
-public:
- LyingOnGeom_i();
- virtual ~LyingOnGeom_i();
+ {
+ public:
+ FreeEdges_i();
+ SMESH::FreeEdges::Borders* GetBorders();
+ FunctorType GetFunctorType();
- void SetGeom( GEOM::GEOM_Object_ptr theGeom );
- void SetElementType( ElementType theType );
- FunctorType GetFunctorType();
+ protected:
+ Controls::FreeEdgesPtr myFreeEdgesPtr;
+ };
- void SetGeom( const TopoDS_Shape& theShape );
- void SetShapeName( const char* theName );
- char* GetShapeName();
+ /*
+ Class : RangeOfIds_i
+ Description : Predicate for Range of Ids
+ */
+ class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
+ public virtual Predicate_i
+ {
+ public:
+ RangeOfIds_i();
+ void SetRange( const SMESH::long_array& theIds );
+ CORBA::Boolean SetRangeStr( const char* theRange );
+ char* GetRangeStr();
+
+ void SetElementType( ElementType theType );
+ FunctorType GetFunctorType();
+
+ protected:
+ Controls::RangeOfIdsPtr myRangeOfIdsPtr;
+ };
-protected:
- Controls::LyingOnGeomPtr myLyingOnGeomPtr;
- char* myShapeName;
-};
-
-/*
- Class : FreeBorders_i
- Description : Predicate for free borders
-*/
-class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
- public virtual Predicate_i
-{
-public:
- FreeBorders_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : FreeEdges_i
- Description : Predicate for free edges
-*/
-class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
- public virtual Predicate_i
-{
-public:
- FreeEdges_i();
- SMESH::FreeEdges::Borders* GetBorders();
- FunctorType GetFunctorType();
-
-protected:
- Controls::FreeEdgesPtr myFreeEdgesPtr;
-};
-
-
-/*
- Class : RangeOfIds_i
- Description : Predicate for Range of Ids
-*/
-class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
- public virtual Predicate_i
-{
-public:
- RangeOfIds_i();
- void SetRange( const SMESH::long_array& theIds );
- CORBA::Boolean SetRangeStr( const char* theRange );
- char* GetRangeStr();
-
- void SetElementType( ElementType theType );
- FunctorType GetFunctorType();
-
-protected:
- Controls::RangeOfIdsPtr myRangeOfIdsPtr;
-};
-
-/*
- Class : Comparator_i
- Description : Base class for comparators
-*/
-class Comparator_i: public virtual POA_SMESH::Comparator,
- public virtual Predicate_i
-{
-public:
- virtual ~Comparator_i();
-
- virtual void SetMargin( CORBA::Double );
- virtual void SetNumFunctor( NumericalFunctor_ptr );
-
- Controls::ComparatorPtr GetComparator();
- NumericalFunctor_i* GetNumFunctor_i();
- CORBA::Double GetMargin();
-
-protected:
- Comparator_i();
-protected:
- Controls::ComparatorPtr myComparatorPtr;
- NumericalFunctor_i* myNumericalFunctor;
-};
-
-
-/*
- Class : LessThan_i
- Description : Comparator "<"
-*/
-class LessThan_i: public virtual POA_SMESH::LessThan,
- public virtual Comparator_i
-{
-public:
- LessThan_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : MoreThan_i
- Description : Comparator ">"
-*/
-class MoreThan_i: public virtual POA_SMESH::MoreThan,
- public virtual Comparator_i
-{
-public:
- MoreThan_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : EqualTo_i
- Description : Comparator "="
-*/
-class EqualTo_i: public virtual POA_SMESH::EqualTo,
- public virtual Comparator_i
-{
-public:
- EqualTo_i();
- virtual void SetTolerance( CORBA::Double );
- CORBA::Double GetTolerance();
- FunctorType GetFunctorType();
-
-protected:
- Controls::EqualToPtr myEqualToPtr;
-};
-
-
-/*
- Class : LogicalNOT_i
- Description : Logical NOT predicate
-*/
-class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
- public virtual Predicate_i
-{
-public:
- LogicalNOT_i();
+ /*
+ Class : Comparator_i
+ Description : Base class for comparators
+ */
+ class Comparator_i: public virtual POA_SMESH::Comparator,
+ public virtual Predicate_i
+ {
+ public:
+ virtual ~Comparator_i();
+
+ virtual void SetMargin( CORBA::Double );
+ virtual void SetNumFunctor( NumericalFunctor_ptr );
+
+ Controls::ComparatorPtr GetComparator();
+ NumericalFunctor_i* GetNumFunctor_i();
+ CORBA::Double GetMargin();
+
+ protected:
+ Comparator_i();
+ protected:
+ Controls::ComparatorPtr myComparatorPtr;
+ NumericalFunctor_i* myNumericalFunctor;
+ };
+
+
+ /*
+ Class : LessThan_i
+ Description : Comparator "<"
+ */
+ class LessThan_i: public virtual POA_SMESH::LessThan,
+ public virtual Comparator_i
+ {
+ public:
+ LessThan_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : MoreThan_i
+ Description : Comparator ">"
+ */
+ class MoreThan_i: public virtual POA_SMESH::MoreThan,
+ public virtual Comparator_i
+ {
+ public:
+ MoreThan_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : EqualTo_i
+ Description : Comparator "="
+ */
+ class EqualTo_i: public virtual POA_SMESH::EqualTo,
+ public virtual Comparator_i
+ {
+ public:
+ EqualTo_i();
+ virtual void SetTolerance( CORBA::Double );
+ CORBA::Double GetTolerance();
+ FunctorType GetFunctorType();
+
+ protected:
+ Controls::EqualToPtr myEqualToPtr;
+ };
+
+
+ /*
+ Class : LogicalNOT_i
+ Description : Logical NOT predicate
+ */
+ class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
+ public virtual Predicate_i
+ {
+ public:
+ LogicalNOT_i();
virtual ~LogicalNOT_i();
+
+ virtual void SetPredicate( Predicate_ptr );
+ Predicate_i* GetPredicate_i();
+ FunctorType GetFunctorType();
+
+ protected:
+ Controls::LogicalNOTPtr myLogicalNOTPtr;
+ Predicate_i* myPredicate;
+ };
- virtual void SetPredicate( Predicate_ptr );
- Predicate_i* GetPredicate_i();
- FunctorType GetFunctorType();
-protected:
- Controls::LogicalNOTPtr myLogicalNOTPtr;
- Predicate_i* myPredicate;
-};
-
-
-/*
- Class : LogicalBinary_i
- Description : Base class for binary logical predicate
-*/
-class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
- public virtual Predicate_i
-{
-public:
- virtual ~LogicalBinary_i();
- virtual void SetMesh( SMESH_Mesh_ptr theMesh );
- virtual void SetPredicate1( Predicate_ptr );
- virtual void SetPredicate2( Predicate_ptr );
-
- Controls::LogicalBinaryPtr GetLogicalBinary();
- Predicate_i* GetPredicate1_i();
- Predicate_i* GetPredicate2_i();
-
-protected:
- LogicalBinary_i();
-protected:
- Controls::LogicalBinaryPtr myLogicalBinaryPtr;
- Predicate_i* myPredicate1;
- Predicate_i* myPredicate2;
-};
-
-
-/*
- Class : LogicalAND_i
- Description : Logical AND
-*/
-class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
- public virtual LogicalBinary_i
-{
-public:
- LogicalAND_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- Class : LogicalOR_i
- Description : Logical OR
-*/
-class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
- public virtual LogicalBinary_i
-{
-public:
- LogicalOR_i();
- FunctorType GetFunctorType();
-};
-
-
-/*
- FILTER
-*/
-class Filter_i: public virtual POA_SMESH::Filter,
- public virtual SALOME::GenericObj_i
-{
-public:
- Filter_i();
- virtual ~Filter_i();
+ /*
+ Class : LogicalBinary_i
+ Description : Base class for binary logical predicate
+ */
+ class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
+ public virtual Predicate_i
+ {
+ public:
+ virtual ~LogicalBinary_i();
+ virtual void SetMesh( SMESH_Mesh_ptr theMesh );
+ virtual void SetPredicate1( Predicate_ptr );
+ virtual void SetPredicate2( Predicate_ptr );
+
+ Controls::LogicalBinaryPtr GetLogicalBinary();
+ Predicate_i* GetPredicate1_i();
+ Predicate_i* GetPredicate2_i();
+
+ protected:
+ LogicalBinary_i();
+ protected:
+ Controls::LogicalBinaryPtr myLogicalBinaryPtr;
+ Predicate_i* myPredicate1;
+ Predicate_i* myPredicate2;
+ };
- void SetPredicate( Predicate_ptr );
- void SetMesh( SMESH_Mesh_ptr );
-
- long_array* GetElementsId( SMESH_Mesh_ptr );
- ElementType GetElementType();
-
- CORBA::Boolean GetCriteria( SMESH::Filter::Criteria_out theCriteria );
- CORBA::Boolean SetCriteria( const SMESH::Filter::Criteria& theCriteria );
- Predicate_ptr GetPredicate();
- Predicate_i* GetPredicate_i();
-
-private:
- Controls::Filter myFilter;
- Predicate_i* myPredicate;
-};
-
-
-/*
- FILTER LIBRARY
-*/
-class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
- public virtual SALOME::GenericObj_i
-{
-public:
- FilterLibrary_i( const char* theFileName );
- FilterLibrary_i();
- ~FilterLibrary_i();
-
- Filter_ptr Copy( const char* theFilterName );
-
- CORBA::Boolean Add ( const char* theFilterName, Filter_ptr theFilter );
- CORBA::Boolean AddEmpty( const char* theFilterName, ElementType theType );
- CORBA::Boolean Delete ( const char* theFilterName );
- CORBA::Boolean Replace ( const char* theFilterName,
- const char* theNewName,
- Filter_ptr theFilter );
-
- CORBA::Boolean Save();
- CORBA::Boolean SaveAs( const char* aFileName );
-
- CORBA::Boolean IsPresent( const char* aFilterName );
- CORBA::Long NbFilters( ElementType );
- string_array* GetNames( ElementType );
- string_array* GetAllNames();
- void SetFileName( const char* theFileName );
- char* GetFileName();
-
-private:
- char* myFileName;
- LDOM_Document myDoc;
- FilterManager_var myFilterMgr;
-};
-
-
-/*
- FILTER MANAGER
-*/
-
-class FilterManager_i: public virtual POA_SMESH::FilterManager,
- public virtual SALOME::GenericObj_i
-{
-public:
- FilterManager_i();
- MinimumAngle_ptr CreateMinimumAngle();
- AspectRatio_ptr CreateAspectRatio();
- AspectRatio3D_ptr CreateAspectRatio3D();
- Warping_ptr CreateWarping();
- Taper_ptr CreateTaper();
- Skew_ptr CreateSkew();
- Area_ptr CreateArea();
- Length_ptr CreateLength();
- Length2D_ptr CreateLength2D();
- MultiConnection_ptr CreateMultiConnection();
- MultiConnection2D_ptr CreateMultiConnection2D();
-
- BelongToGeom_ptr CreateBelongToGeom();
- BelongToPlane_ptr CreateBelongToPlane();
- BelongToCylinder_ptr CreateBelongToCylinder();
-
- LyingOnGeom_ptr CreateLyingOnGeom();
-
- FreeBorders_ptr CreateFreeBorders();
- FreeEdges_ptr CreateFreeEdges();
-
- RangeOfIds_ptr CreateRangeOfIds();
-
- BadOrientedVolume_ptr CreateBadOrientedVolume();
-
- LessThan_ptr CreateLessThan();
- MoreThan_ptr CreateMoreThan();
- EqualTo_ptr CreateEqualTo();
+ /*
+ Class : LogicalAND_i
+ Description : Logical AND
+ */
+ class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
+ public virtual LogicalBinary_i
+ {
+ public:
+ LogicalAND_i();
+ FunctorType GetFunctorType();
+ };
- LogicalNOT_ptr CreateLogicalNOT();
- LogicalAND_ptr CreateLogicalAND();
- LogicalOR_ptr CreateLogicalOR();
-
- Filter_ptr CreateFilter();
-
- FilterLibrary_ptr LoadLibrary( const char* aFileName );
- FilterLibrary_ptr CreateLibrary();
- CORBA::Boolean DeleteLibrary( const char* aFileName );
-};
-
-
+
+ /*
+ Class : LogicalOR_i
+ Description : Logical OR
+ */
+ class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
+ public virtual LogicalBinary_i
+ {
+ public:
+ LogicalOR_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ FILTER
+ */
+ class Filter_i: public virtual POA_SMESH::Filter,
+ public virtual SALOME::GenericObj_i
+ {
+ public:
+ Filter_i();
+ virtual ~Filter_i();
+
+ void SetPredicate( Predicate_ptr );
+ void SetMesh( SMESH_Mesh_ptr );
+
+ static
+ void GetElementsId( Predicate_i*,
+ const SMDS_Mesh*,
+ Controls::Filter::TIdSequence& );
+ static
+ void GetElementsId( Predicate_i*,
+ SMESH_Mesh_ptr,
+ Controls::Filter::TIdSequence& );
+
+ long_array* GetElementsId( SMESH_Mesh_ptr );
+ ElementType GetElementType();
+
+ CORBA::Boolean GetCriteria( SMESH::Filter::Criteria_out theCriteria );
+ CORBA::Boolean SetCriteria( const SMESH::Filter::Criteria& theCriteria );
+
+ Predicate_ptr GetPredicate();
+ Predicate_i* GetPredicate_i();
-};
+ private:
+ Controls::Filter myFilter;
+ Predicate_i* myPredicate;
+ };
+
+
+ /*
+ FILTER LIBRARY
+ */
+ class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
+ public virtual SALOME::GenericObj_i
+ {
+ public:
+ FilterLibrary_i( const char* theFileName );
+ FilterLibrary_i();
+ ~FilterLibrary_i();
+
+ Filter_ptr Copy( const char* theFilterName );
+
+ CORBA::Boolean Add ( const char* theFilterName, Filter_ptr theFilter );
+ CORBA::Boolean AddEmpty( const char* theFilterName, ElementType theType );
+ CORBA::Boolean Delete ( const char* theFilterName );
+ CORBA::Boolean Replace ( const char* theFilterName,
+ const char* theNewName,
+ Filter_ptr theFilter );
+
+ CORBA::Boolean Save();
+ CORBA::Boolean SaveAs( const char* aFileName );
+
+ CORBA::Boolean IsPresent( const char* aFilterName );
+ CORBA::Long NbFilters( ElementType );
+ string_array* GetNames( ElementType );
+ string_array* GetAllNames();
+ void SetFileName( const char* theFileName );
+ char* GetFileName();
+
+ private:
+ char* myFileName;
+ LDOM_Document myDoc;
+ FilterManager_var myFilterMgr;
+ };
+
+
+ /*
+ FILTER MANAGER
+ */
+
+ class FilterManager_i: public virtual POA_SMESH::FilterManager,
+ public virtual SALOME::GenericObj_i
+ {
+ public:
+ FilterManager_i();
+ MinimumAngle_ptr CreateMinimumAngle();
+ AspectRatio_ptr CreateAspectRatio();
+ AspectRatio3D_ptr CreateAspectRatio3D();
+ Warping_ptr CreateWarping();
+ Taper_ptr CreateTaper();
+ Skew_ptr CreateSkew();
+ Area_ptr CreateArea();
+ Length_ptr CreateLength();
+ Length2D_ptr CreateLength2D();
+ MultiConnection_ptr CreateMultiConnection();
+ MultiConnection2D_ptr CreateMultiConnection2D();
+
+ BelongToGeom_ptr CreateBelongToGeom();
+ BelongToPlane_ptr CreateBelongToPlane();
+ BelongToCylinder_ptr CreateBelongToCylinder();
+
+ LyingOnGeom_ptr CreateLyingOnGeom();
+
+ FreeBorders_ptr CreateFreeBorders();
+ FreeEdges_ptr CreateFreeEdges();
+
+ RangeOfIds_ptr CreateRangeOfIds();
+
+ BadOrientedVolume_ptr CreateBadOrientedVolume();
+
+ LessThan_ptr CreateLessThan();
+ MoreThan_ptr CreateMoreThan();
+ EqualTo_ptr CreateEqualTo();
+
+ LogicalNOT_ptr CreateLogicalNOT();
+ LogicalAND_ptr CreateLogicalAND();
+ LogicalOR_ptr CreateLogicalOR();
+
+ Filter_ptr CreateFilter();
+
+ FilterLibrary_ptr LoadLibrary( const char* aFileName );
+ FilterLibrary_ptr CreateLibrary();
+ CORBA::Boolean DeleteLibrary( const char* aFileName );
+ };
+
+
+ Predicate_i*
+ GetPredicate( SMESH::Predicate_ptr thePredicate );
+}
#endif
+++ /dev/null
-// File : SMESH_Gen_i_DumpPython.cxx
-// Created : Thu Mar 24 17:17:59 2005
-// Author : Julia DOROVSKIKH
-// Module : SMESH
-// $Header : $
-
-#include "SMESH_Gen_i.hxx"
-
-#include <TColStd_HSequenceOfInteger.hxx>
-
-//=======================================================================
-//function : DumpPython
-//purpose :
-//=======================================================================
-Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean& isValidScript)
-{
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
- if (CORBA::is_nil(aStudy))
- return new Engines::TMPFile(0);
-
- SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
- if (CORBA::is_nil(aSO))
- return new Engines::TMPFile(0);
-
- // Map study entries to object names
- Resource_DataMapOfAsciiStringAsciiString aMap;
- TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
-
- SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
- for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
- SALOMEDS::SObject_var aValue = Itr->Value();
-
- TCollection_AsciiString aName (aValue->GetName());
- if (aName.Length() > 0) {
- int p, p2 = 1, e = aName.Length();
- while ((p = aName.FirstLocationNotInSet(s, p2, e))) {
- aName.SetValue(p, '_');
- p2 = p;
- }
- aMap.Bind(TCollection_AsciiString(aValue->GetID()), aName);
- }
- }
-
- // Get trace of restored study
- //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr =
- aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
- char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
- TCollection_AsciiString aSavedTrace (oldValue);
-
- // Add trace of API methods calls and replace study entries by names
- bool aValidScript;
- //TCollection_AsciiString aScript = myGen.DumpPython
- TCollection_AsciiString aScript = DumpPython_impl
- (aStudy->StudyId(), aMap, isPublished, aValidScript, aSavedTrace);
-
- int aLen = aScript.Length();
- unsigned char* aBuffer = new unsigned char[aLen+1];
- strcpy((char*)aBuffer, aScript.ToCString());
-
- CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
- Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
- isValidScript = aValidScript;
-
- return aStreamFile._retn();
-}
-
-//=============================================================================
-/*!
- * AddToPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
-{
- if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
- myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
- }
- myPythonScripts[theStudyID]->Append(theString);
-}
-
-//=============================================================================
-/*!
- * RemoveLastFromPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
-{
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- int aLen = myPythonScripts[theStudyID]->Length();
- myPythonScripts[theStudyID]->Remove(aLen);
- }
-}
-
-//=======================================================================
-//function : AddToCurrentPyScript
-//purpose :
-//=======================================================================
-
-void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString)
-{
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
- if (aStudy->_is_nil()) return;
- aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString);
-}
-
-
-//=======================================================================
-//function : AddObject
-//purpose : add object to script string
-//=======================================================================
-
-TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
- CORBA::Object_ptr theObject)
-{
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_var aSO =
- aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
- if ( !aSO->_is_nil() )
- theStr += aSO->GetID();
- else if ( !CORBA::is_nil( theObject ) )
- theStr += GetORB()->object_to_string( theObject );
- else
- theStr += "None";
-
- return theStr;
-}
-
-//=======================================================================
-//function : SavePython
-//purpose :
-//=======================================================================
-void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
-{
- // Dump trace of API methods calls
- TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
-
- // Check contents of PythonObject attribute
- SALOMEDS::SObject_var aSO = theStudy->FindComponent(ComponentDataType());
- //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
- SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr =
- aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
- char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
- TCollection_AsciiString oldScript (oldValue);
-
- if (oldScript.Length() > 0) {
- oldScript += "\n";
- oldScript += aScript;
- } else {
- oldScript = aScript;
- }
-
- // Store in PythonObject attribute
- SALOMEDS::AttributePythonObject::_narrow(anAttr)->SetObject(oldScript.ToCString(), 1);
-
- // Clean trace of API methods calls
- CleanPythonTrace(theStudy->StudyId());
-}
-
-
-// impl
-
-
-//=============================================================================
-/*!
- * FindEntries: Returns a sequence of start/end positions of entries in the string
- */
-//=============================================================================
-Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
-{
- Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
- Standard_Integer aLen = theString.Length();
- Standard_Boolean isFound = Standard_False;
-
- char* arr = theString.ToCString();
- Standard_Integer i = 0, j;
-
- while(i < aLen) {
- int c = (int)arr[i];
- j = i+1;
- if(c >= 48 && c <= 57) { //Is digit?
-
- isFound = Standard_False;
- while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
- c = (int)arr[j++];
- if(c == 58) isFound = Standard_True;
- }
-
- if (isFound) {
- int prev = (i < 1) ? 0 : (int)arr[i - 1];
- // last char should be a diggit,
- // previous char should not be '"'.
- if (arr[j-2] != 58 && prev != 34) {
- aSeq->Append(i+1); // +1 because AsciiString starts from 1
- aSeq->Append(j-1);
- }
- }
- }
-
- i = j;
- }
-
- return aSeq;
-}
-
-//=============================================================================
-/*!
- * DumpPython
- */
-//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
- (int theStudyID,
- Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
- bool isPublished,
- bool& aValidScript,
- const TCollection_AsciiString& theSavedTrace)
-{
- TCollection_AsciiString aScript;
- aScript += "import salome\n";
- aScript += "import geompy\n\n";
- aScript += "import SMESH\n";
- aScript += "import StdMeshers\n\n";
- aScript += "#import GEOM module\n";
- aScript += "import string\n";
- aScript += "import os\n";
- aScript += "import sys\n";
- aScript += "sys.path.append( os.path.dirname(__file__) )\n";
- aScript += "exec(\"from \"+string.replace(__name__,\"SMESH\",\"GEOM\")+\" import *\")\n\n";
-
- aScript += "def RebuildData(theStudy):";
- aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")";
- if ( isPublished )
- aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
- else
- aScript += "\n\tsmesh.SetCurrentStudy(None)";
-
- Standard_Integer posToInertGlobalVars = aScript.Length();
- TCollection_AsciiString globalVars;
-
- // Dump trace of restored study
- if (theSavedTrace.Length() > 0) {
- aScript += "\n";
- aScript += theSavedTrace;
- }
-
- // Dump trace of API methods calls
- TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID);
- if (aNewLines.Length() > 0) {
- aScript += "\n";
- aScript += aNewLines;
- }
-
- // Find entries to be replaced by names
- Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
- Standard_Integer aLen = aSeq->Length();
-
- if (aLen == 0)
- return aScript;
-
- // Replace entries by the names
- GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
- TColStd_SequenceOfAsciiString seqRemoved;
- Resource_DataMapOfAsciiStringAsciiString mapRemoved;
- Resource_DataMapOfAsciiStringAsciiString aNames;
- Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
- TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
-
- for (Standard_Integer i = 1; i <= aLen; i += 2) {
- anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
- anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
- if (theObjectNames.IsBound(anEntry)) {
- aName = theObjectNames.Find(anEntry);
- if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
- // diff objects have same name - make a new name
- TCollection_AsciiString aName2;
- Standard_Integer i = 0;
- do {
- aName2 = aName + "_" + ++i;
- } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
- aName = aName2;
- theObjectNames(anEntry) = aName;
- }
- } else {
- // is a GEOM object?
- aName = geom->GetDumpName( anEntry.ToCString() );
- if ( aName.IsEmpty() ) {
- // ? Removed Object ?
- do {
- aName = aBaseName + TCollection_AsciiString(++objectCounter);
- } while (theObjectNames.IsBound(aName));
- seqRemoved.Append(aName);
- mapRemoved.Bind(anEntry, "1");
- }
- theObjectNames.Bind(anEntry, aName);
- }
- theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
-
- anUpdatedScript += aName;
- aNames.Bind(aName, "1");
- aStart = aSeq->Value(i + 1) + 1;
- }
-
- // add final part of aScript
- if (aSeq->Value(aLen) < aScriptLength)
- anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
-
- // Remove removed objects
- anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()";
- for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
- anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
- anUpdatedScript += seqRemoved.Value(ir);
- anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)";
- }
- anUpdatedScript += "\n";
-
- // Set object names
- anUpdatedScript += "\n\tisGUIMode = ";
- anUpdatedScript += isPublished;
- anUpdatedScript += "\n\tif isGUIMode:";
- anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
- anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
- anUpdatedScript += "\n";
-
- Resource_DataMapOfAsciiStringAsciiString mapEntries;
- for (Standard_Integer i = 1; i <= aLen; i += 2) {
- anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
- if (theObjectNames.IsBound(anEntry) &&
- !mapEntries.IsBound(anEntry) &&
- !mapRemoved.IsBound(anEntry)) {
- aName = theObjectNames.Find(anEntry);
- mapEntries.Bind(anEntry, aName);
- anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID(";
- anUpdatedScript += aName + "), \"" + aName + "\")";
- }
- }
- anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
-
- anUpdatedScript += "\n\n\tpass\n";
-
- aValidScript = true;
-
- return anUpdatedScript;
-}
-
-//=============================================================================
-/*!
- * GetNewPythonLines
- */
-//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
-{
- TCollection_AsciiString aScript;
-
- // Dump trace of API methods calls
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
- Standard_Integer istr, aLen = aPythonScript->Length();
- for (istr = 1; istr <= aLen; istr++) {
- aScript += "\n\t";
- aScript += aPythonScript->Value(istr);
- }
- aScript += "\n";
- }
-
- return aScript;
-}
-
-//=============================================================================
-/*!
- * CleanPythonTrace
- */
-//=============================================================================
-void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
-{
- TCollection_AsciiString aScript;
-
- // Clean trace of API methods calls
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- myPythonScripts[theStudyID]->Clear();
- }
-}
#include "SMESHDS_Group.hxx"
#include "SMESHDS_GroupOnGeom.hxx"
#include "SMDSAbs_ElementType.hxx"
+
+#include "SMESH_Filter_i.hxx"
+#include "SMESH_PythonDump.hxx"
+
#include "utilities.h"
+using namespace SMESH;
+
//=============================================================================
/*!
*
*/
//=============================================================================
+CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
+{
+ // Update Python script
+ TCollection_AsciiString aStr ("nbDel = ");
+ SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
+ SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
+
+ SMESH_Gen_i::AddToCurrentPyScript(aStr);
+
+ // Remove elements from the group
+ SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
+ if (aGroupDS) {
+ int nbDel = 0;
+ for (int i = 0; i < theIDs.length(); i++) {
+ int anID = (int) theIDs[i];
+ if (aGroupDS->Remove(anID))
+ nbDel++;
+ }
+ return nbDel;
+ }
+ MESSAGE("attempt to remove elements from a vague group");
+ return 0;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int);
+
+CORBA::Long
+ChangeByPredicate( SMESH::Predicate_i* thePredicate,
+ SMESHDS_GroupBase* theGroupBase,
+ TFunChangeGroup theFun)
+{
+ CORBA::Long aNb = 0;
+ if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){
+ SMESH::Controls::Filter::TIdSequence aSequence;
+ const SMDS_Mesh* aMesh = theGroupBase->GetMesh();
+ SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence);
+
+ CORBA::Long i = 0, iEnd = aSequence.size();
+ for(; i < iEnd; i++)
+ if((aGroupDS->*theFun)(aSequence[i]))
+ aNb++;
+ return aNb;
+ }
+ return aNb;
+}
+
+CORBA::Long
+SMESH_Group_i::
+AddByPredicate( SMESH::Predicate_ptr thePredicate )
+{
+ if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
+ TPythonDump()<<_this()<<".AddByPredicate("<<aPredicate<<")";
+ return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Add);
+ }
+ return 0;
+}
+
+CORBA::Long
+SMESH_Group_i::
+RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
+{
+ if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
+ TPythonDump()<<_this()<<".RemoveByPredicate("<<aPredicate<<")";
+ return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Remove);
+ }
+ return 0;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex )
{
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
return aRes._retn();
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
-{
- // Update Python script
- TCollection_AsciiString aStr ("nbDel = ");
- SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
- SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
-
- SMESH_Gen_i::AddToCurrentPyScript(aStr);
-
- // Remove elements from the group
- SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
- if (aGroupDS) {
- int nbDel = 0;
- for (int i = 0; i < theIDs.length(); i++) {
- int anID = (int) theIDs[i];
- if (aGroupDS->Remove(anID))
- nbDel++;
- }
- return nbDel;
- }
- MESSAGE("attempt to remove elements from a vague group");
- return 0;
-}
-
//=============================================================================
/*!
*
void Clear();
CORBA::Long Add( const SMESH::long_array& theIDs );
CORBA::Long Remove( const SMESH::long_array& theIDs );
+
+ CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
+ CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
};
// =========================
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+#ifndef _SMESH_PYTHONDUMP_HXX_
+#define _SMESH_PYTHONDUMP_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include <TCollection_AsciiString.hxx>
+
+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 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;
+ public:
+ virtual ~TPythonDump();
+
+ template<class T>
+ TCollection_AsciiString&
+ operator<<(T theArg){
+ return myString<<theArg;
+ }
+ };
+}
+
+
+#endif