1 // Copyright (C) 2007-2008 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 #pragma warning( disable:4786 )
26 #include "GEOM_Engine.hxx"
28 #include "GEOM_Solver.hxx"
29 #include "GEOM_Function.hxx"
30 #include "GEOM_ISubShape.hxx"
31 #include "GEOM_SubShapeDriver.hxx"
32 #include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
33 #include "GEOM_PythonDump.hxx"
35 #include "utilities.h"
37 #include <TDF_Tool.hxx>
38 #include <TDF_Data.hxx>
39 #include <TDF_LabelSequence.hxx>
40 #include <TDataStd_Integer.hxx>
41 #include <TDataStd_ChildNodeIterator.hxx>
42 #include <TFunction_Driver.hxx>
43 #include <TFunction_DriverTable.hxx>
46 #include <TopTools_IndexedMapOfShape.hxx>
48 #include <TCollection_AsciiString.hxx>
49 #include <TCollection_ExtendedString.hxx>
50 #include <TColStd_SequenceOfAsciiString.hxx>
51 #include <TColStd_MapOfTransient.hxx>
52 #include <TColStd_HSequenceOfInteger.hxx>
54 #include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
55 #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
60 #include <Standard_Failure.hxx>
61 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
63 static GEOM_Engine* TheEngine = NULL;
65 static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject)
67 TCollection_AsciiString anID(theObject->GetDocID()), anEntry;
68 TDF_Tool::Entry(theObject->GetEntry(), anEntry);
69 anID+=(TCollection_AsciiString("_")+anEntry);
73 static TCollection_AsciiString BuildID(Standard_Integer theDocID, char* theEntry)
75 TCollection_AsciiString anID(theDocID);
76 anID+=(TCollection_AsciiString("_")+theEntry);
80 static Standard_Integer ExtractDocID(TCollection_AsciiString& theID)
82 TCollection_AsciiString aDocID = theID.Token("_");
83 if(aDocID.Length() < 1) return -1;
84 return aDocID.IntegerValue();
87 void ProcessFunction(Handle(GEOM_Function)& theFunction,
88 TCollection_AsciiString& theScript,
89 TColStd_MapOfTransient& theProcessed);
91 Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString);
93 //=============================================================================
97 //=============================================================================
98 GEOM_Engine* GEOM_Engine::GetEngine() { return TheEngine; }
101 //=============================================================================
105 //=============================================================================
106 void GEOM_Engine::SetEngine(GEOM_Engine* theEngine) { TheEngine = theEngine; }
108 //=============================================================================
112 //=============================================================================
113 GEOM_Engine::GEOM_Engine()
115 TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver());
117 _OCAFApp = new GEOM_Application();
124 GEOM_Engine::~GEOM_Engine()
126 GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient It(_objects);
127 for(; It.More(); It.Next())
129 RemoveObject(Handle(GEOM_Object)::DownCast(It.Value()));
132 //Close all documents not closed
133 for(Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr(_mapIDDocument); anItr.More(); anItr.Next())
136 _mapIDDocument.Clear();
140 //=============================================================================
144 //=============================================================================
145 Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID)
147 Handle(TDocStd_Document) aDoc;
148 if(!_mapIDDocument.IsBound(theDocID)) {
149 _OCAFApp->NewDocument("SALOME_GEOM", aDoc);
150 aDoc->SetUndoLimit(_UndoLimit);
151 _mapIDDocument.Bind(theDocID, aDoc);
152 TDataStd_Integer::Set(aDoc->Main(), theDocID);
155 return Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
158 //=============================================================================
162 //=============================================================================
163 int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument)
165 if(theDocument.IsNull()) return -1;
166 for(Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr(_mapIDDocument); anItr.More(); anItr.Next())
167 if(anItr.Value() == theDocument) return anItr.Key();
173 //=============================================================================
177 //=============================================================================
178 Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry)
180 TCollection_AsciiString anID = BuildID(theDocID, theEntry);
181 if(_objects.IsBound(anID)) return Handle(GEOM_Object)::DownCast(_objects(anID));
184 Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
185 TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True);
186 Handle(GEOM_Object) anObject = new GEOM_Object(aLabel);
188 _objects.Bind(anID, anObject);
193 //=============================================================================
197 //=============================================================================
198 Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
200 Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
201 Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
203 // NPAL18604: use existing label to decrease memory usage,
204 // if this label has been freed (object deleted)
205 bool useExisting = false;
207 if (!_lastCleared.IsNull()) {
208 if (_lastCleared.Root() == aDoc->Main().Root()) {
210 aChild = _lastCleared;
211 _lastCleared.Nullify();
216 aChild = TDF_TagSource::NewChild(aDoc->Main());
219 Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType);
221 //Put an object in the map of created objects
222 TCollection_AsciiString anID = BuildIDFromObject(anObject);
223 if(_objects.IsBound(anID)) _objects.UnBind(anID);
224 _objects.Bind(anID, anObject);
229 //=============================================================================
233 //=============================================================================
234 Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
235 Handle(TColStd_HArray1OfInteger) theIndices,
236 bool isStandaloneOperation)
238 if(theMainShape.IsNull() || theIndices.IsNull()) return NULL;
240 Handle(TDocStd_Document) aDoc = GetDocument(theMainShape->GetDocID());
241 Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
243 // NPAL18604: use existing label to decrease memory usage,
244 // if this label has been freed (object deleted)
245 bool useExisting = false;
247 if (!_lastCleared.IsNull()) {
248 if (_lastCleared.Root() == aDoc->Main().Root()) {
250 aChild = _lastCleared;
251 _lastCleared.Nullify();
256 aChild = TDF_TagSource::NewChild(aDoc->Main());
259 Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction();
260 Handle(GEOM_Object) anObject = new GEOM_Object(aChild, 28); //28 is SUBSHAPE type
261 Handle(GEOM_Function) aFunction = anObject->AddFunction(GEOM_Object::GetSubShapeID(), 1);
263 GEOM_ISubShape aSSI(aFunction);
264 aSSI.SetMainShape(aMainShape);
265 aSSI.SetIndices(theIndices);
268 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
271 GEOM_Solver aSolver (GEOM_Engine::GetEngine());
272 if (!aSolver.ComputeFunction(aFunction)) {
273 MESSAGE("GEOM_Engine::AddSubShape Error: Can't build a sub shape");
277 catch (Standard_Failure) {
278 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
279 MESSAGE("GEOM_Engine::AddSubShape Error: " << aFail->GetMessageString());
283 //Put an object in the map of created objects
284 TCollection_AsciiString anID = BuildIDFromObject(anObject);
285 if(_objects.IsBound(anID)) _objects.UnBind(anID);
286 _objects.Bind(anID, anObject);
288 GEOM::TPythonDump pd (aFunction);
290 if (isStandaloneOperation) {
291 pd << anObject << " = geompy.GetSubShape(" << theMainShape << ", [";
292 Standard_Integer i = theIndices->Lower(), up = theIndices->Upper();
293 for (; i <= up - 1; i++) {
294 pd << theIndices->Value(i) << ", ";
296 pd << theIndices->Value(up) << "])";
304 //=============================================================================
308 //=============================================================================
309 bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
311 if (!theObject) return false;
313 //Remove an object from the map of available objects
314 TCollection_AsciiString anID = BuildIDFromObject(theObject);
315 if (_objects.IsBound(anID)) _objects.UnBind(anID);
317 int nb = theObject->GetNbFunctions();
318 Handle(TDataStd_TreeNode) aNode;
319 for (int i = 1; i<=nb; i++) {
320 Handle(GEOM_Function) aFunction = theObject->GetFunction(i);
321 if (aFunction->GetEntry().FindAttribute(GEOM_Function::GetFunctionTreeID(), aNode))
325 TDF_Label aLabel = theObject->GetEntry();
326 aLabel.ForgetAllAttributes(Standard_True);
327 _lastCleared = aLabel;
334 //=============================================================================
338 //=============================================================================
339 void GEOM_Engine::Undo(int theDocID)
341 GetDocument(theDocID)->Undo();
344 //=============================================================================
348 //=============================================================================
349 void GEOM_Engine::Redo(int theDocID)
351 GetDocument(theDocID)->Redo();
354 //=============================================================================
358 //=============================================================================
359 bool GEOM_Engine::Save(int theDocID, char* theFileName)
361 if(!_mapIDDocument.IsBound(theDocID)) return false;
362 Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
364 _OCAFApp->SaveAs(aDoc, theFileName);
369 //=============================================================================
373 //=============================================================================
374 bool GEOM_Engine::Load(int theDocID, char* theFileName)
376 Handle(TDocStd_Document) aDoc;
377 if(_OCAFApp->Open(theFileName, aDoc) != CDF_RS_OK) {
381 aDoc->SetUndoLimit(_UndoLimit);
383 if(_mapIDDocument.IsBound(theDocID)) _mapIDDocument.UnBind(theDocID);
384 _mapIDDocument.Bind(theDocID, aDoc);
386 TDataStd_Integer::Set(aDoc->Main(), theDocID);
391 //=============================================================================
395 //=============================================================================
396 void GEOM_Engine::Close(int theDocID)
398 if (_mapIDDocument.IsBound(theDocID)) {
399 Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
401 //Remove all GEOM Objects associated to the given document
402 TColStd_SequenceOfAsciiString aSeq;
403 GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient It (_objects);
404 for (; It.More(); It.Next()) {
405 TCollection_AsciiString anObjID (It.Key());
406 Standard_Integer anID = ExtractDocID(anObjID);
407 if (theDocID == anID) aSeq.Append(It.Key());
409 for (Standard_Integer i=1; i<=aSeq.Length(); i++) _objects.UnBind(aSeq.Value(i));
411 _lastCleared.Nullify();
413 _mapIDDocument.UnBind(theDocID);
414 _OCAFApp->Close(aDoc);
419 //=============================================================================
423 //=============================================================================
424 TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
425 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
429 TCollection_AsciiString aScript;
430 Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
432 if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
434 aScript = "import geompy\n";
435 aScript += "import math\n";
436 aScript += "import SALOMEDS\n\n";
437 aScript += "def RebuildData(theStudy):";
438 aScript += "\n\tgeompy.init_geom(theStudy)";
440 Standard_Integer posToInsertGlobalVars = aScript.Length() + 1;
442 Handle(TDataStd_TreeNode) aNode, aRoot;
443 Handle(GEOM_Function) aFunction;
444 TColStd_MapOfTransient aMap;
446 if(aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
447 TDataStd_ChildNodeIterator Itr(aRoot);
448 for(; Itr.More(); Itr.Next()) {
450 aFunction = GEOM_Function::GetFunction(aNode->Label());
451 if(aFunction.IsNull()) {
452 MESSAGE ( "Null function !!!!" );
455 ProcessFunction(aFunction, aScript, aMap);
459 Resource_DataMapOfAsciiStringAsciiString aEntry2StEntry, aStEntry2Entry;
460 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString anEntryToNameIt;
461 // build maps entry <-> studyEntry
462 for (anEntryToNameIt.Initialize( theObjectNames );
463 anEntryToNameIt.More();
464 anEntryToNameIt.Next())
466 const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
467 // look for an object by entry
469 TDF_Tool::Label( aDoc->GetData(), aEntry, L );
470 if ( L.IsNull() ) continue;
471 Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
473 if ( !obj.IsNull() ) {
474 TCollection_AsciiString aStudyEntry (obj->GetAuxData());
475 aEntry2StEntry.Bind( aEntry, aStudyEntry);
476 aStEntry2Entry.Bind( aStudyEntry, aEntry );
480 Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
481 Standard_Integer aLen = aSeq->Length(), objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
482 Resource_DataMapOfAsciiStringAsciiString aNameToEntry, anEntryToBadName;
484 //Replace entries by the names
485 TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"),
486 allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
487 if(aLen == 0) anUpdatedScript = aScript;
489 for(Standard_Integer i = 1; i <= aLen; i+=2) {
490 anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i)-1);
491 anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i+1));
492 if(theObjectNames.IsBound(anEntry)) {
493 aName = theObjectNames.Find(anEntry);
494 // check validity of aName
495 bool isValidName = true;
496 if ( aName.IsIntegerValue() ) { // aName must not start with a digit
497 aName.Insert( 1, 'a' );
500 int p, p2=1; // replace not allowed chars
501 while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) {
502 aName.SetValue(p, '_');
506 if ( aNameToEntry.IsBound( aName ) && anEntry != aNameToEntry( aName ))
507 { // diff objects have same name - make a new name by appending a digit
508 TCollection_AsciiString aName2;
509 Standard_Integer i = 0;
511 aName2 = aName + "_" + ++i;
512 } while ( aNameToEntry.IsBound( aName2 ) && anEntry != aNameToEntry( aName2 ));
516 if ( !isValidName ) {
518 anEntryToBadName.Bind( anEntry, theObjectNames.Find(anEntry) );
519 theObjectNames( anEntry ) = aName;
524 aName = aBaseName + TCollection_AsciiString(++objectCounter);
525 } while(aNameToEntry.IsBound(aName));
526 theObjectNames.Bind(anEntry, aName);
528 aNameToEntry.Bind(aName, anEntry); // to detect same name of diff objects
530 anUpdatedScript += aName;
531 aStart = aSeq->Value(i+1) + 1;
534 //Add final part of the script
535 if (aLen && aSeq->Value(aLen) < aScriptLength)
536 anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
539 for (anEntryToNameIt.Initialize( theObjectNames );
540 anEntryToNameIt.More();
541 anEntryToNameIt.Next())
543 const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
544 const TCollection_AsciiString& aName = anEntryToNameIt.Value();
547 TDF_Tool::Label( aDoc->GetData(), aEntry, L );
551 Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
555 bool anAutoColor = obj->GetAutoColor();
558 TCollection_AsciiString aCommand( "\n\t" );
559 aCommand += aName + ".SetAutoColor(1)";
560 anUpdatedScript += aCommand.ToCString();
563 SALOMEDS::Color aColor = obj->GetColor();
564 if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 )
566 TCollection_AsciiString aCommand( "\n\t" );
567 aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))";
568 anUpdatedScript += aCommand.ToCString();
572 // Make script to publish in study
575 std::map< int, std::string > anEntryToCommandMap; // sort publishing commands by object entry
576 for (anEntryToNameIt.Initialize( theObjectNames );
577 anEntryToNameIt.More();
578 anEntryToNameIt.Next())
580 const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
581 const TCollection_AsciiString& aName = anEntryToNameIt.Value();
582 if ( !aEntry2StEntry.IsBound( aEntry ))
583 continue; // was not published
584 TCollection_AsciiString aCommand("\n\tgeompy."), aFatherEntry;
586 // find a father entry
587 const TCollection_AsciiString& aStudyEntry = aEntry2StEntry( aEntry );
588 TCollection_AsciiString aFatherStudyEntry =
589 aStudyEntry.SubString( 1, aStudyEntry.SearchFromEnd(":") - 1 );
590 if ( aStEntry2Entry.IsBound( aFatherStudyEntry ))
591 aFatherEntry = aStEntry2Entry( aFatherStudyEntry );
594 if ( !aFatherEntry.IsEmpty() && theObjectNames.IsBound( aFatherEntry )) {
595 aCommand += "addToStudyInFather( ";
596 aCommand += theObjectNames( aFatherEntry ) + ", ";
599 aCommand += "addToStudy( ";
600 if ( anEntryToBadName.IsBound( aEntry ))
601 aCommand += aName + ", \"" + anEntryToBadName( aEntry ) + "\" )";
603 aCommand += aName + ", \"" + aName + "\" )";
605 // bind a command to the last digit of the entry
607 aEntry.SubString( aEntry.SearchFromEnd(":")+1, aEntry.Length() ).IntegerValue();
608 anEntryToCommandMap.insert( std::make_pair( tag, aCommand.ToCString() ));
611 // add publishing commands to the script
612 std::map< int, std::string >::iterator anEntryToCommand = anEntryToCommandMap.begin();
613 for ( ; anEntryToCommand != anEntryToCommandMap.end(); ++anEntryToCommand ) {
614 anUpdatedScript += (char*)anEntryToCommand->second.c_str();
618 anUpdatedScript += "\n\tpass\n";
621 // fill _studyEntry2NameMap and build globalVars
622 TCollection_AsciiString globalVars;
623 _studyEntry2NameMap.Clear();
624 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString aStEntryToEntryIt;
625 for (aStEntryToEntryIt.Initialize( aStEntry2Entry );
626 aStEntryToEntryIt.More();
627 aStEntryToEntryIt.Next() )
629 const TCollection_AsciiString & name = theObjectNames( aStEntryToEntryIt.Value() );
630 _studyEntry2NameMap.Bind (aStEntryToEntryIt.Key(), name );
631 if ( !globalVars.IsEmpty() )
635 if ( !globalVars.IsEmpty() ) {
636 globalVars.Insert( 1, "\n\tglobal " );
637 anUpdatedScript.Insert( posToInsertGlobalVars, globalVars );
640 return anUpdatedScript;
643 //=======================================================================
644 //function : GetDumpName
646 //=======================================================================
648 const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
650 if ( _studyEntry2NameMap.IsBound( (char*)theStudyEntry ))
651 return _studyEntry2NameMap( (char*)theStudyEntry ).ToCString();
656 //=======================================================================
657 //function : GetAllDumpNames
659 //=======================================================================
661 Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const
663 Handle(TColStd_HSequenceOfAsciiString) aRetSeq = new TColStd_HSequenceOfAsciiString;
665 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString it (_studyEntry2NameMap);
666 for (; it.More(); it.Next()) {
667 aRetSeq->Append(it.Value());
674 //===========================================================================
675 // Internal functions
676 //===========================================================================
677 void ProcessFunction(Handle(GEOM_Function)& theFunction,
678 TCollection_AsciiString& theScript,
679 TColStd_MapOfTransient& theProcessed)
681 if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
684 TDF_LabelSequence aSeq;
685 theFunction->GetDependency(aSeq);
686 Standard_Integer aLen = aSeq.Length();
687 for(Standard_Integer i = 1; i <= aLen; i++) {
688 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aSeq.Value(i));
689 if(aFunction.IsNull()) continue;
690 ProcessFunction(aFunction, theScript, theProcessed);
694 // pass functions, that depends on nonexisting ones
695 //jfa:test//bool doComment = false;
696 TDF_LabelSequence aSeq;
697 theFunction->GetDependency(aSeq);
698 Standard_Integer aLen = aSeq.Length();
699 //jfa:test//for (Standard_Integer i = 1; i <= aLen && !doComment; i++) {
700 for (Standard_Integer i = 1; i <= aLen; i++) {
701 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aSeq.Value(i));
702 //jfa:test//if (aFunction.IsNull()) doComment = true;
703 //jfa:test//else if (!theProcessed.Contains(aFunction)) doComment = true;
704 if (aFunction.IsNull()) return;
705 if (!theProcessed.Contains(aFunction)) return;
708 TCollection_AsciiString aDescr = theFunction->GetDescription();
709 if(aDescr.Length() == 0) {
710 //cout << "Warning: the function has no description" << endl;
714 //Check if its internal function which doesn't requires dumping
715 if(aDescr == "None") return;
718 //jfa:test//if (doComment) theScript += "#";
721 theProcessed.Add(theFunction);
724 //=============================================================================
726 * FindEntries: Returns a sequence of start/end positions of entries in the string
728 //=============================================================================
729 Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString)
731 Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
732 Standard_Integer aLen = theString.Length();
733 Standard_Boolean isFound = Standard_False;
735 const char* arr = theString.ToCString();
736 Standard_Integer i = 0, j;
741 if(c >= 48 && c <= 57) { //Is digit?
743 isFound = Standard_False;
744 while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
746 if(c == 58) isFound = Standard_True;
749 if(isFound && arr[j-2] != 58) { // last char should be a diggit
750 aSeq->Append(i+1); // +1 because AsciiString starts from 1