diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl index bae2f8f95..93fbb710d 100644 --- a/idl/SMESH_MeshEditor.idl +++ b/idl/SMESH_MeshEditor.idl @@ -281,6 +281,48 @@ module SMESH in double AngleInRadians, in long NbOfSteps, in double Tolerance); + /*! + * \brief Genarate dim+1 elements by rotation of the object around axis + * \param theObject - object containing elements to ratate + * \param Axix - rotation axis + * \param AngleInRadians - rotation angle + * \param NbOfSteps - number of elements to generate from one element + */ + void RotationSweepObject1D(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Same as previous but additionally create groups of elements + * generated from elements belonging to preexisting groups + */ + ListOfGroups RotationSweepObject1DMakeGroups(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Genarate dim+1 elements by rotation of the object around axis + * \param theObject - object containing elements to ratate + * \param Axix - rotation axis + * \param AngleInRadians - rotation angle + * \param NbOfSteps - number of elements to generate from one element + */ + void RotationSweepObject2D(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Same as previous but additionally create groups of elements + * generated from elements belonging to preexisting groups + */ + ListOfGroups RotationSweepObject2DMakeGroups(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); /*! * \brief Genarate dim+1 elements by extrusion of elements along vector * \param IDsOfElements - elements to sweep @@ -386,6 +428,42 @@ module SMESH in PointStruct RefPoint, out Extrusion_Error Error); + Extrusion_Error ExtrusionAlongPathObject1D(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint); + ListOfGroups ExtrusionAlongPathObject1DMakeGroups(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint, + out Extrusion_Error Error); + + Extrusion_Error ExtrusionAlongPathObject2D(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint); + ListOfGroups ExtrusionAlongPathObject2DMakeGroups(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint, + out Extrusion_Error Error); + /*! * Compute rotation angles for ExtrusionAlongPath as linear variation * of given angles along path steps diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index d4f7098ab..239df0871 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -483,45 +483,7 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() SMESH::long_array_var anElementsId = new SMESH::long_array; - if (MeshCheck->isChecked()) { - // If "Select whole mesh, submesh or group" check box is on -> - // get all elements of the required type from the object selected - - // if MESH object is selected - if (!CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(myIDSource))) { - // get mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(myIDSource); - // get IDs from mesh... - if (Elements1dRB->isChecked()) - // 1d elements - anElementsId = aMesh->GetElementsByType(SMESH::EDGE); - else if (Elements2dRB->isChecked()) { - anElementsId = aMesh->GetElementsByType(SMESH::FACE); - } - } - // SUBMESH is selected - if (!CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(myIDSource))) { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(myIDSource); - // get IDs from submesh - if (Elements1dRB->isChecked()) - // 1d elements - anElementsId = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (Elements2dRB->isChecked()) - // 2d elements - anElementsId = aSubMesh->GetElementsByType(SMESH::FACE); - } - // GROUP is selected - if (!CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(myIDSource))) { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(myIDSource); - // get IDs from group - // 1d elements or 2d elements - if (Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE || - Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE) - anElementsId = aGroup->GetListOfID(); - } - } else { + if (!MeshCheck->isChecked()) { // If "Select whole mesh, submesh or group" check box is off -> // use only elements of given type selected by user @@ -546,10 +508,10 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() } anElementsId->length(j); } - } - if (anElementsId->length() <= 0) { - return false; + if (anElementsId->length() <= 0) { + return false; + } } if (StartPointLineEdit->text().trimmed().isEmpty()) { @@ -596,17 +558,47 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles ); SMESH::SMESH_MeshEditor::Extrusion_Error retVal; - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint, retVal); - else - retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( MeshCheck->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + } + else { + if( MeshCheck->isChecked() ) { + if( GetConstructorId() == 0 ) + retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + else + retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + } + else + retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + } if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 83e18035a..b2ce80812 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -87,7 +87,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); @@ -382,11 +383,29 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps); - else - aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepObject1DMakeGroups(mySelectedObject, aVector, aNbSteps); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepObject2DMakeGroups(mySelectedObject, aVector, aNbSteps); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps); + } + else { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps); + else + aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps); + } + else + aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); + } myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); @@ -398,6 +417,7 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } return true; @@ -561,41 +581,21 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() } if (CheckBoxMesh->isChecked()) { - SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE; - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface(IO); - - if (!mesh->_is_nil()) { //MESH - // get elements from mesh - myElementsId = mesh->GetElementsByType(neededType); - aNbElements = myElementsId->length(); - } else { - SMESH::SMESH_subMesh_var aSubMesh = - SMESH::IObjectToInterface(IO); - - if (!aSubMesh->_is_nil()) { //SUBMESH - // get IDs from submesh - myElementsId = aSubMesh->GetElementsByType(neededType); - aNbElements = myElementsId->length(); - } else { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - - if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP - // get IDs from smesh group - myElementsId = aGroup->GetListOfID(); - aNbElements = myElementsId->length(); - } - } - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { // get indices of selcted elements TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex(IO,aMapIndex); aNbElements = aMapIndex.Extent(); + if (aNbElements < 1) + return; + myElementsId = new SMESH::long_array; myElementsId->length( aNbElements ); aString = ""; @@ -603,9 +603,6 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) ); } - if (aNbElements < 1) - return; - myNbOkElements = true; } diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index 7679d9231..65de96ade 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -83,6 +83,8 @@ private: int myNbOkElements; /* to check when elements are defined */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH::long_array_var myElementsId; diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index cc5f909e9..d547fc2d4 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -88,7 +88,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); @@ -494,12 +495,31 @@ bool SMESHGUI_RevolutionDlg::ClickOnApply() SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis, - anAngle, aNbSteps, aTolerance); - else + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis, + anAngle, aNbSteps, aTolerance); + } + else { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance); + else + aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance); + } aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); + } myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); } catch (...) { @@ -510,6 +530,7 @@ bool SMESHGUI_RevolutionDlg::ClickOnApply() mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } @@ -689,77 +710,18 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument() } if (CheckBoxMesh->isChecked()) { - int aConstructorId = GetConstructorId(); - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - if (aConstructorId == 0) { - SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); - - while (anIter->more()) { - const SMDS_MeshEdge * edge = anIter->next(); - if (edge) { - myElementsId += QString(" %1").arg(edge->GetID()); - aNbUnits++; - } - } - } else if (aConstructorId == 1) { - SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); - while (anIter->more()) { - const SMDS_MeshFace * face = anIter->next(); - if (face) { - myElementsId += QString(" %1").arg(face->GetID()); - aNbUnits++; - } - } - } - } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - if (aConstructorId == 0) - anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (aConstructorId == 1) - anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); - - for (int i = 0; i < anElementsIds->length(); i++) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } else { // GROUP - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || - (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE)) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } - - if (aNbUnits < 1) - return; - myNbOkElements = true; } else { aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); @@ -1064,11 +1026,20 @@ void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview) try { SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); - aMeshEditor->RotationSweep(anElementsId.inout(), - anAxis, - anAngle, - aNbSteps, - aTolerance); + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + else + aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + } + else + aMeshEditor->RotationSweep(anElementsId.inout(), + anAxis, + anAngle, + aNbSteps, + aTolerance); SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); mySimulation->SetData(aMeshPreviewStruct._retn()); } catch (...) {} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h index 0355d951c..9729e3b7f 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -85,6 +85,8 @@ private: QWidget* myEditCurrentArgument; /* Current argument */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index 4b7b094be..dbb632a1e 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -90,7 +90,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -350,12 +351,22 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply() SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( CheckBoxParametric->isChecked() ) - aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); - else - aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); + if ( CheckBoxParametric->isChecked() ) { + if(CheckBoxMesh->isChecked()) + aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + } + else { + if(CheckBoxMesh->isChecked()) + aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + } myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); @@ -370,6 +381,8 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply() mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); Init(); + + mySelectedObject = SMESH::SMESH_IDSource::_nil(); } } @@ -543,48 +556,15 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) { - const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); - if (e) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } else { // GROUP - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) { myNbOkNodes = 0; @@ -592,9 +572,6 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() } else { } - if (aNbUnits < 1) - return; - myBusy = true; myEditCurrentArgument->setText(aString); myBusy = false; diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h index cb067431f..a95d76a9e 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -83,6 +83,8 @@ private: QLineEdit* myEditCurrentArgument; /* Current LineEdit */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 5be482377..135a6eab8 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -255,6 +255,13 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand map< _pyID, Handle(_pyMeshEditor) >::iterator id_editor = myMeshEditors.find( objID ); if ( id_editor != myMeshEditors.end() ) { id_editor->second->Process( aCommand ); + TCollection_AsciiString processedCommand = aCommand->GetString(); + // some commands of SMESH_MeshEditor create meshes + if ( aCommand->GetMethod().Search("MakeMesh") != -1 ) { + Handle(_pyMesh) mesh = new _pyMesh( aCommand, aCommand->GetResultValue() ); + aCommand->GetString() = processedCommand; // discard changes made by _pyMesh + myMeshes.insert( make_pair( mesh->GetID(), mesh )); + } return aCommand; } // SMESH_Hypothesis method? @@ -307,17 +314,20 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) // CreateHypothesis( theHypType, theLibName ) // Compute( mesh, geom ) // mesh creation - if ( theCommand->GetMethod() == "CreateMesh" || - theCommand->GetMethod() == "CreateEmptyMesh" || - theCommand->GetMethod() == "CreateMeshesFromUNV" || - theCommand->GetMethod() == "CreateMeshesFromSTL") + TCollection_AsciiString method = theCommand->GetMethod(); + if ( method == "CreateMesh" || method == "CreateEmptyMesh") { Handle(_pyMesh) mesh = new _pyMesh( theCommand ); myMeshes.insert( make_pair( mesh->GetID(), mesh )); return; } - - if(theCommand->GetMethod() == "CreateMeshesFromMED") + if ( method == "CreateMeshesFromUNV" || method == "CreateMeshesFromSTL") + { + Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue() ); + myMeshes.insert( make_pair( mesh->GetID(), mesh )); + return; + } + if( method == "CreateMeshesFromMED") { for(int ind = 0;indGetNbResultValues();ind++) { @@ -327,14 +337,14 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) } // CreateHypothesis() - if ( theCommand->GetMethod() == "CreateHypothesis" ) + if ( method == "CreateHypothesis" ) { myHypos.push_back( _pyHypothesis::NewHypothesis( theCommand )); return; } // smeshgen.Compute( mesh, geom ) --> mesh.Compute() - if ( theCommand->GetMethod() == "Compute" ) + if ( method == "Compute" ) { const _pyID& meshID = theCommand->GetArg( 1 ); map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.find( meshID ); @@ -347,7 +357,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) } // leave only one smeshgen.GetPattern() in the script - if ( theCommand->GetMethod() == "GetPattern" ) { + if ( method == "GetPattern" ) { if ( myHasPattern ) { theCommand->Clear(); return; @@ -356,9 +366,14 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) } // Concatenate( [mesh1, ...], ... ) - if ( theCommand->GetMethod() == "Concatenate" || - theCommand->GetMethod() == "ConcatenateWithGroups") + if ( method == "Concatenate" || method == "ConcatenateWithGroups") { + if ( method == "ConcatenateWithGroups" ) { + theCommand->SetMethod( "Concatenate" ); + theCommand->SetArg( theCommand->GetNbArgs() + 1, "True" ); + } + Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue() ); + myMeshes.insert( make_pair( mesh->GetID(), mesh )); AddMeshAccessorMethod( theCommand ); } @@ -614,18 +629,17 @@ static bool sameGroupType( const _pyID& grpID, */ //================================================================================ -_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd): - _pyObject(theCreationCmd), myHasEditor(false) +_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd) + : _pyObject(theCreationCmd), myHasEditor(false) { // convert my creation command Handle(_pyCommand) creationCmd = GetCreationCmd(); - TCollection_AsciiString str = creationCmd->GetMethod(); - + //TCollection_AsciiString str = creationCmd->GetMethod(); +// if(str != "CreateMeshesFromUNV" && +// str != "CreateMeshesFromMED" && +// str != "CreateMeshesFromSTL") creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); - if(str != "CreateMeshesFromUNV" && - str != "CreateMeshesFromMED" && - str != "CreateMeshesFromSTL") - creationCmd->SetMethod( "Mesh" ); + creationCmd->SetMethod( "Mesh" ); theGen->SetAccessorMethod( GetID(), "GetMesh()" ); } @@ -898,8 +912,9 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", - "RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion", - "ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D","ExtrusionAlongPath", + "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D", + "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D", + "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject", "FindCoincidentNodes","FindCoincidentNodesOnPart","MergeNodes","FindEqualElements", "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", @@ -928,8 +943,8 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) // meshes made by *MakeMesh() methods are not wrapped by _pyMesh, // so let _pyMesh care of it (TMP?) - if ( theCommand->GetMethod().Search("MakeMesh") != -1 ) - _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod() +// if ( theCommand->GetMethod().Search("MakeMesh") != -1 ) +// _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod() } else { @@ -1718,8 +1733,22 @@ const TCollection_AsciiString & _pyCommand::GetObject() { // beginning int begPos = GetBegPos( RESULT_IND ) + myRes.Length(); - if ( begPos < 1 ) + if ( begPos < 1 ) { begPos = myString.Location( "=", 1, Length() ) + 1; + // is '=' in the string argument (for example, name) or not + int nb1 = 0; // number of ' character at the left of = + int nb2 = 0; // number of " character at the left of = + for ( int i = 1; i < begPos-1; i++ ) { + if ( IsEqual(myString.Value( i ), "'" ) ) + nb1 += 1; + else if ( IsEqual( myString.Value( i ), '"' ) ) + nb2 += 1; + } + // if number of ' or " is not divisible by 2, + // then get an object at the start of the command + if ( nb1 % 2 != 0 || nb2 % 2 != 0 ) + begPos = 1; + } // store myObj = GetWord( myString, begPos, true ); SetBegPos( OBJECT_IND, begPos ); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 99b24dccd..2af4dc18e 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1353,12 +1353,13 @@ SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements, CORBA::Double theAngleInRadians, CORBA::Long theNbOfSteps, CORBA::Double theTolerance, - const bool theMakeGroups) + const bool theMakeGroups, + const SMDSAbs_ElementType theElementType) { initData(); TIDSortedElemSet inElements, copyElements; - arrayToSet(theIDsOfElements, GetMeshDS(), inElements); + arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType); TIDSortedElemSet* workElements = & inElements; TPreviewMesh tmpMesh( SMDSAbs_Face ); @@ -1459,10 +1460,9 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject CORBA::Double theTolerance) { if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".RotationSweepObject( " - << theObject - << ", axis, " + << theObject << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1476,6 +1476,64 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject false); } +//======================================================================= +//function : RotationSweepObject1D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".RotationSweepObject1D( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false, + SMDSAbs_Edge); +} + +//======================================================================= +//function : RotationSweepObject2D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".RotationSweepObject2D( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false, + SMDSAbs_Face); +} + //======================================================================= //function : RotationSweepObjectMakeGroups //purpose : @@ -1496,12 +1554,77 @@ SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theO theTolerance, true); if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump<< this << ".RotationSweepObjectMakeGroups( " - << theObject - << ", axis, " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + return aGroups; +} + +//======================================================================= +//function : RotationSweepObject1DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true, + SMDSAbs_Edge); + if ( !myPreviewMode ) { + TPythonDump aPythonDump; + DumpGroupsList(aPythonDump,aGroups); + aPythonDump<< this << ".RotationSweepObject1DMakeGroups( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + return aGroups; +} + +//======================================================================= +//function : RotationSweepObject2DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true, + SMDSAbs_Face); + if ( !myPreviewMode ) { + TPythonDump aPythonDump; + DumpGroupsList(aPythonDump,aGroups); + aPythonDump<< this << ".RotationSweepObject2DMakeGroups( " + << theObject << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1579,9 +1702,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1597,9 +1719,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject1D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1615,9 +1736,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject2D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1655,11 +1775,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1677,11 +1796,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1699,11 +1817,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1840,7 +1957,8 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme CORBA::Boolean theHasRefPoint, const SMESH::PointStruct & theRefPoint, const bool theMakeGroups, - SMESH::SMESH_MeshEditor::Extrusion_Error & theError) + SMESH::SMESH_MeshEditor::Extrusion_Error & theError, + const SMDSAbs_ElementType theElementType) { initData(); @@ -1865,7 +1983,7 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme } TIDSortedElemSet elements; - arrayToSet(theIDsOfElements, GetMeshDS(), elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType); list angles; for (int i = 0; i < theAngles.length(); i++) { @@ -1953,24 +2071,18 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje 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 << ".ExtrusionAlongPathObject( " << theObject << ", " << 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; SMESH::long_array_var anElementsId = theObject->GetIDs(); @@ -1987,6 +2099,96 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje return anError; } +//======================================================================= +//function : ExtrusionAlongPathObject1D +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Extrusion_Error +SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array & theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct & theRefPoint) +{ + if ( !myPreviewMode ) { + TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; + SMESH::long_array_var anElementsId = theObject->GetIDs(); + extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError, + SMDSAbs_Edge); + return anError; +} + +//======================================================================= +//function : ExtrusionAlongPathObject2D +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Extrusion_Error +SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array & theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct & theRefPoint) +{ + if ( !myPreviewMode ) { + TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; + SMESH::long_array_var anElementsId = theObject->GetIDs(); + extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError, + SMDSAbs_Face); + return anError; +} + //======================================================================= //function : ExtrusionAlongPathMakeGroups @@ -2070,16 +2272,6 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, 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) { @@ -2096,8 +2288,124 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, << thePathShape << ", " << theNodeStart << ", " << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; + } + return aGroups; +} + +//======================================================================= +//function : ExtrusionAlongPathObject1DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* SMESH_MeshEditor_i:: +ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array& theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct& theRefPoint, + SMESH::SMESH_MeshEditor::Extrusion_Error& Error) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error, + SMDSAbs_Edge); + + if ( !myPreviewMode ) { + bool isDumpGroups = aGroups && aGroups->length() > 0; + TPythonDump aPythonDump; + if(isDumpGroups) { + aPythonDump << "("<GetIDs(); + SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error, + SMDSAbs_Face); + + if ( !myPreviewMode ) { + bool isDumpGroups = aGroups && aGroups->length() > 0; + TPythonDump aPythonDump; + if(isDumpGroups) { + aPythonDump << "("<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++) { @@ -541,9 +547,12 @@ void SMESH_NoteBook::ReplaceVariables() aStates->IncrementState(); } else if(aMethod.IsEqual("ExtrusionAlongPath") || + aMethod.IsEqual("ExtrusionAlongPathObject") || aMethod.IsEqual("ExtrusionAlongPathMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObjectMakeGroups") || /* workaround for a bug in the command parsing algorithm */ - aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1) { + aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObjectMakeGroups") != -1 ) { int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z" bool isSubstitute = false; int anArgIndex = 0; @@ -580,7 +589,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()) diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 9ba0fd56c..5a75e7eb4 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -161,7 +161,7 @@ def DegreesToRadians(AngleInDegrees): return AngleInDegrees * pi / 180.0 # Salome notebook variable separator -variable_separator = ":" +var_separator = ":" # Parametrized substitute for PointStruct class PointStructStr: @@ -294,34 +294,34 @@ class DirStructStr: # Returns list of variable values from salome notebook def ParsePointStruct(Point): - Parameters = "::" + Parameters = 2*var_separator if isinstance(Point, PointStructStr): - Parameters = str(Point.xStr) + ":" + str(Point.yStr) + ":" + str(Point.zStr) + Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr) Point = PointStruct(Point.x, Point.y, Point.z) return Point, Parameters # Returns list of variable values from salome notebook def ParseDirStruct(Dir): - Parameters = "::" + Parameters = 2*var_separator if isinstance(Dir, DirStructStr): pntStr = Dir.pointStruct 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) + Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator + Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator + Parameters += str(pntStr.z1Str) + var_separator + 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) + Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr) Point = PointStruct(pntStr.x, pntStr.y, pntStr.z) Dir = DirStruct(Point) return Dir, Parameters # Returns list of variable values from salome notebook def ParseAxisStruct(Axis): - Parameters = 5*variable_separator + Parameters = 5*var_separator if isinstance(Axis, AxisStructStr): - Parameters = str(Axis.xStr) + variable_separator + str(Axis.yStr) + variable_separator + str(Axis.zStr) + variable_separator - Parameters += str(Axis.dxStr) + variable_separator + str(Axis.dyStr) + variable_separator + str(Axis.dzStr) + Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator + Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr) Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz) return Axis, Parameters @@ -338,7 +338,7 @@ def ParseAngles(list): pass Parameters = Parameters + str(parameter) - Parameters = Parameters + ":" + Parameters = Parameters + var_separator pass Parameters = Parameters[:len(Parameters)-1] return Result, Parameters @@ -2431,7 +2431,7 @@ class Mesh: if TotalAngle and NbOfSteps: AngleInRadians /= NbOfSteps NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance) - Parameters = AxisParameters + ":" + AngleParameters + ":" + Parameters + Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis, @@ -2452,18 +2452,98 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweepObject(self, theObject, 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 ( isinstance( theObject, Mesh )): theObject = theObject.GetMesh() 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 + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) return [] + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject1D(self, theObject, 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 ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + 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 + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject2D(self, theObject, 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 ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + 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 + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + ## Generates new elements by extrusion of the elements with given ids # @param IDsOfElements the list of elements ids for extrusion # @param StepVector vector, defining the direction and value of extrusion @@ -2478,7 +2558,7 @@ class Mesh: StepVector = self.smeshpyD.GetDirStruct(StepVector) StepVector,StepVectorParameters = ParseDirStruct(StepVector) NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) - Parameters = StepVectorParameters + ":" + Parameters + Parameters = StepVectorParameters + var_separator + Parameters self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) @@ -2518,6 +2598,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) @@ -2535,6 +2619,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) @@ -2552,6 +2640,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) @@ -2590,7 +2682,7 @@ class Mesh: if HasAngles and Angles and LinearVariation: Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) pass - Parameters = AnglesParameters + ":" + RefPointParameters + Parameters = AnglesParameters + var_separator + RefPointParameters self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh, @@ -2620,6 +2712,8 @@ class Mesh: def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) if ( isinstance( theObject, Mesh )): theObject = theObject.GetMesh() if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): @@ -2629,6 +2723,8 @@ class Mesh: if HasAngles and Angles and LinearVariation: Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh, PathShape, NodeStart, HasAngles, @@ -2637,6 +2733,90 @@ class Mesh: NodeStart, HasAngles, Angles, HasRefPoint, RefPoint) + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + ## Creates a symmetrical copy of mesh elements # @param IDsOfElements list of elements ids # @param Mirror is AxisStruct or geom object(point, line, plane) @@ -2811,7 +2991,7 @@ class Mesh: if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) Axis,AxisParameters = ParseAxisStruct(Axis) - Parameters = AxisParameters + ":" + Parameters + Parameters = AxisParameters + var_separator + Parameters self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) @@ -2838,7 +3018,7 @@ class Mesh: if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) Axis,AxisParameters = ParseAxisStruct(Axis) - Parameters = AxisParameters + ":" + Parameters + Parameters = AxisParameters + var_separator + Parameters mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, MakeGroups, NewMeshName) mesh.SetParameters(Parameters) @@ -4351,7 +4531,7 @@ def ParseParameters(last, nbParams,nbParam, value): strResult=strResult+str(value) result = value if nbParams - 1 != counter: - strResult=strResult+variable_separator #":" + strResult=strResult+var_separator #":" counter = counter+1 return result, strResult