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