]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0021336: EDF 1717 SMESH: New algorithm "body fitting" cartesian unstructured
authoreap <eap@opencascade.com>
Fri, 28 Oct 2011 12:57:18 +0000 (12:57 +0000)
committereap <eap@opencascade.com>
Fri, 28 Oct 2011 12:57:18 +0000 (12:57 +0000)
13 files changed:
src/StdMeshersGUI/Makefile.am
src/StdMeshersGUI/StdMeshersGUI.cxx
src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx [new file with mode: 0644]
src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.h [new file with mode: 0644]
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
src/StdMeshersGUI/StdMeshers_images.ts
src/StdMeshersGUI/StdMeshers_msg_en.ts
src/StdMeshers_I/Makefile.am
src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.cxx [new file with mode: 0644]
src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx [new file with mode: 0644]
src/StdMeshers_I/StdMeshers_Cartesian_3D_i.cxx [new file with mode: 0644]
src/StdMeshers_I/StdMeshers_Cartesian_3D_i.hxx [new file with mode: 0644]
src/StdMeshers_I/StdMeshers_i.cxx

index f1824090291a6b96af177e47a9e5da73e4b5cc09..fe0dee7ce1f60d3aeeb9ce77ce878065386db488 100644 (file)
@@ -34,7 +34,8 @@ salomeinclude_HEADERS = \
        StdMeshersGUI_QuadrangleParamWdg.h \
        StdMeshersGUI_LayerDistributionParamWdg.h \
        StdMeshersGUI_FixedPointsParamWdg.h \
-       StdMeshersGUI_SubShapeSelectorWdg.h
+       StdMeshersGUI_SubShapeSelectorWdg.h \
+       StdMeshersGUI_CartesianParamCreator.h
 
 # Libraries targets
 lib_LTLIBRARIES = libStdMeshersGUI.la
@@ -49,7 +50,8 @@ dist_libStdMeshersGUI_la_SOURCES = \
        StdMeshersGUI_QuadrangleParamWdg.cxx \
        StdMeshersGUI_LayerDistributionParamWdg.cxx \
        StdMeshersGUI_FixedPointsParamWdg.cxx \
-       StdMeshersGUI_SubShapeSelectorWdg.cxx
+       StdMeshersGUI_SubShapeSelectorWdg.cxx \
+       StdMeshersGUI_CartesianParamCreator.cxx
 
 MOC_FILES = \
        StdMeshersGUI_StdHypothesisCreator_moc.cxx \
@@ -60,7 +62,8 @@ MOC_FILES = \
        StdMeshersGUI_QuadrangleParamWdg_moc.cxx \
        StdMeshersGUI_LayerDistributionParamWdg_moc.cxx \
        StdMeshersGUI_FixedPointsParamWdg_moc.cxx \
-       StdMeshersGUI_SubShapeSelectorWdg_moc.cxx
+       StdMeshersGUI_SubShapeSelectorWdg_moc.cxx \
+       StdMeshersGUI_CartesianParamCreator_moc.cxx
 
 nodist_libStdMeshersGUI_la_SOURCES= \
        $(MOC_FILES)
index efe3f1283c4c754fd11554dea1082765e3c692b5..b311ff8e386f5545d249d403a139e7d0391bc14a 100644 (file)
@@ -26,6 +26,7 @@
 //
 #include "StdMeshersGUI_StdHypothesisCreator.h"
 #include "StdMeshersGUI_NbSegmentsCreator.h"
+#include "StdMeshersGUI_CartesianParamCreator.h"
 
 //=============================================================================
 /*! GetHypothesisCreator
@@ -39,6 +40,8 @@ extern "C"
   {
     if( aHypType=="NumberOfSegments" )
       return new StdMeshersGUI_NbSegmentsCreator();
+    else if ( aHypType=="CartesianParameters3D" )
+      return new StdMeshersGUI_CartesianParamCreator( aHypType );
     else
       return new StdMeshersGUI_StdHypothesisCreator( aHypType );
   }
diff --git a/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx
new file mode 100644 (file)
index 0000000..1a54a45
--- /dev/null
@@ -0,0 +1,690 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : StdMeshersGUI_CartesianParamCreator.cxx
+// Author : Open CASCADE S.A.S.
+// SMESH includes
+//
+#include "StdMeshersGUI_CartesianParamCreator.h"
+
+#include <SMESHGUI.h>
+#include <SMESHGUI_Utils.h>
+#include <SMESHGUI_HypothesesUtils.h>
+#include <SMESHGUI_SpinBox.h>
+
+// IDL includes
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+// SALOME GUI includes
+#include <SalomeApp_Tools.h>
+#include <SalomeApp_IntSpinBox.h>
+#include <QtxComboBox.h>
+
+// Qt includes
+#include <QAbstractItemModel>
+#include <QApplication>
+#include <QButtonGroup>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QModelIndex>
+#include <QRadioButton>
+#include <QString>
+#include <QStyleOptionViewItem>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QTabWidget>
+
+#define SPACING 6
+#define MARGIN  11
+
+namespace StdMeshersGUI
+{
+  enum { COORD_BUT = 0, SPACING_BUT };
+
+  //================================================================================
+  /*!
+   * \brief get spacing definition from a tree item
+   */
+  //================================================================================
+
+  void getFromItem(QTreeWidgetItem * item, double& t0, double& t1, QString& fun )
+  {
+    if ( item )
+    {
+      t0 = item->text( 0 ).split(' ')[0].toDouble();
+      t1 = item->data( 0, Qt::UserRole ).toDouble();
+      fun = item->text( 1 );
+    }
+  }
+
+  //================================================================================
+  /*!
+   * \brief set spacing definition to a tree item
+   */
+  //================================================================================
+
+  QTreeWidgetItem* setToItem(double t0, double t1, const QString& fun, QTreeWidgetItem * item)
+  {
+    if ( !item ) item = new QTreeWidgetItem;
+    item->setText( 0, QString( "%1 - %2" ).arg( t0 ).arg( t1 ));
+    item->setData( 0, Qt::UserRole, t1 );
+    item->setText( 1, fun );
+    item->setFlags( item->flags() | Qt::ItemIsEditable );
+    return item;
+  }
+
+  //================================================================================
+  /*!
+   * \brief Retrieves coordinate value from a list item
+   */
+  //================================================================================
+
+  double coordFromItem( QListWidgetItem * item )
+  {
+    return item ? item->data( Qt::UserRole ).toDouble() : 0;
+  }
+
+  //================================================================================
+  /*!
+   * \brief Sets coordinate value to a list item
+   */
+  //================================================================================
+
+  QListWidgetItem* coordToItem( double coord, QListWidgetItem * item )
+  {
+    if ( !item ) item = new QListWidgetItem;
+    item->setText( QString::number( coord ));
+    item->setData( Qt::UserRole, coord );
+    item->setFlags( item->flags() | Qt::ItemIsEditable );
+    return item;
+  }
+
+  //================================================================================
+  /*!
+   * \brief Constructor
+   * \param theParent - Parent widget for this tab
+   * 
+   * Makes tab's look and feel
+   */
+  //================================================================================
+
+  GridAxisTab::GridAxisTab( QWidget* theParent,const int axisIndex ):
+    QFrame( theParent ), myAxisIndex( axisIndex )
+  {
+    // 1) Grid definition mode
+    myModeGroup = new QButtonGroup( this );
+    QGroupBox* modeBox = new QGroupBox( tr( "GRID_DEF_MODE" ), this );
+    QHBoxLayout* modeLay = new QHBoxLayout( modeBox );
+    modeLay->setMargin( MARGIN );
+    modeLay->setSpacing( SPACING );
+
+    QRadioButton* coordModeBtn = new QRadioButton( tr( "SMESH_COORDINATES" ), modeBox );
+    QRadioButton* spacModeBtn  = new QRadioButton( tr( "SPACING" ), modeBox );
+
+    modeLay->addWidget( coordModeBtn );
+    modeLay->addWidget( spacModeBtn );
+    myModeGroup->addButton( coordModeBtn, COORD_BUT );
+    myModeGroup->addButton( spacModeBtn,  SPACING_BUT );
+
+    // 2) Buttons + Step
+    myInsertBtn = new QPushButton( tr("INSERT"), this);
+    myDeleteBtn = new QPushButton( tr("SMESH_BUT_DELETE"), this);
+
+    myStepLabel = new QLabel( tr("COORD_STEP"));
+    myStepSpin  = new SMESHGUI_SpinBox( this );
+    myStepSpin->setAcceptNames( false ); // No Notebook variables allowed
+    myStepSpin->RangeStepAndValidator();
+    myStepSpin->SetStep( 1. );
+    myStepSpin->SetValue( myStep = 1. );
+
+    // 3) Coodrinates/Spacing group
+    QFrame* csFrame = new QFrame( this );
+    QVBoxLayout* scLay = new QVBoxLayout( csFrame );
+    scLay->setMargin( 0 );
+    scLay->setSpacing( SPACING );
+
+    // 3.1) Spacing
+    mySpacingTreeWdg = new QTreeWidget( csFrame );
+    mySpacingTreeWdg->setColumnCount(2);
+    mySpacingTreeWdg->setHeaderLabels( QStringList() << tr( "SMESH_RANGE" ) << QString( "f(t)" ));
+    mySpacingTreeWdg->setColumnWidth( 1, 40 );
+    mySpacingTreeWdg->setColumnWidth( 2, 30 );
+    mySpacingTreeWdg->setItemDelegate( new LineDelegate( mySpacingTreeWdg ));
+    scLay->addWidget( mySpacingTreeWdg );
+
+    // 3.2) Coordinates
+    myCoordList = new QListWidget( csFrame );
+    myCoordList->setItemDelegate( new LineDelegate( myCoordList ));
+    scLay->addWidget( myCoordList );
+
+    // layouting
+
+    QGridLayout* axisTabLayout = new QGridLayout( this );
+    axisTabLayout->setMargin( MARGIN );
+    axisTabLayout->setSpacing( SPACING );
+
+    axisTabLayout->addWidget( modeBox    , 0, 0, 1, 3 );
+    axisTabLayout->addWidget( myInsertBtn  , 1, 0, 1, 2 );
+    axisTabLayout->addWidget( myDeleteBtn  , 2, 0, 1, 2 );
+    axisTabLayout->addWidget( myStepLabel, 3, 0 );
+    axisTabLayout->addWidget( myStepSpin , 3, 1 );
+    axisTabLayout->addWidget( csFrame    , 1, 2, 4, 1 );
+
+    axisTabLayout->setRowStretch( 4, 1 );
+
+    // signals
+    connect( myInsertBtn,      SIGNAL( clicked() ),             SLOT( onInsert() ));
+    connect( myDeleteBtn,      SIGNAL( clicked() ),             SLOT( onDelete() ));
+    connect( myModeGroup,      SIGNAL( buttonClicked ( int )),  SLOT( onMode(int)));
+    connect( mySpacingTreeWdg, SIGNAL( itemSelectionChanged()), SLOT( updateButtons() ));
+    connect( myCoordList,      SIGNAL( itemSelectionChanged()), SLOT( updateButtons() ));
+    connect( myStepSpin,       SIGNAL( valueChanged(double)),   SLOT( onStepChange() ));
+  }
+
+  void GridAxisTab::onInsert()
+  {
+    if ( isGridBySpacing() )
+    {
+      QTreeWidgetItem * item = mySpacingTreeWdg->currentItem();
+      if ( !item ) item = mySpacingTreeWdg->topLevelItem( 0 );
+      int i = mySpacingTreeWdg->indexOfTopLevelItem( item );
+
+      double t0, t1; QString fun;
+      getFromItem( item, t0, t1, fun );
+      double t = 0.5 * ( t0 + t1 );
+      setToItem( t0, t, fun, item );
+
+      item = setToItem( t, t1, fun );
+      if ( i == mySpacingTreeWdg->topLevelItemCount()-1 )
+        mySpacingTreeWdg->addTopLevelItem( item );
+      else
+        mySpacingTreeWdg->insertTopLevelItem( i+1, item );
+      mySpacingTreeWdg->setCurrentItem( item );
+    }
+    else
+    {
+      if ( myCoordList->count() == 0 )
+      {
+        myCoordList->addItem( coordToItem( 0 ));
+      }
+      else
+      {
+        double coord = coordFromItem( myCoordList->currentItem() ) + myStep;
+        int i = myCoordList->currentRow();
+        while ( i > 0 && coordFromItem( myCoordList->item( i-1 )) > coord )
+          --i;
+        while ( i < myCoordList->count() && coordFromItem( myCoordList->item( i )) < coord )
+          ++i;
+        const double tol = 1e-6;
+        const bool isSame = 
+          ( i < myCoordList->count() && coordFromItem( myCoordList->item( i )) - coord < tol ) ||
+          ( i > 0 && coord - coordFromItem( myCoordList->item( i-1 )) < tol );
+        if ( !isSame )
+          myCoordList->insertItem( i, coordToItem( coord ));
+        else if ( myStep < 0 )
+          --i;
+        myCoordList->setCurrentRow( i );
+      }
+    }
+    updateButtons();
+  }
+
+  void GridAxisTab::onDelete()
+  {
+    if ( isGridBySpacing() )
+    {
+      QList<QTreeWidgetItem *> selItems = mySpacingTreeWdg->selectedItems();
+      QTreeWidgetItem * item;
+      foreach ( item, selItems )
+      {
+        int i = mySpacingTreeWdg->indexOfTopLevelItem( item );
+        if ( i == 0 ) continue; 
+        QTreeWidgetItem* prevItem = mySpacingTreeWdg->topLevelItem( i-1 );
+
+        double t0, t1, t2; QString fun;
+        getFromItem( item, t1, t2, fun );
+        getFromItem( prevItem, t0, t1, fun );
+        delete item;
+
+        setToItem( t0, t2, fun, prevItem );
+      }
+    }
+    else
+    {
+      if ( myCoordList->count() > 2 )
+        if ( QListWidgetItem * item = myCoordList->currentItem() )
+          delete item;
+    }
+    updateButtons();
+  }
+
+  void GridAxisTab::onMode(int isSpacing)
+  {
+    mySpacingTreeWdg->setShown( isSpacing );
+    myCoordList->setShown( !isSpacing );
+    myStepSpin->setShown( !isSpacing );
+    myStepLabel->setShown( !isSpacing );
+    if ( isSpacing )
+    {
+      if ( mySpacingTreeWdg->topLevelItemCount() == 0 )
+      {
+        QString spacing( "1" );
+        if ( myCoordList->count() > 1 )
+        {
+          double c1 = coordFromItem( myCoordList->item( 1 ));
+          double c0 = coordFromItem( myCoordList->item( 0 ));
+          spacing = QString::number( c1 - c0 );
+        }
+        mySpacingTreeWdg->addTopLevelItem( setToItem( 0., 1., spacing ) );
+      }
+      myCoordList->clear();
+    }
+    else
+    {
+      mySpacingTreeWdg->clear();
+      if ( myCoordList->count() == 0 )
+        myCoordList->addItem( coordToItem( 0 ));
+    }
+    updateButtons();
+  }
+
+  void GridAxisTab::onStepChange()
+  {
+    if ( fabs( myStepSpin->GetValue() ) < 1e-100 )
+    {
+      double delta = myStepSpin->singleStep() * ( myStep > myStepSpin->GetValue() ? -1 : +1 );
+      myStepSpin->SetValue( myStepSpin->GetValue() + delta );
+    }
+    myStep = myStepSpin->GetValue();
+  }
+
+  void GridAxisTab::updateButtons()
+  {
+    bool insertEnable = false, deleteEnable = false;
+    if ( isGridBySpacing() )
+    {
+      insertEnable = true;
+      const int nbSelected = mySpacingTreeWdg->selectedItems().count();
+      if ( nbSelected > 0 )
+      {
+        // we delete a current range by uniting it with the previous
+        int i = mySpacingTreeWdg->indexOfTopLevelItem(  mySpacingTreeWdg->currentItem() );
+        deleteEnable = ( i > 0 );
+      }
+    }
+    else
+    {
+      const int nbSelected = myCoordList->selectedItems().count();
+      insertEnable = ( nbSelected || myCoordList->count() < 2 );
+      deleteEnable = ( nbSelected && myCoordList->count() > 2 );
+    }
+    myInsertBtn->setEnabled( insertEnable );
+    myDeleteBtn->setEnabled( deleteEnable );
+  }
+
+  void GridAxisTab::setCoordinates( SMESH::double_array_var coords )
+  {
+    myCoordList->clear();
+    for ( size_t i = 0; i < coords->length(); ++i )
+      myCoordList->addItem( coordToItem( coords[i] ));
+
+    myModeGroup->button( COORD_BUT )->setChecked( true );
+    onMode( COORD_BUT );
+  }
+
+  void GridAxisTab::setSpacing( SMESH::string_array_var funs, SMESH::double_array_var points )
+  {
+    mySpacingTreeWdg->clear();
+    if ( funs->length() == points->length() - 1 )
+    {
+      for ( size_t i = 1; i < points->length(); ++i )
+        mySpacingTreeWdg->addTopLevelItem
+          ( setToItem( points[i-1], points[i], (const char*) funs[i-1] ));
+    }
+    myModeGroup->button( SPACING_BUT )->setChecked( true );
+    onMode( SPACING_BUT );
+  }
+
+  bool GridAxisTab::isGridBySpacing() const
+  {
+    return ( myModeGroup->checkedId() == SPACING_BUT );
+  }
+
+  SMESH::double_array* GridAxisTab::getCoordinates()
+  {
+    SMESH::double_array_var coords = new SMESH::double_array;
+    coords->length( myCoordList->count() );
+    for ( size_t i = 0; i < coords->length(); ++i )
+      coords[i] = coordFromItem( myCoordList->item( i ) );
+
+    return coords._retn();
+  }
+
+  void GridAxisTab::getSpacing(SMESH::string_array_out funs,
+                               SMESH::double_array_out points) const
+  {
+    funs =  new SMESH::string_array();
+    points = new SMESH::double_array();
+    funs->length( mySpacingTreeWdg->topLevelItemCount() );
+    points->length( mySpacingTreeWdg->topLevelItemCount() + 1 );
+    double t0, t1; QString fun;
+    for ( size_t i = 0; i < funs->length(); ++i )
+    {
+      QTreeWidgetItem* item = mySpacingTreeWdg->topLevelItem( i );
+      getFromItem( item, t0, t1, fun );
+      points[i] = t0;
+      funs[i] = fun.toLatin1().constData();
+    }
+    points[ points->length()-1 ] = 1.0;
+  }
+
+
+  bool GridAxisTab::checkParams(QString& msg, SMESH::SMESH_Hypothesis_var& hyp) const
+  {
+    if ( isGridBySpacing() )
+    {
+      if ( mySpacingTreeWdg->topLevelItemCount() == 0 )
+        return false; // how could it be?
+      StdMeshers::StdMeshers_CartesianParameters3D_var h =
+        StdMeshers::StdMeshers_CartesianParameters3D::_narrow( hyp );
+      SMESH::string_array_var funs;
+      SMESH::double_array_var points;
+      getSpacing( funs.out(), points.out() );
+      try {
+        const char* axisName[3] = { "X", "Y", "Z" };
+        SMESH::double_array_var coords =
+          h->ComputeCoordinates(0.,1., funs, points, axisName[ myAxisIndex ]);
+      }
+      catch ( const SALOME::SALOME_Exception& ex ) {
+        msg = (const char*) ex.details.text;
+        return false;
+      }
+    }
+    else
+    {
+      return myCoordList->count() > 1;
+    }
+    return true;
+  }
+
+  LineDelegate::LineDelegate( QWidget* parent ):
+    QItemDelegate( parent ),
+    mySpacingTreeWdg( qobject_cast<QTreeWidget*>( parent )),
+    myCoordList( qobject_cast<QListWidget*>( parent ))
+  {
+  }
+
+  QWidget* LineDelegate::createEditor( QWidget*                    parent,
+                                       const QStyleOptionViewItem& opt,
+                                       const QModelIndex&          index) const
+  {
+    QWidget* w = 0;
+    if ( mySpacingTreeWdg )
+    {
+      if ( index.column() == 0 &&
+           index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
+      {
+        SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox( parent );
+        sb->setAcceptNames( false ); // No Notebook variables allowed
+        sb->setFrame( false );
+        w = sb;
+      }
+      if ( index.column() == 1 ) {
+        w = new QLineEdit( parent );
+      }
+    }
+    else
+    {
+      SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox( parent );
+      sb->setAcceptNames( false ); // No Notebook variables allowed
+      sb->setFrame( false );
+      const double tol = 1e-5;
+      double from = index.row() ? coordFromItem( myCoordList->item( index.row()-1 ))+tol : -1e+6;
+      double to = index.row() == myCoordList->count()-1 ? 1e+6 : coordFromItem( myCoordList->item( index.row()+1 ))-tol;
+      sb->RangeStepAndValidator( from, to, 0.01 );
+      w = sb;
+    }
+    return w;
+  }
+
+  void LineDelegate::setEditorData ( QWidget * editor, const QModelIndex & index ) const
+  {
+    if ( mySpacingTreeWdg && index.column() == 0 )
+    {
+      double t0, t1, t2=1.0; QString fun;
+      QTreeWidgetItem* item = mySpacingTreeWdg->topLevelItem( index.row() );
+      getFromItem( item, t0, t1, fun );
+      if ( index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
+      {
+        item = mySpacingTreeWdg->topLevelItem( index.row()+1 );
+        getFromItem( item, t1, t2, fun );
+      }
+      const double tol = 1e-3;
+      SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
+      sb->RangeStepAndValidator( t0 + tol, t2 - tol, 0.01 );
+      sb->SetValue( t1 );
+    }
+    else
+    {
+      QItemDelegate::setEditorData( editor, index );
+    }
+  }
+  void LineDelegate::setModelData( QWidget*            editor,
+                                   QAbstractItemModel* model,
+                                   const QModelIndex&  index ) const
+  {
+    if ( mySpacingTreeWdg )
+    {
+      if ( index.column() == 0 )
+      {
+        if ( index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
+        {
+          SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
+          double t0, t1, t = sb->GetValue(); QString fun;
+
+          QTreeWidgetItem* item = mySpacingTreeWdg->topLevelItem( index.row() );
+          getFromItem( item, t0, t1, fun );
+          setToItem( t0, t, fun, item );
+
+          item = mySpacingTreeWdg->topLevelItem( index.row() + 1 );
+          getFromItem( item, t0, t1, fun );
+          setToItem( t, t1, fun, item );
+        }
+      }
+      else if ( !qobject_cast<QLineEdit*>(editor)->text().trimmed().isEmpty() )
+      {
+        QItemDelegate::setModelData( editor, model, index );
+      }
+    }
+    else
+    {
+      SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
+      coordToItem( sb->GetValue(), myCoordList->item( index.row() ));
+    }
+  }
+
+} // namespace StdMeshersGUI
+
+
+StdMeshersGUI_CartesianParamCreator::StdMeshersGUI_CartesianParamCreator(const QString& aHypType)
+  : StdMeshersGUI_StdHypothesisCreator( aHypType ),
+    myThreshold( 0 )
+{
+  myAxisTabs[0] = 0;
+  myAxisTabs[1] = 0;
+  myAxisTabs[2] = 0;
+}
+
+StdMeshersGUI_CartesianParamCreator::~StdMeshersGUI_CartesianParamCreator()
+{
+  if ( myAxisTabs[0] ) delete myAxisTabs[0];
+  if ( myAxisTabs[1] ) delete myAxisTabs[1];
+  if ( myAxisTabs[2] ) delete myAxisTabs[2];
+  myAxisTabs[0] = 0;
+  myAxisTabs[1] = 0;
+  myAxisTabs[2] = 0;
+}
+
+bool StdMeshersGUI_CartesianParamCreator::checkParams( QString& msg ) const
+{
+  if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
+    return false;
+
+  if ( myName && myName->text().trimmed().isEmpty() )
+  {
+    msg = tr("SMESH_WRN_EMPTY_NAME");
+    return false;
+  }
+  if ( ! myThreshold->isValid( msg, true ))
+    return false;
+
+  SMESH::SMESH_Hypothesis_var hyp = hypothesis();
+  if ( !myAxisTabs[0]->checkParams( msg, hyp )) return false;
+  if ( !myAxisTabs[1]->checkParams( msg, hyp )) return false;
+  if ( !myAxisTabs[2]->checkParams( msg, hyp )) return false;
+
+  return true;
+}
+
+QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame()
+{
+  QFrame* fr = new QFrame();
+  //fr->setMinimumWidth(460);
+
+  QVBoxLayout* lay = new QVBoxLayout( fr );
+  lay->setMargin( 0 );
+  lay->setSpacing( SPACING );
+
+  QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
+  lay->addWidget( GroupC1 );
+
+  StdMeshers::StdMeshers_NumberOfSegments_var h =
+    StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+
+  QGridLayout* argGroupLayout = new QGridLayout( GroupC1 );
+  argGroupLayout->setSpacing( SPACING );
+  argGroupLayout->setMargin( MARGIN );
+  argGroupLayout->setColumnStretch( 0, 0 );
+  argGroupLayout->setColumnStretch( 1, 1 );
+
+  int row = 0;
+  // 0)  name
+  myName = 0;
+  if( isCreation() )
+  {
+    myName = new QLineEdit( GroupC1 );
+    argGroupLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), GroupC1 ), row, 0 );
+    argGroupLayout->addWidget( myName, row, 1 );
+    row++;
+  }
+
+  // 1)  threshold
+  argGroupLayout->addWidget( new QLabel( tr( "THRESHOLD" ), GroupC1 ), row, 0 );
+  myThreshold = new SMESHGUI_SpinBox( GroupC1 );
+  myThreshold->setAcceptNames( false ); // No Notebook variables allowed
+  myThreshold->RangeStepAndValidator( 1.1, 1e+10, 1., "length_precision" );
+  argGroupLayout->addWidget( myThreshold, row, 1 );
+  row++;
+  
+  // 2)  Grid definition
+  QTabWidget* tabWdg = new QTabWidget( fr );
+  myAxisTabs[ 0 ] = new StdMeshersGUI::GridAxisTab( tabWdg, 0 );
+  myAxisTabs[ 1 ] = new StdMeshersGUI::GridAxisTab( tabWdg, 1 );
+  myAxisTabs[ 2 ] = new StdMeshersGUI::GridAxisTab( tabWdg, 2 );
+  tabWdg->addTab( myAxisTabs[ 0 ], tr( "AXIS_X" ) );
+  tabWdg->addTab( myAxisTabs[ 1 ], tr( "AXIS_Y" ) );
+  tabWdg->addTab( myAxisTabs[ 2 ], tr( "AXIS_Z" ) );
+  argGroupLayout->addWidget( tabWdg, row, 0, 1, 2 );
+
+  return fr;
+}
+
+void StdMeshersGUI_CartesianParamCreator::retrieveParams() const
+{
+  StdMeshers::StdMeshers_CartesianParameters3D_var h =
+    StdMeshers::StdMeshers_CartesianParameters3D::_narrow( initParamsHypothesis() );
+
+  if( myName )
+    myName->setText( hypName() );
+
+  myThreshold->setValue( h->GetSizeThreshold() );
+
+  for ( int ax = 0; ax < 3; ++ax )
+  {
+    if ( h->IsGridBySpacing( ax ))
+    {
+      SMESH::string_array_var funs;
+      SMESH::double_array_var intPoints;
+      h->GetGridSpacing( funs.out(), intPoints.out(), ax );
+      myAxisTabs[ax]->setSpacing( funs, intPoints );
+    }
+    else
+    {
+      SMESH::double_array_var coords = h->GetGrid( ax );
+      myAxisTabs[ax]->setCoordinates( coords );
+    }
+  }
+  if ( dlg() )
+    dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
+}
+
+QString StdMeshersGUI_CartesianParamCreator::storeParams() const
+{
+  StdMeshers::StdMeshers_CartesianParameters3D_var h =
+    StdMeshers::StdMeshers_CartesianParameters3D::_narrow( hypothesis() );
+
+  try
+  {
+    if( isCreation() )
+      SMESH::SetName( SMESH::FindSObject( h ), myName->text().toLatin1().constData() );
+
+    h->SetSizeThreshold( myThreshold->text().toDouble() );
+
+    for ( int ax = 0; ax < 3; ++ax )
+    {
+      if ( myAxisTabs[ax]->isGridBySpacing())
+      {
+        SMESH::double_array_var intPoints;
+        SMESH::string_array_var funs;
+        myAxisTabs[ax]->getSpacing( funs.out(), intPoints.out() );
+        h->SetGridSpacing( funs, intPoints, ax );
+      }
+      else
+      {
+        SMESH::double_array_var coords = myAxisTabs[ax]->getCoordinates();
+        h->SetGrid( coords, ax );
+      }
+    }
+  }
+  catch(const SALOME::SALOME_Exception& ex)
+  {
+    SalomeApp_Tools::QtCatchCorbaException(ex);
+  }
+  return "";
+}
+
diff --git a/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.h b/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.h
new file mode 100644 (file)
index 0000000..a35608f
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : StdMeshersGUI_CartesianParamCreator.h
+// Author : Open CASCADE S.A.S.
+//
+#ifndef STDMESHERSGUI_CartesianParamCreator_H
+#define STDMESHERSGUI_CartesianParamCreator_H
+
+// SMESH includes
+#include "SMESH_StdMeshersGUI.hxx"
+
+#include "StdMeshersGUI_StdHypothesisCreator.h"
+
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+#include <QFrame>
+#include <QItemDelegate>
+
+class SMESHGUI_SpinBox;
+class QLineEdit;
+class QButtonGroup;
+class QTreeWidgetItem;
+class QString;
+class QWidget;
+class QTreeWidget;
+class QListWidget;
+class QStyleOptionViewItem;
+class QModelIndex;
+class QAbstractItemModel;
+class QListWidgetItem;
+
+namespace StdMeshersGUI
+{
+  void getFromItem(QTreeWidgetItem * item, double& t0, double& t1, QString& fun );
+  QTreeWidgetItem* setToItem (double  t0, double  t1, const QString& fun, QTreeWidgetItem* item=0);
+
+  double coordFromItem( QListWidgetItem * );
+  QListWidgetItem* coordToItem( double coord, QListWidgetItem * item=0);
+
+  /*!
+   * \brief Widget defining the grid in one direction
+   */
+  class GridAxisTab : public QFrame
+  {
+    Q_OBJECT
+  public:
+    GridAxisTab( QWidget* parent, const int axisIndex );
+    ~GridAxisTab() {}
+
+    void setCoordinates( SMESH::double_array_var coords );
+    void setSpacing( SMESH::string_array_var funs, SMESH::double_array_var points );
+
+    bool checkParams(QString& msg, SMESH::SMESH_Hypothesis_var& hyp) const;
+    bool isGridBySpacing() const;
+    SMESH::double_array* getCoordinates();
+    void getSpacing(SMESH::string_array_out funs, SMESH::double_array_out points) const;
+
+  private slots:
+    void onInsert();
+    void onDelete();
+    void onMode(int);
+    void onStepChange();
+    void updateButtons();
+
+  private:
+
+    int               myAxisIndex;
+    QButtonGroup*     myModeGroup;
+    QTreeWidget*      mySpacingTreeWdg;
+    QListWidget*      myCoordList;
+    QPushButton*      myInsertBtn;
+    QPushButton*      myDeleteBtn;
+    SMESHGUI_SpinBox* myStepSpin;
+    QLabel*           myStepLabel;
+    double            myStep;
+  };
+  /*
+   * \brief : Custom item delegate
+   */
+  class LineDelegate : public QItemDelegate
+  {
+    Q_OBJECT
+  public:
+    LineDelegate( QWidget* parent );
+    ~LineDelegate() {}
+
+    QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
+    void setEditorData ( QWidget * editor, const QModelIndex & index ) const;
+    void setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const;
+
+  private:
+    QTreeWidget* mySpacingTreeWdg;
+    QListWidget* myCoordList;
+  };
+}
+
+class STDMESHERSGUI_EXPORT StdMeshersGUI_CartesianParamCreator : public StdMeshersGUI_StdHypothesisCreator
+{
+  Q_OBJECT
+
+public:
+  StdMeshersGUI_CartesianParamCreator( const QString& aHypType );
+  virtual ~StdMeshersGUI_CartesianParamCreator();
+
+  virtual bool checkParams( QString& ) const;
+
+protected:
+  virtual QFrame*  buildFrame();
+  virtual void     retrieveParams() const;
+  virtual QString  storeParams() const;
+
+private:
+  QLineEdit*                  myName;
+  SMESHGUI_SpinBox*           myThreshold;
+  StdMeshersGUI::GridAxisTab* myAxisTabs[3];
+};
+
+#endif // STDMESHERSGUI_CartesianParamCreator_H
index ff09f9b48b53e5fb0ccef3991d33d612df424a09..0c99dcbd11e5d2622bb4dcc7607ad675c43cd486 100644 (file)
@@ -1341,6 +1341,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons
     types.insert( "MaxLength", "MAX_LENGTH" );
     types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
+    types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
   }
 
   QString res;
index 6bf81c4e25b6ae8ce062595edcc255ab997f0e54..aaf16607c11a5eae684e9f32c22a4933111ee626 100644 (file)
             <source>ICON_DLG_MAX_LENGTH</source>
             <translation>mesh_hypo_length.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_CARTESIAN_PARAMS</source>
+            <translation>mesh_hypo_length.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_VISCOUS_LAYERS</source>
             <translation>mesh_hypo_viscous_layers.png</translation>
index 203913c5d501e9c7e714029bb8a07e3924e24a4c..8a5d055b5c3903ffaea224a18d142d7cec021729 100644 (file)
         <source>SMESH_MAX_LENGTH_HYPOTHESIS</source>
         <translation>Max Length</translation>
     </message>
+    <message>
+        <source>SMESH_CARTESIAN_PARAMS_HYPOTHESIS</source>
+        <translation>Body Fitting Parameters</translation>
+    </message>
     <message>
         <source>SMESH_USE_PREESTIMATED_LENGTH</source>
         <translation>Use preestimated length</translation>
         <source>SMESH_MAX_LENGTH_TITLE</source>
         <translation>Hypothesis Construction</translation>
     </message>
+    <message>
+        <source>SMESH_CARTESIAN_PARAMS_TITLE</source>
+        <translation>Hypothesis Construction</translation>
+    </message>
     <message>
         <source>SMESH_MAX_ELEMENT_AREA_HYPOTHESIS</source>
         <translation>Max. Element Area</translation>
         <translation>Edit</translation>
     </message>
 </context>
+<context>
+    <name>StdMeshersGUI_CartesianParamCreator</name>
+    <message>
+        <source>THRESHOLD</source>
+        <translation>Threshold</translation>
+    </message>
+    <message>
+        <source>AXIS_X</source>
+        <translation>Axis X</translation>
+    </message>
+    <message>
+        <source>AXIS_Y</source>
+        <translation>Axis Y</translation>
+    </message>
+    <message>
+        <source>AXIS_Z</source>
+        <translation>Axis Z</translation>
+    </message>
+</context>
+<context>
+    <name>StdMeshersGUI::GridAxisTab</name>
+    <message>
+        <source>GRID_DEF_MODE</source>
+        <translation>Definition mode</translation>
+    </message>
+    <message>
+        <source>SPACING</source>
+        <translation>Spacing</translation>
+    </message>
+    <message>
+        <source>INSERT</source>
+        <translation>Insert</translation>
+    </message>
+    <message>
+        <source>COORD_STEP</source>
+        <translation>Step</translation>
+    </message>
+</context>
 </TS>
index 19a04f18edfa4d3dbcbdc82c4115e8f5ef6bc9a6..cec31e8be5edb4a34de0d86dd5d40616a3696fcf 100644 (file)
@@ -67,7 +67,9 @@ salomeinclude_HEADERS = \
        StdMeshers_ImportSource2D_i.hxx \
        StdMeshers_Import_1D_i.hxx \
        StdMeshers_Import_1D2D_i.hxx \
-       StdMeshers_ViscousLayers_i.hxx
+       StdMeshers_ViscousLayers_i.hxx \
+       StdMeshers_CartesianParameters3D_i.hxx \
+       StdMeshers_Cartesian_3D_i.hxx
 
 # Libraries targets
 lib_LTLIBRARIES = libStdMeshersEngine.la
@@ -113,7 +115,9 @@ dist_libStdMeshersEngine_la_SOURCES = \
        StdMeshers_ImportSource2D_i.cxx \
        StdMeshers_Import_1D_i.cxx \
        StdMeshers_Import_1D2D_i.cxx \
-       StdMeshers_ViscousLayers_i.cxx
+       StdMeshers_ViscousLayers_i.cxx \
+       StdMeshers_CartesianParameters3D_i.cxx \
+       StdMeshers_Cartesian_3D_i.cxx
 
 # additionnal information to compil and link file
 libStdMeshersEngine_la_CPPFLAGS = \
diff --git a/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.cxx b/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.cxx
new file mode 100644 (file)
index 0000000..06ebe87
--- /dev/null
@@ -0,0 +1,294 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  File   : StdMeshers_CartesianParameters3D_i.cxx
+//  Module : SMESH
+//
+#include "StdMeshers_CartesianParameters3D_i.hxx"
+
+#include "StdMeshers_CartesianParameters3D.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_PythonDump.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#define _vec2array( v, a,conversion )           \
+  {                                             \
+    a->length( v.size() );                      \
+    for ( size_t i = 0; i < v.size(); ++i )     \
+      a[i] = conversion( v[i] );                \
+  }
+#define _array2vec(a,v,conversion)              \
+  {                                             \
+    v.resize( a.length() );                     \
+    for ( size_t i = 0; i < v.size(); ++i )     \
+      v[i] = conversion ( a[i] );               \
+  }
+namespace
+{
+  const char* _string2chars(const std::string& s ) { return s.c_str(); }
+}
+
+//=============================================================================
+/*!
+ *  StdMeshers_CartesianParameters3D_i::StdMeshers_CartesianParameters3D_i
+ *
+ *  Constructor
+ */
+//=============================================================================
+
+StdMeshers_CartesianParameters3D_i::
+StdMeshers_CartesianParameters3D_i( PortableServer::POA_ptr thePOA,
+                                    int                     theStudyId,
+                                    ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ), 
+    SMESH_Hypothesis_i( thePOA )
+{
+  MESSAGE( "StdMeshers_CartesianParameters3D_i::StdMeshers_CartesianParameters3D_i" );
+  myBaseImpl = new ::StdMeshers_CartesianParameters3D( theGenImpl->GetANewId(),
+                                                       theStudyId,
+                                                       theGenImpl );
+}
+
+//=============================================================================
+/*!
+ *  StdMeshers_CartesianParameters3D_i::~StdMeshers_CartesianParameters3D_i
+ *
+ *  Destructor
+ */
+//=============================================================================
+
+StdMeshers_CartesianParameters3D_i::~StdMeshers_CartesianParameters3D_i()
+{
+  MESSAGE( "StdMeshers_CartesianParameters3D_i::~StdMeshers_CartesianParameters3D_i" );
+}
+
+//=============================================================================
+/*!
+ * SetGrid
+ */
+//=============================================================================
+
+void StdMeshers_CartesianParameters3D_i::SetGrid(const SMESH::double_array& coords,
+                                                 CORBA::Short               axis)
+  throw (SALOME::SALOME_Exception)
+{
+  std::vector<double> coordVec;//, yCoords, zCoords;
+  _array2vec( coords, coordVec, );
+
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetGrid( coordVec, axis );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+
+  // Update Python script
+  SMESH::TPythonDump() << _this() << ".SetGrid( " << coords << ", " << axis << " )";
+}
+
+//=============================================================================
+/*!
+ *  GetGrid
+ */
+//=============================================================================
+
+SMESH::double_array* StdMeshers_CartesianParameters3D_i::GetGrid(CORBA::Short axis)
+  throw (SALOME::SALOME_Exception)
+{
+  std::vector<double> coordVec;
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->GetGrid(coordVec, axis);
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+
+  SMESH::double_array_var coords = new SMESH::double_array();
+  _vec2array( coordVec, coords, );
+
+  return coords._retn();
+}
+
+//=============================================================================
+/*!
+ *  SetSizeThreshold
+ */
+//=============================================================================
+
+void StdMeshers_CartesianParameters3D_i::SetSizeThreshold(CORBA::Double threshold)
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetSizeThreshold(threshold);
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+
+  // Update Python script
+  SMESH::TPythonDump() << _this() << ".SetSizeThreshold( " << threshold << " )";
+}
+
+//=============================================================================
+/*!
+ *  GetSizeThreshold
+ */
+//=============================================================================
+
+CORBA::Double StdMeshers_CartesianParameters3D_i::GetSizeThreshold()
+{
+  return this->GetImpl()->GetSizeThreshold();
+}
+
+//=======================================================================
+//function : SetGridSpacing
+//\brief Set grid spacing along the three axes
+// \param spaceFunctions - functions defining spacing values at given point on axis
+// \param internalPoints - points dividing a grid into parts along each direction
+// Parameter t of spaceFunction f(t) is a position [0,1] withing bounding box of
+// the shape to mesh or withing an interval defined by internal points
+//=======================================================================
+
+void StdMeshers_CartesianParameters3D_i::SetGridSpacing(const SMESH::string_array& spaceFunctions,
+                                                        const SMESH::double_array& internalPoints,
+                                                        CORBA::Short               axis)
+  throw (SALOME::SALOME_Exception)
+{
+  vector<string> funVec;
+  vector<double> pointVec;
+  _array2vec( spaceFunctions, funVec, (const char*) );
+  _array2vec( internalPoints, pointVec, );
+
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetGridSpacing( funVec, pointVec, axis );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+
+  // Update Python script
+  SMESH::TPythonDump() << _this() << ".SetGridSpacing( "
+                       << spaceFunctions << ", "
+                       << internalPoints << ", "
+                       << axis << " )";
+}
+
+//=======================================================================
+//function : GetGridSpacing
+//=======================================================================
+
+void StdMeshers_CartesianParameters3D_i::GetGridSpacing(SMESH::string_array_out xSpaceFunctions,
+                                                        SMESH::double_array_out xInternalPoints,
+                                                        CORBA::Short            axis)
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT( myBaseImpl );
+  try {
+    vector<string> funVec;
+    vector<double> pointVec;
+    this->GetImpl()->GetGridSpacing( funVec, pointVec, axis );
+
+    xSpaceFunctions = new SMESH::string_array();
+    xInternalPoints = new SMESH::double_array();
+
+    _vec2array( funVec, xSpaceFunctions, _string2chars );
+    _vec2array( pointVec, xInternalPoints, );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+}
+
+//=======================================================================
+//function : IsGridBySpacing
+//purpose  : Return true if the grid is defined by spacing functions and 
+//           not by node coordinates
+//=======================================================================
+
+CORBA::Boolean StdMeshers_CartesianParameters3D_i::IsGridBySpacing(CORBA::Short axis)
+{
+  return this->GetImpl()->IsGridBySpacing(axis);
+}
+
+//=======================================================================
+//function : ComputeCoordinates
+//purpose  : Computes node coordinates by spacing functions
+//=======================================================================
+
+SMESH::double_array*
+StdMeshers_CartesianParameters3D_i::ComputeCoordinates(CORBA::Double              x0,
+                                                       CORBA::Double              x1,
+                                                       const SMESH::string_array& spaceFuns,
+                                                       const SMESH::double_array& points,
+                                                       const char*                axisName )
+    throw (SALOME::SALOME_Exception)
+{
+  vector<string> xFuns;
+  vector<double> xPoints, coords;
+  _array2vec( spaceFuns, xFuns, (const char*) );
+  _array2vec( points, xPoints, );
+  
+  try {
+    this->GetImpl()->ComputeCoordinates( x0, x1, xFuns, xPoints, coords, axisName );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+  SMESH::double_array_var res = new SMESH::double_array;
+  _vec2array( coords, res,  );
+
+  return res._retn();
+}
+
+//=============================================================================
+/*!
+ *  Get implementation
+ */
+//=============================================================================
+
+::StdMeshers_CartesianParameters3D* StdMeshers_CartesianParameters3D_i::GetImpl()
+{
+  MESSAGE( "StdMeshers_CartesianParameters3D_i::GetImpl" );
+  return ( ::StdMeshers_CartesianParameters3D* )myBaseImpl;
+}
+
+//================================================================================
+/*!
+ * \brief Verify whether hypothesis supports given entity type 
+  * \param type - dimension (see SMESH::Dimension enumeration)
+  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ * 
+ * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ */
+//================================================================================  
+
+CORBA::Boolean StdMeshers_CartesianParameters3D_i::IsDimSupported( SMESH::Dimension type )
+{
+  return type == SMESH::DIM_3D;
+}
diff --git a/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx b/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx
new file mode 100644 (file)
index 0000000..e33a898
--- /dev/null
@@ -0,0 +1,117 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  File   : StdMeshers_CartesianParameters3D_i.hxx
+//  Module : SMESH
+//
+#ifndef _SMESH_CartesianParameters3D_I_HXX_
+#define _SMESH_CartesianParameters3D_I_HXX_
+
+#include "SMESH_StdMeshers_I.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+
+class SMESH_Gen;
+class StdMeshers_CartesianParameters3D;
+
+// ======================================================
+// "CartesianParameters3D" hypothesis
+// ======================================================
+
+class STDMESHERS_I_EXPORT StdMeshers_CartesianParameters3D_i:
+  public virtual POA_StdMeshers::StdMeshers_CartesianParameters3D,
+  public virtual SMESH_Hypothesis_i
+{
+ public:
+  // Constructor
+  StdMeshers_CartesianParameters3D_i( PortableServer::POA_ptr thePOA,
+                                      int                     theStudyId,
+                                      ::SMESH_Gen*            theGenImpl );
+  // Destructor
+  virtual ~StdMeshers_CartesianParameters3D_i();
+
+  /*!
+   * Set size threshold. A polyhedral cell got by cutting an initial
+   * hexahedron by geometry boundary is considered small and is removed if
+   * it's size is \athreshold times less than the size of the initial hexahedron. 
+   * threshold must be > 1.0
+   */
+  void SetSizeThreshold(CORBA::Double threshold) throw (SALOME::SALOME_Exception);
+  CORBA::Double GetSizeThreshold();
+
+  /*!
+   * \brief Set node coordinates along an axis (counterd from zero)
+   */
+  void SetGrid(const SMESH::double_array& coords,
+               CORBA::Short               axis) throw (SALOME::SALOME_Exception);
+  SMESH::double_array* GetGrid(CORBA::Short axis) throw (SALOME::SALOME_Exception);
+
+  /*!
+   * \brief Set grid spacing along an axis
+   *  \param spaceFunctions - functions defining spacing value at given point on axis
+   *  \param internalPoints - points dividing a grid into parts along each direction
+   *  \param axis - index of an axis counterd from zero, i.e. 0==X, 1==Y, 2==Z
+   *
+   * Parameter t of spaceFunction f(t) is a position [0,1] withing bounding box of
+   * the shape to mesh or withing an interval defined by internal points
+   */
+  void SetGridSpacing(const SMESH::string_array& spaceFunctions,
+                      const SMESH::double_array& internalPoints,
+                      CORBA::Short               axis) throw (SALOME::SALOME_Exception);
+
+  void GetGridSpacing(SMESH::string_array_out xSpaceFunctions,
+                      SMESH::double_array_out xInternalPoints,
+                      CORBA::Short            axis) throw (SALOME::SALOME_Exception);
+
+  /*!
+   * \brief Return true if the grid is defined by spacing functions and 
+   *        not by node coordinates
+   */
+  CORBA::Boolean IsGridBySpacing(CORBA::Short axis);
+
+  /*!
+   * \brief Computes node coordinates by spacing functions
+   *  \param x0 - lower coordinate
+   *  \param x1 - upper coordinate
+   *  \param spaceFuns - space functions
+   *  \param points - internal points
+   *  \param coords - the computed coordinates
+   */
+  SMESH::double_array* ComputeCoordinates(CORBA::Double              x0,
+                                          CORBA::Double              x1,
+                                          const SMESH::string_array& spaceFuns,
+                                          const SMESH::double_array& points,
+                                          const char*                axisName )
+    throw (SALOME::SALOME_Exception);
+
+  // Get implementation
+  ::StdMeshers_CartesianParameters3D* GetImpl();
+
+  // Verify whether hypothesis supports given entity type 
+  CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+};
+
+#endif
+
diff --git a/src/StdMeshers_I/StdMeshers_Cartesian_3D_i.cxx b/src/StdMeshers_I/StdMeshers_Cartesian_3D_i.cxx
new file mode 100644 (file)
index 0000000..0665ebe
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  File   : StdMeshers_Cartesian_3D_i.cxx
+//  Module : SMESH
+//
+#include "StdMeshers_Cartesian_3D_i.hxx"
+#include "StdMeshers_Cartesian_3D.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *  StdMeshers_Cartesian_3D_i::StdMeshers_Cartesian_3D_i
+ *
+ *  Constructor
+ */
+//=============================================================================
+
+StdMeshers_Cartesian_3D_i::StdMeshers_Cartesian_3D_i( PortableServer::POA_ptr thePOA,
+                                                      int                     theStudyId,
+                                                      ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ), 
+    SMESH_Hypothesis_i( thePOA ), 
+    SMESH_Algo_i( thePOA ),
+    SMESH_3D_Algo_i( thePOA )
+{
+  MESSAGE( "StdMeshers_Cartesian_3D_i::StdMeshers_Cartesian_3D_i" );
+  myBaseImpl = new ::StdMeshers_Cartesian_3D( theGenImpl->GetANewId(),
+                                              theStudyId,
+                                              theGenImpl );
+}
+
+//=============================================================================
+/*!
+ *  StdMeshers_Cartesian_3D_i::~StdMeshers_Cartesian_3D_i
+ *
+ *  Destructor
+ */
+//=============================================================================
+
+StdMeshers_Cartesian_3D_i::~StdMeshers_Cartesian_3D_i()
+{
+  MESSAGE( "StdMeshers_Cartesian_3D_i::~StdMeshers_Cartesian_3D_i" );
+}
+
+//=============================================================================
+/*!
+ *  StdMeshers_Cartesian_3D_i::GetImpl
+ *
+ *  Get implementation
+ */
+//=============================================================================
+
+::StdMeshers_Cartesian_3D* StdMeshers_Cartesian_3D_i::GetImpl()
+{
+  MESSAGE( "StdMeshers_Cartesian_3D_i::GetImpl" );
+  return ( ::StdMeshers_Cartesian_3D* )myBaseImpl;
+}
diff --git a/src/StdMeshers_I/StdMeshers_Cartesian_3D_i.hxx b/src/StdMeshers_I/StdMeshers_Cartesian_3D_i.hxx
new file mode 100644 (file)
index 0000000..4d51803
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  File   : StdMeshers_Cartesian_3D_i.hxx
+//  Module : SMESH
+//
+#ifndef _SMESH_Cartesian_3D_I_HXX_
+#define _SMESH_Cartesian_3D_I_HXX_
+
+#include "SMESH_StdMeshers_I.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_3D_Algo_i.hxx"
+
+class SMESH_Gen;
+class StdMeshers_Cartesian_3D;
+
+// ======================================================
+// Cartesianedron 3d algorithm
+// ======================================================
+class STDMESHERS_I_EXPORT StdMeshers_Cartesian_3D_i:
+  public virtual POA_StdMeshers::StdMeshers_Cartesian_3D,
+  public virtual SMESH_3D_Algo_i
+{
+public:
+  // Constructor
+  StdMeshers_Cartesian_3D_i( PortableServer::POA_ptr thePOA,
+                             int                     theStudyId,
+                             ::SMESH_Gen*            theGenImpl );
+
+  // Destructor
+  virtual ~StdMeshers_Cartesian_3D_i();
+
+  // Get implementation
+  ::StdMeshers_Cartesian_3D* GetImpl();
+};
+
+#endif
index 34047b0d8ef3782a23956b86698409944c3cc27f..a87dc8490d153162e4700d512a18987e5d139f1d 100644 (file)
@@ -58,6 +58,7 @@
 #include "StdMeshers_QuadrangleParams_i.hxx"
 #include "StdMeshers_ImportSource1D_i.hxx"
 #include "StdMeshers_ImportSource2D_i.hxx"
+#include "StdMeshers_Cartesian_3D_i.hxx"
 
 #include "StdMeshers_Regular_1D_i.hxx"
 #include "StdMeshers_MEFISTO_2D_i.hxx"
@@ -72,6 +73,7 @@
 #include "StdMeshers_Import_1D_i.hxx"
 #include "StdMeshers_Import_1D2D_i.hxx"
 #include "StdMeshers_ViscousLayers_i.hxx"
+#include "StdMeshers_CartesianParameters3D_i.hxx"
 
 template <class T> class StdHypothesisCreator_i:public HypothesisCreator_i<T>
 {
@@ -177,6 +179,8 @@ STDMESHERS_I_EXPORT
       aCreator = new StdHypothesisCreator_i<StdMeshers_ImportSource2D_i>;
     else if (strcmp(aHypName, "ViscousLayers") == 0)
       aCreator = new StdHypothesisCreator_i<StdMeshers_ViscousLayers_i>;
+    else if (strcmp(aHypName, "CartesianParameters3D") == 0)
+      aCreator = new StdHypothesisCreator_i<StdMeshers_CartesianParameters3D_i>;
 
     // Algorithms
     else if (strcmp(aHypName, "Regular_1D") == 0)
@@ -213,6 +217,8 @@ STDMESHERS_I_EXPORT
       aCreator = new StdHypothesisCreator_i<StdMeshers_Import_1D_i>;
     else if (strcmp(aHypName, "Import_1D2D") == 0)
       aCreator = new StdHypothesisCreator_i<StdMeshers_Import_1D2D_i>;
+    else if (strcmp(aHypName, "Cartesian_3D") == 0)
+      aCreator = new StdHypothesisCreator_i<StdMeshers_Cartesian_3D_i>;
     else ;
 
     return aCreator;