Salome HOME
0021375: EDF 1671 SMESH: Dump study of current state
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.hxx
1 // Copyright (C) 2007-2011  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
40 #include CORBA_SERVER_HEADER(SALOMEDS)
41
42 // ===========================================================================================
43 /*!
44  * This file was created in order to respond to requirement of bug PAL10494:
45  * SMESH python dump uses idl interface.
46  *
47  * The creation reason is that smesh.py commands defining hypotheses encapsulate
48  * several SMESH engine method calls. As well, the dependencies between smesh.py
49  * classes differ from ones between corresponding SMESH IDL interfaces.
50  * 
51  * Everything here is for internal usage by SMESH_2smeshpy::ConvertScript()
52  * declared in SMESH_PythonDump.hxx
53  *
54  * See comments to _pyHypothesis class to know how to assure convertion of a new
55  * type of hypothesis
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
75 DEFINE_STANDARD_HANDLE (_pyCommand   ,Standard_Transient);
76 DEFINE_STANDARD_HANDLE (_pyObject    ,Standard_Transient);
77 DEFINE_STANDARD_HANDLE (_pyGen       ,_pyObject);
78 DEFINE_STANDARD_HANDLE (_pyMesh      ,_pyObject);
79 DEFINE_STANDARD_HANDLE (_pySubMesh   ,_pyObject);
80 DEFINE_STANDARD_HANDLE (_pyGroup     ,_pySubMesh);
81 DEFINE_STANDARD_HANDLE (_pyMeshEditor,_pyObject);
82 DEFINE_STANDARD_HANDLE (_pyHypothesis,_pyObject);
83 DEFINE_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
84
85 typedef TCollection_AsciiString _pyID;
86
87 // ===========================================================
88 /*!
89  * \brief Class operating on a command string looking like
90  *        ResultValue = Object.Method( Arg1, Arg2,...)
91  */
92 // ===========================================================
93
94 class _pyCommand: public Standard_Transient
95 {
96   int                             myOrderNb;            //!< position within the script
97   TCollection_AsciiString         myString;             //!< command text
98   TCollection_AsciiString         myRes, myObj, myMeth; //!< found parts of command
99   TColStd_SequenceOfAsciiString   myArgs;               //!< found arguments
100   TColStd_SequenceOfInteger       myBegPos;             //!< where myRes, myObj, ... begin
101   std::list< Handle(_pyCommand) > myDependentCmds; //!< commands that sould follow me in the script
102
103   enum { UNKNOWN=-1, EMPTY=0, RESULT_IND, OBJECT_IND, METHOD_IND, ARG1_IND };
104   int GetBegPos( int thePartIndex );
105   void SetBegPos( int thePartIndex, int thePosition );
106   void SetPart( int thePartIndex, const TCollection_AsciiString& theNewPart,
107                 TCollection_AsciiString& theOldPart);
108   void FindAllArgs() { GetArg(1); }
109
110 public:
111   _pyCommand() {};
112   _pyCommand( const TCollection_AsciiString& theString, int theNb )
113     : myString( theString ), myOrderNb( theNb ) {};
114   TCollection_AsciiString & GetString() { return myString; }
115   int GetOrderNb() const { return myOrderNb; }
116   void SetOrderNb( int theNb ) { myOrderNb = theNb; }
117   typedef void* TAddr;
118   TAddr GetAddress() const { return (void*) this; }
119   int Length() { return myString.Length(); }
120   void Clear() { myString.Clear(); myBegPos.Clear(); myArgs.Clear(); }
121   bool IsEmpty() const { return myString.IsEmpty(); }
122   TCollection_AsciiString GetIndentation();
123   const TCollection_AsciiString & GetResultValue();
124   const int GetNbResultValues();
125   const TCollection_AsciiString & GetResultValue(int res);
126   const TCollection_AsciiString & GetObject();
127   const TCollection_AsciiString & GetMethod();
128   const TCollection_AsciiString & GetArg( int index );
129   int GetNbArgs() { FindAllArgs(); return myArgs.Length(); }
130   bool MethodStartsFrom(const TCollection_AsciiString& beg)
131   { GetMethod(); return ( myMeth.Location( beg, 1, myMeth.Length() ) == 1 ); }
132   //Handle(TColStd_HSequenceOfAsciiString) GetArgs();
133   void SetResultValue( const TCollection_AsciiString& theResult )
134   { GetResultValue(); SetPart( RESULT_IND, theResult, myRes ); }
135   void SetObject(const TCollection_AsciiString& theObject)
136   { GetObject(); SetPart( OBJECT_IND, theObject, myObj ); }
137   void SetMethod(const TCollection_AsciiString& theMethod)
138   { GetMethod(); SetPart( METHOD_IND, theMethod, myMeth ); }
139   void SetArg( int index, const TCollection_AsciiString& theArg);
140   void RemoveArgs();
141   void Comment();
142   static bool SkipSpaces( const TCollection_AsciiString & theSring, int & thePos );
143   static TCollection_AsciiString GetWord( const TCollection_AsciiString & theSring,
144                                           int & theStartPos, const bool theForward,
145                                           const bool dotIsWord = false);
146   static bool IsStudyEntry( const TCollection_AsciiString& str );
147   static std::list< _pyID > GetStudyEntries( const TCollection_AsciiString& 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   TCollection_AsciiString 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 TCollection_AsciiString& 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
235   _pyID GenerateNewID( const _pyID& theID );
236   void AddObject( Handle(_pyObject)& theObj );
237   Handle(_pyObject) FindObject( const _pyID& theObjID ) const;
238   Handle(_pySubMesh) FindSubMesh( const _pyID& theSubMeshID );
239   Handle(_pyHypothesis) FindHyp( const _pyID& theHypID );
240   Handle(_pyHypothesis) FindAlgo( const _pyID& theGeom, const _pyID& theMesh,
241                                   const Handle(_pyHypothesis)& theHypothesis);
242
243   void SetAccessorMethod(const _pyID& theID, const char* theMethod );
244   bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
245   bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
246   virtual const char* AccessorMethod() const;
247
248   bool IsGeomObject(const _pyID& theObjID) const;
249   bool IsNotPublished(const _pyID& theObjID) const;
250   bool IsToKeepAllCommands() const { return myToKeepAllCommands; }
251   void AddExportedMesh(const TCollection_AsciiString& file, const ExportedMeshData& mesh )
252   { myFile2ExportedMesh[ file ] = mesh; }
253   ExportedMeshData& FindExportedMesh( const TCollection_AsciiString& file )
254   { return myFile2ExportedMesh[ file ]; }
255
256   virtual void Process( const Handle(_pyCommand)& theCommand );
257   virtual void Flush();
258   virtual void ClearCommands();
259   virtual void Free();
260
261 private:
262   void setNeighbourCommand( Handle(_pyCommand)& theCmd,
263                             Handle(_pyCommand)& theOtherCmd,
264                             const bool theIsAfter );
265   
266 private:
267   std::map< _pyID, Handle(_pyMesh) >       myMeshes;
268   std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;
269   std::map< _pyID, Handle(_pyObject) >     myObjects;
270   std::list< Handle(_pyHypothesis) >       myHypos;
271   std::list< Handle(_pyCommand) >          myCommands;
272   int                                      myNbCommands;
273   Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
274   Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
275   Handle(_pyCommand)                       myLastCommand;
276   int                                      myNbFilters;
277   bool                                     myToKeepAllCommands;
278   SALOMEDS::Study_var                      myStudy;
279   int                                      myGeomIDNb, myGeomIDIndex;
280   std::map< TCollection_AsciiString, ExportedMeshData > myFile2ExportedMesh;
281
282   DEFINE_STANDARD_RTTI (_pyGen)
283 };
284
285 // -------------------------------------------------------------------------------------
286 /*!
287  * \brief Contains commands concerning mesh substructures
288  */
289 // -------------------------------------------------------------------------------------
290 #define _pyMesh_ACCESS_METHOD "GetMesh()"
291 class _pyMesh: public _pyObject
292 {
293   std::list< Handle(_pyHypothesis) > myHypos;
294   std::list< Handle(_pyCommand) >    myAddHypCmds;
295   std::list< Handle(_pySubMesh) >    mySubmeshes;
296   std::list< Handle(_pyGroup) >      myGroups;
297   std::list< Handle(_pyMeshEditor)>  myEditors;
298   //d::list< Handle(_pyMesh) >       myFatherMeshes; // this mesh depends on
299   std::list< Handle(_pyMesh) >       myChildMeshes; // depending on me
300   bool                               myGeomNotInStudy;
301   Handle(_pyCommand)                 myLastComputeCmd;
302 public:
303   _pyMesh(const Handle(_pyCommand) creationCmd);
304   _pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID & id);
305   const _pyID& GetGeom() { return GetCreationCmd()->GetArg(1); }
306   void AddGroup( const Handle(_pyGroup)& g ) { myGroups.push_back( g ); }
307   void AddEditor( const Handle(_pyMeshEditor)& e ) { myEditors.push_back( e ); }
308   bool IsNotGeomPublished() { return myGeomNotInStudy; }
309   virtual void Process( const Handle(_pyCommand)& theCommand);
310   virtual void Flush();
311   virtual void SetRemovedFromStudy(const bool isRemoved);
312   virtual bool CanClear();
313   virtual void ClearCommands();
314   virtual void Free() { /*myFatherMeshes.clear();*/ myChildMeshes.clear(); }
315   virtual const char* AccessorMethod() const { return _pyMesh_ACCESS_METHOD; }
316 private:
317   void addFatherMesh( const Handle(_pyMesh)& mesh );
318   void addFatherMesh( const _pyID& meshID );
319   static bool NeedMeshAccess( const Handle(_pyCommand)& theCommand );
320   static void AddMeshAccess( const Handle(_pyCommand)& theCommand )
321   { theCommand->SetObject( theCommand->GetObject() + "." _pyMesh_ACCESS_METHOD ); }
322
323   DEFINE_STANDARD_RTTI (_pyMesh)
324 };
325 #undef _pyMesh_ACCESS_METHOD 
326
327 // -------------------------------------------------------------------------------------
328 /*!
329  * \brief MeshEditor convert its commands to ones of mesh
330  */
331 // -------------------------------------------------------------------------------------
332 class _pyMeshEditor: public _pyObject
333 {
334   _pyID myMesh;
335   TCollection_AsciiString myCreationCmdStr;
336 public:
337   _pyMeshEditor(const Handle(_pyCommand)& theCreationCmd);
338   _pyID GetMesh() const { return myMesh; }
339   virtual void Process( const Handle(_pyCommand)& theCommand);
340   virtual void Flush() {}
341   virtual bool CanClear();
342
343   DEFINE_STANDARD_RTTI (_pyMesh)
344 };
345
346 // -------------------------------------------------------------------------------------
347 /*!
348  * \brief Root class for hypothesis
349  *
350  * HOWTO assure convertion of a new type of hypothesis
351  * In _pyHypothesis::NewHypothesis():
352  * 1. add a case for the name of the new hypothesis
353  * 2. use SetConvMethodAndType() to set
354  *    . for algo: algorithm name and method of Mesh creating the algo
355  *    . for hypo: name of the algorithm and method creating the hypothesis
356  * 3. append to myArgMethods interface methods setting param values in the
357  *    order they are used when creation method is called. If arguments of
358  *    the creation method can't be easily got from calls of hypothesis methods, you are
359  *    to derive a specific class from _pyHypothesis that would redefine Process(),
360  *    see _pyComplexParamHypo for example
361  */
362 // -------------------------------------------------------------------------------------
363 class _pyHypothesis: public _pyObject
364 {
365 protected:
366   bool    myIsAlgo, myIsWrapped;
367   _pyID   myGeom,   myMesh;
368   // a hypothesis can be used and created by different algos by different methods
369   std::map<TCollection_AsciiString, TCollection_AsciiString > myType2CreationMethod;
370   TColStd_SequenceOfAsciiString myArgs;           // creation arguments
371   TColStd_SequenceOfAsciiString myArgMethods;     // hypo methods setting myArgs
372   TColStd_SequenceOfInteger     myNbArgsByMethod; // nb args set by each method
373   std::list<Handle(_pyCommand)> myArgCommands;
374   std::list<Handle(_pyCommand)> myUnknownCommands;
375   std::list<Handle(_pyObject) > myReferredObjs;
376   // maps used to clear commands setting parameters if result of setting is not
377   // used (no mesh.Compute()) or discared (e.g. by mesh.Clear())
378   std::map<TCollection_AsciiString, std::list<Handle(_pyCommand)> > myMeth2Commands;
379   std::map< _pyCommand::TAddr, std::list<Handle(_pyCommand) > >     myComputeAddr2Cmds;
380   std::list<Handle(_pyCommand) >                                    myComputeCmds;
381   void rememberCmdOfParameter( const Handle(_pyCommand) & cmd );
382   bool isCmdUsedForCompute( const Handle(_pyCommand) & cmd,
383                             _pyCommand::TAddr avoidComputeAddr=NULL ) const;
384 public:
385   _pyHypothesis(const Handle(_pyCommand)& theCreationCmd);
386   void SetConvMethodAndType(const char* creationMethod, const char* type)
387   { myType2CreationMethod[ (char*)type ] = (char*)creationMethod; }
388   void AddArgMethod(const char* method, const int nbArgs = 1)
389   { myArgMethods.Append( (char*)method ); myNbArgsByMethod.Append( nbArgs ); }
390   const TColStd_SequenceOfAsciiString& GetArgs() const { return myArgs; }
391   const std::list<Handle(_pyCommand)>& GetArgCommands() const { return myArgCommands; }
392   void ClearAllCommands();
393   virtual bool IsAlgo() const { return myIsAlgo; }
394   bool IsValid() const { return !myType2CreationMethod.empty(); }
395   bool IsWrapped() const { return myIsWrapped; }
396   const _pyID & GetGeom() const { return myGeom; }
397   void SetMesh( const _pyID& theMeshId) { if ( myMesh.IsEmpty() ) myMesh = theMeshId; }
398   const _pyID & GetMesh() const { return myMesh; }
399   const TCollection_AsciiString& GetAlgoType() const
400   { return myType2CreationMethod.begin()->first; }
401   const TCollection_AsciiString& GetAlgoCreationMethod() const
402   { return myType2CreationMethod.begin()->second; }
403   bool CanBeCreatedBy(const TCollection_AsciiString& algoType ) const
404   { return myType2CreationMethod.find( algoType ) != myType2CreationMethod.end(); }
405   const TCollection_AsciiString& GetCreationMethod(const TCollection_AsciiString& algoType) const
406   { return myType2CreationMethod.find( algoType )->second; }
407   static Handle(_pyHypothesis) NewHypothesis( const Handle(_pyCommand)& theCreationCmd);
408
409   virtual bool IsWrappable(const _pyID& theMesh) const;
410   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
411                                   const _pyID&              theMesh);
412   virtual void Process( const Handle(_pyCommand)& theCommand);
413   virtual void Flush();
414   virtual void Free() { myReferredObjs.clear(); }
415   virtual void Assign( const Handle(_pyHypothesis)& theOther,
416                        const _pyID&                 theMesh );
417   virtual bool CanClear();
418   virtual void ClearCommands();
419   virtual bool GetReferredMeshesAndGeom( std::list< Handle(_pyMesh) >& meshes );
420
421   void MeshComputed    ( const Handle(_pyCommand)& theComputeCommand );
422   void ComputeDiscarded( const Handle(_pyCommand)& theComputeCommand );
423   //void ComputeSaved    ( const Handle(_pyCommand)& theComputeCommand );
424
425
426   DEFINE_STANDARD_RTTI (_pyHypothesis)
427 };
428
429 // -------------------------------------------------------------------------------------
430 /*!
431  * \brief Class representing smesh.Mesh_Algorithm
432  */
433 // -------------------------------------------------------------------------------------
434 class _pyAlgorithm: public _pyHypothesis
435 {
436 public:
437   _pyAlgorithm(const Handle(_pyCommand)& theCreationCmd);
438   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
439                                   const _pyID&              theMesh);
440   virtual const char* AccessorMethod() const { return "GetAlgorithm()"; }
441   virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped; }
442
443   DEFINE_STANDARD_RTTI (_pyAlgorithm)
444 };
445
446 // -------------------------------------------------------------------------------------
447 /*!
448  * \brief Class for hypotheses having several parameters modified by one method
449  */
450 // -------------------------------------------------------------------------------------
451 class _pyComplexParamHypo: public _pyHypothesis
452 {
453 public:
454   _pyComplexParamHypo(const Handle(_pyCommand)& theCreationCmd): _pyHypothesis(theCreationCmd) {}
455   virtual void Process( const Handle(_pyCommand)& theCommand);
456   virtual void Flush();
457
458   DEFINE_STANDARD_RTTI (_pyComplexParamHypo)
459 };
460 DEFINE_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis);
461
462 // -------------------------------------------------------------------------------------
463 /*!
464  * \brief Class for LayerDistribution hypothesis conversion
465  */
466 // -------------------------------------------------------------------------------------
467 class _pyLayerDistributionHypo: public _pyHypothesis
468 {
469   Handle(_pyHypothesis) my1dHyp;
470   TCollection_AsciiString myAlgoMethod;
471 public:
472   _pyLayerDistributionHypo(const Handle(_pyCommand)& theCreationCmd, const char* algoMethod):
473     _pyHypothesis(theCreationCmd), myAlgoMethod((char*)algoMethod) {}
474   virtual void Process( const Handle(_pyCommand)& theCommand);
475   virtual void Flush();
476   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
477                                   const _pyID&              theMesh);
478   virtual void Free() { my1dHyp.Nullify(); }
479
480   DEFINE_STANDARD_RTTI (_pyLayerDistributionHypo)
481 };
482 DEFINE_STANDARD_HANDLE (_pyLayerDistributionHypo, _pyHypothesis);
483
484 // -------------------------------------------------------------------------------------
485 /*!
486  * \brief Class representing NumberOfSegments hypothesis
487  */
488 // -------------------------------------------------------------------------------------
489 class _pyNumberOfSegmentsHyp: public _pyHypothesis
490 {
491 public:
492   _pyNumberOfSegmentsHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
493   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
494                                   const _pyID&              theMesh);
495   void Flush();
496
497   DEFINE_STANDARD_RTTI (_pyNumberOfSegmentsHyp)
498 };
499 DEFINE_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis);
500
501 // -------------------------------------------------------------------------------------
502 /*!
503  * \brief Class representing SegmentLengthAroundVertex hypothesis
504  */
505 // -------------------------------------------------------------------------------------
506 class _pySegmentLengthAroundVertexHyp: public _pyHypothesis
507 {
508 public:
509   _pySegmentLengthAroundVertexHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
510   virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
511                                   const _pyID&              theMesh);
512   DEFINE_STANDARD_RTTI (_pySegmentLengthAroundVertexHyp)
513 };
514 DEFINE_STANDARD_HANDLE (_pySegmentLengthAroundVertexHyp, _pyHypothesis);
515
516 // -------------------------------------------------------------------------------------
517 /*!
518  * \brief SelfEraser erases creation command if no more it's commands invoked
519  */
520 // -------------------------------------------------------------------------------------
521 class _pySelfEraser: public _pyObject
522 {
523 public:
524   _pySelfEraser(const Handle(_pyCommand)& theCreationCmd):_pyObject(theCreationCmd) {}
525   virtual void Flush();
526
527   DEFINE_STANDARD_RTTI (_pySelfEraser)
528 };
529 DEFINE_STANDARD_HANDLE (_pySelfEraser, _pyObject);
530
531 // -------------------------------------------------------------------------------------
532 /*!
533  * \brief SubMesh creation can be moved to the end of engine commands
534  */
535 // -------------------------------------------------------------------------------------
536 class _pySubMesh:  public _pyObject
537 {
538   Handle(_pyObject) myCreator;
539   Handle(_pyMesh) myMesh;
540 public:
541   _pySubMesh(const Handle(_pyCommand)& theCreationCmd);
542   virtual void Process( const Handle(_pyCommand)& theCommand);
543   virtual void Flush();
544   virtual Handle(_pyMesh) GetMesh() { return myMesh; }
545   virtual void Free() { myCreator.Nullify(); myMesh.Nullify(); }
546   void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
547
548   DEFINE_STANDARD_RTTI (_pySubMesh)
549 };
550 // -------------------------------------------------------------------------------------
551 /*!
552  * \brief To convert creation of a group by filter
553  */
554 // -------------------------------------------------------------------------------------
555 class _pyGroup:  public _pySubMesh
556 {
557 public:
558   _pyGroup(const Handle(_pyCommand)& theCreationCmd, const _pyID & id=_pyID())
559     :_pySubMesh(theCreationCmd) { setID( id ); }
560   virtual void Process( const Handle(_pyCommand)& theCommand);
561   virtual void Flush() {}
562
563   DEFINE_STANDARD_RTTI (_pyGroup)
564 };
565
566 // -------------------------------------------------------------------------------------
567 /*!
568  * \brief A filter sets a human readable name to self
569  */
570 // -------------------------------------------------------------------------------------
571 class _pyFilter:  public _pyObject
572 {
573   _pyID myNewID;
574   std::list< Handle(_pyObject) > myUsers;
575 public:
576   _pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID="");
577   void AddUser( const Handle(_pyObject)& user) { myUsers.push_back( user ); }
578   virtual void Process( const Handle(_pyCommand)& theCommand);
579   virtual void Flush();
580   virtual bool CanClear();
581   virtual void Free() { myUsers.clear(); }
582   const _pyID& GetNewID() const { return myNewID; }
583
584   DEFINE_STANDARD_RTTI (_pyFilter)
585 };
586 DEFINE_STANDARD_HANDLE (_pyFilter, _pyObject);
587
588 #endif