+//================================================================================
+/*!
+ * Evaluate
+ */
+//================================================================================
+
+bool StdMeshers_CompositeHexa_3D::Evaluate(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape,
+ MapShapeNbElems& aResMap)
+{
+ // -------------------------
+ // Try to find 6 side faces
+ // -------------------------
+ list< _QuadFaceGrid > boxFaceContainer;
+ _QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
+ if ( ! findBoxFaces( theShape, boxFaceContainer,
+ fBottom, fTop, fFront, fBack, fLeft, fRight))
+ return false;
+
+ // Find a less complex side
+ _QuadFaceGrid * lessComplexSide = & boxFaceContainer.front();
+ list< _QuadFaceGrid >::iterator face = boxFaceContainer.begin();
+ for ( ++face; face != boxFaceContainer.end() && lessComplexSide->IsComplex(); ++face )
+ if ( face->NbChildren() < lessComplexSide->NbChildren() )
+ lessComplexSide = & *face;
+
+ // Get an 1D size of lessComplexSide
+ int nbSeg1 = 0;
+ vector<TopoDS_Edge> edges;
+ if ( !lessComplexSide->GetHoriEdges(edges) )
+ return false;
+ for ( size_t i = 0; i < edges.size(); ++i )
+ {
+ const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( edges[i] )];
+ if ( !nbElems.empty() )
+ nbSeg1 += Max( nbElems[ SMDSEntity_Edge ], nbElems[ SMDSEntity_Quad_Edge ]);
+ }
+
+ // Get an 1D size of a box side ortogonal to lessComplexSide
+ int nbSeg2 = 0;
+ _QuadFaceGrid* ortoSide =
+ lessComplexSide->FindAdjacentForSide( Q_LEFT, boxFaceContainer, B_UNDEFINED );
+ edges.clear();
+ if ( !ortoSide || !ortoSide->GetHoriEdges(edges) ) return false;
+ for ( size_t i = 0; i < edges.size(); ++i )
+ {
+ const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( edges[i] )];
+ if ( !nbElems.empty() )
+ nbSeg2 += Max( nbElems[ SMDSEntity_Edge ], nbElems[ SMDSEntity_Quad_Edge ]);
+ }
+
+ // Get an 2D size of a box side ortogonal to lessComplexSide
+ int nbFaces = 0, nbQuadFace = 0;
+ list< TopoDS_Face > sideFaces;
+ if ( ortoSide->IsComplex() )
+ for ( _QuadFaceGrid::TChildIterator child = ortoSide->GetChildren(); child.more(); )
+ sideFaces.push_back( child.next().GetFace() );
+ else
+ sideFaces.push_back( ortoSide->GetFace() );
+ //
+ list< TopoDS_Face >::iterator f = sideFaces.begin();
+ for ( ; f != sideFaces.end(); ++f )
+ {
+ const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( *f )];
+ if ( !nbElems.empty() )
+ {
+ nbFaces = nbElems[ SMDSEntity_Quadrangle ];
+ nbQuadFace = nbElems[ SMDSEntity_Quad_Quadrangle ];
+ }
+ }
+
+ // Fill nb of elements
+ vector<int> aResVec(SMDSEntity_Last,0);
+ int nbSeg3 = ( nbFaces + nbQuadFace ) / nbSeg2;
+ aResVec[SMDSEntity_Node] = (nbSeg1-1) * (nbSeg2-1) * (nbSeg3-1);
+ aResVec[SMDSEntity_Hexa] = nbSeg1 * nbFaces;
+ aResVec[SMDSEntity_Quad_Hexa] = nbSeg1 * nbQuadFace;
+
+ aResMap.insert( make_pair( theMesh.GetSubMesh(theShape), aResVec ));
+
+ return true;
+}
+
+