]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implementation of NPAL13504 improvement.
authorrnv <rnv@opencascade.com>
Wed, 24 Oct 2007 07:05:58 +0000 (07:05 +0000)
committerrnv <rnv@opencascade.com>
Wed, 24 Oct 2007 07:05:58 +0000 (07:05 +0000)
21 files changed:
resources/StdMeshers.xml
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_MesherHelper.cxx
src/SMESH/SMESH_MesherHelper.hxx
src/SMESH/SMESH_subMesh.cxx
src/SMESHGUI/SMESHGUI_ComputeDlg.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.h
src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx
src/SMESHGUI/SMESHGUI_HypothesesUtils.h
src/SMESHGUI/SMESHGUI_MeshDlg.cxx
src/SMESHGUI/SMESHGUI_MeshDlg.h
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_XmlHandler.cxx
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_2smeshpy.hxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_Mesh_i.cxx

index 70530de017ca2665b9b6cd83bb8bec3a48034ffc..821cd587bbc2978696e40bab51f9f2e65b2c644b 100644 (file)
@@ -83,6 +83,7 @@
     <hypothesis type="MaxElementVolume"
                 label-id="Max. Element Volume"
                 icon-id="mesh_hypo_volume.png"
+               need-geom = "false"
                 dim="3"/>
 
     <hypothesis type="ProjectionSource3D"
index f3f25d9e254209160f6c6bcdabcd190f69c59485..57b7d3ecf595d5b90020866d0172236e5a5a8b6e 100644 (file)
@@ -162,6 +162,14 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
         ret = false;;
     }
+    if ((algo && !aMesh.HasShapeToMesh()))
+    {
+      if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
+        smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+      
+      if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
+        ret = false;;
+    }
   }
 
   // -----------------------------------------------
index bbc40cd6d062ade870b47b6d9820288c9c8613e5..236d400feab6dc94d2c636d2eb45a8c4a083ee37 100644 (file)
@@ -214,7 +214,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName)
   if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
   if(_isShapeToMesh)
     throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
-  _isShapeToMesh = true;
+  _isShapeToMesh = false;
   DriverUNV_R_SMDS_Mesh myReader;
   myReader.SetMesh(_myMeshDS);
   myReader.SetFile(theFileName);
@@ -269,7 +269,7 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
   if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
   if(_isShapeToMesh)
     throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
-  _isShapeToMesh = true;
+  _isShapeToMesh = false;
   DriverMED_R_SMESHDS_Mesh myReader;
   myReader.SetMesh(_myMeshDS);
   myReader.SetMeshId(-1);
@@ -312,7 +312,7 @@ int SMESH_Mesh::STLToMesh(const char* theFileName)
   if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
   if(_isShapeToMesh)
     throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
-  _isShapeToMesh = true;
+  _isShapeToMesh = false;
   DriverSTL_R_SMDS_Mesh myReader;
   myReader.SetMesh(_myMeshDS);
   myReader.SetFile(theFileName);
index 024a93e5d6de6aea4636dc0c3f9b538baaa34a7c..dcb255db22ab991e78e5792925aa32c463b25c60 100644 (file)
@@ -1138,3 +1138,36 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
 
   return true;
 }
+
+/**
+ * Check mesh without geometry for: if all elements on this shape are quadratic,
+ * quadratic elements will be created.
+ * Used then generated 3D mesh without geometry.
+   */
+SMESH_MesherHelper:: MType SMESH_MesherHelper::IsQuadraticMesh()
+{
+  int NbAllEdgsAndFaces=0;
+  int NbQuadFacesAndEdgs=0;
+  int NbFacesAndEdges=0;
+  //All faces and edges
+  NbAllEdgsAndFaces = myMesh->NbEdges() + myMesh->NbFaces();
+  
+  //Quadratic faces and edges
+  NbQuadFacesAndEdgs = myMesh->NbEdges(ORDER_QUADRATIC) + myMesh->NbFaces(ORDER_QUADRATIC);
+
+  //Linear faces and edges
+  NbFacesAndEdges = myMesh->NbEdges(ORDER_LINEAR) + myMesh->NbFaces(ORDER_LINEAR);
+  
+  if (NbAllEdgsAndFaces == NbQuadFacesAndEdgs) {
+    //Quadratic mesh
+    return SMESH_MesherHelper::QUADRATIC;
+  }
+  else if (NbAllEdgsAndFaces == NbFacesAndEdges) {
+    //Linear mesh
+    return SMESH_MesherHelper::LINEAR;
+  }
+  else
+    //Mesh with both type of elements
+    return SMESH_MesherHelper::COMP;
+}
+
index ad3a1e8f82fc7685b54f4dbd21d347b61b227107..41544a3f48304abe137fba028bdcb420a3cd7abd 100644 (file)
@@ -306,6 +306,14 @@ public:
    */
   const NLinkNodeMap& GetNLinkNodeMap() const { return myNLinkNodeMap; }
 
+  /**
+   * Check mesh without geometry for: if all elements on this shape are quadratic,
+   * quadratic elements will be created.
+   * Used then generated 3D mesh without geometry.
+   */
+  enum MType{ LINEAR, QUADRATIC, COMP };
+  MType IsQuadraticMesh();
+  
 protected:
 
   /*!
index ebb96e21d01f3749dd2bc32d45938a52ec6f865a..e47c030bfd31287b557bccd422ccab2580b256dd 100644 (file)
@@ -412,10 +412,12 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn()
   case TopAbs_SOLID:
     {
       //MESSAGE("solid");
-      for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
-           exp.Next())
-      {
-        InsertDependence(exp.Current());
+      if(_father->HasShapeToMesh()) {
+        for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
+             exp.Next())
+        {
+          InsertDependence(exp.Current());
+        }
       }
       break;
     }
@@ -496,9 +498,14 @@ const TopoDS_Shape & SMESH_subMesh::GetSubShape() const
 bool SMESH_subMesh::CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const
 {
   int aHypDim   = theHypothesis->GetDim();
-  int aShapeDim = SMESH_Gen::GetShapeDim(_subShape);
-  if ( aHypDim <= aShapeDim )
-    return true;
+  if(_father->HasShapeToMesh()) {
+    int aShapeDim = SMESH_Gen::GetShapeDim(_subShape);
+    if ( aHypDim <= aShapeDim )
+      return true;
+  }
+  else
+    //Only 3D hypothesis may be assigned to the mesh w/o geometry
+    return aHypDim == 3;
 //   if ( aHypDim < aShapeDim )
 //     return ( _father->IsMainShape( _subShape ));
 
@@ -601,8 +608,9 @@ SMESH_Hypothesis::Hypothesis_Status
     // check if a shape needed by algo is present
     // -------------------------------------------
     algo = static_cast< SMESH_Algo* >( anHyp );
-    if ( !_father->HasShapeToMesh() && algo->NeedShape() )
-      return SMESH_Hypothesis::HYP_BAD_GEOMETRY;
+    if(_father->GetShapeToMesh() != SMESH_Mesh::PseudoShape())
+      if ( !_father->HasShapeToMesh() && algo->NeedShape() )
+        return SMESH_Hypothesis::HYP_BAD_GEOMETRY;
     // ----------------------
     // check mesh conformity
     // ----------------------
@@ -618,6 +626,17 @@ SMESH_Hypothesis::Hypothesis_Status
     if ( ! CanAddHypothesis( anHyp )) // check dimension
       return SMESH_Hypothesis::HYP_BAD_DIM;
 
+    if(anHyp->GetDim() == 3 && !_father->HasShapeToMesh()
+       && event == ADD_ALGO) {
+      //Only NETGEN_3D and GHS3D_3D can be assigned to the Mesh w/o geometryy
+      bool isNetgen3D = (strcmp( "NETGEN_3D", anHyp->GetName()) == 0);
+      bool  isGhs3d = (strcmp( "GHS3D_3D", anHyp->GetName()) == 0);
+      if( !isNetgen3D && !isGhs3d)
+        return SMESH_Hypothesis::HYP_BAD_DIM;
+    }
+      
+
+    
     if ( /*!anHyp->IsAuxiliary() &&*/ GetSimilarAttached( _subShape, anHyp ) )
       return SMESH_Hypothesis::HYP_ALREADY_EXIST;
 
index 1da473118b8aac2c69646271da5131bc5e6064f6..a4d8fca519b790d538c1eab6616191291a02f6bf 100644 (file)
@@ -806,7 +806,9 @@ void SMESHGUI_ComputeOp::startOperation()
     MemoryReserve aMemoryReserve;
     _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
     myMainShape = aMesh->GetShapeToMesh();
-    if ( !myMainShape->_is_nil() && aMeshSObj )
+    if ( ((!myMainShape->_is_nil() && aMesh->HasShapeToMesh()) ||
+          (myMainShape->_is_nil() && !aMesh->HasShapeToMesh()))
+         && aMeshSObj )
     {
       myDlg->myMeshName->setText( aMeshSObj->GetName() );
       SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
@@ -919,10 +921,20 @@ void SMESHGUI_ComputeOp::startOperation()
     myDlg->myBriefInfo->show();
     myDlg->myFullInfo->hide();
     myDlg->myErrorGroup->show();
-
+    
+    bool hasShape = aMesh->HasShapeToMesh();
+    if ( !hasShape )
+    {
+      myDlg->myPublishBtn->hide();
+      myDlg->myShowBtn->hide();
+    }
+    else
+    {
+      myDlg->myPublishBtn->show();
+      myDlg->myShowBtn->show();
+    }
     // fill table of errors
     tbl->setNumRows( anErrors->length() );
-    bool hasShape = aMesh->HasShapeToMesh();
     if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
     else             tbl->showColumn( COL_SHAPE );
     tbl->setColumnWidth( COL_ERROR, 200 );
index b411cf7b893f2ce613914fbd4cf86ea2b149a683..fba15ebd198e33e7ce5b91ac66bae03bb8e6a244 100644 (file)
@@ -149,7 +149,8 @@ class HypothesisData
                   const QStringList& theNeededHypos,
                   const QStringList& theOptionalHypos,
                   const QStringList& theInputTypes,
-                  const QStringList& theOutputTypes)
+                  const QStringList& theOutputTypes,
+                 const bool theIsNeedGeometry = true)
     : TypeName( theTypeName ),
     PluginName( thePluginName ),
     ServerLibName( theServerLibName ),
@@ -159,7 +160,8 @@ class HypothesisData
     Dim( theDim ),
     IsAux( theIsAux ),
     NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ),
-    InputTypes( theInputTypes ), OutputTypes( theOutputTypes )
+    InputTypes( theInputTypes ), OutputTypes( theOutputTypes ),
+    IsNeedGeometry( theIsNeedGeometry )
     {};
 
  QString TypeName;        //!< hypothesis type name
@@ -170,6 +172,7 @@ class HypothesisData
  QString IconId;          //!< icon identifier
  QValueList<int> Dim;     //!< list of supported dimensions (see SMESH::Dimension enumeration)
  bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
+ bool IsNeedGeometry;     //!< TRUE if for given hypothesis need shape, FALSE otherwise
 
  // for algorithm only: dependencies algo <-> algo and algo -> hypos
  QStringList NeededHypos;  //!< list of obligatory hypotheses
index 4be1a4cbb6fd374904bd5956231b97c3d492414f..119406be5c283b59ed859f7cbe69bc475c7fde5a 100644 (file)
@@ -208,21 +208,27 @@ namespace SMESH{
 
   QStringList GetAvailableHypotheses( const bool isAlgo, 
                                       const int theDim,                          
-                                      const bool isAux )
+                                      const bool isAux,
+                                      const bool isNeedGeometry)
   {
     QStringList aHypList;
 
     // Init list of available hypotheses, if needed
     InitAvailableHypotheses();
-
+    bool checkGeometry = !isNeedGeometry;
     // fill list of hypotheses/algorithms
     THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap;
     THypothesisDataMap::iterator anIter;
     for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ )
     {
       HypothesisData* aData = (*anIter).second;
-      if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux )
-        aHypList.append(((*anIter).first).c_str());
+      if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux)
+        if (checkGeometry){
+          if (aData->IsNeedGeometry == isNeedGeometry)
+            aHypList.append(((*anIter).first).c_str());
+        }
+        else
+          aHypList.append(((*anIter).first).c_str());
     }
     return aHypList;
   }
@@ -533,27 +539,36 @@ namespace SMESH{
     if (MorSM) {
       try {
         GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
-        if (!aShapeObject->_is_nil()) {
-          SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
-         SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
-
-         if (!aSubMesh->_is_nil())
-           aMesh = aSubMesh->GetFather();
-
-         if (!aMesh->_is_nil()) {
-           res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
-           if (res < SMESH::HYP_UNKNOWN_FATAL) {
+        SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
+        SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
+        
+        if (!aSubMesh->_is_nil())
+          aMesh = aSubMesh->GetFather();
+        
+        if (!aMesh->_is_nil()) {    
+          if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) {
+            res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
+            if (res < SMESH::HYP_UNKNOWN_FATAL) {
               _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
               if (meshSO)
                 SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
             }
-           if (res > SMESH::HYP_OK) {
-             wc.suspend();
-             processHypothesisStatus(res, anHyp, false);
-             wc.resume();
-           }
-         }
-       }
+            
+          }
+          else if(!aMesh->HasShapeToMesh()){
+            res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
+           if (res < SMESH::HYP_UNKNOWN_FATAL) {
+              _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
+              if (meshSO)
+                SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);              
+            }
+          }
+          if (res > SMESH::HYP_OK) {
+            wc.suspend();
+            processHypothesisStatus(res, anHyp, false);
+            wc.resume();
+          }
+        }
       } catch(const SALOME::SALOME_Exception& S_ex) {
        wc.suspend();
        SalomeApp_Tools::QtCatchCorbaException(S_ex);
index f62b14da2d666bb533d81df9e1e33d2c18b82152..42172d76b64ce64f3394b971a236e3c110981be5 100644 (file)
@@ -57,7 +57,8 @@ namespace SMESH{
   SMESHGUI_EXPORT
   QStringList GetAvailableHypotheses( const bool isAlgo, 
                                       const int theDim = -1, 
-                                      const bool isAux = false);
+                                      const bool isAux = false,
+                                     const bool isNeedGeometry = true);
   SMESHGUI_EXPORT
   QStringList GetHypothesesSets();
 
index 33d2e6485f6eaf4c13943600fc337944b0c99615..b9b4f079d7babbaa98b6b5a057bb9717fff4e57f 100644 (file)
@@ -569,6 +569,27 @@ void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
   }
 }
 
+
+//================================================================================
+/*!
+ * \brief Disable tab
+ * \param int - tab ID
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
+  myTabWg->setTabEnabled( myTabs[ theTabId ], false );
+}
+
+//================================================================================
+/*!
+ * \brief Enable tabs
+ * \param int - tab ID
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
+  myTabWg->setTabEnabled( myTabs[ theTabId ], true );
+}
+
 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
 {
   if ( myGeomPopup && isBtnOn )
index 33f1b2d573dd05abcd22f9771f4d6e162fb5b1ae..4b909b3c8ea3819d5fcfdb1bc95ca2ab1a9f7e0d 100644 (file)
@@ -74,6 +74,9 @@ public:
   void                         setMaxHypoDim( const int );
   void                         setHypoSets( const QStringList& );
   void                         setGeomPopupEnabled( const bool );
+  void                         disableTab(const int);
+  void                         enableTab(const int);
+
 
 signals:
 
index ca82f9dd3207a601558ebc0d1c24e0857233098a..c8d85ecb012040b32703ab0401269be93ac88e26 100644 (file)
@@ -102,6 +102,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
 {
   if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
     GeometryGUI::InitGeomGen();
+  myIsOnGeometry = true;
 }
 
 //================================================================================
@@ -412,125 +413,165 @@ void SMESHGUI_MeshOp::selectionDone()
 {
   if ( !dlg()->isShown() || !myDlg->isEnabled() )
     return;
-
+  
   SMESHGUI_SelectionOp::selectionDone();
-
+  
   try
   {
-    // Enable tabs according to shape dimension
-
-    int shapeDim = 3;
-
-    QStringList aGEOMs;
-    myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
-    GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
-
-    if (aGEOMs.count() > 0) {
-      // one or more GEOM shape selected
-      aSeq->length(aGEOMs.count());
-      QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
-      int iSubSh = 0;
-      for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
-        QString aSubGeomEntry = (*aSubShapesIter);
-        _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
-        GEOM::GEOM_Object_var aSubGeomVar =
-          GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
-        aSeq[iSubSh] = aSubGeomVar;
-      }
-    } else {
-      // get geometry by selected sub-mesh
-      QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
-      _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
-      GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
-      if (!aGeomVar->_is_nil()) {
-        aSeq->length(1);
-        aSeq[0] = aGeomVar;
-      }
+    //Check geometry for mesh
+    QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+    _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
+    if ( !pObj )
+      return;
+    
+    SMESH::SMESH_subMesh_var aSubMeshVar =
+      SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+    if ( !aSubMeshVar->_is_nil() ) 
+      myIsOnGeometry = true;
+    else {
+      SMESH::SMESH_Mesh_var aMeshVar =
+        SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+      if ( !myToCreate && !aMeshVar->HasShapeToMesh() )
+        myIsOnGeometry = false;
+      else
+        myIsOnGeometry = true;
     }
+    
+    if ( myIsOnGeometry ) {
+      // Enable tabs according to shape dimension
+    
+      int shapeDim = 3;
+      QStringList aGEOMs;
+      myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
+      GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+      if (aGEOMs.count() > 0) {
+        // one or more GEOM shape selected
+        aSeq->length(aGEOMs.count());
+        QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
+        int iSubSh = 0;
+        for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
+          QString aSubGeomEntry = (*aSubShapesIter);
+          _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
+          GEOM::GEOM_Object_var aSubGeomVar =
+            GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
+          aSeq[iSubSh] = aSubGeomVar;
+        }
+      } else {
+        // get geometry by selected sub-mesh
+        QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+        _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
+        GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+        if (!aGeomVar->_is_nil()) {
+          aSeq->length(1);
+          aSeq[0] = aGeomVar;
+        }
+      }
 
-    if (aSeq->length() > 0) {
-      shapeDim = 0;
-      for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
-        GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
-        switch ( aGeomVar->GetShapeType() ) {
-        case GEOM::SOLID:
-        case GEOM::SHELL:  shapeDim = 3; break;
-        case GEOM::FACE:   shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
-        case GEOM::WIRE:
-        case GEOM::EDGE:   shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
-        case GEOM::VERTEX: break;
-        default:
-          TopoDS_Shape aShape;
-          if ( GEOMBase::GetShape(aGeomVar, aShape)) {
-            TopExp_Explorer exp( aShape, TopAbs_SHELL );
-            if ( exp.More() )
-              shapeDim = 3;
-            else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
-              shapeDim = (shapeDim < 2) ? 2 : shapeDim;
-            else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
-              shapeDim = (shapeDim < 1) ? 1 : shapeDim;
-            else
-              ;//shapeDim = 0;
+      if (aSeq->length() > 0) {
+        shapeDim = 0;
+        for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
+          GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
+          switch ( aGeomVar->GetShapeType() ) {
+          case GEOM::SOLID:
+          case GEOM::SHELL:  shapeDim = 3; break;
+          case GEOM::FACE:   shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
+          case GEOM::WIRE:
+          case GEOM::EDGE:   shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
+          case GEOM::VERTEX: break;
+          default:
+            TopoDS_Shape aShape;
+            if ( GEOMBase::GetShape(aGeomVar, aShape)) {
+              TopExp_Explorer exp( aShape, TopAbs_SHELL );
+              if ( exp.More() )
+                shapeDim = 3;
+              else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
+                shapeDim = (shapeDim < 2) ? 2 : shapeDim;
+              else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
+                shapeDim = (shapeDim < 1) ? 1 : shapeDim;
+              else
+                ;//shapeDim = 0;
+            }
           }
         }
       }
-    }
-    myDlg->setMaxHypoDim( shapeDim );
+      myDlg->setMaxHypoDim( shapeDim );
 
-
-    if ( !myToCreate ) // edition: read hypotheses
-    {
-      QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
-      _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
-      if ( pObj != 0 )
+      
+      if ( !myToCreate ) // edition: read hypotheses
       {
-        SMESH::SMESH_subMesh_var aVar =
-          SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
-        myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
-        myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
-        myDlg->updateGeometry();
-        myDlg->adjustSize();
-        readMesh();
-      }
-      else
-        myDlg->reset();
-
-    }
-    else if ( !myIsMesh ) // submesh creation
-    {
-      // if a submesh on the selected shape already exist, pass to submesh edition mode
-      if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
-        SMESH::SMESH_subMesh_var sm =
-          SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
-        bool editSubmesh = ( !sm->_is_nil() &&
-                             SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
-                                                         tr( "EDIT_SUBMESH_QUESTION"),
-                                                         tr( "SMESH_BUT_YES" ),
-                                                         tr( "SMESH_BUT_NO" ), 1, 0, 0 ));
-        if ( editSubmesh )
+        QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+        _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
+        if ( pObj != 0 )
         {
-          selectionMgr()->clearFilters();
-          selectObject( pSubmesh );
-          SMESHGUI::GetSMESHGUI()->switchToOperation(704);
-          return;
+          
+          SMESH::SMESH_subMesh_var aVar =
+            SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+          myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
+          myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
+          myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
+          myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
+          myDlg->updateGeometry();
+          myDlg->adjustSize();
+          readMesh();
         }
         else
-        {
-          myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
-          selectObject( _PTR(SObject)() );
-          selectionDone();
+          myDlg->reset();
+        
+      }
+      else if ( !myIsMesh ) // submesh creation
+      {
+        // if a submesh on the selected shape already exist, pass to submesh edition mode
+        if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
+          SMESH::SMESH_subMesh_var sm =
+            SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
+          bool editSubmesh = ( !sm->_is_nil() &&
+                               SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
+                                                           tr( "EDIT_SUBMESH_QUESTION"),
+                                                           tr( "SMESH_BUT_YES" ),
+                                                           tr( "SMESH_BUT_NO" ), 1, 0, 0 ));
+          if ( editSubmesh )
+          {
+            selectionMgr()->clearFilters();
+            selectObject( pSubmesh );
+            SMESHGUI::GetSMESHGUI()->switchToOperation(704);
+            return;
+          }
+          else
+          {
+            myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
+            selectObject( _PTR(SObject)() );
+            selectionDone();
+          }
+        }
+        
+        // enable/disable popup for choice of geom selection way
+        bool enable = false;
+        QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+        if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+          SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+          if ( !mesh->_is_nil() )
+            enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
         }
+        myDlg->setGeomPopupEnabled( enable );
       }
-
-      // enable/disable popup for choice of geom selection way
-      bool enable = false;
-      QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
-      if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
-        SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
-        if ( !mesh->_is_nil() )
-          enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
+    }
+    else {
+      myDlg->enableTab( SMESH::DIM_3D );
+      QStringList hypList;
+      availableHyps( SMESH::DIM_3D, Algo, hypList,
+                     myAvailableHypData[SMESH::DIM_3D][Algo]);
+      
+      SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
+      aTab->setAvailableHyps( Algo, hypList );
+      for( int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i ) {
+        myDlg->disableTab(i);
       }
-      myDlg->setGeomPopupEnabled( enable );
+      //Hide labels and fields (Mesh ang Geometry)
+      myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
+      myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
+      myDlg->adjustSize();
+      readMesh();
     }
   }
   catch ( const SALOME::SALOME_Exception& S_ex )
@@ -570,7 +611,7 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
     return false;
   }
 
-  // Imported mesh, if create sub-mesh or edit mesh
+/*  // Imported mesh, if create sub-mesh or edit mesh
   if ( !myToCreate || ( myToCreate && !myIsMesh ))
   {
     QString aMeshEntry = myDlg->selectedObject
@@ -582,7 +623,7 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
         return false;
       }
     }
-  }
+  }*/
 
   // Geom
   if ( myToCreate )
@@ -673,7 +714,7 @@ void SMESHGUI_MeshOp::availableHyps( const int       theDim,
   theHyps.clear();
   bool isAlgo = ( theHypType == Algo );
   bool isAux  = ( theHypType == AddHyp );
-  QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux );
+  QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );
 
   QStringList::const_iterator anIter;
   for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
@@ -1224,6 +1265,9 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
       }
       else {
         bool mainHyp = true;
+        QStringList anAvailable;
+        availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
+        myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
         int index = myAvailableHypData[aDim][MainHyp].findIndex( aHypData );
         if ( index < 0 ) {
           mainHyp = false;
@@ -1591,32 +1635,35 @@ void SMESHGUI_MeshOp::readMesh()
   if ( !pObj )
     return;
 
-  // Get name of mesh if current object is sub-mesh
-  SMESH::SMESH_subMesh_var aSubMeshVar =
+  if( myIsOnGeometry ) {  
+    // Get name of mesh 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() )
+    if ( !aSubMeshVar->_is_nil() ) 
     {
-      _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
-      QString aMeshName = name( aMeshSO );
-      myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
+      SMESH::SMESH_Mesh_var aMeshVar =  aSubMeshVar->GetFather();
+      if ( !aMeshVar->_is_nil() )
+      {
+        _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
+        QString aMeshName = name( aMeshSO );
+        myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
+      }
+    }
+    
+    // Get name of geometry object
+    GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+    if ( !aGeomVar->_is_nil() )
+    {
+      _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
+      QString aShapeName = name( aGeomSO );
+      myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
     }
-  }
-
-  // Get name of geometry object
-  GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
-  if ( !aGeomVar->_is_nil() )
-  {
-    _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
-    QString aShapeName = name( aGeomSO );
-    myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
   }
 
   // Get hypotheses and algorithms assigned to the mesh/sub-mesh
   QStringList anExisting;
-  for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
+  const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
+  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
   {
     // get algorithm
     existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
@@ -1641,7 +1688,7 @@ void SMESHGUI_MeshOp::readMesh()
 
   // get hypotheses
   bool hypWithoutAlgo = false;
-  for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
+  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
   {
     for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
     {
@@ -1754,18 +1801,19 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
   // Set new name
   QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
   SMESH::SetName( pObj, aName.latin1() );
+  int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
 
   // First, remove old algos in order to avoid messages on algorithm hiding
-  for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
+  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
   {
     if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
     {
       SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
       CORBA::String_var anOldName = anOldAlgo->GetName();
       SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
-      CORBA::String_var anAlgoName = anAlgoVar->GetName();
+      //      CORBA::String_var anAlgoName = anAlgoVar->GetName();
       if ( anAlgoVar->_is_nil() || // no new algo selected or
-           strcmp(anOldName.in(), anAlgoName.in()) ) // algo change
+           strcmp(anOldName.in(), anAlgoVar->GetName()) ) // algo change
       {
         // remove old algorithm
         SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
@@ -1775,7 +1823,7 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
   }
 
   // Assign new algorithms and hypotheses
-  for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
+  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
   {
     if ( !isAccessibleDim( dim )) continue;
 
index 23365fd1a0c7033fff884284a20a415f40de3ed0..c8b2ed7c0f2d3132653b173cb9d6c86489f60a77 100644 (file)
@@ -137,6 +137,7 @@ private:
   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
   bool                           myToCreate;
   bool                           myIsMesh;
+  bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
 
   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
index 7602c410b31212349110866af3ac1cc3aeb32641..36fdceb67e4210ad3b880c566114e4b88d0db017 100644 (file)
@@ -296,8 +296,25 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const
         _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).latin1() );
        //FindSObject( mesh );
         if ( so ) {
-          GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
-          return QVariant( !shape->_is_nil(), 0 );
+          CORBA::Object_var obj = SMESH::SObjectToObject(so, SMESH::GetActiveStudyDocument());
+          if(!CORBA::is_nil(obj)){
+            SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
+            if (!mesh->_is_nil()){
+              if(mesh->HasShapeToMesh()) {
+                GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
+                return QVariant( !shape->_is_nil(), 0 );
+              }
+              else
+              {
+                return QVariant(!mesh->NbFaces()==0, 0);
+              }
+            }
+            else
+            {
+              GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
+              return QVariant( !shape->_is_nil(), 0 );
+            }
+          }
         }
 //      }
 //    }
index e1ade098004bfed4432e9938997cbf2dd44c2cb1..2fa20059d26c859fecce1bb08d953b199e3a5f65 100644 (file)
@@ -130,6 +130,10 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
       QString aLabel = atts.value("label-id");
       QString anIcon = atts.value("icon-id");
       bool isAux = atts.value("auxiliary") == "true";
+      bool isNeedGeom = true;
+      QString aNeedGeom = atts.value("need-geom");
+      if ( !aNeedGeom.isEmpty() )
+        isNeedGeom = (aNeedGeom == "true");
       
       QString aDimStr = atts.value("dim");
       aDimStr = aDimStr.remove( ' ' );
@@ -159,7 +163,7 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
       HypothesisData* aHypData =
         new HypothesisData (aHypAlType, myPluginName, myServerLib, myClientLib,
                             aLabel, anIcon, aDim, isAux,
-                            attr[ HYPOS ], attr[ OPT_HYPOS ], attr[ INPUT ], attr[ OUTPUT ]);
+                            attr[ HYPOS ], attr[ OPT_HYPOS ], attr[ INPUT ], attr[ OUTPUT ], isNeedGeom );
 
       if (qName == "algorithm")
       {
index 998266806c6a5fb5cbf932c74eafd54a1259bb70..4d362f69c81147c255b5bf7ed03f8bca1311a40b 100644 (file)
@@ -81,6 +81,7 @@ static TCollection_AsciiString theEmptyString;
 #undef DUMP_CONVERSION
 #endif
 
+
 namespace {
 
   //================================================================================
@@ -250,7 +251,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
   AddMeshAccessorMethod( aCommand );
 
   // Add access to a wrapped algorithm
-  AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ???
+  //  AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ???
 
   // PAL12227. PythonDump was not updated at proper time; result is
   //     aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1))
@@ -287,16 +288,26 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
   // Concatenate( [mesh1, ...], ... )
   // CreateHypothesis( theHypType, theLibName )
   // Compute( mesh, geom )
-
   // mesh creation
   if ( theCommand->GetMethod() == "CreateMesh" ||
-       theCommand->GetMethod() == "CreateEmptyMesh" )
+       theCommand->GetMethod() == "CreateEmptyMesh" ||
+       theCommand->GetMethod() == "CreateMeshesFromUNV" ||
+       theCommand->GetMethod() == "CreateMeshesFromSTL")
   {
     Handle(_pyMesh) mesh = new _pyMesh( theCommand );
     myMeshes.insert( make_pair( mesh->GetID(), mesh ));
     return;
   }
 
+  if(theCommand->GetMethod() == "CreateMeshesFromMED")
+  {
+    for(int ind = 0;ind<theCommand->GetNbResultValues();ind++)
+    {
+      Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind));
+      myMeshes.insert( make_pair( theCommand->GetResultValue(ind), mesh ));     
+    }
+  }
+
   // CreateHypothesis()
   if ( theCommand->GetMethod() == "CreateHypothesis" )
   {
@@ -589,12 +600,32 @@ _pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd):
 {
   // convert my creation command
   Handle(_pyCommand) creationCmd = GetCreationCmd();
-  creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() );
-  creationCmd->SetMethod( "Mesh" );
+  TCollection_AsciiString str = creationCmd->GetMethod();
+  
+  creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); 
+  if(str != "CreateMeshesFromUNV" &&
+     str != "CreateMeshesFromMED" &&
+     str != "CreateMeshesFromSTL")
+    creationCmd->SetMethod( "Mesh" );
 
   theGen->SetAccessorMethod( GetID(), "GetMesh()" );
 }
 
+//================================================================================
+/*!
+ * \brief 
+  * \param theCreationCmd - 
+ */
+//================================================================================
+_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString& id):
+  _pyObject(theCreationCmd), myHasEditor(false)
+{
+  // convert my creation command
+  Handle(_pyCommand) creationCmd = GetCreationCmd();
+  creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); 
+  theGen->SetAccessorMethod( id, "GetMesh()" );
+}
+
 //================================================================================
 /*!
  * \brief Convert a IDL API command of SMESH::Mesh to a method call of python Mesh
@@ -676,7 +707,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
       }
     }
     Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
-    if ( ! hasAddCmd ) { // hypo addition already wrapped
+    if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped
       // RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 )
       _pyID geom = theCommand->GetArg( 1 );
       theCommand->RemoveArgs();
@@ -1562,6 +1593,54 @@ const TCollection_AsciiString & _pyCommand::GetResultValue()
   return myRes;
 }
 
+//================================================================================
+/*!
+ * \brief Return number of python command result value ResultValue = Obj.Meth()
+  * \retval const int
+ */
+//================================================================================
+
+const int _pyCommand::GetNbResultValues()
+{
+  int begPos = 1;
+  int Nb=0;
+  int endPos = myString.Location( "=", 1, Length() );
+  TCollection_AsciiString str = "";
+  while ( begPos < endPos) {
+    str = GetWord( myString, begPos, true );
+    begPos = begPos+ str.Length();
+    Nb++;
+  }
+  return (Nb-1);
+}
+
+
+//================================================================================
+/*!
+ * \brief Return substring of python command looking like
+ *  ResultValue1 , ResultValue1,... = Obj.Meth() with res index
+ * \retval const TCollection_AsciiString & - ResultValue with res index substring
+ */
+//================================================================================
+const TCollection_AsciiString & _pyCommand::GetResultValue(int res)
+{
+  int begPos = 1;
+  int Nb=0;
+  int endPos = myString.Location( "=", 1, Length() );
+  while ( begPos < endPos) {
+    myRes = GetWord( myString, begPos, true );
+    begPos = begPos + myRes.Length();
+    Nb++;
+    if(res == Nb){
+      myRes.RemoveAll('[');myRes.RemoveAll(']');
+      return myRes;
+    }
+    if(Nb>res)
+      break;
+  }
+  return theEmptyString;
+}
+
 //================================================================================
 /*!
  * \brief Return substring of python command looking like ResVal = Object.Meth()
index a09a84cd645a8be5e595505bbc49e5dc1d45a542..a5fd824139cf591063e00b02de5bd4f8355c90d7 100644 (file)
@@ -111,6 +111,8 @@ public:
   bool IsEmpty() const { return myString.IsEmpty(); }
   TCollection_AsciiString GetIndentation();
   const TCollection_AsciiString & GetResultValue();
+  const int GetNbResultValues();
+  const TCollection_AsciiString & GetResultValue(int res);
   const TCollection_AsciiString & GetObject();
   const TCollection_AsciiString & GetMethod();
   const TCollection_AsciiString & GetArg( int index );
@@ -210,6 +212,7 @@ class _pyMesh: public _pyObject
   bool                            myHasEditor;
 public:
   _pyMesh(const Handle(_pyCommand) theCreationCmd);
+  _pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString &);
   const _pyID& GetGeom() { return GetCreationCmd()->GetArg(1); }
   void Process( const Handle(_pyCommand)& theCommand);
   void Flush();
index cf94c0ec7530b86d02e5d21ad0d4a9aa5620cf4a..d79dfa565e4ac4c8a9f312f4f07a9ecaf509e230 100644 (file)
@@ -1030,7 +1030,7 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr
   Unexpect aCatch(SALOME_SalomeException);
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetComputeErrors()" );
 
-  if ( CORBA::is_nil( theSubObject ) )
+  if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh())
     THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
 
   if ( CORBA::is_nil( theMesh ) )
@@ -1040,7 +1040,12 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr
   try {
     if ( SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ))
     {
-      TopoDS_Shape shape = GeomObjectToShape( theSubObject );
+      TopoDS_Shape shape;
+      if(theMesh->HasShapeToMesh())
+        shape = GeomObjectToShape( theSubObject );
+      else
+        shape = SMESH_Mesh::PseudoShape();
+      
       ::SMESH_Mesh& mesh = meshServant->GetImpl();
 
       error_array->length( mesh.GetMeshDS()->MaxShapeIndex() );
@@ -1095,7 +1100,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes
   Unexpect aCatch(SALOME_SalomeException);
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetAlgoState()" );
 
-  if ( CORBA::is_nil( theSubObject ) )
+  if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh())
     THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
 
   if ( CORBA::is_nil( theMesh ) )
@@ -1106,7 +1111,12 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes
     SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
     ASSERT( meshServant );
     if ( meshServant ) {
-      TopoDS_Shape myLocShape = GeomObjectToShape( theSubObject );
+      TopoDS_Shape myLocShape;
+      if(theMesh->HasShapeToMesh())
+        myLocShape = GeomObjectToShape( theSubObject );
+      else
+        myLocShape = SMESH_Mesh::PseudoShape();
+      
       ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
       list< ::SMESH_Gen::TAlgoStateError > error_list;
       list< ::SMESH_Gen::TAlgoStateError >::iterator error;
@@ -1224,7 +1234,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
   Unexpect aCatch(SALOME_SalomeException);
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" );
 
-  if ( CORBA::is_nil( theShapeObject ) )
+  if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh())
     THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", 
                                   SALOME::BAD_PARAM );
 
@@ -1244,7 +1254,11 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
       // NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
       meshServant->CheckGeomGroupModif();
       // get local TopoDS_Shape
-      TopoDS_Shape myLocShape = GeomObjectToShape( theShapeObject );
+      TopoDS_Shape myLocShape;
+      if(theMesh->HasShapeToMesh())
+        myLocShape = GeomObjectToShape( theShapeObject );
+      else
+        myLocShape = SMESH_Mesh::PseudoShape();
       // call implementation compute
       ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
       return myGen.Compute( myLocMesh, myLocShape);
@@ -1785,6 +1799,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
             int id = myStudyContext->findId( string( objStr.in() ) );
             ::SMESH_Mesh& myLocMesh = myImpl->GetImpl();
             SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
+            bool hasShape = myLocMesh.HasShapeToMesh();
 
             // for each mesh open the HDF group basing on its id
             char meshGrpName[ 30 ];
@@ -1830,10 +1845,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
             // write applied hypotheses if exist
             SALOMEDS::SObject_var myHypBranch;
             found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch );
-            if ( found && !shapeRefFound ) { // remove applied hyps
+            if ( found && !shapeRefFound && hasShape) { // remove applied hyps
               myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
             }
-            if ( found && shapeRefFound ) {
+            if ( found && (shapeRefFound || !hasShape) ) {
               aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
               aGroup->CreateOnDisk();
 
@@ -1873,10 +1888,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
             // write applied algorithms if exist
             SALOMEDS::SObject_var myAlgoBranch;
             found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch );
-            if ( found && !shapeRefFound ) { // remove applied algos
+            if ( found && !shapeRefFound && hasShape) { // remove applied algos
               myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
             }
-            if ( found && shapeRefFound ) {
+            if ( found && (shapeRefFound || !hasShape)) {
               aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
               aGroup->CreateOnDisk();
 
@@ -2185,7 +2200,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
              myWriter.Perform();
              
              // maybe a shape was deleted in the study
-             if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) {
+             if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() && hasShape) {
                TopoDS_Shape nullShape;
                myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data
              }
@@ -2911,7 +2926,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
               if ( !CORBA::is_nil( hypObject ) ) {
                 SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
-                if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() )
+                if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil()
+                                           || !myNewMeshImpl->HasShapeToMesh()) )
                   myNewMeshImpl->addHypothesis( aShapeObject, anHyp );
               }
             }
@@ -2948,7 +2964,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
               if ( !CORBA::is_nil( hypObject ) ) {
                 SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
-                if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() )
+                if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil()
+                                           || !myNewMeshImpl->HasShapeToMesh()) )
                   myNewMeshImpl->addHypothesis( aShapeObject, anHyp );
               }
             }
@@ -3314,9 +3331,14 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
       } // if ( hasData )
 
       // Recompute State (as computed sub-meshes are restored from MED)
-      if ( !aShapeObject->_is_nil() ) {
+      if ( !aShapeObject->_is_nil() || !myNewMeshImpl->HasShapeToMesh()) {
         MESSAGE("Compute State Engine ...");
-        TopoDS_Shape myLocShape = GeomObjectToShape( aShapeObject );
+        TopoDS_Shape myLocShape;
+        if(myNewMeshImpl->HasShapeToMesh())
+          myLocShape = GeomObjectToShape( aShapeObject );
+        else
+          myLocShape = SMESH_Mesh::PseudoShape();
+        
         myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine
           (SMESH_subMesh::SUBMESH_RESTORED);
         MESSAGE("Compute State Engine finished");
index d179f62d1ded9d7011f3e51f55d767f3bd7acd98..2460bcc1cb82e1ca9891ffd18d3cad1e6eda8a5f 100644 (file)
@@ -740,10 +740,15 @@ SALOMEDS::SObject_ptr
 {
   if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape")
   SALOMEDS::SObject_var aMeshOrSubMesh;
-  if ( theShape->_is_nil() || theMesh->_is_nil() )
+  if (theMesh->_is_nil() || ( theShape->_is_nil() && theMesh->HasShapeToMesh()))
     return aMeshOrSubMesh._retn();
+  
+  TopoDS_Shape aShape;
+  if(theMesh->HasShapeToMesh())
+    aShape = GeomObjectToShape( theShape );
+  else
+    aShape = SMESH_Mesh::PseudoShape();
 
-  TopoDS_Shape aShape = GeomObjectToShape( theShape );
   SMESH_Mesh_i* mesh_i = objectToServant<SMESH_Mesh_i>( theMesh );
 
   if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) {
@@ -773,7 +778,8 @@ bool SMESH_Gen_i::AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
 {
   if(MYDEBUG) MESSAGE("AddHypothesisToShape")
   if (theStudy->_is_nil() || theMesh->_is_nil() ||
-      theHyp->_is_nil() || theShape->_is_nil() )
+      theHyp->_is_nil() || (theShape->_is_nil()
+                            && theMesh->HasShapeToMesh()) )
     return false;
 
   SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh );
@@ -827,7 +833,8 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy
                                             SMESH::SMESH_Hypothesis_ptr theHyp)
 {
   if (theStudy->_is_nil() || theMesh->_is_nil() ||
-      theHyp->_is_nil() || theShape->_is_nil() )
+      theHyp->_is_nil() || (theShape->_is_nil()
+                            && theMesh->HasShapeToMesh()))
     return false;
 
   SALOMEDS::SObject_var aHypSO = ObjectToSObject( theStudy, theHyp );
index 647439380f256b68c2e7b1eae1c71c664daa7697..274e05f3997c5f3b8e31d448bb5f8cca4ffeabd7 100644 (file)
@@ -364,9 +364,14 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS
   if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
 
   // Update Python script
-  TPythonDump() << "status = " << _this() << ".AddHypothesis( "
-                << aSubShapeObject << ", " << anHyp << " )";
-
+  if(_impl->HasShapeToMesh()) {
+    TPythonDump() << "status = " << _this() << ".AddHypothesis( "
+                  << aSubShapeObject << ", " << anHyp << " )";
+  }
+  else {
+    TPythonDump() << "status = " << _this() << ".AddHypothesis( "<< anHyp << " )";
+  }
+  
   return ConvertHypothesisStatus(status);
 }
 
@@ -382,7 +387,7 @@ SMESH_Hypothesis::Hypothesis_Status
 {
   if(MYDEBUG) MESSAGE("addHypothesis");
 
-  if (CORBA::is_nil(aSubShapeObject))
+  if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh())
     THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
                                  SALOME::BAD_PARAM);
 
@@ -394,7 +399,13 @@ SMESH_Hypothesis::Hypothesis_Status
   SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
   try
   {
-    TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
+    TopoDS_Shape myLocSubShape;
+    //use PseudoShape in case if mesh has no shape
+    if(HasShapeToMesh())
+      myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
+    else              
+      myLocSubShape = _impl->GetShapeToMesh();
+    
     int hypId = myHyp->GetId();
     status = _impl->AddHypothesis(myLocSubShape, hypId);
     if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
@@ -432,8 +443,15 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS
                                       aSubShapeObject, anHyp );
 
   // Update Python script
+    // Update Python script
+  if(_impl->HasShapeToMesh()) {
   TPythonDump() << "status = " << _this() << ".RemoveHypothesis( "
                 << aSubShapeObject << ", " << anHyp << " )";
+  }
+  else {
+    TPythonDump() << "status = " << _this() << ".RemoveHypothesis( "
+                  << anHyp << " )";
+  }
 
   return ConvertHypothesisStatus(status);
 }
@@ -450,7 +468,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Ob
        if(MYDEBUG) MESSAGE("removeHypothesis()");
        // **** proposer liste de subShape (selection multiple)
 
-       if (CORBA::is_nil(aSubShapeObject))
+       if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh())
                THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
                        SALOME::BAD_PARAM);
 
@@ -462,8 +480,14 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Ob
        SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
        try
        {
-               TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
-               int hypId = myHyp->GetId();
+                TopoDS_Shape myLocSubShape;
+                //use PseudoShape in case if mesh has no shape
+                if(HasShapeToMesh())
+                  myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
+                else
+                  myLocSubShape = _impl->GetShapeToMesh();
+                
+                int hypId = myHyp->GetId();
                status = _impl->RemoveHypothesis(myLocSubShape, hypId);
                 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
                   _mapHypo.erase( hypId );