Salome HOME
IMP 23373: [CEA 1170] Optimization of a 3D mesh using MG-Tetra
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index a279a4ada6df344848925daad936a7045094e4e8..2397c7f6c3643c565e5b1f3c4e0ca2a1f2501e2b 100644 (file)
@@ -876,10 +876,17 @@ CORBA::Boolean SMESH_Gen_i::GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr
     {
       if ( !foundMesh->_is_nil() ) // not a sole mesh
       {
-        GEOM::GEOM_Object_var s1 = mesh_i   ->GetShapeToMesh();
-        GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
-        if ( ! ( isSole = s1->IsSame( s2 )))
-          break;
+        if ( !foundMesh->HasShapeToMesh() ||
+             !mesh_i   ->HasShapeToMesh() )
+        {
+          isSole = ( foundMesh->HasShapeToMesh() == mesh_i->HasShapeToMesh() );
+        }
+        else
+        {
+          GEOM::GEOM_Object_var s1 = mesh_i   ->GetShapeToMesh();
+          GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
+          isSole = s1->IsSame( s2 );
+        }
       }
       foundMesh = SMESH::SMESH_Mesh::_narrow( obj );
     }
@@ -960,9 +967,9 @@ void SMESH_Gen_i::SetOption(const char* name, const char* value)
           if ( str.at(i*2) >= '0' && str.at(i*2) <= 'f' && str.at(i*2+1) >= '0' && str.at(i*2+1) <= 'f' )
             color.push_back( strtol( str.substr( i*2, 2 ).c_str(), NULL, 16 ) );
       }
-      else { // rgb color ("255,170,0", for example)
-        char* tempValue = strdup( value );
-        char* colorValue = strtok( tempValue, "," );
+      else if ( value ) { // rgb color ("255,170,0", for example)
+        string tempValue( value );
+        char* colorValue = strtok( &tempValue[0], "," );
         while ( colorValue != NULL ) {
           int c_value = atoi( colorValue );
           if ( c_value >= 0 && c_value <= 255 )
@@ -1916,8 +1923,8 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
         myLocShape = SMESH_Mesh::PseudoShape();
       // call implementation compute
       ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
-      myGen.PrepareCompute( myLocMesh, myLocShape);
-      bool ok = myGen.Compute( myLocMesh, myLocShape);
+      myGen.PrepareCompute( myLocMesh, myLocShape );
+      bool ok = myGen.Compute( myLocMesh, myLocShape, myLocShape != myLocMesh.GetShapeToMesh());
       meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
       myLocMesh.GetMeshDS()->Modified();
       return ok;
@@ -2001,7 +2008,7 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh
       ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
       TSetOfInt shapeIds;
       ::MeshDimension aDim = (MeshDimension)theDimension;
-      if ( myGen.Compute( myLocMesh, myLocShape, false, false, aDim, &shapeIds ) )
+      if ( myGen.Compute( myLocMesh, myLocShape, ::SMESH_Gen::COMPACT_MESH, aDim, &shapeIds ) )
       {
         int nbShapeId = shapeIds.size();
         theShapesId.length( nbShapeId );
@@ -2543,9 +2550,9 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
 
         // make a group name
         const char* typeNames[] = { "All","Nodes","Edges","Faces","Volumes","0DElems","Balls" };
-        { // check of typeNames, compilation failure mains that NB_ELEMENT_TYPES changed:
+        { // check of typeNames: compilation failure mains that NB_ELEMENT_TYPES changed:
           const int nbNames = sizeof(typeNames) / sizeof(const char*);
-          int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 1 : -1 ]; _assert[0]=0;
+          int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 2 : -1 ]; _assert[0]=_assert[1];
         }
         string groupName = "Gr";
         SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, theMeshesArray[i] );