Salome HOME
Merge from OCC_development_generic_2006
authorsmh <smh@opencascade.com>
Tue, 7 Feb 2006 15:01:11 +0000 (15:01 +0000)
committersmh <smh@opencascade.com>
Tue, 7 Feb 2006 15:01:11 +0000 (15:01 +0000)
Preparation of 3.2.0a1

83 files changed:
idl/SMESH_Gen.idl
resources/SMESHCatalog.xml
src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx
src/DriverMED/Makefile.in
src/OBJECT/SMESH_Actor.cxx
src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_Hypothesis.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESHFiltersSelection/Makefile.in
src/SMESHGUI/Makefile.in
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI.h
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx
src/SMESHGUI/SMESHGUI_ClippingDlg.cxx
src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx
src/SMESHGUI/SMESHGUI_FilterDlg.cxx
src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.h
src/SMESHGUI/SMESHGUI_MeshDlg.cxx
src/SMESHGUI/SMESHGUI_MeshDlg.h
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h
src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx
src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx
src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx
src/SMESHGUI/SMESHGUI_NodesDlg.cxx
src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx
src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_VTKUtils.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.h
src/SMESHGUI/SMESH_msg_en.po
src/SMESH_I/Makefile.in
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/StdMeshers/StdMeshers_Arithmetic1D.cxx
src/StdMeshers/StdMeshers_Arithmetic1D.hxx
src/StdMeshers/StdMeshers_AutomaticLength.cxx
src/StdMeshers/StdMeshers_AutomaticLength.hxx
src/StdMeshers/StdMeshers_Deflection1D.cxx
src/StdMeshers/StdMeshers_Deflection1D.hxx
src/StdMeshers/StdMeshers_LengthFromEdges.cxx
src/StdMeshers/StdMeshers_LengthFromEdges.hxx
src/StdMeshers/StdMeshers_LocalLength.cxx
src/StdMeshers/StdMeshers_LocalLength.hxx
src/StdMeshers/StdMeshers_MEFISTO_2D.cxx
src/StdMeshers/StdMeshers_MaxElementArea.cxx
src/StdMeshers/StdMeshers_MaxElementArea.hxx
src/StdMeshers/StdMeshers_MaxElementVolume.cxx
src/StdMeshers/StdMeshers_MaxElementVolume.hxx
src/StdMeshers/StdMeshers_NotConformAllowed.cxx
src/StdMeshers/StdMeshers_NotConformAllowed.hxx
src/StdMeshers/StdMeshers_NumberOfSegments.cxx
src/StdMeshers/StdMeshers_NumberOfSegments.hxx
src/StdMeshers/StdMeshers_Propagation.cxx
src/StdMeshers/StdMeshers_Propagation.hxx
src/StdMeshers/StdMeshers_QuadranglePreference.cxx
src/StdMeshers/StdMeshers_QuadranglePreference.hxx
src/StdMeshers/StdMeshers_Quadrangle_2D.cxx
src/StdMeshers/StdMeshers_Quadrangle_2D.hxx
src/StdMeshers/StdMeshers_Regular_1D.cxx
src/StdMeshers/StdMeshers_StartEndLength.cxx
src/StdMeshers/StdMeshers_StartEndLength.hxx
src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx [deleted file]
src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx
src/StdMeshersGUI/StdMeshersGUI_DistrPreview.h
src/StdMeshersGUI/StdMeshersGUI_DistrTable.cxx
src/StdMeshersGUI/StdMeshersGUI_DistrTable.h
src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h
src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx [deleted file]
src/StdMeshersGUI/StdMeshersGUI_Parameters.h [deleted file]
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h
src/StdMeshersGUI/StdMeshers_icons.po [deleted file]
src/StdMeshersGUI/StdMeshers_msg_en.po

index 5757e10..bc6edfb 100644 (file)
@@ -81,6 +81,19 @@ module SMESH
       raises ( SALOME::SALOME_Exception );
 
     /*!
+     * Return a hypothesis holding parameter values corresponding to the mesh
+     * existing on the given geometry.
+     * The returned hypothesis may be the one existing in a study and used
+     * to compute the mesh, or a temporary one created just to pass parameter
+     * values
+     */
+    SMESH_Hypothesis GetHypothesisParameterValues( in string            theHypName,
+                                                   in string            theLibName,
+                                                   in SMESH_Mesh        theMesh,
+                                                   in GEOM::GEOM_Object theGeom)
+      raises ( SALOME::SALOME_Exception );
+
+    /*!
      * Create a Mesh object, given a geometry shape.
      * Mesh is created empty (no points, no elements).
      * Shape is explored via GEOM_Client to create local copies.
@@ -120,15 +133,14 @@ module SMESH
      * First, verify list of hypothesis associated with the subShape,
      * return NOK if hypothesis are not sufficient
      */
-    boolean Compute( in SMESH_Mesh       theMesh, 
+    boolean Compute( in SMESH_Mesh        theMesh, 
                     in GEOM::GEOM_Object theSubObject )
       raises ( SALOME::SALOME_Exception );
 
     /*!
-     * 
+     * Return true if hypotheses are defined well
      */
-
-    boolean IsReadyToCompute( in SMESH_Mesh       theMesh, 
+    boolean IsReadyToCompute( in SMESH_Mesh        theMesh, 
                              in GEOM::GEOM_Object theSubObject )
       raises ( SALOME::SALOME_Exception );
 
@@ -136,7 +148,7 @@ module SMESH
      * Return errors of hypotheses definintion
      * algo_error_array is empty if everything is OK
      */
-    algo_error_array GetAlgoState( in SMESH_Mesh       theMesh, 
+    algo_error_array GetAlgoState( in SMESH_Mesh        theMesh, 
                                    in GEOM::GEOM_Object theSubObject )
       raises ( SALOME::SALOME_Exception );
 
@@ -144,15 +156,19 @@ module SMESH
      * 
      */
     long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
-                            in object_array theListOfSubObjects )
+                               in object_array      theListOfSubObjects )
        raises ( SALOME::SALOME_Exception );
-    
+
     /*!
-     * 
+     * Return geometrical object the given element is built on.
+     * The returned geometrical object, if not nil, is either found in the 
+     * study or is published by this method with the given name
      */
-    //    long_array GetSubMeshesState( in object_array theListOfSubShape )
-    //  raises ( SALOME::SALOME_Exception );
-    
+    GEOM::GEOM_Object GetGeometryByMeshElement( in SMESH_Mesh  theMesh,
+                                                in long        theElementID,
+                                                in string      theGeomName)
+      raises ( SALOME::SALOME_Exception );
+
   };
 
 };
index e77ee98..f9bb659 100644 (file)
@@ -20,6 +20,7 @@
                <component-comment>Mesh component</component-comment>
                <component-multistudy>1</component-multistudy>
                <component-icone>ModuleMesh.png</component-icone>
+               <component-impltype>1</component-impltype>
 
             <component-interface-list>
                 <component-interface-name>SMESH</component-interface-name>
index b9d8417..44e05bf 100644 (file)
@@ -34,6 +34,7 @@
 #include "SMESHDS_Group.hxx"
 
 #include "MED_Factory.hxx"
+#include "MED_CoordUtils.hxx"
 #include "MED_Utilities.hxx"
 
 #include <stdlib.h>
@@ -48,7 +49,9 @@ static int MYDEBUG = 0;
 
 using namespace MED;
 
-void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
+void
+DriverMED_R_SMESHDS_Mesh
+::SetMeshName(string theMeshName)
 {
   myMeshName = theMeshName;
 }
@@ -61,83 +64,9 @@ FindNode(const SMDS_Mesh* theMesh, TInt theId){
 }
 
 
-enum ECoordName{eX, eY, eZ, eNone};
-typedef TFloat (*TGetCoord)(MED::PNodeInfo&, TInt);
-
-template<ECoordName TheCoordId>
-TFloat GetCoord(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
-  return thePNodeInfo->GetNodeCoord(theElemId,TheCoordId);
-}
-
-template<>
-TFloat GetCoord<eNone>(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
-  return 0.0;
-}
-
-
-static TGetCoord aXYZGetCoord[3] = {
-  &GetCoord<eX>, 
-  &GetCoord<eY>, 
-  &GetCoord<eZ>
-};
-
-
-static TGetCoord aXYGetCoord[3] = {
-  &GetCoord<eX>, 
-  &GetCoord<eY>, 
-  &GetCoord<eNone>
-};
-
-static TGetCoord aYZGetCoord[3] = {
-  &GetCoord<eNone>,
-  &GetCoord<eX>, 
-  &GetCoord<eY>
-};
-
-static TGetCoord aXZGetCoord[3] = {
-  &GetCoord<eX>, 
-  &GetCoord<eNone>,
-  &GetCoord<eY>
-};
-
-
-static TGetCoord aXGetCoord[3] = {
-  &GetCoord<eX>, 
-  &GetCoord<eNone>,
-  &GetCoord<eNone>
-};
-
-static TGetCoord aYGetCoord[3] = {
-  &GetCoord<eNone>,
-  &GetCoord<eX>, 
-  &GetCoord<eNone>
-};
-
-static TGetCoord aZGetCoord[3] = {
-  &GetCoord<eNone>,
-  &GetCoord<eNone>,
-  &GetCoord<eX>
-};
-
-
-class TCoordHelper{
-  MED::PNodeInfo myPNodeInfo;
-  TGetCoord* myGetCoord;
-public:
-  TCoordHelper(const MED::PNodeInfo& thePNodeInfo,
-              TGetCoord* theGetCoord):
-    myPNodeInfo(thePNodeInfo),
-    myGetCoord(theGetCoord)
-  {}
-  virtual ~TCoordHelper(){}
-  TFloat GetCoord(TInt theElemId, TInt theCoodId){
-    return (*myGetCoord[theCoodId])(myPNodeInfo,theElemId);
-  }
-};
-typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
-
-
-Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
+Driver_Mesh::Status 
+DriverMED_R_SMESHDS_Mesh
+::Perform()
 {
   Status aResult = DRS_FAIL;
   try{
@@ -193,50 +122,17 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
        //------------------------------------------------------
        PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
 
-       TCoordHelperPtr aCoordHelperPtr;
-       {
-         TInt aMeshDimension = aMeshInfo->GetDim();
-         bool anIsDimPresent[3] = {false, false, false};
-          for(TInt iDim = 0; iDim < aMeshDimension; iDim++){
-           string aDimName = aNodeInfo->GetCoordName(iDim);
-           if(aDimName == "x" || aDimName == "X")
-             anIsDimPresent[eX] = true;
-           else if(aDimName == "y" || aDimName == "Y")
-             anIsDimPresent[eY] = true;
-           else if(aDimName == "z" || aDimName == "Z")
-             anIsDimPresent[eZ] = true;
-         }
-         switch(aMeshDimension){
-         case 3:
-           aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYZGetCoord));
-           break;
-         case 2:
-           if(anIsDimPresent[eY] && anIsDimPresent[eZ])
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYZGetCoord));
-           else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXZGetCoord));
-           else
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYGetCoord));
-           break;
-         case 1:
-           if(anIsDimPresent[eY])
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYGetCoord));
-           else if(anIsDimPresent[eZ])
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aZGetCoord));
-           else
-             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXGetCoord));
-           break;
-         }
-       }
+       PCoordHelper aCoordHelper = GetCoordHelper(aNodeInfo);
 
        EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
        TInt aNbElems = aNodeInfo->GetNbElem();
        if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
         DriverMED_FamilyPtr aFamily;
         for(TInt iElem = 0; iElem < aNbElems; iElem++){
+         TCCoordSlice aCoordSlice = aNodeInfo->GetCoordSlice(iElem);
           double aCoords[3] = {0.0, 0.0, 0.0};
           for(TInt iDim = 0; iDim < 3; iDim++)
-            aCoords[iDim] = aCoordHelperPtr->GetCoord(iElem,iDim);
+            aCoords[iDim] = aCoordHelper->GetCoord(aCoordSlice,iDim);
           const SMDS_MeshNode* aNode;
           if(anIsNodeNum) {
            aNode = myMesh->AddNodeWithID
@@ -258,6 +154,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
 
        // Reading pre information about all MED cells
        //--------------------------------------------
+       typedef MED::TVector<int> TNodeIds;
         bool takeNumbers = true;  // initially we trust the numbers from file
        MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
        MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
@@ -266,77 +163,63 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
          if(anEntity == eNOEUD) continue;
          // Reading MED cells to the corresponding SMDS structure
          //------------------------------------------------------
-         const MED::TGeom& aTGeom = anEntityIter->second;
-         MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
-         for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
-           const EGeometrieElement& aGeom = anTGeomIter->first;
-
-           if (aGeom == ePOINT1) {
-              continue;
-
-            } else if (aGeom == ePOLYGONE) {
+         const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
+         MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
+         for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
+           const EGeometrieElement& aGeom = aGeom2SizeIter->first;
+
+           switch(aGeom){
+           case ePOINT1:
+             break;
+           case ePOLYGONE: {
               PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
               EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
-
-              TElemNum aConn  = aPolygoneInfo->GetConnectivite();
-              TElemNum aIndex = aPolygoneInfo->GetIndex();
-
-              TInt nbPolygons = aPolygoneInfo->GetNbElem();
-
-              for (TInt iPG = 0; iPG < nbPolygons; iPG++) {
-                // get nodes
-                TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1;
-                int nbNodes = aPolygoneInfo->GetNbConn(iPG);
-                std::vector<int> nodes_ids (nbNodes);
-                //for (TInt inode = 0; inode < nbNodes; inode++) {
-                //  nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
-                //}
+             
+             TInt aNbElem = aPolygoneInfo->GetNbElem();
+             for(TInt iElem = 0; iElem < aNbElem; iElem++){
+               MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
+               TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
+               TNodeIds aNodeIds(aNbConn);
 #ifdef _EDF_NODE_IDS_
-               if (anIsNodeNum) {
-                 for (TInt inode = 0; inode < nbNodes; inode++) {
-                   nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPG_FirstNodeIndex + inode] - 1);
-                 }
-               } else {
-                 for (TInt inode = 0; inode < nbNodes; inode++) {
-                   nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
-                 }
-               }
+               if(anIsNodeNum)
+                 for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                   aNodeIds[iConn] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+               else
+                 for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                   aNodeIds[iConn] = aConnSlice[iConn];
 #else
-               for (TInt inode = 0; inode < nbNodes; inode++) {
-                 nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
-               }
+               for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                 aNodeIds[iConn] = aConnSlice[iConn];
 #endif
-
                 bool isRenum = false;
                 SMDS_MeshElement* anElement = NULL;
-                TInt aFamNum = aPolygoneInfo->GetFamNum(iPG);
+                TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
 
-                try {
-                  if (anIsElemNum) {
-                    anElement = myMesh->AddPolygonalFaceWithID
-                      (nodes_ids, aPolygoneInfo->GetElemNum(iPG));
-                  }
-                  if (!anElement) {
-                    std::vector<const SMDS_MeshNode*> nodes (nbNodes);
-                    for (int inode = 0; inode < nbNodes; inode++) {
-                      nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
-                    }
-                    anElement = myMesh->AddPolygonalFace(nodes);
+                try{
+                  if(anIsElemNum){
+                   TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
+                    anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
+                 }
+                  if(!anElement){
+                    std::vector<const SMDS_MeshNode*> aNodes(aNbConn);
+                   for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                      aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
+                    anElement = myMesh->AddPolygonalFace(aNodes);
                     isRenum = anIsElemNum;
                   }
-                } catch (const std::exception& exc) {
+                }catch(const std::exception& exc){
                   aResult = DRS_FAIL;
-                } catch (...) {
+                }catch (...){
                   aResult = DRS_FAIL;
                 }
 
-                if (!anElement) {
+                if(!anElement){
                   aResult = DRS_WARN_SKIP_ELEM;
-                } else {
-                  if (isRenum) {
+                }else{
+                  if(isRenum){
                     anIsElemNum = eFAUX;
                     takeNumbers = false;
-                    if (aResult < DRS_WARN_RENUMBER)
+                    if(aResult < DRS_WARN_RENUMBER)
                       aResult = DRS_WARN_RENUMBER;
                   }
                   if ( checkFamilyID ( aFamily, aFamNum ))
@@ -346,336 +229,309 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
                     aFamily->SetType(anElement->GetType());
                   }
                 }
-              } // for (TInt iPG = 0; iPG < nbPolygons; iPG++)
-              continue;
-
-            } else if (aGeom == ePOLYEDRE) {
+              }
+              break;
+           }
+           case ePOLYEDRE: {
               PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
               EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
 
-              TElemNum aConn       = aPolyedreInfo->GetConnectivite();
-              TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex();
-              TElemNum aIndex      = aPolyedreInfo->GetIndex();
-
-              TInt nbPolyedres = aPolyedreInfo->GetNbElem();
-
-              for (int iPE = 0; iPE < nbPolyedres; iPE++) {
-                // get faces
-                int aCurrPE_FirstFaceIndex = aIndex[iPE] - 1;
-                int aNextPE_FirstFaceIndex = aIndex[iPE + 1] - 1;
-                int nbFaces = aNextPE_FirstFaceIndex - aCurrPE_FirstFaceIndex;
-                std::vector<int> quantities (nbFaces);
-                for (int iFa = 0; iFa < nbFaces; iFa++) {
-                  int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1;
-                  int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1;
-
-                  int nbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex;
-                  quantities[iFa] = nbNodes;
-                }
-
-                // get nodes
-                int aCurrPE_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex] - 1;
-                int nbPENodes = aPolyedreInfo->GetNbConn(iPE);
-                std::vector<int> nodes_ids (nbPENodes);
-                //for (int inode = 0; inode < nbPENodes; inode++) {
-                //  nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
-                //}
+             TInt aNbElem = aPolyedreInfo->GetNbElem();
+             for(TInt iElem = 0; iElem < aNbElem; iElem++){
+               MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
+               TInt aNbFaces = aConnSliceArr.size();
+                typedef MED::TVector<int> TQuantities;
+               TQuantities aQuantities(aNbFaces);
+               TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
+               TNodeIds aNodeIds(aNbNodes);
+               for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
+                 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+                 TInt aNbConn = aConnSlice.size();
+                  aQuantities[iFace] = aNbConn;
 #ifdef _EDF_NODE_IDS_
-               if (anIsNodeNum) {
-                 for (int inode = 0; inode < nbPENodes; inode++) {
-                   nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPE_FirstNodeIndex + inode] - 1);
-                 }
-               } else {
-                 for (int inode = 0; inode < nbPENodes; inode++) {
-                   nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
-                 }
-               }
+                 if(anIsNodeNum)
+                   for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                     aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+                 else
+                   for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                     aNodeIds[iNode++] = aConnSlice[iConn];
 #else
-               for (int inode = 0; inode < nbPENodes; inode++) {
-                 nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
+                 for(TInt iConn = 0; iConn < aNbConn; iConn++)
+                   aNodeIds[iNode++] = aConnSlice[iConn];
+#endif         
                }
-#endif
-
-                bool isRenum = false;
-                SMDS_MeshElement* anElement = NULL;
-                TInt aFamNum = aPolyedreInfo->GetFamNum(iPE);
 
-                try {
-                  if (anIsElemNum) {
-                    anElement = myMesh->AddPolyhedralVolumeWithID
-                      (nodes_ids, quantities, aPolyedreInfo->GetElemNum(iPE));
-                  }
-                  if (!anElement) {
-                    std::vector<const SMDS_MeshNode*> nodes (nbPENodes);
-                    for (int inode = 0; inode < nbPENodes; inode++) {
-                      nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
-                    }
-                    anElement = myMesh->AddPolyhedralVolume(nodes, quantities);
-                    isRenum = anIsElemNum;
-                  }
-                } catch (const std::exception& exc) {
-                  aResult = DRS_FAIL;
-                } catch (...) {
-                  aResult = DRS_FAIL;
-                }
-
-                if (!anElement) {
-                  aResult = DRS_WARN_SKIP_ELEM;
-                } else {
-                  if (isRenum) {
-                    anIsElemNum = eFAUX;
-                    takeNumbers = false;
-                    if (aResult < DRS_WARN_RENUMBER)
-                      aResult = DRS_WARN_RENUMBER;
-                  }
-                  if ( checkFamilyID ( aFamily, aFamNum ))
-                  {
-                    // Save reference to this element from its family
-                    aFamily->AddElement(anElement);
-                    aFamily->SetType(anElement->GetType());
-                  }
-                }
-              } // for (int iPE = 0; iPE < nbPolyedres; iPE++)
-              continue;
-
-            } else {
-            }
-
-           PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
-           EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
-           TInt aNbElems = aCellInfo->GetNbElem();
-           if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
-           if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
-
-           for(int iElem = 0; iElem < aNbElems; iElem++){
-             TInt aNbNodes = -1;
-             switch(aGeom){
-             case eSEG2:
-             case eSEG3:
-               aNbNodes = 2;
-               break;
-             case eTRIA3:
-             case eTRIA6:
-               aNbNodes = 3;
-               break;
-               break;
-             case eQUAD4:
-             case eQUAD8:
-               aNbNodes = 4;
-                break;
-              case eTETRA4:
-             case eTETRA10:
-               aNbNodes = 4;
-               break;
-             case ePYRA5:
-             case ePYRA13:
-               aNbNodes = 5;
-               break;
-             case ePENTA6:
-             case ePENTA15:
-               aNbNodes = 6;
-               break;
-             case eHEXA8:
-             case eHEXA20:
-               aNbNodes = 8;
-               break;
-             }
-             vector<TInt> aNodeIds(aNbNodes);
-             bool anIsValidConnect = false;
-
-             try{
-#ifdef _EDF_NODE_IDS_
-               if(anIsNodeNum) {
-                 for(int i = 0; i < aNbNodes; i++){
-                   aNodeIds[i] = aNodeInfo->GetElemNum(aCellInfo->GetConn(iElem,i)-1);
+               bool isRenum = false;
+               SMDS_MeshElement* anElement = NULL;
+               TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
+               
+               try{
+                 if(anIsElemNum){
+                   TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
+                   anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
                  }
-               }else{
-                 for(int i = 0; i < aNbNodes; i++){
-                   aNodeIds[i] = aCellInfo->GetConn(iElem,i);
+                 if(!anElement){
+                   std::vector<const SMDS_MeshNode*> aNodes(aNbNodes);
+                   for(TInt iConn = 0; iConn < aNbNodes; iConn++)
+                     aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
+                   anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
+                   isRenum = anIsElemNum;
                  }
+               }catch(const std::exception& exc){
+                 aResult = DRS_FAIL;
+               }catch(...){
+                 aResult = DRS_FAIL;
                }
-#else
-               for(int i = 0; i < aNbNodes; i++){
-                 aNodeIds[i] = aCellInfo->GetConn(iElem,i);
+               
+               if(!anElement){
+                 aResult = DRS_WARN_SKIP_ELEM;
+               }else{
+                 if(isRenum){
+                   anIsElemNum = eFAUX;
+                   takeNumbers = false;
+                   if (aResult < DRS_WARN_RENUMBER)
+                     aResult = DRS_WARN_RENUMBER;
+                 }
+                 if ( checkFamilyID ( aFamily, aFamNum )) {
+                   // Save reference to this element from its family
+                   aFamily->AddElement(anElement);
+                   aFamily->SetType(anElement->GetType());
+                 }
                }
-#endif
-               anIsValidConnect = true;
-             }catch(const std::exception& exc){
-               //INFOS("Follow exception was cought:\n\t"<<exc.what());
-               aResult = DRS_FAIL;
-             }catch(...){
-               //INFOS("Unknown exception was cought !!!");
-               aResult = DRS_FAIL;
              }
+              break;
+            }
+           default: {
+             PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
+             EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
+             TInt aNbElems = aCellInfo->GetNbElem();
+             if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
+             if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
              
-             if(!anIsValidConnect)
-               continue;
-
-             bool isRenum = false;
-             SMDS_MeshElement* anElement = NULL;
-             TInt aFamNum = aCellInfo->GetFamNum(iElem);
-             try{
-                //MESSAGE("Try to create element # " << iElem << " with id = "
-                //        << aCellInfo->GetElemNum(iElem));
+             for(int iElem = 0; iElem < aNbElems; iElem++){
+               TInt aNbNodes = -1;
                switch(aGeom){
                case eSEG2:
                case eSEG3:
-                 if(anIsElemNum)
-                   anElement = myMesh->AddEdgeWithID(aNodeIds[0],
-                                                     aNodeIds[1],
-                                                     aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
-                                               FindNode(myMesh,aNodeIds[1]));
-                   isRenum = anIsElemNum;
-                 }
+                 aNbNodes = 2;
                  break;
                case eTRIA3:
                case eTRIA6:
                  aNbNodes = 3;
-                 if(anIsElemNum)
-                   anElement = myMesh->AddFaceWithID(aNodeIds[0],
-                                                     aNodeIds[1],
-                                                     aNodeIds[2],
-                                                     aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
-                                               FindNode(myMesh,aNodeIds[1]),
-                                               FindNode(myMesh,aNodeIds[2]));
-                   isRenum = anIsElemNum;
-                 }
+                 break;
                  break;
                case eQUAD4:
                case eQUAD8:
                  aNbNodes = 4;
-                 // There is some differnce between SMDS and MED
-                 if(anIsElemNum)
-                   anElement = myMesh->AddFaceWithID(aNodeIds[0],
-                                                     aNodeIds[1],
-                                                     aNodeIds[2],
-                                                     aNodeIds[3],
-                                                     aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
-                                               FindNode(myMesh,aNodeIds[1]),
-                                               FindNode(myMesh,aNodeIds[2]),
-                                               FindNode(myMesh,aNodeIds[3]));
-                   isRenum = anIsElemNum;
-                 }
                  break;
                case eTETRA4:
                case eTETRA10:
                  aNbNodes = 4;
-                 if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
-                                                       aNodeIds[1],
-                                                       aNodeIds[2],
-                                                       aNodeIds[3],
-                                                       aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
-                                                 FindNode(myMesh,aNodeIds[1]),
-                                                 FindNode(myMesh,aNodeIds[2]),
-                                                 FindNode(myMesh,aNodeIds[3]));
-                   isRenum = anIsElemNum;
-                 }
                  break;
                case ePYRA5:
                case ePYRA13:
                  aNbNodes = 5;
-                 // There is some differnce between SMDS and MED
-                 if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
-                                                       aNodeIds[1],
-                                                       aNodeIds[2],
-                                                       aNodeIds[3],
-                                                       aNodeIds[4],
-                                                       aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
-                                                 FindNode(myMesh,aNodeIds[1]),
-                                                 FindNode(myMesh,aNodeIds[2]),
-                                                 FindNode(myMesh,aNodeIds[3]),
-                                                 FindNode(myMesh,aNodeIds[4]));
-                   isRenum = anIsElemNum;
-                 }
                  break;
                case ePENTA6:
                case ePENTA15:
                  aNbNodes = 6;
-                 if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
-                                                       aNodeIds[1],
-                                                       aNodeIds[2],
-                                                       aNodeIds[3],
-                                                       aNodeIds[4],
-                                                       aNodeIds[5],
-                                                       aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
-                                                 FindNode(myMesh,aNodeIds[1]),
-                                                 FindNode(myMesh,aNodeIds[2]),
-                                                 FindNode(myMesh,aNodeIds[3]),
-                                                 FindNode(myMesh,aNodeIds[4]),
-                                                 FindNode(myMesh,aNodeIds[5]));
-                   isRenum = anIsElemNum;
-                 }
                  break;
                case eHEXA8:
                case eHEXA20:
                  aNbNodes = 8;
-                 if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                 break;
+               }
+               TNodeIds aNodeIds(aNbNodes);
+               bool anIsValidConnect = false;
+               TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
+               try{
+#ifdef _EDF_NODE_IDS_
+                 if(anIsNodeNum)
+                   for(int iNode = 0; iNode < aNbNodes; iNode++)
+                     aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
+                 else
+                   for(int iNode = 0; iNode < aNbNodes; iNode++)
+                     aNodeIds[iNode] = aConnSlice[iNode];
+#else
+                 for(int iNode = 0; iNode < aNbNodes; iNode++)
+                   aNodeIds[iNode] = aConnSlice[iNode];
+#endif
+                 anIsValidConnect = true;
+               }catch(const std::exception& exc){
+                 //INFOS("Follow exception was cought:\n\t"<<exc.what());
+                 aResult = DRS_FAIL;
+               }catch(...){
+                 //INFOS("Unknown exception was cought !!!");
+                 aResult = DRS_FAIL;
+               }
+               
+               if(!anIsValidConnect)
+                 continue;
+               
+               bool isRenum = false;
+               SMDS_MeshElement* anElement = NULL;
+               TInt aFamNum = aCellInfo->GetFamNum(iElem);
+               try{
+                 //MESSAGE("Try to create element # " << iElem << " with id = "
+                 //        << aCellInfo->GetElemNum(iElem));
+                 switch(aGeom){
+                 case eSEG2:
+                 case eSEG3:
+                   if(anIsElemNum)
+                     anElement = myMesh->AddEdgeWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case eTRIA3:
+                 case eTRIA6:
+                   aNbNodes = 3;
+                   if(anIsElemNum)
+                     anElement = myMesh->AddFaceWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aNodeIds[2],
+                                                       aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]),
+                                                 FindNode(myMesh,aNodeIds[2]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case eQUAD4:
+                 case eQUAD8:
+                   aNbNodes = 4;
+                   // There is some differnce between SMDS and MED
+                   if(anIsElemNum)
+                     anElement = myMesh->AddFaceWithID(aNodeIds[0],
                                                        aNodeIds[1],
                                                        aNodeIds[2],
                                                        aNodeIds[3],
-                                                       aNodeIds[4],
-                                                       aNodeIds[5],
-                                                       aNodeIds[6],
-                                                       aNodeIds[7],
                                                        aCellInfo->GetElemNum(iElem));
-                 if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                   if (!anElement) {
+                     anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
                                                  FindNode(myMesh,aNodeIds[1]),
                                                  FindNode(myMesh,aNodeIds[2]),
-                                                 FindNode(myMesh,aNodeIds[3]),
-                                                 FindNode(myMesh,aNodeIds[4]),
-                                                 FindNode(myMesh,aNodeIds[5]),
-                                                 FindNode(myMesh,aNodeIds[6]),
-                                                 FindNode(myMesh,aNodeIds[7]));
-                   isRenum = anIsElemNum;
+                                                 FindNode(myMesh,aNodeIds[3]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case eTETRA4:
+                 case eTETRA10:
+                   aNbNodes = 4;
+                   if(anIsElemNum)
+                     anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                         aNodeIds[1],
+                                                         aNodeIds[2],
+                                                         aNodeIds[3],
+                                                         aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                   FindNode(myMesh,aNodeIds[1]),
+                                                   FindNode(myMesh,aNodeIds[2]),
+                                                   FindNode(myMesh,aNodeIds[3]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case ePYRA5:
+                 case ePYRA13:
+                   aNbNodes = 5;
+                   // There is some differnce between SMDS and MED
+                   if(anIsElemNum)
+                     anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                         aNodeIds[1],
+                                                         aNodeIds[2],
+                                                         aNodeIds[3],
+                                                         aNodeIds[4],
+                                                         aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                   FindNode(myMesh,aNodeIds[1]),
+                                                   FindNode(myMesh,aNodeIds[2]),
+                                                   FindNode(myMesh,aNodeIds[3]),
+                                                   FindNode(myMesh,aNodeIds[4]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case ePENTA6:
+                 case ePENTA15:
+                   aNbNodes = 6;
+                   if(anIsElemNum)
+                     anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                         aNodeIds[1],
+                                                         aNodeIds[2],
+                                                         aNodeIds[3],
+                                                         aNodeIds[4],
+                                                         aNodeIds[5],
+                                                         aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                   FindNode(myMesh,aNodeIds[1]),
+                                                   FindNode(myMesh,aNodeIds[2]),
+                                                   FindNode(myMesh,aNodeIds[3]),
+                                                   FindNode(myMesh,aNodeIds[4]),
+                                                   FindNode(myMesh,aNodeIds[5]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
+                 case eHEXA8:
+                 case eHEXA20:
+                   aNbNodes = 8;
+                   if(anIsElemNum)
+                     anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                         aNodeIds[1],
+                                                         aNodeIds[2],
+                                                         aNodeIds[3],
+                                                         aNodeIds[4],
+                                                         aNodeIds[5],
+                                                         aNodeIds[6],
+                                                         aNodeIds[7],
+                                                         aCellInfo->GetElemNum(iElem));
+                   if (!anElement) {
+                     anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                   FindNode(myMesh,aNodeIds[1]),
+                                                   FindNode(myMesh,aNodeIds[2]),
+                                                   FindNode(myMesh,aNodeIds[3]),
+                                                   FindNode(myMesh,aNodeIds[4]),
+                                                   FindNode(myMesh,aNodeIds[5]),
+                                                   FindNode(myMesh,aNodeIds[6]),
+                                                   FindNode(myMesh,aNodeIds[7]));
+                     isRenum = anIsElemNum;
+                   }
+                   break;
                  }
-                 break;
+               }catch(const std::exception& exc){
+                 //INFOS("Follow exception was cought:\n\t"<<exc.what());
+                 aResult = DRS_FAIL;
+               }catch(...){
+                 //INFOS("Unknown exception was cought !!!");
+                 aResult = DRS_FAIL;
                }
-             }catch(const std::exception& exc){
-               //INFOS("Follow exception was cought:\n\t"<<exc.what());
-               aResult = DRS_FAIL;
-             }catch(...){
-               //INFOS("Unknown exception was cought !!!");
-               aResult = DRS_FAIL;
-             }
                
-              if (!anElement) {
-                aResult = DRS_WARN_SKIP_ELEM;
-              }
-              else {
-                if (isRenum) {
-                  anIsElemNum = eFAUX;
-                  takeNumbers = false;
-                  if (aResult < DRS_WARN_RENUMBER)
-                    aResult = DRS_WARN_RENUMBER;
-                }
-                if ( checkFamilyID ( aFamily, aFamNum ))
-                {
-                  // Save reference to this element from its family
-                  aFamily->AddElement(anElement);
-                  aFamily->SetType(anElement->GetType());
-                }
-              }
-            }
+               if (!anElement) {
+                 aResult = DRS_WARN_SKIP_ELEM;
+               }
+               else {
+                 if (isRenum) {
+                   anIsElemNum = eFAUX;
+                   takeNumbers = false;
+                   if (aResult < DRS_WARN_RENUMBER)
+                     aResult = DRS_WARN_RENUMBER;
+                 }
+                 if ( checkFamilyID ( aFamily, aFamNum )) {
+                   // Save reference to this element from its family
+                   myFamilies[aFamNum]->AddElement(anElement);
+                   myFamilies[aFamNum]->SetType(anElement->GetType());
+                 }
+               }
+             }
+           }}
          }
        }
-       break;
       }
     }
   }catch(const std::exception& exc){
index 980a648..22b33cf 100644 (file)
@@ -329,12 +329,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
       int aFamId = (*aFamsIter)->GetId();
 
       const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
-         set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
+      set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
       for (; anElemsIter != anElems.end(); anElemsIter++)
       {
         anElemFamMap[*anElemsIter] = aFamId;
       }
-//      delete (*aFamsIter);
     }
 
     // Storing SMDS nodes to the MED file for the MED mesh
@@ -373,8 +372,9 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
     const ERepere SMDS_COORDINATE_SYSTEM = eCART;
 
     PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo,
-                                           SMDS_COORDINATE_SYSTEM,
                                            aCoordinates,
+                                           eFULL_INTERLACE,
+                                           SMDS_COORDINATE_SYSTEM,
                                            aCoordNames,
                                            aCoordUnits,
                                            aFamilyNums,
@@ -421,8 +421,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
       PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                              SMDS_MED_ENTITY,
                                              eSEG2,
-                                             SMDS_MED_CONNECTIVITY,
                                              aConnectivity,
+                                             SMDS_MED_CONNECTIVITY,
                                              aFamilyNums,
                                              anElemNums);
       myMed->SetCellInfo(aCellInfo);
@@ -532,8 +532,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                eTRIA3,
-                                               SMDS_MED_CONNECTIVITY,
                                                aTriaConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aTriaFamilyNums,
                                                anTriaElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA3<<"; aNbElems = "<<aNbElems);
@@ -543,8 +543,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                eQUAD4,
-                                               SMDS_MED_CONNECTIVITY,
                                                aQuadConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aQuadFamilyNums,
                                                aQuadElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
@@ -558,9 +558,9 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
                                                         SMDS_MED_ENTITY,
                                                         ePOLYGONE,
-                                                        SMDS_MED_CONNECTIVITY,
-                                                        aPolygoneConn,
                                                         aPolygoneInds,
+                                                        aPolygoneConn,
+                                                        SMDS_MED_CONNECTIVITY,
                                                         aPolygoneFamilyNums,
                                                         aPolygoneElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
@@ -722,8 +722,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                eTETRA4,
-                                               SMDS_MED_CONNECTIVITY,
                                                aTetraConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aTetraFamilyNums,
                                                anTetraElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA4<<"; aNbElems = "<<aNbElems);
@@ -733,8 +733,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                ePYRA5,
-                                               SMDS_MED_CONNECTIVITY,
                                                aPyraConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aPyraFamilyNums,
                                                anPyraElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA5<<"; aNbElems = "<<aNbElems);
@@ -744,8 +744,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                ePENTA6,
-                                               SMDS_MED_CONNECTIVITY,
                                                aPentaConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aPentaFamilyNums,
                                                anPentaElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA6<<"; aNbElems = "<<aNbElems);
@@ -755,8 +755,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
                                                SMDS_MED_ENTITY,
                                                eHEXA8,
-                                               SMDS_MED_CONNECTIVITY,
                                                aHexaConn,
+                                               SMDS_MED_CONNECTIVITY,
                                                aHexaFamilyNums,
                                                aHexaElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
@@ -770,10 +770,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
        PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
                                                         SMDS_MED_ENTITY,
                                                         ePOLYEDRE,
-                                                        SMDS_MED_CONNECTIVITY,
-                                                        aPolyedreConn,
-                                                        aPolyedreFaces,
                                                         aPolyedreInds,
+                                                        aPolyedreFaces,
+                                                        aPolyedreConn,
+                                                        SMDS_MED_CONNECTIVITY,
                                                         aPolyedreFamilyNums,
                                                         aPolyedreElemNums);
        MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
index 8426a4d..8c9e441 100644 (file)
@@ -63,7 +63,7 @@ CPPFLAGS += $(OCC_INCLUDES) -I${MED_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS  += -lMeshDriver -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper
 
-LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 -lOpUtil -lSALOMELocalTrace -lSALOMEBasics
+LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lmed_V2_1 -lMEDWrapper_V2_2 -lOpUtil -lSALOMELocalTrace -lSALOMEBasics
 
 @CONCLUDE@
 
index 3c5e2e0..5b21ac7 100644 (file)
 #include "SMESH_ActorUtils.h"
 #include "SMESH_DeviceActor.h"
 #include "SMESH_ControlsDef.hxx"
-#include <VTKViewer_ExtractUnstructuredGrid.h>
+#include "VTKViewer_ExtractUnstructuredGrid.h"
 
 #include "SUIT_Session.h"
 #include "SUIT_ResourceMgr.h"
 
 #include <qstringlist.h>
 
+#include <vtkProperty.h>
 #include <vtkTimeStamp.h>
 #include <vtkObjectFactory.h>
 #include <vtkShrinkPolyData.h>
@@ -786,6 +787,8 @@ vtkDataSet* SMESH_ActorDef::GetInput(){
 
 
 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
+  Superclass::SetTransform(theTransform);
+
   myNodeActor->SetTransform(theTransform);
   myBaseActor->SetTransform(theTransform);
 
index 9d439f7..3cddc41 100644 (file)
@@ -32,6 +32,7 @@ using namespace std;
 #include "SMESH_Mesh.hxx"
 #include "SMESH_HypoFilter.hxx"
 #include "SMDS_FacePosition.hxx"
+#include "SMDS_EdgePosition.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 #include "SMESHDS_Mesh.hxx"
@@ -149,24 +150,24 @@ const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
 
 double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
 {
-       double UMin = 0, UMax = 0;
-       TopLoc_Location L;
-       if (BRep_Tool::Degenerated(E))
-               return 0;
-       Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
-       GeomAdaptor_Curve AdaptCurve(C);
-       GCPnts_AbscissaPoint gabs;
-       double length = gabs.Length(AdaptCurve, UMin, UMax);
-       return length;
+  double UMin = 0, UMax = 0;
+  if (BRep_Tool::Degenerated(E))
+    return 0;
+  TopLoc_Location L;
+  Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
+  GeomAdaptor_Curve AdaptCurve(C);
+  GCPnts_AbscissaPoint gabs;
+  double length = gabs.Length(AdaptCurve, UMin, UMax);
+  return length;
 }
 
 //================================================================================
 /*!
  * \brief Find out elements orientation on a geometrical face
 * \param theFace - The face correctly oriented in the shape being meshed
 * \param theMeshDS - The mesh data structure
 * \retval bool - true if the face normal and the normal of first element
 *                in the correspoding submesh point in different directions
+ * \param theFace - The face correctly oriented in the shape being meshed
+ * \param theMeshDS - The mesh data structure
+ * \retval bool - true if the face normal and the normal of first element
+ *                in the correspoding submesh point in different directions
  */
 //================================================================================
 
@@ -267,3 +268,79 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face&  theFace,
 
   return Ne * Nf < 0.;
 }
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as the algorithm does not hold parameters values
+ */
+//================================================================================
+
+bool SMESH_Algo::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+                                     const TopoDS_Shape& /*theShape*/)
+{
+  return false;
+}
+
+//================================================================================
+/*!
+ * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
+ * \param theMesh - The mesh containing nodes
+ * \param theEdge - The geometrical edge of interest
+ * \param theParams - The resulting vector of sorted node parameters
+ * \retval bool - false if not all parameters are OK
+ */
+//================================================================================
+
+bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
+                                    const TopoDS_Edge&  theEdge,
+                                    vector< double > &  theParams)
+{
+  theParams.clear();
+
+  if ( !theMesh || theEdge.IsNull() )
+    return false;
+
+  SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
+  if ( !eSubMesh || !eSubMesh->GetElements()->more() )
+    return false; // edge is not meshed
+
+  int nbEdgeNodes = 0;
+  set < double > paramSet;
+  if ( eSubMesh )
+  {
+    // loop on nodes of an edge: sort them by param on edge
+    SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
+    while ( nIt->more() )
+    {
+      const SMDS_MeshNode* node = nIt->next();
+      const SMDS_PositionPtr& pos = node->GetPosition();
+      if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
+        return false;
+      const SMDS_EdgePosition* epos =
+        static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+      paramSet.insert( epos->GetUParameter() );
+      ++nbEdgeNodes;
+    }
+  }
+  // add vertex nodes params
+  Standard_Real f, l;
+  BRep_Tool::Range(theEdge, f, l);
+  paramSet.insert( f );
+  paramSet.insert( l );
+  if ( paramSet.size() != nbEdgeNodes + 2 )
+    return false; // there are equal parameters
+
+  // fill the vector
+  theParams.resize( paramSet.size() );
+  set < double >::iterator   par    = paramSet.begin();
+  vector< double >::iterator vecPar = theParams.begin();
+  for ( ; par != paramSet.end(); ++par, ++vecPar )
+    *vecPar = *par;
+
+  return theParams.size() > 1;
+}
index 12c72d8..c92b589 100644 (file)
@@ -41,6 +41,7 @@
 class SMESH_Gen;
 class SMESH_Mesh;
 class TopoDS_Face;
+class TopoDS_Shape;
 class SMESHDS_Mesh;
 
 class SMESH_Algo:public SMESH_Hypothesis
@@ -65,6 +66,19 @@ class SMESH_Algo:public SMESH_Hypothesis
        static double EdgeLength(const TopoDS_Edge & E);
 
   /*!
+   * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
+    * \param theMesh - The mesh containing nodes
+    * \param theEdge - The geometrical edge of interest
+    * \param theParams - The resulting vector of sorted node parameters
+    * \retval bool - false if not all parameters are OK
+   */
+  static bool GetNodeParamOnEdge(const SMESHDS_Mesh*     theMesh,
+                                 const TopoDS_Edge&      theEdge,
+                                 std::vector< double > & theParams);
+
+  //static bool GetSegmentLengths();
+
+  /*!
    * \brief Find out elements orientation on a geometrical face
    * \param theFace - The face correctly oriented in the shape being meshed
    * \param theMeshDS - The mesh data structure
@@ -74,6 +88,16 @@ class SMESH_Algo:public SMESH_Hypothesis
   static bool IsReversedSubMesh (const TopoDS_Face&  theFace,
                                  SMESHDS_Mesh*       theMeshDS);
 
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+    *
+    * Just return false as the algorithm does not hold parameters values
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
  public:
         // algo features
 
index 1d881a6..2edcd14 100644 (file)
@@ -32,6 +32,8 @@
 #include "SMESHDS_Hypothesis.hxx"
 
 class SMESH_Gen;
+class TopoDS_Shape;
+class SMESH_Mesh;
 
 class SMESH_Hypothesis: public SMESHDS_Hypothesis
 {
@@ -61,6 +63,14 @@ public:
   const char* GetLibName() const;
   void  SetLibName(const char* theLibName);
 
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
+
 protected:
   SMESH_Gen* _gen;
   int _studyId;
index ffd77cd..a4b5f80 100644 (file)
@@ -1069,8 +1069,8 @@ void SMESH_Mesh::RemoveGroup (const int theGroupID)
   if (_mapGroup.find(theGroupID) == _mapGroup.end())
     return;
   GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
-  _mapGroup.erase (theGroupID);
   delete _mapGroup[theGroupID];
+  _mapGroup.erase (theGroupID);
 }
 
 //=============================================================================
index e9c3881..c438321 100644 (file)
@@ -64,7 +64,7 @@ EXPORT_HEADERS= SMESH_Type.h \
 # additionnal information to compil and link file
 CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) \
             -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-            -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
+            -I${GEOM_ROOT_DIR}/include/salome ${BOOST_CPPFLAGS}
 CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
             -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
 LDFLAGS  += $(OCC_KERNEL_LIBS) -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit
index a1d7e8a..55987d6 100644 (file)
@@ -108,7 +108,8 @@ LIB_SRC =   SMESHGUI.cxx \
                SMESHGUI_MeshDlg.cxx \
                SMESHGUI_MeshOp.cxx \
                SMESHGUI_Displayer.cxx \
-               SMESHGUI_Hypotheses.cxx
+               SMESHGUI_Hypotheses.cxx \
+               SMESHGUI_ShapeByMeshDlg.cxx
 
 LIB_MOC = \
                SMESHGUI.h \
@@ -155,7 +156,8 @@ LIB_MOC = \
                SMESHGUI_Dialog.h \
                SMESHGUI_MeshDlg.h \
                SMESHGUI_MeshOp.h \
-               SMESHGUI_Hypotheses.h
+               SMESHGUI_Hypotheses.h \
+               SMESHGUI_ShapeByMeshDlg.h
 
 
 LIB_CLIENT_IDL = SALOME_Exception.idl \
index fae7039..ecc471d 100644 (file)
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_FileDlg.h"
 #include "SUIT_Desktop.h"
-#include "SUIT_ResourceMgr.h"
 #include "SUIT_OverrideCursor.h"
 #include "SUIT_Study.h"
 #include "SUIT_Session.h"
@@ -1071,6 +1070,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   if( !mgr )
     return false;
 
+  if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
+    GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
+  }
+
   SUIT_ViewWindow* view = application()->desktop()->activeWindow();
   SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
 
@@ -2995,11 +2998,67 @@ void SMESHGUI::createPreferences()
 
 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
 {
-  if( sect=="SMESH" )
+  if( sect=="SMESH" ){
+    float sbX1,sbY1,sbW,sbH;
+    std::string aWarning;
+    SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
     if( name=="selection_object_color" || name=="selection_element_color" || 
         name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
         name=="selection_precision_node" || name=="selection_precision_element" )
       SMESH::UpdateSelectionProp( this );
+    else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
+      sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
+      sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
+      if(sbX1+sbW > 1.0){
+       aWarning = "Origin and Size Vertical: X+Width > 1\n";   
+       sbX1=0.01;
+       sbW=0.05;
+       aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
+       aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
+      }
+    }
+    else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
+      sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
+      sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
+      if(sbY1+sbH > 1.0){
+       aWarning = "Origin and Size Vertical: Y+Height > 1\n";
+       sbY1=0.01;
+       sbH=0.5;
+       aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
+       aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
+      }
+    }
+    else if(name ==  QString("scalar_bar_horizontal_x") || name ==  QString("scalar_bar_horizontal_width")){
+      sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+      sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
+      if(sbX1+sbW > 1.0){
+       aWarning = "Origin and Size Horizontal: X+Width > 1\n";
+       sbX1=0.2;
+       sbW=0.6;
+       aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+       aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
+      }
+    }
+    else if(name ==  QString("scalar_bar_horizontal_y") || name ==  QString("scalar_bar_horizontal_height")){
+      sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+      sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
+      if(sbY1+sbH > 1.0){
+       aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
+       sbY1=0.01;
+       sbH=0.12;
+       aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+       aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
+      }
+    }
+    
+    if(aWarning.size() != 0){
+      aWarning += "The default values are applied instead.";
+      SUIT_MessageBox::warn1(SMESHGUI::desktop(),
+                            QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
+                            QObject::tr(aWarning.c_str()),
+                            QObject::tr("SMESH_BUT_OK"));
+    }
+  }
 }
 
 //================================================================================
@@ -3083,6 +3142,20 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
   return op;
 }
 
+//================================================================================
+/*!
+ * \brief Stops current operations and starts a given one
+  * \param id - The id of the operation to start
+ */
+//================================================================================
+
+void SMESHGUI::switchToOperation(int id)
+{
+  if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
+    activeStudy()->abortAllOperations();
+  startOperation( id );
+}
+
 LightApp_Displayer* SMESHGUI::displayer()
 {
   if( !myDisplayer )
index 595d831..9626e43 100644 (file)
@@ -83,6 +83,7 @@ public :
   void                ResetState() ;
   void                SetState(int aState) ;
   bool                DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
+  void                switchToOperation(int id) ;
 
   virtual bool OnGUIEvent        ( int id );
   virtual bool OnMousePress      ( QMouseEvent*, SUIT_ViewWindow* );
index 0b5e320..7a396fd 100644 (file)
@@ -65,6 +65,7 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
 
 // QT Includes
 #include <qbuttongroup.h>
index 4fe87b6..5bac218 100644 (file)
@@ -69,6 +69,7 @@
 #include <vtkPlaneSource.h>
 #include <vtkPolyData.h>
 #include <vtkRenderer.h>
+#include <vtkProperty.h>
 
 // STL includes
 #include <algorithm>
index 157a05b..abced02 100644 (file)
@@ -62,6 +62,7 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
 
 // QT Includes
 #include <qapplication.h>
@@ -109,6 +110,7 @@ class TPolySimulation{
       myPreviewActor->PickableOff();
       myPreviewActor->VisibilityOff();
       myPreviewActor->SetMapper( myMapper );
+      myPreviewActor->SetRepresentation( 3 );
 
       float anRGB[3];
       vtkProperty* aProp = vtkProperty::New();
@@ -398,8 +400,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId)
       { 
        if ( myActor ){
           myActor->SetPointRepresentation(true);
-         myActor->SetEntityMode(SMESH_Actor::eVolumes);
-         myActor->SetRepresentation(SMESH_Actor::eSurface);
        }
         else
           SMESH::SetPointRepresentation(true);
@@ -421,9 +421,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId)
       {
        if( myActor ){
          myActor->SetPointRepresentation(false);
-         myActor->SetEntityMode(SMESH_Actor::eFaces);
-         myActor->SetEntityMode(SMESH_Actor::eVolumes);
-         myActor->SetRepresentation(SMESH_Actor::eSurface);
        } else {
          SMESH::SetPointRepresentation(false);
        }
@@ -528,8 +525,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
       
       //SALOME_ListIO aList;
       //mySelectionMgr->setSelectedObjects( aList );
-      mySimulation->SetVisibility(false);
       SMESH::UpdateView();
+      if( myActor ){
+       unsigned int anEntityMode = myActor->GetEntityMode();
+       myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode);
+      }
       ConstructorsClicked( GetConstructorId() );
       busy = false;
     }
@@ -640,7 +640,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText)
          buttonOk->setEnabled( false );
          buttonApply->setEnabled( false );
        }
-       displaySimulation();
+       if(aListId.count()>1)
+         displaySimulation();
       }
     }
   }
@@ -694,9 +695,10 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
   
   // get selected nodes/faces
   QString aString = "";
+  int anbNodes=0,aNbFaces=0;
   switch(GetConstructorId()){
   case 0:{
-    int anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
+    anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
     if (anbNodes >= 3)
       AddButton->setEnabled(true);
     else if (anbNodes < 3){
@@ -709,7 +711,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
   }
   case 1:{
     // get selected faces
-    int aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
+    aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
     if (aNbFaces<=1){
       buttonOk->setEnabled( false );
       buttonApply->setEnabled( false );
@@ -727,8 +729,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
   }
   default: return;
   }
-  
-  displaySimulation();
+  if(anbNodes>2 || aNbFaces>1)
+    displaySimulation();
 }
 
 //=======================================================================
@@ -742,8 +744,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
       SMESH::TPolySimulation::TVTKIds aVTKIds;
       vtkIdType aType = VTK_CONVEX_POINT_SET ;
       if (GetConstructorId() == 0){
-       if(!Preview->isChecked()) myActor->SetEntityMode(SMESH_Actor::eFaces);
-       else myActor->SetEntityMode(SMESH_Actor::eVolumes);
        if (!AddButton->isEnabled()){
          QListBoxItem* anItem;
          mySimulation->ResetGrid(true);
@@ -771,7 +771,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
        } else {
          // add ids from edit line
          QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false);
-         myActor->SetEntityMode(SMESH_Actor::eFaces);
          for ( int i = 0; i < anEditIds.count(); i++ )
            aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() ));
          aType = VTK_POLYGON;
@@ -781,10 +780,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
        SMDS_Mesh* aMesh = 0;
        if ( myActor ){
          aMesh = myActor->GetObject()->GetMesh();
-         if (Preview->isChecked())
-           myActor->SetEntityMode(SMESH_Actor::eVolumes);
-         else
-           myActor->SetEntityMode(SMESH_Actor::eFaces);
        }
        if ( aMesh ) {
          QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
index 6e4ab9f..cd3d8eb 100755 (executable)
@@ -2260,17 +2260,17 @@ bool SMESHGUI_FilterDlg::createFilter (const int theType)
 //=======================================================================
 void SMESHGUI_FilterDlg::insertFilterInViewer()
 {
-  if (SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle()) {
+  if (SVTK_Selector* aSelector = SMESH::GetSelector()) {
     SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
 
     if (myFilter[ myTable->GetType() ]->_is_nil() ||
          myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
          !mySetInViewer->isChecked()) {
-      SMESH::RemoveFilter(getFilterId(anEntType), aStyle);
+      SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
     } else {
       Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
       aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
-      SMESH::SetFilter(aFilter, aStyle);
+      SMESH::SetFilter(aFilter, aSelector);
     }
   }
 }
index c9ffc82..4ea7e91 100644 (file)
@@ -37,8 +37,11 @@ namespace SMESH {
   {
     static GEOM::GEOM_Gen_var aGEOMGen;
 
-    if(CORBA::is_nil(aGEOMGen))
-        aGEOMGen = GeometryGUI::GetGeomGen();
+    if(CORBA::is_nil(aGEOMGen)) {
+      if ( GeometryGUI::GetGeomGen()->_is_nil() )
+        GeometryGUI::InitGeomGen();
+      aGEOMGen = GeometryGUI::GetGeomGen();
+    }
     return aGEOMGen;
   }
 
index 82da54a..b939631 100644 (file)
@@ -89,6 +89,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
      mySMESHGUI( theModule ),
      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+     mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
      myIsBusy( false ),
      myActor( 0 )
 {
@@ -103,7 +104,6 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
     myGeomGroupLine->setEnabled(false);
   }
 
-  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
 
   /* Move widget on the botton right corner of main widget */
   int x, y ;
@@ -121,12 +121,11 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
      mySMESHGUI( theModule ),
      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+     mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
      myIsBusy( false )
 {
   if (!name) setName("SMESHGUI_GroupDlg");
 
-  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
-
   initDialog(false);
   if (!theGroup->_is_nil())
     init(theGroup);
@@ -563,14 +562,14 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
          aViewWindow->SetSelectionMode(VolumeSelection);
       }
     } else {
-      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-       aViewWindow->SetSelectionMode(ActorSelection);
       if (theMode == 4)
        mySelectionMgr->installFilter(mySubMeshFilter);
       else if (theMode == 5)
        mySelectionMgr->installFilter(myGroupFilter);
       else if (theMode == 6)
        mySelectionMgr->installFilter(myMeshFilter);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->SetSelectionMode(ActorSelection);
     }
     mySelectionMode = theMode;
   }
@@ -716,8 +715,6 @@ void SMESHGUI_GroupDlg::onListSelectionChanged()
     SALOME_ListIO aList;
     aList.Append(myActor->getIO());
     mySelectionMgr->setSelectedObjects(aList,false);
-    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-      aViewWindow->highlight( myActor->getIO(), true, true );
   }
   myIsBusy = false;
 }
@@ -1096,12 +1093,27 @@ void SMESHGUI_GroupDlg::onAdd()
 
   SMESH::ElementType aType = SMESH::ALL;
   switch(myTypeId) {
-  case 0: aType = SMESH::NODE; break;
-  case 1: aType = SMESH::EDGE; break;
-  case 2: aType = SMESH::FACE; break;
-  case 3: aType = SMESH::VOLUME; break;
+  case 0: 
+    aType = SMESH::NODE; 
+    mySelector->SetSelectionMode(NodeSelection);
+    break;
+  case 1: 
+    aType = SMESH::EDGE; 
+    mySelector->SetSelectionMode(EdgeSelection);
+    break;
+  case 2: 
+    aType = SMESH::FACE; 
+    mySelector->SetSelectionMode(FaceSelection);
+    break;
+  case 3: 
+    aType = SMESH::VOLUME; 
+    mySelector->SetSelectionMode(VolumeSelection);
+    break;
+  default:
+    mySelector->SetSelectionMode(ActorSelection);
   }
 
+
   if (myCurrentLineEdit == 0) {
     //if (aNbSel != 1) { myIsBusy = false; return; }
     QString aListStr = "";
index 676c37c..6926df4 100644 (file)
@@ -27,6 +27,16 @@ SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
 {
 }
 
+void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
+                                                QWidget* parent)
+{
+  MESSAGE( "Creation of hypothesis with initial params" );
+
+  if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
+    myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
+  create( false, parent );
+}
+
 void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
 {
   MESSAGE( "Creation of hypothesis" );
@@ -94,6 +104,7 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
 
   bool res = true;
   myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
+
   QFrame* fr = buildFrame();
   if( fr )
   {
@@ -105,12 +116,18 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
     dlg->setType( type() );
     retrieveParams();
     res = dlg->exec()==QDialog::Accepted;
-    if( res )
-      storeParams();
+    if( res ) {
+      QString paramValues = storeParams();
+      if ( !paramValues.isEmpty() ) {
+        if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
+          SMESH::SetValue( SHyp, paramValues );
+      }
+    }
     delete dlg;
   }
   changeWidgets().clear();
   myHypo = SMESH::SMESH_Hypothesis::_nil();
+  myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
   return res;
 }
 
@@ -144,37 +161,38 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
     QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
     GroupC1Layout->addWidget( lab, i, 0 );
 
-    QWidget* w = 0;
-    switch( (*anIt).myValue.type() )
-    {
-    case QVariant::Int:
-      {
-       QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( sb, i );
-       sb->setValue( (*anIt).myValue.toInt() );
-       connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
-       w = sb;
-      }
-      break;
-    case QVariant::Double:
-      {
-       QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( sb, i );
-       sb->setValue( (*anIt).myValue.toDouble() );
-       connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
-       w = sb;
-      }
-      break;
-    case QVariant::String:
+    QWidget* w = getCustomWidget( *anIt, GroupC1 );
+    if ( !w ) 
+      switch( (*anIt).myValue.type() )
       {
-       QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( le, i );
-       le->setText( (*anIt).myValue.toString() );
-       connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
-       w = le;
+      case QVariant::Int:
+        {
+          QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toInt() );
+          connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::Double:
+        {
+          QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toDouble() );
+          connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::String:
+        {
+          QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( le, i );
+          le->setText( (*anIt).myValue.toString() );
+          connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+          w = le;
+        }
+        break;
       }
-      break;
-    }
 
     if( w )
     {
@@ -224,17 +242,56 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
       params.append( item );
     }
 
-    else 
+    else if ( getParamFromCustomWidget( item, *anIt ))
+    {
+      params.append( item );
+    }
+
+    else
       res = false;
   }
   return res;
 }
 
+QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
+{
+  QString valueStr = "";
+  ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
+  for( int i=0; param!=aLast; param++, i++ )
+  {
+    if ( i > 0 )
+      valueStr += "; ";
+    switch( (*param).myValue.type() )
+    {
+    case QVariant::Int:
+      valueStr += valueStr.number( (*param).myValue.toInt() );
+      break;
+    case QVariant::Double:
+      valueStr += valueStr.number( (*param).myValue.toDouble() );
+      break;
+    case QVariant::String:
+      valueStr += (*param).myValue.toString();
+      break;
+    default:
+      QVariant valCopy = (*param).myValue;
+      valueStr += valCopy.asString();
+    }
+  }
+  return valueStr;
+}
+
 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
 {
   return myHypo;
 }
 
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
+{
+  if ( CORBA::is_nil( myInitParamsHypo ))
+    return myHypo;
+  return myInitParamsHypo;
+}
+
 QString SMESHGUI_GenericHypothesisCreator::hypType() const
 {
   return myHypType;
@@ -273,10 +330,15 @@ QString SMESHGUI_GenericHypothesisCreator::type() const
 {
   return QString();
 }
-
-
-
-
+QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
+                                                             QWidget*   /*parent*/) const
+{
+  return 0;
+}
+bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QWidget* ) const
+{
+  return false;
+}
 
 
 
index a4558df..d47422a 100644 (file)
@@ -50,6 +50,7 @@ public:
 
           void create( const bool isAlgo, QWidget* );
           void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+          void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
   virtual bool checkParams() const = 0;
 
   QString                     hypType() const;
@@ -67,16 +68,20 @@ protected:
   typedef QPtrList<QWidget>      ListOfWidgets;
 
   SMESH::SMESH_Hypothesis_var hypothesis() const;
+  SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
   const ListOfWidgets&        widgets() const;
   ListOfWidgets&              changeWidgets();
 
   virtual QFrame*  buildFrame    () = 0;
           QFrame*  buildStdFrame ();
   virtual void     retrieveParams() const = 0;
-  virtual void     storeParams   () const = 0;
+  virtual QString  storeParams   () const = 0;
   virtual bool     stdParams     ( ListOfStdParams& ) const;
           bool     getStdParamFromDlg( ListOfStdParams& ) const;
+  static  QString  stdParamValues( const ListOfStdParams& );
   virtual void     attuneStdWidget( QWidget*, const int ) const;
+  virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
+  virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
   virtual QString  caption() const;
   virtual QPixmap  icon() const;
   virtual QString  type() const;
@@ -88,7 +93,7 @@ private:
           bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
 
 private:
-  SMESH::SMESH_Hypothesis_var  myHypo;
+  SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
   QString                      myHypType;
   ListOfWidgets                myParamWidgets;
   bool                         myIsCreate;
index 6d9e88e..a9dbbca 100644 (file)
@@ -371,6 +371,7 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh
   createObject( tr( "MESH" ), aGrp, Mesh );
   // geometry
   createObject( tr( "GEOMETRY" ), aGrp, Geom );
+  myGeomPopup = 0;
   
   // Create tab widget
   
@@ -520,3 +521,40 @@ void SMESHGUI_MeshDlg::onHypoSetButton()
 {
   myHypoSetPopup->exec( QCursor::pos() );
 }
+
+//================================================================================
+/*!
+ * \brief Enable showing of the popup when Geometry selection btn is clicked
+  * \param enable - true to enable
+ */
+//================================================================================
+
+enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
+
+void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
+{
+  if ( QButton* selBtn = dynamic_cast<QButton*>( objectWg( Geom, Btn )))
+  {
+    disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+    if ( enable ) {
+      if ( ! myGeomPopup ) {
+        myGeomPopup = new QPopupMenu();
+        myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
+        myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
+        connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
+      }
+      connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+    }
+  }
+}
+
+void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
+{
+  if ( myGeomPopup && isBtnOn )
+    myGeomPopup->exec( QCursor::pos() );
+}
+
+void SMESHGUI_MeshDlg::onGeomPopup( int index )
+{
+  emit geomSelectionByMesh( index == GEOM_BY_MESH_INDEX );
+}
index f83b77c..f12773b 100644 (file)
@@ -71,21 +71,26 @@ public:
   void                         setCurrentTab( const int );
   void                         setMaxHypoDim( const int );
   void                         setHypoSets( const QStringList& );
+  void                         setGeomPopupEnabled( const bool );
 
 signals:
 
   void                         hypoSet( const QString& );
+  void                         geomSelectionByMesh( bool );
 
 private slots:  
 
   void                         onHypoSetPopup( int );
   void                         onHypoSetButton();
+  void                         onGeomPopup( int );
+  void                         onGeomSelectionButton( bool );
 
 private:
 
   QMap< int, SMESHGUI_MeshTab* > myTabs;
   QTabWidget*                    myTabWg;
   QPopupMenu*                    myHypoSetPopup;
+  QPopupMenu*                    myGeomPopup;
 };
 
 /*!
index 7904ea3..1bf664d 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "SMESHGUI_MeshOp.h"
 #include "SMESHGUI_MeshDlg.h"
+#include "SMESHGUI_ShapeByMeshDlg.h"
 #include "SMESH_TypeFilter.hxx"
 #include "SMESHGUI.h"
 
 #include "SMESHGUI_Hypotheses.h"
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_VTKUtils.h"
 
 #include "SMESH_TypeFilter.hxx"
 #include "SMESH_NumberFilter.hxx"
 
 #include "GEOM_SelectionFilter.h"
+#include "GEOMBase.h"
+#include "GeometryGUI.h"
 
 #include "SalomeApp_Tools.h"
 #include "SALOMEDSClient_Study.hxx"
 #include "SALOMEDS_SComponent.hxx"
 #include "SALOMEDS_SObject.hxx"
 
-
 #include "LightApp_SelectionMgr.h"
 #include "LightApp_UpdateFlags.h"
 #include "SUIT_MessageBox.h"
 #include "SUIT_Desktop.h"
 #include "SUIT_OverrideCursor.h"
-
-#include "GEOMBase.h"
+#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_ListIO.hxx"
 
 #include "utilities.h"
 
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
 
+enum { GLOBAL_ALGO_TAG        =3,
+       GLOBAL_HYPO_TAG        =2,
+       LOCAL_ALGO_TAG         =2,
+       LOCAL_HYPO_TAG         =1,
+       SUBMESH_ON_EDGE_TAG    =5,
+       SUBMESH_ON_WIRE_TAG    =6,
+       SUBMESH_ON_FACE_TAG    =7,
+       SUBMESH_ON_SHELL_TAG   =8,
+       SUBMESH_ON_SOLID_TAG   =9,
+       SUBMESH_ON_COMPOUND_TAG=10 };
+       
 //================================================================================
 /*!
  * \brief Constructor
@@ -81,8 +95,11 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
 : SMESHGUI_SelectionOp(),
   myToCreate( theToCreate ),
   myIsMesh( theIsMesh ),
-  myDlg( 0 )
+  myDlg( 0 ),
+  myShapeByMeshDlg( 0 )
 {
+  if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
+    GeometryGUI::InitGeomGen();
 }
 
 //================================================================================
@@ -92,7 +109,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
 //================================================================================
 SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
 {
-  if( myDlg )
+  if ( myDlg )
     delete myDlg;
 }
 
@@ -190,6 +207,7 @@ void SMESHGUI_MeshOp::startOperation()
               this, SLOT( onEditHyp( const int, const int) ) );
     }
     connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
+    connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
   }
   SMESHGUI_SelectionOp::startOperation();
 
@@ -255,6 +273,105 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
 
 //================================================================================
 /*!
+ * \brief check if selected shape is a subshape of the shape to mesh
+  * \retval bool - check result
+ */
+//================================================================================
+
+bool SMESHGUI_MeshOp::isSubshapeOk() const
+{
+  if ( !myToCreate || myIsMesh ) // not submesh creation
+    return false;
+
+  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+  QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+  _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
+  _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
+  if ( pMesh && pGeom ) {
+    SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+    if ( !mesh->_is_nil() ) {
+      GEOM::GEOM_Object_var mainGeom, subGeom;
+      mainGeom = mesh->GetShapeToMesh();
+      subGeom  = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
+      if ( !mainGeom->_is_nil() && !subGeom->_is_nil() ) {
+        TopoDS_Shape mainShape, subShape;
+        if ( GEOMBase::GetShape( mainGeom, mainShape ) &&
+             GEOMBase::GetShape( subGeom, subShape ) )
+        {
+          int index = GEOMBase::GetIndex( subShape, mainShape, 0 );
+          if ( index > 0 ) {
+            // 1 is index of mainShape itself
+            return index > 1; // it is a subshape
+          }
+          // is it a group?
+          GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+          _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+          if ( !geomGen->_is_nil() && aStudy ) {
+            GEOM::GEOM_IGroupOperations_var op =
+              geomGen->GetIGroupOperations( aStudy->StudyId() );
+            if ( ! op->_is_nil() ) {
+              GEOM::GEOM_Object_var mainObj = op->GetMainShape( subGeom );
+              if ( !mainObj->_is_nil() )
+                return ( string( mainObj->GetEntry() ) == string( mainGeom->GetEntry() ));
+            }
+          }
+        }
+      }
+    }
+  }
+  return false;
+}
+
+//================================================================================
+/*!
+ * \brief find an existing submesh by the selected shape
+  * \retval _PTR(SObject) - the found submesh SObject
+ */
+//================================================================================
+
+_PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
+{
+  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+  QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+  _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
+  _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
+  if ( pMesh && pGeom ) {
+    GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
+    if ( !geom->_is_nil() ) {
+      int tag = -1;
+      switch ( geom->GetShapeType() ) {
+      case GEOM::EDGE:     tag = SUBMESH_ON_EDGE_TAG    ; break;
+      case GEOM::WIRE:     tag = SUBMESH_ON_WIRE_TAG    ; break;
+      case GEOM::FACE:     tag = SUBMESH_ON_FACE_TAG    ; break;
+      case GEOM::SHELL:    tag = SUBMESH_ON_SHELL_TAG   ; break;
+      case GEOM::SOLID:    tag = SUBMESH_ON_SOLID_TAG   ; break;
+      case GEOM::COMPOUND: tag = SUBMESH_ON_COMPOUND_TAG; break;
+      default:;
+      }
+      _PTR(SObject) aSubmeshRoot;
+      _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+      if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
+      {
+        _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
+        for (; smIter->More(); smIter->Next() )
+        {
+          _PTR(SObject) aSmObj = smIter->Value();
+          _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
+          for (; anIter1->More(); anIter1->Next()) {
+            _PTR(SObject) pGeom2 = anIter1->Value();
+            if ( pGeom2->ReferencedObject( pGeom2 ) &&
+                 pGeom2->GetID() == pGeom->GetID() )
+              return aSmObj;
+          }
+        }
+      }
+    }     
+  }
+  return _PTR(SObject)();
+}
+
+//================================================================================
+/*!
  * \brief Updates dialog's look and feel
  *
  * Virtual method redefined from the base class updates dialog's look and feel
@@ -262,41 +379,17 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
 //================================================================================
 void SMESHGUI_MeshOp::selectionDone()
 {
+  if ( myShapeByMeshDlg && myShapeByMeshDlg->isShown() )
+    return;
+
   SMESHGUI_SelectionOp::selectionDone();
 
-  if ( !myToCreate )
+  try
   {
-    try
-    {
-      QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
-      _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
-      if ( pObj != 0 )
-      {
-        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();
-    }
-    catch ( const SALOME::SALOME_Exception& S_ex )
-    {
-      SalomeApp_Tools::QtCatchCorbaException( S_ex );
-    }
-    catch ( ... )
-    {
-    }
-  }
+    // Enable tabs according to shape dimension
 
-  // Enable tabs according to shape dimension
+    int shapeDim = 3;
 
-  int shapeDim = 3;
-  try
-  {
     GEOM::GEOM_Object_var aGeomVar;
     QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
     _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
@@ -332,6 +425,61 @@ void SMESHGUI_MeshOp::selectionDone()
         }
       }
     }
+    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 )
+      {
+        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 )
+        {
+          selectionMgr()->clearFilters();
+          selectObject( pSubmesh );
+          SMESHGUI::GetSMESHGUI()->switchToOperation(704);
+          return;
+        }
+        else
+        {
+          selectObject( _PTR(SObject)() );
+          myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
+        }
+      }
+
+      // 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 );
+    }
   }
   catch ( const SALOME::SALOME_Exception& S_ex )
   {
@@ -340,7 +488,6 @@ void SMESHGUI_MeshOp::selectionDone()
   catch ( ... )
   {
   }
-  myDlg->setMaxHypoDim( shapeDim );
 }
 
 //================================================================================
@@ -371,6 +518,20 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
     return false;
   }
 
+  // Imported mesh, if create sub-mesh or edit mesh
+  if ( !myToCreate || ( myToCreate && !myIsMesh ))
+  {
+    QString aMeshEntry = myDlg->selectedObject
+      ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
+    if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+      SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+      if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
+        theMess = tr( "IMPORTED_MESH" );
+        return false;
+      }
+    }
+  }
+
   // Geom
   if ( myToCreate )
   {
@@ -402,8 +563,14 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
         theMess = tr( "MESH_IS_NULL" );
         return false;
       }
+      if ( !isSubshapeOk() )
+      {
+        theMess = tr( "INVALID_SUBSHAPE" );
+        return false;
+      }
     }
   }
+    
   return true;
 }
 
@@ -468,9 +635,9 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
   bool isMesh = !_CAST( SComponent, theFather );
   int aPart = -1;
   if ( isMesh )
-    aPart = theHypType == Algo ? 3 : 2;
+    aPart = theHypType == Algo ? GLOBAL_ALGO_TAG : GLOBAL_HYPO_TAG;
   else
-    aPart = theHypType == Algo ? 2 : 1;
+    aPart = theHypType == Algo ? LOCAL_ALGO_TAG : LOCAL_HYPO_TAG;
 
   if ( theFather->FindSubObject( aPart, aHypRoot ) )
   {
@@ -513,6 +680,66 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
 
 //================================================================================
 /*!
+ * \brief If create or edit a submesh, return a hypothesis holding parameters used
+ *        to mesh a subshape
+  * \param aHypType - The hypothesis type name
+  * \param aServerLib - Server library name
+  * \param hypData - The structure holding the hypothesis type etc.
+  * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_var
+SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
+                                          const QString& aServerLib ) const
+{
+  if ( aHypType.isEmpty() || aServerLib.isEmpty() )
+    return SMESH::SMESH_Hypothesis::_nil();
+
+  const int nbColonsInMeshEntry = 3;
+  bool isSubMesh = myToCreate ?
+    !myIsMesh :
+    myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry; 
+
+  if ( isSubMesh )
+  {
+    // get mesh and geom object
+    SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
+    GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
+
+    QString anEntry = myDlg->selectedObject
+      ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
+    if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.latin1() ))
+    {
+      CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
+      if ( myToCreate ) // mesh and geom may be selected
+      {
+        aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
+        anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+        if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.latin1() ))
+          aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
+      }
+      else // edition: sub-mesh may be selected
+      {
+        SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
+        if ( !sm->_is_nil() ) {
+          aMeshVar = sm->GetFather();
+          aGeomVar = sm->GetSubShape();
+        }
+      }
+    }
+
+    if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
+      return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType,
+                                                                    aServerLib,
+                                                                    aMeshVar,
+                                                                    aGeomVar );
+  }
+  return SMESH::SMESH_Hypothesis::_nil();
+}
+
+//================================================================================
+/*!
  * \brief Calls plugin methods for hypothesis creation
   * \param theHypType - specifies whether main hypotheses or additional ones
   * are created
@@ -560,8 +787,22 @@ void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
     SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHypTypeName );
 
     // Create hypothesis
-    if( aCreator )
-      aCreator->create( false, myDlg );
+    if ( aCreator )
+    {
+      // When create or edit a submesh, try to initialize a new hypothesis
+      // with values used to mesh a subshape
+      SMESH::SMESH_Hypothesis_var initParamHyp =
+        getInitParamsHypothesis( aHypTypeName, aData->ServerLibName );
+
+      if ( initParamHyp->_is_nil() )
+        aCreator->create( false, myDlg );
+      else
+        aCreator->create( initParamHyp, myDlg );
+    }
+    else
+    {
+      SMESH::CreateHypothesis( aHypTypeName, aData->Label, false );
+    }
   }
 
   QStringList aNewHyps;
@@ -650,18 +891,18 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
       {
         // try to find an existing hypo
         QValueList<SMESH::SMESH_Hypothesis_var> & aList = myExistingHyps[ aDim ][ aHypType ];
-        int iHyp = 0, nbHyp = aList.count();
-        for ( ; iHyp < nbHyp; ++iHyp )
-        {
-          SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
-          if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
-            index = iHyp;
-            break;
-          }
-        }
+        int /*iHyp = 0,*/ nbHyp = aList.count();
+//         for ( ; iHyp < nbHyp; ++iHyp )
+//         {
+//           SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
+//           if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
+//             index = iHyp;
+//             break;
+//           }
+//         }
         if ( index >= 0 ) // found
         {
-          // select an algorithm
+          // select the found hypothesis
           setCurrentHyp ( aDim, aHypType, index );
         }
         else
@@ -676,7 +917,18 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
             // Get hypotheses creator client (GUI)
             SMESHGUI_GenericHypothesisCreator* aCreator =
               SMESH::GetHypothesisCreator( aHypoTypeName );
-            aCreator->create( false, myDlg );
+            if ( aCreator )
+            {
+              // When create or edit a submesh, try to initialize a new hypothesis
+              // with values used to mesh a subshape
+              SMESH::SMESH_Hypothesis_var initParamHyp =
+                getInitParamsHypothesis( aHypoTypeName, aHypData->ServerLibName );
+              aCreator->create( initParamHyp, myDlg );
+            }
+            else
+            {
+              SMESH::CreateHypothesis( aHypoTypeName, aHypData->Label, isAlgo );
+            }
           }
           QStringList aNewHyps;
           _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
@@ -1203,3 +1455,103 @@ bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
 {
   return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
 }
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when the user selects a way of geometry selection
+  * \param theByMesh - true if the user wants to find geometry by mesh element
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
+{
+  if ( theByMesh ) {
+    if ( !myShapeByMeshDlg ) {
+      myShapeByMeshDlg = new SMESHGUI_ShapeByMeshDlg( SMESHGUI::GetSMESHGUI(), "ShapeByMeshDlg");
+      connect(myShapeByMeshDlg, SIGNAL(PublishShape()), SLOT(onPublishShapeByMeshDlg()));
+      connect(myShapeByMeshDlg, SIGNAL(Close()), SLOT(onCloseShapeByMeshDlg()));
+    }
+    // set mesh object to dlg
+    QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+    if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+      SMESH::SMESH_Mesh_var aMeshVar =
+        SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
+      if ( !aMeshVar->_is_nil() ) {
+        myDlg->hide();
+        myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
+        myShapeByMeshDlg->Init();
+        myShapeByMeshDlg->SetMesh( aMeshVar );
+        myShapeByMeshDlg->show();
+      }
+    }
+  }
+}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onPublishShapeByMeshDlg()
+{
+  if ( myShapeByMeshDlg ) {
+    // Select a found geometry object
+    GEOM::GEOM_Object_var aGeomVar = myShapeByMeshDlg->GetShape();
+    if ( !aGeomVar->_is_nil() )
+    {
+      QString ID = aGeomVar->GetStudyEntry();
+      if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID )) {
+        SMESH::SMESH_Mesh_ptr aMeshPtr = myShapeByMeshDlg->GetMesh();
+        if ( !CORBA::is_nil( aMeshPtr )) {
+          if (_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshPtr )) {
+            myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
+            myDlg->selectObject( aMeshSO->GetName(), SMESHGUI_MeshDlg::Mesh, aMeshSO->GetID() );
+          }
+        }
+        myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+        selectObject( aGeomSO );
+        //selectionDone();
+      }
+    }
+    else {
+      onCloseShapeByMeshDlg();
+    }
+  }
+  myDlg->show();
+}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onCloseShapeByMeshDlg()
+{
+  if ( myDlg ) {
+    myDlg->show();
+    myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+    myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Selects a SObject
+  * \param theSObj - the SObject to select
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
+{
+  if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
+    SALOME_ListIO anIOList;
+    if ( theSObj ) {
+      Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
+        ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
+      anIOList.Append( anIO );
+    }
+    sm->setSelectedObjects( anIOList, false );
+  }
+}
index 5041fce..677731a 100644 (file)
@@ -40,9 +40,7 @@
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 class SMESHGUI_MeshDlg;
-class SMESH_TypeFilter;
-class SMESH_NumberFilter;
-
+class SMESHGUI_ShapeByMeshDlg;
 
 /*!
  * \brief Operation for mech creation or editing
@@ -72,6 +70,9 @@ protected slots:
   void                           onCreateHyp( const int theHypType, const int theIndex );
   void                           onEditHyp( const int theHypType, const int theIndex );
   void                           onHypoSet( const QString& theSetName );
+  void                           onGeomSelectionByMesh( bool );
+  void                           onPublishShapeByMeshDlg();
+  void                           onCloseShapeByMeshDlg();
 
 private:
   bool                           isValid( QString& ) const;
@@ -97,12 +98,18 @@ private:
   QString                        name( _PTR(SObject) ) const;
   int                            find( const SMESH::SMESH_Hypothesis_var&,
                                        const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
+  SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
+                                                          const QString& aServerLib ) const;
+  bool                           isSubshapeOk() const;
+  _PTR(SObject)                  getSubmeshByGeom() const;
+  void                           selectObject( _PTR(SObject) ) const;
 
 private:
   typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
   typedef QMap< int, IdToHypListMap > DimToHypMap;
   
   SMESHGUI_MeshDlg*              myDlg;
+  SMESHGUI_ShapeByMeshDlg*       myShapeByMeshDlg;
   bool                           myToCreate;
   bool                           myIsMesh;
   
index 205b5b3..c7ceb4b 100755 (executable)
@@ -91,6 +91,7 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
 
 #define SPACING 5
 #define MARGIN  10
index 1cb0413..1f8dbe5 100644 (file)
@@ -63,6 +63,7 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
 
 // QT includes
 #include <qgroupbox.h>
index 6a70e8d..74ad155 100755 (executable)
@@ -51,7 +51,6 @@
 #include "SVTK_Selector.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
-#include "SVTK_InteractorStyle.h"
 
 // OCCT Includes
 #include <Precision.hxx>
@@ -71,6 +70,7 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
 
 // QT Includes
 #include <qframe.h>
@@ -504,8 +504,8 @@ void SMESHGUI_MultiEditDlg::onSelectionDone()
     myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
     if (!myActor)
       myActor = SMESH::FindActorByObject(myMesh);
-    SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle();
-    Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter(myFilterType);
+    SVTK_Selector* aSelector = SMESH::GetSelector();
+    Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
     if (!aFilter.IsNull())
       aFilter->SetActor(myActor);
   }
@@ -605,9 +605,9 @@ void SMESHGUI_MultiEditDlg::onFilterAccepted()
 //=======================================================================
 bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
 {
-  SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle();
+  SVTK_Selector* aSelector = SMESH::GetSelector();
   Handle(SMESHGUI_Filter) aFilter =
-    Handle(SMESHGUI_Filter)::DownCast(aStyle->GetFilter(myFilterType));
+    Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
 
   return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
 }
index 55b31e5..0e29413 100644 (file)
@@ -69,6 +69,7 @@
 #include <vtkDataSetMapper.h>
 #include <vtkActorCollection.h>
 #include <vtkRenderer.h>
+#include <vtkProperty.h>
 
 // QT Includes
 #include <qbuttongroup.h>
index 8bd1824..ef6dfa0 100644 (file)
@@ -45,6 +45,7 @@
 #include "SVTK_ViewWindow.h"
 #include "SALOME_ListIO.hxx"
 
+#include "SalomeApp_Tools.h"
 #include "utilities.h"
 
 // OCCT Includes
@@ -257,11 +258,16 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply()
     try {
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
       aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout());
-    } catch (...) {
+    } catch (const SALOME::SALOME_Exception& S_ex) {
+      SalomeApp_Tools::QtCatchCorbaException(S_ex);
+      myEditCurrentArgument->clear();
+    } catch (...){
+      myEditCurrentArgument->clear();
     }
 
     if (aResult) {
       myEditCurrentArgument->clear();
+      mySelector->ClearIndex();
       SMESH::UpdateView();
     }
   }
index be9e9e3..775bff0 100644 (file)
@@ -265,6 +265,7 @@ void SMESHGUI_RemoveNodesDlg::ClickOnApply()
 
     if (aResult) {
       myEditCurrentArgument->clear();
+      mySelector->ClearIndex();
       SMESH::UpdateView();
     }
 
index 927ac7f..88d44c5 100644 (file)
@@ -327,8 +327,8 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
     QString ent = entry( ind );
     SMESH_Actor* actor = SMESH::FindActorByEntry( ent.latin1() );
     if ( actor && actor->hasIO() ) {
-      SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
-      return QVariant( renderInter->isVisible( actor->getIO() ), 0 );
+      if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView())
+       return QVariant( aViewWindow->isVisible( actor->getIO() ), 0 );
     }
   }
   return QVariant( false, 0 );
diff --git a/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx
new file mode 100644 (file)
index 0000000..d437ee1
--- /dev/null
@@ -0,0 +1,490 @@
+//  SMESH SMESHGUI : GUI for SMESH component
+//
+//  Copyright (C) 2003  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.
+//
+//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SMESHGUI_ShapeByMeshDlg.cxx
+//  Author : Edward AGAPOV
+//  Module : SMESH
+
+#include "SMESHGUI_ShapeByMeshDlg.h"
+
+#include "SMESHGUI.h"
+#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+
+#include "SMDS_Mesh.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMESH_Actor.h"
+
+#include "GEOMBase.h"
+#include "GeometryGUI.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_SelectionMgr.h"
+#include "SALOMEDSClient_SObject.hxx"
+#include "SALOME_ListIO.hxx"
+#include "SUIT_Desktop.h"
+#include "SVTK_Selector.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SalomeApp_Tools.h"
+
+// OCCT Includes
+#include <TColStd_MapOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopExp_Explorer.hxx>
+
+// QT Includes
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qapplication.h>
+#include <qstringlist.h>
+
+#define SPACING 5
+#define MARGIN  10
+
+enum { EDGE = 0, FACE, VOLUME };
+
+/*!
+ * \brief Dialog to publish a sub-shape of the mesh main shape
+ *        by selecting mesh elements
+ */
+SMESHGUI_ShapeByMeshDlg::SMESHGUI_ShapeByMeshDlg( SMESHGUI*   theModule,
+                                                  const char* theName)
+     : QDialog( SMESH::GetDesktop( theModule ), theName, false,
+                WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+     mySMESHGUI( theModule ),
+     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+{
+  setCaption(tr("CAPTION"));
+
+  QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
+
+  QFrame* aMainFrame = createMainFrame  (this);
+  QFrame* aBtnFrame  = createButtonFrame(this);
+
+  aDlgLay->addWidget(aMainFrame);
+  aDlgLay->addWidget(aBtnFrame);
+
+  aDlgLay->setStretchFactor(aMainFrame, 1);
+
+  myViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+
+  Init();
+}
+
+//=======================================================================
+// function : createMainFrame()
+// purpose  : Create frame containing dialog's input fields
+//=======================================================================
+QFrame* SMESHGUI_ShapeByMeshDlg::createMainFrame (QWidget* theParent)
+{
+  QFrame* aMainGrp = new QFrame(theParent, "main frame");
+  QGridLayout* aLayout = new QGridLayout(aMainGrp, 3, 2);
+  aLayout->setSpacing(6);
+  aLayout->setAutoAdd(false);
+
+  // elem type
+  myElemTypeGroup = new QButtonGroup(1, Qt::Vertical, aMainGrp, "Group types");
+  myElemTypeGroup->setTitle(tr("SMESH_ELEMENT_TYPE"));
+  myElemTypeGroup->setExclusive(true);
+
+  (new QRadioButton( tr("SMESH_EDGE")  , myElemTypeGroup))->setChecked(true);
+  new QRadioButton( tr("SMESH_FACE")  , myElemTypeGroup);
+  new QRadioButton( tr("SMESH_VOLUME"), myElemTypeGroup);
+
+  // element id
+  QLabel* anIdLabel = new QLabel( aMainGrp, "element id label");
+  anIdLabel->setText( tr("ELEMENT_ID") );
+  myElementId = new QLineEdit( aMainGrp, "element id");
+  myElementId->setValidator( new SMESHGUI_IdValidator( theParent, "id validator", 1 ));
+
+  // shape name
+  QLabel* aNameLabel = new QLabel( aMainGrp, "geom name label");
+  aNameLabel->setText( tr("GEOMETRY_NAME") );
+  myGeomName = new QLineEdit( aMainGrp, "geom name");
+
+  aLayout->addMultiCellWidget(myElemTypeGroup, 0, 0, 0, 1);
+  aLayout->addWidget(anIdLabel,   1, 0);
+  aLayout->addWidget(myElementId, 1, 1);
+  aLayout->addWidget(aNameLabel,  2, 0);
+  aLayout->addWidget(myGeomName,  2, 1);
+
+  connect(myElemTypeGroup, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
+  connect(myElementId, SIGNAL(textChanged(const QString&)), SLOT(onElemIdChanged(const QString&)));
+
+  return aMainGrp;
+}
+
+//=======================================================================
+// function : createButtonFrame()
+// purpose  : Create frame containing buttons
+//=======================================================================
+QFrame* SMESHGUI_ShapeByMeshDlg::createButtonFrame (QWidget* theParent)
+{
+  QFrame* aFrame = new QFrame(theParent);
+  aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
+
+  myOkBtn    = new QPushButton(tr("SMESH_BUT_OK"   ), aFrame);
+  myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
+
+  QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+  QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
+
+  aLay->addWidget(myOkBtn);
+  aLay->addItem(aSpacer);
+  aLay->addWidget(myCloseBtn);
+
+  connect(myOkBtn,    SIGNAL(clicked()), SLOT(onOk()));
+  connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
+
+  return aFrame;
+}
+
+//=======================================================================
+// function : ~SMESHGUI_ShapeByMeshDlg()
+// purpose  : Destructor
+//=======================================================================
+SMESHGUI_ShapeByMeshDlg::~SMESHGUI_ShapeByMeshDlg()
+{
+  // no need to delete child widgets, Qt does it all for us
+}
+
+//=======================================================================
+// function : Init()
+// purpose  : Init dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::Init()
+{
+  SetMesh( SMESH::SMESH_Mesh::_nil() );
+  myIsManualIdEnter = false;
+
+  //erasePreview();
+
+  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+  // selection and SMESHGUI
+  connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
+  connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
+
+  setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+  qApp->processEvents();
+  updateGeometry();
+  adjustSize();
+  resize(minimumSize());
+
+  activateSelection();
+  onSelectionDone();
+
+  int x, y;
+  mySMESHGUI->DefineDlgPosition(this, x, y);
+  this->move(x, y);
+  this->show();
+}
+
+//=======================================================================
+// function : SetMesh()
+// purpose  : Set mesh to dialog
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
+{
+  myMesh    = SMESH::SMESH_Mesh::_duplicate(thePtr);
+  myGeomObj = GEOM::GEOM_Object::_nil();
+  myHasSolids = false;
+
+  vector< bool > hasElement (myElemTypeGroup->count(), false);
+  if (!myMesh->_is_nil() && myViewWindow )
+  {
+    _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
+    SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
+
+    vector< int > nbShapes( TopAbs_SHAPE, 0 );
+    int shapeDim = 0; // max dim with several shapes
+    if ( mySelectionMgr->isOk(anIObj) ) // check that the mesh has a valid shape
+    {
+      _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
+      GEOM::GEOM_Object_var mainShape = SMESH::GetGeom(aSO);
+      if ( !mainShape->_is_nil() ) 
+      {
+        if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
+          GeometryGUI::InitGeomGen();
+        TopoDS_Shape aShape;
+        if ( GEOMBase::GetShape(mainShape, aShape))
+        {
+          TopAbs_ShapeEnum types[4] = { TopAbs_EDGE, TopAbs_FACE, TopAbs_SHELL, TopAbs_SOLID };
+          for ( int dim = 4; dim > 0; --dim ) {
+            TopAbs_ShapeEnum type = types[ dim - 1 ];
+            TopAbs_ShapeEnum avoid = ( type == TopAbs_SHELL ) ? TopAbs_SOLID : TopAbs_SHAPE;
+            TopExp_Explorer exp( aShape, type, avoid );
+            for ( ; nbShapes[ type ] < 2 && exp.More(); exp.Next() )
+              ++nbShapes[ type ];
+            if ( nbShapes[ type ] > 1 ) {
+              shapeDim = dim;
+              break;
+            }
+          }
+        }
+      }
+    }
+    if (shapeDim > 0)
+    {
+      if ( nbShapes[ TopAbs_SHELL ] + nbShapes[ TopAbs_SOLID ] > 1 )
+        shapeDim = 3;
+      hasElement[ EDGE ]   = shapeDim > 0 && myMesh->NbEdges()  ;
+      hasElement[ FACE ]   = shapeDim > 1 && myMesh->NbFaces()  ;
+      hasElement[ VOLUME ] = shapeDim > 2 && myMesh->NbVolumes();
+
+      if ( hasElement[ EDGE ] && myViewWindow->GetSelector() )
+      {
+        connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+      }
+    }
+    myHasSolids = nbShapes[ TopAbs_SOLID ];
+  }
+
+  // disable inexistant elem types
+  for ( int i = 0; i < myElemTypeGroup->count(); ++i ) {
+    if ( QButton* button = myElemTypeGroup->find( i ) )
+      button->setEnabled( hasElement[ i ] );
+  }
+  myElementId->setEnabled( hasElement[ EDGE ] );
+  myGeomName-> setEnabled( hasElement[ EDGE ] );
+
+  setElementID("");
+}
+
+//=======================================================================
+// function : GetShape()
+// purpose  : Get published sub-shape
+//=======================================================================
+GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshDlg::GetShape()
+{
+  return myGeomObj.in();
+}
+
+//=======================================================================
+// function : onOk()
+// purpose  : SLOT called when "Ok" button pressed.
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onOk()
+{
+  try {
+    int elemID = myElementId->text().toInt();
+    myGeomObj = SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
+      ( myMesh.in(), elemID, myGeomName->text().latin1());
+
+    accept();
+    emit PublishShape();
+  }
+  catch (const SALOME::SALOME_Exception& S_ex) {
+    SalomeApp_Tools::QtCatchCorbaException(S_ex);
+  }
+  catch (...) {
+  }
+  myViewWindow->SetSelectionMode( ActorSelection );
+  disconnect(mySelectionMgr, 0, this, 0);
+  disconnect(mySMESHGUI, 0, this, 0);
+  mySMESHGUI->ResetState();
+}
+
+//=======================================================================
+// function : onClose()
+// purpose  : SLOT called when "Close" button pressed. Close dialog
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onClose()
+{
+  myViewWindow->SetSelectionMode( ActorSelection );
+  disconnect(mySelectionMgr, 0, this, 0);
+  disconnect(mySMESHGUI, 0, this, 0);
+  mySMESHGUI->ResetState();
+  reject();
+  emit Close();
+}
+
+//=======================================================================
+// function : onSelectionDone()
+// purpose  : SLOT called when selection changed
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onSelectionDone()
+{
+  myOkBtn->setEnabled( false );
+  setElementID("");
+
+  try {
+    SALOME_ListIO aList;
+    mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
+    if (aList.Extent() != 1)
+      return;
+
+    SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());
+    if (aMesh->_is_nil() || myMesh->_is_nil() || aMesh->GetId() != myMesh->GetId() )
+      return;
+
+    QString aString;
+    int nbElems = SMESH::GetNameOfSelectedElements(myViewWindow->GetSelector(),
+                                                   aList.First(), aString);
+    if ( nbElems == 1 ) {
+      setElementID( aString );
+      myOkBtn->setEnabled( true );
+    }
+  } catch (...) {
+  }
+}
+
+//=======================================================================
+// function : onDeactivate()
+// purpose  : SLOT called when dialog must be deativated
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onDeactivate()
+{
+  if ( isEnabled() ) {
+    //disconnect(mySelectionMgr, 0, this, 0);
+    myViewWindow->SetSelectionMode( ActorSelection );
+    setEnabled(false);
+  }
+}
+
+//=======================================================================
+// function : enterEvent()
+// purpose  : Event filter
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::enterEvent (QEvent*)
+{
+  // there is a stange problem that enterEvent() comes after onSave()
+  if ( isVisible () && !isEnabled() ) {
+    mySMESHGUI->EmitSignalDeactivateDialog();
+    setEnabled(true);
+    activateSelection();
+    //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+  }
+}
+
+//=================================================================================
+// function : closeEvent()
+// purpose  : Close dialog box
+//=================================================================================
+void SMESHGUI_ShapeByMeshDlg::closeEvent (QCloseEvent*)
+{
+  onClose();
+}
+
+//=======================================================================
+// function : activateSelection()
+// purpose  : Activate selection in accordance with current pattern type
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::activateSelection()
+{
+  mySelectionMgr->clearFilters();
+  SMESH::SetPointRepresentation(false);
+
+  myGeomName->setText("");
+
+  if ( myViewWindow )
+  {
+    QString geomName;
+    Selection_Mode mode = EdgeSelection;
+    switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
+    case EDGE  :
+      mode = EdgeSelection;   geomName = tr("GEOM_EDGE"); break;
+    case FACE  :
+      mode = FaceSelection;   geomName = tr("GEOM_FACE"); break;
+    case VOLUME:
+      mode = VolumeSelection; geomName = tr(myHasSolids ? "GEOM_SOLID" : "GEOM_SHELL"); break;
+    default: return;
+    }
+    if ( myViewWindow->SelectionMode() != mode )
+      myViewWindow->SetSelectionMode( mode );
+
+    myGeomName->setText( GEOMBase::GetDefaultName( geomName ));
+  }
+}
+
+//=======================================================================
+//function : onTypeChanged
+//purpose  : SLOT. Called when element type changed.
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::onTypeChanged (int theType)
+{
+  setElementID("");
+  activateSelection();
+}
+
+//=======================================================================
+//function : onTypeChanged
+//purpose  : SLOT. Called when element id is entered
+//           Highlight the element whose Ids the user entered manually
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::onElemIdChanged(const QString& theNewText)
+{
+  myOkBtn->setEnabled( false );
+
+  if ( myIsManualIdEnter && !myMesh->_is_nil() && myViewWindow )
+    if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) )
+      if ( SMDS_Mesh* aMesh = actor->GetObject()->GetMesh() )
+      {
+        SMDSAbs_ElementType type = SMDSAbs_Edge;
+        switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
+        case EDGE  : type = SMDSAbs_Edge;   break;
+        case FACE  : type = SMDSAbs_Face;   break;
+        case VOLUME: type = SMDSAbs_Volume; break;
+        default: return;
+        }
+        TColStd_MapOfInteger newIndices;
+        QStringList aListId = QStringList::split( " ", theNewText, false);
+        for ( int i = 0; i < aListId.count(); i++ ) {
+          if ( const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ))
+            if ( e->GetType() == type )
+              newIndices.Add( e->GetID() );
+        }
+
+        if ( !newIndices.IsEmpty() && newIndices.Extent() == 1 )
+          if ( SVTK_Selector* s = myViewWindow->GetSelector() ) {
+            s->AddOrRemoveIndex( actor->getIO(), newIndices, false );
+            myViewWindow->highlight( actor->getIO(), true, true );
+            myOkBtn->setEnabled( true );
+          }
+      }
+}
+
+//=======================================================================
+//function : setElementID
+//purpose  : programmatically set element id
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::setElementID(const QString& theText)
+{
+  myIsManualIdEnter = false;
+  myElementId->setText(theText);
+  myIsManualIdEnter = true;
+}
diff --git a/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.h b/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.h
new file mode 100644 (file)
index 0000000..1f1a50c
--- /dev/null
@@ -0,0 +1,115 @@
+//  Copyright (C) 2003  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.
+//
+//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SMESHGUI_ShapeByMeshDlg.h
+//  Author : Edward AGAPOV
+//  Module : SMESH
+
+
+#ifndef SMESHGUI_ShapeByMeshDlg_H
+#define SMESHGUI_ShapeByMeshDlg_H
+
+#include <qdialog.h>
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+class QCloseEvent;
+class QFrame;
+class QLineEdit;
+class QPushButton;
+class LightApp_SelectionMgr;
+class SVTK_ViewWindow;
+class QButtonGroup;
+class SMESHGUI;
+
+/*!
+ * \brief Dialog to publish a sub-shape of the mesh main shape
+ *        by selecting mesh elements
+ */
+
+class SMESHGUI_ShapeByMeshDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+                           SMESHGUI_ShapeByMeshDlg( SMESHGUI*   theModule,
+                                                    const char* theName = 0);
+  virtual                  ~SMESHGUI_ShapeByMeshDlg();
+
+  void                     Init();
+  void                     SetMesh (SMESH::SMESH_Mesh_ptr);
+  SMESH::SMESH_Mesh_ptr    GetMesh () { return myMesh; }
+  GEOM::GEOM_Object_ptr    GetShape();
+
+signals:
+
+  void                     PublishShape();
+  void                     Close();
+
+private:
+
+  void                     closeEvent (QCloseEvent* e);
+  void                     enterEvent (QEvent*);
+
+private slots:
+
+  void                     onOk();
+  void                     onClose();
+
+  void                     onDeactivate();
+
+  void                     onSelectionDone();
+  void                     onTypeChanged (int);
+  void                     onElemIdChanged (const QString&);
+
+private:
+
+  QFrame*                  createButtonFrame (QWidget*);
+  QFrame*                  createMainFrame   (QWidget*);
+  //void                     displayPreview();
+  //void                     erasePreview();
+  void                     activateSelection();
+  void                     setElementID(const QString&);
+
+private:
+
+  QButtonGroup*            myElemTypeGroup;
+  QLineEdit*               myElementId;
+  QLineEdit*               myGeomName;
+
+  QPushButton*             myOkBtn;
+  QPushButton*             myCloseBtn;
+
+  SMESHGUI*                mySMESHGUI;
+  LightApp_SelectionMgr*   mySelectionMgr;
+  SVTK_ViewWindow*         myViewWindow;
+
+  SMESH::SMESH_Mesh_var    myMesh;
+  GEOM::GEOM_Object_var    myGeomObj;
+
+  bool                     myIsManualIdEnter;
+  bool                     myHasSolids;
+};
+
+#endif
index 01cf071..76a8cb1 100644 (file)
@@ -36,9 +36,6 @@
 #include "SVTK_Selector.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_InteractorStyle.h"
-#include "SVTK_RenderWindowInteractor.h"
 
 #include "utilities.h"
 
@@ -448,85 +445,83 @@ namespace SMESH{
     double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
            SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 );
 
-    for ( int i=0, n=views.count(); i<n; i++ ) {
-        SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] );
-       if (!aVtkView) continue;
-       // update VTK viewer properties
-       SVTK_RenderWindowInteractor* anInteractor = aVtkView->getRWInteractor();
-       if (anInteractor) {
-         // mesh element selection
-         anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
-                                        aSelColor.blue()/255., SW );
-
-         // tolerances
-         anInteractor->SetSelectionTolerance(SP1, SP2);
-
-         // pre-selection
-         SVTK_InteractorStyle* aStyle =
-           dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
-         if (aStyle) {
-           aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
-                                       aPreColor.blue()/255., PW);
-         }
-       }
+    for ( int i=0, n=views.count(); i<n; i++ ){
+      // update VTK viewer properties
+      if(SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] )){
+       // mesh element selection
+       aVtkView->SetSelectionProp(aSelColor.red()/255., 
+                                  aSelColor.green()/255.,
+                                  aSelColor.blue()/255., 
+                                  SW );
+       // tolerances
+       aVtkView->SetSelectionTolerance(SP1, SP2);
+
+       // pre-selection
+       aVtkView->SetPreselectionProp(aPreColor.red()/255., 
+                                     aPreColor.green()/255.,
+                                     aPreColor.blue()/255., 
+                                     PW);
        // update actors
        vtkRenderer* aRenderer = aVtkView->getRenderer();
        vtkActorCollection *aCollection = aRenderer->GetActors();
        aCollection->InitTraversal();
        while(vtkActor *anAct = aCollection->GetNextActor()){
          if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
-           anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
+           anActor->SetHighlightColor(aHiColor.red()/255., 
+                                      aHiColor.green()/255.,
                                       aHiColor.blue()/255.);
-           anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
+           anActor->SetPreHighlightColor(aPreColor.red()/255., 
+                                         aPreColor.green()/255.,
                                          aPreColor.blue()/255.);
          }
        }
+      }
     }
   }
 
 
   //----------------------------------------------------------------------------
-  SVTK_InteractorStyle* GetInteractorStyle(SUIT_ViewWindow *theWindow){
-    if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow)){
-      if(SVTK_RenderWindowInteractor* anInteractor = aWnd->getRWInteractor()){
-       return dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
-      }
-    }
+  SVTK_Selector* 
+  GetSelector(SUIT_ViewWindow *theWindow)
+  {
+    if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
+      return aWnd->GetSelector();
+
     return NULL;
   }
 
   void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
-                SVTK_InteractorStyle* theStyle)
+                SVTK_Selector* theSelector)
   {
-    if (theStyle)
-      theStyle->SetFilter(theFilter);
+    if (theSelector)
+      theSelector->SetFilter(theFilter);
   }
 
-  Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_InteractorStyle* theStyle)
+  Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
   {
-    return theStyle->GetFilter(theId);
+    return theSelector->GetFilter(theId);
   }
 
-  bool IsFilterPresent(int theId, SVTK_InteractorStyle* theStyle)
+  bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
   {
-    return theStyle->IsFilterPresent(theId);
+    return theSelector->IsFilterPresent(theId);
   }
 
-  void RemoveFilter(int theId, SVTK_InteractorStyle* theStyle)
+  void RemoveFilter(int theId, SVTK_Selector* theSelector)
   {
-    theStyle->RemoveFilter(theId);
+    theSelector->RemoveFilter(theId);
   }
 
-  void RemoveFilters(SVTK_InteractorStyle* theStyle)
+  void RemoveFilters(SVTK_Selector* theSelector)
   {
-    for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ )
-      theStyle->RemoveFilter( id );
+    for ( int id = SMESHGUI_NodeFilter; theSelector && id < SMESHGUI_LastFilter; id++ )
+      theSelector->RemoveFilter( id );
   }
 
   bool IsValid(SALOME_Actor* theActor, int theCellId,
-              SVTK_InteractorStyle* theStyle)
+              SVTK_Selector* theSelector)
   {
-    return theStyle->IsValid(theActor,theCellId);
+    return theSelector->IsValid(theActor,theCellId);
   }
 
 
index 53754a3..6b64521 100644 (file)
@@ -34,7 +34,6 @@ class SUIT_Study;
 class SUIT_ViewWindow;
 class SUIT_ViewManager;
 
-class SVTK_InteractorStyle;
 class SVTK_ViewWindow;
 class SVTK_Selector;
 
@@ -119,25 +118,25 @@ namespace SMESH{
 
 
   //----------------------------------------------------------------------------
-  SVTK_InteractorStyle
-    GetInteractorStyle (SUIT_ViewWindow* = GetActiveWindow());
+  SVTK_Selector
+    GetSelector(SUIT_ViewWindow* = GetActiveWindow());
 
   void SetFilter (const Handle(VTKViewer_Filter)& theFilter,
-                 SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+                 SVTK_Selector* theSelector = GetSelector());
 
   Handle(VTKViewer_Filter) 
-    GetFilter (int theId, SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+    GetFilter (int theId, SVTK_Selector* theSelector = GetSelector());
 
   bool IsFilterPresent (int theId, 
-                       SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+                       SVTK_Selector* theSelector = GetSelector());
 
   void RemoveFilter (int theId, 
-                    SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+                    SVTK_Selector* theSelector = GetSelector());
 
-  void RemoveFilters (SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+  void RemoveFilters (SVTK_Selector* theSelector = GetSelector());
 
   bool IsValid (SALOME_Actor* theActor, int theCellId,
-               SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+               SVTK_Selector* theSelector = GetSelector());
 
   //----------------------------------------------------------------------------
   int GetNameOfSelectedNodes(SVTK_Selector* theSelector, 
index 073353a..b0c73c2 100644 (file)
@@ -1,3 +1,18 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2006-01-13 13:50+0300\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
 # This is a Qt message file in .po format.  Each msgid starts with
 # a scope.  This scope should *NOT* be translated - eg. "Foo::Bar"
 # would be translated to "Pub", not "Foo::Pub".
@@ -615,6 +630,10 @@ msgid "SMESH_UPDATEVIEW"
 msgstr "Update View"
 
 
+#Warning incorrect values
+msgid "SMESH_ERR_SCALARBAR_PARAMS"
+msgstr "Warning! The parameters is incorrect"
+
 # -------------- Connectivity --------------
 
 #Boundary Edges
@@ -2893,6 +2912,26 @@ msgstr "Assign a set of hypotheses"
 
 #-----------------------------------------------------------
 
+msgid "SMESHGUI_ShapeByMeshDlg::CAPTION"
+msgstr "Find geometry by mesh element"
+
+msgid "SMESH_ELEMENT_TYPE"
+msgstr "Element Type"
+
+msgid "ELEMENT_ID"
+msgstr "Element ID"
+
+msgid "GEOMETRY_NAME"
+msgstr "Geometry name"
+
+msgid "DIRECT_GEOM_SELECTION"
+msgstr "Direct geometry selection"
+
+msgid "GEOM_BY_MESH_ELEM_SELECTION"
+msgstr "Find geometry by mesh element selection"
+
+#-----------------------------------------------------------
+
 msgid "SMESHGUI_MeshTab::ALGORITHM"
 msgstr "Algorithm"
 
@@ -2931,9 +2970,17 @@ msgstr "Geometry object is not defined\nPlease specify it and try again"
 msgid "SMESHGUI_MeshOp::THERE_IS_NO_OBJECT_FOR_EDITING"
 msgstr "There is no object for editing. Please\nselect mesh or sub-mesh and try again"
 
+msgid "SMESHGUI_MeshOp::EDIT_SUBMESH_QUESTION"
+msgstr "A submesh on the selected geometry already exists.\n Do you want to edit this submesh?"
+
 msgid "SMESHGUI_MeshOp::MESH_IS_NULL"
 msgstr "Mesh is null"
 
+msgid "SMESHGUI_MeshOp::IMPORTED_MESH"
+msgstr "Mesh is not built on geometry"
+
+msgid "SMESHGUI_MeshOp::INVALID_SUBSHAPE"
+msgstr "Geometry object is not a subshape of the shape to mesh"
+
 msgid "SMESHGUI_MeshOp::MESH_IS_NOT_DEFINED"
 msgstr "Mesh is not defined\nPlease specify it and try again"
-
index 5ea16f7..1797437 100644 (file)
@@ -96,7 +96,7 @@ LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistr
 
 
 LDFLAGSFORBIN += -lSMDS -lSMESHDS \
-               -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 \
+               -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 -lmed_V2_1 \
                -lMeshDriver -lMeshDriverMED -lMeshDriverUNV -lMeshDriverDAT -lMeshDriverSTL \
                -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry -lSalomeResourcesManager \
                -lOpUtil -lSALOMELocalTrace -lSALOMEBasics -lSalomeNotification -lCASCatch \
index f4999c9..79f87e1 100644 (file)
@@ -41,6 +41,8 @@
 #include <TopoDS_Shape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
 #include <TCollection_AsciiString.hxx>
 #include "SMESHDS_Document.hxx"
 #include "SMESHDS_Group.hxx"
 #include "SMESHDS_GroupOnGeom.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Hypothesis.hxx"
 #include "SMESH_Group.hxx"
+#include "SMESH_MeshEditor.hxx"
 
 #include "SMDS_EdgePosition.hxx"
 #include "SMDS_FacePosition.hxx"
@@ -490,6 +495,84 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam
   return hyp._retn();
 }
 
+//================================================================================
+/*!
+ * \brief Return hypothesis of given type holding parameter values of the existing mesh
+  * \param theHypType - hypothesis type name
+  * \param theLibName - plugin library name
+  * \param theMesh - The mesh of interest
+  * \param theGeom - The shape to get parameter values from
+  * \retval SMESH::SMESH_Hypothesis_ptr - The returned hypothesis may be the one existing
+  *    in a study and used to compute the mesh, or a temporary one created just to pass
+  *    parameter values
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_ptr
+SMESH_Gen_i::GetHypothesisParameterValues (const char*           theHypType,
+                                           const char*           theLibName,
+                                           SMESH::SMESH_Mesh_ptr theMesh,
+                                           GEOM::GEOM_Object_ptr theGeom)
+    throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  if ( CORBA::is_nil( theMesh ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
+  if ( CORBA::is_nil( theGeom ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
+
+  // -----------------------------------------------
+  // find hypothesis used to mesh theGeom
+  // -----------------------------------------------
+
+  // get mesh and shape
+  SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+  TopoDS_Shape shape = GeomObjectToShape( theGeom );
+  if ( !meshServant || shape.IsNull() )
+    return SMESH::SMESH_Hypothesis::_nil();
+  ::SMESH_Mesh& mesh = meshServant->GetImpl();
+
+  if ( mesh.NbNodes() == 0 ) // empty mesh
+    return SMESH::SMESH_Hypothesis::_nil();
+
+  // create a temporary hypothesis to know its dimention
+  SMESH::SMESH_Hypothesis_var tmpHyp = this->createHypothesis( theHypType, theLibName );
+  SMESH_Hypothesis_i* hypServant = SMESH::DownCast<SMESH_Hypothesis_i*>( tmpHyp );
+  if ( !hypServant )
+    return SMESH::SMESH_Hypothesis::_nil();
+  ::SMESH_Hypothesis* hyp = hypServant->GetImpl();
+
+  // look for a hypothesis of theHypType used to mesh the shape
+  if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
+  {
+    // check local shape
+    SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( theGeom );
+    int nbLocalHyps = aHypList->length();
+    for ( int i = 0; i < nbLocalHyps; i++ )
+      if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
+        return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+    // check super shapes
+    TopTools_ListIteratorOfListOfShape itShape( mesh.GetAncestors( shape ));
+    while ( nbLocalHyps == 0 && itShape.More() ) {
+      GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
+      if ( ! CORBA::is_nil( geomObj )) {
+        SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( geomObj );
+        nbLocalHyps = aHypList->length();
+        for ( int i = 0; i < nbLocalHyps; i++ )
+          if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND global!
+            return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+      }
+      itShape.Next();
+    }
+  }
+
+  // let the temporary hypothesis find out some how parameter values
+  if ( hyp->SetParametersByMesh( &mesh, shape ))
+    return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
+    
+  return SMESH::SMESH_Hypothesis::_nil();
+}
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::CreateMesh
@@ -506,7 +589,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
   // create mesh
   SMESH::SMESH_Mesh_var mesh = this->createMesh();
   // set shape
-  SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
+  SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
   ASSERT( meshServant );
   meshServant->SetShape( theShapeObject );
 
@@ -930,6 +1013,63 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
   return false;
 }
 
+//================================================================================
+/*!
+ * \brief Return geometrical object the given element is built on
+ *  \param theMesh - the mesh the element is in
+ *  \param theElementID - the element ID
+ *  \param theGeomName - the name of the result geom object if it is not yet published
+ *  \retval GEOM::GEOM_Object_ptr - the found or just published geom object
+ */
+//================================================================================
+
+GEOM::GEOM_Object_ptr
+SMESH_Gen_i::GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
+                                       CORBA::Long            theElementID,
+                                       const char*            theGeomName)
+  throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  if ( CORBA::is_nil( theMesh ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
+
+  GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh();
+  GEOM::GEOM_Gen_var    geomGen   = GetGeomEngine();
+
+  // get a core mesh DS
+  SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+  if ( meshServant && !geomGen->_is_nil() && !mainShape->_is_nil() )
+  {
+    ::SMESH_Mesh & mesh = meshServant->GetImpl();
+    SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
+    // find the element in mesh
+    if ( const SMDS_MeshElement * elem = meshDS->FindElement( theElementID ) )
+      // find a shape id by the element
+      if ( int shapeID = ::SMESH_MeshEditor( &mesh ).FindShape( elem )) {
+        // get a geom object by the shape id
+        GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
+        if ( geom->_is_nil() ) {
+          GEOM::GEOM_IShapesOperations_var op =
+            geomGen->GetIShapesOperations( GetCurrentStudyID() );
+          if ( !op->_is_nil() )
+            geom = op->GetSubShape( mainShape, shapeID );
+        }
+        if ( !geom->_is_nil() ) {
+          // try to find the corresponding SObject
+          GeomObjectToShape( geom ); // geom client remembers the found shape
+          SALOMEDS::SObject_var SObj = ObjectToSObject( myCurrentStudy, geom.in() );
+          if ( SObj->_is_nil() )
+            // publish a new subshape
+            SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
+          // return only published geometry
+          if ( !SObj->_is_nil() )
+            return geom._retn();
+        }
+      }
+  }
+  return GEOM::GEOM_Object::_nil();
+}
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::Save
@@ -938,8 +1078,8 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
  */
 //=============================================================================
 SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
-                                     const char*              theURL,
-                                     bool                     isMultiFile )
+                                      const char*              theURL,
+                                      bool                     isMultiFile )
 {
   INFOS( "SMESH_Gen_i::Save" );
 
@@ -988,6 +1128,15 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
   HDFgroup*   aSubSubGroup;
   hdf_size    aSize[ 1 ];
 
+
+  //Remove the files if they exist: BugID: 11225
+  TCollection_AsciiString cmd("rm -f \"");
+  cmd+=filename;
+  cmd+="\" \"";
+  cmd+=meshfile;
+  cmd+="\"";
+  system(cmd.ToCString());
+
   // MED writer to be used by storage process
   DriverMED_W_SMESHDS_Mesh myWriter;
   myWriter.SetFile( meshfile.ToCString() );
@@ -996,7 +1145,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
   // ---> create HDF file
   aFile = new HDFfile( filename.ToCString() );
   aFile->CreateOnDisk();
-  
+
   // --> iterator for top-level objects
   SALOMEDS::ChildIterator_var itBig = myCurrentStudy->NewChildIterator( theComponent );
   for ( ; itBig->More(); itBig->Next() ) {
index b2d6d88..f1cce14 100644 (file)
@@ -176,6 +176,13 @@ public:
                                                 const char* theLibName)
     throw ( SALOME::SALOME_Exception );
   
+  // Return hypothesis of given type holding parameter values of the existing mesh
+  SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char*           theHypType,
+                                                            const char*           theLibName,
+                                                            SMESH::SMESH_Mesh_ptr theMesh,
+                                                            GEOM::GEOM_Object_ptr theGeom)
+    throw ( SALOME::SALOME_Exception );
+  
   // Create empty mesh on a shape
   SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
     throw ( SALOME::SALOME_Exception );
@@ -213,6 +220,11 @@ public:
                                      const SMESH::object_array& theListOfSubShape )
     throw ( SALOME::SALOME_Exception );
 
+  // Return geometrical object the given element is built on
+  GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
+                                                  CORBA::Long            theElementID,
+                                                  const char*            theGeomName)
+    throw ( SALOME::SALOME_Exception );
 
   // ****************************************************
   // Interface inherited methods (from SALOMEDS::Driver)
index d844555..c56c569 100644 (file)
@@ -380,7 +380,7 @@ SMESH_Hypothesis::Hypothesis_Status
     int hypId = myHyp->GetId();
     status = _impl->AddHypothesis(myLocSubShape, hypId);
     if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
-      _mapHypo[hypId] = myHyp;
+      _mapHypo[hypId] = SMESH::SMESH_Hypothesis::_duplicate( myHyp );
       // assure there is a corresponding submesh
       if ( !_impl->IsMainShape( myLocSubShape )) {
         int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
@@ -1194,29 +1194,16 @@ static void PrepareForWriting (const char* file)
       THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
     }
   } else {
-    // nonexisting file
-    TCollection_AsciiString aDirName = aPath.TrekValue(aPath.TrekLength());
-    aPath.UpTrek();
-    aPath.SetName(aDirName);
-    aPath.SetExtension("");
-    OSD_Directory aDir (aPath);
-    TCollection_AsciiString aFullDirName;
-    aPath.SystemName(aFullDirName);
-    if (aDir.Exists()) {
-      aFile.Reset();
-      aFile.Build(OSD_WriteOnly, OSD_Protection());
-      if (aFile.Failed()) {
-        TCollection_AsciiString msg ("You cannot write to directory ");
-        msg += aFullDirName + ".";
-        THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
-      } else {
-        aFile.Close();
-        aFile.Remove();
-      }
-    } else {
-      TCollection_AsciiString msg ("Directory ");
-      msg += aFullDirName + " does not exist.";
+    // nonexisting file; check if it can be created
+    aFile.Reset();
+    aFile.Build(OSD_WriteOnly, OSD_Protection());
+    if (aFile.Failed()) {
+      TCollection_AsciiString msg ("You cannot create the file ");
+      msg += aFullName + ". Check the directory existance and access rights.";
       THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
+    } else {
+      aFile.Close();
+      aFile.Remove();
     }
   }
 }
index c2241c0..b4953a3 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_Arithmetic1D.hxx"
 
+#include "SMESH_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
+
 //=============================================================================
 /*!
  *  
  */
 //=============================================================================
 
-StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId,
-       SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
+  :SMESH_Hypothesis(hypId, studyId, gen)
 {
   _begLength = 1.;
-  _endLength = 1.;
+  _endLength = 10.;
   _name = "Arithmetic1D";
   _param_algo_dim = 1; 
 }
@@ -137,3 +151,49 @@ istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp)
 {
   return hyp.LoadFrom( load );
 }
+
+//================================================================================
+/*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Arithmetic1D::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                  const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _begLength = _endLength = 0.;
+
+  Standard_Real UMin, UMax;
+  TopLoc_Location L;
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+  for ( int i = 1; i <= edgeMap.Extent(); ++i )
+  {
+    const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+    Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
+    GeomAdaptor_Curve AdaptCurve(C);
+
+    vector< double > params;
+    SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+    if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+    {
+      nbEdges++;
+      _begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
+      int nb = params.size();
+      _endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
+    }
+  }
+  if ( nbEdges ) {
+    _begLength /= nbEdges;
+    _endLength /= nbEdges;
+  }
+  return nbEdges;
+}
index ca49df1..0f5e2e0 100644 (file)
@@ -43,10 +43,18 @@ public:
 
   double GetLength(bool isStartLength) const;
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, StdMeshers_Arithmetic1D & hyp);
-  friend istream& operator >> (istream & load, StdMeshers_Arithmetic1D & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp);
+  friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp);
+
+  /*!
+   * \brief Initialize start and end length by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
 
 protected:
   double _begLength, _endLength;
index 1176ebe..fa74a7d 100644 (file)
@@ -31,6 +31,7 @@
 #include "SMESH_Mesh.hxx"
 #include "SMESHDS_Mesh.hxx"
 #include "SMESH_Algo.hxx"
+#include "SMESHDS_SubMesh.hxx"
 
 #include "utilities.h"
 
@@ -47,8 +48,8 @@ using namespace std;
  */
 //=============================================================================
 
-StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId,
-       SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
+  :SMESH_Hypothesis(hypId, studyId, gen)
 {
   _name = "AutomaticLength";
   _param_algo_dim = 1; // is used by SMESH_Regular_1D
@@ -80,6 +81,9 @@ StdMeshers_AutomaticLength::~StdMeshers_AutomaticLength()
  */
 //================================================================================
 
+const double theCoarseConst = 0.5;
+const double theFineConst   = 4.5;
+
 void StdMeshers_AutomaticLength::SetFineness(double theFineness)
   throw(SALOME_Exception)
 {
@@ -113,12 +117,11 @@ inline const TopoDS_TShape* getTShape(const TopoDS_Shape& theShape)
  */
 //================================================================================
 
-static void computeLengths( const SMESH_Mesh*                   theMesh,
+static void computeLengths( SMESHDS_Mesh*                       aMesh,
                             map<const TopoDS_TShape*, double> & theTShapeToLengthMap)
 {
   theTShapeToLengthMap.clear();
 
-  SMESHDS_Mesh* aMesh = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
   TopoDS_Shape aMainShape = aMesh->ShapeToMesh();
 
   // Find length of longest and shortest edge
@@ -197,8 +200,10 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh*   theMesh,
   if ( anEdge.IsNull() || anEdge.ShapeType() != TopAbs_EDGE )
     throw SALOME_Exception(LOCALIZED("Bad edge shape"));
 
-  if ( theMesh != _mesh ) {
-    computeLengths( theMesh, _TShapeToLength );
+  if ( theMesh != _mesh )
+  {
+    SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
+    computeLengths( aMeshDS, _TShapeToLength );
     _mesh = theMesh;
   }
 
@@ -208,7 +213,7 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh*   theMesh,
   if ( tshape_length == _TShapeToLength.end() )
     return 1; // it is a dgenerated edge
 
-  return tshape_length->second / (0.5 + 4.5 * _fineness);
+  return tshape_length->second / (theCoarseConst + theFineConst * _fineness);
 }
 
 //=============================================================================
@@ -257,3 +262,65 @@ istream & operator >>(istream & load, StdMeshers_AutomaticLength & hyp)
 {
   return hyp.LoadFrom( load );
 }
+
+//================================================================================
+/*!
+ * \brief Initialize Fineness by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_AutomaticLength::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                     const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _fineness = 0;
+
+  SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+  for ( int i = 1; i <= edgeMap.Extent(); ++i )
+  {
+    const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+
+    // assure the base automatic length is stored in _TShapeToLength
+    if ( i == 1 ) 
+      GetLength( theMesh, edge );
+
+    // get current segment length
+    double L = SMESH_Algo::EdgeLength( edge );
+    if ( L <= DBL_MIN )
+      continue;
+    SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edge );
+    if ( !eSubMesh )
+      return false;
+    double segLen = L / eSubMesh->NbElements();
+
+    // get segment length from _TShapeToLength
+    map<const TopoDS_TShape*, double>::iterator tshape_length =
+      _TShapeToLength.find( getTShape( edge ));
+    if ( tshape_length == _TShapeToLength.end() )
+      continue;
+    double autoLen = tshape_length->second;
+
+    // segLen = autoLen / (theCoarseConst + theFineConst * _fineness) -->
+    _fineness += ( autoLen / segLen - theCoarseConst ) / theFineConst;
+
+    ++nbEdges;
+  }
+  if ( nbEdges )
+    _fineness /= nbEdges;
+
+  if (_fineness > 1.0)
+    _fineness = 1.0;
+  else if (_fineness < 0.0)
+    _fineness = 0.0;
+
+  return nbEdges;
+}
index b8234b6..fcdd639 100644 (file)
@@ -78,6 +78,14 @@ public:
   friend std::ostream & operator <<(std::ostream & save, StdMeshers_AutomaticLength & hyp);
   friend std::istream & operator >>(std::istream & load, StdMeshers_AutomaticLength & hyp);
 
+  /*!
+   * \brief Initialize Fineness by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
 protected:
   std::map<const TopoDS_TShape*, double> _TShapeToLength;
   const SMESH_Mesh* _mesh;
index f6e5469..bc97ab0 100644 (file)
@@ -30,6 +30,19 @@ using namespace std;
 #include "StdMeshers_Deflection1D.hxx"
 #include "utilities.h"
 
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Algo.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
 
 //=============================================================================
 /*!
@@ -134,3 +147,78 @@ istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp)
 {
   return hyp.LoadFrom( load );
 }
+//================================================================================
+/*!
+ * \brief Evaluate curve deflection between two points
+  * \param theCurve - the curve
+  * \param theU1 - the parameter of the first point
+  * \param theU2 - the parameter of the second point
+  * \retval double - deflection value
+ */
+//================================================================================
+
+static double deflection(const GeomAdaptor_Curve & theCurve,
+                         double                    theU1,
+                         double                    theU2)
+{
+  if ( theCurve.GetType() == GeomAbs_Line )
+    return 0;
+  // line between theU1 and theU2
+  gp_Pnt p1 = theCurve.Value( theU1 ), p2 = theCurve.Value( theU2 );
+  gp_Lin segment( p1, gp_Vec( p1, p2 ));
+
+  // evaluate square distance of theCurve from the segment
+  Standard_Real dist2 = 0;
+  const int nbPnt = 7;
+  const double step = ( theU2 - theU1 ) / nbPnt;
+  while (( theU1 += step ) < theU2 )
+    dist2 = Max( dist2, segment.SquareDistance( theCurve.Value( theU1 )));
+
+  return sqrt( dist2 );
+}
+
+//================================================================================
+/*!
+ * \brief Initialize deflection value by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Deflection1D::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                  const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _value = 0.;
+
+  Standard_Real UMin, UMax;
+  TopLoc_Location L;
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+
+  for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+  {
+    const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+    Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
+    GeomAdaptor_Curve AdaptCurve(C);
+    if ( AdaptCurve.GetType() != GeomAbs_Line )
+    {
+      vector< double > params;
+      SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+      if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+      {
+        nbEdges++;
+        for ( int i = 1; i < params.size(); ++i )
+          _value = Max( _value, deflection( AdaptCurve, params[ i-1 ], params[ i ]));
+      }
+    }
+    else
+      nbEdges++;
+  }
+  return nbEdges;
+}
index 1ed43cb..8aa7112 100644 (file)
@@ -41,10 +41,18 @@ class StdMeshers_Deflection1D:public SMESH_Hypothesis
 
   double GetDeflection() const;
   
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator <<(ostream & save, StdMeshers_Deflection1D & hyp);
-  friend istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator <<(std::ostream & save, StdMeshers_Deflection1D & hyp);
+  friend std::istream & operator >>(std::istream & load, StdMeshers_Deflection1D & hyp);
+
+  /*!
+   * \brief Initialize deflection value by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
 
  protected:
   double _value;
index f21f199..55adccc 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_LengthFromEdges.hxx"
+
 #include "utilities.h"
 
+using namespace std;
+
 //=============================================================================
 /*!
  *  
@@ -42,8 +44,6 @@ StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, S
 {
   _mode =1;
   _name = "LengthFromEdges";
-//   SCRUTE(_name);
-//   SCRUTE(&_name);
   _param_algo_dim = 2; // is used by SMESH_MEFISTO_2D
 }
 
@@ -137,3 +137,19 @@ istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp)
   return hyp.LoadFrom( load );
 }
 
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_LengthFromEdges::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+                                                     const TopoDS_Shape& /*theShape*/)
+{
+  return false;
+}
index d514e7c..c7b20a3 100644 (file)
@@ -45,10 +45,20 @@ public:
 
   int GetMode();
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp);
-  friend istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator << (std::ostream & save, StdMeshers_LengthFromEdges & hyp);
+  friend std::istream & operator >> (std::istream & load, StdMeshers_LengthFromEdges & hyp);
+
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+    *
+    * Just return false as this hypothesis does not have parameters values
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
 
 protected:
   int _mode;
index 457d8d8..90010a2 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_LocalLength.hxx"
+
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Algo.hxx"
+
 #include "utilities.h"
 
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
+
 //=============================================================================
 /*!
  *  
  */
 //=============================================================================
 
-StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId,
-       SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen)
+  :SMESH_Hypothesis(hypId, studyId, gen)
 {
-       _length = 1.;
-       _name = "LocalLength";
-//   SCRUTE(_name);
-//   SCRUTE(&_name);
-        _param_algo_dim = 1; // is used by SMESH_Regular_1D
+  _length = 1.;
+  _name = "LocalLength";
+  _param_algo_dim = 1; // is used by SMESH_Regular_1D
 }
 
 //=============================================================================
@@ -135,3 +148,47 @@ istream & operator >>(istream & load, StdMeshers_LocalLength & hyp)
 {
   return hyp.LoadFrom( load );
 }
+
+//================================================================================
+/*!
+ * \brief Initialize segment length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_LocalLength::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                 const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _length = 0.;
+
+  Standard_Real UMin, UMax;
+  TopLoc_Location L;
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+  for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+  {
+    const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+    Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
+    GeomAdaptor_Curve AdaptCurve(C);
+
+    vector< double > params;
+    SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+    if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+    {
+      for ( int i = 1; i < params.size(); ++i )
+        _length += GCPnts_AbscissaPoint::Length( AdaptCurve, params[ i-1 ], params[ i ]);
+      nbEdges += params.size() - 1;
+    }
+  }
+  if ( nbEdges )
+    _length /= nbEdges;
+
+  return nbEdges;
+}
index aba58e5..a48d285 100644 (file)
 
 class StdMeshers_LocalLength:public SMESH_Hypothesis
 {
 public:
-       StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
-         virtual ~ StdMeshers_LocalLength();
+ public:
+  StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
+  virtual ~ StdMeshers_LocalLength();
 
-       void SetLength(double length) throw(SALOME_Exception);
+  void SetLength(double length) throw(SALOME_Exception);
 
-       double GetLength() const;
+  double GetLength() const;
 
-       virtual ostream & SaveTo(ostream & save);
-       virtual istream & LoadFrom(istream & load);
-       friend ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp);
-       friend istream & operator >>(istream & load, StdMeshers_LocalLength & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator <<(std::ostream & save, StdMeshers_LocalLength & hyp);
+  friend std::istream & operator >>(std::istream & load, StdMeshers_LocalLength & hyp);
 
-  protected:
-       double _length;
+  /*!
+   * \brief Initialize segment length by the mesh built on the geometry
+   * \param theMesh - the built mesh
+   * \param theShape - the geometry of interest
+   * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+ protected:
+  double _length;
 };
 
 #endif
index ed166fc..4852ce4 100644 (file)
@@ -324,7 +324,8 @@ static bool fixOverlappedLinkUV( R2& uv0, const R2& uv1, const R2& uv2 )
       uv0.y -= delta;
     else
       uv0.y += delta;
-//    MESSAGE(" -> " << uv0.x << " " << uv0.y << " ");
+// #ifdef _DEBUG_
+//     MESSAGE(" -> " << uv0.x << " " << uv0.y << " ");
 //     MESSAGE("v1( " << v1.X() << " " << v1.Y() << " ) " <<
 //       "v2( " << v2.X() << " " << v2.Y() << " ) ");
 //    MESSAGE("SIN: " << sqrt(1 - dot * dot / (sqMod1 * sqMod2)));
@@ -336,6 +337,7 @@ static bool fixOverlappedLinkUV( R2& uv0, const R2& uv1, const R2& uv2 )
 //     dot = v1*v2;
 //     double sin = sqrt(1 - dot * dot / (sqMod1 * sqMod2));
 //     MESSAGE("NEW SIN: " << sin);
+// #endif
     return true;
   }
   return false;
@@ -475,134 +477,109 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh &        aMesh,
                                        double              scaley,
                                        const TopTools_IndexedDataMapOfShapeListOfShape& VWMap)
 {
-//  MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints");
-
-  //SMDS_Mesh * meshDS = aMesh.GetMeshDS();
+  //  MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints");
 
   TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
 
-  int mInit = m, mFirst, iEdge;
+  list< int > mOnVertex;
+
   gp_XY scale( scalex, scaley );
 
   TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
   BRepTools_WireExplorer wexp(W, F);
-  for (wexp.Init(W, F), iEdge = 0; wexp.More(); wexp.Next(), iEdge++)
+  for ( wexp.Init(W, F); wexp.More(); wexp.Next() )
   {
     const TopoDS_Edge & E = wexp.Current();
+    bool isForward = (E.Orientation() == TopAbs_FORWARD);
 
     // --- IDNodes of first and last Vertex
 
-    TopoDS_Vertex VFirst, VLast;
+    TopoDS_Vertex VFirst, VLast, V;
     TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+    V = isForward ? VFirst : VLast;
 
-    ASSERT(!VFirst.IsNull());
-    SMDS_NodeIteratorPtr lid=
-      aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
+    ASSERT(!V.IsNull());
+    SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(V)->GetSubMeshDS()->GetNodes();
     if ( !lid->more() ) {
       MESSAGE (" NO NODE BUILT ON VERTEX ");
       return false;
     }
     const SMDS_MeshNode* idFirst = lid->next();
 
-    ASSERT(!VLast.IsNull());
-    lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
-    if ( !lid->more() ) {
-      MESSAGE (" NO NODE BUILT ON VERTEX ");
-      return false;
-    }
-    const SMDS_MeshNode* idLast = lid->next();
-
     // --- edge internal IDNodes (relies on good order storage, not checked)
 
-    int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-
-    double f, l;
-    Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
-
-    SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
-
-    //bool isForward = (E.Orientation() == TopAbs_FORWARD);
     map<double, const SMDS_MeshNode*> params;
+    const SMDS_MeshNode * node;
 
-    while(ite->more())
+    SMDS_NodeIteratorPtr nodeIt= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
+    while ( nodeIt->more() )
     {
-      const SMDS_MeshNode * node = ite->next();
+      node = nodeIt->next();
       const SMDS_EdgePosition* epos =
         static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
-      double param = epos->GetUParameter();
-      params[param] = node;
+      params[ epos->GetUParameter() ] = node;
     }
+    int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
     if ( nbPoints != params.size())
     {
       MESSAGE( "BAD NODE ON EDGE POSITIONS" );
       return false;
     }
 
-    mFirst = m;
-
     // --- load 2D values into MEFISTO structure,
     //     add IDNodes in mefistoToDS map
-    if (E.Orientation() == TopAbs_FORWARD)
+
+    double f, l, uFirst, u;
+    Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+    uFirst = isForward ? f : l;
+
+    // vertex node
+    gp_Pnt2d p = C2d->Value( uFirst ).XY().Multiplied( scale );
+    if ( fixCommonVertexUV( p, V, W, myOuterWire, F, VWMap, aMesh ))
+      myNodesOnCommonV.push_back( idFirst );
+    mOnVertex.push_back( m );
+    uvslf[m].x = p.X();
+    uvslf[m].y = p.Y();
+    mefistoToDS[m + 1] = idFirst;
+    //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+    //MESSAGE("__ f "<<uFirst<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+    m++;
+
+    // internal nodes
+    map<double, const SMDS_MeshNode*>::iterator u_n = params.begin();
+    map<double, const SMDS_MeshNode*>::reverse_iterator u_n_rev = params.rbegin();
+    for ( int i = 0; i < nbPoints; ++i )
     {
-      gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale );       // first point = Vertex Forward
-      if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh ))
-        myNodesOnCommonV.push_back( idFirst );
-      uvslf[m].x = p.X();
-      uvslf[m].y = p.Y();
-      mefistoToDS[m + 1] = idFirst;
-      //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-      //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-      m++;
-      map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
-      for (int i = 1; i <= nbPoints; i++)       // nbPoints internal
-      {
-        double param = (*itp).first;
-        gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale );
-        uvslf[m].x = p.X();
-        uvslf[m].y = p.Y();
-        mefistoToDS[m + 1] = (*itp).second;
-        //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-        //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-        m++;
-        itp++;
+      if ( isForward ) {
+        u    = u_n->first;
+        node = u_n->second;
+        ++u_n;
+      } else {
+        u    = u_n_rev->first;
+        node = u_n_rev->second;
+        ++u_n_rev;
       }
-    }
-    else
-    {
-      gp_Pnt2d p = C2d->Value(l).XY().Multiplied( scale );       // last point = Vertex Reversed
-      if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh ))
-        myNodesOnCommonV.push_back( idLast );
+      gp_Pnt2d p = C2d->Value( u ).XY().Multiplied( scale );
       uvslf[m].x = p.X();
       uvslf[m].y = p.Y();
-      mefistoToDS[m + 1] = idLast;
+      mefistoToDS[m + 1] = node;
       //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-      //MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+      //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
       m++;
-      map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
-      for (int i = nbPoints; i >= 1; i--)
-      {
-        double param = (*itp).first;
-        gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale );
-        uvslf[m].x = p.X();
-        uvslf[m].y = p.Y();
-        mefistoToDS[m + 1] = (*itp).second;
-        //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-        //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-        m++;
-        itp++;
-      }
     }
-    // prevent failure on overlapped adjacent links
-    if ( iEdge > 0 )
-      fixOverlappedLinkUV (uvslf[ mFirst - 1],
-                           uvslf[ mFirst ],
-                           uvslf[ mFirst + 1 ]);
-    
   } // for  wexp
 
-  fixOverlappedLinkUV (uvslf[ m - 1],
-                       uvslf[ mInit ],
-                       uvslf[ mInit + 1 ]);
+  // prevent failure on overlapped adjacent links,
+  // check only links ending in vertex nodes
+  int mFirst = mOnVertex.front(), mLast = m - 1;
+  list< int >::iterator mIt = mOnVertex.begin();
+  for ( ; mIt != mOnVertex.end(); ++mIt ) {
+    int i = *mIt;
+    int iB = i - 1, iA = i + 1; // indices Before and After
+    if ( iB < mFirst ) iB = mLast;
+    if ( iA > mLast )  iA = mFirst;
+    fixOverlappedLinkUV (uvslf[ iB ], uvslf[ i ], uvslf[ iA ]);
+  }
 
   return true;
 }
index c4a2d5e..08c69e6 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_MaxElementArea.hxx"
+
+#include "SMESH_ControlsDef.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 #include "utilities.h"
 
+using namespace std;
+
 //=============================================================================
 /*!
  *  
@@ -42,8 +52,6 @@ StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SME
 {
   _maxArea =1.;
   _name = "MaxElementArea";
-//   SCRUTE(_name);
-//   SCRUTE(&_name);
   _param_algo_dim = 2; 
 }
 
@@ -137,3 +145,44 @@ istream & operator >> (istream & load, StdMeshers_MaxElementArea & hyp)
   return hyp.LoadFrom( load );
 }
 
+//================================================================================
+/*!
+ * \brief Initialize maximal area by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementArea::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                    const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _maxArea = 0;
+
+  SMESH::Controls::Area areaControl;
+  SMESH::Controls::TSequenceOfXYZ nodesCoords;
+
+  SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+  TopTools_IndexedMapOfShape faceMap;
+  TopExp::MapShapes( theShape, TopAbs_FACE, faceMap );
+  for ( int iF = 1; iF <= faceMap.Extent(); ++iF )
+  {
+    SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( faceMap( iF ));
+    if ( !subMesh )
+      return false;
+    SMDS_ElemIteratorPtr fIt = subMesh->GetElements();
+    while ( fIt->more() )
+    {
+      const SMDS_MeshElement* elem = fIt->next();
+      if ( elem->GetType() == SMDSAbs_Face ) {
+        areaControl.GetPoints( elem, nodesCoords );
+        _maxArea = max( _maxArea, areaControl.GetValue( nodesCoords ));
+      }
+    }
+  }
+  return _maxArea > 0;
+}
index 52af887..44e8d09 100644 (file)
 
 class StdMeshers_MaxElementArea:public SMESH_Hypothesis
 {
-  public:
-       StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
-         virtual ~ StdMeshers_MaxElementArea();
+public:
+  StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
+  virtual ~ StdMeshers_MaxElementArea();
 
-       void SetMaxArea(double maxArea) throw(SALOME_Exception);
+  void SetMaxArea(double maxArea) throw(SALOME_Exception);
 
-       double GetMaxArea() const;
+  double GetMaxArea() const;
 
-       virtual ostream & SaveTo(ostream & save);
-       virtual istream & LoadFrom(istream & load);
-       friend ostream & operator <<(ostream & save, StdMeshers_MaxElementArea & hyp);
-       friend istream & operator >>(istream & load, StdMeshers_MaxElementArea & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator <<(std::ostream & save, StdMeshers_MaxElementArea & hyp);
+  friend std::istream & operator >>(std::istream & load, StdMeshers_MaxElementArea & hyp);
 
-  protected:
-       double _maxArea;
+  /*!
+   * \brief Initialize maximal area by the mesh built on the geometry
+   * \param theMesh - the built mesh
+   * \param theShape - the geometry of interest
+   * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+protected:
+  double _maxArea;
 };
 
 #endif
index f9f6b63..c4e5894 100644 (file)
 using namespace std;
 
 #include "StdMeshers_MaxElementVolume.hxx"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_ControlsDef.hxx"
+#include "SMESH_Mesh.hxx"
+
 #include "utilities.h"
 
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 //=============================================================================
 /*!
  *  
@@ -41,10 +51,8 @@ using namespace std;
 StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
   : SMESH_Hypothesis(hypId, studyId, gen)
 {
-  _maxVolume =1.;
+  _maxVolume = 1.;
   _name = "MaxElementVolume";
-//   SCRUTE(_name);
-  SCRUTE(&_name);
   _param_algo_dim = 3;
 }
 
@@ -139,3 +147,54 @@ istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp)
   return hyp.LoadFrom( load );
 }
 
+
+//================================================================================
+/*!
+ * \brief Initialize maximal area by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementVolume::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                      const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _maxVolume = 0;
+
+  SMESH::Controls::Volume volumeControl;
+
+  TopTools_IndexedMapOfShape volMap;
+  TopExp::MapShapes( theShape, TopAbs_SOLID, volMap );
+  if ( volMap.IsEmpty() )
+    TopExp::MapShapes( theShape, TopAbs_SHELL, volMap );
+  if ( volMap.IsEmpty() )
+    return false;
+
+  SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+  for ( int iV = 1; iV <= volMap.Extent(); ++iV )
+  {
+    const TopoDS_Shape& S = volMap( iV );
+    SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( S );
+    if ( !subMesh && S.ShapeType() == TopAbs_SOLID ) {
+      TopExp_Explorer shellExp( S, TopAbs_SHELL );
+      if ( shellExp.More() )
+        subMesh = aMeshDS->MeshElements( shellExp.Current() );
+    }
+    if ( !subMesh) 
+      return false;
+    SMDS_ElemIteratorPtr vIt = subMesh->GetElements();
+    while ( vIt->more() )
+    {
+      const SMDS_MeshElement* elem = vIt->next();
+      if ( elem->GetType() == SMDSAbs_Volume ) {
+        _maxVolume = max( _maxVolume, volumeControl.GetValue( elem->GetID() ));
+      }
+    }
+  }
+  return _maxVolume > 0;
+}
index ee9986f..870aac9 100644 (file)
@@ -45,10 +45,18 @@ public:
 
   double GetMaxVolume() const;
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp);
-  friend istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator << (std::ostream & save, StdMeshers_MaxElementVolume & hyp);
+  friend std::istream & operator >> (std::istream & load, StdMeshers_MaxElementVolume & hyp);
+
+  /*!
+   * \brief Initialize maximal volume by the mesh built on the geometry
+   * \param theMesh - the built mesh
+   * \param theShape - the geometry of interest
+   * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
 
 protected:
   double _maxVolume;
index 5c471b2..5799cbc 100644 (file)
@@ -96,3 +96,19 @@ istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp)
 {
   return load;
 }
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_NotConformAllowed::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+                                                       const TopoDS_Shape& /*theShape*/)
+{
+  return false;
+}
index 0797424..3ffb7b7 100644 (file)
@@ -39,10 +39,21 @@ public:
   StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
   virtual ~StdMeshers_NotConformAllowed();
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp);
-  friend istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator << (std::ostream & save, StdMeshers_NotConformAllowed & hyp);
+  friend std::istream & operator >> (std::istream & load, StdMeshers_NotConformAllowed & hyp);
+
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+    *
+    * Just return false as this hypothesis does not have parameters values
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
 };
 
 #endif
index 0b9d333..139ea22 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_NumberOfSegments.hxx"
+
 #include "StdMeshers_Distribution.hxx"
-#include <Standard_ErrorHandler.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <ExprIntrp_GenExp.hxx>
-#include <Expr_NamedUnknown.hxx>
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_Mesh.hxx"
+
 #include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx> 
 #include <CASCatch_ErrorHandler.hxx>
-#include <OSD.hxx>
+#include <CASCatch_Failure.hxx> 
+#include <ExprIntrp_GenExp.hxx>
 #include <Expr_Array1OfNamedUnknown.hxx>
+#include <Expr_NamedUnknown.hxx>
+#include <OSD.hxx>
 #include <TColStd_Array1OfReal.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
+#include <Standard_ErrorHandler.hxx>
+
+using namespace std;
 
 const double PRECISION = 1e-7;
 
@@ -640,3 +647,40 @@ istream & operator >>(istream & load, StdMeshers_NumberOfSegments & hyp)
 {
   return hyp.LoadFrom( load );
 }
+
+//================================================================================
+/*!
+ * \brief Initialize number of segments by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_NumberOfSegments::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                      const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _numberOfSegments = 0;
+  _distrType = DT_Regular;
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+  for ( int i = 1; i <= edgeMap.Extent(); ++i )
+  {
+    // get current segment length
+    SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+    SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edgeMap( i ));
+    if ( eSubMesh && eSubMesh->NbElements())
+      _numberOfSegments += eSubMesh->NbElements();
+
+    ++nbEdges;
+  }
+  if ( nbEdges )
+    _numberOfSegments /= nbEdges;
+
+  return nbEdges;
+}
index 28d829b..3878330 100644 (file)
@@ -161,10 +161,19 @@ public:
   int ConversionMode() const
     throw (SALOME_Exception);
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp);
-  friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
+
+  /*!
+   * \brief Initialize number of segments by the mesh built on the geometry
+   * \param theMesh - the built mesh
+   * \param theShape - the geometry of interest
+   * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream& operator << (std::ostream & save, StdMeshers_NumberOfSegments & hyp);
+  friend std::istream& operator >> (std::istream & load, StdMeshers_NumberOfSegments & hyp);
 
 protected:
   int                 _numberOfSegments; //!< an edge will be split on to this number of segments
index f314b4c..6672e25 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "StdMeshers_Propagation.hxx"
+
 #include "utilities.h"
 
+using namespace std;
+
 //=============================================================================
 /*!
  *
@@ -100,3 +102,19 @@ std::string StdMeshers_Propagation::GetName ()
 {
   return "Propagation";
 }
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_Propagation::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+                                                 const TopoDS_Shape& /*theShape*/)
+{
+  return false;
+}
index 4ee7c56..ef750b9 100644 (file)
@@ -36,12 +36,22 @@ class StdMeshers_Propagation:public SMESH_Hypothesis
   StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen);
   virtual ~ StdMeshers_Propagation();
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator <<(ostream & save, StdMeshers_Propagation & hyp);
-  friend istream & operator >>(istream & load, StdMeshers_Propagation & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator <<(std::ostream & save, StdMeshers_Propagation & hyp);
+  friend std::istream & operator >>(std::istream & load, StdMeshers_Propagation & hyp);
 
   static std::string GetName ();
+
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+    *
+    * Just return false as this hypothesis does not have parameters values
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
 };
 
 #endif
index 4ba3dd8..60dc494 100644 (file)
@@ -98,3 +98,19 @@ istream & operator >>(istream & load, StdMeshers_QuadranglePreference & hyp)
 {
   return hyp.LoadFrom( load );
 }
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_QuadranglePreference::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+                                                          const TopoDS_Shape& /*theShape*/)
+{
+  return false;
+}
index eb2fdca..ba6eaef 100644 (file)
@@ -47,6 +47,17 @@ class StdMeshers_QuadranglePreference:public SMESH_Hypothesis
   virtual std::istream & LoadFrom(std::istream & load);
   friend std::ostream & operator <<(std::ostream & save, StdMeshers_QuadranglePreference & hyp);
   friend std::istream & operator >>(std::istream & load, StdMeshers_QuadranglePreference & hyp);
+
+  /*!
+   * \brief Initialize my parameter values by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+    *
+    * Just return false as this hypothesis does not have parameters values
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
 };
 
 #endif
index e40390c..9ffa37d 100644 (file)
@@ -51,10 +51,21 @@ using namespace std;
 #include <Precision.hxx>
 #include <gp_Pnt2d.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_SequenceOfReal.hxx>
+#include <TColgp_SequenceOfXY.hxx>
 
 #include "utilities.h"
 #include "Utils_ExceptHandlers.hxx"
 
+#ifndef StdMeshers_Array2OfNode_HeaderFile
+#define StdMeshers_Array2OfNode_HeaderFile
+typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
+#include <NCollection_DefineArray2.hxx>
+DEFINE_BASECOLLECTION (StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
+DEFINE_ARRAY2(StdMeshers_Array2OfNode,
+              StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
+#endif
+
 
 //=============================================================================
 /*!
@@ -117,7 +128,28 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
   SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
   aMesh.GetSubMesh(aShape);
 
-  FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
+  //FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
+  FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
+
+  if (!quad)
+    return false;
+
+  if(myQuadranglePreference) {
+    int n1 = quad->nbPts[0];
+    int n2 = quad->nbPts[1];
+    int n3 = quad->nbPts[2];
+    int n4 = quad->nbPts[3];
+    int nfull = n1+n2+n3+n4;
+    int ntmp = nfull/2;
+    ntmp = ntmp*2;
+    if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
+      // special path for using only quandrangle faces
+      return ComputeQuadPref(aMesh, aShape, quad);
+    }
+  }
+
+  // set normalized grid on unit square in parametric domain
+  SetNormalizedGrid(aMesh, aShape, quad);
   if (!quad)
     return false;
 
@@ -490,14 +522,16 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
   return isOk;
 }
 
+
 //=============================================================================
 /*!
  *  
  */
 //=============================================================================
 
-FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
-  (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
+FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
+                                                       const TopoDS_Shape & aShape)
+     throw(SALOME_Exception)
 {
   Unexpect aCatch(SalomeException);
 
@@ -505,42 +539,56 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
 
   // verify 1 wire only, with 4 edges
 
-  if (NumberOfWires(F) != 1)
-  {
+  if (NumberOfWires(F) != 1) {
     INFOS("only 1 wire by face (quadrangles)");
     return 0;
   }
   const TopoDS_Wire& W = BRepTools::OuterWire(F);
   BRepTools_WireExplorer wexp (W, F);
 
-  FaceQuadStruct *quad = new FaceQuadStruct;
+  FaceQuadStructquad = new FaceQuadStruct;
   for (int i = 0; i < 4; i++)
     quad->uv_edges[i] = 0;
   quad->uv_grid = 0;
 
   int nbEdges = 0;
-  for (wexp.Init(W, F); wexp.More(); wexp.Next())
-  {
+  for (wexp.Init(W, F); wexp.More(); wexp.Next()) {
     const TopoDS_Edge& E = wexp.Current();
     int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-    if (nbEdges < 4)
-    {
+    if (nbEdges < 4) {
       quad->edge[nbEdges] = E;
       quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
     }
     nbEdges++;
   }
 
-  if (nbEdges != 4)
-  {
+  if (nbEdges != 4) {
     INFOS("face must have 4 edges /quadrangles");
     QuadDelete(quad);
     return 0;
   }
 
-  // set normalized grid on unit square in parametric domain
+  return quad;
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
+  (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+
+  FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
+
+  if(!quad) return 0;
 
-  SetNormalizedGrid(aMesh, F, quad);
+  // set normalized grid on unit square in parametric domain
+  SetNormalizedGrid(aMesh, aShape, quad);
 
   return quad;
 }
@@ -789,6 +837,654 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
   }
 }
 
+
+//=======================================================================
+//function : ShiftQuad
+//purpose  : auxilary function for ComputeQuadPref
+//=======================================================================
+static void ShiftQuad(FaceQuadStruct* quad, const int num, bool WisF)
+{
+  if(num>3) return;
+  int i;
+  for(i=1; i<=num; i++) {
+    int nbPts3 = quad->nbPts[0];
+    quad->nbPts[0] = quad->nbPts[1];
+    quad->nbPts[1] = quad->nbPts[2];
+    quad->nbPts[2] = quad->nbPts[3];
+    quad->nbPts[3] = nbPts3;
+    TopoDS_Edge edge3 = quad->edge[0];
+    quad->edge[0] = quad->edge[1];
+    quad->edge[1] = quad->edge[2];
+    quad->edge[2] = quad->edge[3];
+    quad->edge[3] = edge3;
+    double first3 = quad->first[0];
+    quad->first[0] = quad->first[1];
+    quad->first[1] = quad->first[2];
+    quad->first[2] = quad->first[3];
+    quad->first[3] = first3;
+    double last3 = quad->last[0];
+    quad->last[0] = quad->last[1];
+    quad->last[1] = quad->last[2];
+    quad->last[2] = quad->last[3];
+    quad->last[3] = last3;
+    bool isEdgeForward3 = quad->isEdgeForward[0];
+    quad->isEdgeForward[0] = quad->isEdgeForward[1];
+    quad->isEdgeForward[1] = quad->isEdgeForward[2];
+    quad->isEdgeForward[2] = quad->isEdgeForward[3];
+    quad->isEdgeForward[3] = isEdgeForward3;
+    bool isEdgeOut3 = quad->isEdgeOut[0];
+    quad->isEdgeOut[0] = quad->isEdgeOut[1];
+    quad->isEdgeOut[1] = quad->isEdgeOut[2];
+    quad->isEdgeOut[2] = quad->isEdgeOut[3];
+    quad->isEdgeOut[3] = isEdgeOut3;
+    UVPtStruct* uv_edges3 = quad->uv_edges[0];
+    quad->uv_edges[0] = quad->uv_edges[1];
+    quad->uv_edges[1] = quad->uv_edges[2];
+    quad->uv_edges[2] = quad->uv_edges[3];
+    quad->uv_edges[3] = uv_edges3;
+  }
+  if(!WisF) {
+    // replacement left and right edges
+    int nbPts3 = quad->nbPts[1];
+    quad->nbPts[1] = quad->nbPts[3];
+    quad->nbPts[3] = nbPts3;
+    TopoDS_Edge edge3 = quad->edge[1];
+    quad->edge[1] = quad->edge[3];
+    quad->edge[3] = edge3;
+    double first3 = quad->first[1];
+    quad->first[1] = quad->first[3];
+    quad->first[3] = first3;
+    double last3 = quad->last[1];
+    quad->last[1] = quad->last[2];
+    quad->last[3] = last3;
+    bool isEdgeForward3 = quad->isEdgeForward[1];
+    quad->isEdgeForward[1] = quad->isEdgeForward[3];
+    quad->isEdgeForward[3] = isEdgeForward3;
+    bool isEdgeOut3 = quad->isEdgeOut[1];
+    quad->isEdgeOut[1] = quad->isEdgeOut[3];
+    quad->isEdgeOut[3] = isEdgeOut3;
+    UVPtStruct* uv_edges3 = quad->uv_edges[1];
+    quad->uv_edges[1] = quad->uv_edges[3];
+    quad->uv_edges[3] = uv_edges3;
+  }
+}
+
+
+//=======================================================================
+//function : CalcUV
+//purpose  : auxilary function for ComputeQuadPref
+//=======================================================================
+static gp_XY CalcUV(double x0, double x1, double y0, double y1,
+                    FaceQuadStruct* quad,
+                    const gp_Pnt2d& a0, const gp_Pnt2d& a1,
+                    const gp_Pnt2d& a2, const gp_Pnt2d& a3,
+                    const Handle(Geom2d_Curve)& c2db,
+                    const Handle(Geom2d_Curve)& c2dr,
+                    const Handle(Geom2d_Curve)& c2dt,
+                    const Handle(Geom2d_Curve)& c2dl)
+{
+  int nb = quad->nbPts[0];
+  int nr = quad->nbPts[1];
+  int nt = quad->nbPts[2];
+  int nl = quad->nbPts[3];
+
+  UVPtStruct* uv_eb = quad->uv_edges[0];
+  UVPtStruct* uv_er = quad->uv_edges[1];
+  UVPtStruct* uv_et = quad->uv_edges[2];
+  UVPtStruct* uv_el = quad->uv_edges[3];
+
+  double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
+  double y = y0 + x * (y1 - y0);
+
+  double param_b = uv_eb[0].param + x * (uv_eb[nb-1].param - uv_eb[0].param);
+  double param_t = uv_et[0].param + x * (uv_et[nt-1].param - uv_et[0].param);
+  double param_r = uv_er[0].param + y * (uv_er[nr-1].param - uv_er[0].param);
+  double param_l = uv_el[0].param + y * (uv_el[nl-1].param - uv_el[0].param);
+
+  gp_Pnt2d p0 = c2db->Value(param_b);
+  gp_Pnt2d p1 = c2dr->Value(param_r);
+  gp_Pnt2d p2 = c2dt->Value(param_t);
+  gp_Pnt2d p3 = c2dl->Value(param_l);
+
+  double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
+  double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
+
+  u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
+    x * y * a2.X() + (1 - x) * y * a3.X();
+  v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
+    x * y * a2.Y() + (1 - x) * y * a3.Y();
+
+  //cout<<"x0="<<x0<<" x1="<<x1<<" y0="<<y0<<" y1="<<y1<<endl;
+  //cout<<"x="<<x<<" y="<<y<<endl;
+  //cout<<"param_b="<<param_b<<" param_t="<<param_t<<" param_r="<<param_r<<" param_l="<<param_l<<endl;
+  //cout<<"u="<<u<<" v="<<v<<endl;
+
+  return gp_XY(u,v);
+}
+
+
+//=======================================================================
+//function : ComputeQuadPref
+//purpose  : 
+//=======================================================================
+/*!
+ * Special function for creation only quandrangle faces
+ */
+bool StdMeshers_Quadrangle_2D::ComputeQuadPref
+                          (SMESH_Mesh & aMesh,
+                           const TopoDS_Shape& aShape,
+                           FaceQuadStruct* quad) throw (SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+
+  SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+  const TopoDS_Face& F = TopoDS::Face(aShape);
+  Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+  const TopoDS_Wire& W = BRepTools::OuterWire(F);
+  bool WisF = false;
+  if(W.Orientation()==TopAbs_FORWARD) 
+    WisF = true;
+  //if(WisF) cout<<"W is FORWARD"<<endl;
+  //else cout<<"W is REVERSED"<<endl;
+  bool FisF = (F.Orientation()==TopAbs_FORWARD);
+  if(!FisF) WisF = !WisF;
+  int i,j,geomFaceID = meshDS->ShapeToIndex( F );
+
+  int nb = quad->nbPts[0];
+  int nr = quad->nbPts[1];
+  int nt = quad->nbPts[2];
+  int nl = quad->nbPts[3];
+  int dh = abs(nb-nt);
+  int dv = abs(nr-nl);
+
+  if( dh>=dv ) {
+    if( nt>nb ) {
+      // it is a base case => not shift quad but me be replacement is need
+      ShiftQuad(quad,0,WisF);
+    }
+    else {
+      // we have to shift quad on 2
+      ShiftQuad(quad,2,WisF);
+    }
+  }
+  else {
+    if( nr>nl ) {
+      // we have to shift quad on 3
+      ShiftQuad(quad,3,WisF);
+    }
+    else {
+      // we have to shift quad on 1
+      ShiftQuad(quad,1,WisF);
+    }
+  }
+
+  nb = quad->nbPts[0];
+  nr = quad->nbPts[1];
+  nt = quad->nbPts[2];
+  nl = quad->nbPts[3];
+  dh = abs(nb-nt);
+  dv = abs(nr-nl);
+  int nbh  = Max(nb,nt);
+  int nbv = Max(nr,nl);
+  int addh = 0;
+  int addv = 0;
+
+  // orientation of face and 3 main domain for future faces
+  //       0   top    1
+  //      1------------1
+  //       |   |  |   |
+  //       |   |  |   |
+  //       | L |  | R |
+  //  left |   |  |   | rigth
+  //       |  /    \  |
+  //       | /  C   \ |
+  //       |/        \|
+  //      0------------0
+  //       0  bottom  1
+
+  if(dh>dv) {
+    addv = (dh-dv)/2;
+    nbv = nbv + addv;
+  }
+  else { // dv>=dh
+    addh = (dv-dh)/2;
+    nbh = nbh + addh;
+  }
+
+  Handle(Geom2d_Curve) c2d[4];
+  for(i=0; i<4; i++) {
+    c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F,
+                                       quad->first[i], quad->last[i]);
+  }
+
+  bool loadOk = true;
+  for(i=0; i<2; i++) {
+    quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], false);
+    if(!quad->uv_edges[i]) loadOk = false;
+  }
+  for(i=2; i<4; i++) {
+    quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], true);
+    if (!quad->uv_edges[i]) loadOk = false;
+  }
+  if (!loadOk) {
+    INFOS("StdMeshers_Quadrangle_2D::ComputeQuadPref - LoadEdgePoints failed");
+    QuadDelete( quad );
+    quad = 0;
+    return false;
+  }
+
+  UVPtStruct* uv_eb = quad->uv_edges[0];
+  UVPtStruct* uv_er = quad->uv_edges[1];
+  UVPtStruct* uv_et = quad->uv_edges[2];
+  UVPtStruct* uv_el = quad->uv_edges[3];
+
+  // arrays for normalized params
+  //cout<<"Dump B:"<<endl;
+  TColStd_SequenceOfReal npb, npr, npt, npl;
+  for(i=0; i<nb; i++) {
+    npb.Append(uv_eb[i].normParam);
+    //cout<<"i="<<i<<" par="<<uv_eb[i].param<<" npar="<<uv_eb[i].normParam;
+    //const SMDS_MeshNode* N = uv_eb[i].node;
+    //cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
+  }
+  for(i=0; i<nr; i++) {
+    npr.Append(uv_er[i].normParam);
+  }
+  for(i=0; i<nt; i++) {
+    npt.Append(uv_et[i].normParam);
+  }
+  for(i=0; i<nl; i++) {
+    npl.Append(uv_el[i].normParam);
+  }
+
+  // we have to add few values of params to right and left
+  // insert them after first param
+  // insert to right
+  int dr = nbv - nr;
+  double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
+  for(i=1; i<=dr; i++) {
+    npr.InsertAfter(1,npr.Value(2)-dpr);
+  }
+  // insert to left
+  int dl = nbv - nl;
+  dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
+  for(i=1; i<=dl; i++) {
+    npl.InsertAfter(1,npl.Value(2)-dpr);
+  }
+  //cout<<"npb:";
+  //for(i=1; i<=npb.Length(); i++) {
+  //  cout<<" "<<npb.Value(i);
+  //}
+  //cout<<endl;
+  
+  gp_Pnt2d a[4];
+  c2d[0]->D0(uv_eb[0].param,a[0]);
+  c2d[0]->D0(uv_eb[nb-1].param,a[1]);
+  c2d[2]->D0(uv_et[nt-1].param,a[2]);
+  c2d[2]->D0(uv_et[0].param,a[3]);
+  //cout<<" a[0]("<<a[0].X()<<","<<a[0].Y()<<")"<<" a[1]("<<a[1].X()<<","<<a[1].Y()<<")"
+  //    <<" a[2]("<<a[2].X()<<","<<a[2].Y()<<")"<<" a[3]("<<a[3].X()<<","<<a[3].Y()<<")"<<endl;
+
+  int nnn = Min(nr,nl);
+  // auxilary sequence of XY for creation nodes
+  // in the bottom part of central domain
+  // it's length must be == nbv-nnn-1
+  TColgp_SequenceOfXY UVL;
+  TColgp_SequenceOfXY UVR;
+
+  // step1: create faces for left domain
+  StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
+  // add left nodes
+  for(j=1; j<=nl; j++) 
+    NodesL.SetValue(1,j,uv_el[j-1].node);
+  if(dl>0) {
+    // add top nodes
+    for(i=1; i<=dl; i++) 
+      NodesL.SetValue(i+1,nl,uv_et[i].node);
+    // create and add needed nodes
+    TColgp_SequenceOfXY UVtmp;
+    for(i=1; i<=dl; i++) {
+      double x0 = npt.Value(i+1);
+      double x1 = x0;
+      // diagonal node
+      double y0 = npl.Value(i+1);
+      double y1 = npr.Value(i+1);
+      gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+                        c2d[0], c2d[1], c2d[2], c2d[3]);
+      gp_Pnt P = S->Value(UV.X(),UV.Y());
+      SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+      meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+      NodesL.SetValue(i+1,1,N);
+      if(UVL.Length()<nbv-nnn-1) UVL.Append(UV);
+      // internal nodes
+      for(j=2; j<nl; j++) {
+        double y0 = npl.Value(dl+j);
+        double y1 = npr.Value(dl+j);
+        gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+                          c2d[0], c2d[1], c2d[2], c2d[3]);
+        gp_Pnt P = S->Value(UV.X(),UV.Y());
+        SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+        meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+        NodesL.SetValue(i+1,j,N);
+        if( i==dl ) UVtmp.Append(UV);
+      }
+    }
+    for(i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
+      UVL.Append(UVtmp.Value(i));
+    }
+    //cout<<"Dump NodesL:"<<endl;
+    //for(i=1; i<=dl+1; i++) {
+    //  cout<<"i="<<i;
+    //  for(j=1; j<=nl; j++) {
+    //    cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
+    //  }
+    //  cout<<endl;
+    //}
+    // create faces
+    for(i=1; i<=dl; i++) {
+      for(j=1; j<nl; j++) {
+        if(WisF) {
+          SMDS_MeshFace* F =
+            meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
+                            NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
+          meshDS->SetMeshElementOnShape(F, geomFaceID);
+        }
+        else {
+          SMDS_MeshFace* F =
+            meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
+                            NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
+          meshDS->SetMeshElementOnShape(F, geomFaceID);
+        }
+      }
+    }
+  }
+  else {
+    // fill UVL using c2d
+    for(i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
+      gp_Pnt2d p2d;
+      c2d[3]->D0(uv_el[i].param,p2d);
+      UVL.Append(p2d.XY());
+    }
+  }
+
+  // step2: create faces for right domain
+  StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
+  // add right nodes
+  for(j=1; j<=nr; j++) 
+    NodesR.SetValue(1,j,uv_er[nr-j].node);
+  if(dr>0) {
+    // add top nodes
+    for(i=1; i<=dr; i++) 
+      NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
+    // create and add needed nodes
+    TColgp_SequenceOfXY UVtmp;
+    for(i=1; i<=dr; i++) {
+      double x0 = npt.Value(nt-i);
+      double x1 = x0;
+      // diagonal node
+      double y0 = npl.Value(i+1);
+      double y1 = npr.Value(i+1);
+      gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+                        c2d[0], c2d[1], c2d[2], c2d[3]);
+      gp_Pnt P = S->Value(UV.X(),UV.Y());
+      SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+      meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+      NodesR.SetValue(i+1,nr,N);
+      if(UVR.Length()<nbv-nnn-1) UVR.Append(UV);
+      // internal nodes
+      for(j=2; j<nr; j++) {
+        double y0 = npl.Value(nbv-j+1);
+        double y1 = npr.Value(nbv-j+1);
+        gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+                          c2d[0], c2d[1], c2d[2], c2d[3]);
+        gp_Pnt P = S->Value(UV.X(),UV.Y());
+        SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+        meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+        NodesR.SetValue(i+1,j,N);
+        if( i==dr ) UVtmp.Prepend(UV);
+      }
+    }
+    for(i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
+      UVR.Append(UVtmp.Value(i));
+    }
+    // create faces
+    for(i=1; i<=dr; i++) {
+      for(j=1; j<nr; j++) {
+        if(WisF) {
+          SMDS_MeshFace* F =
+            meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
+                            NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
+          meshDS->SetMeshElementOnShape(F, geomFaceID);
+        }
+        else {
+          SMDS_MeshFace* F =
+            meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
+                            NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
+          meshDS->SetMeshElementOnShape(F, geomFaceID);
+        }
+      }
+    }
+  }
+  else {
+    // fill UVR using c2d
+    for(i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
+      gp_Pnt2d p2d;
+      c2d[1]->D0(uv_er[i].param,p2d);
+      UVR.Append(p2d.XY());
+    }
+  }
+
+  // step3: create faces for central domain
+  StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
+  // add first string using NodesL
+  for(i=1; i<=dl+1; i++)
+    NodesC.SetValue(1,i,NodesL(i,1));
+  for(i=2; i<=nl; i++)
+    NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
+  // add last string using NodesR
+  for(i=1; i<=dr+1; i++)
+    NodesC.SetValue(nb,i,NodesR(i,nr));
+  for(i=1; i<nr; i++)
+    NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
+  // add top nodes (last columns)
+  for(i=dl+2; i<nbh-dr; i++) 
+    NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
+  // add bottom nodes (first columns)
+  for(i=2; i<nb; i++) {
+    NodesC.SetValue(i,1,uv_eb[i-1].node);
+    gp_Pnt2d p2d;
+    c2d[0]->D0(uv_eb[i-1].param,p2d);
+  }
+  // create and add needed nodes
+  // add linear layers
+  for(i=2; i<nb; i++) {
+    double x0 = npt.Value(dl+i);
+    double x1 = x0;
+    for(j=1; j<nnn; j++) {
+      double y0 = npl.Value(nbv-nnn+j);
+      double y1 = npr.Value(nbv-nnn+j);
+      gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+                        c2d[0], c2d[1], c2d[2], c2d[3]);
+      gp_Pnt P = S->Value(UV.X(),UV.Y());
+      SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+      meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+      NodesC.SetValue(i,nbv-nnn+j,N);
+    }
+  }
+  // add diagonal layers
+  //cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
+  //cout<<"Dump UVL:"<<endl;
+  //for(i=1; i<=UVL.Length(); i++) {
+  //  cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
+  //}
+  //cout<<endl;
+  for(i=1; i<nbv-nnn; i++) {
+    double du = UVR.Value(i).X() - UVL.Value(i).X();
+    double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
+    for(j=2; j<nb; j++) {
+      double u = UVL.Value(i).X() + du*npb.Value(j);
+      double v = UVL.Value(i).Y() + dv*npb.Value(j);
+      gp_Pnt P = S->Value(u,v);
+      SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+      meshDS->SetNodeOnFace(N, geomFaceID, u, v);
+      NodesC.SetValue(j,i+1,N);
+    }
+  }
+  // create faces
+  for(i=1; i<nb; i++) {
+    for(j=1; j<nbv; j++) {
+      if(WisF) {
+        SMDS_MeshFace* F =
+          meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
+                          NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
+        meshDS->SetMeshElementOnShape(F, geomFaceID);
+      }
+      else {
+        SMDS_MeshFace* F =
+          meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
+                          NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
+        meshDS->SetMeshElementOnShape(F, geomFaceID);
+      }
+    }
+  }
+
+  QuadDelete(quad);
+  bool isOk = true;
+  return isOk;
+}
+
+
+//=============================================================================
+/*!
+ *  LoadEdgePoints2
+ */
+//=============================================================================
+UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
+                                                       const TopoDS_Face& F,
+                                                       const TopoDS_Edge& E,
+                                                       bool IsReverse)
+{
+  //MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
+  // --- IDNodes of first and last Vertex
+  TopoDS_Vertex VFirst, VLast;
+  TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+
+  ASSERT(!VFirst.IsNull());
+  SMDS_NodeIteratorPtr lid = aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
+  if (!lid->more()) {
+    MESSAGE ( "NO NODE BUILT ON VERTEX" );
+    return 0;
+  }
+  const SMDS_MeshNode* idFirst = lid->next();
+
+  ASSERT(!VLast.IsNull());
+  lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
+  if (!lid->more()) {
+    MESSAGE ( "NO NODE BUILT ON VERTEX" );
+    return 0;
+  }
+  const SMDS_MeshNode* idLast = lid->next();
+
+  // --- edge internal IDNodes (relies on good order storage, not checked)
+
+  map<double, const SMDS_MeshNode *> params;
+  SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
+
+  while(ite->more()) {
+    const SMDS_MeshNode* node = ite->next();
+    const SMDS_EdgePosition* epos =
+      static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+    double param = epos->GetUParameter();
+    params[param] = node;
+  }
+
+  int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+  if (nbPoints != params.size()) {
+    MESSAGE( "BAD NODE ON EDGE POSITIONS" );
+    return 0;
+  }
+  UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2];
+
+  double f, l;
+  Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+
+  const TopoDS_Wire& W = BRepTools::OuterWire(F);
+  bool FisF = (F.Orientation()==TopAbs_FORWARD);
+  bool WisF = (W.Orientation()==TopAbs_FORWARD);
+  bool isForward = (E.Orientation()==TopAbs_FORWARD);
+  //if(isForward) cout<<"E is FORWARD"<<endl;
+  //else cout<<"E is REVERSED"<<endl;
+  if(!WisF) isForward = !isForward;
+  if(!FisF) isForward = !isForward;
+  //bool isForward = !(E.Orientation()==TopAbs_FORWARD);
+  if(IsReverse) isForward = !isForward;
+  double paramin = 0;
+  double paramax = 0;
+  if (isForward) {
+    paramin = f;
+    paramax = l;
+    gp_Pnt2d p = C2d->Value(f);        // first point = Vertex Forward
+    uvslf[0].x = p.X();
+    uvslf[0].y = p.Y();
+    uvslf[0].param = f;
+    uvslf[0].node = idFirst;
+    //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+    map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
+    for (int i = 1; i <= nbPoints; i++)        { // nbPoints internal
+      double param = (*itp).first;
+      gp_Pnt2d p = C2d->Value(param);
+      uvslf[i].x = p.X();
+      uvslf[i].y = p.Y();
+      uvslf[i].param = param;
+      uvslf[i].node = (*itp).second;
+      //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+      itp++;
+    }
+    p = C2d->Value(l);         // last point = Vertex Reversed
+    uvslf[nbPoints + 1].x = p.X();
+    uvslf[nbPoints + 1].y = p.Y();
+    uvslf[nbPoints + 1].param = l;
+    uvslf[nbPoints + 1].node = idLast;
+    //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+  }
+  else {
+    paramin = l;
+    paramax = f;
+    gp_Pnt2d p = C2d->Value(l);        // first point = Vertex Reversed
+    uvslf[0].x = p.X();
+    uvslf[0].y = p.Y();
+    uvslf[0].param = l;
+    uvslf[0].node = idLast;
+    //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+    map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
+    for (int j = nbPoints; j >= 1; j--)        { // nbPoints internal
+      double param = (*itp).first;
+      int i = nbPoints + 1 - j;
+      gp_Pnt2d p = C2d->Value(param);
+      uvslf[i].x = p.X();
+      uvslf[i].y = p.Y();
+      uvslf[i].param = param;
+      uvslf[i].node = (*itp).second;
+      //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+      itp++;
+    }
+    p = C2d->Value(f);         // last point = Vertex Forward
+    uvslf[nbPoints + 1].x = p.X();
+    uvslf[nbPoints + 1].y = p.Y();
+    uvslf[nbPoints + 1].param = f;
+    uvslf[nbPoints + 1].node = idFirst;
+    //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+  }
+
+  ASSERT(paramin != paramax);
+  for (int i = 0; i < nbPoints + 2; i++) {
+    uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
+  }
+
+  return uvslf;
+}
+
+
 //=============================================================================
 /*!
  *  LoadEdgePoints
index 4d02719..afb3498 100644 (file)
@@ -87,11 +87,27 @@ public:
 
 protected:
 
+  FaceQuadStruct* CheckNbEdges(SMESH_Mesh& aMesh,
+                               const TopoDS_Shape& aShape)
+    throw (SALOME_Exception);
+
   void SetNormalizedGrid(SMESH_Mesh& aMesh,
                         const TopoDS_Shape& aShape,
                         FaceQuadStruct* quad)
     throw (SALOME_Exception);
 
+  /**
+   * Special function for creation only quandrangle faces
+   */
+  bool ComputeQuadPref(SMESH_Mesh& aMesh,
+                       const TopoDS_Shape& aShape,
+                       FaceQuadStruct* quad)
+    throw (SALOME_Exception);
+
+  UVPtStruct* LoadEdgePoints2(SMESH_Mesh& aMesh,
+                             const TopoDS_Face& F, const TopoDS_Edge& E,
+                              bool IsReverse);
+
   UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
                             const TopoDS_Face& F, const TopoDS_Edge& E,
                             double first, double last);
index 6bc2ca7..1723d65 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
-
 #include "StdMeshers_Regular_1D.hxx"
 #include "StdMeshers_Distribution.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
 
-#include <OSD.hxx>
-
 #include "StdMeshers_LocalLength.hxx"
 #include "StdMeshers_NumberOfSegments.hxx"
 #include "StdMeshers_Arithmetic1D.hxx"
 #include "StdMeshers_StartEndLength.hxx"
 #include "StdMeshers_Deflection1D.hxx"
-#include <StdMeshers_AutomaticLength.hxx>
+#include "StdMeshers_AutomaticLength.hxx"
 
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
@@ -66,10 +62,13 @@ using namespace std;
 #include <Expr_Array1OfNamedUnknown.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <ExprIntrp_GenExp.hxx>
+#include <OSD.hxx>
 
 #include <string>
 #include <math.h>
 
+using namespace std;
+
 //=============================================================================
 /*!
  *  
index 1d70162..4632076 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
-
 #include "StdMeshers_StartEndLength.hxx"
-#include "utilities.h"
 
+#include "SMESH_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
 
 //=============================================================================
 /*!
@@ -43,7 +54,7 @@ StdMeshers_StartEndLength::StdMeshers_StartEndLength(int         hypId,
      :SMESH_Hypothesis(hypId, studyId, gen)
 {
   _begLength = 1.;
-  _endLength = 1.;
+  _endLength = 10.;
   _name = "StartEndLength";
   _param_algo_dim = 1; // is used by SMESH_Regular_1D
 }
@@ -141,3 +152,49 @@ istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp)
 {
   return hyp.LoadFrom( load );
 }
+
+//================================================================================
+/*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_StartEndLength::SetParametersByMesh(const SMESH_Mesh*   theMesh,
+                                                    const TopoDS_Shape& theShape)
+{
+  if ( !theMesh || theShape.IsNull() )
+    return false;
+
+  _begLength = _endLength = 0.;
+
+  Standard_Real UMin, UMax;
+  TopLoc_Location L;
+
+  int nbEdges = 0;
+  TopTools_IndexedMapOfShape edgeMap;
+  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+  for ( int i = 1; i <= edgeMap.Extent(); ++i )
+  {
+    const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+    Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
+    GeomAdaptor_Curve AdaptCurve(C);
+
+    vector< double > params;
+    SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+    if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+    {
+      nbEdges++;
+      _begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
+      int nb = params.size();
+      _endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
+    }
+  }
+  if ( nbEdges ) {
+    _begLength /= nbEdges;
+    _endLength /= nbEdges;
+  }
+  return nbEdges;
+}
index 05bd2e0..52a8a58 100644 (file)
@@ -41,12 +41,21 @@ class StdMeshers_StartEndLength:public SMESH_Hypothesis
 
   double GetLength(bool isStartLength) const;
   
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp);
-  friend istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp);
+  friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp);
 
- protected:
+
+  /*!
+   * \brief Initialize start and end length by the mesh built on the geometry
+    * \param theMesh - the built mesh
+    * \param theShape - the geometry of interest
+    * \retval bool - true if parameter values have been successfully defined
+   */
+  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+protected:
   double _begLength, _endLength;
 };
 
diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx
deleted file mode 100644 (file)
index 29205f4..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-//  SMESH StdMeshersGUI : GUI for StdMeshers plugin
-//
-//  Copyright (C) 2003  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. 
-// 
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : StdMeshersGUI_CreateStdHypothesisDlg.cxx
-//           Moved here from SMESHGUI_CreateStdHypothesisDlg.cxx
-//  Author : Nicolas REJNERI
-//  Module : SMESH
-//  $Header$
-
-using namespace std;
-#include "StdMeshersGUI_CreateStdHypothesisDlg.h"
-#include "StdMeshersGUI_Parameters.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_Hypotheses.h"
-
-#include "utilities.h"
-
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_OverrideCursor.h"
-#include "SUIT_Desktop.h"
-
-//=================================================================================
-// class    : StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose  : 
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType,
-                                                                            QWidget* parent,
-                                                                            const char* name,
-                                                                            bool /*modal*/,
-                                                                            WFlags fl)
-     : StdMeshersGUI_CreateHypothesisDlg (hypType, parent, name, true, fl)
-{
-  QString hypTypeStr;
-  if (hypType.compare("LocalLength") == 0)
-    hypTypeStr = "LOCAL_LENGTH";
-  else if (hypType.compare("NumberOfSegments") == 0)
-    hypTypeStr = "NB_SEGMENTS";
-  else if (hypType.compare("MaxElementArea") == 0)
-    hypTypeStr = "MAX_ELEMENT_AREA";
-  else if (hypType.compare("MaxElementVolume") == 0)
-    hypTypeStr = "MAX_ELEMENT_VOLUME";
-  else if (hypType.compare("StartEndLength") == 0)
-    hypTypeStr = "START_END_LENGTH";
-  else if (hypType.compare("Deflection1D") == 0)
-    hypTypeStr = "DEFLECTION1D";
-  else if (hypType.compare("Arithmetic1D") == 0)
-    hypTypeStr = "ARITHMETIC_1D";
-  else if (hypType.compare("AutomaticLength") == 0)
-    hypTypeStr = "AUTOMATIC_LENGTH";
-  else
-    return;
-
-  QString caption( tr ( QString( "SMESH_%1_TITLE" ).arg( hypTypeStr )));
-  QString hypTypeName( tr ( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeStr )));
-  QString hypIconName( tr ( QString( "ICON_DLG_%1" ).arg( hypTypeStr )));
-
-  CreateDlgLayout(caption,
-                  SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName ),
-                  hypTypeName);
-}
-
-//=================================================================================
-// function : ~StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose  : Destroys the object and frees any allocated resources
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::~StdMeshersGUI_CreateStdHypothesisDlg()
-{
-    // no need to delete child widgets, Qt does it all for us
-}
-//=================================================================================
-// function : FillParameters()
-// purpose  :
-//=================================================================================
-void StdMeshersGUI_CreateStdHypothesisDlg::GetParameters
-  (const QString &                     hypType,
-   std::list<SMESHGUI_aParameterPtr> & params)
-{
-  StdMeshersGUI_Parameters::GetParameters( hypType, params );
-}
-
-//=================================================================================
-// function : SetParameters()
-// purpose  :
-//=================================================================================
-bool StdMeshersGUI_CreateStdHypothesisDlg::SetParameters
-  (SMESH::SMESH_Hypothesis_ptr theHyp, const list<SMESHGUI_aParameterPtr> & params)
-{
-  StdMeshersGUI_Parameters::SetParameters( theHyp, params );
-  return true;
-}
index f763fbd..0d66dc5 100644 (file)
@@ -19,8 +19,8 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
 {
   myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h );
   myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
-  myCurve1 = insertCurve( QString() );
-  myCurve2 = insertCurve( QString() );
+  myDensity = insertCurve( QString() );
+  myDistr = insertCurve( QString() );
   myMsg = insertMarker( new QwtPlotMarker( this ) );
   setMarkerPos( myMsg, 0.5, 0.5 );
   setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) );
@@ -28,11 +28,16 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
   f.setPointSize( 14 );
   f.setBold( true );
   setMarkerFont( myMsg, f );
-  setCurvePen( myCurve1, QPen( Qt::red, 1 ) );
+  setCurvePen( myDensity, QPen( Qt::red, 1 ) );
 
   QColor dc = Qt::blue;
-  setCurvePen( myCurve2, QPen( dc, 1 ) );
-  setCurveSymbol( myCurve2, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+  setCurvePen( myDistr, QPen( dc, 1 ) );
+  setCurveSymbol( myDistr, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+  setAutoLegend( true );
+  enableLegend( true );
+  setLegendPos( Qwt::Bottom );
+  setCurveTitle( myDensity, tr( "SMESH_DENSITY_FUNC" ) );
+  setCurveTitle( myDistr, tr( "SMESH_DISTR" ) );
 }
 
 StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview()
@@ -196,9 +201,9 @@ void StdMeshersGUI_DistrPreview::update()
       max_x = x[i];
   }
 
-  setAxisScale( curveXAxis( myCurve1 ), min_x, max_x );
-  setAxisScale( curveYAxis( myCurve1 ), min( 0.0, min_y ), max( 0.0, max_y ) );
-  setCurveData( myCurve1, x, y, size );
+  setAxisScale( curveXAxis( myDensity ), min_x, max_x );
+  setAxisScale( curveYAxis( myDensity ), min( 0.0, min_y ), max( 0.0, max_y ) );
+  setCurveData( myDensity, x, y, size );
   if( x )
     delete[] x;
   if( y )
@@ -213,19 +218,33 @@ void StdMeshersGUI_DistrPreview::update()
     x[i] = distr[i];
     y[i] = 0;
   }
-  setCurveData( myCurve2, x, y, size );
+  setCurveData( myDistr, x, y, size );
   delete[] x;
   delete[] y;
   x = y = 0;
-  replot();
+
+  OSD::SetSignal( true );
+  CASCatch_CatchSignals aCatchSignals;
+  aCatchSignals.Activate();
+
+  CASCatch_TRY
+  {   
+    replot();
+  }
+  CASCatch_CATCH(CASCatch_Failure)
+  {
+    aCatchSignals.Deactivate();
+    Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+  }
+  aCatchSignals.Deactivate();
 }
 
 void StdMeshersGUI_DistrPreview::showError()
 {
-  setAxisScale( curveXAxis( myCurve1 ), 0.0, 1.0 );
-  setAxisScale( curveYAxis( myCurve1 ), 0.0, 1.0 );
-  setCurveData( myCurve1, 0, 0, 0 );
-  setCurveData( myCurve2, 0, 0, 0 );
+  setAxisScale( curveXAxis( myDensity ), 0.0, 1.0 );
+  setAxisScale( curveYAxis( myDensity ), 0.0, 1.0 );
+  setCurveData( myDensity, 0, 0, 0 );
+  setCurveData( myDistr, 0, 0, 0 );
   setMarkerLabel( myMsg, tr( "SMESH_INVALID_FUNCTION" ) );
   replot();
 }
index 5a3551d..2246588 100644 (file)
@@ -48,7 +48,7 @@ private:
   bool                      myIsTable;
   Conversion                myConv;
   SMESH::double_array       myTableFunc;
-  long                      myCurve1, myCurve2, myMsg;
+  long                      myDensity, myDistr, myMsg;
   Handle(ExprIntrp_GenExp)  myExpr;
   Expr_Array1OfNamedUnknown myVars;
   TColStd_Array1OfReal      myValues;
index db0b7f3..31eeae6 100644 (file)
 //  $Header$
 
 #include "StdMeshersGUI_DistrTable.h"
+#include <QtxDblValidator.h>
+
 #include <qlayout.h>
 #include <qpushbutton.h>
-#include <qvalidator.h>
 #include <qlineedit.h>
 
 //=================================================================================
@@ -40,8 +41,8 @@ StdMeshersGUI_DistrTable::StdMeshersGUI_DistrTable( const int rows, QWidget* par
 {
   horizontalHeader()->setLabel( 0, "t" );
   horizontalHeader()->setLabel( 1, "f(t)" );
-  myArgV = new QDoubleValidator( 0.0, 1.0, 3, this );
-  myFuncV = new QDoubleValidator( 0.0, 1E10, 3, this );
+  myArgV = new QtxDblValidator( 0.0, 1.0, 3, this );
+  myFuncV = new QtxDblValidator( 0.0, 1E20, 3, this );
 }
 
 StdMeshersGUI_DistrTable::~StdMeshersGUI_DistrTable()
@@ -70,6 +71,14 @@ void StdMeshersGUI_DistrTable::stopEditing( const bool accept )
   endEdit( currEditRow(), currEditCol(), accept, false );
 }
 
+QWidget* StdMeshersGUI_DistrTable::beginEdit( int row, int col, bool replace )
+{
+  QWidget* w = QTable::beginEdit( row, col, replace );
+  if( w && w->inherits( "QLineEdit" ) )
+    ( ( QLineEdit* )w )->selectAll();
+  return w;
+}
+
 void StdMeshersGUI_DistrTable::edit( const int r, const int c )
 {
   if( isEditing() )
@@ -265,8 +274,24 @@ void StdMeshersGUI_DistrTable::setData( const SMESH::double_array& d )
 {
   stopEditing( false );
   setNumRows( d.length()/2 );
+  QString val;
   for( int i=0; i<d.length(); i++ )
-    setText( i/2, i%2, QString( "%1" ).arg( d[i] ) );
+  {
+    QtxDblValidator* v = i%2==0 ? myArgV : myFuncV;
+    val = QString::number( d[i] );
+    v->fixup( val );
+    setText( i/2, i%2, val );
+  }
+}
+
+QtxDblValidator* StdMeshersGUI_DistrTable::argValidator() const
+{
+  return myArgV;
+}
+
+QtxDblValidator* StdMeshersGUI_DistrTable::funcValidator() const
+{
+  return myFuncV;
 }
 
 //=================================================================================
@@ -346,3 +371,4 @@ void StdMeshersGUI_DistrTableFrame::onButtonClicked()
   else if( sender()==button( REMOVE_ROW ) )
     emit toEdit( REMOVE_ROW, table()->currentRow() );
 }
+
index 6f6ca82..a6f7f61 100644 (file)
@@ -34,7 +34,7 @@
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 class QButton;
-class QDoubleValidator;
+class QtxDblValidator;
 
 /*!
  *  \brief Values corresponding to buttons for table resize
@@ -65,17 +65,21 @@ public:
   void data( SMESH::double_array& );
   void setData( const SMESH::double_array& );
 
+  QtxDblValidator* argValidator() const;
+  QtxDblValidator* funcValidator() const;
+
 protected:
   virtual QWidget* createEditor( int, int, bool ) const;
   virtual bool     eventFilter( QObject*, QEvent* );
   virtual void     keyPressEvent( QKeyEvent* );
+  virtual QWidget* beginEdit( int row, int col, bool replace );
   virtual void     edit( const int, const int );
 
 private slots:
   void onEdit( TableButton, int );
 
 private:
-  QDoubleValidator   *myArgV, *myFuncV;
+  QtxDblValidator   *myArgV, *myFuncV;
 };
 
 
@@ -122,6 +126,5 @@ private:
   StdMeshersGUI_DistrTable  *myTable;
 };
 
-
 #endif
 
index a071169..f190fb2 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <QtxIntSpinBox.h>
 #include <QtxComboBox.h>
+#include <QtxDblValidator.h>
 #include <SMESHGUI_SpinBox.h>
 
 #include <qlabel.h>
@@ -142,7 +143,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
   myConv->setColumnLayout( 0, Qt::Vertical );
   QGridLayout* convLay = new QGridLayout( myConv->layout() );
   convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
-  convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
+  convLay->addWidget( myCutNeg = new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
   myGroupLayout->addWidget( myConv, row, 1 );
   row++;
 
@@ -176,17 +177,59 @@ void StdMeshersGUI_NbSegmentsCreator::retrieveParams() const
   myExpr->setText( data.myExpr );
 }
 
-void StdMeshersGUI_NbSegmentsCreator::storeParams() const
+QString StdMeshersGUI_NbSegmentsCreator::storeParams() const
 {
   NbSegmentsHypothesisData data;
   readParamsFromWidgets( data );
   storeParamsToHypo( data );
+
+  QString valStr = QString::number( data.myNbSeg ) += "; ";
+
+  enum DistrType
+  {
+    Regular, //!< equidistant distribution
+    Scale,   //!< scale distribution
+    TabFunc, //!< distribution with density function presented by table
+    ExprFunc //!< distribution with density function presented by expression
+  };
+  bool hasConv = false;
+  switch ( data.myDistrType ) {
+  case Regular :
+    valStr += tr("SMESH_DISTR_REGULAR");
+    break;
+  case Scale   :
+    valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );
+    break;
+  case TabFunc : {
+    //valStr += tr("SMESH_TAB_FUNC");
+    bool param = true;
+    for( int i=0; i < data.myTable.length(); i++, param = !param ) {
+      if ( param )
+        valStr += "[";
+      valStr += QString::number( data.myTable[ i ]);
+      valStr += ( param ? "," : "]" );
+    }
+    hasConv = true;
+    break;
+  }
+  case ExprFunc:
+    valStr += data.myExpr;
+    hasConv = true;
+    break;
+  }
+  if ( hasConv )
+    if ( data.myConv )
+      valStr += "; " + tr("SMESH_CUT_NEG_MODE");
+    else
+      valStr += "; " + tr("SMESH_EXP_MODE");
+
+  return valStr;
 }
 
 bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisData& h_data ) const
 {
   StdMeshers::StdMeshers_NumberOfSegments_var h =
-    StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+    StdMeshers::StdMeshers_NumberOfSegments::_narrow( initParamsHypothesis() );
 
   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
   h_data.myName = isCreation() && data ? data->Label : "";
@@ -270,6 +313,19 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
 {
   int distr = myDistr->currentItem();
 
+/*  if( distr==2 ) //table func
+    myCutNeg->setText( tr( "SMESH_NO_CONV" ) );
+  else if( distr==3 )
+    myCutNeg->setText( tr( "SMESH_CUT_NEG_MODE" ) );*/
+
+  if( distr==2 && sender()==myConv ) //table func
+  {
+    myTable->table()->funcValidator()->setBottom( myConv->id( myConv->selected() )==0 ? -1E20 : 0 );
+    SMESH::double_array arr;
+    myTable->table()->data( arr );
+    myTable->table()->setData( arr ); //update data in table
+  }
+
   myScale->setShown( distr==1 );
   myLScale->setShown( distr==1 );
 
index 26ca099..6d902fe 100644 (file)
@@ -15,6 +15,7 @@ class StdMeshersGUI_DistrPreview;
 class QLineEdit;
 class QButtonGroup;
 class QGridLayout;
+class QRadioButton;
 
 typedef struct
 {
@@ -38,7 +39,7 @@ public:
 protected:
   virtual QFrame*  buildFrame();
   virtual void     retrieveParams() const;
-  virtual void     storeParams() const;
+  virtual QString  storeParams() const;
 
 protected slots:
   virtual void     onValueChanged();
@@ -59,6 +60,7 @@ private:
   QLabel          *myLScale, *myLTable, *myLExpr, *myLConv, *myInfo;
   QGridLayout*     myGroupLayout;
   int              myTableRow, myPreviewRow;
+  QRadioButton*    myCutNeg;
 };
 
 #endif
diff --git a/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx b/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx