mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-11 16:19:16 +05:00
First working version
Missing update of object browser + parameters + generic adaptation to shape
This commit is contained in:
parent
1b69b0f98a
commit
246a01ab71
@ -284,6 +284,14 @@ module SMESH
|
||||
in boolean theMakeRequiredGroups,
|
||||
out SMESH::ComputeError theError)
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
/*!
|
||||
* Create a dual mesh of a Tetrahedron mesh
|
||||
* \param meshPart - TetraHedron mesh to create dual from
|
||||
* \param meshName - a name of the new mesh
|
||||
*/
|
||||
SMESH_Mesh CreateDualMesh(in SMESH_IDSource mesh,
|
||||
in string meshName)
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Create a mesh by copying a part of another mesh
|
||||
|
@ -157,6 +157,8 @@ SET(_moc_HEADERS
|
||||
SMESHGUI_AddNodeOnSegmentDlg.h
|
||||
SMESHGUI_AddNodeOnFaceDlg.h
|
||||
SMESHGUI_InteractiveOp.h
|
||||
SMESHGUI_CreateDualMeshDlg.h
|
||||
SMESHGUI_CreateDualMeshOp.h
|
||||
)
|
||||
|
||||
# header files / no moc processing
|
||||
@ -283,6 +285,8 @@ SET(_other_SOURCES
|
||||
SMESHGUI_AddNodeOnSegmentDlg.cxx
|
||||
SMESHGUI_AddNodeOnFaceDlg.cxx
|
||||
SMESHGUI_InteractiveOp.cxx
|
||||
SMESHGUI_CreateDualMeshDlg.cxx
|
||||
SMESHGUI_CreateDualMeshOp.cxx
|
||||
)
|
||||
|
||||
# sources / to compile
|
||||
|
@ -97,6 +97,8 @@
|
||||
#include "SMESHGUI_SymmetryDlg.h"
|
||||
#include "SMESHGUI_TranslationDlg.h"
|
||||
#include "SMESHGUI_TransparencyDlg.h"
|
||||
#include "SMESHGUI_CreateDualMeshDlg.h"
|
||||
#include "SMESHGUI_CreateDualMeshOp.h"
|
||||
#include "SMESHGUI_Utils.h"
|
||||
#include "SMESHGUI_VTKUtils.h"
|
||||
|
||||
@ -3051,6 +3053,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
||||
// Adaptation - end
|
||||
case SMESHOp::OpSplitBiQuadratic:
|
||||
case SMESHOp::OpConvertMeshToQuadratic:
|
||||
case SMESHOp::OpCreateDualMesh:
|
||||
case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
|
||||
case SMESHOp::OpReorientFaces:
|
||||
case SMESHOp::OpCreateGeometryGroup:
|
||||
@ -4275,6 +4278,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
|
||||
createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
|
||||
createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
|
||||
createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
|
||||
createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
|
||||
|
||||
createSMESHAction( SMESHOp::OpReset, "RESET" );
|
||||
@ -4524,6 +4528,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
|
||||
createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
|
||||
createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
|
||||
createMenu( SMESHOp::OpCreateDualMesh, modifyId, -1 );
|
||||
createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
|
||||
createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
|
||||
createMenu( SMESHOp::OpRevolution, modifyId, -1 );
|
||||
@ -4675,6 +4680,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
|
||||
int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
|
||||
createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
|
||||
createTool( SMESHOp::OpCreateDualMesh, modifyTb );
|
||||
createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
|
||||
createTool( SMESHOp::OpExtrusion, modifyTb );
|
||||
createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
|
||||
@ -4788,6 +4794,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
popupMgr()->insert( separator(), -1, 0 );
|
||||
createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
|
||||
createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
|
||||
createPopupItem( SMESHOp::OpCreateDualMesh, OB, mesh_submesh, "&& selcount=1 && dim>=2");
|
||||
|
||||
// Adaptation - begin
|
||||
popupMgr()->insert( separator(), -1, 0 );
|
||||
@ -6025,6 +6032,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
|
||||
case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
|
||||
op = new SMESHGUI_Make2DFrom3DOp();
|
||||
break;
|
||||
case SMESHOp::OpCreateDualMesh:
|
||||
op = new SMESHGUI_CreateDualMeshOp();
|
||||
break;
|
||||
case SMESHOp::OpReorientFaces:
|
||||
op = new SMESHGUI_ReorientFacesOp();
|
||||
break;
|
||||
|
86
src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx
Normal file
86
src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright (C) 2007-2021 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, 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
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// SMESH SMESHGUI : GUI for SMESH component
|
||||
// File : SMESHGUI_CreateDualMeshDlg.cxx
|
||||
// Author : Yoann AUDOUIN (EDF)
|
||||
// SMESH includes
|
||||
//
|
||||
#include "SMESHGUI_CreateDualMeshDlg.h"
|
||||
|
||||
#include "SMESHGUI_CreateDualMeshOp.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QGroupBox>
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#define SPACING 6
|
||||
#define MARGIN 11
|
||||
|
||||
SMESHGUI_CreateDualMeshDlg::SMESHGUI_CreateDualMeshDlg()
|
||||
: SMESHGUI_Dialog( 0, false, true )
|
||||
{
|
||||
setWindowTitle( tr( "CAPTION" ) );
|
||||
|
||||
// Create top controls
|
||||
|
||||
// mesh
|
||||
setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
|
||||
createObject( tr( "MESH" ), mainFrame(), 0 );
|
||||
|
||||
myWarning = new QLabel(QString("<b>%1</b>").arg(tr("NON_TETRA_MESH_WARNING")), mainFrame());
|
||||
|
||||
// Fill layout
|
||||
QGridLayout* aLay = new QGridLayout( mainFrame() );
|
||||
aLay->setMargin( 5 );
|
||||
aLay->setSpacing( 5 );
|
||||
|
||||
aLay->addWidget( objectWg( 0, Label ), 0, 0 );
|
||||
aLay->addWidget( objectWg( 0, Btn ), 0, 1 );
|
||||
aLay->addWidget( objectWg( 0, Control ), 0, 2 );
|
||||
aLay->addWidget( myWarning, 3, 0, 1, 3 );
|
||||
|
||||
}
|
||||
|
||||
SMESHGUI_CreateDualMeshDlg::~SMESHGUI_CreateDualMeshDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void SMESHGUI_CreateDualMeshDlg::ShowWarning(bool toShow)
|
||||
{
|
||||
if ( toShow )
|
||||
myWarning->show();
|
||||
else
|
||||
myWarning->hide();
|
||||
}
|
||||
|
||||
bool SMESHGUI_CreateDualMeshDlg::isWarningShown()
|
||||
{
|
||||
return myWarning->isVisible();
|
||||
}
|
59
src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h
Normal file
59
src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright (C) 2007-2021 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, 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
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// SMESH SMESHGUI : GUI for SMESH component
|
||||
// File : SMESHGUI_CreateDualMeshDlg.h
|
||||
// Author : Yoann Audouin (EDF)
|
||||
//
|
||||
#ifndef SMESHGUI_CREATEDUALMESHDLG_H
|
||||
#define SMESHGUI_CREATEDUALMESHDLG_H
|
||||
|
||||
// SMESH includes
|
||||
#include "SMESH_SMESHGUI.hxx"
|
||||
|
||||
#include "SMESHGUI_Dialog.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class QButtonGroup;
|
||||
class QGroupBox;
|
||||
class QLabel;
|
||||
|
||||
class SMESHGUI_EXPORT SMESHGUI_CreateDualMeshDlg : public SMESHGUI_Dialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SMESHGUI_CreateDualMeshDlg();
|
||||
virtual ~SMESHGUI_CreateDualMeshDlg();
|
||||
|
||||
void ShowWarning(bool);
|
||||
bool isWarningShown();
|
||||
|
||||
signals:
|
||||
void onClicked( int );
|
||||
|
||||
private:
|
||||
QLabel* myWarning;
|
||||
};
|
||||
|
||||
#endif // SMESHGUI_CREATEDUALMESHDLG_H
|
284
src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx
Normal file
284
src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx
Normal file
@ -0,0 +1,284 @@
|
||||
// Copyright (C) 2007-2021 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, 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
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// SMESH SMESHGUI : GUI for SMESH component
|
||||
// File : SMESHGUI_CreateDualMeshOp.cxx
|
||||
// Author : Yoann AUDOUIN (EDF)
|
||||
// SMESH includes
|
||||
//
|
||||
#include "SMESHGUI_CreateDualMeshOp.h"
|
||||
|
||||
#include "SMESHGUI.h"
|
||||
#include "SMESHGUI_CreateDualMeshDlg.h"
|
||||
#include "SMESHGUI_MeshEditPreview.h"
|
||||
#include "SMESHGUI_Utils.h"
|
||||
#include "SMESH_ActorUtils.h"
|
||||
#include "SMESH_TypeFilter.hxx"
|
||||
#include "SMDSAbs_ElementType.hxx"
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <LightApp_UpdateFlags.h>
|
||||
#include <SUIT_MessageBox.h>
|
||||
#include <SUIT_OverrideCursor.h>
|
||||
#include <SalomeApp_Tools.h>
|
||||
#include <SALOME_Actor.h>
|
||||
|
||||
// IDL includes
|
||||
#include <SALOMEconfig.h>
|
||||
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
|
||||
|
||||
// VTK includes
|
||||
#include <vtkProperty.h>
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Constructor
|
||||
*
|
||||
* Initialize operation
|
||||
*/
|
||||
//================================================================================
|
||||
SMESHGUI_CreateDualMeshOp::SMESHGUI_CreateDualMeshOp()
|
||||
: SMESHGUI_SelectionOp(),
|
||||
myDlg( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
SMESHGUI_CreateDualMeshOp::~SMESHGUI_CreateDualMeshOp()
|
||||
{
|
||||
if ( myDlg ) delete myDlg;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Gets dialog of this operation
|
||||
* \retval LightApp_Dialog* - pointer to dialog of this operation
|
||||
*/
|
||||
//================================================================================
|
||||
LightApp_Dialog* SMESHGUI_CreateDualMeshOp::dlg() const
|
||||
{
|
||||
return myDlg;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Creates dialog if necessary and shows it
|
||||
*
|
||||
* Virtual method redefined from base class called when operation is started creates
|
||||
* dialog if necessary and shows it, activates selection
|
||||
*/
|
||||
//================================================================================
|
||||
void SMESHGUI_CreateDualMeshOp::startOperation()
|
||||
{
|
||||
if( !myDlg )
|
||||
{
|
||||
myDlg = new SMESHGUI_CreateDualMeshDlg( );
|
||||
}
|
||||
connect( myDlg, SIGNAL( onClicked( int ) ), SLOT( ConnectRadioButtons( int ) ) );
|
||||
|
||||
myHelpFileName = "create_dual_mesh.html";
|
||||
|
||||
SMESHGUI_SelectionOp::startOperation();
|
||||
|
||||
myDlg->activateObject( 0 );
|
||||
myDlg->ShowWarning( false );
|
||||
myDlg->show();
|
||||
|
||||
selectionDone();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Updates dialog's look and feel
|
||||
*
|
||||
* Virtual method redefined from the base class updates dialog's look and feel
|
||||
*/
|
||||
//================================================================================
|
||||
void SMESHGUI_CreateDualMeshOp::selectionDone()
|
||||
{
|
||||
if ( !dlg()->isVisible() )
|
||||
return;
|
||||
|
||||
SMESHGUI_SelectionOp::selectionDone();
|
||||
try
|
||||
{
|
||||
QString anObjEntry = myDlg->selectedObject( 0 );
|
||||
_PTR(SObject) pObj = SMESH::getStudy()->FindObjectID( anObjEntry.toUtf8().data() );
|
||||
if ( !pObj ) return;
|
||||
|
||||
SMESH::SMESH_IDSource_var idSource =
|
||||
SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
|
||||
|
||||
myDlg->setButtonEnabled( true, QtxDialog::OK | QtxDialog::Apply );
|
||||
if( idSource->_is_nil() )
|
||||
{
|
||||
myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply );
|
||||
return;
|
||||
}
|
||||
SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
|
||||
|
||||
// show warning on non-conformal result mesh
|
||||
if ( ! idSource->_is_nil() )
|
||||
{
|
||||
SMESH::SMESH_subMesh_var subMesh =
|
||||
SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pObj );
|
||||
// TODO: Check that mesh is only tetra
|
||||
if (!checkMesh(idSource)){
|
||||
myDlg->ShowWarning( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( const SALOME::SALOME_Exception& S_ex )
|
||||
{
|
||||
SalomeApp_Tools::QtCatchCorbaException( S_ex );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Creates selection filter
|
||||
* \param theId - identifier of current selection widget
|
||||
* \retval SUIT_SelectionFilter* - pointer to the created filter or null
|
||||
*
|
||||
* Creates selection filter in accordance with identifier of current selection widget
|
||||
*/
|
||||
//================================================================================
|
||||
SUIT_SelectionFilter* SMESHGUI_CreateDualMeshOp::createFilter( const int theId ) const
|
||||
{
|
||||
if ( theId == 0 )
|
||||
return new SMESH_TypeFilter( SMESH::MESHorSUBMESH );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Edits mesh
|
||||
*
|
||||
* Virtual slot redefined from the base class called when "Apply" button is clicked
|
||||
*/
|
||||
//================================================================================
|
||||
bool SMESHGUI_CreateDualMeshOp::onApply()
|
||||
{
|
||||
SUIT_OverrideCursor aWaitCursor;
|
||||
|
||||
QString aMess;
|
||||
QStringList anEntryList;
|
||||
|
||||
QString anObjEntry = myDlg->selectedObject( 0 );
|
||||
_PTR(SObject) pObj = SMESH::getStudy()->FindObjectID( anObjEntry.toUtf8().data() );
|
||||
if ( !pObj )
|
||||
{
|
||||
dlg()->show();
|
||||
SUIT_MessageBox::warning( myDlg,
|
||||
tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED") );
|
||||
return false;
|
||||
}
|
||||
|
||||
SMESH::SMESH_Mesh_var mesh;
|
||||
SMESH::SMESH_IDSource_var idSource =
|
||||
SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
|
||||
if( !CORBA::is_nil(idSource) )
|
||||
mesh = idSource->GetMesh();
|
||||
|
||||
if( CORBA::is_nil(mesh) )
|
||||
{
|
||||
SUIT_MessageBox::warning( myDlg,
|
||||
tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL") );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool aResult = false;
|
||||
SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
|
||||
SMESH::SMESH_Mesh_var newMesh;
|
||||
QByteArray newMeshName="MESH_DUAL";
|
||||
try
|
||||
{
|
||||
// TODO: Call the python script using medcoupling
|
||||
// String to run medcoupling dual
|
||||
// TODO: change name as previous name + "_dual"
|
||||
newMesh = gen->CreateDualMesh(mesh, newMeshName.constData());
|
||||
|
||||
if ( !newMesh->_is_nil() )
|
||||
if ( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
|
||||
{
|
||||
anEntryList.append( aSObject->GetID().c_str() );
|
||||
|
||||
SMESH::SetName( aSObject, newMeshName );
|
||||
}
|
||||
aResult = true;
|
||||
}
|
||||
catch ( const SALOME::SALOME_Exception& S_ex )
|
||||
{
|
||||
SalomeApp_Tools::QtCatchCorbaException( S_ex );
|
||||
aResult = false;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
aResult = false;
|
||||
}
|
||||
if( aResult )
|
||||
{
|
||||
SMESHGUI::Modified();
|
||||
update( UF_ObjBrowser | UF_Model | UF_Viewer );
|
||||
selectionDone();
|
||||
}
|
||||
|
||||
|
||||
// updateObjBrowser(true);
|
||||
// SMESHGUI::Modified();
|
||||
|
||||
// if( LightApp_Application* anApp =
|
||||
// dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
|
||||
// anApp->browseObjects( anEntryList, true );
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*! checkMesh
|
||||
* Verify that mesh as only tetraheadrons as 3D elements
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool
|
||||
SMESHGUI_CreateDualMeshOp::checkMesh( const SMESH::SMESH_IDSource_var& idSource)
|
||||
{
|
||||
SMESH::smIdType_array_var nbElemOfType = idSource->GetMeshInfo();
|
||||
// Checking that the mesh only has Tetrahedron
|
||||
bool hasOnlyTetra = (
|
||||
nbElemOfType[SMDSEntity_Tetra ] &&
|
||||
!nbElemOfType[SMDSEntity_Hexa ] &&
|
||||
!nbElemOfType[SMDSEntity_Pyramid ] &&
|
||||
!nbElemOfType[SMDSEntity_Polygon ] &&
|
||||
!nbElemOfType[SMDSEntity_Penta ] );
|
||||
|
||||
return hasOnlyTetra;
|
||||
}
|
64
src/SMESHGUI/SMESHGUI_CreateDualMeshOp.h
Normal file
64
src/SMESHGUI/SMESHGUI_CreateDualMeshOp.h
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2007-2021 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, 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
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// SMESH SMESHGUI : GUI for SMESH component
|
||||
// File : SMESHGUI_CreateDualMeshOp.h
|
||||
// Author : Yoann AUDOUIN (EDF)
|
||||
//
|
||||
#ifndef SMESHGUI_CREATEDUALMESHOP_H
|
||||
#define SMESHGUI_CREATEDUALMESHOP_H
|
||||
|
||||
// SMESH includes
|
||||
#include "SMESH_SMESHGUI.hxx"
|
||||
|
||||
#include "SMESHGUI_SelectionOp.h"
|
||||
|
||||
// IDL includes
|
||||
#include <SALOMEconfig.h>
|
||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
||||
|
||||
class SMESHGUI_CreateDualMeshDlg;
|
||||
|
||||
class SMESHGUI_EXPORT SMESHGUI_CreateDualMeshOp : public SMESHGUI_SelectionOp
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SMESHGUI_CreateDualMeshOp();
|
||||
virtual ~SMESHGUI_CreateDualMeshOp();
|
||||
|
||||
virtual LightApp_Dialog* dlg() const;
|
||||
|
||||
static bool checkMesh( const SMESH::SMESH_IDSource_var& );
|
||||
protected:
|
||||
virtual void startOperation();
|
||||
virtual void selectionDone();
|
||||
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
||||
|
||||
protected slots:
|
||||
virtual bool onApply();
|
||||
|
||||
private:
|
||||
SMESHGUI_CreateDualMeshDlg* myDlg;
|
||||
};
|
||||
|
||||
#endif // SMESHGUI_CREATEDUALMESHOP_H
|
@ -186,6 +186,7 @@ namespace SMESHOp {
|
||||
OpMoveNodeInteractive = 4516, // MENU MODIFICATION - MOVE NODE INTERACTIVE
|
||||
OpSplitEdgeInteract = 4517, // MENU MODIFICATION - INTERACTIVE ADD NODE ON EDGE
|
||||
OpSplitFaceInteract = 4518, // MENU MODIFICATION - INTERACTIVE ADD NODE ON FACE
|
||||
OpCreateDualMesh = 4519, // MENU MODIFICATION - CREATE DUAL MESH
|
||||
// Adaptation ---------------------//--------------------------------
|
||||
OpMGAdapt = 8020, // MENU ADAPTATION - MG-ADAPT
|
||||
OpHomardAdapt = 8021, // MENU ADAPTATION - HOMARD-ADAPT
|
||||
|
@ -1022,6 +1022,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
|
||||
}
|
||||
if ( method == "CreateMeshesFromUNV" ||
|
||||
method == "CreateMeshesFromSTL" ||
|
||||
method == "CreateDualMesh" ||
|
||||
method == "CopyMesh" ) // command result is a mesh
|
||||
{
|
||||
Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue() );
|
||||
|
@ -49,6 +49,10 @@
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
// Have to be included before std headers
|
||||
#include <Python.h>
|
||||
#include <structmember.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -2802,6 +2806,114 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
|
||||
return newMesh._retn();
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a mesh by copying a part of another mesh
|
||||
* \param mesh - TetraHedron mesh
|
||||
* \param meshName Name of the created mesh
|
||||
* \retval SMESH::SMESH_Mesh_ptr - the new mesh
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh,
|
||||
const char* meshName)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
|
||||
TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
|
||||
std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
|
||||
|
||||
// 1. Get source mesh
|
||||
|
||||
if ( CORBA::is_nil( mesh ))
|
||||
THROW_SALOME_CORBA_EXCEPTION( "bad IDSource", SALOME::BAD_PARAM );
|
||||
|
||||
std::cout << mesh << std::endl;
|
||||
SMESH::SMESH_Mesh_var srcMesh = mesh->GetMesh();
|
||||
SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( srcMesh );
|
||||
if ( !srcMesh_i )
|
||||
THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM );
|
||||
|
||||
SMESH_Mesh& srcMesh2 = srcMesh_i->GetImpl();
|
||||
|
||||
// TODO: Get it
|
||||
CORBA::String_var mesh_ior=GetORB()->object_to_string(mesh);
|
||||
std::string mesh_id = mesh_ior.in();
|
||||
std::string dual_mesh_file="/tmp/test_dual.med";
|
||||
std::string mesh_name = "MESH";
|
||||
|
||||
std::string python_code;
|
||||
python_code += "import sys\n";
|
||||
python_code += "import salome\n";
|
||||
python_code += "import medcoupling as mc\n";
|
||||
python_code += "from math import pi\n";
|
||||
python_code += "salome.salome_init()\n";
|
||||
python_code += "import GEOM\n";
|
||||
python_code += "from salome.geom import geomBuilder\n";
|
||||
python_code += "geompy = geomBuilder.New()\n";
|
||||
python_code += "import SMESH, SALOMEDS\n";
|
||||
python_code += "from salome.smesh import smeshBuilder\n";
|
||||
python_code += "smesh = smeshBuilder.New()\n";
|
||||
python_code += "def create_dual_mesh(mesh_ior, output_file):\n";
|
||||
python_code += " mesh = salome.orb.string_to_object(mesh_ior)\n";
|
||||
python_code += " shape = mesh.GetShapeToMesh()\n";
|
||||
python_code += " if not mesh:\n";
|
||||
python_code += " raise Exception(\"Could not find mesh using id: \", mesh_id)\n";
|
||||
python_code += " int_ptr = mesh.ExportMEDCoupling(True, True)\n";
|
||||
python_code += " dab = mc.FromPyIntPtrToDataArrayByte(int_ptr)\n";
|
||||
python_code += " tetras = mc.MEDFileMesh.New(dab)[0]\n";
|
||||
python_code += " tetras = mc.MEDCoupling1SGTUMesh(tetras)\n";
|
||||
python_code += " polyh = tetras.computeDualMesh()\n";
|
||||
python_code += " skin = tetras.buildUnstructured().computeSkin()\n";
|
||||
python_code += " skin_polyh = polyh.buildUnstructured().computeSkin()\n";
|
||||
python_code += " allNodesOnSkinPolyh = skin_polyh.computeFetchedNodeIds()\n";
|
||||
python_code += " allNodesOnSkin = skin.computeFetchedNodeIds()\n";
|
||||
python_code += " ptsAdded = allNodesOnSkinPolyh.buildSubstraction(allNodesOnSkin)\n";
|
||||
python_code += " ptsAddedMesh = mc.MEDCouplingUMesh.Build0DMeshFromCoords( skin_polyh.getCoords()[ptsAdded] )\n";
|
||||
python_code += " ptsAddedCoo = ptsAddedMesh.getCoords()\n";
|
||||
python_code += " ptsAddedCooModified = ptsAddedCoo[:]\n";
|
||||
python_code += " polyh.setName(\"MESH\")\n";
|
||||
python_code += " polyh.write(output_file)\n";
|
||||
|
||||
// Running Python script
|
||||
assert(Py_IsInitialized());
|
||||
PyGILState_STATE gstate;
|
||||
gstate = PyGILState_Ensure();
|
||||
PyRun_SimpleString(python_code.c_str());
|
||||
std::string cmd="";
|
||||
cmd += "create_dual_mesh(\"" + mesh_id + "\", \"" + dual_mesh_file + "\")";
|
||||
PyRun_SimpleString(cmd.c_str());
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
// Import created MED
|
||||
SMESH::SMESH_Mesh_var newMesh = CreateMesh(GEOM::GEOM_Object::_nil());
|
||||
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
|
||||
if ( !newMesh_i )
|
||||
THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
|
||||
SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
|
||||
if ( !meshSO->_is_nil() )
|
||||
{
|
||||
SetName( meshSO, meshName, "Mesh" );
|
||||
SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
|
||||
}
|
||||
|
||||
SMESH_Mesh& newMesh2 = newMesh_i->GetImpl();
|
||||
|
||||
newMesh2.MEDToMesh(dual_mesh_file.c_str(), "MESH");
|
||||
|
||||
SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
|
||||
|
||||
newMeshDS->Modified();
|
||||
|
||||
*pyDump << newMesh << " = " << this
|
||||
<< ".CreateDualMesh( " << mesh << ", "
|
||||
<< "'" << meshName << "') ";
|
||||
|
||||
return newMesh._retn();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a mesh by copying a part of another mesh
|
||||
|
@ -253,6 +253,10 @@ public:
|
||||
CORBA::Boolean theMakeRequiredGroups,
|
||||
SMESH::ComputeError_out theError);
|
||||
|
||||
// Create dual mesh of a tetrahedron mesh
|
||||
SMESH::SMESH_Mesh_ptr CreateDualMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
||||
const char* meshName);
|
||||
|
||||
// Copy a part of mesh
|
||||
SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
||||
const char* meshName,
|
||||
|
@ -773,6 +773,26 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
|
||||
aMesh = Mesh( self, self.geompyD, aSmeshMesh, name=name )
|
||||
return aMesh
|
||||
|
||||
def CreateDualMesh( self, mesh, meshName):
|
||||
"""
|
||||
Create a dual of a mesh.
|
||||
|
||||
Parameters:
|
||||
mesh: Tetrahedron mesh
|
||||
:class:`mesh, <SMESH.SMESH_IDSource>`.
|
||||
|
||||
meshName: a name of the new mesh
|
||||
|
||||
Returns:
|
||||
an instance of class :class:`Mesh`
|
||||
"""
|
||||
|
||||
if isinstance( mesh, Mesh ):
|
||||
meshPart = mesh.GetMesh()
|
||||
mesh = SMESH._objref_SMESH_Gen.CreateDualMesh(self, mesh, meshName)
|
||||
return Mesh(self, self.geompyD, mesh)
|
||||
|
||||
|
||||
def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
|
||||
"""
|
||||
Create a mesh by copying a part of another mesh.
|
||||
|
Loading…
Reference in New Issue
Block a user