X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_MeshEditor_i.cxx;h=534580ccbb36c76500d9ee3dab15221af98a2598;hp=a983a13c3298599e2a7230aeb435134097d7248b;hb=251f8c052dd12dd29922210dc901b295fe999a0e;hpb=c94d606fe399faeb356151a1a9754e5f21754082 diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index a983a13c3..534580ccb 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -307,33 +308,56 @@ namespace MeshEditor_I { */ //================================================================================ + enum IDSource_Error { IDSource_OK, IDSource_INVALID, IDSource_EMPTY }; + bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource, const SMESHDS_Mesh* theMeshDS, TIDSortedElemSet& theElemSet, const SMDSAbs_ElementType theType, - const bool emptyIfIsMesh=false) + const bool emptyIfIsMesh = false, + IDSource_Error* error = 0) { + if ( error ) *error = IDSource_OK; + if ( CORBA::is_nil( theIDSource ) ) + { + if ( error ) *error = IDSource_INVALID; return false; + } if ( emptyIfIsMesh && SMESH::DownCast( theIDSource )) + { + if ( error && theMeshDS->GetMeshInfo().NbElements( theType ) == 0 ) + *error = IDSource_EMPTY; return true; - + } SMESH::long_array_var anIDs = theIDSource->GetIDs(); if ( anIDs->length() == 0 ) + { + if ( error ) *error = IDSource_EMPTY; return false; + } SMESH::array_of_ElementType_var types = theIDSource->GetTypes(); if ( types->length() == 1 && types[0] == SMESH::NODE ) // group of nodes { if ( theType == SMDSAbs_All || theType == SMDSAbs_Node ) + { arrayToSet( anIDs, theMeshDS, theElemSet, SMDSAbs_Node ); + } else + { + if ( error ) *error = IDSource_INVALID; return false; + } } else { arrayToSet( anIDs, theMeshDS, theElemSet, theType); - return bool(anIDs->length()) == bool(theElemSet.size()); + if ( bool(anIDs->length()) != bool(theElemSet.size())) + { + if ( error ) *error = IDSource_INVALID; + return false; + } } return true; } @@ -394,7 +418,8 @@ namespace MeshEditor_I { if ( !sameElemType ) elemType = SMDSAbs_All; - TIDSortedElemSet visitedNodes; + vector isNodeChecked( theMeshDS->NbNodes(), false ); + TIDSortedElemSet::const_iterator elemIt = theElements.begin(); for ( ; elemIt != theElements.end(); ++elemIt ) { @@ -403,8 +428,9 @@ namespace MeshEditor_I { while ( --i != -1 ) { const SMDS_MeshNode* n = e->GetNode( i ); - if ( visitedNodes.insert( n ).second ) + if ( !isNodeChecked[ n->GetID() ]) { + isNodeChecked[ n->GetID() ] = true; SMDS_ElemIteratorPtr invIt = n->GetInverseElementIterator(elemType); while ( invIt->more() ) { @@ -755,21 +781,22 @@ struct SMESH_MeshEditor_i::_IDSource : public virtual POA_SMESH::SMESH_IDSource, } return types._retn(); } + SALOMEDS::TMPFile* GetVtkUgStream() + { + SALOMEDS::TMPFile_var SeqFile; + return SeqFile._retn(); + } }; SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids, SMESH::ElementType type) { - // if ( myAuxIDSources.size() > 10 ) { - // delete myAuxIDSources.front(); - // myAuxIDSources.pop_front(); - // } - _IDSource* idSrc = new _IDSource; idSrc->_mesh = myMesh_i->_this(); idSrc->_ids = ids; idSrc->_type = type; - //myAuxIDSources.push_back( idSrc ); + if ( type == SMESH::ALL && ids.length() > 0 ) + idSrc->_type = myMesh_i->GetElementType( ids[0], true ); SMESH::SMESH_IDSource_var anIDSourceVar = idSrc->_this(); @@ -1644,7 +1671,11 @@ CORBA::Long SMESH_MeshEditor_i::Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup, TIDSortedElemSet elements; prepareIdSource( the2Dgroup ); - if ( !idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1)) + IDSource_Error error; + idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1, &error ); + if ( error == IDSource_EMPTY ) + return 0; + if ( error == IDSource_INVALID ) THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM); @@ -1710,6 +1741,58 @@ CORBA::Long SMESH_MeshEditor_i::Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup, return 0; } +//======================================================================= +//function : Reorient2DBy3D +//purpose : Reorient faces basing on orientation of adjacent volumes. +//======================================================================= + +CORBA::Long SMESH_MeshEditor_i::Reorient2DBy3D(const SMESH::ListOfIDSources& faceGroups, + SMESH::SMESH_IDSource_ptr volumeGroup, + CORBA::Boolean outsideNormal) + throw (SALOME::SALOME_Exception) +{ + SMESH_TRY; + initData(); + + TIDSortedElemSet volumes; + prepareIdSource( volumeGroup ); + IDSource_Error volsError; + idSourceToSet( volumeGroup, getMeshDS(), volumes, SMDSAbs_Volume, /*emptyIfMesh=*/1, &volsError); + + int nbReori = 0; + for ( size_t i = 0; i < faceGroups.length(); ++i ) + { + SMESH::SMESH_IDSource_ptr faceGrp = faceGroups[i].in(); + prepareIdSource( faceGrp ); + + TIDSortedElemSet faces; + IDSource_Error error; + idSourceToSet( faceGrp, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/1, &error ); + if ( error == IDSource_INVALID && faceGroups.length() == 1 ) + THROW_SALOME_CORBA_EXCEPTION("No faces in a given object", SALOME::BAD_PARAM); + if ( error == IDSource_OK && volsError != IDSource_OK ) + THROW_SALOME_CORBA_EXCEPTION("No volumes in a given object", SALOME::BAD_PARAM); + + nbReori += getEditor().Reorient2DBy3D( faces, volumes, outsideNormal ); + + if ( error != IDSource_EMPTY && faces.empty() ) // all faces in the mesh treated + break; + } + + if ( nbReori ) { + declareMeshModified( /*isReComputeSafe=*/false ); + } + TPythonDump() << this << ".Reorient2DBy3D( " + << faceGroups << ", " + << volumeGroup << ", " + << outsideNormal << " )"; + + return nbReori; + + SMESH_CATCH( SMESH::throwCorbaException ); + return 0; +} + //============================================================================= /*! * \brief Fuse neighbour triangles into quadrangles. @@ -2607,6 +2690,77 @@ SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr th return aGroups; } +namespace MeshEditor_I +{ + /*! + * \brief Structure used to pass extrusion parameters to ::SMESH_MeshEditor + */ + struct ExtrusionParams : public ::SMESH_MeshEditor::ExtrusParam + { + bool myIsExtrusionByNormal; + + static int makeFlags( CORBA::Boolean MakeGroups, + CORBA::Boolean ByAverageNormal = false, + CORBA::Boolean UseInputElemsOnly = false, + CORBA::Long Flags = 0, + CORBA::Boolean MakeBoundary = true ) + { + if ( MakeGroups ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_GROUPS; + if ( ByAverageNormal ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_BY_AVG_NORMAL; + if ( UseInputElemsOnly) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY; + if ( MakeBoundary ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_BOUNDARY; + return Flags; + } + // standard params + ExtrusionParams(const SMESH::DirStruct & theDir, + CORBA::Long theNbOfSteps, + CORBA::Boolean theMakeGroups): + ::SMESH_MeshEditor::ExtrusParam ( gp_Vec( theDir.PS.x, + theDir.PS.y, + theDir.PS.z ), + theNbOfSteps, + makeFlags( theMakeGroups )), + myIsExtrusionByNormal( false ) + { + } + // advanced params + ExtrusionParams(const SMESH::DirStruct & theDir, + CORBA::Long theNbOfSteps, + CORBA::Boolean theMakeGroups, + CORBA::Long theExtrFlags, + CORBA::Double theSewTolerance): + ::SMESH_MeshEditor::ExtrusParam ( gp_Vec( theDir.PS.x, + theDir.PS.y, + theDir.PS.z ), + theNbOfSteps, + makeFlags( theMakeGroups, false, false, + theExtrFlags, false ), + theSewTolerance ), + myIsExtrusionByNormal( false ) + { + } + // params for extrusion by normal + ExtrusionParams(CORBA::Double theStepSize, + CORBA::Long theNbOfSteps, + CORBA::Short theDim, + CORBA::Boolean theUseInputElemsOnly, + CORBA::Boolean theByAverageNormal, + CORBA::Boolean theMakeGroups ): + ::SMESH_MeshEditor::ExtrusParam ( theStepSize, + theNbOfSteps, + makeFlags( theMakeGroups, + theByAverageNormal, theUseInputElemsOnly ), + theDim), + myIsExtrusionByNormal( true ) + { + } + + void SetNoGroups() + { + Flags() &= ~(::SMESH_MeshEditor::EXTRUSION_FLAG_GROUPS); + } + }; +} //======================================================================= //function : extrusionSweep @@ -2614,43 +2768,45 @@ SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr th //======================================================================= SMESH::ListOfGroups* -SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, - const SMESH::DirStruct & theStepVector, - CORBA::Long theNbOfSteps, - bool theMakeGroups, - const SMDSAbs_ElementType theElementType) +SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, + MeshEditor_I::ExtrusionParams& theParams, + 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 ); + arrayToSet( theIDsOfElements, getMeshDS(), elements, theElementType ); TIDSortedElemSet* workElements = & elements; - SMDSAbs_ElementType aType = SMDSAbs_Face; - if (theElementType == SMDSAbs_Node) + if ( myIsPreviewMode ) { - aType = SMDSAbs_Edge; - } - if ( myIsPreviewMode ) { + SMDSAbs_ElementType previewType = SMDSAbs_Face; + if (theElementType == SMDSAbs_Node) + previewType = SMDSAbs_Edge; + SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume; - getPreviewMesh( aType )->Copy( elements, copyElements, select, avoid ); + getPreviewMesh( previewType )->Copy( elements, copyElements, select, avoid ); workElements = & copyElements; - theMakeGroups = false; + theParams.SetNoGroups(); + + if ( theParams.myIsExtrusionByNormal && !theParams.ToUseInpElemsOnly() ) + { + TIDSortedElemSet elemsAround, elemsAroundCopy; + getElementsAround( elements, getMeshDS(), elemsAround ); + getPreviewMesh( previewType )->Copy( elemsAround, elemsAroundCopy, select, avoid ); + } } ::SMESH_MeshEditor::TTElemOfElemListMap aHystory; - ::SMESH_MeshEditor::PGroupIDs groupIds = - getEditor().ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups); + ::SMESH_MeshEditor::PGroupIDs groupIds = + getEditor().ExtrusionSweep (*workElements, theParams, aHystory ); declareMeshModified( /*isReComputeSafe=*/true ); // does not influence Compute() - return theMakeGroups ? getGroups(groupIds.get()) : 0; + return theParams.ToMakeGroups() ? getGroups(groupIds.get()) : 0; SMESH_CATCH( SMESH::throwCorbaException ); return 0; @@ -2666,7 +2822,8 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { - extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( theIDsOfElements, params ); if (!myIsPreviewMode) { TPythonDump() << this << ".ExtrusionSweep( " << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps) << " )"; @@ -2683,7 +2840,8 @@ void SMESH_MeshEditor_i::ExtrusionSweep0D(const SMESH::long_array & theIDsOfElem CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { - extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false, SMDSAbs_Node ); + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( theIDsOfElements, params, SMDSAbs_Node ); if (!myIsPreviewMode) { TPythonDump() << this << ".ExtrusionSweep0D( " << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps)<< " )"; @@ -2702,7 +2860,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec { prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false ); + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( anElementsId, params ); if (!myIsPreviewMode) { TPythonDump() << this << ".ExtrusionSweepObject( " << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; @@ -2721,7 +2880,12 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObj { prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node ); + if ( anElementsId->length() == 0 ) + if ( SMESH_Mesh_i* mesh = SMESH::DownCast( theObject )) + anElementsId = mesh->GetNodesId(); + + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( anElementsId, params, SMDSAbs_Node ); if ( !myIsPreviewMode ) { TPythonDump() << this << ".ExtrusionSweepObject0D( " << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; @@ -2740,7 +2904,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj { prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( anElementsId, params, SMDSAbs_Edge ); if ( !myIsPreviewMode ) { TPythonDump() << this << ".ExtrusionSweepObject1D( " << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; @@ -2759,7 +2924,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj { prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); + ExtrusionParams params( theStepVector, theNbOfSteps, false ); + extrusionSweep( anElementsId, params, SMDSAbs_Face ); if ( !myIsPreviewMode ) { TPythonDump() << this << ".ExtrusionSweepObject2D( " << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; @@ -2779,7 +2945,8 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() - SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( theIDsOfElements, params ); if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); @@ -2802,7 +2969,8 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups0D(const SMESH::long_array& theIDsOf { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() - SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true,SMDSAbs_Node); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( theIDsOfElements, params, SMDSAbs_Node ); if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); @@ -2827,7 +2995,8 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params ); if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); @@ -2852,8 +3021,9 @@ SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr t prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, - theNbOfSteps, true, SMDSAbs_Node); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Node ); + if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject @@ -2877,8 +3047,9 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, - theNbOfSteps, true, SMDSAbs_Edge); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Edge ); + if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject @@ -2902,8 +3073,9 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); - SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, - theNbOfSteps, true, SMDSAbs_Face); + ExtrusionParams params( theStepVector, theNbOfSteps, true ); + SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Face ); + if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject @@ -2912,41 +3084,49 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t return aGroups; } - //======================================================================= -//function : advancedExtrusion +//function : ExtrusionByNormal //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) +SMESH_MeshEditor_i::ExtrusionByNormal(SMESH::SMESH_IDSource_ptr object, + CORBA::Double stepSize, + CORBA::Long nbOfSteps, + CORBA::Boolean byAverageNormal, + CORBA::Boolean useInputElemsOnly, + CORBA::Boolean makeGroups, + CORBA::Short dim) 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 ); - - ::SMESH_MeshEditor::TTElemOfElemListMap aHystory; - ::SMESH_MeshEditor::PGroupIDs groupIds = - getEditor().ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, - theMakeGroups, theExtrFlags, theSewTolerance); + TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() - declareMeshModified( /*isReComputeSafe=*/true ); + ExtrusionParams params( stepSize, nbOfSteps, dim, + byAverageNormal, useInputElemsOnly, makeGroups ); - return theMakeGroups ? getGroups(groupIds.get()) : 0; + SMDSAbs_ElementType elemType = ( dim == 1 ? SMDSAbs_Edge : SMDSAbs_Face ); + if ( !SMESH::DownCast( object )) + { + SMESH::array_of_ElementType_var elemTypes = object->GetTypes(); + if (( elemTypes->length() == 1 ) && + ( elemTypes[0] == SMESH::EDGE || elemTypes[0] == SMESH::FACE )) + elemType = ( SMDSAbs_ElementType ) elemTypes[0]; + } + prepareIdSource( object ); + SMESH::long_array_var anElementsId = object->GetIDs(); + SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, elemType ); - SMESH_CATCH( SMESH::throwCorbaException ); - return 0; + if (!myIsPreviewMode) { + dumpGroupsList(aPythonDump, aGroups); + aPythonDump << this << ".ExtrusionByNormal( " << object + << ", " << TVar( stepSize ) + << ", " << TVar( nbOfSteps ) + << ", " << byAverageNormal + << ", " << makeGroups + << ", " << dim + << " )"; + } + return aGroups ? aGroups : new SMESH::ListOfGroups; } //======================================================================= @@ -2961,6 +3141,9 @@ void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfEle CORBA::Double theSewTolerance) throw (SALOME::SALOME_Exception) { + ExtrusionParams params( theStepVector, theNbOfSteps, false, theExtrFlags, theSewTolerance); + extrusionSweep( theIDsOfElements, params ); + if ( !myIsPreviewMode ) { TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".AdvancedExtrusion(" @@ -2970,12 +3153,6 @@ void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfEle << theExtrFlags << ", " << theSewTolerance << " )"; } - advancedExtrusion( theIDsOfElements, - theStepVector, - theNbOfSteps, - theExtrFlags, - theSewTolerance, - false); } //======================================================================= @@ -2995,12 +3172,8 @@ SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsO } TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() - SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements, - theStepVector, - theNbOfSteps, - theExtrFlags, - theSewTolerance, - true); + ExtrusionParams params( theStepVector, theNbOfSteps, true, theExtrFlags, theSewTolerance); + SMESH::ListOfGroups * aGroups = extrusionSweep( theIDsOfElements, params ); if (!myIsPreviewMode) { dumpGroupsList(aPythonDump, aGroups); @@ -4667,9 +4840,23 @@ SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject, }; double tol = std::numeric_limits::max(); gp_Trsf aTrsf; + +#if OCC_VERSION_LARGE > 0x06070100 + // fight against ortagonalization + // aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]), + // 0, S[1], 0, thePoint.y * (1-S[1]), + // 0, 0, S[2], thePoint.z * (1-S[2]) ); + aTrsf.SetTranslation( gp_Vec( thePoint.x * (1-S[0]), + thePoint.y * (1-S[1]), + thePoint.z * (1-S[2]))); + gp_Mat & M = ( gp_Mat& ) aTrsf.HVectorialPart(); + M.SetDiagonal( S[0], S[1], S[2] ); + +#else aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]), 0, S[1], 0, thePoint.y * (1-S[1]), 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol); +#endif TIDSortedElemSet copyElements; TIDSortedElemSet* workElements = &elements; @@ -5253,13 +5440,6 @@ SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x, for ( int i = 0; i < foundElems.size(); ++i ) res[i] = foundElems[i]->GetID(); - if ( !myIsPreviewMode ) // call from tui - TPythonDump() << "res = " << this << ".FindElementsByPoint( " - << x << ", " - << y << ", " - << z << ", " - << type << " )"; - return res._retn(); SMESH_CATCH( SMESH::throwCorbaException ); @@ -5321,14 +5501,6 @@ SMESH_MeshEditor_i::FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elementID for ( int i = 0; i < foundElems.size(); ++i ) res[i] = foundElems[i]->GetID(); - if ( !myIsPreviewMode ) // call from tui - TPythonDump() << "res = " << this << ".FindAmongElementsByPoint( " - << elementIDs << ", " - << x << ", " - << y << ", " - << z << ", " - << type << " )"; - return res._retn(); SMESH_CATCH( SMESH::throwCorbaException ); @@ -6890,18 +7062,21 @@ CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D() * If there is no shared faces between the group #n and the group #p in the list, the group j_n_p is not created. * All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation). * The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples". - * @param theDomains - list of groups of volumes - * @param createJointElems - if TRUE, create the elements - * @return TRUE if operation has been completed successfully, FALSE otherwise + * \param theDomains - list of groups of volumes + * \param createJointElems - if TRUE, create the elements + * \param onAllBoundaries - if TRUE, the nodes and elements are also created on + * the boundary between \a theDomains and the rest mesh + * \return TRUE if operation has been completed successfully, FALSE otherwise */ //================================================================================ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains, - CORBA::Boolean createJointElems ) + CORBA::Boolean createJointElems, + CORBA::Boolean onAllBoundaries ) throw (SALOME::SALOME_Exception) { - bool aResult = false; + bool isOK = false; SMESH_TRY; initData(); @@ -6909,10 +7084,11 @@ SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& the SMESHDS_Mesh* aMeshDS = getMeshDS(); // MESSAGE("theDomains.length = "< domains; - domains.clear(); + domains.resize( theDomains.length() ); for ( int i = 0, n = theDomains.length(); i < n; i++ ) { @@ -6921,26 +7097,25 @@ SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& the { // if ( aGrp->GetType() != SMESH::VOLUME ) // THROW_SALOME_CORBA_EXCEPTION("Not a volume group", SALOME::BAD_PARAM); - TIDSortedElemSet domain; - domain.clear(); - domains.push_back(domain); SMESH::long_array_var anIDs = aGrp->GetIDs(); arrayToSet( anIDs, aMeshDS, domains[ i ], SMDSAbs_All ); } } - aResult = getEditor().DoubleNodesOnGroupBoundaries( domains, createJointElems ); + isOK = getEditor().DoubleNodesOnGroupBoundaries( domains, createJointElems, onAllBoundaries ); // TODO publish the groups of flat elements in study - declareMeshModified( /*isReComputeSafe=*/ !aResult ); + declareMeshModified( /*isReComputeSafe=*/ !isOK ); // Update Python script TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains - << ", " << createJointElems << " )"; + << ", " << createJointElems << ", " << onAllBoundaries << " )"; SMESH_CATCH( SMESH::throwCorbaException ); - return aResult; + myMesh_i->CreateGroupServants(); // publish created groups if any + + return isOK; } //================================================================================