diff --git a/doc/salome/gui/SMESH/images/cartesian3D_hyp.png b/doc/salome/gui/SMESH/images/cartesian3D_hyp.png
new file mode 100644
index 000000000..b8373ed6d
Binary files /dev/null and b/doc/salome/gui/SMESH/images/cartesian3D_hyp.png differ
diff --git a/doc/salome/gui/SMESH/images/cartesian3D_sphere.png b/doc/salome/gui/SMESH/images/cartesian3D_sphere.png
new file mode 100644
index 000000000..45bffdabe
Binary files /dev/null and b/doc/salome/gui/SMESH/images/cartesian3D_sphere.png differ
diff --git a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc
index 274ab7438..1047397b4 100644
--- a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc
+++ b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc
@@ -23,10 +23,8 @@ shape of a mesh.
- Triangle meshing algorithms (Mefisto, Netgen 1D-2D and BLSUFR ) - Faces
are split into triangular elements.
-- Quadrangle meshing algorithm (Mapping) - Faces are split into
+
- Quadrangle meshing algorithm (Mapping) - quadrilateral Faces are split into
quadrangular elements.
-- Radial quadrangle 1D2D algorithm - Faces (circles or part of circles)
-are split into triangular and quadrangle elements.
\image html image123.gif "Example of a triangular 2D mesh"
@@ -36,10 +34,14 @@ are split into triangular and quadrangle elements.
For meshing of 3D entities (volume objects):
-- Hexahedron meshing algorithm (i,j,k) - Volumes are split into
+
- Hexahedron meshing algorithm (i,j,k) - 6-sided Volumes are split into
hexahedral (cubic) elements.
- Tetrahedron (Netgen and GHS3D) meshing algorithms - Volumes are split into
tetrahedral (pyramidal) elements.
+- \subpage cartesian_algo_page
+internal part of Volumes are split into hexahedral elements forming a
+Cartesian grid; polyhedra and other types of elements are gerenated
+where the geometrical boundary intersects Cartesian cells.
\image html image125.gif "Example of a tetrahedral 3D mesh"
diff --git a/doc/salome/gui/SMESH/input/cartesian_algo.doc b/doc/salome/gui/SMESH/input/cartesian_algo.doc
new file mode 100644
index 000000000..d093a57c1
--- /dev/null
+++ b/doc/salome/gui/SMESH/input/cartesian_algo.doc
@@ -0,0 +1,75 @@
+/*!
+
+\page cartesian_algo_page Body Fitting 3D meshing algorithm
+
+Body Fitting algorithm generates hexahedrones of a Cartesian grid in
+the internal part of geometry and polyhedra and other types of
+elements at intersection of Cartesian cells with the geometrical
+boundary.
+
+\image html cartesian3D_sphere.png "A shpere meshed by Body Fitting algorithm"
+
+Algorithm of meshing is following.
+
+- Lines of a Cartesian structured grid defined by
+\ref cartesian_hyp_anchor "Body Fitting Parameters" hypothesis are
+intersected with the geometry boundary, thus nodes laying on the
+boundary are found. This step also allows finding out for each node of
+the Cartesian grid if it is inside or outside the geometry.
+- For each cell of the grid, check how many of it's nodes are outside
+of the geometry boundary. Depending on a result of this check
+
+- skip a cell, if all it's nodes are outside
+- skip a cell, if it is too small according to Size
+ Threshold paremeter
+- add a hexahedron in the mesh, if all nodes are inside
+- add a polyhedron or a cell of other type in the mesh, if some
+nodes are inside and some outside
+
+
+
+To apply this algorithm, when you define your mesh, select Body
+ Fitting in the list of 3D algorithms and click "Add
+ Hypothesis" button and "Body Fitting Parameters"" menu
+ item. Dialog of Body Fitting Parameters
+ hypothesis will appear.
+
+
+\anchor cartesian_hyp_anchor
+Body Fitting Parameters hypothesis
+
+\image html cartesian3D_hyp.png "Body Fitting Parameters hypothesis dialog"
+
+This dialog lets you define
+
+- \b Name of the algorithm
+- Minimal size of a cell truncated be the geometry boundary. If
+ size of a truncated grid cell is \b Threshold times less than a
+ initial cell size, then a mesh element is not created.
+- Cartesian structured grid. Each grid axis is defined
+ individually. Definition mode chooses a way of grid
+ definition:
+ - You can specify \b Coordinates of grid nodes. \b Insert button
+ inserts a node at distance \b Step (negative or positive) from a
+ selected node. \b Delete botton removes a selected node. Double
+ click on a coordinate in the list enables its edition. A grid
+ defined by \b Coordinates should enclose the geometry, else the
+ algorithm will fail.
+ - You can define \b Spacing of a grid as an algebraic formular
+ f(t) where \a t is a position along a grid axiz
+ normalized at [0.0,1.0]. The whole range of geometry can be
+ divided into sub-ranges with their own spacing formulars to apply;
+ \a t varies between 0.0 and 1.0 within each sub-range. \b Insert button
+ divides a selected range into two ones. \b Delete button adds a
+ selected sub-range to a previous one. Double click on a range in
+ the list enables edition of its right boundary. Double click on a
+ function in the list enables its edition.
+
+
+
+
+
+See Also a sample TUI Script of a
+\ref tui_cartesian_algo "Usage of Body Fitting algorithm".
+
+*/
diff --git a/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc
new file mode 100644
index 000000000..f1218439b
--- /dev/null
+++ b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc
@@ -0,0 +1,49 @@
+/*!
+
+\page tui_cartesian_algo Usage of Body Fitting algorithm
+
+\code
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+# create a sphere
+sphere = geompy.MakeSphereR( 50 )
+geompy.addToStudy( sphere, "sphere" )
+
+# create a mesh and assign a "Body Fitting" algo
+mesh = Mesh( sphere )
+cartAlgo = mesh.BodyFitted()
+
+# define a cartesian grid using Coordinates
+coords = range(-100,100,10)
+cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
+
+# compute the mesh
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+print
+
+# define the grid by sitting constant spacing
+cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
+
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+
+
+# define the grid by sitting different spacing in 2 sub-ranges of geometry
+spaceFuns = ["5","10+10*t"]
+cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 2 )
+
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+print
+
+\endcode
+
+*/
diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx
index 96e6e422d..fd59f5c86 100644
--- a/src/SMESH_I/SMESH_2smeshpy.cxx
+++ b/src/SMESH_I/SMESH_2smeshpy.cxx
@@ -1665,6 +1665,16 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
hyp = new _pyLayerDistributionHypo( theCreationCmd, "Get3DHypothesis" );
hyp->SetConvMethodAndType( "LayerDistribution", "RadialPrism_3D");
}
+ // Cartesian 3D ---------
+ else if ( hypType == "Cartesian_3D" ) {
+ algo->SetConvMethodAndType( "BodyFitted", hypType.ToCString());
+ }
+ else if ( hypType == "CartesianParameters3D" ) {
+ hyp = new _pyComplexParamHypo( theCreationCmd );
+ hyp->SetConvMethodAndType( "SetGrid", "Cartesian_3D");
+ for ( int iArg = 0; iArg < 4; ++iArg )
+ hyp->myArgs.Append("[]");
+ }
return algo->IsValid() ? algo : hyp;
}
@@ -1835,12 +1845,44 @@ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther,
//================================================================================
/*!
* \brief Remember hypothesis parameter values
- * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
*/
//================================================================================
void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand)
{
+ if ( GetAlgoType() == "Cartesian_3D" )
+ {
+ // CartesianParameters3D hyp
+
+ if ( theCommand->GetMethod() == "SetSizeThreshold" )
+ {
+ myArgs( 4 ) = theCommand->GetArg( 1 );
+ myArgCommands.push_back( theCommand );
+ return;
+ }
+ if ( theCommand->GetMethod() == "SetGrid" ||
+ theCommand->GetMethod() == "SetGridSpacing" )
+ {
+ TCollection_AsciiString axis = theCommand->GetArg( theCommand->GetNbArgs() );
+ int iArg = 1 + ( axis.Value(1) - '0' );
+ if ( theCommand->GetMethod() == "SetGrid" )
+ {
+ myArgs( iArg ) = theCommand->GetArg( 1 );
+ }
+ else
+ {
+ myArgs( iArg ) = "[ ";
+ myArgs( iArg ) += theCommand->GetArg( 1 );
+ myArgs( iArg ) += ", ";
+ myArgs( iArg ) += theCommand->GetArg( 2 );
+ myArgs( iArg ) += "]";
+ }
+ myArgCommands.push_back( theCommand );
+ return;
+ }
+ }
+
if( theCommand->GetMethod() == "SetLength" )
{
// NOW it becomes OBSOLETE