-// 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
// 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
// Author : Nicolas REJNERI
// Module : SMESH
-#ifdef WNT
+#ifdef WIN32
#define NOMINMAX
#endif
#include <Utils_ExceptHandlers.hxx>
#include <Utils_CorbaException.hxx>
#include <SALOMEDS_wrap.hxx>
+#include <SALOME_GenericObj_i.hh>
+#include <Basics_OCCTVersion.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
anElemNode->GetID());
}
+ void RemoveAll()
+ {
+ GetMeshDS()->ClearMesh();
+ }
};// struct TPreviewMesh
static SMESH_NodeSearcher * theNodeSearcher = 0;
}
myMesh = mesh;
myMeshPartIOR = meshPartIOR;
- if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
- const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
- TDependsOnMap::const_iterator sm;
- for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
- sm->second->SetEventListener( this, 0, sm->second );
+ SMESH_subMesh* sm = mesh->GetSubMesh( mesh->GetShapeToMesh() );
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator( /*includeSelf=*/true );
+ while ( smIt->more() )
+ {
+ sm = smIt->next();
+ sm->SetEventListener( this, 0, sm );
}
}
}
//!< delete self from all submeshes
void Unset(SMESH_Mesh* mesh)
{
- if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
- const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
- TDependsOnMap::const_iterator sm;
- for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
- sm->second->DeleteEventListener( this );
+ if ( SMESH_subMesh* sm = mesh->GetSubMeshContaining(1) ) {
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator( /*includeSelf=*/true );
+ while ( smIt->more() )
+ smIt->next()->DeleteEventListener( this );
}
myMesh = 0;
}
void arrayToSet(const SMESH::long_array & IDs,
const SMESHDS_Mesh* aMesh,
TIDSortedElemSet& aMap,
- const SMDSAbs_ElementType aType = SMDSAbs_All )
+ const SMDSAbs_ElementType aType = SMDSAbs_All,
+ SMDS_MeshElement::Filter* aFilter = NULL)
{
- for (int i=0; i<IDs.length(); i++) {
- CORBA::Long ind = IDs[i];
- const SMDS_MeshElement * elem =
- (aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
- if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
- aMap.insert( aMap.end(), elem );
- }
+ SMDS_MeshElement::NonNullFilter filter1;
+ SMDS_MeshElement::TypeFilter filter2( aType );
+
+ if ( aFilter == NULL )
+ aFilter = ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter*) &filter1 : (SMDS_MeshElement::Filter*) &filter2;
+
+ SMDS_MeshElement::Filter & filter = *aFilter;
+
+ if ( aType == SMDSAbs_Node )
+ for (int i=0; i<IDs.length(); i++) {
+ const SMDS_MeshElement * elem = aMesh->FindNode( IDs[i] );
+ if ( filter( elem ))
+ aMap.insert( aMap.end(), elem );
+ }
+ else
+ for (int i=0; i<IDs.length(); i++) {
+ const SMDS_MeshElement * elem = aMesh->FindElement( IDs[i] );
+ if ( filter( elem ))
+ aMap.insert( aMap.end(), elem );
+ }
}
//================================================================================
/*!
*/
//================================================================================
+ 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<SMESH_Mesh_i*>( 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;
}
if ( !sameElemType )
elemType = SMDSAbs_All;
- TIDSortedElemSet visitedNodes;
+ vector<bool> isNodeChecked( theMeshDS->NbNodes(), false );
+
TIDSortedElemSet::const_iterator elemIt = theElements.begin();
for ( ; elemIt != theElements.end(); ++elemIt )
{
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() )
{
SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
{
- deleteAuxIDSources();
+ PortableServer::POA_var poa = SMESH_Gen_i::GetPOA();
+ PortableServer::ObjectId_var anObjectId = poa->servant_to_id(this);
+ poa->deactivate_object(anObjectId.in());
+
+ //deleteAuxIDSources();
delete myPreviewMesh; myPreviewMesh = 0;
delete myPreviewEditor; myPreviewEditor = 0;
}
void SMESH_MeshEditor_i::initData(bool deleteSearchers)
{
if ( myIsPreviewMode ) {
- if ( myPreviewMesh ) myPreviewMesh->Clear();
+ if ( myPreviewMesh ) myPreviewMesh->RemoveAll();
}
else {
if ( deleteSearchers )
//=======================================================================
//function : MakeIDSource
-//purpose : Wrap a sequence of ids in a SMESH_IDSource
+//purpose : Wrap a sequence of ids in a SMESH_IDSource.
+// Call UnRegister() as you fininsh using it!!
//=======================================================================
-struct SMESH_MeshEditor_i::_IDSource : public POA_SMESH::SMESH_IDSource
+struct SMESH_MeshEditor_i::_IDSource : public virtual POA_SMESH::SMESH_IDSource,
+ public virtual SALOME::GenericObj_i
{
SMESH::long_array _ids;
SMESH::ElementType _type;
SMESH::SMESH_Mesh_ptr _mesh;
SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); }
SMESH::long_array* GetMeshInfo() { return 0; }
+ SMESH::long_array* GetNbElementsByType()
+ {
+ SMESH::long_array_var aRes = new SMESH::long_array();
+ aRes->length(SMESH::NB_ELEMENT_TYPES);
+ for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++)
+ aRes[ i ] = ( i == _type ) ? _ids.length() : 0;
+ return aRes._retn();
+ }
SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); }
bool IsMeshInfoCorrect() { return true; }
SMESH::array_of_ElementType* GetTypes()
}
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 )
- deleteAuxIDSources();
-
_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();
return SMESH::DownCast<SMESH_MeshEditor_i::_IDSource*>( idSource );
}
-void SMESH_MeshEditor_i::deleteAuxIDSources()
+CORBA::Long* SMESH_MeshEditor_i::GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource,
+ int& nbIds)
{
- std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin();
- for ( ; idSrcIt != myAuxIDSources.end(); ++idSrcIt )
- delete *idSrcIt;
- myAuxIDSources.clear();
+ if ( _IDSource* tmpIdSource = SMESH::DownCast<SMESH_MeshEditor_i::_IDSource*>( idSource ))
+ {
+ nbIds = (int) tmpIdSource->_ids.length();
+ return & tmpIdSource->_ids[0];
+ }
+ nbIds = 0;
+ return 0;
}
+// void SMESH_MeshEditor_i::deleteAuxIDSources()
+// {
+// std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin();
+// for ( ; idSrcIt != myAuxIDSources.end(); ++idSrcIt )
+// delete *idSrcIt;
+// myAuxIDSources.clear();
+// }
+
//=============================================================================
/*!
*
TPythonDump pyDump;
TIDSortedElemSet elements, elems0D;
+ prepareIdSource( theObject );
if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
getEditor().Create0DElementsOnAllNodes( elements, elems0D );
TPythonDump aTPythonDump; // suppress dump in Reorient()
+ prepareIdSource( theObject );
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = Reorient(anElementsId);
initData(/*deleteSearchers=*/false);
TIDSortedElemSet elements;
- if ( !idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1))
+ prepareIdSource( the2Dgroup );
+ 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);
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.
initData();
SMESHDS_Mesh* aMesh = getMeshDS();
- TIDSortedElemSet faces;
- arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
+ TIDSortedElemSet faces,copyFaces;
+ SMDS_MeshElement::GeomFilter triaFilter(SMDSGeom_TRIANGLE);
+ arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face, & triaFilter);
+ TIDSortedElemSet* workElements = & faces;
+
+ if ( myIsPreviewMode ) {
+ SMDSAbs_ElementType select = SMDSAbs_Face;
+ getPreviewMesh( SMDSAbs_Face )->Copy( faces, copyFaces, select );
+ workElements = & copyFaces;
+ }
SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
else
aCrit = aNumericalFunctor->GetNumericalFunctor();
- // Update Python script
- TPythonDump() << "isDone = " << this << ".TriToQuad( "
- << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
-
+ if ( !myIsPreviewMode ) {
+ // Update Python script
+ TPythonDump() << "isDone = " << this << ".TriToQuad( "
+ << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
- bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle );
+ bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle );
declareMeshModified( /*isReComputeSafe=*/!stat );
return stat;
initData();
TPythonDump aTPythonDump; // suppress dump in TriToQuad()
+
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
- SMESH::NumericalFunctor_i* aNumericalFunctor =
- SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
+ if ( !myIsPreviewMode ) {
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
+ SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
- // Update Python script
- aTPythonDump << "isDone = " << this << ".TriToQuadObject("
- << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ // Update Python script
+ aTPythonDump << "isDone = " << this << ".TriToQuadObject("
+ << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
return isDone;
TPythonDump aTPythonDump; // suppress dump in QuadToTri()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
initData();
TIDSortedElemSet faces;
+ prepareIdSource( theObject );
if ( !idSourceToSet( theObject, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/true ) &&
faces.empty() )
THROW_SALOME_CORBA_EXCEPTION("No faces given", SALOME::BAD_PARAM);
TPythonDump aTPythonDump; // suppress dump in SplitQuad()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
int id = getEditor().BestSplit(quad, aCrit);
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
+ return id;
}
SMESH_CATCH( SMESH::throwCorbaException );
{
SMESH_TRY;
initData();
+ prepareIdSource( elems );
- SMESH::long_array_var anElementsId = elems->GetIDs();
- TIDSortedElemSet elemSet;
- arrayToSet( anElementsId, getMeshDS(), elemSet, SMDSAbs_Volume );
+ ::SMESH_MeshEditor::TFacetOfElem elemSet;
+ const int noneFacet = -1;
+ SMDS_ElemIteratorPtr volIt = myMesh_i->GetElements( elems, SMESH::VOLUME );
+ while( volIt->more() )
+ elemSet.insert( elemSet.end(), make_pair( volIt->next(), noneFacet ));
- getEditor().SplitVolumesIntoTetra( elemSet, int( methodFlags ));
+ getEditor().SplitVolumes( elemSet, int( methodFlags ));
declareMeshModified( /*isReComputeSafe=*/true ); // it does not influence Compute()
TPythonDump() << this << ".SplitVolumesIntoTetra( "
SMESH_CATCH( SMESH::throwCorbaException );
}
+//================================================================================
+/*!
+ * \brief Split hexahedra into triangular prisms
+ * \param elems - elements to split
+ * \param facetToSplitNormal - normal used to find a facet of hexahedron
+ * to split into triangles
+ * \param methodFlags - flags passing splitting method:
+ * 1 - split the hexahedron into 2 prisms
+ * 2 - split the hexahedron into 4 prisms
+ */
+//================================================================================
+
+void SMESH_MeshEditor_i::SplitHexahedraIntoPrisms (SMESH::SMESH_IDSource_ptr elems,
+ const SMESH::PointStruct & startHexPoint,
+ const SMESH::DirStruct& facetToSplitNormal,
+ CORBA::Short methodFlags,
+ CORBA::Boolean allDomains)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+ prepareIdSource( elems );
+
+ gp_Ax1 facetNorm( gp_Pnt( startHexPoint.x,
+ startHexPoint.y,
+ startHexPoint.z ),
+ gp_Dir( facetToSplitNormal.PS.x,
+ facetToSplitNormal.PS.y,
+ facetToSplitNormal.PS.z ));
+ TIDSortedElemSet elemSet;
+ SMESH::long_array_var anElementsId = elems->GetIDs();
+ SMDS_MeshElement::GeomFilter filter( SMDSGeom_HEXA );
+ arrayToSet( anElementsId, getMeshDS(), elemSet, SMDSAbs_Volume, &filter );
+
+ ::SMESH_MeshEditor::TFacetOfElem elemFacets;
+ while ( !elemSet.empty() )
+ {
+ getEditor().GetHexaFacetsToSplit( elemSet, facetNorm, elemFacets );
+ if ( !allDomains )
+ break;
+
+ ::SMESH_MeshEditor::TFacetOfElem::iterator ef = elemFacets.begin();
+ for ( ; ef != elemFacets.end(); ++ef )
+ elemSet.erase( ef->first );
+ }
+
+ if ( methodFlags == 2 )
+ methodFlags = int( ::SMESH_MeshEditor::HEXA_TO_4_PRISMS );
+ else
+ methodFlags = int( ::SMESH_MeshEditor::HEXA_TO_2_PRISMS );
+
+ getEditor().SplitVolumes( elemFacets, int( methodFlags ));
+ declareMeshModified( /*isReComputeSafe=*/true ); // it does not influence Compute()
+
+ TPythonDump() << this << ".SplitHexahedraIntoPrisms( "
+ << elems << ", "
+ << startHexPoint << ", "
+ << facetToSplitNormal<< ", "
+ << methodFlags<< ", "
+ << allDomains << " )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
//=======================================================================
//function : Smooth
//purpose :
TPythonDump aTPythonDump; // suppress dump in smooth()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
MaxAspectRatio, Method, IsParametric);
<< theNbOfSteps << ", "
<< theTolerance << " )";
}
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
rotationSweep(anElementsId,
theAxis,
<< TVar( theNbOfSteps ) << ", "
<< TVar( theTolerance ) << " )";
}
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
rotationSweep(anElementsId,
theAxis,
<< TVar( theNbOfSteps ) << ", "
<< TVar( theTolerance ) << " )";
}
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
rotationSweep(anElementsId,
theAxis,
{
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,
{
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,
{
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,
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
//=======================================================================
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 );
+ }
}
- TElemOfElemListMap aHystory;
- ::SMESH_MeshEditor::PGroupIDs groupIds =
- getEditor().ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
+ ::SMESH_MeshEditor::TTElemOfElemListMap aHystory;
+ ::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;
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) << " )";
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)<< " )";
CORBA::Long theNbOfSteps)
throw (SALOME::SALOME_Exception)
{
+ 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 << " )";
CORBA::Long theNbOfSteps)
throw (SALOME::SALOME_Exception)
{
+ 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<SMESH_Mesh_i*>( theObject ))
+ anElementsId = mesh->GetNodesId();
+
+ ExtrusionParams params( theStepVector, theNbOfSteps, false );
+ extrusionSweep( anElementsId, params, SMDSAbs_Node );
if ( !myIsPreviewMode ) {
TPythonDump() << this << ".ExtrusionSweepObject0D( "
<< theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
CORBA::Long theNbOfSteps)
throw (SALOME::SALOME_Exception)
{
+ 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 ) << " )";
CORBA::Long theNbOfSteps)
throw (SALOME::SALOME_Exception)
{
+ 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 ) << " )";
{
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);
{
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);
{
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);
+ ExtrusionParams params( theStepVector, theNbOfSteps, true );
+ SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params );
if (!myIsPreviewMode) {
dumpGroupsList(aPythonDump, aGroups);
{
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);
+ ExtrusionParams params( theStepVector, theNbOfSteps, true );
+ SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Node );
+
if (!myIsPreviewMode) {
dumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject
{
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);
+ ExtrusionParams params( theStepVector, theNbOfSteps, true );
+ SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Edge );
+
if (!myIsPreviewMode) {
dumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
{
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);
+ ExtrusionParams params( theStepVector, theNbOfSteps, true );
+ SMESH::ListOfGroups* aGroups = extrusionSweep( anElementsId, params, SMDSAbs_Face );
+
if (!myIsPreviewMode) {
dumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
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 );
-
- TElemOfElemListMap 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<SMESH_Mesh_i*>( 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;
}
//=======================================================================
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("
<< theExtrFlags << ", "
<< theSewTolerance << " )";
}
- advancedExtrusion( theIDsOfElements,
- theStepVector,
- theNbOfSteps,
- theExtrFlags,
- theSewTolerance,
- false);
}
//=======================================================================
}
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);
<< ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionAlongPath( anElementsId,
thePathMesh,
<< ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionAlongPath( anElementsId,
thePathMesh,
<< ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionAlongPath( anElementsId,
thePathMesh,
{
TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
{
TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
{
TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
{
TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+ prepareIdSource( Object );
SMESH::long_array_var anElementsId = Object->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
Path,
bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+ prepareIdSource( theObject );
if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
mirror(elements, theAxis, theMirrorType, theCopy, false);
}
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if ( idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
aGroups = mirror(elements, theMirror, theMirrorType, true, true);
mesh = makeMesh( theMeshName );
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if ( mesh_i &&
idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
{
bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+ prepareIdSource( theObject );
if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
translate(elements, theVector, theCopy, false);
}
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
aGroups = translate(elements, theVector, true, true);
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if ( mesh_i &&
idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
{
}
TIDSortedElemSet elements;
bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+ prepareIdSource( theObject );
if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
rotate(elements,theAxis,theAngle,theCopy,false);
}
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
aGroups = rotate(elements, theAxis, theAngle, true, true);
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
if (mesh_i &&
idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
{
theCopy = false;
TIDSortedElemSet elements;
+ prepareIdSource( theObject );
bool emptyIfIsMesh = myIsPreviewMode ? false : true;
if ( !idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
return 0;
};
double tol = std::numeric_limits<double>::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;
initData();
TIDSortedNodeSet nodes;
+ prepareIdSource( theObject );
idSourceToNodeSet( theObject, getMeshDS(), nodes );
::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
initData();
TIDSortedNodeSet nodes;
+ prepareIdSource( theObject );
idSourceToNodeSet( theObject, getMeshDS(), nodes );
for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
{
TIDSortedElemSet elems;
+ prepareIdSource( theObject );
idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true);
::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
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 );
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 );
TIDSortedElemSet elems;
bool elemsOK;
if ( !( elemsOK = CORBA::is_nil( theObject )))
+ {
+ prepareIdSource( theObject );
elemsOK = idSourceToSet( theObject, getMeshDS(), elems,
SMDSAbs_All, /*emptyIfIsMesh=*/true );
+ }
if ( elemsOK )
{
if ( !elems.empty() && (*elems.begin())->GetType() == SMDSAbs_Node )
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
- TPythonDump pyDump;
+
+ TPythonDump pyDump;
+
TIDSortedElemSet elems;
+ prepareIdSource( theObject );
if ( idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ))
{
if ( elems.empty() )
int index = 0;
while (!groupNames.insert(name).second)
- name = SMESH_Comment( thePrefix ) << "_" << index;
+ name = SMESH_Comment( thePrefix ) << "_" << index++;
return name;
}
+//================================================================================
+/*!
+ * \brief Prepare SMESH_IDSource for work
+ */
+//================================================================================
+
+void SMESH_MeshEditor_i::prepareIdSource(SMESH::SMESH_IDSource_ptr theObject)
+{
+ if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theObject ))
+ {
+ SMESH::SMESH_Mesh_var mesh = myMesh_i->_this();
+ filter->SetMesh( mesh );
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Duplicates given elements, i.e. creates new elements based on the
+ * same nodes as the given ones.
+ * \param theElements - container of elements to duplicate.
+ * \param theGroupName - a name of group to contain the generated elements.
+ * If a group with such a name already exists, the new elements
+ * are added to the existng group, else a new group is created.
+ * If \a theGroupName is empty, new elements are not added
+ * in any group.
+ * \return a group where the new elements are added. NULL if theGroupName == "".
+ * \sa DoubleNode()
+ */
+//================================================================================
+
+SMESH::SMESH_Group_ptr
+SMESH_MeshEditor_i::DoubleElements(SMESH::SMESH_IDSource_ptr theElements,
+ const char* theGroupName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH::SMESH_Group_var newGroup;
+
+ SMESH_TRY;
+ initData();
+
+ TPythonDump pyDump;
+
+ TIDSortedElemSet elems;
+ prepareIdSource( theElements );
+ if ( idSourceToSet( theElements, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true))
+ {
+ getEditor().DoubleElements( elems );
+
+ if ( strlen( theGroupName ) && !getEditor().GetLastCreatedElems().IsEmpty() )
+ {
+ // group type
+ SMESH::ElementType type =
+ SMESH::ElementType( getEditor().GetLastCreatedElems().Value(1)->GetType() );
+ // find existing group
+ SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
+ for ( size_t i = 0; i < groups->length(); ++i )
+ if ( groups[i]->GetType() == type )
+ {
+ CORBA::String_var name = groups[i]->GetName();
+ if ( strcmp( name, theGroupName ) == 0 ) {
+ newGroup = SMESH::SMESH_Group::_narrow( groups[i] );
+ break;
+ }
+ }
+ // create a new group
+ if ( newGroup->_is_nil() )
+ newGroup = myMesh_i->CreateGroup( type, theGroupName );
+ // fill newGroup
+ if ( SMESH_Group_i* group_i = SMESH::DownCast< SMESH_Group_i* >( newGroup ))
+ {
+ SMESHDS_Group* groupDS = static_cast< SMESHDS_Group* >( group_i->GetGroupDS() );
+ const SMESH_SequenceOfElemPtr& aSeq = getEditor().GetLastCreatedElems();
+ for ( int i = 1; i <= aSeq.Length(); i++ )
+ groupDS->SMDSGroup().Add( aSeq(i) );
+ }
+ }
+ }
+ // python dump
+ if ( !newGroup->_is_nil() )
+ pyDump << newGroup << " = ";
+ pyDump << this << ".DoubleElements( "
+ << theElements << ", " << "'" << theGroupName <<"')";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return newGroup._retn();
+}
+
//================================================================================
/*!
\brief Creates a hole in a mesh by doubling the nodes of some particular elements
* 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();
SMESHDS_Mesh* aMeshDS = getMeshDS();
// MESSAGE("theDomains.length = "<<theDomains.length());
- if ( theDomains.length() <= 1 )
+ if ( theDomains.length() <= 1 && !onAllBoundaries )
THROW_SALOME_CORBA_EXCEPTION("At least 2 groups are required.", SALOME::BAD_PARAM);
+
vector<TIDSortedElemSet> domains;
- domains.clear();
+ domains.resize( theDomains.length() );
for ( int i = 0, n = theDomains.length(); i < n; i++ )
{
{
// 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;
}
//================================================================================
TIDSortedElemSet elements;
SMDSAbs_ElementType elemType = (dim == SMESH::BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume;
+ prepareIdSource( idSource );
if ( idSourceToSet( idSource, aMeshDS, elements, elemType,/*emptyIfIsMesh=*/true ))
{
// mesh to fill in