From 05883ebcaa7cad6128ad7075a6b79815fede4673 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 12 Nov 2007 10:01:09 +0000 Subject: [PATCH] PAL16842 (Genertion of groups when a mesh is transformed) add *MakeGroups() methods --- src/SMESH_I/SMESH_MeshEditor_i.cxx | 1140 ++++++++++++++++++++-------- src/SMESH_I/SMESH_MeshEditor_i.hxx | 197 ++++- 2 files changed, 978 insertions(+), 359 deletions(-) diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index c458ff041..c83334fa5 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -37,6 +37,7 @@ #include "SMESH_Gen_i.hxx" #include "SMESH_Filter_i.hxx" #include "SMESH_PythonDump.hxx" +#include "CASCatch.hxx" #include "utilities.h" @@ -197,6 +198,22 @@ namespace { } } }; + + TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType ) + { + TCollection_AsciiString typeStr; + switch ( theMirrorType ) { + case SMESH::SMESH_MeshEditor::POINT: + typeStr = "SMESH.SMESH_MeshEditor.POINT"; + break; + case SMESH::SMESH_MeshEditor::AXIS: + typeStr = "SMESH.SMESH_MeshEditor.AXIS"; + break; + default: + typeStr = "SMESH.SMESH_MeshEditor.PLANE"; + } + return typeStr; + } } //============================================================================= @@ -205,9 +222,10 @@ namespace { */ //============================================================================= -SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh, bool isPreview) +SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview) { - myMesh = theMesh; + myMesh_i = theMesh; + myMesh = & theMesh->GetImpl(); myPreviewMode = isPreview; } @@ -621,7 +639,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, bool stat = aMeshEditor.DeleteDiag ( n1, n2 ); - StoreResult(aMeshEditor); + storeResult(aMeshEditor); return stat; } @@ -686,10 +704,10 @@ namespace */ //================================================================================ - void ToMap(const SMESH::long_array & IDs, - const SMESHDS_Mesh* aMesh, - TIDSortedElemSet& aMap, - const SMDSAbs_ElementType aType = SMDSAbs_All ) + void arrayToSet(const SMESH::long_array & IDs, + const SMESHDS_Mesh* aMesh, + TIDSortedElemSet& aMap, + const SMDSAbs_ElementType aType = SMDSAbs_All ) { for (int i=0; i( SMESH_Gen_i::GetServant( Criterion ).in() ); @@ -734,7 +752,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle ); - StoreResult(anEditor); + storeResult(anEditor); return stat; } @@ -787,7 +805,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE SMESHDS_Mesh* aMesh = GetMeshDS(); TIDSortedElemSet faces; - ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face); + arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face); SMESH::NumericalFunctor_i* aNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( Criterion ).in() ); @@ -807,7 +825,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit ); - StoreResult(anEditor); + storeResult(anEditor); return stat; } @@ -858,7 +876,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle SMESHDS_Mesh* aMesh = GetMeshDS(); TIDSortedElemSet faces; - ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face); + arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face); // Update Python script TPythonDump() << "isDone = " << this << ".SplitQuad( " @@ -870,7 +888,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 ); - StoreResult(anEditor); + storeResult(anEditor); return stat; } @@ -1020,7 +1038,7 @@ CORBA::Boolean SMESHDS_Mesh* aMesh = GetMeshDS(); TIDSortedElemSet elements; - ToMap(IDsOfElements, aMesh, elements, SMDSAbs_Face); + arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face); set fixedNodes; for (int i = 0; i < IDsOfFixedNodes.length(); i++) { @@ -1037,7 +1055,7 @@ CORBA::Boolean anEditor.Smooth(elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio, IsParametric ); - StoreResult(anEditor); + storeResult(anEditor); // Update Python script TPythonDump() << "isDone = " << this << "." @@ -1127,22 +1145,37 @@ void SMESH_MeshEditor_i::RenumberElements() GetMeshDS()->Renumber( false ); } +//======================================================================= + /*! + * \brief Return groups by their IDs + */ +//======================================================================= + +SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list* groupIDs) +{ + if ( !groupIDs ) + return 0; + myMesh_i->CreateGroupServants(); + return myMesh_i->GetGroups( *groupIDs ); +} //======================================================================= -//function : RotationSweep -//purpose : +//function : rotationSweep +//purpose : //======================================================================= -void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, - CORBA::Double theAngleInRadians, - CORBA::Long theNbOfSteps, - CORBA::Double theTolerance) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance, + const bool theMakeGroups) { initData(); TIDSortedElemSet inElements, copyElements; - ToMap(theIDsOfElements, GetMeshDS(), inElements); + arrayToSet(theIDsOfElements, GetMeshDS(), inElements); TIDSortedElemSet* workElements = & inElements; TPreviewMesh tmpMesh( SMDSAbs_Face ); @@ -1165,13 +1198,26 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz )); ::SMESH_MeshEditor anEditor( mesh ); - anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians, - theNbOfSteps, theTolerance, makeWalls); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians, + theNbOfSteps, theTolerance, theMakeGroups, makeWalls); + storeResult(anEditor); + + return theMakeGroups ? getGroups(groupIds.get()) : 0; +} - StoreResult(anEditor); +//======================================================================= +//function : RotationSweep +//purpose : +//======================================================================= +void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ if ( !myPreviewMode ) { - // Update Python script TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".RotationSweep( " << theIDsOfElements @@ -1180,6 +1226,41 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement << theNbOfSteps << ", " << theTolerance << " )"; } + rotationSweep(theIDsOfElements, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false); +} + +//======================================================================= +//function : RotationSweepMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotationSweepMakeGroups( " + << theIDsOfElements + << ", axis, " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + return rotationSweep(theIDsOfElements, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true); } //======================================================================= @@ -1193,32 +1274,66 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject CORBA::Long theNbOfSteps, CORBA::Double theTolerance) { - initData(); - + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotationSweepObject( " + << theObject + << ", axis, " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } SMESH::long_array_var anElementsId = theObject->GetIDs(); - RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance); + rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false); +} - // Clear python line, created by RotationSweep() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +//======================================================================= +//function : RotationSweepObjectMakeGroups +//purpose : +//======================================================================= - // Update Python script - TPythonDump() << this << ".RotationSweepObject( " - << theObject - << ", axis, " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotationSweepObjectMakeGroups( " + << theObject + << ", axis, " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true); } + //======================================================================= -//function : ExtrusionSweep -//purpose : +//function : extrusionSweep +//purpose : //======================================================================= -void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements, - const SMESH::DirStruct & theStepVector, - CORBA::Long theNbOfSteps) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps, + const bool theMakeGroups, + const SMDSAbs_ElementType theElementType) { initData(); @@ -1228,24 +1343,20 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen #else CASCatch_TRY { #endif - SMESHDS_Mesh* aMesh = GetMeshDS(); - TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType); const SMESH::PointStruct * P = &theStepVector.PS; gp_Vec stepVec( P->x, P->y, P->z ); TElemOfElemListMap aHystory; ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups); - StoreResult(anEditor); + storeResult(anEditor); - // Update Python script - TPythonDump() << "stepVector = " << theStepVector; - TPythonDump() << this << ".ExtrusionSweep( " - << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + return theMakeGroups ? getGroups(groupIds.get()) : 0; #ifdef NO_CAS_CATCH } catch(Standard_Failure) { @@ -1255,6 +1366,24 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen Handle(Standard_Failure) aFail = Standard_Failure::Caught(); INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() ); } + return 0; +} + +//======================================================================= +//function : ExtrusionSweep +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweep( " + << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + } } @@ -1267,18 +1396,13 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec const SMESH::DirStruct & theStepVector, CORBA::Long theNbOfSteps) { - initData(); - SMESH::long_array_var anElementsId = theObject->GetIDs(); - ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps); - - // Clear python line, created by ExtrusionSweep() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); - - // Update Python script - TPythonDump() << this << ".ExtrusionSweepObject( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false ); + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObject( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; + } } //======================================================================= @@ -1290,66 +1414,139 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj const SMESH::DirStruct & theStepVector, CORBA::Long theNbOfSteps) { - initData(); + 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 << " )"; + } +} - SMESHDS_Mesh* aMesh = GetMeshDS(); +//======================================================================= +//function : ExtrusionSweepObject2D +//purpose : +//======================================================================= - SMESH::long_array_var allElementsId = theObject->GetIDs(); +void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + 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 << " )"; + } +} - TIDSortedElemSet elements; - ToMap(allElementsId, aMesh, elements); +//======================================================================= +//function : ExtrusionSweepMakeGroups +//purpose : +//======================================================================= - const SMESH::PointStruct * P = &theStepVector.PS; - gp_Vec stepVec( P->x, P->y, P->z ); +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) +{ + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepMakeGroups( " + << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + } + return extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true ); +} +//======================================================================= +//function : ExtrusionSweepObjectMakeGroups +//purpose : +//======================================================================= - ::SMESH_MeshEditor anEditor( myMesh ); - //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); - TElemOfElemListMap aHystory; - anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) +{ + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObjectMakeGroups( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true ); +} - StoreResult(anEditor); +//======================================================================= +//function : ExtrusionSweepObject1DMakeGroups +//purpose : +//======================================================================= - // Update Python script - TPythonDump() << "stepVector = " << theStepVector; - TPythonDump() << this << ".ExtrusionSweepObject1D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) +{ + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObject1DMakeGroups( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge ); } //======================================================================= -//function : ExtrusionSweepObject2D -//purpose : +//function : ExtrusionSweepObject2DMakeGroups +//purpose : //======================================================================= -void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, - const SMESH::DirStruct & theStepVector, - CORBA::Long theNbOfSteps) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) { - initData(); + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObject2DMakeGroups( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face ); +} - SMESHDS_Mesh* aMesh = GetMeshDS(); - SMESH::long_array_var allElementsId = theObject->GetIDs(); +//======================================================================= +//function : advancedExtrusion +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps, + CORBA::Long theExtrFlags, + CORBA::Double theSewTolerance, + const bool theMakeGroups) +{ + initData(); TIDSortedElemSet elements; - ToMap(allElementsId, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements); const SMESH::PointStruct * P = &theStepVector.PS; gp_Vec stepVec( P->x, P->y, P->z ); ::SMESH_MeshEditor anEditor( myMesh ); - //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); TElemOfElemListMap aHystory; - anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); - - StoreResult(anEditor); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, + theMakeGroups, theExtrFlags, theSewTolerance); + storeResult(anEditor); - // Update Python script - TPythonDump() << "stepVector = " << theStepVector; - TPythonDump() << this << ".ExtrusionSweepObject2D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + return theMakeGroups ? getGroups(groupIds.get()) : 0; } - //======================================================================= //function : AdvancedExtrusion //purpose : @@ -1361,34 +1558,59 @@ void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfEle CORBA::Long theExtrFlags, CORBA::Double theSewTolerance) { - initData(); - - SMESHDS_Mesh* aMesh = GetMeshDS(); - - TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); - - const SMESH::PointStruct * P = &theStepVector.PS; - gp_Vec stepVec( P->x, P->y, P->z ); - - ::SMESH_MeshEditor anEditor( myMesh ); - TElemOfElemListMap aHystory; - anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, - theExtrFlags, theSewTolerance); + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".AdvancedExtrusion(" + << theIDsOfElements + << ", stepVector, " + << theNbOfSteps << "," + << theExtrFlags << ", " + << theSewTolerance << " )"; + } + advancedExtrusion( theIDsOfElements, + theStepVector, + theNbOfSteps, + theExtrFlags, + theSewTolerance, + false); +} - StoreResult(anEditor); +//======================================================================= +//function : AdvancedExtrusionMakeGroups +//purpose : +//======================================================================= - // Update Python script - TPythonDump() << "stepVector = " << theStepVector; - TPythonDump() << this << ".AdvancedExtrusion(" - << theIDsOfElements - << ", stepVector, " - << theNbOfSteps << "," - << theExtrFlags << ", " - << theSewTolerance << " )"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps, + CORBA::Long theExtrFlags, + CORBA::Double theSewTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".AdvancedExtrusionMakeGroups(" + << theIDsOfElements + << ", stepVector, " + << theNbOfSteps << "," + << theExtrFlags << ", " + << theSewTolerance << " )"; + } + return advancedExtrusion( theIDsOfElements, + theStepVector, + theNbOfSteps, + theExtrFlags, + theSewTolerance, + true); } +//================================================================================ +/*! + * \brief Convert extrusion error to IDL enum + */ +//================================================================================ + #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm; static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e ) @@ -1405,41 +1627,48 @@ static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_Mesh return SMESH::SMESH_MeshEditor::EXTR_OK; } + //======================================================================= -//function : ExtrusionAlongPath -//purpose : +//function : extrusionAlongPath +//purpose : //======================================================================= -SMESH::SMESH_MeshEditor::Extrusion_Error - SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements, - 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::ListOfGroups* +SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements, + 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, + const bool theMakeGroups, + SMESH::SMESH_MeshEditor::Extrusion_Error & theError) { initData(); - SMESHDS_Mesh* aMesh = GetMeshDS(); - - if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) - return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE; + if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) { + theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE; + return 0; + } + SMESH_Mesh_i* aMeshImp = SMESH::DownCast( thePathMesh ); - SMESH_Mesh_i* aMeshImp = dynamic_cast( SMESH_Gen_i::GetServant( thePathMesh ).in() ); TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape ); SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape ); - if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) - return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE; + if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) { + theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE; + return 0; + } SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart); - if ( !nodeStart ) - return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE; + if ( !nodeStart ) { + theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE; + return 0; + } TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements); list angles; for (int i = 0; i < theAngles.length(); i++) { @@ -1448,35 +1677,73 @@ SMESH::SMESH_MeshEditor::Extrusion_Error gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z ); - // Update Python script - TPythonDump() << "rotAngles = " << theAngles; - - if ( theHasRefPoint ) - TPythonDump() << "refPoint = SMESH.PointStruct( " - << refPnt.X() << ", " - << refPnt.Y() << ", " - << refPnt.Z() << " )"; - else - TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; - - TPythonDump() << "error = " << this << ".ExtrusionAlongPath( " - << theIDsOfElements << ", " - << thePathMesh << ", " - << thePathShape << ", " - << theNodeStart << ", " - << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + int nbOldGroups = myMesh->NbGroup(); ::SMESH_MeshEditor anEditor( myMesh ); - SMESH::SMESH_MeshEditor::Extrusion_Error error = - convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, - theHasAngles, angles, - theHasRefPoint, refPnt ) ); + ::SMESH_MeshEditor::Extrusion_Error error = + anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, + theHasAngles, angles, + theHasRefPoint, refPnt, theMakeGroups ); + storeResult(anEditor); + theError = convExtrError( error ); + + if ( theMakeGroups ) { + list groupIDs = myMesh->GetGroupIds(); + list::iterator newBegin = groupIDs.begin(); + std::advance( newBegin, nbOldGroups ); // skip old groups + groupIDs.erase( groupIDs.begin(), newBegin ); + return getGroups( & groupIDs ); + } + return 0; +} + +//======================================================================= +//function : ExtrusionAlongPath +//purpose : +//======================================================================= - StoreResult(anEditor); +SMESH::SMESH_MeshEditor::Extrusion_Error + SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements, + 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() << "rotAngles = " << theAngles; - return error; + 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 )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; + extrusionAlongPath( theIDsOfElements, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError); + return anError; } //======================================================================= @@ -1494,29 +1761,137 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje CORBA::Boolean theHasRefPoint, const SMESH::PointStruct & theRefPoint) { - initData(); + 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 )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; SMESH::long_array_var anElementsId = theObject->GetIDs(); - SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath - (anElementsId, thePathMesh, thePathShape, theNodeStart, - theHasAngles, theAngles, theHasRefPoint, theRefPoint); + extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError); + return anError; +} - // Clear python line, created by ExtrusionAlongPath() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); - // Update Python script - TPythonDump() << "rotAngles = " << theAngles; - TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( " - << theObject << ", " - << thePathMesh << ", " - << thePathShape << ", " - << theNodeStart << ", " - << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint<<", refPoint )"; +//======================================================================= +//function : ExtrusionAlongPathMakeGroups +//purpose : +//======================================================================= - return error; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements, + 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) +{ + 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() << "groups = " << this << ".ExtrusionAlongPathMakeGroups( " + << theIDsOfElements << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << "rotAngles" << ", " + << theHasRefPoint << ", refPoint )"; + } + return extrusionAlongPath( theIDsOfElements, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error); +} + +//======================================================================= +//function : ExtrusionAlongPathObjectMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* SMESH_MeshEditor_i:: +ExtrusionAlongPathObjectMakeGroups(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) +{ + 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() << "groups = " << this << ".ExtrusionAlongPathObjectMakeGroups( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << "rotAngles" << ", " + << theHasRefPoint << ", refPoint )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error); } //================================================================================ @@ -1539,55 +1914,67 @@ SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMes return aResult._retn(); } + //======================================================================= -//function : Mirror -//purpose : +//function : mirror +//purpose : //======================================================================= -void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, - SMESH::SMESH_MeshEditor::MirrorType theMirrorType, - CORBA::Boolean theCopy) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::mirror(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType, + CORBA::Boolean theCopy, + const bool theMakeGroups) { initData(); - SMESHDS_Mesh* aMesh = GetMeshDS(); - TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements); gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z ); gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); gp_Trsf aTrsf; - TCollection_AsciiString typeStr; switch ( theMirrorType ) { case SMESH::SMESH_MeshEditor::POINT: aTrsf.SetMirror( P ); - typeStr = "SMESH.SMESH_MeshEditor.POINT"; break; case SMESH::SMESH_MeshEditor::AXIS: aTrsf.SetMirror( gp_Ax1( P, V )); - typeStr = "SMESH.SMESH_MeshEditor.AXIS"; break; default: aTrsf.SetMirror( gp_Ax2( P, V )); - typeStr = "SMESH.SMESH_MeshEditor.PLANE"; } - // Update Python script - TPythonDump() << this << ".Mirror( " - << theIDsOfElements << ", " - << theAxis << ", " - << typeStr << ", " - << theCopy << " )"; - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.Transform (elements, aTrsf, theCopy); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups); if(theCopy) { - StoreResult(anEditor); + storeResult(anEditor); + } + return theMakeGroups ? getGroups(groupIds.get()) : 0; +} + +//======================================================================= +//function : Mirror +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType, + CORBA::Boolean theCopy) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".Mirror( " + << theIDsOfElements << ", " + << theAxis << ", " + << mirrorTypeName(theMirrorType) << ", " + << theCopy << " )"; } + mirror(theIDsOfElements, theAxis, theMirrorType, theCopy, false); } @@ -1601,68 +1988,107 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj SMESH::SMESH_MeshEditor::MirrorType theMirrorType, CORBA::Boolean theCopy) { - initData(); - + if ( !myPreviewMode ) { + TPythonDump() << this << ".MirrorObject( " + << theObject << ", " + << theAxis << ", " + << mirrorTypeName(theMirrorType) << ", " + << theCopy << " )"; + } SMESH::long_array_var anElementsId = theObject->GetIDs(); - Mirror(anElementsId, theAxis, theMirrorType, theCopy); + mirror(anElementsId, theAxis, theMirrorType, theCopy, false); +} - // Clear python line, created by Mirror() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +//======================================================================= +//function : MirrorMakeGroups +//purpose : +//======================================================================= - // Update Python script - TCollection_AsciiString typeStr; - switch ( theMirrorType ) { - case SMESH::SMESH_MeshEditor::POINT: - typeStr = "SMESH.SMESH_MeshEditor.POINT"; - break; - case SMESH::SMESH_MeshEditor::AXIS: - typeStr = "SMESH.SMESH_MeshEditor.AXIS"; - break; - default: - typeStr = "SMESH.SMESH_MeshEditor.PLANE"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::AxisStruct& theMirror, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".MirrorMakeGroups( " + << theIDsOfElements << ", " + << theMirror << ", " + << mirrorTypeName(theMirrorType) << " )"; } - TPythonDump() << "axis = " << theAxis; - TPythonDump() << this << ".MirrorObject( " - << theObject << ", " - << "axis, " - << typeStr << ", " - << theCopy << " )"; + return mirror(theIDsOfElements, theMirror, theMirrorType, true, true); } //======================================================================= -//function : Translate -//purpose : +//function : MirrorObjectMakeGroups +//purpose : //======================================================================= -void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, - const SMESH::DirStruct & theVector, - CORBA::Boolean theCopy) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theMirror, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType) { - initData(); + if ( !myPreviewMode ) { + TPythonDump() << this << ".MirrorObjectMakeGroups( " + << theObject << ", " + << theMirror << ", " + << mirrorTypeName(theMirrorType) << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return mirror(anElementsId, theMirror, theMirrorType, true, true); +} - SMESHDS_Mesh* aMesh = GetMeshDS(); + +//======================================================================= +//function : translate +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::translate(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theVector, + CORBA::Boolean theCopy, + const bool theMakeGroups) +{ + initData(); TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements); gp_Trsf aTrsf; const SMESH::PointStruct * P = &theVector.PS; aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z )); ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.Transform (elements, aTrsf, theCopy); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups); - if(theCopy) { - StoreResult(anEditor); - } + if(theCopy) + storeResult(anEditor); - // Update Python script - TPythonDump() << "vector = " << theVector; - TPythonDump() << this << ".Translate( " - << theIDsOfElements - << ", vector, " - << theCopy << " )"; + return theMakeGroups ? getGroups(groupIds.get()) : 0; +} + +//======================================================================= +//function : Translate +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theVector, + CORBA::Boolean theCopy) +{ + if ( !myPreviewMode ) { + TPythonDump() << "vector = " << theVector; + TPythonDump() << this << ".Translate( " + << theIDsOfElements + << ", vector, " + << theCopy << " )"; + } + translate(theIDsOfElements, + theVector, + theCopy, + false); } //======================================================================= @@ -1674,38 +2100,71 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, const SMESH::DirStruct & theVector, CORBA::Boolean theCopy) { - initData(); - + if ( !myPreviewMode ) { + TPythonDump() << this << ".TranslateObject( " + << theObject + << ", vector, " + << theCopy << " )"; + } SMESH::long_array_var anElementsId = theObject->GetIDs(); - Translate(anElementsId, theVector, theCopy); + translate(anElementsId, + theVector, + theCopy, + false); +} - // Clear python line, created by Translate() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +//======================================================================= +//function : TranslateMakeGroups +//purpose : +//======================================================================= - // Update Python script - TPythonDump() << this << ".TranslateObject( " - << theObject - << ", vector, " - << theCopy << " )"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::DirStruct& theVector) +{ + if ( !myPreviewMode ) { + TPythonDump() << "vector = " << theVector; + TPythonDump() << this << ".TranslateMakeGroups( " + << theIDsOfElements + << ", vector )"; + } + return translate(theIDsOfElements,theVector,true,true); } //======================================================================= -//function : Rotate -//purpose : +//function : TranslateObjectMakeGroups +//purpose : //======================================================================= -void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, - CORBA::Double theAngle, - CORBA::Boolean theCopy) +SMESH::ListOfGroups* +SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct& theVector) { - initData(); + if ( !myPreviewMode ) { + TPythonDump() << this << ".TranslateObjectMakeGroups( " + << theObject + << ", vector )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return translate(anElementsId, theVector, true, true); +} - SMESHDS_Mesh* aMesh = GetMeshDS(); +//======================================================================= +//function : rotate +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::rotate(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngle, + CORBA::Boolean theCopy, + const bool theMakeGroups) +{ + initData(); TIDSortedElemSet elements; - ToMap(theIDsOfElements, aMesh, elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements); gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z ); gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); @@ -1714,19 +2173,38 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, aTrsf.SetRotation( gp_Ax1( P, V ), theAngle); ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.Transform (elements, aTrsf, theCopy); + ::SMESH_MeshEditor::PGroupIDs groupIds = + anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups); if(theCopy) { - StoreResult(anEditor); + storeResult(anEditor); } + return theMakeGroups ? getGroups(groupIds.get()) : 0; +} - // Update Python script - TPythonDump() << "axis = " << theAxis; - TPythonDump() << this << ".Rotate( " - << theIDsOfElements - << ", axis, " - << theAngle << ", " - << theCopy << " )"; +//======================================================================= +//function : Rotate +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngle, + CORBA::Boolean theCopy) +{ + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".Rotate( " + << theIDsOfElements + << ", axis, " + << theAngle << ", " + << theCopy << " )"; + } + rotate(theIDsOfElements, + theAxis, + theAngle, + theCopy, + false); } //======================================================================= @@ -1739,21 +2217,61 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, CORBA::Double theAngle, CORBA::Boolean theCopy) { - initData(); - + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotateObject( " + << theObject + << ", axis, " + << theAngle << ", " + << theCopy << " )"; + } SMESH::long_array_var anElementsId = theObject->GetIDs(); - Rotate(anElementsId, theAxis, theAngle, theCopy); + rotate(anElementsId, + theAxis, + theAngle, + theCopy, + false); +} - // Clear python line, created by Rotate() - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +//======================================================================= +//function : RotateMakeGroups +//purpose : +//======================================================================= - // Update Python script - TPythonDump() << this << ".RotateObject( " - << theObject - << ", axis, " - << theAngle << ", " - << theCopy << " )"; +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngle) +{ + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotateMakeGroups( " + << theIDsOfElements + << ", axis, " + << theAngle << " )"; + } + return rotate(theIDsOfElements,theAxis,theAngle,true,true); +} + +//======================================================================= +//function : RotateObjectMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngle) +{ + if ( !myPreviewMode ) { + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotateObjectMakeGroups( " + << theObject + << ", axis, " + << theAngle << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return rotate(anElementsId,theAxis,theAngle,true,true); } //======================================================================= @@ -1777,12 +2295,11 @@ void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tol for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) { list< const SMDS_MeshNode* >& aListOfNodes = *llIt; list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();; - SMESH::long_array& aGroup = GroupsOfNodes[ i ]; + SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ]; aGroup.length( aListOfNodes.size() ); for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ ) aGroup[ j ] = (*lIt)->GetID(); } - // Update Python script TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( " << Tolerance << " )"; } @@ -1834,12 +2351,11 @@ void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) { list< const SMDS_MeshNode* >& aListOfNodes = *llIt; list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();; - SMESH::long_array& aGroup = GroupsOfNodes[ i ]; + SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ]; aGroup.length( aListOfNodes.size() ); for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ ) aGroup[ j ] = (*lIt)->GetID(); } - // Update Python script TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( " <MoveNode(node, x, y, z); // fill preview data ::SMESH_MeshEditor anEditor( & tmpMesh ); - StoreResult( anEditor ); + storeResult( anEditor ); } else { @@ -2042,7 +2554,6 @@ CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x, } if ( !myPreviewMode ) { - // Update Python script TPythonDump() << "nodeID = " << this << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z << " )"; } @@ -2109,7 +2620,6 @@ SMESH::SMESH_MeshEditor::Sew_Error !aSide2ThirdNode) return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; - // Update Python script TPythonDump() << "error = " << this << ".SewFreeBorders( " << FirstNodeID1 << ", " << SecondNodeID1 << ", " @@ -2132,7 +2642,7 @@ SMESH::SMESH_MeshEditor::Sew_Error CreatePolygons, CreatePolyedrs) ); - StoreResult(anEditor); + storeResult(anEditor); return error; } @@ -2169,7 +2679,6 @@ SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, !aSide2SecondNode) return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; - // Update Python script TPythonDump() << "error = " << this << ".SewConformFreeBorders( " << FirstNodeID1 << ", " << SecondNodeID1 << ", " @@ -2188,7 +2697,7 @@ SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, true, false, false) ); - StoreResult(anEditor); + storeResult(anEditor); return error; } @@ -2227,7 +2736,6 @@ SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, !aSide2SecondNode) return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES; - // Update Python script TPythonDump() << "error = " << this << ".SewBorderToSide( " << FirstNodeIDOnFreeBorder << ", " << SecondNodeIDOnFreeBorder << ", " @@ -2249,7 +2757,7 @@ SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, CreatePolygons, CreatePolyedrs) ); - StoreResult(anEditor); + storeResult(anEditor); return error; } @@ -2285,10 +2793,9 @@ SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES; TIDSortedElemSet aSide1Elems, aSide2Elems; - ToMap(IDsOfSide1Elements, aMesh, aSide1Elems); - ToMap(IDsOfSide2Elements, aMesh, aSide2Elems); + arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems); + arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems); - // Update Python script TPythonDump() << "error = " << this << ".SewSideElements( " << IDsOfSide1Elements << ", " << IDsOfSide2Elements << ", " @@ -2305,7 +2812,7 @@ SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, aSecondNode1ToMerge, aSecondNode2ToMerge)); - StoreResult(anEditor); + storeResult(anEditor); return error; } @@ -2329,7 +2836,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide, int nbn = newIDs.length(); int i=0; - const SMDS_MeshNode* aNodes [nbn]; + vector aNodes(nbn); int nbn1=-1; for(; iFindNode(newIDs[i]); @@ -2338,14 +2845,13 @@ CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide, aNodes[nbn1] = aNode; } } - // Update Python script TPythonDump() << "isDone = " << this << ".ChangeElemNodes( " << ide << ", " << newIDs << " )"; #ifdef _DEBUG_ TPythonDump() << "print 'ChangeElemNodes: ', isDone"; #endif - return GetMeshDS()->ChangeElementNodes( elem, aNodes, nbn1+1 ); + return GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 ); } //================================================================================ @@ -2355,7 +2861,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide, */ //================================================================================ -void SMESH_MeshEditor_i::StoreResult(::SMESH_MeshEditor& anEditor) +void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor) { if ( myPreviewMode ) { // --- MeshPreviewStruct filling --- @@ -2492,20 +2998,18 @@ void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d) { ::SMESH_MeshEditor anEditor( myMesh ); anEditor.ConvertToQuadratic(theForce3d); - // Update Python script TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )"; } //======================================================================= //function : ConvertFromQuadratic -//purpose : +//purpose : //======================================================================= CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic() { ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean isDone = anEditor.ConvertFromQuadratic(); - // Update Python script TPythonDump() << this << ".ConvertFromQuadratic()"; return isDone; } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 7e8dff39c..e8dbd38fc 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -34,12 +34,15 @@ #include "SMESH_Mesh.hxx" +#include + class SMESH_MeshEditor; +class SMESH_Mesh_i; class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor { public: - SMESH_MeshEditor_i(SMESH_Mesh * theMesh, bool isPreview); + SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview); virtual ~ SMESH_MeshEditor_i(); @@ -202,14 +205,76 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Double Angle, CORBA::Boolean Copy); + SMESH::ListOfGroups* RotationSweepMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::AxisStruct& Axix, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + SMESH::ListOfGroups* RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::AxisStruct& Axix, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + SMESH::ListOfGroups* ExtrusionSweepMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::DirStruct& StepVector, + CORBA::Long NbOfSteps); + SMESH::ListOfGroups* AdvancedExtrusionMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::DirStruct& StepVector, + CORBA::Long NbOfSteps, + CORBA::Long ExtrFlags, + CORBA::Double SewTolerance); + SMESH::ListOfGroups* ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::DirStruct& StepVector, + CORBA::Long NbOfSteps); + SMESH::ListOfGroups* ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::DirStruct& StepVector, + CORBA::Long NbOfSteps); + SMESH::ListOfGroups* ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::DirStruct& StepVector, + CORBA::Long NbOfSteps); + SMESH::ListOfGroups* ExtrusionAlongPathMakeGroups(const SMESH::long_array& IDsOfElements, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array& Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct& RefPoint, + SMESH::SMESH_MeshEditor::Extrusion_Error& Error); + SMESH::ListOfGroups* ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array& Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct& RefPoint, + SMESH::SMESH_MeshEditor::Extrusion_Error& Error); + SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::AxisStruct& Mirror, + SMESH::SMESH_MeshEditor::MirrorType MirrorType); + SMESH::ListOfGroups* MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::AxisStruct& Mirror, + SMESH::SMESH_MeshEditor::MirrorType MirrorType); + SMESH::ListOfGroups* TranslateMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::DirStruct& Vector); + SMESH::ListOfGroups* TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::DirStruct& Vector); + SMESH::ListOfGroups* RotateMakeGroups(const SMESH::long_array& IDsOfElements, + const SMESH::AxisStruct& Axis, + CORBA::Double AngleInRadians); + SMESH::ListOfGroups* RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::AxisStruct& Axis, + CORBA::Double AngleInRadians); + void FindCoincidentNodes (CORBA::Double Tolerance, SMESH::array_of_long_array_out GroupsOfNodes); - void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject, + void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr Object, CORBA::Double Tolerance, SMESH::array_of_long_array_out GroupsOfNodes); void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes); - void FindEqualElements(SMESH::SMESH_IDSource_ptr theObject, - SMESH::array_of_long_array_out GroupsOfElementsID); + void FindEqualElements(SMESH::SMESH_IDSource_ptr Object, + SMESH::array_of_long_array_out GroupsOfElementsID); void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID); void MergeEqualElements(); CORBA::Long MoveClosestNodeToPoint(CORBA::Double x, @@ -220,35 +285,35 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor SMESH::SMESH_MeshEditor::Sew_Error - SewFreeBorders(CORBA::Long FirstNodeID1, - CORBA::Long SecondNodeID1, - CORBA::Long LastNodeID1, - CORBA::Long FirstNodeID2, - CORBA::Long SecondNodeID2, - CORBA::Long LastNodeID2, - CORBA::Boolean CreatePolygons, - CORBA::Boolean CreatePolyedrs); + SewFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2, + CORBA::Long LastNodeID2, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs); SMESH::SMESH_MeshEditor::Sew_Error - SewConformFreeBorders(CORBA::Long FirstNodeID1, - CORBA::Long SecondNodeID1, - CORBA::Long LastNodeID1, - CORBA::Long FirstNodeID2, - CORBA::Long SecondNodeID2); + SewConformFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2); SMESH::SMESH_MeshEditor::Sew_Error - SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, - CORBA::Long SecondNodeIDOnFreeBorder, - CORBA::Long LastNodeIDOnFreeBorder, - CORBA::Long FirstNodeIDOnSide, - CORBA::Long LastNodeIDOnSide, - CORBA::Boolean CreatePolygons, - CORBA::Boolean CreatePolyedrs); + SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, + CORBA::Long SecondNodeIDOnFreeBorder, + CORBA::Long LastNodeIDOnFreeBorder, + CORBA::Long FirstNodeIDOnSide, + CORBA::Long LastNodeIDOnSide, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs); SMESH::SMESH_MeshEditor::Sew_Error - SewSideElements(const SMESH::long_array& IDsOfSide1Elements, - const SMESH::long_array& IDsOfSide2Elements, - CORBA::Long NodeID1OfSide1ToMerge, - CORBA::Long NodeID1OfSide2ToMerge, - CORBA::Long NodeID2OfSide1ToMerge, - CORBA::Long NodeID2OfSide2ToMerge); + SewSideElements(const SMESH::long_array& IDsOfSide1Elements, + const SMESH::long_array& IDsOfSide2Elements, + CORBA::Long NodeID1OfSide1ToMerge, + CORBA::Long NodeID1OfSide2ToMerge, + CORBA::Long NodeID2OfSide1ToMerge, + CORBA::Long NodeID2OfSide2ToMerge); /*! * Set new nodes for given element. @@ -276,27 +341,77 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor */ SMESH::long_array* GetLastCreatedElems(); - // - // Internal methods - // - - /*! - * \brief Update myLastCreated* or myPreviewData - * \param anEditor - it contains edition results - */ - void StoreResult(::SMESH_MeshEditor& anEditor); - /*! * \brief Return edited mesh ID * \retval int - mesh ID */ int GetMeshId() const { return myMesh->GetId(); } - private: + +private: //!< private methods SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); } + + /*! + * \brief Update myLastCreated* or myPreviewData + * \param anEditor - it contains edition results + */ + void storeResult(::SMESH_MeshEditor& anEditor); + /*! + * \brief Clear myLastCreated* or myPreviewData + */ void initData(); + /*! + * \brief Return groups by their IDs + */ + SMESH::ListOfGroups* getGroups(const std::list* groupIDs); + + SMESH::ListOfGroups* rotationSweep(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance, + const bool MakeGroups); + SMESH::ListOfGroups* extrusionSweep(const SMESH::long_array & IDsOfElements, + const SMESH::DirStruct & StepVector, + CORBA::Long NbOfSteps, + const bool MakeGroups, + const SMDSAbs_ElementType ElementType=SMDSAbs_All); + SMESH::ListOfGroups* advancedExtrusion(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps, + CORBA::Long theExtrFlags, + CORBA::Double theSewTolerance, + const bool MakeGroups); + SMESH::ListOfGroups* extrusionAlongPath(const SMESH::long_array & IDsOfElements, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array & Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct & RefPoint, + const bool MakeGroups, + SMESH::SMESH_MeshEditor::Extrusion_Error & Error); + SMESH::ListOfGroups* mirror(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + SMESH::SMESH_MeshEditor::MirrorType MirrorType, + CORBA::Boolean Copy, + const bool MakeGroups); + SMESH::ListOfGroups* translate(const SMESH::long_array & IDsOfElements, + const SMESH::DirStruct & Vector, + CORBA::Boolean Copy, + const bool MakeGroups); + SMESH::ListOfGroups* rotate(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + CORBA::Double Angle, + CORBA::Boolean Copy, + const bool MakeGroups); + +private: //!< fields + + SMESH_Mesh_i* myMesh_i; SMESH_Mesh * myMesh; SMESH::long_array_var myLastCreatedElems; -- 2.39.2