1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESH_smesh.hxx
24 // Created : Fri Nov 18 12:05:18 2005
25 // Author : Edward AGAPOV (eap)
27 #ifndef SMESH_smesh_HeaderFile
28 #define SMESH_smesh_HeaderFile
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>
42 #include <SALOMEconfig.h>
43 #include CORBA_CLIENT_HEADER(SALOMEDS)
45 #define USE_STRING_FAMILY
47 // ===========================================================================================
49 * This file was created in order to respond to requirement of bug PAL10494:
50 * SMESH python dump uses idl interface.
52 * The creation reason is that smeshBuilder.py commands defining hypotheses encapsulate
53 * several SMESH engine method calls. As well, the dependencies between smeshBuilder.py
54 * classes differ from ones between corresponding SMESH IDL interfaces.
56 * Everything here is for internal usage by SMESH_2smeshpy::ConvertScript()
57 * declared in SMESH_PythonDump.hxx
59 // ===========================================================================================
61 class Resource_DataMapOfAsciiStringAsciiString;
63 // ===========================================================================================
64 // =====================
66 // =====================
67 // ===========================================================================================
76 class _pyHypothesisReader;
78 DEFINE_STANDARD_HANDLE (_pyCommand ,Standard_Transient);
79 DEFINE_STANDARD_HANDLE (_pyObject ,Standard_Transient);
80 DEFINE_STANDARD_HANDLE (_pyHypothesisReader,Standard_Transient);
81 DEFINE_STANDARD_HANDLE (_pyGen ,_pyObject);
82 DEFINE_STANDARD_HANDLE (_pyMesh ,_pyObject);
83 DEFINE_STANDARD_HANDLE (_pySubMesh ,_pyObject);
84 DEFINE_STANDARD_HANDLE (_pyGroup ,_pySubMesh);
85 DEFINE_STANDARD_HANDLE (_pyMeshEditor ,_pyObject);
86 DEFINE_STANDARD_HANDLE (_pyHypothesis ,_pyObject);
87 DEFINE_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
89 typedef TCollection_AsciiString _pyID;
90 typedef TCollection_AsciiString _AString;
92 // ===========================================================
94 * \brief Class operating on a command string looking like
95 * ResultValue = Object.Method( Arg1, Arg2,...)
97 // ===========================================================
99 class _pyCommand: public Standard_Transient
101 int myOrderNb; //!< position within the script
102 _AString myString; //!< command text
103 _AString myRes, myObj, myMeth; //!< found parts of command
104 TColStd_SequenceOfAsciiString myArgs; //!< found arguments
105 TColStd_SequenceOfInteger myBegPos; //!< where myRes, myObj, ... begin
106 std::list< Handle(_pyCommand) > myDependentCmds; //!< commands that sould follow me in the script
108 enum { UNKNOWN=-1, EMPTY=0, RESULT_IND, OBJECT_IND, METHOD_IND, ARG1_IND };
109 int GetBegPos( int thePartIndex );
110 void SetBegPos( int thePartIndex, int thePosition );
111 void SetPart( int thePartIndex, const _AString& theNewPart, _AString& theOldPart);
112 void FindAllArgs() { GetArg(1); }
116 _pyCommand( const _AString& theString, int theNb=-1 )
117 : myString( theString ), myOrderNb( theNb ) {};
118 _AString & GetString() { return myString; }
119 int GetOrderNb() const { return myOrderNb; }
120 void SetOrderNb( int theNb ) { myOrderNb = theNb; }
122 TAddr GetAddress() const { return (void*) this; }
123 int Length() { return myString.Length(); }
124 void Clear() { myString.Clear(); myBegPos.Clear(); myArgs.Clear(); }
125 bool IsEmpty() const { return myString.IsEmpty(); }
126 _AString GetIndentation();
127 const _AString & GetResultValue();
128 int GetNbResultValues();
129 _AString GetResultValue(int res);
130 const _AString & GetObject();
131 const _AString & GetMethod();
132 const _AString & GetArg( int index );
133 int GetNbArgs() { FindAllArgs(); return myArgs.Length(); }
135 bool MethodStartsFrom(const _AString& beg)
136 { GetMethod(); return ( myMeth.Location( beg, 1, myMeth.Length() ) == 1 ); }
137 void SetResultValue( const _AString& theResult )
138 { GetResultValue(); SetPart( RESULT_IND, theResult, myRes ); }
139 void SetObject(const _AString& theObject)
140 { GetObject(); SetPart( OBJECT_IND, theObject, myObj ); }
141 void SetMethod(const _AString& theMethod)
142 { GetMethod(); SetPart( METHOD_IND, theMethod, myMeth ); }
143 void SetArg( int index, const _AString& theArg);
146 static bool SkipSpaces( const _AString & theSring, int & thePos );
147 static _AString GetWord( const _AString & theSring, int & theStartPos,
148 const bool theForward, const bool dotIsWord = false);
149 static bool IsStudyEntry( const _AString& str );
150 static bool IsID( const _AString& str );
151 static std::list< _pyID > GetStudyEntries( const _AString& str );
152 void AddDependantCmd( Handle(_pyCommand) cmd, bool prepend = false)
153 { if (prepend) myDependentCmds.push_front( cmd ); else myDependentCmds.push_back( cmd ); }
154 bool SetDependentCmdsAfter() const;
156 bool AddAccessorMethod( _pyID theObjectID, const char* theAcsMethod );
158 DEFINE_STANDARD_RTTI (_pyCommand)
161 // -------------------------------------------------------------------------------------
163 * \brief Root of all objects. It counts calls of Process()
165 // -------------------------------------------------------------------------------------
167 class _pyObject: public Standard_Transient
171 Handle(_pyCommand) myCreationCmd;
172 std::list< Handle(_pyCommand) > myProcessedCmds;
173 std::list< Handle(_pyCommand) > myArgCmds; // where this obj is used as an argument
176 void setID(const _pyID& theID);
178 _pyObject(const Handle(_pyCommand)& theCreationCmd, const _pyID& theID=_pyID());
179 const _pyID& GetID() { return myID.IsEmpty() ? myCreationCmd->GetResultValue() : myID; }
180 static _pyID FatherID(const _pyID & childID);
181 const Handle(_pyCommand)& GetCreationCmd() { return myCreationCmd; }
182 int GetNbCalls() const { return myProcessedCmds.size(); }
183 bool IsInStudy() const { return myIsPublished; }
184 virtual void SetRemovedFromStudy(const bool isRemoved) { myIsPublished = !isRemoved; }
185 void SetCreationCmd( Handle(_pyCommand) cmd ) { myCreationCmd = cmd; }
186 int GetCommandNb() { return myCreationCmd->GetOrderNb(); }
187 void AddProcessedCmd( const Handle(_pyCommand) & cmd )
188 { if (myProcessedCmds.empty() || myProcessedCmds.back()!=cmd) myProcessedCmds.push_back( cmd );}
189 std::list< Handle(_pyCommand) >& GetProcessedCmds() { return myProcessedCmds; }
190 void AddArgCmd( const Handle(_pyCommand) & cmd ) { myArgCmds.push_back( cmd ); }
191 virtual void Process(const Handle(_pyCommand) & cmd) { AddProcessedCmd(cmd); }
192 virtual void Flush() = 0;
193 virtual const char* AccessorMethod() const;
194 virtual bool CanClear();
195 virtual void ClearCommands();
196 virtual void Free() {}
198 DEFINE_STANDARD_RTTI (_pyObject)
201 // -------------------------------------------------------------------------------------
203 * \brief Data used to restore cleared Compute() command of an exported mesh
204 * when an imported mesh is created
206 // -------------------------------------------------------------------------------------
207 struct ExportedMeshData
209 Handle(_pyMesh) myMesh;
210 Handle(_pyCommand) myLastComputeCmd;
211 _AString myLastComputeCmdString;
212 ExportedMeshData() {}
213 ExportedMeshData( const Handle(_pyMesh)& mesh, Handle(_pyCommand) computeCmd):
214 myMesh( mesh ), myLastComputeCmd( computeCmd )
216 if ( !myLastComputeCmd.IsNull())
217 myLastComputeCmdString = myLastComputeCmd->GetString();
221 // -------------------------------------------------------------------------------------
223 * \brief A container of strings groupped by prefix. It is used for a faster search of
224 * objects requiring to KeepAgrCmds() in commands. A speed up is gained because
225 * only a common prefix (e.g. "aArea") of many object IDs is searched in a command
226 * and not every object ID
228 // -------------------------------------------------------------------------------------
229 class _pyStringFamily
232 std::list< _pyStringFamily > _subFams;
233 std::list< _AString > _strings;
234 int isIn( const char* str );
236 bool Add( const char* str );
237 bool IsIn( const _AString& str, _AString& subStr );
238 void Print( int level = 0 );
241 // -------------------------------------------------------------------------------------
243 * \brief Class corresponding to SMESH_Gen. It holds info on existing
244 * meshes and hypotheses
246 // -------------------------------------------------------------------------------------
247 class _pyGen: public _pyObject
250 _pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
251 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
252 std::set< TCollection_AsciiString >& theRemovedObjIDs,
253 SALOMEDS::Study_ptr& theStudy,
254 const bool theToKeepAllCommands);
255 Handle(_pyCommand) AddCommand( const _AString& theCommand );
256 void ExchangeCommands( Handle(_pyCommand) theCmd1, Handle(_pyCommand) theCmd2 );
257 void SetCommandAfter ( Handle(_pyCommand) theCmd, Handle(_pyCommand) theAfterCmd );
258 void SetCommandBefore( Handle(_pyCommand) theCmd, Handle(_pyCommand) theBeforeCmd );
259 Handle(_pyCommand)& GetLastCommand();
260 std::list< Handle(_pyCommand) >& GetCommands() { return myCommands; }
261 void PlaceSubmeshAfterItsCreation( Handle(_pyCommand) theCmdUsingSubmesh ) const;
263 _pyID GenerateNewID( const _pyID& theID );
264 void AddObject( Handle(_pyObject)& theObj );
265 void CheckObjectIsReCreated( Handle(_pyObject)& theObj );
266 void SetProxyObject( const _pyID& theID, Handle(_pyObject)& theObj );
267 Handle(_pyObject) FindObject( const _pyID& theObjID ) const;
268 Handle(_pySubMesh) FindSubMesh( const _pyID& theSubMeshID );
269 Handle(_pyHypothesis) FindHyp( const _pyID& theHypID );
270 Handle(_pyHypothesis) FindAlgo( const _pyID& theGeom, const _pyID& theMesh,
271 const Handle(_pyHypothesis)& theHypothesis);
273 void SetAccessorMethod(const _pyID& theID, const char* theMethod );
274 bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
275 bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
276 virtual const char* AccessorMethod() const;
278 bool IsGeomObject(const _pyID& theObjID) const;
279 bool IsNotPublished(const _pyID& theObjID) const;
280 void ObjectCreationRemoved(const _pyID& theObjID);
281 #ifdef USE_STRING_FAMILY
282 void KeepAgrCmds(const _pyID& theObjID) { myKeepAgrCmdsIDs.Add( theObjID.ToCString() ); }
284 void KeepAgrCmds(const _pyID& theObjID) { myKeepAgrCmdsIDs.push_back( theObjID ); }
286 bool IsToKeepAllCommands() const { return myToKeepAllCommands; }
287 void AddExportedMesh(const _AString& file, const ExportedMeshData& mesh )
288 { myFile2ExportedMesh[ file ] = mesh; }
289 ExportedMeshData& FindExportedMesh( const _AString& file )
290 { return myFile2ExportedMesh[ file ]; }
292 virtual void Process( const Handle(_pyCommand)& theCommand );
293 virtual void Flush();
294 virtual void ClearCommands();
297 Handle( _pyHypothesisReader ) GetHypothesisReader() const;
300 void setNeighbourCommand( Handle(_pyCommand)& theCmd,
301 Handle(_pyCommand)& theOtherCmd,
302 const bool theIsAfter );
303 //void addFilterUser( Handle(_pyCommand)& theCmd, const Handle(_pyObject)& user );
306 std::map< _pyID, Handle(_pyMesh) > myMeshes;
307 std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;
308 std::map< _pyID, Handle(_pyObject) > myObjects;
309 std::map< _pyID, Handle(_pyHypothesis) > myHypos;
310 #ifdef USE_STRING_FAMILY
311 _pyStringFamily myKeepAgrCmdsIDs;
313 std::list< _pyID > myKeepAgrCmdsIDs;
315 std::list< Handle(_pyCommand) > myCommands;
317 Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
318 Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
319 std::set< TCollection_AsciiString >& myRemovedObjIDs;
320 Handle(_pyCommand) myLastCommand;
322 bool myToKeepAllCommands;
323 SALOMEDS::Study_var myStudy;
324 int myGeomIDNb, myGeomIDIndex;
325 std::map< _AString, ExportedMeshData > myFile2ExportedMesh;
326 Handle( _pyHypothesisReader ) myHypReader;
328 DEFINE_STANDARD_RTTI (_pyGen)
331 // -------------------------------------------------------------------------------------
333 * \brief Contains commands concerning mesh substructures
335 // -------------------------------------------------------------------------------------
336 #define _pyMesh_ACCESS_METHOD "GetMesh()"
337 class _pyMesh: public _pyObject
339 std::list< Handle(_pyHypothesis) > myHypos;
340 std::list< Handle(_pyCommand) > myAddHypCmds, myNotConvertedAddHypCmds;
341 std::list< Handle(_pySubMesh) > mySubmeshes;
342 std::list< Handle(_pyGroup) > myGroups;
343 std::list< Handle(_pyMeshEditor)> myEditors;
344 //d::list< Handle(_pyMesh) > myFatherMeshes; // this mesh depends on
345 std::list< Handle(_pyMesh) > myChildMeshes; // depending on me
346 bool myGeomNotInStudy;
347 Handle(_pyCommand) myLastComputeCmd;
349 _pyMesh(const Handle(_pyCommand) creationCmd);
350 _pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID & id);
351 const _pyID& GetGeom() { return GetCreationCmd()->GetArg(1); }
352 void AddGroup( const Handle(_pyGroup)& g ) { myGroups.push_back( g ); }
353 void AddEditor( const Handle(_pyMeshEditor)& e ) { myEditors.push_back( e ); }
354 bool IsNotGeomPublished() { return myGeomNotInStudy; }
355 virtual void Process( const Handle(_pyCommand)& theCommand);
356 virtual void Flush();
357 virtual void SetRemovedFromStudy(const bool isRemoved);
358 virtual bool CanClear();
359 virtual void ClearCommands();
360 virtual void Free() { /*myFatherMeshes.clear();*/ myChildMeshes.clear(); }
361 virtual const char* AccessorMethod() const { return _pyMesh_ACCESS_METHOD; }
363 void addFatherMesh( const Handle(_pyMesh)& mesh );
364 void addFatherMesh( const _pyID& meshID );
365 static bool NeedMeshAccess( const Handle(_pyCommand)& theCommand );
366 static void AddMeshAccess( const Handle(_pyCommand)& theCommand )
367 { theCommand->SetObject( theCommand->GetObject() + "." _pyMesh_ACCESS_METHOD ); }
369 DEFINE_STANDARD_RTTI (_pyMesh)
371 #undef _pyMesh_ACCESS_METHOD
373 // -------------------------------------------------------------------------------------
375 * \brief MeshEditor convert its commands to ones of mesh
377 // -------------------------------------------------------------------------------------
378 class _pyMeshEditor: public _pyObject
381 _AString myCreationCmdStr;
383 _pyMeshEditor(const Handle(_pyCommand)& theCreationCmd);
384 _pyID GetMesh() const { return myMesh; }
385 virtual void Process( const Handle(_pyCommand)& theCommand);
386 virtual void Flush() {}
387 virtual bool CanClear();
389 DEFINE_STANDARD_RTTI (_pyMesh)
392 // -------------------------------------------------------------------------------------
394 * \brief Root class for hypothesis
396 // -------------------------------------------------------------------------------------
397 class _pyHypothesis: public _pyObject
399 friend class _pyHypothesisReader;
401 bool myIsAlgo, myIsWrapped;
402 _pyID myGeom, myMesh;
403 struct CreationMethod {
404 _AString myMethod; // method of algo or mesh creating a hyp
405 // myArgNb(i)-th arg of myArgMethods(i) of hyp becomes an i-th arg of myMethod
406 std::vector<_AString> myArgMethods;
407 std::vector<int> myArgNb; // arg nb countered from 1
408 std::vector<_AString> myArgs; // creation arguments
410 void setCreationArg( const int argNb, const _AString& arg );
411 // a hypothesis can be created by different algos by different methods
412 typedef std::map<_AString, CreationMethod > TType2CrMethod;
413 TType2CrMethod myAlgoType2CreationMethod;
414 std::set< _AString > myAccumulativeMethods;
415 CreationMethod* myCurCrMethod; // used for adding to myAlgoType2CreationMethod
416 std::list<Handle(_pyCommand)> myArgCommands;
417 std::list<Handle(_pyCommand)> myUnusedCommands;
418 std::list<Handle(_pyObject) > myReferredObjs;
419 // maps used to clear commands setting parameters if result of setting is
420 // discared (e.g. by mesh.Clear())
421 std::map<_AString, std::list<Handle(_pyCommand)> > myMeth2Commands;
422 std::map< _pyCommand::TAddr, std::list<Handle(_pyCommand) > > myComputeAddr2Cmds;
423 std::list<Handle(_pyCommand) > myComputeCmds;
424 void rememberCmdOfParameter( const Handle(_pyCommand) & cmd );
425 bool isCmdUsedForCompute( const Handle(_pyCommand) & cmd,
426 _pyCommand::TAddr avoidComputeAddr=NULL ) const;
428 _pyHypothesis(const Handle(_pyCommand)& theCreationCmd);
429 void SetConvMethodAndType(const _AString& creationMethod, const _AString& type)
430 { myCurCrMethod = &myAlgoType2CreationMethod[ type ];
431 myCurCrMethod->myMethod = creationMethod; }
432 void AddArgMethod(const _AString& method, const int argNb = 1)
433 { myCurCrMethod->myArgMethods.push_back( method );
434 myCurCrMethod->myArgNb.push_back( argNb ); }
435 void AddAccumulativeMethod( const _AString& method)
436 { myAccumulativeMethods.insert( method ); }
437 //const TColStd_SequenceOfAsciiString& GetArgs() const { return myArgs; }
438 const std::list<Handle(_pyCommand)>& GetArgCommands() const { return myArgCommands; }
439 void ClearAllCommands();
440 virtual bool IsAlgo() const { return myIsAlgo; }
441 bool IsValid() const { return !myAlgoType2CreationMethod.empty(); }
442 bool IsWrapped() const { return myIsWrapped; }
443 const _pyID & GetGeom() const { return myGeom; }
444 void SetMesh( const _pyID& theMeshId) { if ( myMesh.IsEmpty() ) myMesh = theMeshId; }
445 const _pyID & GetMesh() const { return myMesh; }
446 const _AString& GetAlgoType() const
447 { return myAlgoType2CreationMethod.begin()->first; }
448 const _AString& GetAlgoCreationMethod() const
449 { return myAlgoType2CreationMethod.begin()->second.myMethod; }
450 bool CanBeCreatedBy(const _AString& algoType ) const
451 { return myAlgoType2CreationMethod.find( algoType ) != myAlgoType2CreationMethod.end(); }
452 const _AString& GetCreationMethod(const _AString& algoType)
453 { return ( myCurCrMethod = & myAlgoType2CreationMethod[ algoType ])->myMethod; }
454 static Handle(_pyHypothesis) NewHypothesis( const Handle(_pyCommand)& theCreationCmd);
456 virtual bool IsWrappable(const _pyID& theMesh) const;
457 virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
458 const _pyID& theMesh);
459 virtual void Process( const Handle(_pyCommand)& theCommand);
460 virtual void Flush();
461 virtual void Free() { myReferredObjs.clear(); }
462 virtual void Assign( const Handle(_pyHypothesis)& theOther,
463 const _pyID& theMesh );
464 virtual bool CanClear();
465 virtual void ClearCommands();
466 virtual bool GetReferredMeshesAndGeom( std::list< Handle(_pyMesh) >& meshes );
468 void MeshComputed ( const Handle(_pyCommand)& theComputeCommand );
469 void ComputeDiscarded( const Handle(_pyCommand)& theComputeCommand );
470 //void ComputeSaved ( const Handle(_pyCommand)& theComputeCommand );
473 DEFINE_STANDARD_RTTI (_pyHypothesis)
476 // -------------------------------------------------------------------------------------
478 * \brief Class representing smesh.Mesh_Algorithm
480 // -------------------------------------------------------------------------------------
481 class _pyAlgorithm: public _pyHypothesis
484 _pyAlgorithm(const Handle(_pyCommand)& theCreationCmd);
485 virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
486 const _pyID& theMesh);
487 virtual const char* AccessorMethod() const { return "GetAlgorithm()"; }
488 virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped; }
490 DEFINE_STANDARD_RTTI (_pyAlgorithm)
493 // -------------------------------------------------------------------------------------
495 * \brief Class for hypotheses having several parameters modified by one method
497 // -------------------------------------------------------------------------------------
498 class _pyComplexParamHypo: public _pyHypothesis
501 _pyComplexParamHypo(const Handle(_pyCommand)& theCreationCmd): _pyHypothesis(theCreationCmd) {}
502 virtual void Process( const Handle(_pyCommand)& theCommand);
503 virtual void Flush();
505 DEFINE_STANDARD_RTTI (_pyComplexParamHypo)
507 DEFINE_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis);
509 // -------------------------------------------------------------------------------------
511 * \brief Class for LayerDistribution hypothesis conversion
513 // -------------------------------------------------------------------------------------
514 class _pyLayerDistributionHypo: public _pyHypothesis
516 Handle(_pyHypothesis) my1dHyp;
517 _AString myAlgoMethod;
519 _pyLayerDistributionHypo(const Handle(_pyCommand)& theCreationCmd, const char* algoMethod):
520 _pyHypothesis(theCreationCmd), myAlgoMethod((char*)algoMethod) {}
521 virtual void Process( const Handle(_pyCommand)& theCommand);
522 virtual void Flush();
523 virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
524 const _pyID& theMesh);
525 virtual void Free() { my1dHyp.Nullify(); }
527 DEFINE_STANDARD_RTTI (_pyLayerDistributionHypo)
529 DEFINE_STANDARD_HANDLE (_pyLayerDistributionHypo, _pyHypothesis);
531 // -------------------------------------------------------------------------------------
533 * \brief Class representing NumberOfSegments hypothesis
535 // -------------------------------------------------------------------------------------
536 class _pyNumberOfSegmentsHyp: public _pyHypothesis
539 _pyNumberOfSegmentsHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
540 virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
541 const _pyID& theMesh);
544 DEFINE_STANDARD_RTTI (_pyNumberOfSegmentsHyp)
546 DEFINE_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis);
548 // -------------------------------------------------------------------------------------
550 * \brief Class representing SegmentLengthAroundVertex hypothesis
552 // -------------------------------------------------------------------------------------
553 class _pySegmentLengthAroundVertexHyp: public _pyHypothesis
556 _pySegmentLengthAroundVertexHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
557 virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
558 const _pyID& theMesh);
559 DEFINE_STANDARD_RTTI (_pySegmentLengthAroundVertexHyp)
561 DEFINE_STANDARD_HANDLE (_pySegmentLengthAroundVertexHyp, _pyHypothesis);
563 // -------------------------------------------------------------------------------------
565 * \brief SelfEraser erases creation command if no more it's commands invoked
567 // -------------------------------------------------------------------------------------
568 class _pySelfEraser: public _pyObject
570 bool myIgnoreOwnCalls; // not to erase only if this obj is used as argument
572 _pySelfEraser(const Handle(_pyCommand)& theCreationCmd);
573 void IgnoreOwnCalls() { myIgnoreOwnCalls = true; }
574 virtual void Flush();
576 DEFINE_STANDARD_RTTI (_pySelfEraser)
578 DEFINE_STANDARD_HANDLE (_pySelfEraser, _pyObject);
580 // -------------------------------------------------------------------------------------
582 * \brief SubMesh creation can be moved to the end of engine commands
584 // -------------------------------------------------------------------------------------
585 class _pySubMesh: public _pyObject
587 Handle(_pyObject) myCreator;
588 Handle(_pyMesh) myMesh;
590 _pySubMesh(const Handle(_pyCommand)& theCreationCmd, bool toKeepAgrCmds=true);
591 virtual void Process( const Handle(_pyCommand)& theCommand);
592 virtual void Flush();
593 virtual Handle(_pyMesh) GetMesh() { return myMesh; }
594 virtual void Free() { myCreator.Nullify(); myMesh.Nullify(); }
595 void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
596 static bool CanBeArgOfMethod(const _AString& theMethodName);
598 DEFINE_STANDARD_RTTI (_pySubMesh)
600 // -------------------------------------------------------------------------------------
602 * \brief A filter sets a human readable name to self
604 // -------------------------------------------------------------------------------------
605 class _pyFilter: public _pyObject
607 _pyID myNewID, myMesh;
608 //std::list< Handle(_pyObject) > myUsers;
610 _pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID="");
611 //void AddUser( const Handle(_pyObject)& user) { myUsers.push_back( user ); }
612 virtual void Process( const Handle(_pyCommand)& theCommand);
613 virtual void Flush();
614 //virtual bool CanClear();
615 //virtual void Free() { myUsers.clear(); }
616 const _pyID& GetNewID() const { return myNewID; }
618 DEFINE_STANDARD_RTTI (_pyFilter)
620 DEFINE_STANDARD_HANDLE (_pyFilter, _pyObject);
622 // -------------------------------------------------------------------------------------
624 * \brief To convert creation of a group by filter
626 // -------------------------------------------------------------------------------------
627 class _pyGroup: public _pySubMesh // use myMesh of _pySubMesh
629 Handle(_pyFilter) myFilter;
630 bool myCanClearCreationCmd;
632 _pyGroup(const Handle(_pyCommand)& theCreationCmd, const _pyID & id=_pyID());
633 virtual void Process( const Handle(_pyCommand)& theCommand);
634 virtual void Flush();
635 virtual void Free() { myFilter.Nullify(); }
636 virtual bool CanClear();
637 void RemovedWithContents();
639 DEFINE_STANDARD_RTTI (_pyGroup)
642 // -------------------------------------------------------------------------------------
644 * \brief Class reading _pyHypothesis'es from resource files of mesher Plugins
646 // -------------------------------------------------------------------------------------
647 class _pyHypothesisReader: public Standard_Transient
649 std::map<_AString, Handle(_pyHypothesis)> myType2Hyp;
651 _pyHypothesisReader();
652 Handle(_pyHypothesis) GetHypothesis(const _AString& hypType,
653 const Handle(_pyCommand)& creationCmd) const;
654 DEFINE_STANDARD_RTTI (_pyHypothesisReader)