+//================================================================================
+/*!
+ * \brief return dimension of elements of the selected object
+ *
+ * \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
+ */
+//================================================================================
+
+int SMESHGUI_Selection::dim( int ind ) const
+{
+ int dim = -1;
+ if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
+ {
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
+
+ if ( !CORBA::is_nil( obj ) ) {
+ SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
+ if ( !CORBA::is_nil( idSrc ) )
+ {
+ SMESH::array_of_ElementType_var types = idSrc->GetTypes();
+ for ( size_t i = 0; i < types->length(); ++ i) {
+ switch ( types[i] ) {
+ case SMESH::EDGE : dim = std::max( dim, 1 ); break;
+ case SMESH::FACE : dim = std::max( dim, 2 ); break;
+ case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
+ case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
+ case SMESH::BALL : dim = std::max( dim, 0 ); break;
+ default: break;
+ }
+ }
+ }
+ }
+ }
+ return dim;
+}
+
+//=======================================================================
+//function : hasAlgo
+//purpose : return true for a ready-to-compute [sub-]mesh
+//=======================================================================
+
+bool SMESHGUI_Selection::hasAlgo( int ind ) const
+{
+ if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
+ myTypes[ind].startsWith("Mesh " )))
+ {
+ QMap<int,int> modeMap;
+ _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toStdString() );
+
+ SMESHGUI_PrecomputeOp::getAssignedAlgos( meshSO, modeMap );
+ return modeMap.size() > 0;
+ }
+ return false;
+}
+
+
+//=======================================================================
+//function : hasAlgo
+//purpose : return true if a mesh was computed with errors
+//=======================================================================
+
+bool SMESHGUI_Selection::hasErrors( int ind ) const
+{
+ if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh"))
+ {
+ _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toStdString() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( meshSO );
+ SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
+ if ( !CORBA::is_nil( mesh ) )
+ {
+ SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGUI()->GetSMESHGen();
+ GEOM::GEOM_Object_var geom = mesh->GetShapeToMesh();
+ SMESH::compute_error_array_var compErrors = gen->GetComputeErrors( mesh, geom );
+ return compErrors->length();
+ }
+ }
+ return false;
+}
+