Salome HOME
feb720f5f913d5c8d5d3a633ef4503c74827538d
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File      : SMESH_smesh.hxx
24 // Created   : Fri Nov 18 12:05:18 2005
25 // Author    : Edward AGAPOV (eap)
26 //
27 #ifndef SMESH_smesh_HeaderFile
28 #define SMESH_smesh_HeaderFile
29
30 #include <Standard_DefineHandle.hxx>
31 #include <Standard_Type.hxx>
32 #include <Standard_Transient.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include <TColStd_SequenceOfAsciiString.hxx>
35 #include <TColStd_SequenceOfInteger.hxx>
36
37 #include <list>
38 #include <map>
39 #include <vector>
40 #include <set>
41
42 #include <SALOMEconfig.h>
43 #include CORBA_CLIENT_HEADER(SALOMEDS)
44
45 // ===========================================================================================
46 /*!
47  * This file was created in order to respond to requirement of bug PAL10494:
48  * SMESH python dump uses idl interface.
49  *
50  * The creation reason is that smesh.py commands defining hypotheses encapsulate
51  * several SMESH engine method calls. As well, the dependencies between smesh.py
52  * classes differ from ones between corresponding SMESH IDL interfaces.
53  * 
54  * Everything here is for internal usage by SMESH_2smeshpy::ConvertScript()
55  * declared in SMESH_PythonDump.hxx
56  */
57 // ===========================================================================================
58
59 class Resource_DataMapOfAsciiStringAsciiString;
60
61 // ===========================================================================================
62 // =====================
63 //    INTERNAL STUFF
64 // =====================
65 // ===========================================================================================
66
67 class _pyCommand;
68 class _pyObject;
69 class _pyGen;
70 class _pyMesh;
71 class _pySubMesh;
72 class _pyHypothesis;
73 class _pyAlgorithm;
74 class _pyHypothesisReader;
75
76 DEFINE_STANDARD_HANDLE (_pyCommand         ,Standard_Transient);
77 DEFINE_STANDARD_HANDLE (_pyObject          ,Standard_Transient);
78 DEFINE_STANDARD_HANDLE (_pyHypothesisReader,Standard_Transient);
79 DEFINE_STANDARD_HANDLE (_pyGen             ,_pyObject);
80 DEFINE_STANDARD_HANDLE (_pyMesh            ,_pyObject);
81 DEFINE_STANDARD_HANDLE (_pySubMesh         ,_pyObject);
82 DEFINE_STANDARD_HANDLE (_pyGroup           ,_pySubMesh);
83 DEFINE_STANDARD_HANDLE (_pyMeshEditor      ,_pyObject);
84 DEFINE_STANDARD_HANDLE (_pyHypothesis      ,_pyObject);
85 DEFINE_STANDARD_HANDLE (_pyAlgorithm       ,_pyHypothesis);
86
87 typedef TCollection_AsciiString _pyID;
88 typedef TCollection_AsciiString _AString;
89
90 // ===========================================================
91 /*!
92  * \brief Class operating on a command string looking like
93  *        ResultValue = Object.Method( Arg1, Arg2,...)
94  */
95 // ===========================================================
96
97 class _pyCommand: public Standard_Transient
98 {
99   int                             myOrderNb;            //!< position within the script
100   _AString                        myString;             //!< command text
101   _AString                        myRes, myObj, myMeth; //!< found parts of command
102   TColStd_SequenceOfAsciiString   myArgs;               //!< found arguments
103   TColStd_SequenceOfInteger       myBegPos;             //!< where myRes, myObj, ... begin
104   std::list< Handle(_pyCommand) > myDependentCmds; //!< commands that sould follow me in the script
105
106   enum { UNKNOWN=-1, EMPTY=0, RESULT_IND, OBJECT_IND, METHOD_IND, ARG1_IND };
107   int  GetBegPos( int thePartIndex );
108   void SetBegPos( int thePartIndex, int thePosition );
109   void SetPart( int thePartIndex, const _AString& theNewPart, _AString& theOldPart);
110   void FindAllArgs() { GetArg(1); }
111
112 public:
113   _pyCommand() {};
114   _pyCommand( const _AString& theString, int theNb=-1 )
115     : myString( theString ), myOrderNb( theNb ) {};
116   _AString & GetString() { return myString; }
117   int GetOrderNb() const { return myOrderNb; }
118   void SetOrderNb( int theNb ) { myOrderNb = theNb; }
119   typedef void* TAddr;
120   TAddr GetAddress() const { return (void*) this; }
121   int Length() { return myString.Length(); }
122   void Clear() { myString.Clear(); myBegPos.Clear(); myArgs.Clear(); }
123   bool IsEmpty() const { return myString.IsEmpty(); }
124   _AString GetIndentation();
125   const _AString & GetResultValue();
126   const int GetNbResultValues();
127   _AString GetResultValue(int res);
128   const _AString & GetObject();
129   const _AString & GetMethod();
130   const _AString & GetArg( int index );
131   int GetNbArgs() { FindAllArgs(); return myArgs.Length(); }
132   bool MethodStartsFrom(const _AString& beg)
133   { GetMethod(); return ( myMeth.Location( beg, 1, myMeth.Length() ) == 1 ); }
134   void SetResultValue( const _AString& theResult )
135   { GetResultValue(); SetPart( RESULT_IND, theResult, myRes ); }
136   void SetObject(const _AString& theObject)
137   { GetObject(); SetPart( OBJECT_IND, theObject, myObj ); }
138   void SetMethod(const _AString& theMethod)
139   { GetMethod(); SetPart( METHOD_IND, theMethod, myMeth ); }
140   void SetArg( int index, const _AString& theArg);
141   void RemoveArgs();
142   void Comment();
143   static bool SkipSpaces( const _AString & theSring, int & thePos );
144   static _AString GetWord( const _AString & theSring, int & theStartPos,
145                            const bool theForward, const bool dotIsWord = false);
146   static bool IsStudyEntry( const _AString& str );
147   static std::list< _pyID > GetStudyEntries( const _AString& str );
148   void AddDependantCmd( Handle(_pyCommand) cmd, bool prepend = false)
149   { if (prepend) myDependentCmds.push_front( cmd ); else myDependentCmds.push_back( cmd ); }
150   bool SetDependentCmdsAfter() const;
151
152   bool AddAccessorMethod( _pyID theObjectID, const char* theAcsMethod );
153
154   DEFINE_STANDARD_RTTI (_pyCommand)
155 };
156
157 // -------------------------------------------------------------------------------------
158 /*!
159  * \brief Root of all objects. It counts calls of Process()
160  */
161 // -------------------------------------------------------------------------------------
162
163 class _pyObject: public Standard_Transient
164 {
165 protected:
166   _pyID                           myID;
167   Handle(_pyCommand)              myCreationCmd;
168   std::list< Handle(_pyCommand) > myProcessedCmds;
169   bool                            myIsPublished;
170
171   void setID(const _pyID& theID);
172 public:
173   _pyObject(const Handle(_pyCommand)& theCreationCmd, const _pyID& theID=_pyID());
174   const _pyID& GetID() { return myID.IsEmpty() ? myCreationCmd->GetResultValue() : myID; }
175   static _pyID FatherID(const _pyID & childID);
176   const Handle(_pyCommand)& GetCreationCmd() { return myCreationCmd; }
177   int GetNbCalls() const { return myProcessedCmds.size(); }
178   bool IsInStudy() const { return myIsPublished; }
179   virtual void SetRemovedFromStudy(const bool isRemoved) { myIsPublished = !isRemoved; }
180   void SetCreationCmd( Handle(_pyCommand) cmd ) { myCreationCmd = cmd; }
181   int GetCommandNb() { return myCreationCmd->GetOrderNb(); }
182   void AddProcessedCmd( const Handle(_pyCommand) & cmd )
183   { if (myProcessedCmds.empty() || myProcessedCmds.back()!=cmd) myProcessedCmds.push_back( cmd );}
184   std::list< Handle(_pyCommand) >& GetProcessedCmds() { return myProcessedCmds; }
185   virtual void Process(const Handle(_pyCommand) & cmd) { AddProcessedCmd(cmd); }
186   virtual void Flush() = 0;
187   virtual const char* AccessorMethod() const;
188   virtual bool CanClear() { return !myIsPublished; }
189   virtual void ClearCommands();
190   virtual void Free() {}
191
192   DEFINE_STANDARD_RTTI (_pyObject)
193 };
194
195 // -------------------------------------------------------------------------------------
196 /*!
197  * \brief Data used to restore cleared Compute() command of an exported mesh
198  * when an imported mesh is created
199  */
200 // -------------------------------------------------------------------------------------
201 struct ExportedMeshData
202 {
203   Handle(_pyMesh)    myMesh;
204   Handle(_pyCommand) myLastComputeCmd;
205   _AString           myLastComputeCmdString;
206   ExportedMeshData() {}
207   ExportedMeshData( const Handle(_pyMesh)& mesh, Handle(_pyCommand) computeCmd):
208     myMesh( mesh ), myLastComputeCmd( computeCmd )
209   {
210     if ( !myLastComputeCmd.IsNull())
211       myLastComputeCmdString = myLastComputeCmd->GetString();
212   }
213 };
214
215 // -------------------------------------------------------------------------------------
216 /*!
217  * \brief Class corresponding to SMESH_Gen. It holds info on existing
218  *        meshes and hypotheses
219  */
220 // -------------------------------------------------------------------------------------
221 class _pyGen: public _pyObject
222 {
223 public:
224   _pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
225          Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
226          SALOMEDS::Study_ptr&                      theStudy,
227          const bool                                theToKeepAllCommands);
228   Handle(_pyCommand) AddCommand( const _AString& theCommand );
229   void ExchangeCommands( Handle(_pyCommand) theCmd1, Handle(_pyCommand) theCmd2 );
230   void SetCommandAfter( Handle(_pyCommand) theCmd, Handle(_pyCommand) theAfterCmd );
231   void SetCommandBefore( Handle(_pyCommand) theCmd, Handle(_pyCommand) theBeforeCmd );
232   Handle(_pyCommand)& GetLastCommand();
233   std::list< Handle(_pyCommand) >& GetCommands() { return myCommands; }
234   void PlaceSubmeshAfterItsCreation( Handle(_pyCommand) theCmdUsingSubmesh ) const;
235
236   _pyID GenerateNewID( const _pyID& theID );
237   void AddObject( Handle(_pyObject)& theObj );
238   void SetProxyObject( const _pyID& theID, Handle(_pyObject)& theObj );
239   Handle(_pyObject) FindObject( const _pyID& theObjID ) const;
240   Handle(_pySubMesh) FindSubMesh( const _pyID& theSubMeshID );
241   Handle(_pyHypothesis) FindHyp( const _pyID& theHypID );
242   Handle(_pyHypothesis) FindAlgo( const _pyID& theGeom, const _pyID& theMesh,
243                                   const Handle(_pyHypothesis)& theHypothesis);
244
245   void SetAccessorMethod(const _pyID& theID, const char* theMethod );
246   bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
247   bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
248   virtual const char* AccessorMethod() const;
249
250   bool IsGeomObject(const _pyID& theObjID) const;
251   bool IsNotPublished(const _pyID& theObjID) const;
252   bool IsToKeepAllCommands() const { return myToKeepAllCommands; }
253   void AddExportedMesh(const _AString& file, const ExportedMeshData& mesh )
254   { myFile2ExportedMesh[ file ] = mesh; }
255   ExportedMeshData& FindExportedMesh( const _AString& file )
256   { return myFile2ExportedMesh[ file ]; }
257
258   virtual void Process( const Handle(_pyCommand)& theCommand );
259   virtual void Flush();
260   virtual void ClearCommands();
261   virtual void Free();
262
263   Handle( _pyHypothesisReader ) GetHypothesisReader() const;
264
265 private:
266   void setNeighbourCommand( Handle(_pyCommand)& theCmd,
267                             Handle(_pyCommand)& theOtherCmd,
268                             const bool theIsAfter );
269   
270 private:
271   std::map< _pyID, Handle(_pyMesh) >       myMeshes;
272   std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;
273   std::map< _pyID, Handle(_pyObject) >     myObjects;
274   std::list< Handle(_pyHypothesis) >       myHypos;
275   std::list< Handle(_pyCommand) >          myCommands;
276   int                                      myNbCommands;
277   Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
278   Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
279   Handle(_pyCommand)                       myLastCommand;
280   int                                      myNbFilters;
281   bool                                     myToKeepAllCommands;
282   SALOMEDS::Study_var                      myStudy;
283   int                                      myGeomIDNb, myGeomIDIndex;
284   std::map< _AString, ExportedMeshData >   myFile2ExportedMesh;
285   Handle( _pyHypothesisReader )            myHypReader;
286
287   DEFINE_STANDARD_RTTI (_pyGen)
288 };
289
290 // -------------------------------------------------------------------------------------
291 /*!
292  * \brief Contains commands concerning mesh substructures
293  */
294 // -------------------------------------------------------------------------------------
295 #define _pyMesh_ACCESS_METHOD "GetMesh()"
296 class _pyMesh: public _pyObject
297 {
298   std::list< Handle(_pyHypothesis) > myHypos;
299   std::list< Handle(_pyCommand) >    myAddHypCmds, myNotConvertedAddHypCmds;
300   std::list< Handle(_pySubMesh) >    mySubmeshes;
301   std::list< Handle(_pyGroup) >      myGroups;
302   std::list< Handle(_pyMeshEditor)>  myEditors;
303   //d::list< Handle(_pyMesh) >       myFatherMeshes; // this mesh depends on
304   std::list< Handle(_pyMesh) >       myChildMeshes; // depending on me
305   bool                               myGeomNotInStudy;
306   Handle(_pyCommand)                 myLastComputeCmd;
307 public:
308   _pyMesh(const Handle(_pyCommand) creationCmd);
309   _pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID & id);
310   const _pyID& GetGeom() { return GetCreationCmd()->GetArg(1); }
311   void AddGroup( const Handle(_pyGroup)& g ) { myGroups.push_back( g ); }
312   void AddEditor( const Handle(_pyMeshEditor)& e ) { myEditors.push_back( e ); }
313   bool IsNotGeomPublished() { return myGeomNotInStudy; }
314   virtual void Process( const Handle(_pyCommand)& theCommand);
315   virtual void Flush();
316   virtual void SetRemovedFromStudy(const bool isRemoved);
317   virtual bool CanClear();
318   virtual void ClearCommands();
319   virtual void Free() { /*myFatherMeshes.clear();*/ myChildMeshes.clear(); }
320   virtual const char* AccessorMethod() const { return _pyMesh_ACCESS_METHOD; }
321 private:
322   void addFatherMesh( const Handle(_pyMesh)& mesh );
323   void addFatherMesh( const _pyID& meshID );
324   static bool NeedMeshAccess( const Handle(_pyCommand)& theCommand );
325   static void AddMeshAccess( const Handle(_pyCommand)& theCommand )
326   { theCommand->SetObject( theCommand->GetObject() + "." _pyMesh_ACCESS_METHOD ); }
327
328   DEFINE_STANDARD_RTTI (_pyMesh)
329 };
330 #undef _pyMesh_ACCESS_METHOD 
331
332 // -------------------------------------------------------------------------------------
333 /*!
334  * \brief MeshEditor convert its commands to ones of mesh
335  */
336 // -------------------------------------------------------------------------------------
337 class _pyMeshEditor: public _pyObject
338 {
339   _pyID    myMesh;
340   _AString myCreationCmdStr;
341 public:
342   _pyMeshEditor(const Handle(_pyCommand)& theCreationCmd);
343   _pyID GetMesh() const { return myMesh; }
344   virtual void Process( const Handle(_pyCommand)& theCommand);
345   virtual void Flush() {}
346   virtual bool CanClear();
347
348   DEFINE_STANDARD_RTTI (_pyMesh)
349 };
350
351 // -------------------------------------------------------------------------------------
352 /*!
353  * \brief Root class for hypothesis
354  */
355 // -------------------------------------------------------------------------------------
356 class _pyHypothesis: public _pyObject
357 {
358   friend class _pyHypothesisReader;
359 protected:
360   bool    myIsAlgo, myIsWrapped;
361   _pyID   myGeom,   myMesh;
362   struct CreationMethod {
363     _AString              myMethod; // method of algo or mesh creating a hyp
364     // myArgNb(i)-th arg of myArgMethods(i) of hyp becomes an i-th arg of myMethod
365     std::vector<_AString> myArgMethods;
366     std::vector<int>      myArgNb; // arg nb countered from 1
367     std::vector<_AString> myArgs; // creation arguments
368   };
369   void setCreationArg( const int argNb, const _AString& arg );
370   // a hypothesis can be created by different algos by different methods
371   typedef std::map<_AString, CreationMethod > TType2CrMethod;
372   TType2CrMethod                myAlgoType2CreationMethod;
373   std::set< _AString >          myAccumulativeMethods;
374   CreationMethod*               myCurCrMethod; // used for adding to myAlgoType2CreationMethod
375   std::list<Handle(_pyCommand)> myArgCommands;
376   std::list<Handle(_pyCommand)> myUnusedCommands;
377   std::list<Handle(_pyObject) > myReferredObjs;
378   // maps used to clear commands setting parameters if result of setting is
379   // discared (e.g. by mesh.Clear())
380   std::map<_AString, std::list<Handle(_pyCommand)> >            myMeth2Commands;
381   std::map< _pyCommand::TAddr, std::list<Handle(_pyCommand) > > myComputeAddr2Cmds;
382   std::list<Handle(_pyCommand) >                                myComputeCmds;
383   void rememberCmdOfParameter( const Handle(_pyCommand) & cmd );
384   bool isCmdUsedForCompute( const Handle(_pyCommand) & cmd,
385                             _pyCommand::TAddr avoidComputeAddr=NULL ) const;
386 public:
387   _pyHypothesis(const Handle(_pyCommand)& theCreationCmd);
388   void SetConvMethodAndType(const _AString& creationMethod, const _AString& type)
389   { myCurCrMethod = &myAlgoType2CreationMethod[ type ];
390     myCurCrMethod->myMethod = creationMethod; }
391   void AddArgMethod(const _AString& method, const int argNb = 1)
392   { myCurCrMethod->myArgMethods.push_back( method );
393     myCurCrMethod->myArgNb.push_back( argNb ); }
394   void AddAccumulativeMethod( const _AString& method)
395   { myAccumulativeMethods.insert( method ); }
396   //const TColStd_SequenceOfAsciiString& GetArgs() const { return myArgs; }
397   const std::list<Handle(_pyCommand)>& GetArgCommands() const { return myArgCommands; }
398   void ClearAllCommands();
399   virtual bool IsAlgo() const { return myIsAlgo; }
400   bool IsValid() const { return !myAlgoType2CreationMethod.empty(); }
401   bool IsWrapped() const { return myIsWrapped; }
402   const _pyID & GetGeom() const { return myGeom; }
403   void SetMesh( const _pyID& theMeshId) { if ( myMesh.IsEmpty() ) myMesh = theMeshId; }
404   const _pyID & GetMesh() const { return myMesh; }
405   const _AString& GetAlgoType() const
406   { return myAlgoType2CreationMethod.begin()->first; }
407   const _AString& GetAlgoCreationMethod() const
408   { return myAlgoType2CreationMethod.begin()->second.myMethod; }
409   bool CanBeCreatedBy(const _AString& algoType ) const
410   { return myAlgoType2CreationMethod.find( algoType ) != myAlgoType2CreationMethod.end(); }
411   const _AString& GetCreationMethod(const _AString& algoType)
412   { return ( myCurCrMethod = & myAlgoType2CreationMethod[ algoType ])->myMethod; }
413   static Handle(_pyHypothesis) NewHypothesis( const Handle(_pyCommand)& theCreationCmd);
414
415   virtual bool IsWrappable(const _pyID& theMesh) const;
416   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
417                                   const _pyID&              theMesh);
418   virtual void Process( const Handle(_pyCommand)& theCommand);
419   virtual void Flush();
420   virtual void Free() { myReferredObjs.clear(); }
421   virtual void Assign( const Handle(_pyHypothesis)& theOther,
422                        const _pyID&                 theMesh );
423   virtual bool CanClear();
424   virtual void ClearCommands();
425   virtual bool GetReferredMeshesAndGeom( std::list< Handle(_pyMesh) >& meshes );
426
427   void MeshComputed    ( const Handle(_pyCommand)& theComputeCommand );
428   void ComputeDiscarded( const Handle(_pyCommand)& theComputeCommand );
429   //void ComputeSaved    ( const Handle(_pyCommand)& theComputeCommand );
430
431
432   DEFINE_STANDARD_RTTI (_pyHypothesis)
433 };
434
435 // -------------------------------------------------------------------------------------
436 /*!
437  * \brief Class representing smesh.Mesh_Algorithm
438  */
439 // -------------------------------------------------------------------------------------
440 class _pyAlgorithm: public _pyHypothesis
441 {
442 public:
443   _pyAlgorithm(const Handle(_pyCommand)& theCreationCmd);
444   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
445                                   const _pyID&              theMesh);
446   virtual const char* AccessorMethod() const { return "GetAlgorithm()"; }
447   virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped; }
448
449   DEFINE_STANDARD_RTTI (_pyAlgorithm)
450 };
451
452 // -------------------------------------------------------------------------------------
453 /*!
454  * \brief Class for hypotheses having several parameters modified by one method
455  */
456 // -------------------------------------------------------------------------------------
457 class _pyComplexParamHypo: public _pyHypothesis
458 {
459 public:
460   _pyComplexParamHypo(const Handle(_pyCommand)& theCreationCmd): _pyHypothesis(theCreationCmd) {}
461   virtual void Process( const Handle(_pyCommand)& theCommand);
462   virtual void Flush();
463
464   DEFINE_STANDARD_RTTI (_pyComplexParamHypo)
465 };
466 DEFINE_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis);
467
468 // -------------------------------------------------------------------------------------
469 /*!
470  * \brief Class for LayerDistribution hypothesis conversion
471  */
472 // -------------------------------------------------------------------------------------
473 class _pyLayerDistributionHypo: public _pyHypothesis
474 {
475   Handle(_pyHypothesis) my1dHyp;
476   _AString              myAlgoMethod;
477 public:
478   _pyLayerDistributionHypo(const Handle(_pyCommand)& theCreationCmd, const char* algoMethod):
479     _pyHypothesis(theCreationCmd), myAlgoMethod((char*)algoMethod) {}
480   virtual void Process( const Handle(_pyCommand)& theCommand);
481   virtual void Flush();
482   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
483                                   const _pyID&              theMesh);
484   virtual void Free() { my1dHyp.Nullify(); }
485
486   DEFINE_STANDARD_RTTI (_pyLayerDistributionHypo)
487 };
488 DEFINE_STANDARD_HANDLE (_pyLayerDistributionHypo, _pyHypothesis);
489
490 // -------------------------------------------------------------------------------------
491 /*!
492  * \brief Class representing NumberOfSegments hypothesis
493  */
494 // -------------------------------------------------------------------------------------
495 class _pyNumberOfSegmentsHyp: public _pyHypothesis
496 {
497 public:
498   _pyNumberOfSegmentsHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
499   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
500                                   const _pyID&              theMesh);
501   void Flush();
502
503   DEFINE_STANDARD_RTTI (_pyNumberOfSegmentsHyp)
504 };
505 DEFINE_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis);
506
507 // -------------------------------------------------------------------------------------
508 /*!
509  * \brief Class representing SegmentLengthAroundVertex hypothesis
510  */
511 // -------------------------------------------------------------------------------------
512 class _pySegmentLengthAroundVertexHyp: public _pyHypothesis
513 {
514 public:
515   _pySegmentLengthAroundVertexHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
516   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
517                                   const _pyID&              theMesh);
518   DEFINE_STANDARD_RTTI (_pySegmentLengthAroundVertexHyp)
519 };
520 DEFINE_STANDARD_HANDLE (_pySegmentLengthAroundVertexHyp, _pyHypothesis);
521
522 // -------------------------------------------------------------------------------------
523 /*!
524  * \brief SelfEraser erases creation command if no more it's commands invoked
525  */
526 // -------------------------------------------------------------------------------------
527 class _pySelfEraser: public _pyObject
528 {
529 public:
530   _pySelfEraser(const Handle(_pyCommand)& theCreationCmd)
531     :_pyObject(theCreationCmd) { myIsPublished = true; }
532   virtual void Flush();
533
534   DEFINE_STANDARD_RTTI (_pySelfEraser)
535 };
536 DEFINE_STANDARD_HANDLE (_pySelfEraser, _pyObject);
537
538 // -------------------------------------------------------------------------------------
539 /*!
540  * \brief SubMesh creation can be moved to the end of engine commands
541  */
542 // -------------------------------------------------------------------------------------
543 class _pySubMesh:  public _pyObject
544 {
545   Handle(_pyObject) myCreator;
546   Handle(_pyMesh) myMesh;
547 public:
548   _pySubMesh(const Handle(_pyCommand)& theCreationCmd);
549   virtual void Process( const Handle(_pyCommand)& theCommand);
550   virtual void Flush();
551   virtual Handle(_pyMesh) GetMesh() { return myMesh; }
552   virtual void Free() { myCreator.Nullify(); myMesh.Nullify(); }
553   void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
554   static bool CanBeArgOfMethod(const _AString& theMethodName);
555
556   DEFINE_STANDARD_RTTI (_pySubMesh)
557 };
558 // -------------------------------------------------------------------------------------
559 /*!
560  * \brief A filter sets a human readable name to self
561  */
562 // -------------------------------------------------------------------------------------
563 class _pyFilter:  public _pyObject
564 {
565   _pyID myNewID, myMesh;
566   std::list< Handle(_pyObject) > myUsers;
567 public:
568   _pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID="");
569   void AddUser( const Handle(_pyObject)& user) { myUsers.push_back( user ); }
570   virtual void Process( const Handle(_pyCommand)& theCommand);
571   virtual void Flush();
572   virtual bool CanClear();
573   virtual void Free() { myUsers.clear(); }
574   const _pyID& GetNewID() const { return myNewID; }
575
576   DEFINE_STANDARD_RTTI (_pyFilter)
577 };
578 DEFINE_STANDARD_HANDLE (_pyFilter, _pyObject);
579
580 // -------------------------------------------------------------------------------------
581 /*!
582  * \brief To convert creation of a group by filter
583  */
584 // -------------------------------------------------------------------------------------
585 class _pyGroup:  public _pySubMesh
586 {
587   Handle(_pyFilter) myFilter;
588   bool              myCanClearCreationCmd;
589 public:
590   _pyGroup(const Handle(_pyCommand)& theCreationCmd, const _pyID & id=_pyID());
591   virtual void Process( const Handle(_pyCommand)& theCommand);
592   virtual void Flush();
593   virtual void Free() { myFilter.Nullify(); }
594   void RemovedWithContents();
595
596   DEFINE_STANDARD_RTTI (_pyGroup)
597 };
598
599 // -------------------------------------------------------------------------------------
600 /*!
601  * \brief Class reading _pyHypothesis'es from resource files of mesher Plugins
602  */
603 // -------------------------------------------------------------------------------------
604 class _pyHypothesisReader: public Standard_Transient
605 {
606   std::map<_AString, Handle(_pyHypothesis)> myType2Hyp;
607 public:
608   _pyHypothesisReader();
609   Handle(_pyHypothesis) GetHypothesis(const _AString&           hypType,
610                                       const Handle(_pyCommand)& creationCmd) const;
611   DEFINE_STANDARD_RTTI (_pyHypothesisReader)
612 };
613
614 #endif