mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-05 06:10:33 +05:00
PAL16617 (Modification/Transformation operations with copy don't create a new mesh)
PGroupIDs Transform (TIDSortedElemSet & theElements, const gp_Trsf& theTrsf, const bool theCopy, - const bool theMakeGroups); + const bool theMakeGroups, + SMESH_Mesh* theTargetMesh=0);
This commit is contained in:
parent
dcdf3c5ef8
commit
53660eaf43
@ -94,9 +94,12 @@ struct TNodeXYZ : public gp_XYZ {
|
|||||||
|
|
||||||
typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
|
typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief A sorted pair of nodes
|
* \brief A sorted pair of nodes
|
||||||
*/
|
*/
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
struct TLink: public NLink
|
struct TLink: public NLink
|
||||||
{
|
{
|
||||||
TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
|
TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
|
||||||
@ -110,8 +113,8 @@ struct TLink: public NLink
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
SMESH_MeshEditor::SMESH_MeshEditor( SMESH_Mesh* theMesh ):
|
SMESH_MeshEditor::SMESH_MeshEditor( SMESH_Mesh* theMesh )
|
||||||
myMesh( theMesh )
|
:myMesh( theMesh ) // theMesh may be NULL
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,7 +1174,7 @@ void SMESH_MeshEditor::AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
|||||||
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
|
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
|
||||||
for ( ; grIt != groups.end(); grIt++ ) {
|
for ( ; grIt != groups.end(); grIt++ ) {
|
||||||
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
|
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
|
||||||
if ( group && group->SMDSGroup().Contains( elemInGroups ))
|
if ( group && group->Contains( elemInGroups ))
|
||||||
group->SMDSGroup().Add( elemToAdd );
|
group->SMDSGroup().Add( elemToAdd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3221,16 +3224,17 @@ void SMESH_MeshEditor::makeWalls (TNodeOfNodeListMap & mapNewNodes,
|
|||||||
list<const SMDS_MeshElement*> & newVolumes = itElem->second;
|
list<const SMDS_MeshElement*> & newVolumes = itElem->second;
|
||||||
int iVol, volNb, nbVolumesByStep = newVolumes.size() / nbSteps;
|
int iVol, volNb, nbVolumesByStep = newVolumes.size() / nbSteps;
|
||||||
|
|
||||||
set<const SMDS_MeshNode*> initNodeSet, faceNodeSet;
|
set<const SMDS_MeshNode*> initNodeSet, topNodeSet, faceNodeSet;
|
||||||
for ( iNode = 0; iNode < nbNodes; iNode++ )
|
for ( iNode = 0; iNode < nbNodes; iNode++ ) {
|
||||||
initNodeSet.insert( vecNewNodes[ iNode ]->first );
|
initNodeSet.insert( vecNewNodes[ iNode ]->first );
|
||||||
|
topNodeSet .insert( vecNewNodes[ iNode ]->second.back() );
|
||||||
|
}
|
||||||
for ( volNb = 0; volNb < nbVolumesByStep; volNb++ ) {
|
for ( volNb = 0; volNb < nbVolumesByStep; volNb++ ) {
|
||||||
list<const SMDS_MeshElement*>::iterator v = newVolumes.begin();
|
list<const SMDS_MeshElement*>::iterator v = newVolumes.begin();
|
||||||
iVol = 0;
|
iVol = 0;
|
||||||
while ( iVol++ < volNb ) v++;
|
while ( iVol++ < volNb ) v++;
|
||||||
// find indices of free faces of a volume
|
// find indices of free faces of a volume and their source edges
|
||||||
list< int > fInd;
|
list< int > freeInd;
|
||||||
list< const SMDS_MeshElement* > srcEdges; // source edges of free faces
|
list< const SMDS_MeshElement* > srcEdges; // source edges of free faces
|
||||||
SMDS_VolumeTool vTool( *v );
|
SMDS_VolumeTool vTool( *v );
|
||||||
int iF, nbF = vTool.NbFaces();
|
int iF, nbF = vTool.NbFaces();
|
||||||
@ -3239,31 +3243,29 @@ void SMESH_MeshEditor::makeWalls (TNodeOfNodeListMap & mapNewNodes,
|
|||||||
vTool.GetFaceNodes( iF, faceNodeSet ) &&
|
vTool.GetFaceNodes( iF, faceNodeSet ) &&
|
||||||
initNodeSet != faceNodeSet) // except an initial face
|
initNodeSet != faceNodeSet) // except an initial face
|
||||||
{
|
{
|
||||||
fInd.push_back( iF );
|
if ( nbSteps == 1 && faceNodeSet == topNodeSet )
|
||||||
|
continue;
|
||||||
|
freeInd.push_back( iF );
|
||||||
// find source edge of a free face iF
|
// find source edge of a free face iF
|
||||||
vector<const SMDS_MeshNode*> commonNodes; // shared by the initial and free faces
|
vector<const SMDS_MeshNode*> commonNodes; // shared by the initial and free faces
|
||||||
commonNodes.resize( initNodeSet.size(), NULL ); // avoid spoiling memory
|
commonNodes.resize( initNodeSet.size(), NULL ); // avoid spoiling memory
|
||||||
std::set_intersection( faceNodeSet.begin(), faceNodeSet.end(),
|
std::set_intersection( faceNodeSet.begin(), faceNodeSet.end(),
|
||||||
initNodeSet.begin(), initNodeSet.end(),
|
initNodeSet.begin(), initNodeSet.end(),
|
||||||
commonNodes.begin());
|
commonNodes.begin());
|
||||||
if (!commonNodes[ 1 + int((*v)->IsQuadratic()) ]) {
|
|
||||||
#ifdef _DEBUG_
|
|
||||||
throw SALOME_Exception(LOCALIZED("Common nodes not found"));
|
|
||||||
#else
|
|
||||||
srcEdges.push_back( NULL );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if ( (*v)->IsQuadratic() )
|
if ( (*v)->IsQuadratic() )
|
||||||
srcEdges.push_back(aMesh-> FindEdge (commonNodes[0],commonNodes[1],commonNodes[2]));
|
srcEdges.push_back(aMesh->FindEdge (commonNodes[0],commonNodes[1],commonNodes[2]));
|
||||||
else
|
else
|
||||||
srcEdges.push_back(aMesh-> FindEdge (commonNodes[0],commonNodes[1]));
|
srcEdges.push_back(aMesh->FindEdge (commonNodes[0],commonNodes[1]));
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
if ( !srcEdges.back() )
|
if ( !srcEdges.back() )
|
||||||
throw SALOME_Exception(LOCALIZED("Source edge not found"));
|
{
|
||||||
|
cout << "SMESH_MeshEditor::makeWalls(), no source edge found for a free face #"
|
||||||
|
<< iF << " of volume #" << vTool.ID() << endl;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( fInd.empty() )
|
if ( freeInd.empty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// create faces for all steps;
|
// create faces for all steps;
|
||||||
@ -3272,9 +3274,9 @@ void SMESH_MeshEditor::makeWalls (TNodeOfNodeListMap & mapNewNodes,
|
|||||||
for ( int iStep = 0; iStep < nbSteps; iStep++ ) {
|
for ( int iStep = 0; iStep < nbSteps; iStep++ ) {
|
||||||
vTool.Set( *v );
|
vTool.Set( *v );
|
||||||
vTool.SetExternalNormal();
|
vTool.SetExternalNormal();
|
||||||
list< int >::iterator ind = fInd.begin();
|
list< int >::iterator ind = freeInd.begin();
|
||||||
list< const SMDS_MeshElement* >::iterator srcEdge = srcEdges.begin();
|
list< const SMDS_MeshElement* >::iterator srcEdge = srcEdges.begin();
|
||||||
for ( ; ind != fInd.end(); ++ind, ++srcEdge ) // loop on free faces
|
for ( ; ind != freeInd.end(); ++ind, ++srcEdge ) // loop on free faces
|
||||||
{
|
{
|
||||||
const SMDS_MeshNode** nodes = vTool.GetFaceNodes( *ind );
|
const SMDS_MeshNode** nodes = vTool.GetFaceNodes( *ind );
|
||||||
int nbn = vTool.NbFaceNodes( *ind );
|
int nbn = vTool.NbFaceNodes( *ind );
|
||||||
@ -4132,7 +4134,8 @@ SMESH_MeshEditor::PGroupIDs
|
|||||||
SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
||||||
const gp_Trsf& theTrsf,
|
const gp_Trsf& theTrsf,
|
||||||
const bool theCopy,
|
const bool theCopy,
|
||||||
const bool theMakeGroups)
|
const bool theMakeGroups,
|
||||||
|
SMESH_Mesh* theTargetMesh)
|
||||||
{
|
{
|
||||||
myLastCreatedElems.Clear();
|
myLastCreatedElems.Clear();
|
||||||
myLastCreatedNodes.Clear();
|
myLastCreatedNodes.Clear();
|
||||||
@ -4160,7 +4163,10 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
groupPostfix = "transformed";
|
groupPostfix = "transformed";
|
||||||
}
|
}
|
||||||
|
|
||||||
SMESHDS_Mesh* aMesh = GetMeshDS();
|
SMESH_MeshEditor targetMeshEditor( theTargetMesh );
|
||||||
|
SMESHDS_Mesh* aTgtMesh = theTargetMesh ? theTargetMesh->GetMeshDS() : 0;
|
||||||
|
SMESHDS_Mesh* aMesh = GetMeshDS();
|
||||||
|
|
||||||
|
|
||||||
// map old node to new one
|
// map old node to new one
|
||||||
TNodeNodeMap nodeMap;
|
TNodeNodeMap nodeMap;
|
||||||
@ -4185,9 +4191,9 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
|
|
||||||
// check if a node has been already transformed
|
// check if a node has been already transformed
|
||||||
const SMDS_MeshNode* node = cast2Node( itN->next() );
|
const SMDS_MeshNode* node = cast2Node( itN->next() );
|
||||||
pair<TNodeNodeMap::iterator,bool> iter_isnew =
|
pair<TNodeNodeMap::iterator,bool> n2n_isnew =
|
||||||
nodeMap.insert( make_pair ( node, node ));
|
nodeMap.insert( make_pair ( node, node ));
|
||||||
if ( !iter_isnew.second )
|
if ( !n2n_isnew.second )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double coord[3];
|
double coord[3];
|
||||||
@ -4195,9 +4201,15 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
coord[1] = node->Y();
|
coord[1] = node->Y();
|
||||||
coord[2] = node->Z();
|
coord[2] = node->Z();
|
||||||
theTrsf.Transforms( coord[0], coord[1], coord[2] );
|
theTrsf.Transforms( coord[0], coord[1], coord[2] );
|
||||||
if ( theCopy ) {
|
if ( theTargetMesh ) {
|
||||||
|
const SMDS_MeshNode * newNode = aTgtMesh->AddNode( coord[0], coord[1], coord[2] );
|
||||||
|
n2n_isnew.first->second = newNode;
|
||||||
|
myLastCreatedNodes.Append(newNode);
|
||||||
|
srcNodes.Append( node );
|
||||||
|
}
|
||||||
|
else if ( theCopy ) {
|
||||||
const SMDS_MeshNode * newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
|
const SMDS_MeshNode * newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
|
||||||
iter_isnew.first->second = newNode;
|
n2n_isnew.first->second = newNode;
|
||||||
myLastCreatedNodes.Append(newNode);
|
myLastCreatedNodes.Append(newNode);
|
||||||
srcNodes.Append( node );
|
srcNodes.Append( node );
|
||||||
}
|
}
|
||||||
@ -4209,7 +4221,7 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keep inverse elements
|
// keep inverse elements
|
||||||
if ( !theCopy && needReverse ) {
|
if ( !theCopy && !theTargetMesh && needReverse ) {
|
||||||
SMDS_ElemIteratorPtr invElemIt = node->GetInverseElementIterator();
|
SMDS_ElemIteratorPtr invElemIt = node->GetInverseElementIterator();
|
||||||
while ( invElemIt->more() ) {
|
while ( invElemIt->more() ) {
|
||||||
const SMDS_MeshElement* iel = invElemIt->next();
|
const SMDS_MeshElement* iel = invElemIt->next();
|
||||||
@ -4220,7 +4232,7 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// either create new elements or reverse mirrored ones
|
// either create new elements or reverse mirrored ones
|
||||||
if ( !theCopy && !needReverse)
|
if ( !theCopy && !needReverse && !theTargetMesh )
|
||||||
return PGroupIDs();
|
return PGroupIDs();
|
||||||
|
|
||||||
TIDSortedElemSet::iterator invElemIt = inverseElemSet.begin();
|
TIDSortedElemSet::iterator invElemIt = inverseElemSet.begin();
|
||||||
@ -4280,7 +4292,11 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
if ( iNode != nbNodes )
|
if ( iNode != nbNodes )
|
||||||
continue; // not all nodes transformed
|
continue; // not all nodes transformed
|
||||||
|
|
||||||
if ( theCopy ) {
|
if ( theTargetMesh ) {
|
||||||
|
myLastCreatedElems.Append(aTgtMesh->AddPolygonalFace(poly_nodes));
|
||||||
|
srcElems.Append( elem );
|
||||||
|
}
|
||||||
|
else if ( theCopy ) {
|
||||||
myLastCreatedElems.Append(aMesh->AddPolygonalFace(poly_nodes));
|
myLastCreatedElems.Append(aMesh->AddPolygonalFace(poly_nodes));
|
||||||
srcElems.Append( elem );
|
srcElems.Append( elem );
|
||||||
}
|
}
|
||||||
@ -4320,7 +4336,11 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
if ( !allTransformed )
|
if ( !allTransformed )
|
||||||
continue; // not all nodes transformed
|
continue; // not all nodes transformed
|
||||||
|
|
||||||
if ( theCopy ) {
|
if ( theTargetMesh ) {
|
||||||
|
myLastCreatedElems.Append(aTgtMesh->AddPolyhedralVolume(poly_nodes, quantities));
|
||||||
|
srcElems.Append( elem );
|
||||||
|
}
|
||||||
|
else if ( theCopy ) {
|
||||||
myLastCreatedElems.Append(aMesh->AddPolyhedralVolume(poly_nodes, quantities));
|
myLastCreatedElems.Append(aMesh->AddPolyhedralVolume(poly_nodes, quantities));
|
||||||
srcElems.Append( elem );
|
srcElems.Append( elem );
|
||||||
}
|
}
|
||||||
@ -4329,18 +4349,18 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Regular elements
|
// Regular elements
|
||||||
int* i = index[ FORWARD ];
|
int* i = index[ FORWARD ];
|
||||||
if ( needReverse && nbNodes > 2) // reverse mirrored faces and volumes
|
if ( needReverse && nbNodes > 2) // reverse mirrored faces and volumes
|
||||||
if ( elemType == SMDSAbs_Face )
|
if ( elemType == SMDSAbs_Face )
|
||||||
i = index[ REV_FACE ];
|
i = index[ REV_FACE ];
|
||||||
else
|
else
|
||||||
i = index[ nbNodes - 4 ];
|
i = index[ nbNodes - 4 ];
|
||||||
|
|
||||||
if(elem->IsQuadratic()) {
|
if(elem->IsQuadratic()) {
|
||||||
static int anIds[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
|
static int anIds[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
|
||||||
@ -4392,14 +4412,20 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
if ( iNode != nbNodes )
|
if ( iNode != nbNodes )
|
||||||
continue; // not all nodes transformed
|
continue; // not all nodes transformed
|
||||||
|
|
||||||
if ( theCopy ) {
|
if ( theTargetMesh ) {
|
||||||
|
if ( SMDS_MeshElement* copy =
|
||||||
|
targetMeshEditor.AddElement( nodes, elem->GetType(), elem->IsPoly() )) {
|
||||||
|
myLastCreatedElems.Append( copy );
|
||||||
|
srcElems.Append( elem );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( theCopy ) {
|
||||||
if ( SMDS_MeshElement* copy = AddElement( nodes, elem->GetType(), elem->IsPoly() )) {
|
if ( SMDS_MeshElement* copy = AddElement( nodes, elem->GetType(), elem->IsPoly() )) {
|
||||||
myLastCreatedElems.Append( copy );
|
myLastCreatedElems.Append( copy );
|
||||||
srcElems.Append( elem );
|
srcElems.Append( elem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// reverse element as it was reversed by transformation
|
// reverse element as it was reversed by transformation
|
||||||
if ( nbNodes > 2 )
|
if ( nbNodes > 2 )
|
||||||
aMesh->ChangeElementNodes( elem, &nodes[0], nbNodes );
|
aMesh->ChangeElementNodes( elem, &nodes[0], nbNodes );
|
||||||
@ -4408,8 +4434,9 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
|
|
||||||
PGroupIDs newGroupIDs;
|
PGroupIDs newGroupIDs;
|
||||||
|
|
||||||
if ( theCopy && theMakeGroups )
|
if ( theMakeGroups && theCopy ||
|
||||||
newGroupIDs = generateGroups( srcNodes, srcElems, groupPostfix );
|
theMakeGroups && theTargetMesh )
|
||||||
|
newGroupIDs = generateGroups( srcNodes, srcElems, groupPostfix, theTargetMesh );
|
||||||
|
|
||||||
return newGroupIDs;
|
return newGroupIDs;
|
||||||
}
|
}
|
||||||
@ -4426,24 +4453,27 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
|
|||||||
SMESH_MeshEditor::PGroupIDs
|
SMESH_MeshEditor::PGroupIDs
|
||||||
SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
||||||
const SMESH_SequenceOfElemPtr& elemGens,
|
const SMESH_SequenceOfElemPtr& elemGens,
|
||||||
const std::string& postfix)
|
const std::string& postfix,
|
||||||
|
SMESH_Mesh* targetMesh)
|
||||||
{
|
{
|
||||||
PGroupIDs newGroupIDs( new list<int> );
|
PGroupIDs newGroupIDs( new list<int> );
|
||||||
|
SMESH_Mesh* mesh = targetMesh ? targetMesh : GetMesh();
|
||||||
|
|
||||||
// Sort existing groups by types and collect their names
|
// Sort existing groups by types and collect their names
|
||||||
|
|
||||||
// store an old group and a generated new one
|
// to store an old group and a generated new one
|
||||||
typedef pair< SMESHDS_Group*, SMDS_MeshGroup* > TOldNewGroup;
|
typedef pair< SMESHDS_GroupBase*, SMDS_MeshGroup* > TOldNewGroup;
|
||||||
vector< list< TOldNewGroup > > groupsByType( SMDSAbs_NbElementTypes );
|
vector< list< TOldNewGroup > > groupsByType( SMDSAbs_NbElementTypes );
|
||||||
// group names
|
// group names
|
||||||
set< string > groupNames;
|
set< string > groupNames;
|
||||||
|
//
|
||||||
SMDS_MeshGroup* nullNewGroup = (SMDS_MeshGroup*) 0;
|
SMDS_MeshGroup* nullNewGroup = (SMDS_MeshGroup*) 0;
|
||||||
SMESH_Mesh::GroupIteratorPtr groupIt = GetMesh()->GetGroups();
|
SMESH_Mesh::GroupIteratorPtr groupIt = GetMesh()->GetGroups();
|
||||||
while ( groupIt->more() ) {
|
while ( groupIt->more() ) {
|
||||||
SMESH_Group * group = groupIt->next();
|
SMESH_Group * group = groupIt->next();
|
||||||
if ( !group ) continue;
|
if ( !group ) continue;
|
||||||
SMESHDS_Group* groupDS = dynamic_cast< SMESHDS_Group* >( group->GetGroupDS() );
|
SMESHDS_GroupBase* groupDS = group->GetGroupDS();
|
||||||
if ( !groupDS ) continue;
|
if ( !groupDS || groupDS->IsEmpty() ) continue;
|
||||||
groupNames.insert( group->GetName() );
|
groupNames.insert( group->GetName() );
|
||||||
groupDS->SetStoreName( group->GetName() );
|
groupDS->SetStoreName( group->GetName() );
|
||||||
groupsByType[ groupDS->GetType() ].push_back( make_pair( groupDS, nullNewGroup ));
|
groupsByType[ groupDS->GetType() ].push_back( make_pair( groupDS, nullNewGroup ));
|
||||||
@ -4470,7 +4500,7 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
|||||||
list< TOldNewGroup > & groupsOldNew = groupsByType[ sourceElem->GetType() ];
|
list< TOldNewGroup > & groupsOldNew = groupsByType[ sourceElem->GetType() ];
|
||||||
if ( groupsOldNew.empty() ) {
|
if ( groupsOldNew.empty() ) {
|
||||||
while ( iElem < gens.Length() && gens( iElem+1 ) == sourceElem )
|
while ( iElem < gens.Length() && gens( iElem+1 ) == sourceElem )
|
||||||
++iElem;
|
++iElem; // skip all elements made by sourceElem
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// collect all elements made by sourceElem
|
// collect all elements made by sourceElem
|
||||||
@ -4491,32 +4521,35 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
|||||||
list< TOldNewGroup >::iterator gOldNew, gLast = groupsOldNew.end();
|
list< TOldNewGroup >::iterator gOldNew, gLast = groupsOldNew.end();
|
||||||
for ( gOldNew = groupsOldNew.begin(); gOldNew != gLast; ++gOldNew )
|
for ( gOldNew = groupsOldNew.begin(); gOldNew != gLast; ++gOldNew )
|
||||||
{
|
{
|
||||||
SMESHDS_Group* oldGroup = gOldNew->first;
|
SMESHDS_GroupBase* oldGroup = gOldNew->first;
|
||||||
if ( oldGroup->SMDSGroup().Contains( sourceElem )) // sourceElem in oldGroup
|
if ( oldGroup->Contains( sourceElem )) // sourceElem in oldGroup
|
||||||
{
|
{
|
||||||
SMDS_MeshGroup* & newGroup = gOldNew->second;
|
SMDS_MeshGroup* & newGroup = gOldNew->second;
|
||||||
if ( !newGroup )// create a new group
|
if ( !newGroup )// create a new group
|
||||||
{
|
{
|
||||||
// make a name
|
// make a name
|
||||||
string name = oldGroup->GetStoreName();
|
string name = oldGroup->GetStoreName();
|
||||||
name += "_";
|
if ( !targetMesh ) {
|
||||||
name += postfix;
|
name += "_";
|
||||||
int nb = 0;
|
name += postfix;
|
||||||
while ( !groupNames.insert( name ).second ) // name exists
|
int nb = 0;
|
||||||
{
|
while ( !groupNames.insert( name ).second ) // name exists
|
||||||
if ( nb == 0 ) {
|
{
|
||||||
name += "_1";
|
if ( nb == 0 ) {
|
||||||
}
|
name += "_1";
|
||||||
else {
|
}
|
||||||
TCollection_AsciiString nbStr(++nb);
|
else {
|
||||||
name.resize( name.rfind('_') );
|
TCollection_AsciiString nbStr(nb+1);
|
||||||
name += nbStr.ToCString();
|
name.resize( name.rfind('_')+1 );
|
||||||
|
name += nbStr.ToCString();
|
||||||
|
}
|
||||||
|
++nb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// make a group
|
// make a group
|
||||||
int id;
|
int id;
|
||||||
SMESH_Group* group = GetMesh()->AddGroup( resultElems.back()->GetType(),
|
SMESH_Group* group = mesh->AddGroup( resultElems.back()->GetType(),
|
||||||
name.c_str(), id );
|
name.c_str(), id );
|
||||||
SMESHDS_Group* groupDS = static_cast<SMESHDS_Group*>(group->GetGroupDS());
|
SMESHDS_Group* groupDS = static_cast<SMESHDS_Group*>(group->GetGroupDS());
|
||||||
newGroup = & groupDS->SMDSGroup();
|
newGroup = & groupDS->SMDSGroup();
|
||||||
newGroupIDs->push_back( id );
|
newGroupIDs->push_back( id );
|
||||||
|
@ -296,7 +296,8 @@ public:
|
|||||||
PGroupIDs Transform (TIDSortedElemSet & theElements,
|
PGroupIDs Transform (TIDSortedElemSet & theElements,
|
||||||
const gp_Trsf& theTrsf,
|
const gp_Trsf& theTrsf,
|
||||||
const bool theCopy,
|
const bool theCopy,
|
||||||
const bool theMakeGroups);
|
const bool theMakeGroups,
|
||||||
|
SMESH_Mesh* theTargetMesh=0);
|
||||||
// Move or copy theElements applying theTrsf to their nodes
|
// Move or copy theElements applying theTrsf to their nodes
|
||||||
|
|
||||||
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
|
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
|
||||||
@ -531,7 +532,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
|
||||||
const SMESH_SequenceOfElemPtr& elemGens,
|
const SMESH_SequenceOfElemPtr& elemGens,
|
||||||
const std::string& postfix);
|
const std::string& postfix,
|
||||||
|
SMESH_Mesh* targetMesh=0);
|
||||||
|
|
||||||
|
|
||||||
typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
|
typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user