TIDSortedElemSet& aMap,
const SMDSAbs_ElementType aType = SMDSAbs_All )
{
- 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 );
+ SMDS_MeshElement::Filter & filter =
+ ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2;
+
+ 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 );
+ }
}
//================================================================================
/*!
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;
+ prepareIdSource( the2Dgroup );
if ( !idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1))
THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM);
initData();
TPythonDump aTPythonDump; // suppress dump in TriToQuad()
+
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
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);
SMESH_TRY;
initData();
+ prepareIdSource( elems );
SMESH::long_array_var anElementsId = elems->GetIDs();
TIDSortedElemSet elemSet;
arrayToSet( anElementsId, getMeshDS(), elemSet, SMDSAbs_Volume );
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,
CORBA::Long theNbOfSteps)
throw (SALOME::SALOME_Exception)
{
+ prepareIdSource( theObject );
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
if (!myIsPreviewMode) {
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 ) {
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 ) {
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 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);
{
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);
{
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);
{
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);
<< ( 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;
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;
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
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