Salome HOME
22752: [EDF] Provide explicit feedback on what has been done by Shape Processing...
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IFieldOperations.cxx
index 828de70380e311ca539b2b039e790051b777068b..7e817402fff0901fe1cf8b3d884da4c9b4f4ce57 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  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
@@ -6,7 +6,7 @@
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -161,7 +161,7 @@ GEOMImpl_IFieldOperations::GetFields( const Handle(GEOM_Object)& theShape )
 {
   SetErrorCode(KO);
 
-  Handle(TColStd_HSequenceOfTransient) fields;
+  Handle(TColStd_HSequenceOfTransient) fields = new TColStd_HSequenceOfTransient;
   if ( theShape.IsNull() ) {
     SetErrorCode( "Error: NULL shape" );
     return fields;
@@ -180,10 +180,13 @@ GEOMImpl_IFieldOperations::GetFields( const Handle(GEOM_Object)& theShape )
   for (; anIt.More(); anIt.Next()) {
     TCollection_ExtendedString& anEntry = anIt.Value();
     anEntry.ToUTF8CString( (Standard_PCharacter&) pentry );
-    Handle(GEOM_Field) field = Handle(GEOM_Field)::DownCast
-      ( GetEngine()->GetObject( GetDocID(), entry, false ));
-    if ( !field.IsNull() )
-      fields->Append( field );
+    Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), entry, false);
+    if ( !anObj.IsNull() && anObj->IsKind(STANDARD_TYPE(GEOM_Field)) )
+    {
+        Handle(GEOM_Field) field = Handle(GEOM_Field)::DownCast( anObj );
+        if ( !field.IsNull() )
+          fields->Append( field );
+    }
   }
 
   return fields;