!myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil())
return false;
+ if (!isValid())
+ return false;
+
SMESH::long_array_var anElementsId = new SMESH::long_array;
if (MeshCheck->isChecked()) {
return false;
}
+ QStringList aParameters;
+
// get angles
SMESH::double_array_var anAngles = new SMESH::double_array;
if (AnglesGrp->isChecked()) {
- anAngles->length(AnglesList->count());
+ anAngles->length(myAnglesList.count());
int j = 0;
- bool bOk;
- for (int i = 0; i < AnglesList->count(); i++) {
- double angle = AnglesList->item(i)->text().toDouble(&bOk);
- if (bOk)
- anAngles[ j++ ] = angle*PI/180;
+ for (int i = 0; i < myAnglesList.count(); i++) {
+ double angle = myAnglesList[i];
+ anAngles[ j++ ] = angle*PI/180;
+ aParameters << AnglesList->item(i)->text();
}
anAngles->length(j);
}
aBasePoint.z = ZSpin->GetValue();
}
+ aParameters << XSpin->text();
+ aParameters << YSpin->text();
+ aParameters << ZSpin->text();
+
try {
SUIT_OverrideCursor wc;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint);
+ if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
+
//wc.stop();
wc.suspend();
switch (retVal) {
//=======================================================================
void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
{
- AnglesList->addItem(QString::number(AngleSpin->GetValue()));
+ QString msg;
+ if( !AngleSpin->isValid( msg, true ) ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ return;
+ }
+ AnglesList->addItem(AngleSpin->text());
+ myAnglesList.append(AngleSpin->GetValue());
+
+ updateLinearAngles();
}
//=======================================================================
{
QList<QListWidgetItem*> aList = AnglesList->selectedItems();
QListWidgetItem* anItem;
- foreach(anItem, aList) delete anItem;
+ foreach(anItem, aList) {
+ myAnglesList.removeAt(AnglesList->row(anItem));
+ delete anItem;
+ }
+
+ updateLinearAngles();
}
//=================================================================================
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
+{
+ QString msg;
+ bool ok = true;
+ ok = XSpin->isValid( msg, true ) && ok;
+ ok = YSpin->isValid( msg, true ) && ok;
+ ok = ZSpin->isValid( msg, true ) && ok;
+
+ if( !ok ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================
+// function : updateLinearAngles
+// purpose :
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
+{
+ bool enableLinear = true;
+ for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
+ if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
+ enableLinear = false;
+ anItem->text().toDouble(&enableLinear);
+ if( !enableLinear )
+ break;
+ }
+ }
+ if( !enableLinear )
+ LinearAnglesCheck->setChecked( false );
+ LinearAnglesCheck->setEnabled( enableLinear );
+}
int GetConstructorId();
void SetEditCurrentArgument( QToolButton* );
+ bool isValid();
+
+ void updateLinearAngles();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SUIT_SelectionFilter* myElementsFilter;
SUIT_SelectionFilter* myPathMeshFilter;
int myType;
+ QList<double> myAnglesList;
// widgets
QGroupBox* ConstructorsBox;
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
#include <SVTK_ViewWindow.h>
#include <SVTK_Selector.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
-#include <QSpinBox>
#include <QKeyEvent>
// IDL includes
SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
- SpinBox_NbSteps = new QSpinBox(GroupAngleBox);
+ SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
GroupAngleLayout->addWidget(RadioButton3, 0, 0);
GroupAngleLayout->addWidget(RadioButton4, 0, 1);
connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
+ connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
+
ConstructorsClicked(0);
SelectionIntoArgument();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void SMESHGUI_RevolutionDlg::ClickOnApply()
+bool SMESHGUI_RevolutionDlg::ClickOnApply()
{
if (mySMESHGUI->isActiveStudyLocked())
- return;
+ return false;
+
+ if (!isValid())
+ return false;
if (myNbOkElements && IsAxisOk()) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
if ( GroupAngle->checkedId() == 1 )
anAngle = anAngle/aNbSteps;
+ QStringList aParameters;
+ aParameters << SpinBox_X->text();
+ aParameters << SpinBox_Y->text();
+ aParameters << SpinBox_Z->text();
+ aParameters << SpinBox_DX->text();
+ aParameters << SpinBox_DY->text();
+ aParameters << SpinBox_DZ->text();
+ aParameters << SpinBox_Angle->text();
+ aParameters << SpinBox_NbSteps->text();
+ aParameters << SpinBox_Tolerance->text();
+
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
anAngle, aNbSteps, aTolerance);
else
aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
+
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) {
}
ConstructorsClicked(GetConstructorId());
SelectionIntoArgument();
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_RevolutionDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
}
}
+//=======================================================================
+// function : onAngleTextChange()
+// purpose :
+//=======================================================================
+void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
+{
+ bool isNumber;
+ SpinBox_Angle->text().toDouble( &isNumber );
+ if( !isNumber )
+ RadioButton3->setChecked( true );
+ RadioButton4->setEnabled( isNumber );
+}
+
//=======================================================================
// function : onTextChange()
// purpose :
mySimulation->SetVisibility(false);
}
}
+
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_RevolutionDlg::isValid()
+{
+ QString msg;
+ bool ok = true;
+ ok = SpinBox_X->isValid( msg, true ) && ok;
+ ok = SpinBox_Y->isValid( msg, true ) && ok;
+ ok = SpinBox_Z->isValid( msg, true ) && ok;
+ ok = SpinBox_DX->isValid( msg, true ) && ok;
+ ok = SpinBox_DY->isValid( msg, true ) && ok;
+ ok = SpinBox_DZ->isValid( msg, true ) && ok;
+ ok = SpinBox_Angle->isValid( msg, true ) && ok;
+ ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
+ ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
+
+ if( !ok ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ return false;
+ }
+ return true;
+}
class QPushButton;
class QRadioButton;
class QCheckBox;
-class QSpinBox;
+class SalomeApp_IntSpinBox;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
class SMESHGUI;
int GetConstructorId();
bool IsAxisOk();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QLabel* TextLabelAngle;
SMESHGUI_SpinBox* SpinBox_Angle;
QLabel* TextLabelNbSteps;
- QSpinBox* SpinBox_NbSteps;
+ SalomeApp_IntSpinBox* SpinBox_NbSteps;
QLabel* TextLabelTolerance;
SMESHGUI_SpinBox* SpinBox_Tolerance;
void ConstructorsClicked( int );
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
void DeactivateActiveDialog();
void ActivateThisDialog();
void onTextChange( const QString& );
+ void onAngleTextChange( const QString& );
void onSelectMesh( bool );
void onVectorChanged();
void toDisplaySimulation();
QStringList aParameters;
aParameters << SpinBox1_1->text();
- aParameters << SpinBox1_2->text();
- aParameters << SpinBox1_3->text();
- if (GetConstructorId() == 0) {
+ if (GetConstructorId() == 0)
aParameters << SpinBox2_1->text();
+ aParameters << SpinBox1_2->text();
+ if (GetConstructorId() == 0)
aParameters << SpinBox2_2->text();
+ aParameters << SpinBox1_3->text();
+ if (GetConstructorId() == 0)
aParameters << SpinBox2_3->text();
- }
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
"BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",
"ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements",
"RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion",
- "ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D","Mirror",
- "MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
+ "ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D","ExtrusionAlongPath",
+ "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
"FindCoincidentNodes","FindCoincidentNodesOnPart","MergeNodes","FindEqualElements",
"MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders",
"SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
CORBA::Double theTolerance)
{
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotationSweep( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
theTolerance,
true);
if ( !myPreviewMode ) {
- TPythonDump()<< "axis = " << theAxis;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".RotationSweepMakeGroups( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
const SMESH::PointStruct & theRefPoint)
{
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
-
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
- else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
<< theIDsOfElements << ", "
<< thePathMesh << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
extrusionAlongPath( theIDsOfElements,
true,
Error);
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
-
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
- else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
bool isDumpGroups = aGroups && aGroups->length() > 0;
TPythonDump aPythonDump;
if(isDumpGroups) {
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
return aGroups;
}
#include <string>
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#endif
using namespace std;
}
}
- if(it != _objectMap.end() && !aMethod.IsEmpty()) {
+ if(it != _objectMap.end()) {
ObjectStates *aStates = (*it).second;
// Case for LocalLength hypothesis
if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
}
}
else if(aCurrentStateSize == 6) { // translation by x1, x2, y1, y2, z1, z2
- // TODO
+ isVariableFound = true;
+ for(int j = 0; j < 3; j++) {
+ TCollection_AsciiString anArg = aCmd->GetArg(anArgIndex+j);
+ TCollection_AsciiString aValue1 = aCurrentState.at(2*j), aValue2 = aCurrentState.at(2*j+1);
+ bool aV1 = !aValue1.IsEmpty();
+ bool aV2 = !aValue2.IsEmpty();
+ double aValue, aCurrentValue = anArg.IsRealValue() ? anArg.RealValue() : 0;
+ if(aV1 && !aV2) {
+ if(!GetReal(aValue1, aValue))
+ aValue = 0;
+ aValue2 = TCollection_AsciiString( aValue + aCurrentValue );
+ }
+ else if(!aV1 && aV2) {
+ if(!GetReal(aValue2, aValue))
+ aValue = 0;
+ aValue1 = TCollection_AsciiString( aValue - aCurrentValue );
+ }
+ else if(!aV1 && !aV2) {
+ aValue1 = TCollection_AsciiString( 0 );
+ aValue2 = TCollection_AsciiString( aCurrentValue );
+ }
+ aCmd->SetArg(anArgIndex+j, aValue1 + ", " + aValue2 );
+ }
}
}
if(isVariableFound) {
- aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
+ TCollection_AsciiString aDim;
+ if(aCurrentStateSize == 6)
+ aDim = "6";
+ aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"+aDim);
aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
}
aStates->IncrementState();
else if(aMethod.IsEqual("Rotate") ||
aMethod.IsEqual("RotateMakeGroups") ||
aMethod.IsEqual("RotateMakeMesh") ||
+ aMethod.IsEqual("RotationSweep") ||
+ aMethod.IsEqual("RotationSweepMakeGroups") ||
aMethod.IsEqual("Mirror") ||
- aMethod.IsEqual("MirrorMakeGroups") ||
- aMethod.IsEqual("MirrorMakeMesh")) {
+ aMethod.IsEqual("MirrorMakeGroups")) {
bool isSubstitute = false;
int anArgIndex = 0;
for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
if(anArgIndex > 0) {
for(int j = 0; j < aCurrentStateSize; j++) {
if(!aCurrentState.at(j).IsEmpty()) {
- if(j < 6) // from 0 to 5 - axis struct, 6 - angle
+ if(j < 6) // 0-5 - axis struct, 6 - angle (rotation & sweep), 7-8 - nbSteps and tolerance (sweep)
isSubstitute = true;
aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
}
if(anArgIndex > 0) {
for(int j = 0; j < aCurrentStateSize; j++) {
if(!aCurrentState.at(j).IsEmpty()) {
- if(j < 3) // from 0 to 2 - dir struct, 3 - number of steps
+ if(j < 3) // 0-2 - dir struct, 3 - number of steps
isSubstitute = true;
aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
}
}
aStates->IncrementState();
}
+ else if(aMethod.IsEqual("ExtrusionAlongPath") ||
+ aMethod.IsEqual("ExtrusionAlongPathMakeGroups") ||
+ /* workaround for a bug in the command parsing algorithm */
+ aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1) {
+ int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z"
+ bool isSubstitute = false;
+ int anArgIndex = 0;
+ for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
+ if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) {
+ anArgIndex = i-1-aNbAngles;
+ break;
+ }
+ }
+ if(anArgIndex > 0) {
+ int j = 0;
+ for(; j < aNbAngles; j++) {
+ if(!aCurrentState.at(j).IsEmpty()) {
+ aCmd->SetArg(anArgIndex+j-1, aCurrentState.at(j));
+ }
+ }
+ for(; j < aNbAngles+3; j++) {
+ if(!aCurrentState.at(j).IsEmpty()) {
+ isSubstitute = true;
+ aCmd->SetArg(anArgIndex+j+2, aCurrentState.at(j));
+ }
+ }
+ }
+ if(isSubstitute)
+ aCmd->SetArg(anArgIndex + aNbAngles + 1,
+ TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
+ aStates->IncrementState();
+ }
else if(aMethod.IsEqual("TriToQuad") ||
aMethod.IsEqual("Concatenate") ||
aMethod.IsEqual("ConcatenateWithGroups")) {
aResult+=_commands[i]->GetString()+"\n";
return aResult;
}
+
+//================================================================================
+/*!
+ * \brief Return value of the variable
+ */
+//================================================================================
+bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& theValue)
+{
+ bool ok = false;
+
+ SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
+ if(!aGen)
+ return ok;
+
+ SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
+ if(aStudy->_is_nil())
+ return ok;
+
+ TCollection_AsciiString aVarName = theVarName;
+ aVarName.RemoveAll('\"');
+
+ if(aVarName.IsEmpty())
+ return ok;
+
+ const char* aName = aVarName.ToCString();
+ if(aStudy->IsVariable(aName) && (aStudy->IsReal(aName) || aStudy->IsInteger(aName))) {
+ theValue = aStudy->GetReal(aVarName.ToCString());
+ ok = true;
+ }
+
+ return ok;
+}
private:
void InitObjectMap();
void ProcessLayerDistribution();
+
+ bool GetReal(const TCollection_AsciiString& theVarName, double& theValue);
private:
PrecisionConfusion = 1e-07
+## Converts an angle from degrees to radians
+def DegreesToRadians(AngleInDegrees):
+ from math import pi
+ return AngleInDegrees * pi / 180.0
+
# Salome notebook variable separator
variable_separator = ":"
else:
self.z = zStr
+# Parametrized substitute for PointStruct (with 6 parameters)
+class PointStructStr6:
+
+ x1 = 0
+ y1 = 0
+ z1 = 0
+ x2 = 0
+ y2 = 0
+ z2 = 0
+ xStr1 = ""
+ yStr1 = ""
+ zStr1 = ""
+ xStr2 = ""
+ yStr2 = ""
+ zStr2 = ""
+
+ def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
+ self.x1Str = x1Str
+ self.x2Str = x2Str
+ self.y1Str = y1Str
+ self.y2Str = y2Str
+ self.z1Str = z1Str
+ self.z2Str = z2Str
+ if isinstance(x1Str, str) and notebook.isVariable(x1Str):
+ self.x1 = notebook.get(x1Str)
+ else:
+ self.x1 = x1Str
+ if isinstance(x2Str, str) and notebook.isVariable(x2Str):
+ self.x2 = notebook.get(x2Str)
+ else:
+ self.x2 = x2Str
+ if isinstance(y1Str, str) and notebook.isVariable(y1Str):
+ self.y1 = notebook.get(y1Str)
+ else:
+ self.y1 = y1Str
+ if isinstance(y2Str, str) and notebook.isVariable(y2Str):
+ self.y2 = notebook.get(y2Str)
+ else:
+ self.y2 = y2Str
+ if isinstance(z1Str, str) and notebook.isVariable(z1Str):
+ self.z1 = notebook.get(z1Str)
+ else:
+ self.z1 = z1Str
+ if isinstance(z2Str, str) and notebook.isVariable(z2Str):
+ self.z2 = notebook.get(z2Str)
+ else:
+ self.z2 = z2Str
+
# Parametrized substitute for AxisStruct
class AxisStructStr:
Parameters = "::"
if isinstance(Dir, DirStructStr):
pntStr = Dir.pointStruct
- Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr)
- Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
+ if isinstance(pntStr, PointStructStr6):
+ Parameters = str(pntStr.x1Str) + ":" + str(pntStr.x2Str) + ":"
+ Parameters += str(pntStr.y1Str) + ":" + str(pntStr.y2Str) + ":"
+ Parameters += str(pntStr.z1Str) + ":" + str(pntStr.z2Str)
+ Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
+ else:
+ Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr)
+ Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
Dir = DirStruct(Point)
return Dir, Parameters
Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
return Axis, Parameters
+## Return list of variable values from salome notebook
+def ParseAngles(list):
+ Result = []
+ Parameters = ""
+ for parameter in list:
+ if isinstance(parameter,str) and notebook.isVariable(parameter):
+ Result.append(DegreesToRadians(notebook.get(parameter)))
+ pass
+ else:
+ Result.append(parameter)
+ pass
+
+ Parameters = Parameters + str(parameter)
+ Parameters = Parameters + ":"
+ pass
+ Parameters = Parameters[:len(Parameters)-1]
+ return Result, Parameters
+
def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol:
return True
print hypName, "was not assigned to",geomName,":", reason
pass
-## Converts an angle from degrees to radians
-def DegreesToRadians(AngleInDegrees):
- from math import pi
- return AngleInDegrees * pi / 180.0
-
# end of l1_auxiliary
## @}
## Generates new elements by rotation of the elements around the axis
# @param IDsOfElements the list of ids of elements to sweep
# @param Axis the axis of rotation, AxisStruct or line(geom object)
- # @param AngleInRadians the angle of Rotation
+ # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
# @param NbOfSteps the number of steps
# @param Tolerance tolerance
# @param MakeGroups forces the generation of new groups from existing ones
# @ingroup l2_modif_extrurev
def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
MakeGroups=False, TotalAngle=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
+ Axis,AxisParameters = ParseAxisStruct(Axis)
if TotalAngle and NbOfSteps:
AngleInRadians /= NbOfSteps
+ NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
+ Parameters = AxisParameters + ":" + AngleParameters + ":" + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
AngleInRadians, NbOfSteps, Tolerance)
def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
HasAngles, Angles, HasRefPoint, RefPoint,
MakeGroups=False, LinearVariation=False):
+ Angles,AnglesParameters = ParseAngles(Angles)
+ RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
if HasAngles and Angles and LinearVariation:
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
pass
+ Parameters = AnglesParameters + ":" + RefPointParameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
PathShape, NodeStart, HasAngles,