IPAL54401: Offset dialog bug

This commit is contained in:
eap 2018-06-19 14:00:57 +03:00
parent b7a7d49664
commit c704eadf04
9 changed files with 63 additions and 25 deletions

View File

@ -36,7 +36,7 @@ This information can be defined using either of two hypotheses:
.. centered:: .. centered::
*"Distribution of layers"* hypothesis *"Distribution of layers"* hypothesis
*Distribution of layers* hypothesis allows using any of *Distribution of layers* hypothesis allows using most of
:ref:`1D Hypotheses <a1d_meshing_hypo_page>` to define :ref:`1D Hypotheses <a1d_meshing_hypo_page>` to define
the distribution of mesh layers. the distribution of mesh layers.

View File

@ -691,6 +691,7 @@ module SMESH
SMESH_Mesh Offset(in SMESH_IDSource theObject, SMESH_Mesh Offset(in SMESH_IDSource theObject,
in double Value, in double Value,
in boolean CopyGroups, in boolean CopyGroups,
in boolean CopyElements,
in string MeshName, in string MeshName,
out ListOfGroups Groups) out ListOfGroups Groups)
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);

View File

@ -6741,6 +6741,7 @@ SMESH_MeshEditor::PGroupIDs SMESH_MeshEditor::Offset( TIDSortedElemSet & theElem
const double theValue, const double theValue,
SMESH_Mesh* theTgtMesh, SMESH_Mesh* theTgtMesh,
const bool theMakeGroups, const bool theMakeGroups,
const bool theCopyElements,
const bool theFixSelfIntersection) const bool theFixSelfIntersection)
{ {
SMESHDS_Mesh* meshDS = GetMeshDS(); SMESHDS_Mesh* meshDS = GetMeshDS();
@ -6757,6 +6758,18 @@ SMESH_MeshEditor::PGroupIDs SMESH_MeshEditor::Offset( TIDSortedElemSet & theElem
( SMESH_MeshAlgos::MakeOffset( eIt, *meshDS, theValue, ( SMESH_MeshAlgos::MakeOffset( eIt, *meshDS, theValue,
theFixSelfIntersection, theFixSelfIntersection,
new2OldFaces, new2OldNodes )); new2OldFaces, new2OldNodes ));
if ( offsetMesh->NbElements() == 0 )
return PGroupIDs(); // MakeOffset() failed
if ( theTgtMesh == myMesh && !theCopyElements )
{
// clear the source elements
if ( theElements.empty() ) eIt = meshDS->elementsIterator( SMDSAbs_Face );
else eIt = SMESHUtils::elemSetIterator( theElements );
while ( eIt->more() )
meshDS->RemoveFreeElement( eIt->next(), 0 );
}
offsetMesh->Modified(); offsetMesh->Modified();
offsetMesh->CompactMesh(); // make IDs start from 1 offsetMesh->CompactMesh(); // make IDs start from 1
@ -12883,7 +12896,7 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
tgtNodes.resize( srcNodes.size() ); tgtNodes.resize( srcNodes.size() );
for ( inode = 0; inode < srcNodes.size(); ++inode ) for ( inode = 0; inode < srcNodes.size(); ++inode )
tgtNodes[inode] = getNodeWithSameID( tgtMeshDS, srcNodes[inode] ); tgtNodes[inode] = getNodeWithSameID( tgtMeshDS, srcNodes[inode] );
if ( aroundElements && tgtEditor.GetMeshDS()->FindElement( tgtNodes, if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( tgtNodes,
missType, missType,
/*noMedium=*/false)) /*noMedium=*/false))
continue; continue;
@ -12894,7 +12907,7 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
for ( size_t i = 0; i < missingBndElems.size(); ++i ) for ( size_t i = 0; i < missingBndElems.size(); ++i )
{ {
TConnectivity& nodes = missingBndElems[ i ]; TConnectivity& nodes = missingBndElems[ i ];
if ( aroundElements && tgtEditor.GetMeshDS()->FindElement( nodes, if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( nodes,
missType, missType,
/*noMedium=*/false)) /*noMedium=*/false))
continue; continue;

View File

@ -469,6 +469,7 @@ public:
const double theValue, const double theValue,
SMESH_Mesh* theTgtMesh, SMESH_Mesh* theTgtMesh,
const bool theMakeGroups, const bool theMakeGroups,
const bool theCopyElements,
const bool theFixSelfIntersection); const bool theFixSelfIntersection);
// Make an offset mesh from a source 2D mesh // Make an offset mesh from a source 2D mesh

View File

@ -351,6 +351,7 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
aParameters << SpinBox->text(); aParameters << SpinBox->text();
int actionButton = ActionGroup->checkedId(); int actionButton = ActionGroup->checkedId();
bool copyElements = ( actionButton == COPY_ELEMS_BUTTON );
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
SMESH::ListOfGroups_var groups; SMESH::ListOfGroups_var groups;
SMESH::SMESH_Mesh_var mesh; SMESH::SMESH_Mesh_var mesh;
@ -360,17 +361,20 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
switch ( actionButton ) { switch ( actionButton ) {
case MOVE_ELEMS_BUTTON: case MOVE_ELEMS_BUTTON:
makeGroups = true;
if ( CheckBoxMesh->isChecked() ) if ( CheckBoxMesh->isChecked() )
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); myMeshes[i]->SetParameters( aParameters.join( ":" ).toLatin1().constData() );
mesh = aMeshEditor->Offset( myObjects[i], offsetValue, true, "", groups.out() ); mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups,
copyElements, "", groups.out() );
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE); SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE);
myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() );
mesh = aMeshEditor->Offset( src, offsetValue, true, "", groups.out() ); mesh = aMeshEditor->Offset( src, offsetValue, makeGroups,
copyElements, "", groups.out() );
} }
break; break;
@ -379,13 +383,15 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups, "", groups.out() ); mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups,
copyElements, "", groups.out() );
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE ); SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE );
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->Offset( src, offsetValue, makeGroups, "", groups.out() ); mesh = aMeshEditor->Offset( src, offsetValue, makeGroups,
copyElements, "", groups.out() );
} }
break; break;
@ -397,7 +403,7 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] )); SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ));
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups, mesh = aMeshEditor->Offset( myObjects[i], offsetValue, makeGroups, copyElements,
aName.toLatin1().data(), groups.out() ); aName.toLatin1().data(), groups.out() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh )) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ))
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
@ -407,7 +413,7 @@ bool SMESHGUI_OffsetDlg::ClickOnApply()
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE ); SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE );
mesh = aMeshEditor->Offset( src, offsetValue, makeGroups, mesh = aMeshEditor->Offset( src, offsetValue, makeGroups, copyElements,
LineEditNewMesh->text().toLatin1().data(), groups.out() ); LineEditNewMesh->text().toLatin1().data(), groups.out() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
@ -907,7 +913,7 @@ void SMESHGUI_OffsetDlg::onDisplaySimulation( bool toDisplayPreview )
for ( int i = 0; i < myObjects.count(); i++ ) for ( int i = 0; i < myObjects.count(); i++ )
{ {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer();
mesh = aMeshEditor->Offset( myObjects[i], offsetValue, false, "", groups.out() ); mesh = aMeshEditor->Offset( myObjects[i], offsetValue, false, false, "", groups.out() );
aMeshPreviewStruct << aMeshEditor->GetPreviewData(); aMeshPreviewStruct << aMeshEditor->GetPreviewData();
} }
else else
@ -920,7 +926,7 @@ void SMESHGUI_OffsetDlg::onDisplaySimulation( bool toDisplayPreview )
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE); SMESH::IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::FACE);
mesh = aMeshEditor->Offset( src, offsetValue, false, "", groups.out() ); mesh = aMeshEditor->Offset( src, offsetValue, false, false, "", groups.out() );
aMeshPreviewStruct << aMeshEditor->GetPreviewData(); aMeshPreviewStruct << aMeshEditor->GetPreviewData();
} }
setSimulationPreview(aMeshPreviewStruct); setSimulationPreview(aMeshPreviewStruct);

View File

@ -682,10 +682,9 @@ namespace
dot *= -1; dot *= -1;
if ( dot * theSign < 0 ) if ( dot * theSign < 0 )
{ {
useOneNormal = true; gp_XYZ p1 = oldXYZ + faces[ i ].Norm() * theOffset;
// gp_XYZ p1 = oldXYZ + faces[ i ].Norm() * theOffset; gp_XYZ p2 = oldXYZ + faces[ iPrev ].Norm() * theOffset;
// gp_XYZ p2 = oldXYZ + faces[ iPrev ].Norm() * theOffset; useOneNormal = ( p1 - p2 ).SquareModulus() > 1e-12;
// useOneNormal = ( p1 - p2 ).SquareModulus() > theTol * theTol;
} }
} }
if ( useOneNormal && theNewNode->isMarked() ) if ( useOneNormal && theNewNode->isMarked() )

View File

@ -4034,6 +4034,7 @@ SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theObject, SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theObject,
CORBA::Double theValue, CORBA::Double theValue,
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
CORBA::Boolean theCopyElements,
const char* theMeshName, const char* theMeshName,
SMESH::ListOfGroups_out theGroups) SMESH::ListOfGroups_out theGroups)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
@ -4059,7 +4060,9 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
TPreviewMesh * tmpMesh = getPreviewMesh(); TPreviewMesh * tmpMesh = getPreviewMesh();
tgtMesh = tmpMesh; tgtMesh = tmpMesh;
tmpMesh->Copy( elements, copyElements ); tmpMesh->Copy( elements, copyElements );
elements.swap( copyElements );
theCopyGroups = false; theCopyGroups = false;
theCopyElements = false;
} }
else else
{ {
@ -4068,26 +4071,39 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var ); SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
tgtMesh = & mesh_i->GetImpl(); tgtMesh = & mesh_i->GetImpl();
} }
groupIds = getEditor().Offset( elements, theValue, tgtMesh, theCopyGroups, !myIsPreviewMode ); groupIds = getEditor().Offset( elements, theValue, tgtMesh,
theCopyGroups, theCopyElements, !myIsPreviewMode );
tgtMesh->GetMeshDS()->Modified(); tgtMesh->GetMeshDS()->Modified();
} }
if ( myIsPreviewMode ) if ( myIsPreviewMode )
{ {
getPreviewMesh()->Remove( SMESHUtils::elemSetIterator( copyElements )); //getPreviewMesh()->Remove( SMESHUtils::elemSetIterator( copyElements ));
} }
else else
{ {
theGroups = theCopyGroups ? getGroups( groupIds.get() ) : new SMESH::ListOfGroups; theGroups = theCopyGroups ? getGroups( groupIds.get() ) : new SMESH::ListOfGroups;
if ( *theMeshName && mesh_var->NbFaces() == 0 )
{
// new mesh empty, remove it
SMESH_Gen_i* smesh = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_var study = smesh->GetCurrentStudy();
SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
SALOMEDS::SObject_wrap meshSO = smesh->ObjectToSObject( study, mesh_var );
builder->RemoveObjectWithChildren( meshSO );
THROW_SALOME_CORBA_EXCEPTION("Offset failed", SALOME::INTERNAL_ERROR);
}
// result of Offset() is a tuple (mesh, groups) // result of Offset() is a tuple (mesh, groups)
if ( mesh_var->_is_nil() ) pyDump << myMesh_i->_this() << ", "; if ( mesh_var->_is_nil() ) pyDump << myMesh_i->_this() << ", ";
else pyDump << mesh_var << ", "; else pyDump << mesh_var << ", ";
pyDump << theGroups << " = " pyDump << theGroups << " = " << this << ".Offset( "
<< this << ".Offset( " << theObject << ", "
<< theValue << ", " << theValue << ", "
<< theCopyGroups << ", " << theCopyGroups << ", "
<< theCopyElements << ", "
<< "'" << theMeshName<< "')"; << "'" << theMeshName<< "')";
} }

View File

@ -482,6 +482,7 @@ public:
SMESH::SMESH_Mesh_ptr Offset( SMESH::SMESH_IDSource_ptr theObject, SMESH::SMESH_Mesh_ptr Offset( SMESH::SMESH_IDSource_ptr theObject,
CORBA::Double Value, CORBA::Double Value,
CORBA::Boolean CopyGroups, CORBA::Boolean CopyGroups,
CORBA::Boolean CopyElements,
const char* MeshName, const char* MeshName,
SMESH::ListOfGroups_out Groups) SMESH::ListOfGroups_out Groups)
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);

View File

@ -1156,7 +1156,7 @@ class StdMeshersBuilder_Projection3D(Mesh_Algorithm):
class StdMeshersBuilder_Prism3D(Mesh_Algorithm): class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
""" """
Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry.
It is created by calling smeshBuilder.Mesh.Prism(geom=0) It is created by calling smeshBuilder.Mesh.Prism(geom=0)
""" """
@ -1367,11 +1367,12 @@ class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D): class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D):
""" """
Defines Radial Prism 3D algorithm Defines Radial Prism 3D algorithm.
It is created by calling smeshBuilder.Mesh.Prism(geom=0) It is created by calling smeshBuilder.Mesh.Prism(geom=0).
See :class:`StdMeshersBuilder_Prism3D` for methods defining distribution of mesh layers
build between the inner and outer shells.
""" """
meshMethod = "Prism" meshMethod = "Prism"
""" """
name of the dynamic method in smeshBuilder.Mesh class name of the dynamic method in smeshBuilder.Mesh class