1 // Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESH_NoteBook.cxx
21 // Author : Roman NIKOLAEV
23 #include "SMESH_2smeshpy.hxx"
24 #include "SMESH_NoteBook.hxx"
25 #include "SMESH_Gen_i.hxx"
26 #include "SMESH_PythonDump.hxx"
28 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
29 #include <TColStd_SequenceOfAsciiString.hxx>
30 #include <TColStd_HSequenceOfInteger.hxx>
36 static int MYDEBUG = 0;
38 static int MYDEBUG = 0;
45 //================================================================================
49 //================================================================================
50 ObjectStates::ObjectStates(TCollection_AsciiString theType)
56 //================================================================================
60 //================================================================================
61 ObjectStates::~ObjectStates()
65 //================================================================================
67 * \brief Add new object state
68 * \param theState - Object state (vector of notebook variable)
70 //================================================================================
71 void ObjectStates::AddState(const TState &theState)
73 _states.push_back(theState);
76 //================================================================================
78 * \brief Return current object state
79 * \\retval state - Object state (vector of notebook variable)
81 //================================================================================
82 TState ObjectStates::GetCurrectState() const
84 if(_states.size() > _dumpstate)
85 return _states[_dumpstate];
91 //================================================================================
95 //================================================================================
96 TAllStates ObjectStates::GetAllStates() const
101 //================================================================================
105 //================================================================================
106 void ObjectStates::IncrementState()
111 //================================================================================
115 //================================================================================
116 TCollection_AsciiString ObjectStates::GetObjectType() const{
121 //================================================================================
125 //================================================================================
126 LayerDistributionStates::LayerDistributionStates():
127 ObjectStates("LayerDistribution")
130 //================================================================================
134 //================================================================================
135 LayerDistributionStates::~LayerDistributionStates()
140 //================================================================================
142 * \brief AddDistribution
144 //================================================================================
145 void LayerDistributionStates::AddDistribution(const TCollection_AsciiString& theDistribution)
147 _distributions.insert(pair<TCollection_AsciiString,TCollection_AsciiString>(theDistribution,""));
150 //================================================================================
152 * \brief HasDistribution
154 //================================================================================
155 bool LayerDistributionStates::HasDistribution(const TCollection_AsciiString& theDistribution) const
157 return _distributions.find(theDistribution) != _distributions.end();
160 //================================================================================
162 * \brief SetDistributionType
164 //================================================================================
165 bool LayerDistributionStates::SetDistributionType(const TCollection_AsciiString& theDistribution,
166 const TCollection_AsciiString& theType)
168 TDistributionMap::iterator it = _distributions.find(theDistribution);
169 if(it == _distributions.end())
171 (*it).second = theType;
175 //================================================================================
177 * \brief GetDistributionType
179 //================================================================================
180 TCollection_AsciiString LayerDistributionStates::
181 GetDistributionType(const TCollection_AsciiString& theDistribution) const
183 TDistributionMap::const_iterator it = _distributions.find(theDistribution);
184 return (it == _distributions.end()) ? TCollection_AsciiString() : (*it).second;
187 //================================================================================
191 //================================================================================
192 SMESH_NoteBook::SMESH_NoteBook()
197 //================================================================================
201 //================================================================================
202 SMESH_NoteBook::~SMESH_NoteBook()
204 TVariablesMap::const_iterator it = _objectMap.begin();
205 for(;it!=_objectMap.end();it++) {
211 //================================================================================
213 * \brief Replace parameters of the functions on the Salome NoteBook Variables
214 * \param theString - Input string
215 * \retval TCollection_AsciiString - Convertion result
217 //================================================================================
218 void SMESH_NoteBook::ReplaceVariables()
220 for(int i=0;i<_commands.size();i++) {
221 Handle(_pyCommand) aCmd = _commands[i];
222 TCollection_AsciiString aMethod = aCmd->GetMethod();
223 TCollection_AsciiString aObject = aCmd->GetObject();
224 TCollection_AsciiString aResultValue = aCmd->GetResultValue();
226 cout<<"Command before : "<< aCmd->GetString()<<endl;
227 cout<<"Method : "<< aMethod<<endl;
228 cout<<"Object : "<< aObject<<endl;
229 cout<<"Result : "<< aResultValue<<endl;
232 // check if method modifies the object itself
233 TVariablesMap::const_iterator it = _objectMap.find(aObject);
234 if(it == _objectMap.end()) // check if method returns a new object
235 it = _objectMap.find(aResultValue);
237 if(it == _objectMap.end()) { // check if method modifies a mesh using mesh editor
238 TMeshEditorMap::const_iterator meIt = myMeshEditors.find(aObject);
239 if(meIt != myMeshEditors.end()) {
240 TCollection_AsciiString aMesh = (*meIt).second;
241 it = _objectMap.find(aMesh);
245 if(it != _objectMap.end()) {
246 ObjectStates *aStates = (*it).second;
247 // Case for LocalLength hypothesis
248 if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
249 if(aMethod.IsEqual("SetLength")) {
250 if(!aStates->GetCurrectState().at(0).IsEmpty() )
251 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
252 aStates->IncrementState();
254 else if(aMethod.IsEqual("SetPrecision")) {
255 if(!aStates->GetCurrectState().at(1).IsEmpty() )
256 aCmd->SetArg(1,aStates->GetCurrectState().at(1));
257 aStates->IncrementState();
261 // Case for SegmentLengthAroundVertex hypothesis
262 else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")
263 && aStates->GetCurrectState().size() >= 1) {
264 if(aMethod == "SetLength") {
265 if(!aStates->GetCurrectState().at(0).IsEmpty() )
266 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
267 aStates->IncrementState();
271 // Case for Arithmetic1D and StartEndLength hypothesis
272 else if(aStates->GetObjectType().IsEqual("Arithmetic1D") ||
273 aStates->GetObjectType().IsEqual("StartEndLength")) {
274 if(aMethod == "SetLength" &&
275 aStates->GetCurrectState().size() >= 2) {
276 if(aCmd->GetArg(2) == "1" && !aStates->GetCurrectState().at(0).IsEmpty())
277 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
278 else if(!aStates->GetCurrectState().at(1).IsEmpty())
279 aCmd->SetArg(1,aStates->GetCurrectState().at(1));
280 aStates->IncrementState();
284 //Case for Deflection1D hypothesis
285 else if(aStates->GetObjectType().IsEqual("Deflection1D")){
286 if(aMethod == "SetDeflection" && aStates->GetCurrectState().size() >= 1) {
287 if(!aStates->GetCurrectState().at(0).IsEmpty() )
288 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
289 aStates->IncrementState();
293 // Case for LayerDistribution hypothesis (not finished yet)
294 else if(aStates->GetObjectType() == "LayerDistribution") {
295 if(aMethod == "SetLayerDistribution"){
296 LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
297 aLDStates->AddDistribution(aCmd->GetArg(1));
301 // Case for MaxElementArea hypothesis
302 else if(aStates->GetObjectType().IsEqual("MaxElementArea")){
303 if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 1) {
304 if(!aStates->GetCurrectState().at(0).IsEmpty() )
305 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
306 aStates->IncrementState();
310 // Case for MaxElementVolume hypothesis
311 else if(aStates->GetObjectType().IsEqual("MaxElementVolume")){
312 if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 1) {
313 if(!aStates->GetCurrectState().at(0).IsEmpty() )
314 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
315 aStates->IncrementState();
319 // Case for NETGEN_Parameters_2D or NETGEN_Parameters_2D hypothesis
320 else if(aStates->GetObjectType().IsEqual("NETGEN_Parameters_2D") ||
321 aStates->GetObjectType().IsEqual("NETGEN_Parameters")){
322 if(aMethod == "SetMaxSize" && aStates->GetCurrectState().size() >= 1) {
323 if(!aStates->GetCurrectState().at(0).IsEmpty() )
324 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
325 aStates->IncrementState();
327 else if(aMethod == "SetGrowthRate" && aStates->GetCurrectState().size() >= 2) {
328 if(!aStates->GetCurrectState().at(1).IsEmpty() )
329 aCmd->SetArg(1,aStates->GetCurrectState().at(1));
330 aStates->IncrementState();
332 else if(aMethod == "SetNbSegPerEdge" && aStates->GetCurrectState().size() >= 3) {
333 if(!aStates->GetCurrectState().at(2).IsEmpty() )
334 aCmd->SetArg(1,aStates->GetCurrectState().at(2));
335 aStates->IncrementState();
337 else if(aMethod == "SetNbSegPerRadius" && aStates->GetCurrectState().size() >= 4) {
338 if(!aStates->GetCurrectState().at(3).IsEmpty() )
339 aCmd->SetArg(1,aStates->GetCurrectState().at(3));
340 aStates->IncrementState();
344 // Case for NETGEN_SimpleParameters_3D or NETGEN_SimpleParameters_2D hypothesis
345 else if(aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_3D") ||
346 aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_2D")){
348 if((aMethod == "SetNumberOfSegments" || aMethod == "LocalLength") &&
349 aStates->GetCurrectState().size() >= 1) {
350 if(!aStates->GetCurrectState().at(0).IsEmpty() )
351 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
352 aStates->IncrementState();
354 else if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 2) {
355 if(!aStates->GetCurrectState().at(1).IsEmpty() )
356 aCmd->SetArg(1,aStates->GetCurrectState().at(1));
357 aStates->IncrementState();
359 else if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 3) {
360 if(!aStates->GetCurrectState().at(2).IsEmpty() )
361 aCmd->SetArg(1,aStates->GetCurrectState().at(2));
362 aStates->IncrementState();
364 else if(aMethod == "LengthFromEdges" || aMethod == "LengthFromFaces"){
365 aStates->IncrementState();
369 // Case for NumberOfLayers hypothesis
370 else if(aStates->GetObjectType().IsEqual("NumberOfLayers")){
371 if(aMethod == "SetNumberOfLayers" && aStates->GetCurrectState().size() >= 1) {
372 if(!aStates->GetCurrectState().at(0).IsEmpty() )
373 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
374 aStates->IncrementState();
378 // Case for NumberOfSegments hypothesis
379 else if(aStates->GetObjectType().IsEqual("NumberOfSegments")){
380 if(aMethod == "SetNumberOfSegments" && aStates->GetCurrectState().size() >= 1) {
381 if(!aStates->GetCurrectState().at(0).IsEmpty() )
382 aCmd->SetArg(1,aStates->GetCurrectState().at(0));
383 if(aStates->GetCurrectState().size()==1)
384 aStates->IncrementState();
386 else if (aMethod == "SetScaleFactor" && aStates->GetCurrectState().size() >= 2) {
387 if(!aStates->GetCurrectState().at(1).IsEmpty() )
388 aCmd->SetArg(1,aStates->GetCurrectState().at(1));
389 aStates->IncrementState();
393 else if(aStates->GetObjectType().IsEqual("Mesh")) {
394 TState aCurrentState = aStates->GetCurrectState();
395 int aCurrentStateSize = aCurrentState.size();
396 if(aMethod.IsEqual("Translate") ||
397 aMethod.IsEqual("TranslateMakeGroups") ||
398 aMethod.IsEqual("TranslateMakeMesh")) {
399 bool isVariableFound = false;
401 for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
402 if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) {
408 if(aCurrentStateSize == 3) { // translation by dx, dy, dz
409 for(int j = 0; j < aCurrentStateSize; j++) {
410 if(!aCurrentState.at(j).IsEmpty()) {
411 isVariableFound = true;
412 aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
416 else if(aCurrentStateSize == 6) { // translation by x1, x2, y1, y2, z1, z2
417 // TODO: limitation until operations on the variables will be introduced
419 isVariableFound = true;
420 for(int j = 0; j < 3; j++) {
421 TCollection_AsciiString anArg = aCmd->GetArg(anArgIndex+j);
422 TCollection_AsciiString aValue1 = aCurrentState.at(2*j), aValue2 = aCurrentState.at(2*j+1);
423 bool aV1 = !aValue1.IsEmpty();
424 bool aV2 = !aValue2.IsEmpty();
425 double aValue, aCurrentValue = anArg.IsRealValue() ? anArg.RealValue() : 0;
427 if(!GetReal(aValue1, aValue))
429 aValue2 = TCollection_AsciiString( aValue + aCurrentValue );
431 else if(!aV1 && aV2) {
432 if(!GetReal(aValue2, aValue))
434 aValue1 = TCollection_AsciiString( aValue - aCurrentValue );
436 else if(!aV1 && !aV2) {
437 aValue1 = TCollection_AsciiString( 0 );
438 aValue2 = TCollection_AsciiString( aCurrentValue );
440 aCmd->SetArg(anArgIndex+j, aValue1 + ", " + aValue2 );
445 if(isVariableFound) {
446 TCollection_AsciiString aDim;
447 if(aCurrentStateSize == 6)
449 aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"+aDim);
450 aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
452 aStates->IncrementState();
454 else if(aMethod.IsEqual("Rotate") ||
455 aMethod.IsEqual("RotateMakeGroups") ||
456 aMethod.IsEqual("RotateMakeMesh") ||
457 aMethod.IsEqual("RotationSweep") ||
458 aMethod.IsEqual("RotationSweepMakeGroups") ||
459 aMethod.IsEqual("Mirror") ||
460 aMethod.IsEqual("MirrorMakeGroups")) {
461 bool isSubstitute = false;
463 for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
464 if(aCmd->GetArg(i).IsEqual("SMESH.AxisStruct")) {
470 for(int j = 0; j < aCurrentStateSize; j++) {
471 if(!aCurrentState.at(j).IsEmpty()) {
472 if(j < 6) // 0-5 - axis struct, 6 - angle (rotation & sweep), 7-8 - nbSteps and tolerance (sweep)
474 aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
479 aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".AxisStructStr");
480 aStates->IncrementState();
482 else if(aMethod.IsEqual("AddNode") ||
483 aMethod.IsEqual("MoveClosestNodeToPoint")) {
484 for(int j = 0; j < aCurrentStateSize; j++) {
485 if(!aCurrentState.at(j).IsEmpty())
486 aCmd->SetArg(j+1, aCurrentState.at(j));
488 aStates->IncrementState();
490 else if(aMethod.IsEqual("MoveNode")) {
491 for(int j = 0; j < aCurrentStateSize; j++) {
492 if(!aCurrentState.at(j).IsEmpty())
493 aCmd->SetArg(j+2, aCurrentState.at(j));
495 aStates->IncrementState();
497 else if(aMethod.IsEqual("ExtrusionSweep") ||
498 aMethod.IsEqual("ExtrusionSweepMakeGroups")) {
499 bool isSubstitute = false;
501 for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
502 if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) {
508 for(int j = 0; j < aCurrentStateSize; j++) {
509 if(!aCurrentState.at(j).IsEmpty()) {
510 if(j < 3) // 0-2 - dir struct, 3 - number of steps
512 aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
517 aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
518 aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
520 aStates->IncrementState();
522 else if(aMethod.IsEqual("ExtrusionAlongPath") ||
523 aMethod.IsEqual("ExtrusionAlongPathMakeGroups") ||
524 /* workaround for a bug in the command parsing algorithm */
525 aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1) {
526 int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z"
527 bool isSubstitute = false;
529 for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
530 if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) {
531 anArgIndex = i-1-aNbAngles;
537 for(; j < aNbAngles; j++) {
538 if(!aCurrentState.at(j).IsEmpty()) {
539 aCmd->SetArg(anArgIndex+j-1, aCurrentState.at(j));
542 for(; j < aNbAngles+3; j++) {
543 if(!aCurrentState.at(j).IsEmpty()) {
545 aCmd->SetArg(anArgIndex+j+2, aCurrentState.at(j));
550 aCmd->SetArg(anArgIndex + aNbAngles + 1,
551 TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
552 aStates->IncrementState();
554 else if(aMethod.IsEqual("TriToQuad") ||
555 aMethod.IsEqual("Concatenate") ||
556 aMethod.IsEqual("ConcatenateWithGroups")) {
557 if(aCurrentStateSize && !aCurrentState.at(0).IsEmpty())
558 aCmd->SetArg(aCmd->GetNbArgs(), aCurrentState.at(0));
559 aStates->IncrementState();
561 else if(aMethod.IsEqual("Smooth") ||
562 aMethod.IsEqual("SmoothParametric")) {
563 int anArgIndex = aCmd->GetNbArgs() - 2;
564 for(int j = 0; j < aCurrentStateSize; j++) {
565 if(!aCurrentState.at(j).IsEmpty())
566 aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
568 aStates->IncrementState();
573 cout<<"Command after: "<< aCmd->GetString()<<endl;
576 // ProcessLayerDistribution();
578 //================================================================================
580 * \brief Private method
582 //================================================================================
583 void SMESH_NoteBook::InitObjectMap()
585 SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
589 SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
590 if(aStudy->_is_nil())
593 SALOMEDS::SObject_var aSO = aStudy->FindComponent(aGen->ComponentDataType());
594 if(CORBA::is_nil(aSO))
597 SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
599 for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
600 SALOMEDS::SObject_var aSObject = Itr->Value();
601 SALOMEDS::GenericAttribute_var anAttr;
602 if ( aSObject->FindAttribute(anAttr, "AttributeString")) {
603 aParameters = SALOMEDS::AttributeString::_narrow(anAttr)->Value();
604 SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
606 cout<<"Entry : "<< aSObject->GetID()<<endl;
607 cout<<"aParameters : "<<aParameters<<endl;
609 TCollection_AsciiString anObjType;
610 CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject(aSObject);
611 SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
612 if(!aHyp->_is_nil()) {
613 anObjType = TCollection_AsciiString(aHyp->GetName());
615 else if(SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject)) {
616 anObjType = TCollection_AsciiString("Mesh");
619 cout<<"The object Type : "<<anObjType<<endl;
620 ObjectStates *aState = NULL;
621 if(anObjType == "LayerDistribution")
622 aState = new LayerDistributionStates();
624 aState = new ObjectStates(anObjType);
626 for(int i = 0; i < aSections->length(); i++) {
628 SALOMEDS::ListOfStrings aListOfVars = aSections[i];
629 for(int j = 0;j<aListOfVars.length();j++) {
630 TCollection_AsciiString aVar(aListOfVars[j].in());
631 if(!aVar.IsEmpty() && aStudy->IsVariable(aVar.ToCString())) {
632 aVar.InsertBefore(1,"\"");
633 aVar.InsertAfter(aVar.Length(),"\"");
635 aVars.push_back(aVar);
637 cout<<"Variable: '"<<aVar<<"'"<<endl;
640 aState->AddState(aVars);
642 _objectMap.insert(pair<TCollection_AsciiString,ObjectStates*>(TCollection_AsciiString(aSObject->GetID()),aState));
647 //================================================================================
651 //================================================================================
652 void SMESH_NoteBook::AddCommand(const TCollection_AsciiString& theString)
655 cout<<theString<<endl;
656 Handle(_pyCommand) aCommand = new _pyCommand( theString, -1);
657 _commands.push_back(aCommand);
659 if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
660 myMeshEditors.insert( make_pair( aCommand->GetResultValue(),
661 aCommand->GetObject() ) );
665 //================================================================================
669 //================================================================================
670 void SMESH_NoteBook::ProcessLayerDistribution()
672 // 1) Find all LayerDistribution states
673 vector<LayerDistributionStates*> aLDS;
674 TVariablesMap::const_iterator it = _objectMap.begin();
675 for(;it != _objectMap.end();it++)
676 if(LayerDistributionStates* aLDStates = (LayerDistributionStates*)((*it).second)) {
677 aLDS.push_back(aLDStates);
680 // 2) Initialize all type of 1D Distribution hypothesis
681 for(int i=0;i<_commands.size();i++){
682 for(int j =0;j < aLDS.size();j++){
683 TCollection_AsciiString aResultValue = _commands[i]->GetResultValue();
684 if(_commands[i]->GetMethod() == "CreateHypothesis" &&
685 aLDS[j]->HasDistribution(aResultValue)){
686 TCollection_AsciiString aType = _commands[i]->GetArg(1);
687 aType.RemoveAll('\'');
688 aLDS[j]->SetDistributionType(aResultValue,aType);
692 // 3) ... and replase variables ...
694 for(int i=0;i<_commands.size();i++){
695 for(int j =0;j < aLDS.size();j++){
696 TCollection_AsciiString anObject = _commands[i]->GetObject();
698 if(aLDS[j]->HasDistribution(anObject)) {
699 TCollection_AsciiString aType = aLDS[j]->GetDistributionType(anObject);
700 TCollection_AsciiString aMethod = _commands[i]->GetMethod();
701 if(aType == "LocalLength") {
702 if(aMethod == "SetLength") {
703 if(!aLDS[j]->GetCurrectState().at(0).IsEmpty() )
704 _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(0));
705 aLDS[j]->IncrementState();
707 else if(aMethod == "SetPrecision") {
708 if(!aLDS[j]->GetCurrectState().at(1).IsEmpty() )
709 _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(1));
710 aLDS[j]->IncrementState();
717 //================================================================================
719 * \brief Return result script
721 //================================================================================
722 TCollection_AsciiString SMESH_NoteBook::GetResultScript() const
724 TCollection_AsciiString aResult;
725 for(int i=0;i<_commands.size();i++)
726 aResult+=_commands[i]->GetString()+"\n";
730 //================================================================================
732 * \brief Return value of the variable
734 //================================================================================
735 bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& theValue)
739 SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
743 SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
744 if(aStudy->_is_nil())
747 TCollection_AsciiString aVarName = theVarName;
748 aVarName.RemoveAll('\"');
750 if(aVarName.IsEmpty())
753 const char* aName = aVarName.ToCString();
754 if(aStudy->IsVariable(aName) && (aStudy->IsReal(aName) || aStudy->IsInteger(aName))) {
755 theValue = aStudy->GetReal(aVarName.ToCString());