-SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::AxisStruct& theAxis,
- CORBA::Double theAngleInRadians,
- CORBA::Long theNbOfSteps,
- CORBA::Double theTolerance)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
- theAxis,
- theAngleInRadians,
- theNbOfSteps,
- theTolerance,
- true,
- SMDSAbs_Edge);
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".RotationSweepObject1DMakeGroups( "
- << theObject << ", "
- << theAxis << ", "
- << TVar( theAngleInRadians ) << ", "
- << TVar( theNbOfSteps ) << ", "
- << TVar( 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)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
- theAxis,
- theAngleInRadians,
- theNbOfSteps,
- theTolerance,
- true,
- SMDSAbs_Face);
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".RotationSweepObject2DMakeGroups( "
- << theObject << ", "
- << theAxis << ", "
- << TVar( theAngleInRadians ) << ", "
- << TVar( theNbOfSteps ) << ", "
- << TVar( theTolerance ) << " )";
- }
- return aGroups;
-}
-
-
-//=======================================================================
-//function : extrusionSweep
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps,
- bool theMakeGroups,
- const SMDSAbs_ElementType theElementType)
- throw (SALOME::SALOME_Exception)
-{
- SMESH_TRY;
- initData();
-
- TIDSortedElemSet elements, copyElements;
- arrayToSet(theIDsOfElements, getMeshDS(), elements, theElementType);
-
- const SMESH::PointStruct * P = &theStepVector.PS;
- gp_Vec stepVec( P->x, P->y, P->z );
-
- TIDSortedElemSet* workElements = & elements;
-
- SMDSAbs_ElementType aType = SMDSAbs_Face;
- if (theElementType == SMDSAbs_Node)
- {
- aType = SMDSAbs_Edge;
- }
- if ( myIsPreviewMode ) {
- SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
- getPreviewMesh( aType )->Copy( elements, copyElements, select, avoid );
- workElements = & copyElements;
- theMakeGroups = false;
- }
-
- TElemOfElemListMap aHystory;
- ::SMESH_MeshEditor::PGroupIDs groupIds =
- getEditor().ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
-
- declareMeshModified( /*isReComputeSafe=*/true ); // does not influence Compute()
-
- return theMakeGroups ? getGroups(groupIds.get()) : 0;
-
- SMESH_CATCH( SMESH::throwCorbaException );
- return 0;
-}
-
-//=======================================================================
-//function : ExtrusionSweep
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
- if (!myIsPreviewMode) {
- TPythonDump() << this << ".ExtrusionSweep( "
- << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps) << " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweep0D
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweep0D(const SMESH::long_array & theIDsOfElements,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
- if (!myIsPreviewMode) {
- TPythonDump() << this << ".ExtrusionSweep0D( "
- << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps)<< " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
- if (!myIsPreviewMode) {
- TPythonDump() << this << ".ExtrusionSweepObject( "
- << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject0D
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
- if ( !myIsPreviewMode ) {
- TPythonDump() << this << ".ExtrusionSweepObject0D( "
- << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject1D
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
- if ( !myIsPreviewMode ) {
- TPythonDump() << this << ".ExtrusionSweepObject1D( "
- << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject2D
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
- if ( !myIsPreviewMode ) {
- TPythonDump() << this << ".ExtrusionSweepObject2D( "
- << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
-}
-
-//=======================================================================
-//function : ExtrusionSweepMakeGroups
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true);
-
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements
- << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )";
- }
- return aGroups;
-}
-
-//=======================================================================
-//function : ExtrusionSweepMakeGroups0D
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepMakeGroups0D(const SMESH::long_array& theIDsOfElements,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true,SMDSAbs_Node);
-
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepMakeGroups0D( " << theIDsOfElements
- << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )";
- }
- return aGroups;
-}
-
-//=======================================================================
-//function : ExtrusionSweepObjectMakeGroups
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true);
-
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepObjectMakeGroups( " << theObject
- << ", " << theStepVector << ", " << theNbOfSteps << " )";
- }
- return aGroups;
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject0DMakeGroups
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
- theNbOfSteps, true, SMDSAbs_Node);
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject
- << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
- return aGroups;
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject1DMakeGroups
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
- theNbOfSteps, true, SMDSAbs_Edge);
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
- << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
- return aGroups;
-}
-
-//=======================================================================
-//function : ExtrusionSweepObject2DMakeGroups
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps)
- throw (SALOME::SALOME_Exception)
-{
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- prepareIdSource( theObject );
- SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
- theNbOfSteps, true, SMDSAbs_Face);
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
- << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
- }
- return aGroups;
-}
-
-
-//=======================================================================
-//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)
- throw (SALOME::SALOME_Exception)
-{
- SMESH_TRY;
- initData();
-
- TIDSortedElemSet elements;
- arrayToSet(theIDsOfElements, getMeshDS(), elements);
-
- const SMESH::PointStruct * P = &theStepVector.PS;
- gp_Vec stepVec( P->x, P->y, P->z );
-
- TElemOfElemListMap aHystory;
- ::SMESH_MeshEditor::PGroupIDs groupIds =
- getEditor().ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
- theMakeGroups, theExtrFlags, theSewTolerance);
-
- declareMeshModified( /*isReComputeSafe=*/true );
-
- return theMakeGroups ? getGroups(groupIds.get()) : 0;
-
- SMESH_CATCH( SMESH::throwCorbaException );
- return 0;
-}
-
-//=======================================================================
-//function : AdvancedExtrusion
-//purpose :
-//=======================================================================
-
-void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
- const SMESH::DirStruct & theStepVector,
- CORBA::Long theNbOfSteps,
- CORBA::Long theExtrFlags,
- CORBA::Double theSewTolerance)
- throw (SALOME::SALOME_Exception)
-{
- if ( !myIsPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
- TPythonDump() << this << ".AdvancedExtrusion("
- << theIDsOfElements
- << ", stepVector, "
- << theNbOfSteps << ","
- << theExtrFlags << ", "
- << theSewTolerance << " )";
- }
- advancedExtrusion( theIDsOfElements,
- theStepVector,
- theNbOfSteps,
- theExtrFlags,
- theSewTolerance,
- false);
-}
-
-//=======================================================================
-//function : AdvancedExtrusionMakeGroups
-//purpose :
-//=======================================================================
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
- const SMESH::DirStruct& theStepVector,
- CORBA::Long theNbOfSteps,
- CORBA::Long theExtrFlags,
- CORBA::Double theSewTolerance)
- throw (SALOME::SALOME_Exception)
-{
- if (!myIsPreviewMode) {
- TPythonDump() << "stepVector = " << theStepVector;
- }
- TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
-
- SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
- theStepVector,
- theNbOfSteps,
- theExtrFlags,
- theSewTolerance,
- true);
-
- if (!myIsPreviewMode) {
- dumpGroupsList(aPythonDump, aGroups);
- aPythonDump << this << ".AdvancedExtrusionMakeGroups("
- << theIDsOfElements
- << ", stepVector, "
- << theNbOfSteps << ","
- << theExtrFlags << ", "
- << theSewTolerance << " )";
- }
- return aGroups;
-}
-
-
-//================================================================================
-/*!
- * \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 )
-{
- switch ( e ) {
- RETCASE( EXTR_OK );
- RETCASE( EXTR_NO_ELEMENTS );
- RETCASE( EXTR_PATH_NOT_EDGE );
- RETCASE( EXTR_BAD_PATH_SHAPE );
- RETCASE( EXTR_BAD_STARTING_NODE );
- RETCASE( EXTR_BAD_ANGLES_NUMBER );
- RETCASE( EXTR_CANT_GET_TANGENT );
- }
- return SMESH::SMESH_MeshEditor::EXTR_OK;
-}
-
-
-//=======================================================================
-//function : extrusionAlongPath
-//purpose :
-//=======================================================================
-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,
- const SMDSAbs_ElementType theElementType)
- throw (SALOME::SALOME_Exception)
-{
- SMESH_TRY;
- MESSAGE("extrusionAlongPath");
- initData();
-
- if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
- theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
- return 0;
- }
- SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
-
- TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
- SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
-
- 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 ) {
- theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
- return 0;
- }
-
- TIDSortedElemSet elements;
- arrayToSet(theIDsOfElements, getMeshDS(), elements, theElementType);
-
- list<double> angles;
- for (int i = 0; i < theAngles.length(); i++) {
- angles.push_back( theAngles[i] );
- }
-
- gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
-
- int nbOldGroups = myMesh->NbGroup();
-
- ::SMESH_MeshEditor::Extrusion_Error error =
- getEditor().ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
- theHasAngles, angles, false,
- theHasRefPoint, refPnt, theMakeGroups );
-
- declareMeshModified( /*isReComputeSafe=*/true );
- theError = convExtrError( error );
-
- if ( theMakeGroups ) {
- list<int> groupIDs = myMesh->GetGroupIds();
- list<int>::iterator newBegin = groupIDs.begin();
- std::advance( newBegin, nbOldGroups ); // skip old groups
- groupIDs.erase( groupIDs.begin(), newBegin );
- return getGroups( & groupIDs );
- }
- return 0;
-
- SMESH_CATCH( SMESH::throwCorbaException );
- return 0;
-}
-
-//=======================================================================
-//function : extrusionAlongPathX
-//purpose :
-//=======================================================================
-
-SMESH::ListOfGroups*
-SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
- SMESH::SMESH_IDSource_ptr Path,
- CORBA::Long NodeStart,
- CORBA::Boolean HasAngles,
- const SMESH::double_array& Angles,
- CORBA::Boolean LinearVariation,
- CORBA::Boolean HasRefPoint,
- const SMESH::PointStruct& RefPoint,
- bool MakeGroups,
- const SMDSAbs_ElementType ElementType,
- SMESH::SMESH_MeshEditor::Extrusion_Error & Error)
- throw (SALOME::SALOME_Exception)