in boolean byMesh)
raises ( SALOME::SALOME_Exception );
+ /*!
+ * Returns \c True if a hypothesis is assigned to a sole sub-mesh in a current Study
+ * \param [in] theHyp - the hypothesis of interest
+ * \param [out] theMesh - the sole mesh using \a theHyp
+ * \param [out] theShape - the sole geometry \a theHyp is assigned to
+ * \return boolean - \c True if \a theMesh and \a theShape are sole using \a theHyp
+ */
+ boolean GetSoleSubMeshUsingHyp( in SMESH_Hypothesis theHyp,
+ out SMESH_Mesh theMesh,
+ out GEOM::GEOM_Object theShape);
+
/*!
* Sets number of segments per diagonal of boundary box of geometry by which
* default segment length of appropriate 1D hypotheses is defined
/*!
* \brief Moves objects to the specified position
+ * \param what objects being moved
+ * \param where parent object where objects are moved to
+ * \param row position in the parent object's children list at which objects are moved
*
* This function is used in the drag-n-drop functionality.
- *
- * \param what objects being moved
- * \param where parent object where objects are moved to
- * \param row position in the parent object's children list at which objects are moved
*/
- void Move( in sobject_list what,
- in SALOMEDS::SObject where,
+ void Move( in sobject_list what,
+ in SALOMEDS::SObject where,
in long row );
/*!
- * Return true if algorithm can be applied
+ * Returns true if algorithm can be used to mesh a given geometry
+ * \param theAlgoType - the algorithm type
+ * \param theLibName - a name of the Plug-in library implementing the algorithm
+ * \param theShapeObject - the geometry to mesh
+ * \param toCheckAll - if \c True, returns \c True if all shapes are meshable,
+ * else, returns \c True if at least one shape is meshable
*/
boolean IsApplicable( in string theAlgoType,
in string theLibName,
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_FilterUtils.h"
+#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MeshUtils.h"
Handle(SALOME_InteractiveObject) anIObject = selected.First();
SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
- /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
- /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
- /* Warning : however by internal mechanism all subMeshes icons are changed ! */
if ( !aHypothesis->_is_nil() )
{
- // BUG 0020378
- //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
- SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
- if (aCreator) {
+ SMESHGUI_GenericHypothesisCreator* aCreator =
+ SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
+ if (aCreator)
+ {
+ // set geometry of mesh and sub-mesh to aCreator
+ aSel->selectedObjects( selected, "", /*convertReferences=*/false);
+ if ( selected.Extent() == 1 )
+ {
+ QString subGeomID, meshGeomID;
+ Handle(SALOME_InteractiveObject) hypIO = selected.First();
+ if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
+ {
+ if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
+ aCreator->setShapeEntry( subGeomID );
+ aCreator->setMainShapeEntry( meshGeomID );
+ }
+ }
+
aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
}
else
//
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_Utils.h"
+#include "SMESHGUI.h"
// SALOME GEOM includes
#include <GeometryGUI.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SMESH_Mesh)
+#include <QString>
+
namespace SMESH
{
GEOM::GEOM_Gen_var GetGEOMGen()
GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape (theMainShape,theID);
return subShape._retn();
}
+
+ //================================================================================
+ /*!
+ * \brief Return entries of sub-mesh geometry and mesh geometry by an IO of assigned
+ * hypothesis
+ * \param [in] hypIO - IO of hyp which is a reference SO to a hyp SO
+ * \param [out] subGeom - found entry of a sub-mesh if any
+ * \param [out] meshGeom - found entry of a mesh
+ * \return bool - \c true if any geometry has been found
+ */
+ //================================================================================
+
+ bool GetGeomEntries( Handle(SALOME_InteractiveObject)& hypIO,
+ QString& subGeom,
+ QString& meshGeom )
+ {
+ subGeom.clear();
+ meshGeom.clear();
+ if ( hypIO.IsNull() ) return false;
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if ( !aStudy ) return false;
+
+ _PTR(SObject) hypSO = aStudy->FindObjectID( hypIO->getEntry() );
+ if ( !hypSO ) return false;
+
+ // Depth() is a number of fathers
+ if ( hypSO->Depth() == 4 ) // hypSO is not a reference to a hyp but a hyp it-self
+ {
+ SMESH::SMESH_Hypothesis_var hyp =
+ SMESH::SObjectToInterface< SMESH::SMESH_Hypothesis >( hypSO );
+ SMESH::SMESH_Mesh_var mesh;
+ GEOM::GEOM_Object_var geom;
+ SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGUI()->GetSMESHGen();
+ if ( !gen || !gen->GetSoleSubMeshUsingHyp( hyp, mesh.out(), geom.out() ))
+ return false;
+
+ subGeom = toQStr( geom->GetStudyEntry() );
+
+ geom = mesh->GetShapeToMesh();
+ if ( geom->_is_nil() )
+ return false;
+ meshGeom = toQStr( geom->GetStudyEntry() );
+ }
+ else
+ {
+ _PTR(SObject) appliedSO = hypSO->GetFather(); // "Applied hypotheses" folder
+ if ( !appliedSO ) return false;
+
+ _PTR(SObject) subOrMeshSO = appliedSO->GetFather(); // mesh or sub-mesh SO
+ if ( !subOrMeshSO ) return false;
+
+ bool isMesh;
+ GEOM::GEOM_Object_var geom = GetShapeOnMeshOrSubMesh( subOrMeshSO, &isMesh );
+ if ( geom->_is_nil() )
+ return false;
+
+ if ( isMesh )
+ {
+ meshGeom = toQStr( geom->GetStudyEntry() );
+ return !meshGeom.isEmpty();
+ }
+
+ subGeom = toQStr( geom->GetStudyEntry() );
+
+ _PTR(SObject) subFolderSO = subOrMeshSO->GetFather(); // "SubMeshes on ..." folder
+ if ( !subFolderSO ) return false;
+
+ _PTR(SObject) meshSO = subFolderSO->GetFather(); // mesh SO
+ if ( !meshSO ) return false;
+
+ geom = GetShapeOnMeshOrSubMesh( meshSO );
+ if ( geom->_is_nil() )
+ return false;
+
+ meshGeom = toQStr( geom->GetStudyEntry() );
+ }
+
+ return !meshGeom.isEmpty() && !subGeom.isEmpty();
+ }
+
+
} // end of namespace SMESH
#include CORBA_SERVER_HEADER(GEOM_Gen)
class SALOMEDSClient_SObject;
+class Handle_SALOME_InteractiveObject;
+class QString;
namespace SMESH
{
SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
+
+ SMESHGUI_EXPORT bool GetGeomEntries( Handle_SALOME_InteractiveObject& hypIO,
+ QString& subGeom, QString& meshGeom);
}
#endif // SMESHGUI_GEOMGENUTILS_H
THypList algoList;
existingHyps(3, Algo, pMesh, algoNames, algoList);
if (!algoList.empty()) {
- HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() );
+ HypothesisData* algo =
+ SMESH::GetHypothesisData( SMESH::toQStr( algoList[0].first->GetName() ));
if ( algo &&
algo->InputTypes.empty() && // builds all dimensions it-self
!algo->IsSupportSubmeshes )
// if ( !geom->_is_nil() && geom->GetShapeType() >= GEOM::FACE ) { // WIRE, EDGE as well
existingHyps(2, Algo, pMesh, algoNames, algoList);
if (!algoList.empty()) {
- HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() );
+ HypothesisData* algo =
+ SMESH::GetHypothesisData( SMESH::toQStr( algoList[0].first->GetName() ));
if ( algo &&
algo->InputTypes.empty() && // builds all dimensions it-self
!algo->IsSupportSubmeshes )
return hyp;
}
+//================================================================================
+/*!
+ * \brief initialize a hypothesis creator
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::initHypCreator( SMESHGUI_GenericHypothesisCreator* theCreator )
+{
+ if ( !theCreator ) return;
+
+ // Set shapes, of mesh and sub-mesh if any
+
+ // get Entry of the Geom object
+ QString aGeomEntry = "";
+ QString aMeshEntry = "";
+ QString anObjEntry = "";
+ aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+
+ if ( myToCreate && myIsMesh )
+ aMeshEntry = aGeomEntry;
+
+ if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
+ _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ aMeshEntry = ( aGeomVar->_is_nil() ) ? QString() : SMESH::toQStr( aGeomVar->GetStudyEntry() );
+ }
+
+ if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ bool isMesh;
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
+ if ( !aGeomVar->_is_nil() )
+ {
+ aGeomEntry = SMESH::toQStr( aGeomVar->GetStudyEntry() );
+ if ( isMesh )
+ aMeshEntry = aGeomEntry;
+ }
+ }
+
+ if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
+ // take geometry from submesh being created
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( pObj ) {
+ // if current object is sub-mesh
+ SMESH::SMESH_subMesh_var aSubMeshVar =
+ SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+ if ( !aSubMeshVar->_is_nil() ) {
+ SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
+ if ( !aMeshVar->_is_nil() ) {
+ _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
+ if ( !aGeomVar->_is_nil() )
+ aMeshEntry = SMESH::toQStr( aGeomVar->GetStudyEntry() );
+ }
+ }
+ }
+ }
+
+ theCreator->setShapeEntry( aGeomEntry );
+ if ( aMeshEntry != "" )
+ theCreator->setMainShapeEntry( aMeshEntry );
+}
+
//================================================================================
/*!
* \Brief Returns tab dimention
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
// Create hypothesis
- if (aCreator) {
+ if (aCreator)
+ {
// Get parameters appropriate to initialize a new hypothesis
SMESH::SMESH_Hypothesis_var initParamHyp =
getInitParamsHypothesis(theTypeName, aData->ServerLibName);
removeCustomFilters(); // Issue 0020170
- // Get Entry of the Geom object
- QString aGeomEntry = "";
- QString aMeshEntry = "";
- QString anObjEntry = "";
- aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ // set shapes, of mesh and sub-mesh if any
+ initHypCreator( aCreator );
- if ( myToCreate && myIsMesh )
- aMeshEntry = aGeomEntry;
-
- if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
- _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
- aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
- }
-
- if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- bool isMesh;
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
- if ( !aGeomVar->_is_nil() )
- {
- aGeomEntry = aGeomVar->GetStudyEntry();
- if ( isMesh )
- aMeshEntry = aGeomEntry;
- }
- }
-
- if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
- // take geometry from submesh being created
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- if ( pObj ) {
- // if current object is sub-mesh
- SMESH::SMESH_subMesh_var aSubMeshVar =
- SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
- if ( !aSubMeshVar->_is_nil() ) {
- SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
- if ( !aMeshVar->_is_nil() ) {
- _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
- if ( !aGeomVar->_is_nil() )
- aMeshEntry = aGeomVar->GetStudyEntry();
- }
- }
- }
- }
-
- aCreator->setShapeEntry( aGeomEntry );
- if ( aMeshEntry != "" )
- aCreator->setMainShapeEntry( aMeshEntry );
myDlg->setEnabled( false );
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true;
if ( aHyp->_is_nil() )
return;
- SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
+ SMESHGUI_GenericHypothesisCreator* aCreator =
+ SMESH::GetHypothesisCreator( SMESH::toQStr( aHyp->GetName() ));
if ( aCreator )
{
- // Get initial parameters
+ // set initial parameters
SMESH::SMESH_Hypothesis_var initParamHyp =
- getInitParamsHypothesis( aHyp->GetName(), aHyp->GetLibName());
+ getInitParamsHypothesis( SMESH::toQStr( aHyp->GetName() ),
+ SMESH::toQStr( aHyp->GetLibName() ));
aCreator->setInitParamsHypothesis( initParamHyp );
- // Get Entry of the Geom object
- QString aGeomEntry = "";
- QString aMeshEntry = "";
- QString anObjEntry = "";
- aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ // set shapes, of mesh and sub-mesh if any
+ initHypCreator( aCreator );
- if ( myToCreate && myIsMesh )
- aMeshEntry = aGeomEntry;
-
- if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
- _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
- aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
- }
-
- if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- bool isMesh;
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
- if ( !aGeomVar->_is_nil() )
- {
- aGeomEntry = aGeomVar->GetStudyEntry();
- if ( isMesh )
- aMeshEntry = aGeomEntry;
- }
- }
-
- if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
- // take geometry from submesh being created
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- if ( pObj ) {
- // if current object is sub-mesh
- SMESH::SMESH_subMesh_var aSubMeshVar =
- SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
- if ( !aSubMeshVar->_is_nil() ) {
- SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
- if ( !aMeshVar->_is_nil() ) {
- _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
- if ( !aGeomVar->_is_nil() )
- aMeshEntry = aGeomVar->GetStudyEntry();
- }
- }
- }
- }
-
- aCreator->setShapeEntry( aGeomEntry );
- if ( aMeshEntry != "" )
- aCreator->setMainShapeEntry( aMeshEntry );
removeCustomFilters(); // Issue 0020170
myDlg->setEnabled( false );
+
aCreator->edit( aHyp.in(), aHypItem.second, dlg(), this, SLOT( onHypoEdited( int ) ) );
}
}
if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
// try to find algo by selected hypothesis in order to keep it selected
bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
- CORBA::String_var curHypType = curHyp->GetName();
+ QString curHypType = SMESH::toQStr( curHyp->GetName() );
if ( !algoDeselectedByUser &&
- myObjHyps[ dim ][ type ].count() > 0 &&
- !strcmp( curHypType, myObjHyps[ dim ][ type ].first().first->GetName()) )
+ myObjHyps[ dim ][ type ].count() > 0 &&
+ curHypType == SMESH::toQStr( myObjHyps[ dim ][ type ].first().first->GetName()) )
{
HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
for (int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i) {
for ( ; anIter != aHypVarList.end(); anIter++)
{
SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
- CORBA::String_var aName = aHypVar->GetName();
- if ( !aHypVar->_is_nil() && !strcmp(aHypName.toLatin1().data(), aName) )
+ if ( !aHypVar->_is_nil() && aHypName == SMESH::toQStr( aHypVar->GetName() ))
{
anAlgoVar = aHypVar;
break;
for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
{
SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
- CORBA::String_var aName = aHypVar->GetName();
- if ( !aHypVar->_is_nil() && !strcmp(aHypName.toLatin1().data(), aName) )
+ if ( !aHypVar->_is_nil() && aHypName == SMESH::toQStr( aHypVar->GetName() ))
{
anAlgoVar = aHypVar;
break;
GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
if ( !aGeomVar->_is_nil() )
{
- QString ID = aGeomVar->GetStudyEntry();
+ QString ID = SMESH::toQStr( aGeomVar->GetStudyEntry() );
if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.toLatin1().data() )) {
selectObject( aGeomSO );
selectionDone();
class SMESHGUI_MeshDlg;
class SMESHGUI_ShapeByMeshOp;
class HypothesisData;
+class SMESHGUI_GenericHypothesisCreator;
/*!
* \brief Operation for mech creation or editing
const THypList& ) const;
SMESH::SMESH_Hypothesis_var getInitParamsHypothesis( const QString&,
const QString& ) const;
+ void initHypCreator( SMESHGUI_GenericHypothesisCreator* aCreator );
bool isSubshapeOk() const;
char* isSubmeshIgnored() const;
_PTR(SObject) getSubmeshByGeom() const;
// type to use instead of SMESH_IDSource_var for automatic UnRegister()
typedef SALOME::GenericObj_wrap<SMESH_IDSource> SMESH_IDSource_wrap;
+ /*!
+ * \brief Class usefull to convert a string returned from a CORBA call
+ * to other string types w/o memory leak.
+ *
+ * Usage (of instantiations): QString s = toQStr( objVar->GetName() );
+ * std::string ss = toStdStr( objVar->GetName() );
+ */
+ template < class _STRING >
+ class toStrT : public _STRING {
+ CORBA::String_var myStr;
+ public:
+ toStrT( char* s ): myStr(s), _STRING( s )
+ {}
+ operator const char*() const
+ { return myStr.in(); }
+ };
+ // Instantiations:
+ struct toQStr : public toStrT< QString > {
+ toQStr( char* s ): toStrT< QString >(s) {}
+ };
+ class toStdStr : public toStrT< std::string > {
+ toStdStr( char* s ): toStrT< std::string >(s) {}
+ };
+
}
#endif // SMESHGUI_UTILS_H
PortableServer::ObjectId* contId,
const char* instanceName,
const char* interfaceName )
- : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
+ : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
{
MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" );
// create a new hypothesis object, store its ref. in studyContext
if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName);
myHypothesis_i =
- myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
+ myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
myHypothesis_i->SetLibName(aPlatformLibName.c_str()); // for persistency assurance
if (!myHypothesis_i)
*/
//=============================================================================
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
- throw ( SALOME::SALOME_Exception )
+ throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::createMesh" );
StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
{
if ( !CORBA::is_nil( myCurrentStudy ) &&
- myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
+ myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
return myStudyContextMap[ myCurrentStudy->StudyId() ];
else
return 0;
SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypName,
const char* theLibName )
- throw ( SALOME::SALOME_Exception )
+ throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
// Create hypothesis/algorithm
return SMESH::SMESH_Hypothesis::_nil();
}
+//=============================================================================
+/*!
+ * Returns \c True if a hypothesis is assigned to a sole sub-mesh in a current Study
+ * \param [in] theHyp - the hypothesis of interest
+ * \param [out] theMesh - the sole mesh using \a theHyp
+ * \param [out] theShape - the sole geometry \a theHyp is assigned to
+ * \return boolean - \c True if \a theMesh and \a theShape are sole using \a theHyp
+ *
+ * If two meshes on same shape have theHyp assigned to the same sub-shape, they are
+ * considered as SAME sub-mesh => result is \c true.
+ * This method ids used to initialize SMESHGUI_GenericHypothesisCreator with
+ * a shape to which an hyp being edited is assigned.
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr theHyp,
+ SMESH::SMESH_Mesh_out theMesh,
+ GEOM::GEOM_Object_out theShape)
+{
+ if ( GetCurrentStudyID() < 0 || CORBA::is_nil( theHyp ))
+ return false;
+
+ // get Mesh component SO
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SComponent_wrap comp = myCurrentStudy->FindComponent( compDataType.in() );
+ if ( CORBA::is_nil( comp ))
+ return false;
+
+ // look for child SO of meshes
+ SMESH::SMESH_Mesh_var foundMesh;
+ TopoDS_Shape foundShape;
+ bool isSole = true;
+ SALOMEDS::ChildIterator_wrap meshIter = myCurrentStudy->NewChildIterator( comp );
+ for ( ; meshIter->More() && isSole; meshIter->Next() )
+ {
+ SALOMEDS::SObject_wrap curSO = meshIter->Value();
+ CORBA::Object_var obj = SObjectToObject( curSO );
+ SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( obj );
+ if ( ! mesh_i )
+ continue;
+
+ // look for a sole shape where theHyp is assigned
+ bool isHypFound = false;
+ const ShapeToHypothesis & s2hyps = mesh_i->GetImpl().GetMeshDS()->GetHypotheses();
+ ShapeToHypothesis::Iterator s2hypsIt( s2hyps );
+ for ( ; s2hypsIt.More() && isSole; s2hypsIt.Next() )
+ {
+ const THypList& hyps = s2hypsIt.Value();
+ THypList::const_iterator h = hyps.begin();
+ for ( ; h != hyps.end(); ++h )
+ if ( (*h)->GetID() == theHyp->GetId() )
+ break;
+ if ( h != hyps.end()) // theHyp found
+ {
+ isHypFound = true;
+ if ( ! foundShape.IsNull() &&
+ ! foundShape.IsSame( s2hypsIt.Key() )) // not a sole sub-shape
+ {
+ foundShape.Nullify();
+ isSole = false;
+ break;
+ }
+ foundShape = s2hypsIt.Key();
+ }
+ } // loop on assigned hyps
+
+ if ( isHypFound && !foundShape.IsNull() ) // a mesh using theHyp is found
+ {
+ if ( !foundMesh->_is_nil() ) // not a sole mesh
+ {
+ GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh();
+ GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
+ if ( ! ( isSole = s1->IsSame( s2 )))
+ break;
+ }
+ foundMesh = SMESH::SMESH_Mesh::_narrow( obj );
+ }
+
+ } // loop on meshes
+
+ if ( isSole &&
+ ! foundMesh->_is_nil() &&
+ ! foundShape.IsNull() )
+ {
+ theMesh = foundMesh._retn();
+ theShape = ShapeToGeomObject( foundShape );
+ return ( !theMesh->_is_nil() && !theShape->_is_nil() );
+ }
+ return false;
+}
+
//=============================================================================
/*!
* Sets number of segments per diagonal of boundary box of geometry by which
useCaseBuilder->AppendTo( where, sobj ); // append to the end of list
}
}
-//=================================================================================
-// function : IsApplicable
-// purpose : Return true if algorithm can be applied
-//=================================================================================
+//================================================================================
+/*!
+ * \brief Returns true if algorithm can be used to mesh a given geometry
+ * \param [in] theAlgoType - the algorithm type
+ * \param [in] theLibName - a name of the Plug-in library implementing the algorithm
+ * \param [in] theGeomObject - the geometry to mesh
+ * \param [in] toCheckAll - if \c True, returns \c True if all shapes are meshable,
+ * else, returns \c True if at least one shape is meshable
+ * \return CORBA::Boolean - can or can't
+ */
+//================================================================================
+
CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char* theAlgoType,
const char* theLibName,
GEOM::GEOM_Object_ptr theGeomObject,
std::string aPlatformLibName;
typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char*);
- GenericHypothesisCreator_i* aCreator = getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
+ GenericHypothesisCreator_i* aCreator =
+ getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
if (aCreator)
{
TopoDS_Shape shape = GeomObjectToShape( theGeomObject );
CORBA::Boolean byMesh)
throw ( SALOME::SALOME_Exception );
+ /*
+ * Returns True if a hypothesis is assigned to a sole sub-mesh in a current Study
+ */
+ CORBA::Boolean GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr theHyp,
+ SMESH::SMESH_Mesh_out theMesh,
+ GEOM::GEOM_Object_out theShape);
+
// Preferences
// ------------
/*!
// SALOME GUI includes
#include <SUIT_ResourceMgr.h>
+#include <SUIT_MessageBox.h>
// IDL includes
#include <SALOMEconfig.h>
idsWg->SetMainShapeEntry( aMainEntry );
idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
- idsWg->SetListOfIDs( h->GetFaces() );
- idsWg->showPreview( true );
+ if ( idsWg->SetListOfIDs( h->GetFaces() ))
+ {
+ idsWg->showPreview( true );
+ }
+ else
+ {
+ SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
+ idsWg->setEnabled( false );
+ }
customWidgets()->append ( idsWg );
}
}
idsWg->SetMainShapeEntry( aMainEntry );
idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
- idsWg->SetListOfIDs( h->GetEdges() );
- idsWg->showPreview( true );
+ if ( idsWg->SetListOfIDs( h->GetEdges() ))
+ {
+ idsWg->showPreview( true );
+ }
+ else
+ {
+ SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
+ idsWg->setEnabled( false );
+ }
customWidgets()->append ( idsWg );
}
}
//=================================================================================
// function : SetListOfIds
-// purpose : Called to set the list of SubShapes IDs
+// purpose : Called to set the list of SubShapes IDs. Returns false if any ID is invalid
//=================================================================================
-void StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theIds)
+bool StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theIds)
{
mySelectedIDs.clear();
myListOfIDs.clear();
for ( int i = 0; i < size; i++ )
mySelectedIDs.append( theIds[ i ] );
- mySelectedIDs = GetCorrectedListOfIDs( false );
+ bool isOk;
+ mySelectedIDs = GetCorrectedListOfIDs( false, &isOk );
onAdd();
+ return isOk;
}
//=================================================================================
// function : GetCorrectedListOfIds
// purpose : Called to convert the list of IDs from sub-shape IDs to main shape IDs
//=================================================================================
-QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape )
+QList<int>
+StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape,
+ bool* isOK )
{
- if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) && fromSubshapeToMainshape )
+ if (( myMainShape.IsNull() || myGeomShape.IsNull() ) && fromSubshapeToMainshape )
return myListOfIDs;
- else if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) && !fromSubshapeToMainshape )
+ else if (( myMainShape.IsNull() /*||*/&& myGeomShape.IsNull() ) && !fromSubshapeToMainshape )
return mySelectedIDs;
+ if ( !fromSubshapeToMainshape ) // called from SetListOfIDs
+ {
+ if ( myMainShape.IsNull() )
+ std::swap( myMainShape, myGeomShape );
+ }
+
QList<int> aList;
- TopTools_IndexedMapOfShape aGeomMap;
- TopTools_IndexedMapOfShape aMainMap;
- TopExp::MapShapes(myGeomShape, aGeomMap);
+ TopTools_IndexedMapOfShape aGeomMap, aMainMap;
TopExp::MapShapes(myMainShape, aMainMap);
+ if ( !myGeomShape.IsNull() )
+ TopExp::MapShapes(myGeomShape, aGeomMap);
- if ( fromSubshapeToMainshape ) { // convert indexes from sub-shape to mainshape
+ bool ok = true;
+ if ( fromSubshapeToMainshape ) // convert indexes from sub-shape to mainshape
+ {
int size = myListOfIDs.size();
for (int i = 0; i < size; i++) {
- TopoDS_Shape aSubShape = aGeomMap.FindKey( myListOfIDs.at(i) );
- int index = aMainMap.FindIndex( aSubShape );
+ int index = myListOfIDs.at(i);
+ if ( aGeomMap.Extent() < index )
+ {
+ ok = false;
+ }
+ else
+ {
+ TopoDS_Shape aSubShape = aGeomMap.FindKey( index );
+ if ( mySubShType != aSubShape.ShapeType() )
+ ok = false;
+ if ( !aMainMap.Contains( aSubShape ))
+ ok = false;
+ else
+ index = aMainMap.FindIndex( aSubShape );
+ }
aList.append( index );
}
myIsNotCorrected = false;
- } else { // convert indexes from main shape to sub-shape
+ }
+ else // convert indexes from main shape to sub-shape, or just check indices
+ {
int size = mySelectedIDs.size();
for (int i = 0; i < size; i++) {
- TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
- int index = aGeomMap.FindIndex( aSubShape );
+ int index = mySelectedIDs.at(i);
+ if ( aMainMap.Extent() < index )
+ {
+ ok = false;
+ }
+ else
+ {
+ TopoDS_Shape aSubShape = aMainMap.FindKey( index );
+ if ( mySubShType != aSubShape.ShapeType() )
+ ok = false;
+ if ( !aGeomMap.Contains( aSubShape ) && !aGeomMap.IsEmpty() )
+ ok = false;
+ else
+ index = aGeomMap.FindIndex( aSubShape );
+ }
aList.append( index );
}
}
+ if ( isOK ) *isOK = ok;
return aList;
}
~StdMeshersGUI_SubShapeSelectorWdg();
SMESH::long_array_var GetListOfIDs();
- void SetListOfIDs( SMESH::long_array_var );
+ bool SetListOfIDs( SMESH::long_array_var );
void SetGeomShapeEntry( const QString& theEntry );
const char* GetGeomShapeEntry() { return myEntry.toLatin1().data();}
TopoDS_Shape GetGeomShape() { return myGeomShape; }
TopoDS_Shape GetMainShape() { return myMainShape; }
- QList<int> GetCorrectedListOfIDs( bool fromSubshapeToMainshape = true );
+ QList<int> GetCorrectedListOfIDs( bool fromSubshapeToMainshape,
+ bool* isOK=0);
static GEOM::GEOM_Object_var GetGeomObjectByEntry( const QString& );
static TopoDS_Shape GetTopoDSByEntry( const QString& );
<source>TO_IGNORE_FACES</source>
<translation>Faces without layers (inlets and oulets)</translation>
</message>
+ <message>
+ <source>BAD_FACES_WARNING</source>
+ <translation>
+Specified faces are not sub-shapes of the shape of
+mesh/sub-mesh.
+Consider creating another hypothesis instead of using
+this one for this mesh/sub-mesh.</translation>
+ </message>
+ <message>
+ <source>BAD_EDGES_WARNING</source>
+ <translation>
+Specified edges are not sub-shapes of the shape of
+mesh/sub-mesh.
+Consider creating another hypothesis instead of using
+this one for this mesh/sub-mesh.</translation>
+ </message>
</context>
<context>
<name>@default</name>