X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_NoteBook.cxx;h=bd7268049430ef85fee519a2b0f295ed32ce01ac;hp=ac3ae0c152a29c3cc10b9c56e718277b0f5ea948;hb=6bcc9f5949829c1c68662f11e38fe313772c2e91;hpb=69ef5d6f25ece0587600745138e80f5544180612 diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx index ac3ae0c15..bd7268049 100644 --- a/src/SMESH_I/SMESH_NoteBook.cxx +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -41,6 +41,7 @@ static int MYDEBUG = 0; using namespace std; +void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb); //================================================================================ /*! @@ -242,7 +243,15 @@ void SMESH_NoteBook::ReplaceVariables() } } + if(it == _objectMap.end()) { // additional check for pattern mapping + if(aMethod.IsEqual("ApplyToMeshFaces") || + aMethod.IsEqual("ApplyToHexahedrons")) + it = _objectMap.find(aCmd->GetArg(1)); + } + if(it != _objectMap.end()) { + if(MYDEBUG) + cout << "Found object : " << (*it).first << endl; ObjectStates *aStates = (*it).second; // Case for LocalLength hypothesis if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) { @@ -295,6 +304,8 @@ void SMESH_NoteBook::ReplaceVariables() if(aMethod == "SetLayerDistribution"){ LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates); aLDStates->AddDistribution(aCmd->GetArg(1)); + if(MYDEBUG) + cout<<"Add Distribution :"<GetArg(1)<GetObjectType().IsEqual("Mesh")) { TState aCurrentState = aStates->GetCurrectState(); int aCurrentStateSize = aCurrentState.size(); - if(aMethod.IsEqual("Translate") || - aMethod.IsEqual("TranslateMakeGroups") || - aMethod.IsEqual("TranslateMakeMesh")) { + if(aMethod.IsEqual("Translate") || + aMethod.IsEqual("TranslateMakeGroups") || + aMethod.IsEqual("TranslateMakeMesh") || + aMethod.IsEqual("TranslateObject") || + aMethod.IsEqual("TranslateObjectMakeGroups") || + aMethod.IsEqual("TranslateObjectMakeMesh")) { bool isVariableFound = false; int anArgIndex = 0; for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { @@ -451,13 +465,26 @@ void SMESH_NoteBook::ReplaceVariables() } aStates->IncrementState(); } - else if(aMethod.IsEqual("Rotate") || - aMethod.IsEqual("RotateMakeGroups") || - aMethod.IsEqual("RotateMakeMesh") || - aMethod.IsEqual("RotationSweep") || + else if(aMethod.IsEqual("Rotate") || + aMethod.IsEqual("RotateMakeGroups") || + aMethod.IsEqual("RotateMakeMesh") || + aMethod.IsEqual("RotateObject") || + aMethod.IsEqual("RotateObjectMakeGroups") || + aMethod.IsEqual("RotateObjectMakeMesh") || + aMethod.IsEqual("RotationSweep") || + aMethod.IsEqual("RotationSweepObject") || + aMethod.IsEqual("RotationSweepObject1D") || + aMethod.IsEqual("RotationSweepObject2D") || aMethod.IsEqual("RotationSweepMakeGroups") || - aMethod.IsEqual("Mirror") || - aMethod.IsEqual("MirrorMakeGroups")) { + aMethod.IsEqual("RotationSweepObjectMakeGroups") || + aMethod.IsEqual("RotationSweepObject1DMakeGroups") || + aMethod.IsEqual("RotationSweepObject2DMakeGroups") || + aMethod.IsEqual("Mirror") || + aMethod.IsEqual("MirrorMakeMesh") || + aMethod.IsEqual("MirrorMakeGroups") || + aMethod.IsEqual("MirrorObject") || + aMethod.IsEqual("MirrorObjectMakeMesh") || + aMethod.IsEqual("MirrorObjectMakeGroups")) { bool isSubstitute = false; int anArgIndex = 0; for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { @@ -495,7 +522,13 @@ void SMESH_NoteBook::ReplaceVariables() aStates->IncrementState(); } else if(aMethod.IsEqual("ExtrusionSweep") || - aMethod.IsEqual("ExtrusionSweepMakeGroups")) { + aMethod.IsEqual("ExtrusionSweepObject") || + aMethod.IsEqual("ExtrusionSweepObject1D") || + aMethod.IsEqual("ExtrusionSweepObject2D") || + aMethod.IsEqual("ExtrusionSweepMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObjectMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObject1DMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObject2DMakeGroups")) { bool isSubstitute = false; int anArgIndex = 0; for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { @@ -520,9 +553,18 @@ void SMESH_NoteBook::ReplaceVariables() aStates->IncrementState(); } else if(aMethod.IsEqual("ExtrusionAlongPath") || + aMethod.IsEqual("ExtrusionAlongPathObject") || + aMethod.IsEqual("ExtrusionAlongPathObject1D") || + aMethod.IsEqual("ExtrusionAlongPathObject2D") || aMethod.IsEqual("ExtrusionAlongPathMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObjectMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObject1DMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObject2DMakeGroups") || /* workaround for a bug in the command parsing algorithm */ - aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1) { + aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObjectMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObject1DMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObject2DMakeGroups") != -1 ) { int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z" bool isSubstitute = false; int anArgIndex = 0; @@ -559,7 +601,9 @@ void SMESH_NoteBook::ReplaceVariables() aStates->IncrementState(); } else if(aMethod.IsEqual("Smooth") || - aMethod.IsEqual("SmoothParametric")) { + aMethod.IsEqual("SmoothObject") || + aMethod.IsEqual("SmoothParametric") || + aMethod.IsEqual("SmoothParametricObject")) { int anArgIndex = aCmd->GetNbArgs() - 2; for(int j = 0; j < aCurrentStateSize; j++) { if(!aCurrentState.at(j).IsEmpty()) @@ -567,13 +611,26 @@ void SMESH_NoteBook::ReplaceVariables() } aStates->IncrementState(); } + else if(aMethod.IsEqual("ApplyToMeshFaces") || + aMethod.IsEqual("ApplyToHexahedrons")) { + int anArgIndex = aCmd->GetNbArgs()-1; + for(int j = 0; j < aCurrentStateSize; j++) + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + aStates->IncrementState(); + } } } + else { + if(MYDEBUG) + cout << "Object not found" << endl; + } if(MYDEBUG) { cout<<"Command after: "<< aCmd->GetString()< aLDS; TVariablesMap::const_iterator it = _objectMap.begin(); - for(;it != _objectMap.end();it++) - if(LayerDistributionStates* aLDStates = (LayerDistributionStates*)((*it).second)) { + for(;it != _objectMap.end();it++) { + LayerDistributionStates* aLDStates = dynamic_cast(((*it).second)); + if(aLDStates!=NULL) { aLDS.push_back(aLDStates); } + } + + if(!aLDS.size()) + return; // 2) Initialize all type of 1D Distribution hypothesis for(int i=0;i<_commands.size();i++){ @@ -700,13 +763,39 @@ void SMESH_NoteBook::ProcessLayerDistribution() TCollection_AsciiString aMethod = _commands[i]->GetMethod(); if(aType == "LocalLength") { if(aMethod == "SetLength") { - if(!aLDS[j]->GetCurrectState().at(0).IsEmpty() ) - _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(0)); + SetVariable(_commands[i], aLDS[j],0,1); aLDS[j]->IncrementState(); } else if(aMethod == "SetPrecision") { - if(!aLDS[j]->GetCurrectState().at(1).IsEmpty() ) - _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(1)); + SetVariable(_commands[i], aLDS[j],1,1); + aLDS[j]->IncrementState(); + } + } + + // Case for NumberOfSegments hypothesis + else if(aType == "NumberOfSegments"){ + if(aMethod == "SetNumberOfSegments") { + SetVariable(_commands[i], aLDS[j],0,1); + if(aLDS[j]->GetCurrectState().size()==1) + aLDS[j]->IncrementState(); + } + else if (aMethod == "SetScaleFactor") { + SetVariable(_commands[i], aLDS[j],1,1); + aLDS[j]->IncrementState(); + } + } + + else if( aType == "Deflection1D" ){ + if(aMethod == "SetDeflection"){ + SetVariable(_commands[i], aLDS[j],0,1); + aLDS[j]->IncrementState(); + } + } + // Case for Arithmetic1D and StartEndLength hypothesis + else if(aType == "Arithmetic1D" || aType == "StartEndLength") { + if(aMethod == "SetLength") { + int anArgNb = (_commands[i]->GetArg(2) == "1") ? 0 : 1; + SetVariable(_commands[i], aLDS[j],anArgNb,1); aLDS[j]->IncrementState(); } } @@ -758,3 +847,15 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& return ok; } + + +/*! + * Set variable of the ObjectStates from position to the _pyCommand + * method as nbArg argument + */ +void SetVariable(Handle(_pyCommand) theCommand, const ObjectStates* theStates, int position, int theArgNb) +{ + if(theStates->GetCurrectState().size() > position) + if(!theStates->GetCurrectState().at(position).IsEmpty()) + theCommand->SetArg(theArgNb,theStates->GetCurrectState().at(position)); +}