Salome HOME
ILMAB project. DS for the Field on Geometry implemented
authoreap <eap@opencascade.com>
Mon, 30 Sep 2013 11:45:32 +0000 (11:45 +0000)
committereap <eap@opencascade.com>
Mon, 30 Sep 2013 11:45:32 +0000 (11:45 +0000)
51 files changed:
idl/GEOM_Gen.idl
resources/CMakeLists.txt
resources/tree_field_edge.png [new file with mode: 0644]
resources/tree_field_face.png [new file with mode: 0644]
resources/tree_field_solid.png [new file with mode: 0644]
resources/tree_field_vertex.png [new file with mode: 0644]
src/GEOM/CMakeLists.txt
src/GEOM/GEOM_BaseDriver.hxx
src/GEOM/GEOM_BaseObject.cxx [new file with mode: 0644]
src/GEOM/GEOM_BaseObject.hxx [new file with mode: 0644]
src/GEOM/GEOM_Engine.cxx
src/GEOM/GEOM_Engine.hxx
src/GEOM/GEOM_Field.cxx [new file with mode: 0644]
src/GEOM/GEOM_Field.hxx [new file with mode: 0644]
src/GEOM/GEOM_Function.cxx
src/GEOM/GEOM_Function.hxx
src/GEOM/GEOM_IField.hxx [new file with mode: 0644]
src/GEOM/GEOM_Object.cxx
src/GEOM/GEOM_Object.hxx
src/GEOM/GEOM_PythonDump.cxx
src/GEOM/GEOM_PythonDump.hxx
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMImpl/CMakeLists.txt
src/GEOMImpl/GEOMImpl_FieldDriver.cxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_FieldDriver.hxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_Gen.cxx
src/GEOMImpl/GEOMImpl_Gen.hxx
src/GEOMImpl/GEOMImpl_IFieldOperations.cxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_IFieldOperations.hxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_IGroupOperations.cxx
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOM_I/CMakeLists.txt
src/GEOM_I/GEOM_BaseObject_i.cc [new file with mode: 0644]
src/GEOM_I/GEOM_BaseObject_i.hh [new file with mode: 0644]
src/GEOM_I/GEOM_DumpPython.cc
src/GEOM_I/GEOM_Field_i.cc [new file with mode: 0644]
src/GEOM_I/GEOM_Field_i.hh [new file with mode: 0644]
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh
src/GEOM_I/GEOM_IFieldOperations_i.cc [new file with mode: 0644]
src/GEOM_I/GEOM_IFieldOperations_i.hh [new file with mode: 0644]
src/GEOM_I/GEOM_IHealingOperations_i.cc
src/GEOM_I/GEOM_IOperations_i.cc
src/GEOM_I/GEOM_IOperations_i.hh
src/GEOM_I/GEOM_Object_i.cc
src/GEOM_I/GEOM_Object_i.hh
src/GEOM_I/GEOM_wrap.hxx
src/GEOM_SWIG/geomBuilder.py

index 7aaaa622c632a5f4cfb66df2b92b4f0097ae6f67..211d7c3584bdcedd1aedc535e9525b1c387c5c2a 100644 (file)
@@ -190,6 +190,17 @@ module GEOM
     HEXAGON
   };
 
+ /*!
+   * \brief Type of field data
+   */
+  enum field_data_type {
+    FDT_Bool,
+    FDT_Int,
+    FDT_Double,
+    FDT_String
+  };
+
+
  /*!
    * \brief Object creation parameters
    *
@@ -217,16 +228,32 @@ module GEOM
   typedef sequence<double>      ListOfDouble;
 
   interface GEOM_Object;
+  interface GEOM_BaseObject;
+  interface GEOM_Field;
+  interface GEOM_FieldStep;
 
-  typedef sequence<GEOM_Object> ListOfGO;
+  typedef sequence<GEOM_Object>       ListOfGO;
+  typedef sequence<GEOM_BaseObject>   ListOfGBO;
+  typedef sequence<GEOM_Field>        ListOfFields;
   typedef sequence<SALOMEDS::SObject> object_list;
 
-  //# GEOM_Object
+  //# GEOM_BaseObject
   /*!
-   *  \brief Interface of geometric object
+   *  \brief A common root of objects in GEOM module
    */
-  interface GEOM_Object : SALOME::GenericObj
+  interface GEOM_BaseObject : SALOME::GenericObj
   {
+    /*!
+     *  \brief Set name of the object.
+     *
+     *  \param theName is a name which will be associated with this object.
+     */
+    void SetName (in string theName);
+
+    /*!
+    *  \brief Get name of the object associated with this object.
+     */
+    string GetName();
 
     /*!
      *  \brief Get internal (unique) entry of the object in the GEOM component's data tree.
@@ -246,6 +273,67 @@ module GEOM
      */
     long GetType();
 
+    /*!
+     *  \brief Set a Study entry where this object was published.
+     */
+    void SetStudyEntry (in string theEntry);
+
+    /*!
+     *  \brief Get a Study entry where this object was published.
+     */
+    string GetStudyEntry();
+
+    /*!
+     *  \brief Get a list of all GEOM_Object on which were the arguments
+     *  when this object was constructed and modified.
+     *  \note This method is supposed to be used by GUI only.
+     */
+    ListOfGBO GetDependency();
+
+    /*!
+     *  \brief Get a list of GEOM_Object on which the last function that created or modified the object depends.
+     *  \note This method is supposed to be used by GUI only.
+     */
+    ListOfGBO GetLastDependency();
+
+    /*
+     *  \brief Return true if geom object representes a shape.
+     *
+     *  For example, method return false for GEOM_MARKER
+     */
+     boolean IsShape();
+
+    /*
+     *  \brief Return true if passed object is identical to this object
+     *
+     *  \param other object being compared with this one
+     */
+    boolean IsSame(in GEOM_BaseObject other);
+
+     /*!
+     *  Set list of parameters
+     *  \param theParameters is a string containing the notebook variables separated by ":" symbol,
+     *         used for object creation
+     */
+    void SetParameters (in string theParameters);
+
+    /*!
+     *  \brief Return list of notebook variables used for object creation separated by ":" symbol
+     */
+    string GetParameters();
+
+    /*!
+     * \brief Return name of operation and values of parameters used for object creation
+     */
+    CreationInformation GetCreationInformation();
+  };
+
+  //# GEOM_Object
+  /*!
+   *  \brief Interface of geometric object
+   */
+  interface GEOM_Object : GEOM_BaseObject
+  {
     /*!
      *  \brief Get a <VAR>shape_type</VAR> of the object value.
      */
@@ -283,18 +371,6 @@ module GEOM
      */
     shape_type GetMaxShapeType();
 
-    /*!
-     *  \brief Set name of the object.
-     *
-     *  \param theName is a name which will be associated with this object.
-     */
-    void SetName (in string theName);
-
-    /*!
-     *  \brief Get name of the object associated with this object.
-     */
-    string GetName();
-
     /*!
      *  \brief Set color of the object.
      *
@@ -351,29 +427,6 @@ module GEOM
      */
     long GetMarkerTexture();
 
-    /*!
-     *  \brief Set a Study entry where this object was published.
-     */
-    void SetStudyEntry (in string theEntry);
-
-    /*!
-     *  \brief Get a Study entry where this object was published.
-     */
-    string GetStudyEntry();
-
-    /*!
-     *  \brief Get a list of all GEOM_Object on which were the arguments
-     *  when this object was constructed and modified.
-     *  \note This method is supposed to be used by GUI only.
-     */
-    ListOfGO GetDependency();
-
-    /*!
-     *  \brief Get a list of GEOM_Object on which the last function that created or modified the object depends.
-     *  \note This method is supposed to be used by GUI only.
-     */
-    ListOfGO GetLastDependency();
-
     /*!
      *  \brief Get the TopoDS_Shape, for colocated case only.
      */
@@ -405,36 +458,166 @@ module GEOM
      */
     GEOM_Object GetMainShape();
 
-    /*
-     *  \brief Return true if geom object representes a shape.
-     *
-     *  For example, method return false for GEOM_MARKER
+  };
+
+  //# GEOM_Field
+  /*!
+   *  \brief Interface of the field
+   */
+  interface GEOM_Field : GEOM_BaseObject
+  {
+    /*!
+     *  \brief Returns the shape the field lies on
      */
-     boolean IsShape();
+    GEOM_Object GetShape();
 
-    /*
-     *  \brief Return true if passed object is identical to this object
-     *
-     *  \param other object being compared with this one
+    /*!
+     *  \brief Returns type of field data
      */
-    boolean IsSame(in GEOM_Object other);
+    field_data_type GetDataType();
 
-     /*!
-     *  Set list of parameters
-     *  \param theParameters is a string containing the notebook variables separated by ":" symbol,
-     *         used for object creation
+    /*!
+     *  \brief Returns dimension of the shape the field lies on
+     *  0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
      */
-    void SetParameters (in string theParameters);
+    short GetDimension();
 
     /*!
-     *  \brief Return list of notebook variables used for object creation separated by ":" symbol
+     *  \brief Returns names of components
      */
-    string GetParameters();
+    string_array GetComponents();
 
     /*!
-     * \brief Return name of operation and values of parameters used for object creation
+     *  \brief Removes a component. Component number counts from one.
      */
-    CreationInformation GetCreationInformation();
+    //void RemoveComponent(in long number);
+
+    /*!
+     *  \brief Adds a time step to the field
+     */
+    GEOM_FieldStep AddStep(in long stepID, in long stamp);
+
+    /*!
+     *  \brief Remove a time step from the field
+     */
+    void RemoveStep(in long stepID);
+
+    /*!
+     *  \brief Returns number of time steps in the field
+     */
+    long CountSteps();
+
+    /*!
+     *  \brief Returns a list of time step IDs in the field
+     */
+    ListOfLong GetSteps();
+
+    /*!
+     *  \brief Returns a time step by its ID
+     */
+    GEOM_FieldStep GetStep(in long stepID);
+
+    /*!
+     *  \brief Returns a size of data array that is to be passed to
+     *         GEOM_FieldStep.SetValues( dataArray ). This size depends on the
+     *         number of sub-shapes of field dimension and the number of components
+     */
+    long GetArraySize();
+  };
+
+  // # GEOM_FieldStep:
+  /*!
+   *  \brief Interface of the field time step
+   */
+  interface GEOM_FieldStep : GEOM_BaseObject
+  {
+    /*!
+     *  \brief Changes the time of the field step
+     */
+    void SetStamp(in long stamp);
+
+    /*!
+     *  \brief Returns the time of the field step
+     */
+    long GetStamp();
+
+    /*!
+     *  \brief Returns the number of the field step
+     */
+    long GetID();
+
+    /*!
+     *  \brief Returns the field the step belongs to
+     */
+    GEOM_Field GetField();
+  };
+
+  // # GEOM_BoolFieldStep:
+  /*!
+   *  \brief Interface of the boolean field time step
+   */
+  interface GEOM_BoolFieldStep : GEOM_FieldStep
+  {
+    /*!
+     *  \brief Changes values of the field step. Returns false if number of values is wrong
+     */
+    boolean SetValues(in short_array boolValues);
+
+    /*!
+     *  \brief Returns values of the field step
+     */
+    short_array GetValues();
+  };
+
+  // # GEOM_IntFieldStep:
+  /*!
+   *  \brief Interface of the integer field time step
+   */
+  interface GEOM_IntFieldStep : GEOM_FieldStep
+  {
+    /*!
+     *  \brief Changes values of the field step. Returns false if number of values is wrong
+     */
+    boolean SetValues(in ListOfLong intValues);
+
+    /*!
+     *  \brief Returns values of the field step
+     */
+    ListOfLong GetValues();
+  };
+
+  // # GEOM_DoubleFieldStep:
+  /*!
+   *  \brief Interface of the double field time step
+   */
+  interface GEOM_DoubleFieldStep : GEOM_FieldStep
+  {
+    /*!
+     *  \brief Changes values of the field step. Returns false if number of values is wrong
+     */
+    boolean SetValues(in ListOfDouble doubleValues);
+
+    /*!
+     *  \brief Returns values of the field step
+     */
+    ListOfDouble GetValues();
+  };
+
+  // # GEOM_StringFieldStep:
+  /*!
+   *  \brief Interface of the string field time step
+   */
+  interface GEOM_StringFieldStep : GEOM_FieldStep
+  {
+    /*!
+     *  \brief Changes values of the field step. Returns false if number of values is wrong
+     */
+    boolean SetValues(in string_array strValues);
+
+    /*!
+     *  \brief Returns values of the field step
+     */
+    string_array GetValues();
   };
 
   // # GEOM_IOperations:
@@ -2284,7 +2467,7 @@ module GEOM
      *  \return found sub-shape.
      */
     GEOM_Object GetSame (in GEOM_Object theShapeWhere,
-                                in GEOM_Object theShapeWhat);
+                         in GEOM_Object theShapeWhat);
 
     /*!
      *  \brief Get sub-shape Ids of theShapeWhere, which are
@@ -4442,6 +4625,41 @@ module GEOM
     /*@@ insert new functions before this line @@ do not remove this line @@*/
   };
 
+ // # GEOM_IFieldOperations:
+  /*!
+   *  \brief Interface for field operation.
+   */
+  interface GEOM_IFieldOperations : GEOM_IOperations
+  {
+    /*!
+     *  \brief Creates a field
+     */
+    GEOM_Field CreateField(in GEOM_Object     shape, 
+                           in string          name,
+                           in field_data_type type,
+                           in short           dimension,
+                           in string_array    componentNames);
+    /*!
+     *  \brief Returns number of fields on a shape
+     */
+    long CountFields(in GEOM_Object shape);
+
+    /*!
+     *  \brief Returns all fields on a shape
+     */
+    ListOfFields GetFields(in GEOM_Object shape);
+
+    /*!
+     *  \brief Returns a field on a shape by its name
+     */
+    GEOM_Field GetField(in GEOM_Object shape, in string name);
+
+    /*!
+     *  \brief Returns number of sub-shapes of given dimension
+     */
+    long GetNbSubShapes(in GEOM_Object shape, in short fieldDim);
+  };
+
  // # GEOM_Gen:
   /*!
    *  \brief Interface to access other GEOM interfaces.
@@ -4466,9 +4684,9 @@ module GEOM
      * Returns a SObject where theObject is placed
      */
     SALOMEDS::SObject AddInStudy (in SALOMEDS::Study theStudy,
-                                  in GEOM_Object theObject,
-                                  in string theName,
-                                  in GEOM_Object theFather);
+                                  in GEOM_BaseObject theObject,
+                                  in string          theName,
+                                  in GEOM_BaseObject theFather);
 
     /*!
      *  \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments
@@ -4577,6 +4795,7 @@ module GEOM
     GEOM_IMeasureOperations   GetIMeasureOperations  (in long theStudyID) raises (SALOME::SALOME_Exception);
     GEOM_IBlocksOperations    GetIBlocksOperations   (in long theStudyID) raises (SALOME::SALOME_Exception);
     GEOM_IGroupOperations     GetIGroupOperations    (in long theStudyID) raises (SALOME::SALOME_Exception);
+    GEOM_IFieldOperations     GetIFieldOperations    (in long theStudyID) raises (SALOME::SALOME_Exception);
 
     GEOM_IOperations GetPluginOperations (in long   theStudyID,
                                           in string theLibName) raises (SALOME::SALOME_Exception);
@@ -4588,7 +4807,7 @@ module GEOM
      *  \brief Removes the object from the GEOM component
      *  \param theObject is a GEOM_Object to be removed
      */
-    void RemoveObject (in GEOM_Object theObject);
+    void RemoveObject (in GEOM_BaseObject theObject);
 
     /*!
      *  \brief Returns an object defined by the study and its entry in the GEOM component
@@ -4596,7 +4815,7 @@ module GEOM
      *  \param theEntry is an entry of the requested GEOM_Object in the GEOM component
      *  \note if the object has not previously been created a NULL GEOM_Object is returned
      */
-    GEOM_Object GetObject (in long theStudyID, in string theEntry);
+    GEOM_BaseObject GetObject (in long theStudyID, in string theEntry);
 
     /*!
      *  \brief Add a sub-shape defined by indices in \a theIndices
index 164807296fca086e808e26192397a6c9b51ea31f..d6b0e279b905af50cb6524a2d83bbf39c3bf5536 100755 (executable)
@@ -182,6 +182,10 @@ SET( _res_files
   tree_group_edge.png
   tree_group_face.png
   tree_group_solid.png
+  tree_field_vertex.png
+  tree_field_edge.png
+  tree_field_face.png
+  tree_field_solid.png
   tree_lcs.png
   vector.png
   vector_mode.png
diff --git a/resources/tree_field_edge.png b/resources/tree_field_edge.png
new file mode 100644 (file)
index 0000000..410c233
Binary files /dev/null and b/resources/tree_field_edge.png differ
diff --git a/resources/tree_field_face.png b/resources/tree_field_face.png
new file mode 100644 (file)
index 0000000..0f1743c
Binary files /dev/null and b/resources/tree_field_face.png differ
diff --git a/resources/tree_field_solid.png b/resources/tree_field_solid.png
new file mode 100644 (file)
index 0000000..c64d0ea
Binary files /dev/null and b/resources/tree_field_solid.png differ
diff --git a/resources/tree_field_vertex.png b/resources/tree_field_vertex.png
new file mode 100644 (file)
index 0000000..68933db
Binary files /dev/null and b/resources/tree_field_vertex.png differ
index d71cf09672a60759a109139b791ec739d8ee86e5..a1ce3979a09c3659dad6af2058b222e8c5d8ca24 100755 (executable)
@@ -53,6 +53,7 @@ SET(GEOM_HEADERS
   GEOM_Engine.hxx
   GEOM_Function.hxx
   GEOM_Object.hxx
+  GEOM_Field.hxx
   GEOM_BaseDriver.hxx
   GEOM_SubShapeDriver.hxx
   GEOM_IOperations.hxx
@@ -71,7 +72,9 @@ SET(GEOM_SOURCES
   GEOM_Application.cxx
   GEOM_Engine.cxx
   GEOM_Function.cxx
+  GEOM_BaseObject.cxx
   GEOM_Object.cxx
+  GEOM_Field.cxx
   GEOM_IOperations.cxx
   GEOM_Solver.cxx
   GEOM_BaseDriver.cxx
index 0508c3d8fdf2a8ae1dd56690aa3b3682e4275f2b..449af202a03f2bce308c4c9ef8239551a3f6c10f 100644 (file)
@@ -78,14 +78,15 @@ public:
   // Adds GEOM_Param to params and sets its name
   // This method is safer than resizing the params vector and accessing to its items
   Standard_EXPORT GEOM_Param& AddParam(std::vector<GEOM_Param>& params,
-                       const char*              name);
+                                       const char*              name);
 
   // Adds GEOM_Param to params vector and sets its name and value
   // This method is safer than resizing the params vector and accessing to its items
-  template <class T> Standard_EXPORT GEOM_Param& AddParam(std::vector<GEOM_Param>& params,
-                                          const char*              name,
-                                          const T&                 value,
-                                          const char*              dfltValue = 0)
+  template <class T>
+  Standard_EXPORT GEOM_Param& AddParam(std::vector<GEOM_Param>& params,
+                                       const char*              name,
+                                       const T&                 value,
+                                       const char*              dfltValue = 0)
   {
     GEOM_Param p;
     p.Set( name, value );
diff --git a/src/GEOM/GEOM_BaseObject.cxx b/src/GEOM/GEOM_BaseObject.cxx
new file mode 100644 (file)
index 0000000..0433506
--- /dev/null
@@ -0,0 +1,519 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_BaseObject.hxx"
+#include "GEOM_Engine.hxx"
+
+#include <TCollection_ExtendedString.hxx>
+#include <TDF_Data.hxx>
+#include <TDF_LabelSequence.hxx>
+#include <TDF_Reference.hxx>
+#include <TDF_Tool.hxx>
+#include <TDataStd_ChildNodeIterator.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDocStd_Owner.hxx>
+#include <TFunction_Driver.hxx>
+#include <TFunction_DriverTable.hxx>
+
+#include "utilities.h"
+
+
+#define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
+#define TYPE_LABEL       2
+#define FREE_LABEL       3
+#define TIC_LABEL        4
+// #define COLOR_LABEL      5 -- Labels used by GEOM_Object
+// #define AUTO_COLOR_LABEL 6
+// #define MARKER_LABEL     7
+
+
+//=======================================================================
+//function : GetObjectID
+//purpose  :
+//=======================================================================
+
+const Standard_GUID& GEOM_BaseObject::GetObjectID()
+{
+  static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16");
+  return anObjectID;
+}
+
+//=======================================================================
+//function : GetSubShapeID
+//purpose  :
+//=======================================================================
+
+const Standard_GUID& GEOM_BaseObject::GetSubShapeID()
+{
+  static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16");
+  return anObjectID;
+}
+
+//=============================================================================
+/*!
+ *  GetObject
+ */
+//=============================================================================
+
+Handle(GEOM_BaseObject) GEOM_BaseObject::GetObject(const TDF_Label& theLabel)
+{
+  if (!theLabel.IsAttribute(GetObjectID())) return NULL;
+
+  TCollection_AsciiString anEntry;
+  TDF_Tool::Entry(theLabel, anEntry);
+
+  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theLabel.Data());
+  if(aDoc.IsNull()) return NULL;
+
+  Handle(TDataStd_Integer) anID;
+  if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL;
+
+  GEOM_Engine* anEngine = GEOM_Engine::GetEngine();
+  if(anEngine == NULL) return NULL;
+  return anEngine->GetObject(anID->Get(), anEntry.ToCString());
+}
+
+//=============================================================================
+/*!
+ *  GetReferencedObject
+ */
+//=============================================================================
+Handle(GEOM_BaseObject) GEOM_BaseObject::GetReferencedObject(const TDF_Label& theLabel)
+{
+  Handle(TDF_Reference) aRef;
+  if (!theLabel.FindAttribute(TDF_Reference::GetID(), aRef)) {
+    return NULL;
+  }
+  
+  if(aRef.IsNull() || aRef->Get().IsNull()) {
+    return NULL;
+  }
+
+
+  // Get TreeNode of a referenced function
+  Handle(TDataStd_TreeNode) aT, aFather;
+  if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) {
+    return NULL;
+  }
+
+
+  // Get TreeNode of Object of the referenced function
+  aFather = aT->Father();
+  if (aFather.IsNull()) {
+    return NULL;
+  }
+
+  // Get label of the referenced object
+  TDF_Label aLabel = aFather->Label();
+  
+
+  return GEOM_BaseObject::GetObject(aLabel);
+}
+
+//=======================================================================
+//function : GetEntryString
+//purpose  : Returns an entry of this GEOM_BaseObject
+//=======================================================================
+
+TCollection_AsciiString GEOM_BaseObject::GetEntryString()
+{
+  TCollection_AsciiString anEntry;
+  TDF_Tool::Entry( GetEntry(), anEntry );
+  return anEntry;
+}
+
+//=======================================================================
+//function : GetType
+//purpose  : Returns type of an object (GEOM_POINT, GEOM_VECTOR...) on theLabel,
+//           -1 if no object is there
+//=======================================================================
+
+int GEOM_BaseObject::GetType(const TDF_Label& theLabel)
+{
+  Handle(TDataStd_Integer) aType;
+  if(theLabel.IsNull() ||
+     !theLabel.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType))
+    return -1;
+
+  return aType->Get();
+}
+
+//=============================================================================
+/*!
+ *  Constructor: private
+ */
+//=============================================================================
+GEOM_BaseObject::GEOM_BaseObject(const TDF_Label& theEntry)
+  : _label(theEntry), _ior(""), _docID(-1)
+{
+  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
+  if(!aDoc.IsNull()) {
+    Handle(TDataStd_Integer) anID;
+    if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
+  }
+
+  if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
+    _root = TDataStd_TreeNode::Set(theEntry);
+}
+
+//=============================================================================
+/*!
+ *  Constructor: public
+ */
+//=============================================================================
+GEOM_BaseObject::GEOM_BaseObject(const TDF_Label& theEntry, int theType)
+: _label(theEntry), _ior(""), _docID(-1)
+{
+  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
+  if(!aDoc.IsNull()) {
+    Handle(TDataStd_Integer) anID;
+    if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
+  }
+
+  theEntry.ForgetAllAttributes(Standard_True);
+
+  if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
+    _root = TDataStd_TreeNode::Set(theEntry);
+
+  TDataStd_Integer::Set(theEntry.FindChild(TYPE_LABEL), theType);
+
+  TDataStd_UAttribute::Set(theEntry, GetObjectID());
+}
+
+//=============================================================================
+/*!
+ *  Destructor
+ */
+//=============================================================================
+GEOM_BaseObject::~GEOM_BaseObject()
+{
+  MESSAGE("GEOM_BaseObject::~GEOM_BaseObject()");
+}
+
+//=============================================================================
+/*!
+ *  GetType
+ */
+//=============================================================================
+int GEOM_BaseObject::GetType()
+{
+  Handle(TDataStd_Integer) aType;
+  if(!_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1;
+
+  return aType->Get();
+}
+
+//=============================================================================
+/*!
+ *  SetType
+ */
+//=============================================================================
+void GEOM_BaseObject::SetType(int theType)
+{
+  TDataStd_Integer::Set(_label.FindChild(TYPE_LABEL), theType);
+}
+
+
+//=============================================================================
+/*!
+ *  Returns modifications counter of this object.
+ *  Comparing this value with modifications counters of argument objects
+ *  (on which this object depends) we decide whether this object needs to be updated.
+ */
+//=============================================================================
+int GEOM_BaseObject::GetTic()
+{
+  Handle(TDataStd_Integer) aTicAttr;
+  if (!_label.FindChild(TIC_LABEL).FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
+    return 0;
+
+  return aTicAttr->Get();
+}
+
+//=============================================================================
+/*!
+ *  Set another value of modifications counter.
+ *
+ *  Use this method to update modifications counter of dependent object
+ *  to be equal to modifications counter of its argument.
+ *  This is commonly done in GEOM_Function::GetValue()
+ */
+//=============================================================================
+void GEOM_BaseObject::SetTic(int theTic)
+{
+  TDataStd_Integer::Set(_label.FindChild(TIC_LABEL), theTic);
+}
+
+//=============================================================================
+/*!
+ *  Increment modifications counter to mark this object as modified.
+ *
+ *  Commonly called from GEOM_Function::SetValue()
+ */
+//=============================================================================
+void GEOM_BaseObject::IncrementTic()
+{
+  TDF_Label aTicLabel = _label.FindChild(TIC_LABEL);
+
+  Standard_Integer aTic = 0;
+  Handle(TDataStd_Integer) aTicAttr;
+  if (aTicLabel.FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
+    aTic = aTicAttr->Get();
+
+  TDataStd_Integer::Set(aTicLabel, aTic + 1);
+}
+
+
+//=============================================================================
+/*!
+ *  GetDocID
+ */
+//=============================================================================
+int GEOM_BaseObject::GetDocID()
+{
+  return _docID;
+}
+
+//=============================================================================
+/*!
+ *  SetName
+ */
+//=============================================================================
+void GEOM_BaseObject::SetName(const char* theName)
+{
+  TDataStd_Name::Set(_label, (char*)theName);
+}
+
+//=============================================================================
+/*!
+ *  GetName
+ */
+//=============================================================================
+TCollection_AsciiString GEOM_BaseObject::GetName()
+{
+  TCollection_AsciiString aName;
+  Handle(TDataStd_Name) aNameAttr;
+  if(_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+    aName = aNameAttr->Get();
+  // do not return pointer of local variable
+  // return aName.ToCString();
+  // the following code could lead to memory leak, so take care about recieved pointer
+  return aName;
+}
+
+//=============================================================================
+/*!
+ *  SetAuxData
+ */
+//=============================================================================
+void GEOM_BaseObject::SetAuxData(const char* theData)
+{
+  TDataStd_Comment::Set(_label, (char*)theData);
+}
+
+//=============================================================================
+/*!
+ *  GetAuxData
+ */
+//=============================================================================
+TCollection_AsciiString GEOM_BaseObject::GetAuxData()
+{
+  TCollection_AsciiString aData;
+
+  Handle(TDataStd_Comment) aCommentAttr;
+  if (_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr))
+    aData = aCommentAttr->Get();
+
+  return aData;
+}
+
+//=============================================================================
+/*!
+ *  SetParameters
+ */
+//=============================================================================
+void GEOM_BaseObject::SetParameters(const TCollection_AsciiString& theParameters)
+{
+  if( _parameters.IsEmpty() )
+    _parameters = theParameters;
+  else {
+    _parameters += "|";
+    _parameters += theParameters;
+  }
+}
+
+//=============================================================================
+/*!
+ *  GetParameters
+ */
+//=============================================================================
+TCollection_AsciiString GEOM_BaseObject::GetParameters() const
+{
+  return _parameters;
+}
+
+//=============================================================================
+/*!
+ *  AddFunction
+ */
+//=============================================================================
+Handle(GEOM_Function) GEOM_BaseObject::AddFunction(const Standard_GUID& theGUID,
+                                                   int                  theFunctionType,
+                                                   bool                 allowSubShape)
+{
+  Standard_Integer nb = GetNbFunctions();
+  if(!allowSubShape && nb == 1 && theGUID == GetSubShapeID()) return NULL; //It's impossible to add a function to sub-shape
+  TDF_Label aChild = FUNCTION_LABEL(++nb);
+
+  Handle(TDataStd_TreeNode) aNode = TDataStd_TreeNode::Set(aChild);
+  _root->Append(aNode);
+
+  Handle(GEOM_Function) aFunction = new GEOM_Function(aChild, theGUID, theFunctionType);
+
+  return aFunction;
+}
+
+//=============================================================================
+/*!
+ *  GetNbFunctions
+ */
+//=============================================================================
+int GEOM_BaseObject::GetNbFunctions()
+{
+  Standard_Integer nb = 0;
+  for(TDataStd_ChildNodeIterator CI(_root); CI.More(); CI.Next()) nb++;
+  return nb;
+}
+
+//=============================================================================
+/*!
+ *  GetFunction
+ */
+//=============================================================================
+Handle(GEOM_Function) GEOM_BaseObject::GetFunction(int theFunctionNumber)
+{
+  TDF_Label aChild = FUNCTION_LABEL(theFunctionNumber);
+  return GEOM_Function::GetFunction(aChild);
+}
+
+//=============================================================================
+/*!
+ *  GetlastFunction
+ */
+//=============================================================================
+Handle(GEOM_Function) GEOM_BaseObject::GetLastFunction()
+{
+  Standard_Integer nb = GetNbFunctions();
+  if(nb) return GetFunction(nb);
+
+  return NULL;
+}
+
+//=============================================================================
+/*!
+ *  GetAllDependency
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOM_BaseObject::GetAllDependency()
+{
+  Handle(TColStd_HSequenceOfTransient) anArray;
+  TDF_LabelSequence aSeq;
+  Standard_Integer nb = GetNbFunctions();
+  if(nb == 0) return anArray;
+  for(Standard_Integer i=1; i<=nb; i++) {
+    Handle(GEOM_Function) aFunction = GetFunction(i);
+    if(aFunction.IsNull()) continue;
+    aFunction->GetDependency(aSeq);
+  }
+
+  Standard_Integer aLength = aSeq.Length();
+  if(aLength > 0) {
+    anArray = new TColStd_HSequenceOfTransient;
+    for(Standard_Integer j =1; j<=aLength; j++) {
+      Handle(GEOM_BaseObject) aRefObj = GetReferencedObject(aSeq(j));
+      if(!aRefObj.IsNull()) anArray->Append(aRefObj);
+    }
+  }
+
+  return anArray;
+}
+
+//=============================================================================
+/*!
+ *  GetLastDependency
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOM_BaseObject::GetLastDependency()
+{
+  Handle(TColStd_HSequenceOfTransient) anArray;
+  Handle(GEOM_Function) aFunction = GetLastFunction();
+  if (aFunction.IsNull()) return anArray;
+
+  TDF_LabelSequence aSeq;
+  aFunction->GetDependency(aSeq);
+  Standard_Integer aLength = aSeq.Length();
+  if (aLength > 0) {
+    anArray = new TColStd_HSequenceOfTransient;
+    for (Standard_Integer i = 1; i <= aLength; i++)
+      anArray->Append(GetReferencedObject(aSeq(i)));
+  }
+
+  return anArray;
+}
+
+//================================================================================
+/*!
+ * \brief Returns a driver creator of this object
+ */
+//================================================================================
+
+Handle(TFunction_Driver) GEOM_BaseObject::GetCreationDriver()
+{
+  Handle(TFunction_Driver) aDriver;
+
+  Handle(GEOM_Function) function = GetFunction(1);
+  if ( !function.IsNull() )
+  {
+    Standard_GUID aGUID = function->GetDriverGUID();
+    if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver))
+      aDriver->Init( function->GetEntry() );
+  }
+  return aDriver;
+}
+
+//=============================================================================
+/*!
+ *  GetFreeLabel
+ */
+//=============================================================================
+TDF_Label GEOM_BaseObject::GetFreeLabel()
+{
+  return _label.FindChild(FREE_LABEL);
+}
+
+IMPLEMENT_STANDARD_HANDLE (GEOM_BaseObject, Standard_Transient );
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_BaseObject, Standard_Transient );
diff --git a/src/GEOM/GEOM_BaseObject.hxx b/src/GEOM/GEOM_BaseObject.hxx
new file mode 100644 (file)
index 0000000..d20cc8e
--- /dev/null
@@ -0,0 +1,170 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOM_BaseObject_HeaderFile
+#define _GEOM_BaseObject_HeaderFile
+
+#include "GEOM_Function.hxx"
+
+#include <Standard_GUID.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <TDataStd_TreeNode.hxx>
+
+class GEOM_BaseObject;
+class Handle(TFunction_Driver);
+class GEOM_Engine;
+
+DEFINE_STANDARD_HANDLE( GEOM_BaseObject, Standard_Transient );
+
+class GEOM_BaseObject : public Standard_Transient
+{
+  friend class GEOM_Engine;
+
+protected:
+  Standard_EXPORT GEOM_BaseObject(const TDF_Label& theLabel);
+
+public:
+
+  Standard_EXPORT GEOM_BaseObject(const TDF_Label& theEntry, int theType);
+  Standard_EXPORT ~GEOM_BaseObject();
+
+  //Finds a GEOM_BaseObject on the label theLabel
+  Standard_EXPORT static Handle(GEOM_BaseObject) GetObject(const TDF_Label& theLabel);
+
+  //Finds a GEOM_BaseObject by a reference, stored on the label theLabel
+  Standard_EXPORT static Handle(GEOM_BaseObject) GetReferencedObject(const TDF_Label& theLabel);
+
+  // Returns type of a object (GEOM_POINT, GEOM_VECTOR...) on theLabel, -1 if no object is there
+  Standard_EXPORT static int GetType(const TDF_Label& theLabel);
+
+  //Returns a GEOM_BaseObject common GUID.
+  // This GUID marks the label of any object in GEOM module
+  Standard_EXPORT static const Standard_GUID& GetObjectID();
+
+  //Returns a GUID associated with a sub-shape object
+  // This GUID corresponds to GEOM_SubShapeDriver
+  Standard_EXPORT static const Standard_GUID& GetSubShapeID();
+
+  //###########################################################
+  //Access to properties
+  //###########################################################
+
+  //Returns a TreeNode that presents a root of a function tree for this GEOM_BaseObject
+  Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
+
+  //Returns a label of this GEOM_BaseObject
+  Standard_EXPORT TDF_Label GetEntry() const { return _label; }
+
+  //Returns an entry of this GEOM_BaseObject
+  Standard_EXPORT TCollection_AsciiString GetEntryString();
+
+  //Returns a type of this GEOM_BaseObject (GEOM_POINT, GEOM_VECTOR...)
+  Standard_EXPORT int GetType();
+
+  //Sets the type of this GEOM_BaseObject
+  Standard_EXPORT void SetType(int theType);
+
+  //Modifications counter management
+  Standard_EXPORT int  GetTic();
+  Standard_EXPORT void SetTic(int theTic);
+  Standard_EXPORT void IncrementTic();
+
+  //Returns an ID of the OCAF document where this GEOM_BaseObject is stored
+  Standard_EXPORT int GetDocID();
+
+  //Sets a name of this GEOM_BaseObject
+  Standard_EXPORT void SetName(const char* theName);
+
+  //Returns a name of this GEOM_BaseObject
+  Standard_EXPORT TCollection_AsciiString GetName();
+
+  //Sets an auxiliary data
+  Standard_EXPORT void SetAuxData(const char* theData);
+
+  //Returns an auxiliary data
+  Standard_EXPORT TCollection_AsciiString GetAuxData();
+
+  //Set a notebook variables used for object creation
+  Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
+
+  //Get a notebook variables used for object creation
+  Standard_EXPORT TCollection_AsciiString GetParameters() const;
+
+  //###########################################################
+  // CORBA related methods
+  //###########################################################
+
+  //Sets an IOR of CORBA GEOM_BaseObject_i which refers to this object
+  Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
+
+  //Returns an IOR of CORBA GEOM_BaseObject_i which refers to this object
+  Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
+
+  //###########################################################
+  //Functions methods
+  //###########################################################
+
+  //Adds a function with a driver GUID = theGUID and a type theFunctionType
+  //to the function tree of this GEOM_BaseObject
+  Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID,
+                                                    int                  theFunctionType,
+                                                    bool                 allowSubShape=false);
+
+  //Returns a number of functions of this GEOM_BaseObject
+  Standard_EXPORT int GetNbFunctions();
+
+  //Returns a function with given number theFunctionNumber
+  Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
+
+  //Return the last function of this GEOM_BaseObject
+  Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
+
+  //Returns all dependencies of the object
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
+
+  //Returns the dependencies of the last function
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
+
+  //Returns a driver creator of this object
+  Standard_EXPORT Handle(TFunction_Driver) GetCreationDriver();
+
+  //###########################################################
+  // Internal methods
+  //###########################################################
+
+  //Returns a label which could be used to store some additional data
+  Standard_EXPORT TDF_Label GetFreeLabel();
+
+ protected:
+  Handle(TDataStd_TreeNode) _root;
+  TDF_Label                 _label;
+  TCollection_AsciiString   _ior;
+  TCollection_AsciiString   _parameters;
+  int                       _docID;
+
+public:
+  DEFINE_STANDARD_RTTI( GEOM_BaseObject );
+};
+
+#endif
index 30c9b449c9a697663899b958c382a4aee92e5985..e6b7e6ba5984f391e9ec2a70f278e3c6b60c58c5 100644 (file)
 
 #include "GEOM_Engine.hxx"
 
-#include "GEOM_Solver.hxx"
+#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
+#include "GEOM_Field.hxx"
 #include "GEOM_Function.hxx"
 #include "GEOM_ISubShape.hxx"
-#include "GEOM_SubShapeDriver.hxx"
-#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
 #include "GEOM_PythonDump.hxx"
+#include "GEOM_Solver.hxx"
+#include "GEOM_SubShapeDriver.hxx"
 #include "Sketcher_Profile.hxx"
 
 #include <Basics_OCCTVersion.hxx>
 #include <TColStd_MapOfTransient.hxx>
 #include <TColStd_HSequenceOfInteger.hxx>
 
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
 #include <TColStd_HArray1OfByte.hxx>
 #include <TColStd_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
-#else
-#include <TDataStd_HArray1OfByte.hxx>
-#include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
-#endif
 
 #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
 
@@ -97,7 +93,7 @@ typedef std::map< TCollection_AsciiString, TObjectData* >            TSting2ObjD
 static GEOM_Engine* TheEngine = NULL;
 
 
-static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject)
+static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_BaseObject)& theObject)
 {
   TCollection_AsciiString anID(theObject->GetDocID()), anEntry;
   TDF_Tool::Entry(theObject->GetEntry(), anEntry);
@@ -105,7 +101,7 @@ static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject)
   return anID;
 }
 
-static TCollection_AsciiString BuildID(Standard_Integer theDocID, char* theEntry)
+static TCollection_AsciiString BuildID(Standard_Integer theDocID, const char* theEntry)
 {
   TCollection_AsciiString anID(theDocID);
   anID+=(TCollection_AsciiString("_")+theEntry);
@@ -236,11 +232,7 @@ GEOM_Engine::~GEOM_Engine()
     RemoveObject(*objit);
 
   //Close all documents not closed
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
   TColStd_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
-#else
-  Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
-#endif
   for (; anItr.More(); anItr.Next())
   {
     Close(anItr.Key());
@@ -278,11 +270,7 @@ Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID, bool force)
 int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument)
 {
   if (theDocument.IsNull()) return -1;
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
   TColStd_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
-#else
-  Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
-#endif
   for (; anItr.More(); anItr.Next())
     if (anItr.Value() == theDocument) return anItr.Key();
 
@@ -294,22 +282,30 @@ int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument)
  *  GetObject
  */
 //=============================================================================
-Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry, bool force)
+
+Handle(GEOM_BaseObject) GEOM_Engine::GetObject(int theDocID, const char* theEntry, bool force)
 {
-  Handle(GEOM_Object) anObject;
+  Handle(GEOM_BaseObject) anObject;
 
   TCollection_AsciiString anID = BuildID(theDocID, theEntry);
 
   if (_objects.IsBound(anID)) {
-    anObject = Handle(GEOM_Object)::DownCast(_objects(anID));
+    anObject = Handle(GEOM_BaseObject)::DownCast(_objects(anID));
   }
   else if (force) {
     Handle(TDocStd_Document) aDoc = GetDocument(theDocID, force);
     if ( !aDoc.IsNull()) {
       TDF_Label aLabel;
       TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True);
-      anObject = new GEOM_Object(aLabel);
-      _objects.Bind(anID, anObject);
+      if ( !aLabel.IsNull() ) {
+        int objType = GEOM_BaseObject::GetType( aLabel );
+        switch ( objType ) {
+        case GEOM_FIELD_OBJTYPE:      anObject = new GEOM_Field    (aLabel); break;
+        case GEOM_FIELD_STEP_OBJTYPE: anObject = new GEOM_FieldStep(aLabel); break;
+        default:                      anObject = new GEOM_Object   (aLabel);
+        }
+        _objects.Bind(anID, anObject);
+      }
     }
   }
 
@@ -318,10 +314,11 @@ Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry, bool fo
 
 //=============================================================================
 /*!
- *  AddObject
+ *  AddBaseObject
  */
 //=============================================================================
-Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
+
+Handle(GEOM_BaseObject) GEOM_Engine::AddBaseObject(int theDocID, int theType)
 {
   Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
   Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
@@ -343,7 +340,12 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
     aChild = TDF_TagSource::NewChild(aDoc->Main());
   }
 
-  Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType);
+  Handle(GEOM_BaseObject) anObject;
+  switch ( theType ) {
+  case GEOM_FIELD_OBJTYPE:      anObject = new GEOM_Field    (aChild, theType); break;
+  case GEOM_FIELD_STEP_OBJTYPE: anObject = new GEOM_FieldStep(aChild, theType); break;
+  default:                      anObject = new GEOM_Object   (aChild, theType);
+  }
 
   //Put an object in the map of created objects
   TCollection_AsciiString anID = BuildIDFromObject(anObject);
@@ -353,12 +355,24 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
   return anObject;
 }
 
+//================================================================================
+/*!
+ * \brief Adds a new object of the type theType in the OCAF document
+ */
+//================================================================================
+
+Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
+{
+  return Handle(GEOM_Object)::DownCast( AddBaseObject(theDocID, theType) );
+}
+
 //=============================================================================
 /*!
  *  AddSubShape
  */
 //=============================================================================
-Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
+
+Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object)              theMainShape,
                                              Handle(TColStd_HArray1OfInteger) theIndices,
                                              bool isStandaloneOperation)
 {
@@ -438,7 +452,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
  *  RemoveObject
  */
 //=============================================================================
-bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
+bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject)
 {
   if (theObject.IsNull()) return false;
 
@@ -451,7 +465,8 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
   if (_objects.IsBound(anID)) _objects.UnBind(anID);
 
   // If sub-shape, remove it from the list of sub-shapes of its main shape
-  if (!theObject->IsMainShape()) {
+  Handle(GEOM_Object) aGO = Handle(GEOM_Object)::DownCast( theObject );
+  if ( !aGO.IsNull() && !aGO->IsMainShape()) {
     Handle(GEOM_Function) aFunction = theObject->GetFunction(1);
     GEOM_ISubShape aSSI (aFunction);
     Handle(GEOM_Function) aMainShape = aSSI.GetMainShape();
@@ -505,7 +520,7 @@ void GEOM_Engine::Redo(int theDocID)
  *  Save
  */
 //=============================================================================
-bool GEOM_Engine::Save(int theDocID, char* theFileName)
+bool GEOM_Engine::Save(int theDocID, const char* theFileName)
 {
   if(!_mapIDDocument.IsBound(theDocID)) return false;
   Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
@@ -520,14 +535,10 @@ bool GEOM_Engine::Save(int theDocID, char* theFileName)
  *  Load
  */
 //=============================================================================
-bool GEOM_Engine::Load(int theDocID, char* theFileName)
+bool GEOM_Engine::Load(int theDocID, const char* theFileName)
 {
   Handle(TDocStd_Document) aDoc;
-#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
   if (_OCAFApp->Open(theFileName, aDoc) != PCDM_RS_OK) {
-#else
-  if (_OCAFApp->Open(theFileName, aDoc) != CDF_RS_OK) {
-#endif
     return false;
   }
 
@@ -626,7 +637,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
     TDF_Label L;
     TDF_Tool::Label( aDoc->GetData(), data._entry, L );
     if ( L.IsNull() ) continue;
-    Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
+    Handle(GEOM_BaseObject) obj = GEOM_BaseObject::GetObject( L );
     // fill maps
     if ( !obj.IsNull() ) {
       TSting2ObjDataMap::iterator ent2Data =
index 38d954a0e34c4c048d6298ed8033e16dc4b2218d..b3c9febfe944d82c601cd2bcfdf268185dcb203a 100644 (file)
@@ -115,20 +115,25 @@ class GEOM_Engine
   //Returns the OCAF appliaction
   Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
 
-  //Returns a pointer to GEOM_Object defined by a document and the entry
-  Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, char* theEntry, bool force=true);
-  
+  //Returns a pointer to GEOM_BaseObject defined by a document and the entry
+  Standard_EXPORT Handle(GEOM_BaseObject) GetObject(int         theDocID,
+                                                    const char* theEntry,
+                                                    bool        force=true);
+
+  //Adds a new object of the type theType in the OCAF document
+  Standard_EXPORT Handle(GEOM_BaseObject) AddBaseObject(int theDocID, int theType);
+
   //Adds a new object of the type theType in the OCAF document
   Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
 
   //Removes the object from the OCAF document
-  Standard_EXPORT bool RemoveObject(Handle(GEOM_Object) theObject);  
+  Standard_EXPORT bool RemoveObject(Handle(GEOM_BaseObject)& theObject);  
 
   //Saves the OCAF document with ID = theDocID with file with name theFileName
-  Standard_EXPORT bool Save(int theDocID, char* theFileName);
+  Standard_EXPORT bool Save(int theDocID, const char* theFileName);
   
   //Loads the OCAF document into the application and assigns to it an ID = theDocID
-  Standard_EXPORT bool Load(int theDocID, char* theFileName);
+  Standard_EXPORT bool Load(int theDocID, const char* theFileName);
 
   //Closes the document with ID =  theDocID
   Standard_EXPORT void Close(int theDocID);
@@ -144,8 +149,8 @@ class GEOM_Engine
 
   //Adds a new sub-shape object of the MainShape object
   Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape, 
-                                  Handle(TColStd_HArray1OfInteger) theIndices,
-                                  bool isStandaloneOperation = false);
+                                                  Handle(TColStd_HArray1OfInteger) theIndices,
+                                                  bool isStandaloneOperation = false);
 
   Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID, 
                                                      std::vector<TObjectData>& theObjectData,
@@ -159,18 +164,10 @@ class GEOM_Engine
   Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
 
   Standard_EXPORT int addTexture(int theDocID, int theWidth, int theHeight,
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
                                  const Handle(TColStd_HArray1OfByte)& theTexture,
-#else
-                                 const Handle(TDataStd_HArray1OfByte)& theTexture,
-#endif
                                  const TCollection_AsciiString& theFileName = "");
 
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
-  Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int theDocID, int theTextureID,
-#else
-  Standard_EXPORT Handle(TDataStd_HArray1OfByte) getTexture(int theDocID, int theTextureID,
-#endif
+  Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int  theDocID, int theTextureID,
                                                            int& theWidth, int& theHeight,
                                                            TCollection_AsciiString& theFileName);
 
@@ -179,26 +176,22 @@ class GEOM_Engine
   static const Standard_GUID& GetTextureGUID();
 
   Standard_EXPORT void healPyName( TCollection_AsciiString&                  pyName,
-                                  const TCollection_AsciiString&            anEntry,
-                                  Resource_DataMapOfAsciiStringAsciiString& aNameToEntry);
+                                   const TCollection_AsciiString&            anEntry,
+                                   Resource_DataMapOfAsciiStringAsciiString& aNameToEntry);
 
  protected:
   Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);       
   
  private:
 
-  Handle(GEOM_Application)  _OCAFApp;
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
-  TColStd_DataMapOfIntegerTransient _mapIDDocument;
-#else
-  Interface_DataMapOfIntegerTransient _mapIDDocument;
-#endif
-  int _UndoLimit;
-  GEOM_DataMapOfAsciiStringTransient _objects;
+  Handle(GEOM_Application)                 _OCAFApp;
+  TColStd_DataMapOfIntegerTransient        _mapIDDocument;
+  int                                      _UndoLimit;
+  GEOM_DataMapOfAsciiStringTransient       _objects;
 
   Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
 
-  TFreeLabelsList _freeLabels;
+  TFreeLabelsList                          _freeLabels;
 };
 
 #endif
diff --git a/src/GEOM/GEOM_Field.cxx b/src/GEOM/GEOM_Field.cxx
new file mode 100644 (file)
index 0000000..bfc485c
--- /dev/null
@@ -0,0 +1,769 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_Field.hxx"
+
+#include "GEOM_IField.hxx"
+#include "GEOM_Engine.hxx"
+#include "GEOM_PythonDump.hxx"
+
+#include <Standard_MultiplyDefined.hxx>
+#include <TDataStd_ChildNodeIterator.hxx>
+#include <TDataStd_ExtStringArray.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include "utilities.h"
+
+#include <limits>
+
+using namespace GEOM;
+
+namespace
+{
+  //================================================================================
+  /*!
+   * \brief Returns a funtion with a given type OR the 1st function
+   */
+  //================================================================================
+
+  Handle(GEOM_Function) getFunction(int theFunType, GEOM_BaseObject* obj )
+  {
+    Handle(GEOM_Function) fun;
+    int nbFuns = obj->GetNbFunctions();
+    while ( nbFuns >= 1 )
+    {
+      fun = obj->GetFunction( nbFuns-- );
+      const int funType = fun->GetType();
+      if ( funType == theFunType )
+        return fun;
+    }
+    return fun; // function 1
+  }
+}
+
+//=============================================================================
+/*!
+ *  Constructor: private
+ */
+//=============================================================================
+
+GEOM_Field::GEOM_Field(const TDF_Label& theEntry)
+  : GEOM_BaseObject(theEntry), nbSubShapes(-1)
+{
+}
+
+//=============================================================================
+/*!
+ *  Constructor: public
+ */
+//=============================================================================
+
+GEOM_Field::GEOM_Field(const TDF_Label&    theEntry, int /*typ*/)
+  : GEOM_BaseObject( theEntry, GEOM_FIELD_OBJTYPE ), nbSubShapes(-1)
+{
+}
+
+//================================================================================
+/*!
+ * \brief Sets the basic data that do not change (except compNames?)
+ */
+//================================================================================
+
+void GEOM_Field::Init(const Handle(GEOM_Object)&                     theShape,
+                      const char*                                    theName,
+                      const int                                      theDataType,
+                      const int                                      theDimension,
+                      const Handle(TColStd_HArray1OfExtendedString)& theCompNames)
+{
+  Handle(GEOM_Function) fun = GetFunction(1);
+  if ( !fun.IsNull() )
+    Standard_MultiplyDefined::Raise( "Reinitialization of GEOM_Field is forbiden" );
+  fun = AddFunction( GetFieldID(), FUN_ADD_FIELD );
+
+  GEOM_IField data( fun );
+  data.SetShape     ( theShape->GetLastFunction() );
+  data.SetDataType  ( theDataType );
+  data.SetDimension ( theDimension );
+  data.SetComponents( theCompNames );
+
+  TPythonDump py( fun ); // prevent dump of SetName
+  SetName( theName );
+  // PythonDump to be done by the operation creating this field
+}
+
+//=============================================================================
+/*!
+ *  GetField
+ */
+//=============================================================================
+
+Handle(GEOM_Field) GEOM_Field::GetField(const TDF_Label& theLabel)
+{
+  Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel);
+  return Handle(GEOM_Field)::DownCast( base );
+}
+
+//=======================================================================
+//function : GetFieldID
+//purpose  :
+//=======================================================================
+
+const Standard_GUID& GEOM_Field::GetFieldID()
+{
+  static Standard_GUID anID("FF1BBB01-5252-4df2-980B-3A668264EA16");
+  return anID;
+}
+
+//=============================================================================
+/*!
+ *  Destructor
+ */
+//=============================================================================
+
+GEOM_Field::~GEOM_Field()
+{
+}
+
+//=============================================================================
+/*!
+ *  Returns a shape this GEOM_Field lies on
+ */
+//=============================================================================
+
+Handle(GEOM_Object) GEOM_Field::GetShape()
+{
+  Handle(GEOM_Object) shapeObject;
+
+  Handle(GEOM_Function) fun = GetFunction(1);
+  if ( !fun.IsNull() )
+  {
+    GEOM_IField data( fun );
+    Handle(GEOM_Function) shapeFun = data.GetShape();
+    if ( !shapeFun.IsNull() )
+    {
+      TDF_Label shapeLabel = shapeFun->GetOwnerEntry();
+      shapeObject = GEOM_Object::GetObject( shapeLabel );
+    }
+  }
+
+  return shapeObject;
+}
+
+//=======================================================================
+//function : GetNbSubShapes
+//purpose  : Returns number of sub-shapes.
+//           Size of data arrays == GetNbSubShapes() * GetComponents()->Extent()
+//=======================================================================
+
+int GEOM_Field::GetNbSubShapes()
+{
+  if ( nbSubShapes < 0 )
+    nbSubShapes = GetNbSubShapes( GetShape(), GetDimension() );
+
+  return nbSubShapes;
+}
+
+//=======================================================================
+//function : GetNbSubShapes
+//purpose  : Returns number of sub-shapes of given dimension
+//=======================================================================
+
+int GEOM_Field::GetNbSubShapes(const Handle(GEOM_Object)& shObj,
+                               const int                  dim)
+{
+  int nbSubShapes = 0;
+  if ( shObj.IsNull() ) return nbSubShapes;
+
+  TopoDS_Shape shape = shObj->GetValue();
+  if (shape.IsNull() ) return nbSubShapes;
+
+  if ( dim == -1 )
+  {
+    nbSubShapes = 1;
+  }
+  else
+  {
+    TopAbs_ShapeEnum type;
+    switch( dim ) {
+    case 0: type = TopAbs_VERTEX; break;
+    case 1: type = TopAbs_EDGE; break;
+    case 2: type = TopAbs_FACE; break;
+    case 3: type = TopAbs_SOLID; break;
+    default: return nbSubShapes;
+    }
+    TopTools_IndexedMapOfShape map;
+    TopExp::MapShapes( shape, type, map );
+    nbSubShapes = map.Extent();
+  }
+  return nbSubShapes;
+}
+
+//=======================================================================
+//function : GetNbComponents
+//purpose  : Returns number of components
+//=======================================================================
+
+int GEOM_Field::GetNbComponents()
+{
+  Handle(TColStd_HArray1OfExtendedString) comps = GetComponents();
+  return comps.IsNull() ? 0 : comps->Length();
+}
+
+//=======================================================================
+//function : GetArrayLength
+//purpose  : Returns size of data array == GetNbSubShapes() * GetComponents()->Extent()
+//=======================================================================
+
+int GEOM_Field::GetArrayLength()
+{
+  return GetNbComponents() * GetNbSubShapes();
+}
+
+//=======================================================================
+//function : GetDataType
+//purpose  : Returns a data type of this GEOM_Field
+//=======================================================================
+
+int GEOM_Field::GetDataType()
+{
+  Handle(GEOM_Function) fun = GetFunction(1);
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetDataType();
+  return -1;
+}
+
+//=======================================================================
+//function : GetDataTypeString
+//purpose  : Returns one of "Bool","Int","Double","String"
+//=======================================================================
+
+TCollection_AsciiString GEOM_Field::GetDataTypeString(int type)
+{
+  const char* typeNames[] = { "Bool","Int","Double","String" };
+  if ( type < 0 || type > 3 )
+    return type;
+  return typeNames[ type ];
+}
+
+//=======================================================================
+//function : GetDimension
+//purpose  : Returns dimension of the shape the field lies on:
+//           0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+//=======================================================================
+
+int GEOM_Field::GetDimension()
+{
+  Handle(GEOM_Function) fun = GetFunction(1);
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetDimension();
+  return -1;
+}
+
+//=======================================================================
+//function : SetComponents
+//purpose  : Sets names of components
+//=======================================================================
+
+void GEOM_Field::SetComponents( const Handle(TColStd_HArray1OfExtendedString)& compNames )
+{
+  // By spec. modification of components is not required, but just in case...
+  Handle(GEOM_Function) fun = GetLastFunction();
+  if ( fun->GetType() != FUN_ADD_FIELD )
+  {
+    fun = AddFunction( GetFieldID(), FUN_CHANGE_COMP_NAMES );
+    //TPythonDump( fun ) << this << ".setComponents( "
+  }
+  GEOM_IField data( fun );
+  data.SetComponents( compNames );
+}
+
+//=======================================================================
+//function : GetComponents
+//purpose  : Returns names of components
+//=======================================================================
+
+Handle(TColStd_HArray1OfExtendedString) GEOM_Field::GetComponents()
+{
+  Handle(GEOM_Function) fun = getFunction( FUN_CHANGE_COMP_NAMES, this );
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetComponents();
+  return NULL;
+}
+
+//=======================================================================
+//function : getFunctionToSetValues
+//purpose  : dump any HArray into a string
+//=======================================================================
+template< class Handle_HARRAY1 >
+TCollection_AsciiString arrayToSting( const Handle_HARRAY1& ar,
+                                      const char*            quote="")
+{
+  TCollection_AsciiString s;
+  char prefix[] = "[ ";
+  if ( !ar.IsNull() )
+    for ( int i = ar->Lower(), nb = ar->Upper(); i <= nb; ++i )
+    {
+      s += prefix;
+      s += quote;
+      s += TCollection_AsciiString( ar->Value( i ));
+      s += quote;
+      prefix[0] = ',';
+    }
+  if ( !s.IsEmpty() )
+    s += " ]";
+
+  return s;
+}
+
+//=======================================================================
+//function : GetComponentsForPython
+//purpose  : Returns names of components in a python syntax
+//=======================================================================
+
+TCollection_AsciiString GEOM_Field::GetComponentsForPython()
+{
+  return arrayToSting( GetComponents(), "'" );
+}
+
+//=======================================================================
+//function : AddStep
+//purpose  : Adds a step
+//=======================================================================
+
+Handle(GEOM_FieldStep) GEOM_Field::AddStep(const int stepID, const int stamp)
+{
+  Handle(GEOM_FieldStep) step = GetStep( stepID );
+  if ( !step.IsNull() )
+    return NULL;
+
+  GEOM_Engine* anEngine = GEOM_Engine::GetEngine();
+  if(anEngine == NULL) return NULL;
+
+  step = Handle(GEOM_FieldStep)::DownCast
+    ( anEngine->AddBaseObject( GetDocID(),GEOM_FIELD_STEP_OBJTYPE ));
+  if ( step.IsNull())
+    return step;
+
+  // set all step data
+  Handle(GEOM_Field) field = GEOM_Field::GetField( GetEntry() );
+  step->Init( field, stepID, stamp );
+
+  Handle(TDataStd_TreeNode) aRoot, aNode;
+  aRoot = TDataStd_TreeNode::Set( GetEntry(),       GetFieldID() );
+  aNode = TDataStd_TreeNode::Set( step->GetEntry(), GetFieldID() );
+  aRoot->Append(aNode);
+
+  // Dump just in case if step.SetValues() would fail which normally
+  // replaces this dump.
+  // field.addStep(step, stamp, values)
+  TCollection_AsciiString defaultVal( GetDataType() == 3 ? "''" : "0" );
+  TPythonDump( step->GetFunction(1) )
+    << step << " = "
+    << this << ".addStep( "
+    << stepID << ", "
+    << stamp << ", "
+    << "[" << defaultVal << "]*" << GetArrayLength() << " )";
+
+  return step;
+}
+
+//=======================================================================
+//function : RemoveStep
+//purpose  : Removes a step
+//=======================================================================
+
+void GEOM_Field::RemoveStep(const int stepID)
+{
+  Handle(GEOM_FieldStep) step = GetStep( stepID );
+  if ( step.IsNull() )
+    return;
+
+  Handle(TDataStd_TreeNode) aNode =
+    TDataStd_TreeNode::Set( step->GetEntry(), GetFieldID() );
+  aNode->Remove(); // Removes this tree node attribute from its father
+
+  // Dump of removed objects is not produced anayway
+  //Handle(GEOM_Function) fun = AddFunction( GetFieldID(), FUN_REMOVE_STEP );
+  //TPythonDump( fun ) << this << ".removeStep( " << stepID << " )";
+
+  GEOM_Engine* anEngine = GEOM_Engine::GetEngine();
+  if ( anEngine )
+    anEngine->RemoveObject( step );
+}
+
+//=======================================================================
+//function : GetStep
+//purpose  : Returns a step
+//=======================================================================
+
+Handle(GEOM_FieldStep) GEOM_Field::GetStep(const int stepID)
+{
+  Handle(GEOM_FieldStep) step;
+
+  Handle(TDataStd_TreeNode) aRoot, aNode;
+  if ( !GetEntry().FindAttribute( GetFieldID(), aRoot ))
+    return step;
+
+  TDataStd_ChildNodeIterator anIter (aRoot);
+  for (; anIter.More(); anIter.Next())
+  {
+    aNode = anIter.Value();
+    step = GEOM_FieldStep::GetFieldStep( aNode->Label() );
+    if ( !step.IsNull() && step->GetID() == stepID )
+      return step;
+  }
+  return NULL;
+}
+
+//=======================================================================
+//function : GetSteps
+//purpose  : Returns all steps
+//=======================================================================
+
+std::list< Handle(GEOM_FieldStep)> GEOM_Field::GetSteps()
+{
+  std::list< Handle(GEOM_FieldStep) > stepList;
+
+  Handle(TDataStd_TreeNode) aRoot, aNode;
+  if ( !GetEntry().FindAttribute( GetFieldID(), aRoot ))
+    return stepList;
+
+  Handle(GEOM_FieldStep) step;
+  TDataStd_ChildNodeIterator anIter (aRoot);
+  for (; anIter.More(); anIter.Next())
+  {
+    aNode = anIter.Value();
+    step = GEOM_FieldStep::GetFieldStep( aNode->Label() );
+    if ( !step.IsNull() )
+      stepList.push_back( step );
+  }
+  return stepList;
+}
+
+//=============================================================================
+/*!
+ *  Constructor: private
+ */
+//=============================================================================
+
+GEOM_FieldStep::GEOM_FieldStep(const TDF_Label& theEntry)
+  : GEOM_BaseObject(theEntry)
+{
+}
+
+//=============================================================================
+/*!
+ *  Constructor: public
+ */
+//=============================================================================
+
+GEOM_FieldStep::GEOM_FieldStep(const TDF_Label& theLabel, int /*type*/ )
+  : GEOM_BaseObject( theLabel, GEOM_FIELD_STEP_OBJTYPE )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Sets the basic data
+ */
+//================================================================================
+
+void GEOM_FieldStep::Init(const Handle(GEOM_Field)& theField,
+                          const int                 theID,
+                          const int                 theStamp)
+{
+  Handle(GEOM_Function) fun = GetFunction(1);
+  if ( !fun.IsNull() )
+    Standard_MultiplyDefined::Raise( "Reinitialization of GEOM_FieldStep is forbiden" );
+  fun = AddFunction( GEOM_Field::GetFieldID(), GEOM_Field::FUN_ADD_STEP );
+
+  GEOM_IField data( fun );
+  data.SetField    ( theField->GetFunction(1) );
+  data.SetStepID   ( theID );
+  data.SetStepStamp( theStamp );
+  // PythonDump to be done by the operation creating this field step
+}
+
+//=============================================================================
+/*!
+ *  GetField
+ */
+//=============================================================================
+
+Handle(GEOM_FieldStep) GEOM_FieldStep::GetFieldStep(const TDF_Label& theLabel)
+{
+  Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel);
+  return Handle(GEOM_FieldStep)::DownCast( base );
+}
+
+//=============================================================================
+/*!
+ *  Destructor
+ */
+//=============================================================================
+
+GEOM_FieldStep::~GEOM_FieldStep()
+{
+}
+
+//=======================================================================
+//function : GetField
+//purpose  : Returns the Field this GEOM_FieldStep belongs to
+//=======================================================================
+
+Handle(GEOM_Field) GEOM_FieldStep::GetField()
+{
+  Handle(GEOM_Field) field;
+
+  Handle(GEOM_Function) fun= GetFunction(1);
+  if ( !fun.IsNull() )
+  {
+    GEOM_IField data( fun );
+    Handle(GEOM_Function) fldFun = data.GetField();
+    if ( !fldFun.IsNull() )
+      field = GEOM_Field::GetField( fldFun->GetOwnerEntry() );
+  }
+  return field;
+}
+
+//=======================================================================
+//function : GetID
+//purpose  : Returns the stamp step id
+//=======================================================================
+
+int GEOM_FieldStep::GetID()
+{
+  Handle(GEOM_Function) fun= GetFunction(1);
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetStepID();
+  return std::numeric_limits<int>::max();
+}
+
+//=======================================================================
+//function : SetStamp
+//purpose  : Sets the stamp of the step
+//=======================================================================
+
+void GEOM_FieldStep::SetStamp(const int stamp)
+{
+  Handle(GEOM_Function) fun = GetLastFunction();
+  if ( fun.IsNull() ) return;
+  if ( fun->GetType() == GEOM_Field::FUN_ADD_STEP )
+  {
+    // it's creation of the step, dump is performed outside
+    GEOM_IField data( fun );
+    data.SetStepStamp( stamp );
+  }
+  else
+  {
+    // it's stamp modification: field.setStamp(step, stamp)
+    fun = AddFunction( GEOM_Field::GetFieldID(), GEOM_Field::FUN_CHANGE_STEP_STAMP );
+
+    GEOM_IField data( fun );
+    data.SetStepStamp( stamp );
+
+    TPythonDump( fun ) <<
+      GetField() << ".setStamp( " << data.GetStepID() << ", " << stamp << " )";
+  }
+}
+
+//=======================================================================
+//function : GetStamp
+//purpose  : Returns the stamp of the step
+//=======================================================================
+
+int GEOM_FieldStep::GetStamp()
+{
+  // find the last function changing the stamp
+  Handle(GEOM_Function) fun = getFunction( GEOM_Field::FUN_CHANGE_STEP_STAMP, this );
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetStepStamp();
+  return std::numeric_limits<int>::max(); // very strange
+}
+
+//=======================================================================
+//function : getFunctionToSetValues
+//purpose  : Finds a function to store new values and dumps to Python
+//=======================================================================
+
+Handle(GEOM_Function)
+GEOM_FieldStep::getFunctionToSetValuesAndDump( const TCollection_AsciiString& valueStr )
+{
+  Handle(GEOM_Function) fun = GetLastFunction();
+  if ( fun->GetType() == GEOM_Field::FUN_ADD_STEP &&
+       !fun->HasData( GEOM_IField::STEP_VALUES, GetDataID() ))
+  {
+    // it's creation of the step: field.addStep(step, stamp, values)
+    GEOM_IField data( fun );
+    TPythonDump( fun ) << this << " = " << GetField() << ".addStep( " <<
+      data.GetStepID() << ", " << data.GetStepStamp() << ", " << valueStr << " )";
+  }
+  else
+  {
+    // it's value modification: field.setValues(step, values)
+    fun = AddFunction( GEOM_Field::GetFieldID(), GEOM_Field::FUN_CHANGE_VALUE );
+    GEOM_IField data( GetFunction(1) );
+    TPythonDump( fun ) << GetField() << ".setValues( " <<
+      data.GetStepID() << ", " << valueStr << " )";
+  }
+  return fun;
+}
+
+//=======================================================================
+//function : SetValues
+//purpose  : Sets int or bool values
+//=======================================================================
+
+bool GEOM_FieldStep::SetValues( const Handle(TColStd_HArray1OfInteger)& values )
+{
+  Handle(GEOM_Field) field = GetField();
+  if ( field.IsNull() ||
+       values.IsNull() ||
+       field->GetArrayLength() != values->Length() )
+    return false;
+
+  // fix bool values to be 0 or 1 only
+  if ( field->GetDataType() == 0 )
+    for ( int i = values->Lower(), nb = values->Upper(); i <= nb; ++i )
+      values->SetValue( i , bool( values->Value( i )));
+
+  Handle(GEOM_Function) fun =
+    getFunctionToSetValuesAndDump( arrayToSting( values ));
+
+  GEOM_IField data( fun );
+  data.SetValues( values );
+  return true;
+}
+
+//=======================================================================
+//function : SetValues
+//purpose  : Sets double values
+//=======================================================================
+
+bool GEOM_FieldStep::SetValues( const Handle(TColStd_HArray1OfReal)& values )
+{
+  Handle(GEOM_Field) field = GetField();
+  if ( field.IsNull() ||
+       values.IsNull() ||
+       field->GetArrayLength() != values->Length() )
+    return false;
+
+  Handle(GEOM_Function) fun =
+    getFunctionToSetValuesAndDump( arrayToSting( values ));
+
+  GEOM_IField data( fun );
+  data.SetValues( values );
+  return true;
+}
+
+//=======================================================================
+//function : SetValues
+//purpose  : Sets string values
+//=======================================================================
+
+bool GEOM_FieldStep::SetValues( const Handle(TColStd_HArray1OfExtendedString)& values )
+{
+  Handle(GEOM_Field) field = GetField();
+  if ( field.IsNull() ||
+       values.IsNull() ||
+       field->GetArrayLength() != values->Length() )
+    return false;
+
+  Handle(GEOM_Function) fun =
+    getFunctionToSetValuesAndDump( arrayToSting( values, "'" ));
+
+  GEOM_IField data( fun );
+  data.SetValues( values );
+  return true;
+}
+
+//=======================================================================
+//function : GetIntValues
+//purpose  : Returns int or bool values
+//=======================================================================
+
+Handle(TColStd_HArray1OfInteger) GEOM_FieldStep::GetIntValues()
+{
+  Handle(GEOM_Function) fun = getFunction( GEOM_Field::FUN_CHANGE_VALUE, this );
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetIntValues();
+  return NULL;
+}
+
+//=======================================================================
+//function : GetDoubleValues
+//purpose  : Returns double values
+//=======================================================================
+
+Handle(TColStd_HArray1OfReal) GEOM_FieldStep::GetDoubleValues()
+{
+  Handle(GEOM_Function) fun = getFunction( GEOM_Field::FUN_CHANGE_VALUE, this );
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetDoubleValues();
+  return NULL;
+}
+
+//=======================================================================
+//function : GetStringValues
+//purpose  : Returns string values
+//=======================================================================
+
+Handle(TColStd_HArray1OfExtendedString) GEOM_FieldStep::GetStringValues()
+{
+  Handle(GEOM_Function) fun = getFunction( GEOM_Field::FUN_CHANGE_VALUE, this );
+  if ( !fun.IsNull() )
+    return GEOM_IField( fun ).GetStringValues();
+  return NULL;
+}
+
+//=======================================================================
+//function : GetDataID
+//purpose  : Returns GUID of CAF data array
+//=======================================================================
+
+const Standard_GUID& GEOM_FieldStep::GetDataID()
+{
+  int dataType = 2;
+  Handle(GEOM_Field) f = GetField();
+  if ( !f.IsNull() )
+    dataType = f->GetDataType();
+
+  switch ( dataType ) {
+  case 0: // bool
+  case 1: // int
+    return TDataStd_IntegerArray::GetID();
+  case 2: // double
+    return TDataStd_RealArray::GetID();
+  default:; // string
+  }
+  return TDataStd_ExtStringArray::GetID();
+}
+
+IMPLEMENT_STANDARD_HANDLE (GEOM_Field, GEOM_BaseObject );
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_Field, GEOM_BaseObject );
+IMPLEMENT_STANDARD_HANDLE (GEOM_FieldStep, GEOM_BaseObject );
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_FieldStep, GEOM_BaseObject );
diff --git a/src/GEOM/GEOM_Field.hxx b/src/GEOM/GEOM_Field.hxx
new file mode 100644 (file)
index 0000000..3380d2f
--- /dev/null
@@ -0,0 +1,201 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOM_Field_HeaderFile
+#define _GEOM_Field_HeaderFile
+
+#include "GEOM_Object.hxx"
+
+#include <list>
+
+
+const int GEOM_FIELD_OBJTYPE      = 52; // same value #defined in GEOMImpl_Types.hxx
+const int GEOM_FIELD_STEP_OBJTYPE = 53;
+
+class GEOM_Field;
+class GEOM_FieldStep;
+DEFINE_STANDARD_HANDLE( GEOM_Field, GEOM_BaseObject );
+DEFINE_STANDARD_HANDLE( GEOM_FieldStep, GEOM_BaseObject );
+
+
+
+class GEOM_Field : public GEOM_BaseObject
+{
+  GEOM_Field(const TDF_Label& theLabel);
+  friend class GEOM_Engine;
+
+ public:
+
+  // Function types
+  enum { FUN_ADD_FIELD = 1,
+         FUN_ADD_STEP,
+         FUN_CHANGE_COMP_NAMES,
+         //FUN_REMOVE_STEP,
+         FUN_CHANGE_STEP_STAMP,
+         FUN_CHANGE_VALUE
+  };
+
+  // Creates a GEOM_Field on an empty Label
+  Standard_EXPORT GEOM_Field(const TDF_Label& theLabel, int );
+  Standard_EXPORT ~GEOM_Field();
+
+  // Finds a GEOM_Field on theLabel
+  Standard_EXPORT static Handle(GEOM_Field) GetField(const TDF_Label& theLabel);
+
+  // Returns a GUID associated with a field object (GEOM_Field or GEOM_FieldStep)
+  // This GUID corresponds to GEOMImpl_FieldDriver::GetID() and
+  // it also marks TDataStd_TreeNode on a label of GEOM_FieldStep
+  Standard_EXPORT static const Standard_GUID& GetFieldID();
+
+  // Sets the basic data that do not change (except compNames?)
+  Standard_EXPORT void Init(const Handle(GEOM_Object)&                     theShape,
+                            const char*                                    theName,
+                            const int                                      theDataType,
+                            const int                                      theDimension,
+                            const Handle(TColStd_HArray1OfExtendedString)& theCompNames);
+
+  // Returns a shape this GEOM_Field lies on
+  Standard_EXPORT Handle(GEOM_Object) GetShape();
+
+  // Returns a data type of this GEOM_Field
+  // 0 - bool, 1 - int, 2 - double, 3 - string
+  Standard_EXPORT int GetDataType();
+
+  // Returns one of "Bool","Int","Double","String"
+  Standard_EXPORT static TCollection_AsciiString GetDataTypeString(int type);
+
+  // Returns dimension of the shape the field lies on:
+  // 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+  Standard_EXPORT int GetDimension();
+
+  // Sets names of components
+  Standard_EXPORT void SetComponents( const Handle(TColStd_HArray1OfExtendedString)& compNames );
+
+  // Returns names of components
+  Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetComponents();
+
+  // Returns names of components in a python syntax
+  Standard_EXPORT TCollection_AsciiString GetComponentsForPython();
+
+  // Returns number of components
+  Standard_EXPORT int GetNbComponents();
+
+  // Returns number of sub-shapes.
+  // Size of data arrays == GetNbSubShapes() * GetComponents()->Extent()
+  Standard_EXPORT int GetNbSubShapes();
+
+  // Returns number of sub-shapes of given dimension
+  Standard_EXPORT static int GetNbSubShapes(const Handle(GEOM_Object)& shape,
+                                            const int                  dim);
+
+  // Returns size of data array == GetNbSubShapes() * GetComponents()->Extent()
+  Standard_EXPORT int GetArrayLength();
+
+  // Removes a component. Number counts from one.
+  //Standard_EXPORT void RemoveComponent(const int number);
+
+  // Adds a step
+  Standard_EXPORT Handle(GEOM_FieldStep) AddStep(const int stepID, const int stamp);
+
+  // Removes a step
+  Standard_EXPORT void RemoveStep(const int stepID);
+
+  // Returns a step
+  Standard_EXPORT Handle(GEOM_FieldStep) GetStep(const int stepID);
+  // Returns all steps
+  Standard_EXPORT std::list< Handle(GEOM_FieldStep)> GetSteps();
+
+  DEFINE_STANDARD_RTTI( GEOM_Field );
+
+private:
+
+  int nbSubShapes; // not to explode the shape each time nbSubShapes is needed
+};
+
+
+class GEOM_FieldStep : public GEOM_BaseObject
+{
+  GEOM_FieldStep(const TDF_Label& theLabel);
+  friend class GEOM_Engine;
+
+public:
+  // Creates a GEOM_FieldStep on an empty Label
+  Standard_EXPORT GEOM_FieldStep(const TDF_Label& theLabel, int );
+  Standard_EXPORT ~GEOM_FieldStep();
+
+  // Sets the basic data
+  Standard_EXPORT void Init(const Handle(GEOM_Field)& theField,
+                            const int                 theID,
+                            const int                 theStamp);
+
+  // Finds a GEOM_FieldStep on the label theLabel
+  Standard_EXPORT static Handle(GEOM_FieldStep) GetFieldStep(const TDF_Label& theLabel);
+
+  // Returns the Field this GEOM_FieldStep belongs to
+  Standard_EXPORT Handle(GEOM_Field) GetField();
+
+  // Returns the stamp step id
+  Standard_EXPORT int GetID();
+
+  // Removes a component. Number counts from one.
+  //Standard_EXPORT void RemoveComponent(const int number);
+
+  // Sets the stamp of the step
+  Standard_EXPORT void SetStamp(const int stamp);
+
+  // Returns the stamp of the step
+  Standard_EXPORT int GetStamp();
+
+  // Sets int or bool values. Returns false if number of values is wrong
+  Standard_EXPORT bool SetValues( const Handle(TColStd_HArray1OfInteger)& values );
+
+  // Sets double values. Returns false if number of values is wrong
+  Standard_EXPORT bool SetValues( const Handle(TColStd_HArray1OfReal)& values );
+
+  // Sets string values. Returns false if number of values is wrong
+  Standard_EXPORT bool SetValues( const Handle(TColStd_HArray1OfExtendedString)& values );
+
+  // Returns int or bool values
+  Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntValues();
+
+  // Returns double values
+  Standard_EXPORT Handle(TColStd_HArray1OfReal) GetDoubleValues();
+
+  // Returns string values
+  Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringValues();
+
+  // Returns GUID of CAF data array
+  const Standard_GUID& GetDataID();
+
+
+
+  DEFINE_STANDARD_RTTI( GEOM_FieldStep );
+
+private:
+
+  Handle(GEOM_Function) getFunctionToSetValuesAndDump(const TCollection_AsciiString& valueStr);
+
+};
+
+
+#endif
index 0c6ac9cc6a365c08d538e9eaf6bd6ade6b16c96d..af73ba3f63fe2fe91b92ada1b14d3f040284d76c 100644 (file)
@@ -580,6 +580,18 @@ Handle(TColStd_HArray1OfExtendedString) GEOM_Function::GetStringArray(int thePos
   return anArray->Array();
 }
 
+//=======================================================================
+//function : HasData
+//purpose  : Returns true if data of given type already exists
+//=======================================================================
+
+bool GEOM_Function::HasData(int thePosition, const Standard_GUID& dataID)
+{
+  if(thePosition <= 0) return false;
+  TDF_Label anArgLabel = ARGUMENT(thePosition);
+  return anArgLabel.IsAttribute( dataID );
+}
+
 //=======================================================================
 //function : GetReferencesTreeID
 //purpose  :
@@ -848,42 +860,5 @@ TDF_Label GEOM_Function::GetNamingEntry (const Standard_Boolean create)
   return _label.FindChild(NAMING_LABEL, create);
 }
 
-//=======================================================================
-//function :  GEOM_Function_Type_
-//purpose  :
-//=======================================================================
-Standard_EXPORT Handle_Standard_Type& GEOM_Function_Type_()
-{
-
-  static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared);
-  if (aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared);
-  static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient);
-  if (aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient);
-
-  static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL};
-  static Handle_Standard_Type _aType = new Standard_Type("GEOM_Function",
-                                                         sizeof(GEOM_Function),
-                                                         1,
-                                                         (Standard_Address)_Ancestors,
-                                                         (Standard_Address)NULL);
-
-  return _aType;
-}
-
-//=======================================================================
-//function : DownCast
-//purpose  :
-//=======================================================================
-
-const Handle(GEOM_Function) Handle(GEOM_Function)::DownCast(const Handle(Standard_Transient)& AnObject)
-{
-  Handle(GEOM_Function) _anOtherObject;
-
-  if (!AnObject.IsNull()) {
-     if (AnObject->IsKind(STANDARD_TYPE(GEOM_Function))) {
-       _anOtherObject = Handle(GEOM_Function)((Handle(GEOM_Function)&)AnObject);
-     }
-  }
-
-  return _anOtherObject;
-}
+IMPLEMENT_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_Function, Standard_Transient );
index cc83441ae5402df3fb1ea1cdb813d99c36b49d31..c6d273bfc88277c94074fa57cbdac92f9dcf4d82 100644 (file)
 #ifndef _GEOM_Function_HeaderFile
 #define _GEOM_Function_HeaderFile
 
-#ifndef _Standard_TypeMismatch_HeaderFile
-#include <Standard_TypeMismatch.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-#ifndef _Handle_MMgt_TShared_HeaderFile
-#include <Handle_MMgt_TShared.hxx>
-#endif
-#ifndef _MMgt_TShared_HeaderFile
-#include <MMgt_TShared.hxx>
-#endif
-#ifndef _Standard_GUID_HeaderFile
+#include <Standard_Transient.hxx>
 #include <Standard_GUID.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _TDF_Label_HeaderFile
+#include <TColStd_HArray1OfExtendedString.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <TDF_Label.hxx>
-#endif
-#ifndef _TDF_LabelSequence_HeaderFile
 #include <TDF_LabelSequence.hxx>
-#endif
-#ifndef _TColStd_HArray1OfExtendedString_HeaderFile
-#include <TColStd_HArray1OfExtendedString.hxx>
-#endif
+#include <TDataStd_ListOfExtendedString.hxx>
+#include <TopoDS_Shape.hxx>
 
 class Handle_TColStd_HArray1OfReal;
 class Handle_TColStd_HArray1OfInteger;
 class Handle_TColStd_HSequenceOfTransient;
-class Handle_TColStd_HArray1OfExtendedString;
-
-class Standard_Transient;
-class Handle_Standard_Type;
-class Handle(MMgt_TShared);
 class GEOM_Function;
+DEFINE_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
 
-#include <TCollection_AsciiString.hxx>
-#include <TDataStd_ListOfExtendedString.hxx>
-
-Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Function);
-
-class Handle(GEOM_Function) : public Handle(MMgt_TShared) {
-  public:
-    inline void* operator new(size_t,void* anAddress)
-      {
-        return anAddress;
-      }
-    inline void* operator new(size_t size)
-      {
-        return Standard::Allocate(size);
-      }
-    inline void  operator delete(void *anAddress)
-      {
-        if (anAddress) Standard::Free((Standard_Address&)anAddress);
-      }
-
-    Handle(GEOM_Function)():Handle(MMgt_TShared)() {}
-    Handle(GEOM_Function)(const Handle(GEOM_Function)& aHandle) : Handle(MMgt_TShared)(aHandle)
-     {
-     }
-
-    Handle(GEOM_Function)(const GEOM_Function* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
-     {
-     }
-
-    Handle(GEOM_Function)& operator=(const Handle(GEOM_Function)& aHandle)
-     {
-      Assign(aHandle.Access());
-      return *this;
-     }
-
-    Handle(GEOM_Function)& operator=(const GEOM_Function* anItem)
-     {
-      Assign((Standard_Transient *)anItem);
-      return *this;
-     }
-
-    GEOM_Function* operator->()
-     {
-      return (GEOM_Function *)ControlAccess();
-     }
-
-    GEOM_Function* operator->() const
-     {
-      return (GEOM_Function *)ControlAccess();
-     }
-
-   Standard_EXPORT ~Handle(GEOM_Function)() {};
-
-   Standard_EXPORT static const Handle(GEOM_Function) DownCast(const Handle(Standard_Transient)& AnObject);
-};
-
-class GEOM_Function : public MMgt_TShared
+class GEOM_Function : public Standard_Transient
 {
-
-public:
-
-    inline void* operator new(size_t,void* anAddress)
-      {
-        return anAddress;
-      }
-    inline void* operator new(size_t size)
-      {
-        return Standard::Allocate(size);
-      }
-    inline void  operator delete(void *anAddress)
-      {
-        if (anAddress) Standard::Free((Standard_Address&)anAddress);
-      }
-
-    // Type management
-    //
-    Standard_EXPORT friend Handle_Standard_Type& GEOM_Function_Type_();
-    Standard_EXPORT const Handle(Standard_Type)& DynamicType() const
-      { return STANDARD_TYPE(GEOM_Function) ; }
-    Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
-      { return (STANDARD_TYPE(GEOM_Function) == AType || MMgt_TShared::IsKind(AType)); }
-
-
-private:
   GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
 
 public:
@@ -163,7 +55,7 @@ public:
 
 
   Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
-  Standard_EXPORT ~GEOM_Function() {;}
+  Standard_EXPORT ~GEOM_Function() {}
 
   Standard_EXPORT TDF_Label GetOwnerEntry();
 
@@ -234,6 +126,9 @@ public:
   //Returns the array of ExtendedString
   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
 
+  //Returns true if data of given type already exists
+  Standard_EXPORT bool HasData(int thePosition, const Standard_GUID& dataID);
+
   //Returns a GUID for a references tree
   Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
 
@@ -276,7 +171,9 @@ public:
   //Returns top label of this function's naming tree
   Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
 
-private:
+  DEFINE_STANDARD_RTTI (GEOM_Function);
+
+  private:
 
   TDF_Label _label;
   bool      _isDone;
diff --git a/src/GEOM/GEOM_IField.hxx b/src/GEOM/GEOM_IField.hxx
new file mode 100644 (file)
index 0000000..fef92b3
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//NOTE: This is an intreface to a function for the Field creation.
+//
+#include "GEOM_Function.hxx"
+
+#include <TColStd_HArray1OfExtendedString.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+class GEOM_Field;
+
+class GEOM_IField
+{
+  enum {
+    // field
+    FIELD_SHAPE      = 1, // ref
+    FIELD_DATATYPE   = 1, // int
+    FIELD_DIMENSION  = 2, // int
+    FIELD_COMPONENTS = 1, // string array
+    // field step
+    STEP_FIELD       = 1, // ref
+    STEP_ID          = 1, // int
+    STEP_STAMP       = 2, // int
+    STEP_VALUES      = 2  // an array of any type
+  };
+
+public:
+
+  GEOM_IField(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+
+  Standard_EXPORT Handle(GEOM_Function) GetShape()
+  { return _func->GetReference( FIELD_SHAPE ); }
+  Standard_EXPORT int GetDataType()  { return _func->GetInteger( FIELD_DATATYPE ); }
+  Standard_EXPORT int GetDimension() { return _func->GetInteger( FIELD_DIMENSION ); }
+  Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetComponents()
+  { return _func->GetStringArray( FIELD_COMPONENTS ); }
+
+  Standard_EXPORT Handle(GEOM_Function) GetField()
+  { return _func->GetReference( STEP_FIELD ); }
+  Standard_EXPORT int GetStepID() { return _func->GetInteger( STEP_ID ); }
+  Standard_EXPORT int GetStepStamp() { return _func->GetInteger( STEP_STAMP ); }
+  Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntValues()
+  { return _func->GetIntegerArray( STEP_VALUES ); }
+  Standard_EXPORT Handle(TColStd_HArray1OfReal) GetDoubleValues()
+  { return _func->GetRealArray( STEP_VALUES ); }
+  Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringValues()
+  { return _func->GetStringArray( STEP_VALUES ); }
+
+ private:
+
+  void SetShape(Handle(GEOM_Function) theS) { _func->SetReference( FIELD_SHAPE, theS ); }
+  void SetDataType( int type ) { _func->SetInteger( FIELD_DATATYPE, type ); }
+  void SetDimension( int dim ) { _func->SetInteger( FIELD_DIMENSION, dim ); }
+  void SetComponents( const Handle(TColStd_HArray1OfExtendedString)& compNames )
+  { _func->SetStringArray( FIELD_COMPONENTS, compNames ); }
+
+  friend class GEOM_Field;
+
+  void SetField(Handle(GEOM_Function) theF) { _func->SetReference( STEP_FIELD, theF ); }
+  void SetStepStamp( int stamp ) { _func->SetInteger( STEP_STAMP, stamp ); }
+  void SetStepID( int step ) { _func->SetInteger( STEP_ID, step ); }
+  // void SetStepIDs( Handle(TColStd_HArray1OfInteger) steps )
+  // { _func->SetRealArray( FIELD_STEP_IDS, steps ); }
+  void SetValues( const Handle(TColStd_HArray1OfInteger)& values )
+  { _func->SetIntegerArray( STEP_VALUES, values ); }
+  void SetValues( const Handle(TColStd_HArray1OfReal)& values )
+  { _func->SetRealArray( STEP_VALUES, values ); }
+  void SetValues( const Handle(TColStd_HArray1OfExtendedString)& values )
+  { _func->SetStringArray( STEP_VALUES, values ); }
+
+  friend class GEOM_FieldStep;
+
+  Handle(GEOM_Function) _func;
+};
index 0c488e56b713123fc6bc567988d0935f8609c30b..2aac31bf5754fc0a847784939cd3e665cb69768f 100644 (file)
 //
 
 #include "GEOM_Object.hxx"
-#include "GEOM_Engine.hxx"
-#include "GEOM_Solver.hxx"
-
-#include <Standard_Stream.hxx>
-#include <TColStd_HArray1OfReal.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TDF_Data.hxx>
-#include <TDF_LabelSequence.hxx>
-#include <TDF_Reference.hxx>
-#include <TDF_Tool.hxx>
-#include <TDataStd_ByteArray.hxx>
-#include <TDataStd_ChildNodeIterator.hxx>
-#include <TDataStd_Comment.hxx>
+
 #include <TDataStd_Integer.hxx>
-#include <TDataStd_Name.hxx>
 #include <TDataStd_Real.hxx>
 #include <TDataStd_RealArray.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDocStd_Document.hxx>
-#include <TDocStd_Owner.hxx>
-#include <TFunction_Driver.hxx>
-#include <TFunction_DriverTable.hxx>
-#include <TopExp.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
 
 #include "utilities.h"
 
-
-#define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
-#define TYPE_LABEL       2
-#define FREE_LABEL       3
-#define TIC_LABEL        4
+// #define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
+// #define TYPE_LABEL       2 -- Labels used by GEOM_BaseObject
+// #define FREE_LABEL       3
+// #define TIC_LABEL        4
 #define COLOR_LABEL      5
 #define AUTO_COLOR_LABEL 6
 #define MARKER_LABEL     7
 #define MARKER_LABEL_SIZE 2
 #define MARKER_LABEL_ID   3
 
-//=======================================================================
-//function : GetObjectID
-//purpose  :
-//=======================================================================
-const Standard_GUID& GEOM_Object::GetObjectID()
-{
-  static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16");
-  return anObjectID;
-}
-
-//=======================================================================
-//function : GetSubShapeID
-//purpose  :
-//=======================================================================
-const Standard_GUID& GEOM_Object::GetSubShapeID()
-{
-  static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16");
-  return anObjectID;
-}
-
 //=============================================================================
 /*!
  *  GetObject
  */
 //=============================================================================
+
 Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
 {
-  if (!theLabel.IsAttribute(GetObjectID())) return NULL;
-
-  TCollection_AsciiString anEntry;
-  TDF_Tool::Entry(theLabel, anEntry);
-
-  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theLabel.Data());
-  if(aDoc.IsNull()) return NULL;
-
-  Handle(TDataStd_Integer) anID;
-  if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL;
-
-
-  GEOM_Engine* anEngine=  GEOM_Engine::GetEngine();
-  if(anEngine == NULL) return NULL;
-  return anEngine->GetObject(anID->Get(), (char*) anEntry.ToCString());
-
-
+  Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel);
+  return Handle(GEOM_Object)::DownCast( base );
 }
 
 //=============================================================================
@@ -113,36 +57,11 @@ Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
  *  GetReferencedObject
  */
 //=============================================================================
+
 Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
 {
-  Handle(TDF_Reference) aRef;
-  if (!theLabel.FindAttribute(TDF_Reference::GetID(), aRef)) {
-    return NULL;
-  }
-  
-  if(aRef.IsNull() || aRef->Get().IsNull()) {
-    return NULL;
-  }
-
-
-  // Get TreeNode of a referenced function
-  Handle(TDataStd_TreeNode) aT, aFather;
-  if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) {
-    return NULL;
-  }
-
-
-  // Get TreeNode of Object of the referenced function
-  aFather = aT->Father();
-  if (aFather.IsNull()) {
-    return NULL;
-  }
-
-  // Get label of the referenced object
-  TDF_Label aLabel = aFather->Label();
-  
-
-  return GEOM_Object::GetObject(aLabel);
+  Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetReferencedObject(theLabel);
+  return Handle(GEOM_Object)::DownCast( base );
 }
 
 //=============================================================================
@@ -150,17 +69,10 @@ Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
  *  Constructor: private
  */
 //=============================================================================
+
 GEOM_Object::GEOM_Object(TDF_Label& theEntry)
-  : _label(theEntry), _ior(""), _docID(-1)
+  : GEOM_BaseObject(theEntry)
 {
-  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
-  if(!aDoc.IsNull()) {
-    Handle(TDataStd_Integer) anID;
-    if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
-  }
-
-  if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
-    _root = TDataStd_TreeNode::Set(theEntry);
 }
 
 //=============================================================================
@@ -168,23 +80,10 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry)
  *  Constructor: public
  */
 //=============================================================================
+
 GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
-: _label(theEntry), _ior(""), _docID(-1)
+  : GEOM_BaseObject( theEntry, theType )
 {
-  Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
-  if(!aDoc.IsNull()) {
-    Handle(TDataStd_Integer) anID;
-    if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
-  }
-
-  theEntry.ForgetAllAttributes(Standard_True);
-
-  if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
-    _root = TDataStd_TreeNode::Set(theEntry);
-
-  TDataStd_Integer::Set(theEntry.FindChild(TYPE_LABEL), theType);
-
-  TDataStd_UAttribute::Set(theEntry, GetObjectID());
 }
 
 //=============================================================================
@@ -197,91 +96,6 @@ GEOM_Object::~GEOM_Object()
   MESSAGE("GEOM_Object::~GEOM_Object()");
 }
 
-//=============================================================================
-/*!
- *  GetType
- */
-//=============================================================================
-int GEOM_Object::GetType()
-{
-  Handle(TDataStd_Integer) aType;
-  if(!_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1;
-
-  return aType->Get();
-}
-
-//=============================================================================
-/*!
- *  SetType
- */
-//=============================================================================
-void GEOM_Object::SetType(int theType)
-{
-  TDataStd_Integer::Set(_label.FindChild(TYPE_LABEL), theType);
-}
-
-
-//=============================================================================
-/*!
- *  Returns modifications counter of this object.
- *  Comparing this value with modifications counters of argument objects
- *  (on which this object depends) we decide whether this object needs to be updated.
- */
-//=============================================================================
-int GEOM_Object::GetTic()
-{
-  Handle(TDataStd_Integer) aTicAttr;
-  if (!_label.FindChild(TIC_LABEL).FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
-    return 0;
-
-  return aTicAttr->Get();
-}
-
-//=============================================================================
-/*!
- *  Set another value of modifications counter.
- *
- *  Use this method to update modifications counter of dependent object
- *  to be equal to modifications counter of its argument.
- *  This is commonly done in GEOM_Function::GetValue()
- */
-//=============================================================================
-void GEOM_Object::SetTic(int theTic)
-{
-  TDataStd_Integer::Set(_label.FindChild(TIC_LABEL), theTic);
-}
-
-//=============================================================================
-/*!
- *  Increment modifications counter to mark this object as modified.
- *
- *  Commonly called from GEOM_Function::SetValue()
- */
-//=============================================================================
-void GEOM_Object::IncrementTic()
-{
-  TDF_Label aTicLabel = _label.FindChild(TIC_LABEL);
-
-  Standard_Integer aTic = 0;
-  Handle(TDataStd_Integer) aTicAttr;
-  if (aTicLabel.FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
-    aTic = aTicAttr->Get();
-
-  TDataStd_Integer::Set(aTicLabel, aTic + 1);
-}
-
-
-//=============================================================================
-/*!
- *  GetDocID
- */
-//=============================================================================
-int GEOM_Object::GetDocID()
-{
-  return _docID;
-}
-
-
 //=============================================================================
 /*!
  *  GetValue
@@ -299,33 +113,6 @@ TopoDS_Shape GEOM_Object::GetValue()
   return aShape;
 }
 
-//=============================================================================
-/*!
- *  SetName
- */
-//=============================================================================
-void GEOM_Object::SetName(const char* theName)
-{
-  TDataStd_Name::Set(_label, (char*)theName);
-}
-
-//=============================================================================
-/*!
- *  GetName
- */
-//=============================================================================
-TCollection_AsciiString GEOM_Object::GetName()
-{
-  TCollection_AsciiString aName;
-  Handle(TDataStd_Name) aNameAttr;
-  if(_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr))
-    aName = aNameAttr->Get();
-  // do not return pointer of local variable
-  // return aName.ToCString();
-  // the following code could lead to memory leak, so take care about recieved pointer
-  return aName;
-}
-
 //=============================================================================
 /*!
  *  SetColor
@@ -475,58 +262,6 @@ void GEOM_Object::UnsetMarker()
   SetMarkerStd((Aspect_TypeOfMarker)-1, 0.);
 }
 
-//=============================================================================
-/*!
- *  SetAuxData
- */
-//=============================================================================
-void GEOM_Object::SetAuxData(const char* theData)
-{
-  TDataStd_Comment::Set(_label, (char*)theData);
-}
-
-//=============================================================================
-/*!
- *  GetAuxData
- */
-//=============================================================================
-TCollection_AsciiString GEOM_Object::GetAuxData()
-{
-  TCollection_AsciiString aData;
-
-  Handle(TDataStd_Comment) aCommentAttr;
-  if (_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr))
-    aData = aCommentAttr->Get();
-
-  return aData;
-}
-
-//=============================================================================
-/*!
- *  SetParameters
- */
-//=============================================================================
-void GEOM_Object::SetParameters(const TCollection_AsciiString& theParameters)
-{
-  if( _parameters.IsEmpty() )
-    _parameters = theParameters;
-  else {
-    _parameters += "|";
-    _parameters += theParameters;
-  }
-}
-
-//=============================================================================
-/*!
- *  GetParameters
- */
-//=============================================================================
-TCollection_AsciiString GEOM_Object::GetParameters() const
-{
-  return _parameters;
-}
-
-
 //=============================================================================
 /*!
  *  IsSubShape
@@ -535,191 +270,10 @@ TCollection_AsciiString GEOM_Object::GetParameters() const
 bool GEOM_Object::IsMainShape()
 {
   Handle(GEOM_Function) aFunction = GetFunction(1);
-  if(aFunction.IsNull() || aFunction->GetDriverGUID() != GetSubShapeID()) return true; // mkr : IPAL9921
+  if(aFunction.IsNull() || aFunction->GetDriverGUID() != GetSubShapeID())
+    return true; // mkr : IPAL9921
   return false;
 }
 
-
-//=============================================================================
-/*!
- *  AddFunction
- */
-//=============================================================================
-Handle(GEOM_Function) GEOM_Object::AddFunction(const Standard_GUID& theGUID,
-                                               int                  theFunctionType,
-                                               bool                 allowSubShape)
-{
-  Standard_Integer nb = GetNbFunctions();
-  if(!allowSubShape && nb == 1 && theGUID == GetSubShapeID()) return NULL; //It's impossible to add a function to sub-shape
-  nb++;
-  TDF_Label aChild = FUNCTION_LABEL(nb);
-
-  Handle(TDataStd_TreeNode) aNode = TDataStd_TreeNode::Set(aChild);
-  _root->Append(aNode);
-
-  Handle(GEOM_Function) aFunction = new GEOM_Function(aChild, theGUID, theFunctionType);
-
-  return aFunction;
-
-}
-
-//=============================================================================
-/*!
- *  GetNbFunctions
- */
-//=============================================================================
-int GEOM_Object::GetNbFunctions()
-{
-  Standard_Integer nb = 0;
-  for(TDataStd_ChildNodeIterator CI(_root); CI.More(); CI.Next()) nb++;
-  return nb;
-}
-
-//=============================================================================
-/*!
- *  GetFunction
- */
-//=============================================================================
-Handle(GEOM_Function) GEOM_Object::GetFunction(int theFunctionNumber)
-{
-  TDF_Label aChild = FUNCTION_LABEL(theFunctionNumber);
-  return GEOM_Function::GetFunction(aChild);
-}
-
-//=============================================================================
-/*!
- *  GetlastFunction
- */
-//=============================================================================
-Handle(GEOM_Function) GEOM_Object::GetLastFunction()
-{
-  Standard_Integer nb = GetNbFunctions();
-  if(nb) return GetFunction(nb);
-
-  return NULL;
-}
-
-
-//=============================================================================
-/*!
- *  GetAllDependency
- */
-//=============================================================================
-Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetAllDependency()
-{
-  Handle(TColStd_HSequenceOfTransient) anArray;
-  TDF_LabelSequence aSeq;
-  Standard_Integer nb = GetNbFunctions();
-  if(nb == 0) return anArray;
-  for(Standard_Integer i=1; i<=nb; i++) {
-    Handle(GEOM_Function) aFunction = GetFunction(i);
-    if(aFunction.IsNull()) continue;
-    aFunction->GetDependency(aSeq);
-  }
-
-  Standard_Integer aLength = aSeq.Length();
-  if(aLength > 0) {
-    anArray = new TColStd_HSequenceOfTransient;
-    for(Standard_Integer j =1; j<=aLength; j++) {
-      Handle(GEOM_Object) aRefObj = GetReferencedObject(aSeq(j));
-      if(!aRefObj.IsNull()) anArray->Append(aRefObj);
-    }
-  }
-
-  return anArray;
-}
-
-//=============================================================================
-/*!
- *  GetLastDependency
- */
-//=============================================================================
-Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetLastDependency()
-{
-  Handle(TColStd_HSequenceOfTransient) anArray;
-  Handle(GEOM_Function) aFunction = GetLastFunction();
-  if (aFunction.IsNull()) return anArray;
-
-  TDF_LabelSequence aSeq;
-  aFunction->GetDependency(aSeq);
-  Standard_Integer aLength = aSeq.Length();
-  if (aLength > 0) {
-    anArray = new TColStd_HSequenceOfTransient;
-    for (Standard_Integer i = 1; i <= aLength; i++)
-      anArray->Append(GetReferencedObject(aSeq(i)));
-  }
-
-  return anArray;
-}
-
-//================================================================================
-/*!
- * \brief Returns a driver creator of this object
- */
-//================================================================================
-
-Handle(TFunction_Driver) GEOM_Object::GetCreationDriver()
-{
-  Handle(TFunction_Driver) aDriver;
-
-  Handle(GEOM_Function) function = GetFunction(1);
-  if ( !function.IsNull() )
-  {
-    Standard_GUID aGUID = function->GetDriverGUID();
-    if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver))
-      aDriver->Init( function->GetEntry() );
-  }
-  return aDriver;
-}
-
-//=============================================================================
-/*!
- *  GetFreeLabel
- */
-//=============================================================================
-TDF_Label GEOM_Object::GetFreeLabel()
-{
-  return _label.FindChild(FREE_LABEL);
-}
-
-//=======================================================================
-//function :  GEOM_Object_Type_
-//purpose  :
-//=======================================================================
-Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_()
-{
-
-  static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared);
-  if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared);
-  static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient);
-  if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient);
-
-
-  static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL};
-  static Handle_Standard_Type _aType = new Standard_Type("GEOM_Object",
-                                                         sizeof(GEOM_Object),
-                                                         1,
-                                                         (Standard_Address)_Ancestors,
-                                                         (Standard_Address)NULL);
-  return _aType;
-}
-
-//=======================================================================
-//function : DownCast
-//purpose  :
-//=======================================================================
-
-const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject)
-{
-  Handle(GEOM_Object) _anOtherObject;
-
-  if (!AnObject.IsNull()) {
-     if (AnObject->IsKind(STANDARD_TYPE(GEOM_Object))) {
-       _anOtherObject = Handle(GEOM_Object)((Handle(GEOM_Object)&)AnObject);
-     }
-  }
-
-  return _anOtherObject ;
-}
-
-
+IMPLEMENT_STANDARD_HANDLE (GEOM_Object, GEOM_BaseObject );
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_Object, GEOM_BaseObject );
index 3a9cf74600b78e4daf2b70d6079785007f6ec5b1..2d53c2b7cfaf4e46091802702ea793c7382e3dbc 100644 (file)
 #ifndef _GEOM_Object_HeaderFile
 #define _GEOM_Object_HeaderFile
 
-#ifndef _Standard_TypeMismatch_HeaderFile
-#include <Standard_TypeMismatch.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Handle_MMgt_TShared_HeaderFile
-#include <Handle_MMgt_TShared.hxx>
-#endif
-#ifndef _MMgt_TShared_HeaderFile
-#include <MMgt_TShared.hxx>
-#endif
-#ifndef _Standard_GUID_HeaderFile
+#include "GEOM_BaseObject.hxx"
+
+#include <Aspect_TypeOfMarker.hxx>
 #include <Standard_GUID.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _TDF_Label_HeaderFile
 #include <TDF_Label.hxx>
-#endif
-#ifndef _TColStd_HSequenceOfTransient_HeaderFile
-#include <TColStd_HSequenceOfTransient.hxx>
-#endif
-#ifndef _TCollection_AsciiString_HeaderFile
-#include <TCollection_AsciiString.hxx>
-#endif
-#ifndef _Aspect_TypeOfMarker_HeaderFile
-#include <Aspect_TypeOfMarker.hxx>
-#endif
-
+#include <TopoDS_Shape.hxx>
 
-class Handle_TColStd_HSequenceOfTransient;
-class Standard_Transient;
-class Handle_Standard_Type;
-class Handle(MMgt_TShared);
 class GEOM_Object;
 class Handle(TFunction_Driver);
+class GEOM_Engine;
 
+DEFINE_STANDARD_HANDLE( GEOM_Object, GEOM_BaseObject );
 
-Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
-
-class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
-  public:
-    inline void* operator new(size_t,void* anAddress)
-      {
-        return anAddress;
-      }
-    inline void* operator new(size_t size)
-      {
-        return Standard::Allocate(size);
-      }
-    inline void  operator delete(void *anAddress)
-      {
-        if (anAddress) Standard::Free((Standard_Address&)anAddress);
-      }
-
-    Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
-    Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle)
-     {
-     }
-
-    Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
-     {
-     }
-
-    Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
-     {
-      Assign(aHandle.Access());
-      return *this;
-     }
-
-    Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
-     {
-      Assign((Standard_Transient *)anItem);
-      return *this;
-     }
-
-    GEOM_Object* operator->()
-     {
-      return (GEOM_Object *)ControlAccess();
-     }
-
-    GEOM_Object* operator->() const
-     {
-      return (GEOM_Object *)ControlAccess();
-     }
-
-   Standard_EXPORT ~Handle(GEOM_Object)() {};
-
-   Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
-};
-
-
-#include <Standard_GUID.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include "GEOM_Function.hxx"
-#include "GEOM_Engine.hxx"
-
-class GEOM_Object : public MMgt_TShared
+class GEOM_Object : public GEOM_BaseObject
 {
  friend class GEOM_Engine;
  
@@ -142,27 +50,6 @@ class GEOM_Object : public MMgt_TShared
     double B;
   };
 
- public:
-  inline void* operator new(size_t,void* anAddress)
-    {
-      return anAddress;
-    }
-  inline void* operator new(size_t size)
-    {
-      return Standard::Allocate(size);
-    }
-  inline void  operator delete(void *anAddress)
-    {
-      if (anAddress) Standard::Free((Standard_Address&)anAddress);
-    }
-
-  // Type management
-  //
-  Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
-  Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Object) ; }
-  Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
-           { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); }
-
  private:
   GEOM_Object(TDF_Label& theLabel);
 
@@ -176,45 +63,13 @@ class GEOM_Object : public MMgt_TShared
   //Finds a GEOM_Object by a reference, stored on the label theLabel
   Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
 
-  //Returns a GEOM_Object common GUID
-  Standard_EXPORT static const Standard_GUID& GetObjectID();
-
-  //Returns a GUID associated with a sub-shape object
-  Standard_EXPORT static const Standard_GUID& GetSubShapeID();
-
   //###########################################################
   //Access to properties
   //###########################################################
 
-  //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
-  Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
-
-  //Returns a label of this GEOM_Object
-  Standard_EXPORT TDF_Label GetEntry() { return _label; }
-
-  //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
-  Standard_EXPORT int GetType();
-
-  //Sets the type of this GEOM_Object
-  Standard_EXPORT void SetType(int theType);
-
-  //Modifications counter management
-  Standard_EXPORT int  GetTic();
-  Standard_EXPORT void SetTic(int theTic);
-  Standard_EXPORT void IncrementTic();
-
-  //Returns an ID of the OCAF document where this GEOM_Object is stored
-  Standard_EXPORT int GetDocID();
-
   //Returns a value (as TopoDS_Shape) of this GEOM_Object
   Standard_EXPORT TopoDS_Shape GetValue();
 
-  //Sets a name of this GEOM_Object
-  Standard_EXPORT void SetName(const char* theName);
-
-  //Returns a name of this GEOM_Object
-  Standard_EXPORT TCollection_AsciiString GetName();
-
   //Sets a color of this GEOM_Object
   Standard_EXPORT void SetColor(const Color& theColor);
 
@@ -245,18 +100,6 @@ class GEOM_Object : public MMgt_TShared
   //Unsets point marker
   Standard_EXPORT void UnsetMarker();
 
-  //Sets an auxiliary data
-  Standard_EXPORT void SetAuxData(const char* theData);
-
-  //Returns an auxiliary data
-  Standard_EXPORT TCollection_AsciiString GetAuxData();
-
-  //Set a notebook variables used for object creation
-  Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
-
-  //Get a notebook variables used for object creation
-  Standard_EXPORT TCollection_AsciiString GetParameters() const;
-
   //###########################################################
   // Sub-shape methods
   //###########################################################
@@ -264,59 +107,8 @@ class GEOM_Object : public MMgt_TShared
   //Returns false if the object is a sub-shape of another object
   Standard_EXPORT bool IsMainShape();
 
-  //###########################################################
-  // CORBA related methods
-  //###########################################################
-
-  //Sets an IOR of CORBA GEOM_Object_i which refers to this object
-  Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
-
-  //Returns an IOR of CORBA GEOM_Object_i which refers to this object
-  Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
-
-  //###########################################################
-  //Functions methods
-  //###########################################################
-
-  //Adds a function with a driver GUID = theGUID and a type theFunctionType
-  //to the function tree of this GEOM_Object
-  Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID,
-                                                    int                  theFunctionType,
-                                                    bool                 allowSubShape=false);
-
-  //Returns a number of functions of this GEOM_Object
-  Standard_EXPORT int GetNbFunctions();
-
-  //Returns a function with given number theFunctionNumber
-  Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
-
-  //Return the last function of this GEOM_Object
-  Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
-
-  //Returns all dependencies of the object
-  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
-
-  //Returns the dependencies of the last function
-  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
-
-  //Returns a driver creator of this object
-  Standard_EXPORT Handle(TFunction_Driver) GetCreationDriver();
-
-  //###########################################################
-  // Internal methods
-  //###########################################################
-
-  //Returns a label which could be used to store some additional data
-  Standard_EXPORT TDF_Label GetFreeLabel();
-
- private:
-  Handle(TDataStd_TreeNode) _root;
-  TDF_Label                 _label;
-  TCollection_AsciiString   _ior;
-  TCollection_AsciiString   _parameters;
-  int                       _docID;
-
-
+public:
+  DEFINE_STANDARD_RTTI( GEOM_Object );
 };
 
 #endif
index ce5038c70fc01b09390858a021e4a1d6217acddf..e8f2ee33f7adb2e86ce073bce1619d6f923b0a0c 100644 (file)
@@ -33,7 +33,7 @@ namespace GEOM
 {
   size_t TPythonDump::myCounter = 0;
 
-  TPythonDump::TPythonDump (Handle(GEOM_Function)& theFunction, bool theAppend)
+  TPythonDump::TPythonDump (const Handle(GEOM_Function)& theFunction, bool theAppend)
   {
     myFunction = theFunction;
     myCounter++;
@@ -101,6 +101,12 @@ namespace GEOM
     return *this;
   }
 
+  TPythonDump& TPythonDump::operator<< (const TCollection_AsciiString theArg)
+  {
+    myStream<<theArg;
+    return *this;
+  }
+
   TPythonDump& TPythonDump::operator<< (const TopAbs_ShapeEnum theArg)
   {
     myStream<<"geompy.ShapeType[\"";
@@ -109,10 +115,20 @@ namespace GEOM
     return *this;
   }
 
-  TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject)
+  TPythonDump& TPythonDump::operator<< (const Handle(GEOM_BaseObject)& theObject)
   {
     if (theObject.IsNull()) {
       myStream << "None";
+    } else {
+      *this << theObject.operator->();
+    }
+    return *this;
+  }
+
+  TPythonDump& TPythonDump::operator<< (const GEOM_BaseObject* theObject)
+  {
+    if ( !theObject ) {
+      myStream << "None";
     } else {
       TCollection_AsciiString anEntry;
       TDF_Tool::Entry(theObject->GetEntry(), anEntry);
index a8f66c2580c6c3d19eb8c68f379bfb534b17b8cf..3a7ee2b654b872f6b0c1efce266883bc7ce51958 100644 (file)
@@ -41,7 +41,7 @@ namespace GEOM
     Handle(GEOM_Function) myFunction;
 
   public:
-    Standard_EXPORT TPythonDump (Handle(GEOM_Function)& theFunction, bool theAppend=false);
+    Standard_EXPORT TPythonDump (const Handle(GEOM_Function)& theFunction, bool theAppend=false);
     Standard_EXPORT virtual ~TPythonDump();
 
     //operator TCollection_AsciiString () const;
@@ -53,8 +53,10 @@ namespace GEOM
     Standard_EXPORT TPythonDump& operator<< (float theArg);
     Standard_EXPORT TPythonDump& operator<< (const void* theArg);
     Standard_EXPORT TPythonDump& operator<< (const char* theArg);
+    Standard_EXPORT TPythonDump& operator<< (const TCollection_AsciiString theArg);
     Standard_EXPORT TPythonDump& operator<< (const TopAbs_ShapeEnum theArg);
-    Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_Object)& theObject);
+    Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_BaseObject)& theObject);
+    Standard_EXPORT TPythonDump& operator<< (const GEOM_BaseObject* theObject);
   };
 
   /*! Returns an object from two given, which has the latest entry
index 8535072050d980e3a557c79b13fe80dadd3a5214..824d4e03ae71d27143e5987b22764a24b3fa129a 100644 (file)
             <source>ICON_OBJBROWSER_GROUP_SOLID</source>
             <translation>tree_group_solid.png</translation>
         </message>
+        <message>
+            <source>ICON_OBJBROWSER_FIELD_EDGE</source>
+            <translation>tree_field_edge.png</translation>
+        </message>
+        <message>
+            <source>ICON_OBJBROWSER_FIELD_FACE</source>
+            <translation>tree_field_face.png</translation>
+        </message>
+        <message>
+            <source>ICON_OBJBROWSER_FIELD_PNT</source>
+            <translation>tree_field_vertex.png</translation>
+        </message>
+        <message>
+            <source>ICON_OBJBROWSER_FIELD_SOLID</source>
+            <translation>tree_field_solid.png</translation>
+        </message>
         <message>
             <source>ICON_OBJBROWSER_Geometry</source>
             <translation>geometry.png</translation>
index 4456b351921614dce8d54f54aee5592c886d4d0a..6efdf1648376143bc69dae2c605bbf3df73db9ba 100644 (file)
@@ -1968,7 +1968,7 @@ void GeometryGUI::updateCreationInfo()
   //   return;
 
   // look for a sole selected GEOM_Object
-  GEOM::GEOM_Object_var geomObj;
+  GEOM::GEOM_BaseObject_var geomObj;
 
   SALOME_ListIO selected;
   getApp()->selectionMgr()->selectedObjects( selected );
@@ -1981,8 +1981,8 @@ void GeometryGUI::updateCreationInfo()
     if ( !io->hasEntry() ) continue;
     _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
     if ( !sobj ) continue;
-    CORBA::Object_var      obj = GeometryGUI::ClientSObjectToObject( sobj );
-    GEOM::GEOM_Object_var gobj = GEOM::GEOM_Object::_narrow( obj );
+    CORBA::Object_var          obj = GeometryGUI::ClientSObjectToObject( sobj );
+    GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
     if ( !gobj->_is_nil() )
     {
       if ( !geomObj->_is_nil() )
index 71ad0a172c41d6aeb0bb4ff55ae9c19b53fb8e7d..4f028766f082a0390e722e771ea53bf40271cb62 100755 (executable)
@@ -66,6 +66,7 @@ SET(GEOMImpl_HEADERS
   GEOMImpl_IInsertOperations.hxx
   GEOMImpl_IMeasureOperations.hxx
   GEOMImpl_IGroupOperations.hxx
+  GEOMImpl_IFieldOperations.hxx
   GEOMImpl_IGlue.hxx
   GEOMImpl_PointDriver.hxx
   GEOMImpl_IPoint.hxx
@@ -183,6 +184,7 @@ SET(GEOMImpl_SOURCES
   GEOMImpl_IInsertOperations.cxx
   GEOMImpl_IMeasureOperations.cxx
   GEOMImpl_IGroupOperations.cxx
+  GEOMImpl_IFieldOperations.cxx
   GEOMImpl_Gen.cxx
   GEOMImpl_PointDriver.cxx
   GEOMImpl_VectorDriver.cxx
@@ -233,6 +235,7 @@ SET(GEOMImpl_SOURCES
   GEOMImpl_HealingDriver.cxx
   GEOMImpl_FillingDriver.cxx
   GEOMImpl_GlueDriver.cxx
+  GEOMImpl_FieldDriver.cxx
   )
 
 # --- rules ---
diff --git a/src/GEOMImpl/GEOMImpl_FieldDriver.cxx b/src/GEOMImpl/GEOMImpl_FieldDriver.cxx
new file mode 100644 (file)
index 0000000..f522369
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOMImpl_FieldDriver.hxx"
+
+#include "GEOM_Field.hxx"
+#include "GEOM_Function.hxx"
+#include "GEOM_IField.hxx"
+
+//=======================================================================
+//function : GetID
+//purpose  :
+//=======================================================================
+const Standard_GUID& GEOMImpl_FieldDriver::GetID()
+{
+  return GEOM_Field::GetFieldID();
+}
+
+//=======================================================================
+//function : GEOMImpl_FieldDriver
+//purpose  :
+//=======================================================================
+GEOMImpl_FieldDriver::GEOMImpl_FieldDriver()
+{
+}
+
+//=======================================================================
+//function : Execute
+//purpose  :
+//=======================================================================
+Standard_Integer GEOMImpl_FieldDriver::Execute(TFunction_Logbook& log) const
+{
+  return 0;
+}
+
+//================================================================================
+/*!
+ * \brief Returns a name of creation operation and names and values of creation parameters
+ */
+//================================================================================
+
+bool GEOMImpl_FieldDriver::
+GetCreationInformation(std::string&             theOperationName,
+                       std::vector<GEOM_Param>& theParams)
+{
+  if (Label().IsNull()) return false;
+  Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
+
+  GEOM_IField data( function );
+  Standard_Integer funType = function->GetType();
+
+  if ( funType == GEOM_Field::FUN_ADD_FIELD )
+  {
+    theOperationName = "ADD_FIELD";
+    // geompy.CreateField(shape, name, type, dimension, componentNames)
+    Handle(GEOM_Field) f = GEOM_Field::GetField( function->GetOwnerEntry() );
+    AddParam( theParams, "Shape", data.GetShape() );
+    AddParam( theParams, "Name", f->GetName() );
+    AddParam( theParams, "Type", f->GetDataTypeString( data.GetDataType() ));
+    AddParam( theParams, "Dimension", data.GetDimension() );
+    GEOM_Param comps = AddParam( theParams, "Components", f->GetComponentsForPython() );
+  }
+  else if ( funType == GEOM_Field::FUN_ADD_STEP )
+  {
+    theOperationName = "ADD_FIELD_STEP";
+    // field.addStep(step, stamp, values)
+    AddParam( theParams, "Step", data.GetStepID() );
+    AddParam( theParams, "Stamp", data.GetStepStamp() );
+  }
+  else
+  {
+    return false;
+  }
+  
+  return true;
+}
+
+IMPLEMENT_STANDARD_HANDLE (GEOMImpl_FieldDriver,GEOM_BaseDriver);
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_FieldDriver,GEOM_BaseDriver);
diff --git a/src/GEOMImpl/GEOMImpl_FieldDriver.hxx b/src/GEOMImpl/GEOMImpl_FieldDriver.hxx
new file mode 100644 (file)
index 0000000..3a3fbab
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  File   : GEOMImpl_FieldDriver.hxx
+//  Module : GEOM
+//
+#ifndef _GEOMImpl_FieldDriver_HeaderFile
+#define _GEOMImpl_FieldDriver_HeaderFile
+
+#include "GEOM_BaseDriver.hxx"
+
+DEFINE_STANDARD_HANDLE( GEOMImpl_FieldDriver, GEOM_BaseDriver );
+
+/*!
+ * \brief This class is needed only to retrieve creation information of GEOM_Field
+ */
+class GEOMImpl_FieldDriver : public GEOM_BaseDriver
+{
+public:
+  Standard_EXPORT GEOMImpl_FieldDriver();
+  Standard_EXPORT virtual  Standard_Integer Execute(TFunction_Logbook& log) const; 
+  Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
+  Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; }
+  Standard_EXPORT static const Standard_GUID& GetID();
+  Standard_EXPORT ~GEOMImpl_FieldDriver() {};
+
+  Standard_EXPORT virtual
+  bool GetCreationInformation(std::string&             theOperationName,
+                              std::vector<GEOM_Param>& params);
+
+  DEFINE_STANDARD_RTTI( GEOMImpl_FieldDriver )
+};
+
+#endif
index 4b91160ba33d4b899cd565a92a28ad9f29fd17b3..515ffa9fb206b03bd06c55111a32ddd830bf7ab5 100644 (file)
@@ -82,6 +82,7 @@
 #include <GEOMImpl_FillingDriver.hxx>
 #include <GEOMImpl_GlueDriver.hxx>
 #include <GEOMImpl_MeasureDriver.hxx>
+#include <GEOMImpl_FieldDriver.hxx>
 
 //=============================================================================
 /*!
@@ -163,6 +164,9 @@ GEOMImpl_Gen::GEOMImpl_Gen()
    // Measurements
    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver());
 
+   // Field
+   TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FieldDriver::GetID(), new GEOMImpl_FieldDriver());
+
    SetEngine(this);
 }
 
@@ -223,6 +227,10 @@ GEOMImpl_Gen::~GEOMImpl_Gen()
   std::map<int, GEOMImpl_IGroupOperations*>::iterator aGroupIter = _mapOfGroupOperations.begin();
   for (; aGroupIter != _mapOfGroupOperations.end(); aGroupIter++)
     delete (*aGroupIter).second;
+
+  std::map<int, GEOMImpl_IFieldOperations*>::iterator aFieldIter = _mapOfFieldOperations.begin();
+  for (; aFieldIter != _mapOfFieldOperations.end(); aFieldIter++)
+    delete (*aFieldIter).second;
 }
 
 //=============================================================================
@@ -392,3 +400,17 @@ GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID)
 
   return _mapOfGroupOperations[theDocID];
 }
+
+//=============================================================================
+/*!
+ * GetIFieldOperations
+ */
+//=============================================================================
+GEOMImpl_IFieldOperations* GEOMImpl_Gen::GetIFieldOperations(int theDocID)
+{
+  if(_mapOfFieldOperations.find(theDocID) == _mapOfFieldOperations.end()) {
+    _mapOfFieldOperations[theDocID] = new GEOMImpl_IFieldOperations(this, theDocID);
+  }
+
+  return _mapOfFieldOperations[theDocID];
+}
index 06ca4ff63144d6a4143a617c0753d73d30fff3c5..57d1febe6f6a020b0fb953084d854015880e17cd 100644 (file)
@@ -39,6 +39,7 @@
 #include "GEOMImpl_IInsertOperations.hxx"
 #include "GEOMImpl_IMeasureOperations.hxx"
 #include "GEOMImpl_IGroupOperations.hxx"
+#include "GEOMImpl_IFieldOperations.hxx"
 #include "GEOM_Engine.hxx"
 
 class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
@@ -71,6 +72,8 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
 
   GEOMImpl_IGroupOperations* GetIGroupOperations(int theDocID);
 
+  GEOMImpl_IFieldOperations* GetIFieldOperations(int theDocID);
+
  private:
 
   std::map <int, GEOMImpl_IBasicOperations*>     _mapOfBasicOperations;
@@ -85,6 +88,7 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
   std::map <int, GEOMImpl_IInsertOperations*>    _mapOfInsertOperations;
   std::map <int, GEOMImpl_IMeasureOperations*>   _mapOfMeasureOperations;
   std::map <int, GEOMImpl_IGroupOperations*>     _mapOfGroupOperations;
+  std::map <int, GEOMImpl_IFieldOperations*>     _mapOfFieldOperations;
 };
 
 #endif
diff --git a/src/GEOMImpl/GEOMImpl_IFieldOperations.cxx b/src/GEOMImpl/GEOMImpl_IFieldOperations.cxx
new file mode 100644 (file)
index 0000000..828de70
--- /dev/null
@@ -0,0 +1,232 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOMImpl_IFieldOperations.hxx"
+
+#include "GEOMImpl_Types.hxx"
+
+#include "GEOM_Field.hxx"
+#include "GEOM_Function.hxx"
+#include "GEOM_IField.hxx"
+#include "GEOM_Object.hxx"
+#include "GEOM_PythonDump.hxx"
+
+#include <TColStd_HArray1OfExtendedString.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
+
+#include <utilities.h>
+
+
+//=============================================================================
+/*!
+ *   constructor:
+ */
+//=============================================================================
+GEOMImpl_IFieldOperations::GEOMImpl_IFieldOperations (GEOM_Engine* theEngine, int theDocID)
+: GEOM_IOperations(theEngine, theDocID)
+{
+  MESSAGE("GEOMImpl_IFieldOperations::GEOMImpl_IFieldOperations");
+}
+
+//=============================================================================
+/*!
+ *  destructor
+ */
+//=============================================================================
+GEOMImpl_IFieldOperations::~GEOMImpl_IFieldOperations()
+{
+  MESSAGE("GEOMImpl_IFieldOperations::~GEOMImpl_IFieldOperations");
+}
+
+
+//=============================================================================
+/*!
+ *  CreateField
+ */
+//=============================================================================
+Handle(GEOM_Field) GEOMImpl_IFieldOperations::
+CreateField( const Handle(GEOM_Object)&                     theShape,
+             const char*                                    theName,
+             const int                                      theType,
+             const int                                      theDimension,
+             const Handle(TColStd_HArray1OfExtendedString)& theComponentNames)
+{
+  SetErrorCode(KO);
+
+  // check input data
+  if ( theShape.IsNull() ) {
+    SetErrorCode( "Error: NULL shape" );
+    return NULL;
+  }
+  if ( !theName || !theName[0] ) {
+    SetErrorCode( "Error: empty field name" );
+    return NULL;
+  }
+  if ( theType < 0 || theType > 3) {
+    SetErrorCode( "Error: invalid field type."
+                  "Valid types are: 0 - boolean, 1 - integer, 2 - double, 3 - string");
+    return NULL;
+  }
+  if ( theDimension < -1 || theDimension > 3) {
+    SetErrorCode( "Error: invalid shape dimension."
+                  "Valid types are: 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape");
+    return NULL;
+  }
+  if ( theComponentNames.IsNull() || theComponentNames->Length() < 1 ) {
+    SetErrorCode( "Error: no component names provided");
+    return NULL;
+  }
+
+  // make a field
+  Handle(GEOM_Field) aField = Handle(GEOM_Field)::DownCast
+    ( GetEngine()->AddBaseObject( GetDocID(), GEOM_FIELD ));
+
+  // set field data
+  aField->Init( theShape, theName, theType, theDimension, theComponentNames );
+
+  // remember aField as a sub-object of theShape
+  Handle(GEOM_Function) aFieldFun = aField->GetFunction(1);
+  Handle(GEOM_Function) aShapeFun = theShape->GetFunction(1);
+  aShapeFun->AddSubShapeReference(aFieldFun);
+
+  //make a Python command
+  GEOM::TPythonDump(aFieldFun) << aField << " = geompy.CreateField( "
+                               << theShape << ", '"
+                               << theName << "', "
+                               << "GEOM.FDT_" << aField->GetDataTypeString( theType ) << ", "
+                               << theDimension << ", "
+                               << aField->GetComponentsForPython() << ")";
+  SetErrorCode(OK);
+  return aField;
+}
+
+//=======================================================================
+//function : CountFields
+//purpose  : Returns number of fields on a shape
+//=======================================================================
+
+int GEOMImpl_IFieldOperations::CountFields( const Handle(GEOM_Object)& theShape )
+{
+  SetErrorCode(OK);
+
+  if ( theShape.IsNull() )
+    return 0;
+
+  Handle(GEOM_Function) aShapeFun = theShape->GetFunction(1);
+  if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() )
+    return 0;
+
+  const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
+  if (aListEntries.IsEmpty()) return 0;
+
+  int nbFields = 0;
+  char entry[200], *pentry = entry; // the entry can't be too long
+  TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+  for (; anIt.More(); anIt.Next()) {
+    TCollection_ExtendedString& anEntry = anIt.Value();
+    anEntry.ToUTF8CString( (Standard_PCharacter&) pentry );
+    Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), entry, false);
+    nbFields += ( !anObj.IsNull() && anObj->IsKind(STANDARD_TYPE(GEOM_Field)) );
+  }
+
+  return nbFields;
+}
+
+//=======================================================================
+//function : GetFields
+//purpose  : Returns all fields on a shape
+//=======================================================================
+
+Handle(TColStd_HSequenceOfTransient)
+GEOMImpl_IFieldOperations::GetFields( const Handle(GEOM_Object)& theShape )
+{
+  SetErrorCode(KO);
+
+  Handle(TColStd_HSequenceOfTransient) fields;
+  if ( theShape.IsNull() ) {
+    SetErrorCode( "Error: NULL shape" );
+    return fields;
+  }
+  SetErrorCode(OK);
+
+  Handle(GEOM_Function) aShapeFun = theShape->GetFunction(1);
+  if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() )
+    return fields;
+
+  const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
+  if (aListEntries.IsEmpty()) return fields;
+
+  char entry[200], *pentry = entry; // the entry can't be too long
+  TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+  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 );
+  }
+
+  return fields;
+}
+
+//=======================================================================
+//function : GetField
+//purpose  : Returns a field on a shape by its name
+//=======================================================================
+
+Handle(GEOM_Field)
+GEOMImpl_IFieldOperations::GetField( const Handle(GEOM_Object)& theShape,
+                                     const char*                theName )
+{
+  SetErrorCode(OK);
+
+  Handle(GEOM_Field) field;
+  if ( theShape.IsNull() ) {
+    //SetErrorCode( "Error: NULL shape" );
+    return field;
+  }
+  Handle(GEOM_Function) aShapeFun = theShape->GetFunction(1);
+  if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() ) {
+    //SetErrorCode( "Error: No fields on the shape at all" );
+    return field;
+  }
+  const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
+  if (aListEntries.IsEmpty())  {
+    //SetErrorCode( "Error: No fields on the shape at all" );
+    return field;
+  }
+
+  char entry[200], *pentry = entry; // the entry can't be too long
+  TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+  for (; anIt.More(); anIt.Next()) {
+    TCollection_ExtendedString& anEntry = anIt.Value();
+    anEntry.ToUTF8CString( (Standard_PCharacter&) pentry );
+    field = Handle(GEOM_Field)::DownCast( GetEngine()->GetObject( GetDocID(), entry, false ));
+    if ( !field.IsNull() && field->GetName() == theName ) {
+      SetErrorCode(OK);
+      break;
+    }
+  }
+
+  return field;
+}
diff --git a/src/GEOMImpl/GEOMImpl_IFieldOperations.hxx b/src/GEOMImpl/GEOMImpl_IFieldOperations.hxx
new file mode 100644 (file)
index 0000000..aaf36c4
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOMImpl_IFieldOperations_HXX_
+#define _GEOMImpl_IFieldOperations_HXX_
+
+#include "GEOM_IOperations.hxx"
+
+#include <TColStd_HSequenceOfTransient.hxx>
+
+class Handle(GEOM_Field);
+class Handle(GEOM_Object);
+class Handle(TColStd_HArray1OfExtendedString);
+
+class GEOMImpl_IFieldOperations : public GEOM_IOperations {
+ public:
+  Standard_EXPORT GEOMImpl_IFieldOperations(GEOM_Engine* theEngine, int theDocID);
+  Standard_EXPORT ~GEOMImpl_IFieldOperations();
+
+  Standard_EXPORT Handle(GEOM_Field)
+    CreateField ( const Handle(GEOM_Object)&                     theShape,
+                  const char*                                    theName,
+                  const int                                      theType,
+                  const int                                      theDimension,
+                  const Handle(TColStd_HArray1OfExtendedString)& theComponentNames);
+  /*!
+   *  \brief Returns number of fields on a shape
+   */
+  Standard_EXPORT int CountFields( const Handle(GEOM_Object)& shape);
+
+  /*!
+   *  \brief Returns all fields on a shape
+   */
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
+    GetFields( const Handle(GEOM_Object)& shape );
+
+  /*!
+   *  \brief Returns a field on a shape by its name
+   */
+  Standard_EXPORT Handle(GEOM_Field) GetField( const Handle(GEOM_Object)& shape,
+                                               const char*                name);
+};
+
+#endif
index b5dceb10ccb615d4c55b4830122eb2490f665cb4..5deb08ba2451946cd6d50f7620abf97c38fc3aff 100644 (file)
@@ -83,7 +83,7 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
 
   if ( theShapeType != TopAbs_VERTEX && theShapeType != TopAbs_EDGE &&
        theShapeType != TopAbs_FACE && theShapeType != TopAbs_SOLID ) {
-    SetErrorCode( "Error: You could create group only next type: vertex, edge, face or solid" );
+    SetErrorCode( "Error: You could create group of only next type: vertex, edge, face or solid" );
     return NULL;
   }
 
index 267e6e3169a9269b32b113384d7cd12fc756db24..062fe23a0c0271c7401e35fdb5b7eac91710342a 100644 (file)
@@ -1179,8 +1179,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubO
     Standard_Integer aStrLen = anEntry.LengthOfCString();
     char* anEntryStr = new char[aStrLen+1];
     anEntry.ToUTF8CString(anEntryStr);
-    Handle(GEOM_Object) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false);
-    if (!anObj.IsNull()) {
+    Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false);
+    if (!anObj.IsNull() && anObj->IsKind(STANDARD_TYPE(GEOM_Object))) {
       if (!theGroupsOnly || anObj->GetType() == GEOM_GROUP) {
         aSeq->Append(anObj);
 
index d4884912b61e512a6a62855e27e5d1b1b6c78a72..554c864013e49678833bed9ecafb721260315b1b 100755 (executable)
 #define GEOM_FILLET_2D 50
 #define GEOM_FILLET_1D 51
 
+#define GEOM_FIELD      52  // == GEOM_FIELD_OBJTYPE constant
+#define GEOM_FIELD_STEP 53  // == GEOM_FIELD_STEP_OBJTYPE constant
+
 //GEOM_Function types
 
 #define COPY_WITH_REF    1
index 777b479c97170ae06015afb24bb3d8ac3310220d..f774f30001ea31ff198cfb2d80409856f6de2818 100644 (file)
@@ -198,7 +198,7 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
     return false;
 
   // collect all GEOM objects being deleted
-  QMap<QString, GEOM::GEOM_Object_var> gobjects;
+  QMap<QString, GEOM::GEOM_BaseObject_var> gobjects;
   QMap<QString, QString>::ConstIterator oit;
   std::list<_PTR(SObject)> aSelectedSO;
   for ( oit = objects.begin(); oit != objects.end(); ++oit ) {
@@ -207,7 +207,7 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
       continue;
     aSelectedSO.push_back(so);
     CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
-    GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
+    GEOM::GEOM_BaseObject_var geomObj_rem = GEOM::GEOM_BaseObject::_narrow( corbaObj_rem );
     if( CORBA::is_nil( geomObj_rem ) )
       continue;
     gobjects.insert( oit.key(), geomObj_rem );
@@ -238,14 +238,14 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
     if( CORBA::is_nil( geomObj ) )
       continue;
 
-    GEOM::ListOfGO_var list = geomObj->GetDependency();
+    GEOM::ListOfGBO_var list = geomObj->GetDependency();
     if( list->length() == 0 )
       continue;
 
     for( int i = 0; i < list->length(); i++ ) {
       bool depends = false;
       bool deleted = false;
-      QMap<QString, GEOM::GEOM_Object_var>::Iterator git;
+      QMap<QString, GEOM::GEOM_BaseObject_var>::Iterator git;
       for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) {
         depends = depends || list[i]->_is_equivalent( *git );
         deleted = deleted || git.key() == child->GetID().c_str() ;//geomObj->_is_equivalent( *git );
@@ -262,8 +262,8 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
 // purpose  : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
 //=======================================================================
 static void getGeomChildrenAndFolders( _PTR(SObject) theSO, 
-                                      QMap<QString,QString>& geomObjList, 
-                                      QMap<QString,QString>& folderList ) {
+                                       QMap<QString,QString>& geomObjList, 
+                                       QMap<QString,QString>& folderList ) {
   if ( !theSO ) return;
   _PTR(Study) aStudy = theSO->GetStudy();
   if ( !aStudy ) return;
index 3f828e6d9ba198fa4ce2e48258e8f161c4a0e9d3..d3ebabcc20594517afeac3211fb275911b5e0149 100755 (executable)
@@ -75,7 +75,9 @@ SET(GEOMEngine_HEADERS
 # --- sources ---
 
 SET(GEOMEngine_SOURCES
+  GEOM_BaseObject_i.cc
   GEOM_Object_i.cc
+  GEOM_Field_i.cc
   GEOM_IOperations_i.cc
   GEOM_IBasicOperations_i.cc
   GEOM_IHealingOperations_i.cc
@@ -89,6 +91,7 @@ SET(GEOMEngine_SOURCES
   GEOM_ITransformOperations_i.cc
   GEOM_IMeasureOperations_i.cc
   GEOM_IGroupOperations_i.cc
+  GEOM_IFieldOperations_i.cc
   GEOM_Gen_i.cc
   GEOM_DumpPython.cc
   )
diff --git a/src/GEOM_I/GEOM_BaseObject_i.cc b/src/GEOM_I/GEOM_BaseObject_i.cc
new file mode 100644 (file)
index 0000000..5355805
--- /dev/null
@@ -0,0 +1,306 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_BaseObject_i.hh"
+
+#include "GEOMImpl_Types.hxx"
+#include "GEOM_BaseDriver.hxx"
+
+#include <utilities.h>
+//#include <OpUtil.hxx>
+//#include <Utils_ExceptHandlers.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_Tool.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+
+#ifdef _DEBUG_
+#include <typeinfo>
+#endif
+
+#ifdef WNT
+#pragma warning( disable:4786 )
+#endif
+
+//=============================================================================
+/*!
+ *   constructor:
+ */
+//=============================================================================
+
+GEOM_BaseObject_i::GEOM_BaseObject_i (PortableServer::POA_ptr thePOA,
+                                      GEOM::GEOM_Gen_ptr      theEngine,
+                                      Handle(GEOM_BaseObject) theImpl)
+  : SALOME::GenericObj_i( thePOA ), _engine(theEngine), _impl(theImpl)
+{
+}
+
+//=============================================================================
+/*!
+ *  destructor
+ */
+//=============================================================================
+
+GEOM_BaseObject_i::~GEOM_BaseObject_i()
+{
+  MESSAGE("GEOM_BaseObject_i::~GEOM_BaseObject_i");
+  GEOM_Engine::GetEngine()->RemoveObject(_impl);
+}
+
+//=============================================================================
+/*!
+ *  GetEntry
+ */
+//=============================================================================
+
+char* GEOM_BaseObject_i::GetEntry()
+{
+  const TDF_Label& aLabel = _impl->GetEntry();
+  TCollection_AsciiString anEntry;
+  TDF_Tool::Entry(aLabel, anEntry);
+  const char* anEntstr = anEntry.ToCString();
+  return CORBA::string_dup(anEntstr);
+}
+
+//=============================================================================
+/*!
+ *  GetStudyID
+ */
+//=============================================================================
+
+CORBA::Long GEOM_BaseObject_i::GetStudyID()
+{
+   return _impl->GetDocID();
+}
+
+//=============================================================================
+/*!
+ *  GetType
+ */
+//=============================================================================
+
+CORBA::Long GEOM_BaseObject_i::GetType()
+{
+  return _impl->GetType();
+}
+
+//=============================================================================
+/*!
+ *  SetName
+ */
+//=============================================================================
+void GEOM_BaseObject_i::SetName(const char* theName)
+{
+  _impl->SetName(theName);
+}
+
+//=============================================================================
+/*!
+ *  GetName
+ */
+//=============================================================================
+
+char* GEOM_BaseObject_i::GetName()
+{
+  TCollection_AsciiString aName = _impl->GetName();
+  return CORBA::string_dup( aName.ToCString() );
+}
+
+//=============================================================================
+/*!
+ *  SetStudyEntry
+ */
+//=============================================================================
+
+void GEOM_BaseObject_i::SetStudyEntry(const char* theEntry)
+{
+  _impl->SetAuxData(theEntry);
+}
+
+//=============================================================================
+/*!
+ *  GetStudyEntry
+ */
+//=============================================================================
+
+char* GEOM_BaseObject_i::GetStudyEntry()
+{
+  TCollection_AsciiString anEntry = _impl->GetAuxData();
+  return CORBA::string_dup(anEntry.ToCString());
+}
+
+//=============================================================================
+/*!
+ *  GetDependency
+ */
+//=============================================================================
+GEOM::ListOfGBO* GEOM_BaseObject_i::GetDependency()
+{
+  GEOM::ListOfGBO_var aList = new GEOM::ListOfGBO();
+  aList->length(0);
+
+  Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllDependency();
+  if (aSeq.IsNull()) return aList._retn();
+  int aLength = aSeq->Length();
+  if (aLength == 0) return aList._retn();
+
+  aList->length(aLength);
+
+  TCollection_AsciiString anEntry;
+
+  for (int i = 1; i<=aLength; i++) {
+    Handle(GEOM_BaseObject) anObj = Handle(GEOM_BaseObject)::DownCast(aSeq->Value(i));
+    if (anObj.IsNull()) continue;
+    TDF_Tool::Entry(anObj->GetEntry(), anEntry);
+    GEOM::GEOM_BaseObject_var obj = _engine->GetObject(anObj->GetDocID(), (char*) anEntry.ToCString());
+    aList[i-1] = obj;
+  }
+
+  return aList._retn();
+}
+
+//=============================================================================
+/*!
+ * GetLastDependency
+ */
+//=============================================================================
+GEOM::ListOfGBO* GEOM_BaseObject_i::GetLastDependency()
+{
+  GEOM::ListOfGBO_var aList = new GEOM::ListOfGBO();
+  aList->length(0);
+
+  Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetLastDependency();
+  if (aSeq.IsNull()) return aList._retn();
+  int aLength = aSeq->Length();
+  if (aLength == 0) return aList._retn();
+
+  aList->length(aLength);
+
+  TCollection_AsciiString anEntry;
+
+  for (int i = 1; i<=aLength; i++) {
+     Handle(GEOM_BaseObject) anObj = Handle(GEOM_BaseObject)::DownCast(aSeq->Value(i));
+     if (anObj.IsNull()) continue;
+     GEOM::GEOM_BaseObject_var obj = _engine->GetObject(anObj->GetDocID(),
+                                                        anObj->GetEntryString().ToCString());
+     aList[i-1] = GEOM::GEOM_BaseObject::_duplicate( obj );
+  }
+
+  return aList._retn();
+}
+
+//================================================================================
+/*!
+ * \brief 
+ */
+//================================================================================
+
+bool GEOM_BaseObject_i::IsSame(GEOM::GEOM_BaseObject_ptr other)
+{
+  if ( CORBA::is_nil( other ))
+    return false;
+
+  PortableServer::Servant aServant = myPOA->reference_to_servant( other );
+  GEOM_BaseObject_i * other_i = dynamic_cast<GEOM_BaseObject_i*>(aServant);
+  if ( !other_i )
+    return false;
+
+  return _impl->GetEntry() == other_i->_impl->GetEntry();
+}
+
+//================================================================================
+/*!
+ * \brief 
+ */
+//================================================================================
+
+void GEOM_BaseObject_i::SetParameters(const char* theParameters)
+{
+  _impl->SetParameters((char*)theParameters);
+}
+
+//================================================================================
+/*!
+ * \brief 
+ */
+//================================================================================
+
+char* GEOM_BaseObject_i::GetParameters()
+{
+  return CORBA::string_dup(_impl->GetParameters().ToCString());
+}
+
+//================================================================================
+/*!
+ * \brief 
+ */
+//================================================================================
+
+GEOM::CreationInformation* GEOM_BaseObject_i::GetCreationInformation()
+{
+  GEOM::CreationInformation_var info = new GEOM::CreationInformation;
+
+  Handle(GEOM_BaseDriver) driver =
+    Handle(GEOM_BaseDriver)::DownCast( _impl->GetCreationDriver() );
+  if ( !driver.IsNull() )
+  {
+    std::vector<GEOM_Param> params;
+    std::string             operationName;
+    try
+    {
+      OCC_CATCH_SIGNALS;
+      if ( driver->GetCreationInformation( operationName, params ))
+      {
+        info->operationName = operationName.c_str();
+        info->params.length( params.size() );
+        for ( size_t i = 0; i < params.size(); ++i )
+        {
+          info->params[i].name  = params[i].name.c_str();
+          info->params[i].value = params[i].value.c_str();
+        }
+      }
+#ifdef _DEBUG_
+      if ( operationName.empty() )
+      {
+        cout << endl << endl << endl << "Warning: " << endl << "Dear developer!!!" << endl
+             << "  Consider implementing "
+             <<    typeid(*(driver.operator->())).name() << "::GetCreationInformation() " << endl
+             << "  for the case of operation which has created '" << GetName() << "' object" << endl
+             << "PLEEEEEEEASE" << endl
+             << "\tPLEEEEEEEASE" << endl
+             << "\t\tPLEEEEEEEASE" << endl
+             << "\t\t\tPLEEEEEEEASE" << endl
+             << "\t\t\t\tPLEEEEEEEASE" << endl;
+      }
+#endif
+    }
+    catch(...)
+    {
+#ifdef _DEBUG_
+      cout << "Ecxeption in GEOM_BaseObject_i::GetCreationInformation()" << endl;
+#endif
+    }
+  }
+  return info._retn();
+}
diff --git a/src/GEOM_I/GEOM_BaseObject_i.hh b/src/GEOM_I/GEOM_BaseObject_i.hh
new file mode 100644 (file)
index 0000000..e9bdd5d
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOM_BaseObject_i_HeaderFile
+#define _GEOM_BaseObject_i_HeaderFile
+
+#include "GEOM_GEOM_I.hxx"
+
+#include "GEOMImpl_Gen.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include "SALOME_GenericObj_i.hh"
+
+#include "GEOM_BaseObject.hxx"
+
+class GEOM_I_EXPORT GEOM_BaseObject_i : public virtual POA_GEOM::GEOM_BaseObject, public virtual SALOME::GenericObj_i
+{
+ public:
+  GEOM_BaseObject_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_BaseObject) theImpl);
+  ~GEOM_BaseObject_i();
+
+  virtual char* GetEntry();
+
+  virtual CORBA::Long GetStudyID();
+
+  virtual CORBA::Long GetType();
+
+  virtual void SetName(const char* theName);
+
+  virtual char* GetName();
+
+  virtual void SetStudyEntry(const char* theEntry);
+
+  virtual char* GetStudyEntry();
+
+  virtual GEOM::ListOfGBO* GetDependency();
+
+  virtual GEOM::ListOfGBO* GetLastDependency();
+
+  virtual bool IsSame(GEOM::GEOM_BaseObject_ptr other);
+
+  virtual void SetParameters(const char* theParameters);
+
+  virtual char* GetParameters();
+
+  virtual GEOM::CreationInformation* GetCreationInformation();
+
+  Handle(GEOM_BaseObject) GetImpl() { return _impl; }
+
+ protected:
+
+  GEOM::GEOM_Gen_var      _engine;
+
+ private:
+
+  Handle(GEOM_BaseObject) _impl;
+};
+
+#endif
index 4e982647a4fe42268b8eedf22217dc675e6c5a59..627466690475af7e529f1dde3941825414cd678b 100644 (file)
@@ -107,7 +107,7 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
     CORBA::String_var IOR = aValue->GetIOR();
     if(strlen(IOR.in()) > 0) {
       CORBA::Object_var obj = _orb->string_to_object(IOR);
-      GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_narrow(obj);
+      GEOM::GEOM_BaseObject_var GO = GEOM::GEOM_BaseObject::_narrow(obj);
       if(!CORBA::is_nil(GO)) {
         CORBA::String_var aName       = aValue->GetName();
         CORBA::String_var anEntry     = GO->GetEntry();
@@ -185,7 +185,6 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
     }
 
     TCollection_AsciiString aDirScript, aNodeName, aNodeEntry, aFatherName, aFatherEntry;
-    aDirScript += "\n\t### Folders and it's content\n";
     Resource_DataMapOfAsciiStringAsciiString aNameToEntry;
     SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder();
     SALOMEDS::UseCaseIterator_var Itr = useCaseBuilder->GetUseCaseIterator(aSO);
@@ -237,8 +236,11 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
        aDirScript += ")\n";
       }
     }
-    aScript += aDirScript;
-  
+    if ( !aDirScript.IsEmpty() )
+    {
+      aScript += "\n\t### Folders and it's content\n";
+      aScript += aDirScript;
+    }
     //Output the script that sets up the visual parameters.
     char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t");
     if (script && strlen(script) > 0) {
diff --git a/src/GEOM_I/GEOM_Field_i.cc b/src/GEOM_I/GEOM_Field_i.cc
new file mode 100644 (file)
index 0000000..7896301
--- /dev/null
@@ -0,0 +1,511 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_Field_i.hh"
+
+#include <utilities.h>
+
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+#ifdef WNT
+#pragma warning( disable:4786 )
+#endif
+
+//=============================================================================
+/*!
+ *   constructor:
+ */
+//=============================================================================
+
+GEOM_Field_i::GEOM_Field_i (PortableServer::POA_ptr thePOA,
+                            GEOM::GEOM_Gen_ptr      theEngine,
+                            Handle(GEOM_Field)      theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  _impl( theImpl )
+{
+}
+
+//=============================================================================
+/*!
+ *  destructor
+ */
+//=============================================================================
+
+GEOM_Field_i::~GEOM_Field_i()
+{
+  MESSAGE("GEOM_Field_i::~GEOM_Field_i");
+  GEOM_Engine::GetEngine()->RemoveObject(_impl);
+}
+
+//================================================================================
+/*!
+ * \brief Returns the shape the field lies on
+ */
+//================================================================================
+
+GEOM::GEOM_Object_ptr GEOM_Field_i::GetShape()
+{
+  GEOM::GEOM_Object_var shapeVar;
+  Handle(GEOM_Object) shape = _impl->GetShape();
+  if ( !shape.IsNull() )
+  {
+    GEOM::GEOM_BaseObject_var obj = _engine->GetObject( shape->GetDocID(),
+                                                        shape->GetEntryString().ToCString());
+    shapeVar = GEOM::GEOM_Object::_narrow( obj );
+  }
+  return shapeVar._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Returns type of field data
+ */
+//================================================================================
+
+GEOM::field_data_type GEOM_Field_i::GetDataType()
+{
+  return GEOM::field_data_type( _impl->GetDataType() );
+}
+
+//================================================================================
+/*!
+ * \brief Returns dimension of the shape the field lies on
+ *  0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+ */
+//================================================================================
+
+CORBA::Short GEOM_Field_i::GetDimension()
+{
+  return CORBA::Short( _impl->GetDimension() );
+}
+
+//================================================================================
+/*!
+ * \brief Returns names of components
+ */
+//================================================================================
+
+GEOM::string_array* GEOM_Field_i::GetComponents()
+{
+  GEOM::string_array_var compArr = new GEOM::string_array;
+  Handle(TColStd_HArray1OfExtendedString) comps = _impl->GetComponents();
+  if ( !comps.IsNull() )
+  {
+    compArr->length( comps->Length() );
+    std::string entry;
+    int i, i0, nb; 
+    for ( i = i0 = comps->Lower(), nb = comps->Upper(); i <= nb; ++i )
+    {
+      const TCollection_ExtendedString& anEntry = comps->Value( i );
+      entry.resize( anEntry.LengthOfCString() );
+      char* pstr = &entry[0];
+      anEntry.ToUTF8CString( pstr );
+      compArr[ i-i0 ] = CORBA::string_dup( entry.c_str() );
+    }
+  }
+  return compArr._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Adds a time step to the field
+ */
+//================================================================================
+
+GEOM::GEOM_FieldStep_ptr GEOM_Field_i::AddStep(::CORBA::Long stepID, ::CORBA::Long stamp)
+{
+  GEOM::GEOM_FieldStep_var stepVar;
+  Handle(GEOM_FieldStep) step = _impl->AddStep( stepID, stamp );
+  if ( !step.IsNull() )
+  {
+    GEOM::GEOM_BaseObject_var obj = _engine->GetObject( step->GetDocID(),
+                                                        step->GetEntryString().ToCString());
+    stepVar = GEOM::GEOM_FieldStep::_narrow( obj );
+  }
+  return stepVar._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Remove a time step from the field
+ */
+//================================================================================
+
+void GEOM_Field_i::RemoveStep(::CORBA::Long stepID)
+{
+  _impl->RemoveStep( stepID );
+}
+
+//================================================================================
+/*!
+ * \brief Returns number of time steps in the field
+ */
+//================================================================================
+
+CORBA::Long GEOM_Field_i::CountSteps()
+{
+  return (CORBA::Long) _impl->GetSteps().size();
+}
+
+//================================================================================
+/*!
+ * \brief Returns a list of time step IDs in the field
+ */
+//================================================================================
+
+GEOM::ListOfLong* GEOM_Field_i::GetSteps()
+{
+  std::list< Handle(GEOM_FieldStep)> stepList = _impl->GetSteps();
+  std::list< Handle(GEOM_FieldStep)>::iterator stp = stepList.begin();
+  
+  GEOM::ListOfLong_var stepIds = new GEOM::ListOfLong();
+  stepIds->length( stepList.size() );
+  int nbS = 0;
+  for ( ; stp != stepList.end(); ++stp )
+    if ( !stp->IsNull() )
+      stepIds[ nbS++ ] = (*stp)->GetID();
+
+  stepIds->length( nbS );
+  return stepIds._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Returns a time step by its ID
+ */
+//================================================================================
+
+GEOM::GEOM_FieldStep_ptr GEOM_Field_i::GetStep(CORBA::Long stepID)
+{
+  GEOM::GEOM_FieldStep_var stepVar;
+  Handle(GEOM_FieldStep) step = _impl->GetStep(stepID);
+  if ( !step.IsNull() )
+  {
+    GEOM::GEOM_BaseObject_var obj = _engine->GetObject( step->GetDocID(),
+                                                        step->GetEntryString().ToCString());
+    stepVar = GEOM::GEOM_FieldStep::_narrow( obj );
+  }
+  return stepVar._retn();
+}
+
+//================================================================================
+/*!
+ *  \brief Returns a size of data array that is to be passed to
+ *         GEOM_FieldStep.SetValues( dataArray ). This size depends on the
+ *         number of sub-shapes of field dimension and the number of components
+ */
+//================================================================================
+
+CORBA::Long GEOM_Field_i::GetArraySize()
+{
+  return (CORBA::Long) _impl->GetArrayLength();
+}
+
+//================================================================================
+/*!
+ * \brief Constructor of base step class
+ */
+//================================================================================
+
+GEOM_FieldStep_i::GEOM_FieldStep_i(PortableServer::POA_ptr  thePOA,
+                                   GEOM::GEOM_Gen_ptr       theEngine,
+                                   Handle(GEOM_FieldStep)   theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  _impl( theImpl )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+
+GEOM_FieldStep_i::~GEOM_FieldStep_i()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Changes the stamp of the field step
+ */
+//================================================================================
+
+void GEOM_FieldStep_i::SetStamp(::CORBA::Long stamp)
+{
+  _impl->SetStamp( stamp );
+}
+
+//================================================================================
+/*!
+ * \brief Returns the time of the field step
+ */
+//================================================================================
+
+::CORBA::Long GEOM_FieldStep_i::GetStamp()
+{
+  return (CORBA::Long) _impl->GetStamp();
+}
+
+//================================================================================
+/*!
+ * \brief Returns the number of the field step
+ */
+//================================================================================
+
+::CORBA::Long GEOM_FieldStep_i::GetID()
+{
+  return (CORBA::Long) _impl->GetID();
+}
+
+//================================================================================
+/*!
+ * \brief Returns the field the step belongs to
+ */
+//================================================================================
+
+GEOM::GEOM_Field_ptr GEOM_FieldStep_i::GetField()
+{
+  GEOM::GEOM_Field_var fieldVar;
+  Handle(GEOM_Field) field = _impl->GetField();
+  if ( !field.IsNull() )
+  {
+    GEOM::GEOM_BaseObject_var obj = _engine->GetObject( field->GetDocID(),
+                                                        field->GetEntryString().ToCString());
+    fieldVar = GEOM::GEOM_Field::_narrow( obj );
+  }
+  return fieldVar._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Constructor of GEOM_BoolFieldStep_i
+ */
+//================================================================================
+
+GEOM_BoolFieldStep_i::GEOM_BoolFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  GEOM_FieldStep_i( thePOA, theEngine, theImpl )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Changes values of the field step. Returns false if number of values is wrong
+ */
+//================================================================================
+
+::CORBA::Boolean GEOM_BoolFieldStep_i::SetValues(const ::GEOM::short_array& boolValues)
+{
+  Handle(TColStd_HArray1OfInteger) values =
+    new TColStd_HArray1OfInteger( 0, boolValues.length()-1 );
+  for ( size_t i = 0; i < boolValues.length(); ++ i )
+    values->SetValue( i, boolValues[i] );
+
+  return _impl->SetValues( values );
+}
+
+//================================================================================
+/*!
+ * \brief Returns values of the field step
+ */
+//================================================================================
+
+GEOM::short_array* GEOM_BoolFieldStep_i::GetValues()
+{
+  GEOM::short_array_var resArray = new GEOM::short_array;
+
+  Handle(TColStd_HArray1OfInteger) values = GEOM_FieldStep_i::_impl->GetIntValues();
+  if ( !values.IsNull() )
+  {
+    resArray->length( values->Length() );
+    int i, i0, nb; 
+    for ( i = i0 = values->Lower(), nb = values->Upper(); i <= nb; ++i )
+      resArray[ i-i0 ] = values->Value( i );
+  }
+  return resArray._retn();
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor of GEOM_IntFieldStep_i
+ */
+//================================================================================
+
+GEOM_IntFieldStep_i::GEOM_IntFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  GEOM_FieldStep_i( thePOA, theEngine, theImpl )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Changes values of the field step. Returns false if number of values is wrong
+ */
+//================================================================================
+
+::CORBA::Boolean GEOM_IntFieldStep_i::SetValues(const ::GEOM::ListOfLong& intValues)
+{
+  Handle(TColStd_HArray1OfInteger) values =
+    new TColStd_HArray1OfInteger( 0, intValues.length()-1 );
+  for ( size_t i = 0; i < intValues.length(); ++ i )
+    values->SetValue( i, intValues[i] );
+
+  return _impl->SetValues( values );
+}
+
+//================================================================================
+/*!
+ * \brief Returns values of the field step
+ */
+//================================================================================
+
+GEOM::ListOfLong* GEOM_IntFieldStep_i::GetValues()
+{
+  GEOM::ListOfLong_var resArray = new GEOM::ListOfLong;
+
+  Handle(TColStd_HArray1OfInteger) values = GEOM_FieldStep_i::_impl->GetIntValues();
+  if ( !values.IsNull() )
+  {
+    resArray->length( values->Length() );
+    int i, i0, nb; 
+    for ( i = i0 = values->Lower(), nb = values->Upper(); i <= nb; ++i )
+      resArray[ i-i0 ] = values->Value( i );
+  }
+  return resArray._retn();
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor of GEOM_DoubleFieldStep_i
+ */
+//================================================================================
+
+GEOM_DoubleFieldStep_i::GEOM_DoubleFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  GEOM_FieldStep_i( thePOA, theEngine, theImpl )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Changes values of the field step. Returns false if number of values is wrong
+ */
+//================================================================================
+
+::CORBA::Boolean GEOM_DoubleFieldStep_i::SetValues(const ::GEOM::ListOfDouble& dblValues)
+{
+  Handle(TColStd_HArray1OfReal) values =
+    new TColStd_HArray1OfReal( 0, dblValues.length()-1 );
+  for ( size_t i = 0; i < dblValues.length(); ++ i )
+    values->SetValue( i, dblValues[i] );
+
+  return _impl->SetValues( values );
+}
+
+//================================================================================
+/*!
+ * \brief Returns values of the field step
+ */
+//================================================================================
+
+GEOM::ListOfDouble* GEOM_DoubleFieldStep_i::GetValues()
+{
+  GEOM::ListOfDouble_var resArray = new GEOM::ListOfDouble;
+
+  Handle(TColStd_HArray1OfReal) values = GEOM_FieldStep_i::_impl->GetDoubleValues();
+  if ( !values.IsNull() )
+  {
+    resArray->length( values->Length() );
+    int i, i0, nb; 
+    for ( i = i0 = values->Lower(), nb = values->Upper(); i <= nb; ++i )
+      resArray[ i-i0 ] = values->Value( i );
+  }
+  return resArray._retn();
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor of GEOM_StringFieldStep_i
+ */
+//================================================================================
+
+GEOM_StringFieldStep_i::GEOM_StringFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl):
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  GEOM_FieldStep_i( thePOA, theEngine, theImpl )
+{
+}
+
+//================================================================================
+/*!
+ * \brief Changes values of the field step. Returns false if number of values is wrong
+ */
+//================================================================================
+
+::CORBA::Boolean GEOM_StringFieldStep_i::SetValues(const ::GEOM::string_array& strValues)
+{
+  Handle(TColStd_HArray1OfExtendedString) values =
+    new TColStd_HArray1OfExtendedString( 0, strValues.length()-1 );
+  for ( size_t i = 0; i < strValues.length(); ++ i )
+    values->SetValue( i, strValues[i].in() );
+
+  return _impl->SetValues( values );
+}
+
+//================================================================================
+/*!
+ * \brief Returns values of the field step
+ */
+//================================================================================
+
+GEOM::string_array* GEOM_StringFieldStep_i::GetValues()
+{
+  GEOM::string_array_var resArray = new GEOM::string_array;
+
+  Handle(TColStd_HArray1OfExtendedString) values = GEOM_FieldStep_i::_impl->GetStringValues();
+  if ( !values.IsNull() )
+  {
+    resArray->length( values->Length() );
+    std::string entry;
+    int i, i0, nb; 
+    for ( i = i0 = values->Lower(), nb = values->Upper(); i <= nb; ++i )
+    {
+      const TCollection_ExtendedString& anEntry = values->Value( i );
+      entry.resize( anEntry.LengthOfCString() );
+      char* pstr = &entry[0];
+      anEntry.ToUTF8CString( pstr );
+      resArray[ i-i0 ] = CORBA::string_dup( entry.c_str() );
+    }
+  }
+  return resArray._retn();
+}
+
diff --git a/src/GEOM_I/GEOM_Field_i.hh b/src/GEOM_I/GEOM_Field_i.hh
new file mode 100644 (file)
index 0000000..d896b4e
--- /dev/null
@@ -0,0 +1,135 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOM_Field_i_HeaderFile
+#define _GEOM_Field_i_HeaderFile
+
+#include "GEOMImpl_Gen.hxx"
+#include "GEOM_BaseObject_i.hh"
+#include "GEOM_Field.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include <TopoDS_Shape.hxx>
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_Field interface
+ */
+class GEOM_I_EXPORT GEOM_Field_i : public virtual POA_GEOM::GEOM_Field, public virtual GEOM_BaseObject_i
+{
+ public:
+  GEOM_Field_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_Field) theImpl);
+  ~GEOM_Field_i();
+
+  virtual GEOM::GEOM_Object_ptr GetShape();
+  virtual GEOM::field_data_type GetDataType();
+  virtual CORBA::Short GetDimension();
+  virtual GEOM::string_array* GetComponents();
+  virtual GEOM::GEOM_FieldStep_ptr AddStep(::CORBA::Long stepID, ::CORBA::Long stamp);
+  virtual void RemoveStep(::CORBA::Long stepID);
+  virtual CORBA::Long CountSteps();
+  virtual GEOM::ListOfLong* GetSteps();
+  virtual GEOM::GEOM_FieldStep_ptr GetStep(CORBA::Long stepID);
+  virtual ::CORBA::Boolean IsShape() { return false; }
+  virtual CORBA::Long GetArraySize();
+
+ private:
+
+  Handle(GEOM_Field) _impl;
+};
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_FieldStep interface
+ */
+class GEOM_I_EXPORT GEOM_FieldStep_i : public virtual POA_GEOM::GEOM_FieldStep, public virtual GEOM_BaseObject_i
+{
+ public:
+  GEOM_FieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl);
+  ~GEOM_FieldStep_i();
+
+  virtual void SetStamp(::CORBA::Long stamp);
+  virtual ::CORBA::Long GetStamp();
+  virtual ::CORBA::Long GetID();
+  virtual GEOM::GEOM_Field_ptr GetField();
+  virtual ::CORBA::Boolean IsShape() { return false; }
+
+ protected:
+
+  Handle(GEOM_FieldStep) _impl;
+};
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_BoolFieldStep interface
+ */
+class GEOM_I_EXPORT GEOM_BoolFieldStep_i : public virtual POA_GEOM::GEOM_BoolFieldStep, public virtual GEOM_FieldStep_i
+{
+ public:
+  GEOM_BoolFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl);
+
+  virtual ::CORBA::Boolean SetValues(const ::GEOM::short_array& boolValues);
+  virtual GEOM::short_array* GetValues();
+};
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_IntFieldStep interface
+ */
+class GEOM_I_EXPORT GEOM_IntFieldStep_i : public virtual POA_GEOM::GEOM_IntFieldStep, public virtual GEOM_FieldStep_i
+{
+ public:
+  GEOM_IntFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl);
+
+  virtual ::CORBA::Boolean SetValues(const ::GEOM::ListOfLong& intValues);
+  virtual GEOM::ListOfLong* GetValues();
+};
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_DoubleFieldStep interface
+ */
+class GEOM_I_EXPORT GEOM_DoubleFieldStep_i : public virtual POA_GEOM::GEOM_DoubleFieldStep, public virtual GEOM_FieldStep_i
+{
+ public:
+  GEOM_DoubleFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl);
+
+  virtual ::CORBA::Boolean SetValues(const ::GEOM::ListOfDouble& doubleValues);
+  virtual GEOM::ListOfDouble* GetValues();
+};
+
+//================================================================================
+/*!
+ * \brief Class implementing GEOM::GEOM_StringFieldStep interface
+ */
+class GEOM_I_EXPORT GEOM_StringFieldStep_i : public virtual POA_GEOM::GEOM_StringFieldStep, public virtual GEOM_FieldStep_i
+{
+ public:
+  GEOM_StringFieldStep_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_FieldStep) theImpl);
+
+  virtual ::CORBA::Boolean SetValues(const ::GEOM::string_array& strValues);
+  virtual GEOM::string_array* GetValues();
+};
+
+#endif
index 001a989a57d7702cff582230b16a1ff268b42c2e..2f2fc0b37fe161ebd47cdbeb0d4c85e301c68488 100644 (file)
 
 #include "GEOM_Gen_i.hh"
 #include "GEOM_Object_i.hh"
+#include "GEOM_Field_i.hh"
 #include "GEOM_version.h"
 
-#include <set>
-#include <sstream>
-
 #include "Utils_CorbaException.hxx"
 #include "OpUtil.hxx"
 #include "Utils_ExceptHandlers.hxx"
 #include "GEOM_Object.hxx"
 #include "GEOM_Function.hxx"
 #include "GEOM_ISubShape.hxx"
-#include <GEOM_PythonDump.hxx>
+#include "GEOM_PythonDump.hxx"
 #include "GEOMImpl_Types.hxx"
 #include "GEOMImpl_CopyDriver.hxx"
+#include "GEOM_wrap.hxx"
 
 // Cascade headers
 #include <BRep_Builder.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
 #include <TopAbs_ShapeEnum.hxx>
-//#include <TopTools_IndexedMapOfShape.hxx>
 #include <TopExp.hxx>
 #include <OSD.hxx>
 
 #include <SALOMEDS_Tool.hxx>
 #include <SALOMEDS_wrap.hxx>
 
+#include <set>
+#include <sstream>
+
 #ifdef WNT
  #include <windows.h>
  #include <process.h>
@@ -137,7 +138,8 @@ char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
                                          CORBA::Boolean isMultiFile,
                                          CORBA::Boolean isASCII)
 {
-  GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(IORString));
+  GEOM::GEOM_BaseObject_var anObject =
+    GEOM::GEOM_BaseObject::_narrow(_orb->string_to_object(IORString));
   if (!CORBA::is_nil(anObject)) {
     return CORBA::string_dup(anObject->GetEntry());
   }
@@ -158,13 +160,21 @@ char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
 
-  Handle(GEOM_Object) anObject = _impl->GetObject(aStudy->StudyId(), const_cast<char*>(aLocalPersistentID));
-  TCollection_AsciiString anEntry;
-  TDF_Tool::Entry(anObject->GetEntry(), anEntry);
-  GEOM::GEOM_Object_var obj = GetObject(anObject->GetDocID(), anEntry.ToCString());
+  Handle(GEOM_BaseObject) anObject =
+    _impl->GetObject(aStudy->StudyId(), aLocalPersistentID);
+  if ( !anObject.IsNull() )
+  {
+    TCollection_AsciiString anEntry;
+    TDF_Tool::Entry(anObject->GetEntry(), anEntry);
+    GEOM::GEOM_BaseObject_var obj = GetObject(anObject->GetDocID(), anEntry.ToCString());
 
-  CORBA::String_var aPersRefString = _orb->object_to_string(obj);
-  return CORBA::string_dup(aPersRefString);
+    CORBA::String_var aPersRefString = _orb->object_to_string(obj);
+    return CORBA::string_dup(aPersRefString);
+  }
+  else
+  {
+    return CORBA::string_dup("");
+  }
 }
 
 //============================================================================
@@ -182,16 +192,18 @@ bool GEOM_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
 // function : PublishInStudy
 // purpose  :
 //============================================================================
-SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
+SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr   theStudy,
                                                  SALOMEDS::SObject_ptr theSObject,
-                                                 CORBA::Object_ptr theObject,
-                                                 const char* theName) throw (SALOME::SALOME_Exception)
+                                                 CORBA::Object_ptr     theObject,
+                                                 const char*           theName)
+  throw (SALOME::SALOME_Exception)
 {
   Unexpect aCatch(SALOME_SalomeException);
   SALOMEDS::SObject_var aResultSO;
   if(CORBA::is_nil(theObject) || theStudy->_is_nil()) return aResultSO;
-  GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow(theObject);
-  if(aShape->_is_nil()) return aResultSO;
+  GEOM::GEOM_BaseObject_var aBaseObj = GEOM::GEOM_BaseObject::_narrow(theObject);
+  GEOM::GEOM_Object_var       aShape = GEOM::GEOM_Object::_narrow(theObject);
+  if(aBaseObj->_is_nil()) return aResultSO;
 
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::StudyBuilder_var     aStudyBuilder = theStudy->NewBuilder();
@@ -221,109 +233,132 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
   } else {
     if (!theSObject->ReferencedObject(aResultSO))
       aResultSO = SALOMEDS::SObject::_duplicate(theSObject); //SRN: Added Aug 24,2004 : for  the method AddInStudy with theFather argumenet != NULL
-      //THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM);
+    //THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM);
   }
   CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
   aResultSO->SetAttrString("AttributeIOR",aGeomObjIOR);
 
-  TCollection_AsciiString aShapeName("Shape_");
+  TCollection_AsciiString anObjectName("Shape_");
 
-  CORBA::Long mytype=aShape->GetType();
+  // BEGIN: try to find existed name for current shape
+  bool HasName = false;
+  if ( !aShape->_is_nil() )
+  {
+    // recieve current TopoDS shape
+    CORBA::String_var entry = aShape->GetEntry();
+    Handle(GEOM_Object) aGShape = Handle(GEOM_Object)::DownCast
+      ( _impl->GetObject( aShape->GetStudyID(), entry ));
+    TopoDS_Shape TopoSh = aGShape->GetValue();
+    // find label of main shape
+    GEOM::GEOM_Object_var aMainSh = aShape;
+    while( !aMainSh->IsMainShape() ) {
+      aMainSh = aMainSh->GetMainShape();
+    }
+    entry = aMainSh->GetEntry();
+    Handle(GEOM_BaseObject) anObj = _impl->GetObject( aMainSh->GetStudyID(), entry );
+    TDF_Label aMainLbl = anObj->GetFunction(1)->GetNamingEntry();
+
+    // check all named shapes using iterator
+    TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
+
+    for (; anIt.More() && !HasName; anIt.Next()) {
+      Handle(TNaming_NamedShape) anAttr =
+        Handle(TNaming_NamedShape)::DownCast(anIt.Value());
+      if (anAttr.IsNull()) continue;
+      TopoDS_Shape S = anAttr->Get();
+      if (S.IsEqual(TopoSh)) {
+        TDF_Label L = anAttr->Label();
+        Handle(TDataStd_Name) aName;
+        if (L.FindAttribute(TDataStd_Name::GetID(), aName)) {
+          anObjectName = aName->Get();
+          HasName = true;
+        }
+      }
+    }
+  }
+  // END: try to find existed name for current shape
+
+  CORBA::Long mytype=aBaseObj->GetType();
   if ( mytype == GEOM_GROUP ) {
     GEOM::GEOM_IGroupOperations_var anOp = GetIGroupOperations( theStudy->StudyId() );
-    switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape ) ) {
+    switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape )) {
     case TopAbs_VERTEX:
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_PNT" );
-      aShapeName = "Group_Of_Vertices_";
+      anObjectName = "Group_Of_Vertices_";
       break;
     case TopAbs_EDGE:
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_EDGE");
-      aShapeName = "Group_Of_Edges_";
+      anObjectName = "Group_Of_Edges_";
       break;
     case TopAbs_FACE:
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_FACE");
-      aShapeName = "Group_Of_Faces_";
+      anObjectName = "Group_Of_Faces_";
       break;
     case TopAbs_SOLID:
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_SOLID");
-      aShapeName = "Group_Of_Solids_";
+      anObjectName = "Group_Of_Solids_";
       break;
     }
   } else if ( mytype == GEOM_MARKER ) {
     aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS");
-    aShapeName = "LocalCS_";
+    anObjectName = "LocalCS_";
   } else if ( mytype > ADVANCED_BASE ) {
     char buf[20];
-    sprintf( buf, "%d", aShape->GetType() );
+    sprintf( buf, "%d", aBaseObj->GetType() );
     std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf;
     aResultSO->SetAttrString("AttributePixMap",advId.c_str());
-    aShapeName = "Advanced_";
-  } else {
+    anObjectName = "Advanced_";
+  } else if ( mytype == GEOM_FIELD ) {
+    anObjectName = "Field_";
+    GEOM::GEOM_Field_var aField = GEOM::GEOM_Field::_narrow(theObject);
+    if ( !aField->_is_nil() )
+      switch( aField->GetDimension() ) {
+      case 0:
+        aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_PNT" ); break;
+      case 1:
+        aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_EDGE"); break;
+      case 2:
+        aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_FACE"); break;
+      case 3:
+        aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_SOLID"); break;
+      default:
+        aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_SOLID");
+      }
+  } else if ( mytype == GEOM_FIELD_STEP ) {
+    anObjectName = "Step_";
+  } else if ( !aShape->_is_nil() ) {
     GEOM::shape_type myshapetype=aShape->GetShapeType();
     if ( myshapetype == GEOM::COMPOUND ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" );
-      aShapeName = "Compound_";
+      anObjectName = "Compound_";
     } else if ( myshapetype == GEOM::COMPSOLID ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID");
-      aShapeName = "Compsolid_";
+      anObjectName = "Compsolid_";
     } else if ( myshapetype == GEOM::SOLID ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID");
-      aShapeName = "Solid_";
+      anObjectName = "Solid_";
     } else if ( myshapetype == GEOM::SHELL ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL");
-      aShapeName = "Shell_";
+      anObjectName = "Shell_";
     } else if ( myshapetype == GEOM::FACE ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE");
-      aShapeName = "Face_";
+      anObjectName = "Face_";
     } else if ( myshapetype == GEOM::WIRE ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE");
-      aShapeName = "Wire_";
+      anObjectName = "Wire_";
     } else if ( myshapetype == GEOM::EDGE ) {
       aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE");
-      aShapeName = "Edge_";
+      anObjectName = "Edge_";
     } else if ( myshapetype == GEOM::VERTEX ) {
       aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" );
-      aShapeName = "Vertex_";
-    }
-  }
-  //if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
-  //else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName));
-
-  // BEGIN: try to find existed name for current shape
-  bool HasName = false;
-  // recieve current TopoDS shape
-  CORBA::String_var entry = aShape->GetEntry();
-  Handle(GEOM_Object) aGShape = _impl->GetObject(aShape->GetStudyID(), entry);
-  TopoDS_Shape TopoSh = aGShape->GetValue();
-  // find label of main shape
-  GEOM::GEOM_Object_var aMainSh = aShape;
-  while( !aMainSh->IsMainShape() ) {
-    aMainSh = aMainSh->GetMainShape();
-  }
-  entry = aMainSh->GetEntry();
-  Handle(GEOM_Object) anObj = _impl->GetObject(aMainSh->GetStudyID(), entry);
-  TDF_Label aMainLbl = anObj->GetFunction(1)->GetNamingEntry();
-
-  // check all named shapes using iterator
-  TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
-
-  for (; anIt.More() && !HasName; anIt.Next()) {
-    Handle(TNaming_NamedShape) anAttr =
-      Handle(TNaming_NamedShape)::DownCast(anIt.Value());
-    if (anAttr.IsNull()) continue;
-    TopoDS_Shape S = anAttr->Get();
-    if (S.IsEqual(TopoSh)) {
-      TDF_Label L = anAttr->Label();
-      Handle(TDataStd_Name) aName;
-      if (L.FindAttribute(TDataStd_Name::GetID(), aName)) {
-        aShapeName = aName->Get();
-        HasName = true;
-      }
+      anObjectName = "Vertex_";
     }
   }
-  // END: try to find existed name for current shape
+  if (!HasName)
+  {
+    //if (strlen(theName) == 0) anObjectName += TCollection_AsciiString(aResultSO->Tag());
+    //else anObjectName = TCollection_AsciiString(CORBA::string_dup(theName));
 
-  if (!HasName) {
     // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
     //       it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
     //       of objects in the study, but compute a number of objects with the same prefix
@@ -331,34 +366,34 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
     if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR
       int i = 0;                    // (WITH EMPTY NEW NAME)
       SALOMEDS::SObject_var obj;
-      TCollection_AsciiString aNewShapeName;
+      TCollection_AsciiString aNewObjectName;
       do {
-        aNewShapeName = aShapeName + TCollection_AsciiString(++i);
-        obj = theStudy->FindObject( aNewShapeName.ToCString() );
+        aNewObjectName = anObjectName + TCollection_AsciiString(++i);
+        obj = theStudy->FindObject( aNewObjectName.ToCString() );
       }
       while ( !obj->_is_nil() );
-      aShapeName = aNewShapeName;
+      anObjectName = aNewObjectName;
     }
     else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
-      aShapeName = TCollection_AsciiString((char*)theName);
+      anObjectName = theName;
   }
 
   //Set the study entry as a name of  the published GEOM_Object
-  CORBA::String_var anID =aResultSO->GetID();
-  aShape->SetStudyEntry(anID.in());
+  CORBA::String_var anID = aResultSO->GetID();
+  aBaseObj->SetStudyEntry(anID.in());
 
   //Set a name of the added shape
-  aResultSO->SetAttrString("AttributeName",aShapeName.ToCString());
+  aResultSO->SetAttrString("AttributeName",anObjectName.ToCString());
 
   //Set NoteBook variables used in the object creation
   TCollection_AsciiString aVars;
-  CORBA::String_var aString=aShape->GetParameters();
+  CORBA::String_var aString=aBaseObj->GetParameters();
   SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aString);
   for(int i = 0, n = aSections->length(); i < n; i++) {
     SALOMEDS::ListOfStrings aListOfVars = aSections[i];
     for(int j = 0, m = aListOfVars.length(); j < m; j++) {
       if(theStudy->IsVariable(aListOfVars[j].in()))
-        aVars += TCollection_AsciiString(aListOfVars[j].in());
+        aVars += aListOfVars[j].in();
       if(j != m-1)
         aVars += ":";
     }
@@ -370,7 +405,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
   aFather->UnRegister();
 
   //Set a name of the GEOM object
-  aShape->SetName(aShapeName.ToCString());
+  aBaseObj->SetName(anObjectName.ToCString());
 
   // add object to the use case tree
   // (to support tree representation customization and drag-n-drop)
@@ -379,7 +414,6 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
   return aResultSO._retn();
 }
 
-
 //============================================================================
 // function : CreateAndPublishGroup
 // purpose  : auxilary for PublishNamedShapesInStudy
@@ -393,16 +427,15 @@ void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
                                        GEOM::ListOfGO_var aResList)
 {
   CORBA::String_var entry = theMainShape->GetEntry();
-  Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+  //Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
   Handle(TColStd_HArray1OfInteger) anArray;
   if(SeqS.Length()>0) {
     // create a group
     GEOM::GEOM_IGroupOperations_var GOp = GetIGroupOperations(theStudy->StudyId());
-    GEOM::GEOM_Object_ptr GrObj =
-      GOp->CreateGroup( theMainShape, SeqS.Value(1).ShapeType() );
+    GEOM::GEOM_Object_wrap GrObj = GOp->CreateGroup( theMainShape, SeqS(1).ShapeType() );
     AddInStudy(theStudy, GrObj, GrName, theMainShape._retn());
-    CORBA::String_var GrEntry = GrObj->GetEntry();
-    Handle(GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
+    //CORBA::String_var GrEntry = GrObj->GetEntry();
+    //Handle(GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
     // add named objects
     //Handle(GEOM_Object) anObj;
     for(int i=1; i<=SeqS.Length(); i++) {
@@ -447,7 +480,8 @@ GEOM::ListOfGO* GEOM_Gen_i::
   if(theMainShape->_is_nil()) return aResList._retn();
 
   CORBA::String_var entry = theMainShape->GetEntry();
-  Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+  Handle(GEOM_Object) aMainShape = Handle(GEOM_Object)::DownCast
+    ( _impl->GetObject( theMainShape->GetStudyID(), entry ));
   if (aMainShape.IsNull()) return aResList._retn();
   TopoDS_Shape MainSh = aMainShape->GetValue();
 
@@ -738,7 +772,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
 
   TCollection_AsciiString anEntry;
   TDF_Tool::Entry(anObj->GetEntry(), anEntry);
-  GEOM::GEOM_Object_var obj = GetObject(anObj->GetDocID(), anEntry.ToCString());
+  GEOM::GEOM_BaseObject_var obj = GetObject(anObj->GetDocID(), anEntry.ToCString());
 
   //Set the study entry of the published GEOM_Object
   obj->SetStudyEntry(aNewSO->GetID());
@@ -767,10 +801,10 @@ char* GEOM_Gen_i::ComponentDataType()
 // function : AddInStudy
 // purpose  :
 //============================================================================
-SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
-                                              GEOM::GEOM_Object_ptr theObject,
-                                              const char* theName,
-                                              GEOM::GEOM_Object_ptr theFather)
+SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr       theStudy,
+                                              GEOM::GEOM_BaseObject_ptr theObject,
+                                              const char*               theName,
+                                              GEOM::GEOM_BaseObject_ptr theFather)
 {
   SALOMEDS::SObject_var aResultSO;
   if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
@@ -789,14 +823,14 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
   aResultSO = PublishInStudy(theStudy, aResultSO, theObject, theName);
   if(aResultSO->_is_nil()) return aResultSO._retn();
 
-  GEOM::ListOfGO_var aList = theObject->GetDependency();
+  GEOM::ListOfGBO_var aList = theObject->GetDependency();
   Standard_Integer aLength = aList->length();
   if(aLength < 1) return aResultSO._retn();
 
   //Publish the arguments
   TCollection_AsciiString aPrevID; // to avoid multiple references to same object
   for(Standard_Integer i = 0; i< aLength; i++) {
-    GEOM::GEOM_Object_var anObject = aList[i];
+    GEOM::GEOM_BaseObject_var anObject = aList[i];
     if(anObject->_is_nil()) continue;
     IOR = _orb->object_to_string(anObject);
     SALOMEDS::SObject_wrap aSO =  theStudy->FindObjectIOR(IOR.in());
@@ -969,8 +1003,11 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
   }
   else {
     // Get all arguments
-    aList = theObject->GetDependency();
-    aLength = aList->length();
+    GEOM::ListOfGBO_var boList = theObject->GetDependency();
+    aLength = boList->length();
+    aList = new GEOM::ListOfGO;
+    for (int i = 0; i < aLength; i++)
+      aList[i] = GEOM::GEOM_Object::_narrow( boList[i] );
     nbArgsActual = aLength;
   }
 
@@ -1043,7 +1080,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
             GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject);
             if (!CORBA::is_nil(anArgOTrsf)) {
               CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
-              Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+              Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
               Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
               anArgOTrsfFun->SetDescription("");
               aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
@@ -1238,7 +1275,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
   aResParts->length(nb);
   if (nb > 0)
   {
-    Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+    Handle(GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
     Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
     GEOM::TPythonDump pd (aFunction, true);
     pd <<"[";
@@ -1254,8 +1291,8 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
       anObjEntryMap.insert(anEntry);
       aResParts[nbRes++] = anObj;
       // clear python dump of object
-      Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
-      Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
+      Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
+      Handle(GEOM_Function)   anObjFun = aGeomObj->GetLastFunction();
       if ( !anObjFun.IsNull() )
         anObjFun->SetDescription( "" );
       if ( j > 0 )
@@ -1272,7 +1309,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
       GEOM::GEOM_Object_var anObj = anOutArgs[ i ];
       if (CORBA::is_nil(anObj))
         continue;
-      Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
+      Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
       if ( j > 0 )
         pd << ", ";
       pd << aGeomObj;
@@ -1364,7 +1401,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     th
             GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO);
             if (!CORBA::is_nil(anArgOTrsf)) {
               CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
-              Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+              Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
               Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
               anArgOTrsfFun->SetDescription("");
               aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
@@ -1544,8 +1581,8 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
     return aParts._retn();
 
   // Get all arguments
-  GEOM::ListOfGO_var anOpArgsList = theObject->GetDependency();
-  Standard_Integer nbArgsActual = anOpArgsList->length();
+  GEOM::ListOfGBO_var anOpArgsList = theObject->GetDependency();
+  Standard_Integer    nbArgsActual = anOpArgsList->length();
 
   // If anOpArgsList list is empty, nothing to do
   if (nbArgsActual == 0)
@@ -1567,7 +1604,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
   for (int j = 0; j < nbArgsActual; j++) {
     CORBA::String_var anEntry = anOpArgsList[j]->GetEntry();
     if (anArgs.count(anEntry.in())) {
-      aList[k] = GEOM::GEOM_Object::_duplicate(anOpArgsList[j]);
+      aList[k] = GEOM::GEOM_Object::_narrow(anOpArgsList[j]);
       k++;
     }
   }
@@ -1640,7 +1677,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
             GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject);
             if (!CORBA::is_nil(anArgOTrsf)) {
               CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
-              Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+              Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
               Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
               anArgOTrsfFun->SetDescription("");
               aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
@@ -1784,7 +1821,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
   aResParts->length(nb);
   if (nb > 0)
   {
-    Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+    Handle(GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
     Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
     GEOM::TPythonDump pd (aFunction, true);
     pd <<"[";
@@ -1800,8 +1837,8 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
       anObjEntryMap.insert(anEntry);
       aResParts[nbRes++] = anObj;
       // clear python dump of object
-      Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
-      Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
+      Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
+      Handle(GEOM_Function)   anObjFun = aGeomObj->GetLastFunction();
       if ( !anObjFun.IsNull() )
         anObjFun->SetDescription( "" );
       if ( j > 0 )
@@ -1816,7 +1853,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr     theStu
       GEOM::GEOM_Object_var anObj = theArgs[ i ];
       if (CORBA::is_nil(anObj))
         continue;
-      Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
+      Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
       if ( j > 0 )
         pd << ", ";
       pd << aGeomObj;
@@ -1916,7 +1953,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr
             GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO);
             if (!CORBA::is_nil(anArgOTrsf)) {
               CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
-              Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+              Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
               Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
               anArgOTrsfFun->SetDescription("");
               aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
@@ -2334,6 +2371,26 @@ GEOM::GEOM_IGroupOperations_ptr GEOM_Gen_i::GetIGroupOperations(CORBA::Long theS
   return operations._retn();
 }
 
+//============================================================================
+// function : GetIFieldOperations
+// purpose  :
+//============================================================================
+GEOM::GEOM_IFieldOperations_ptr GEOM_Gen_i::GetIFieldOperations(CORBA::Long theStudyID)
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "GEOM_Gen_i::GetIFieldOperations" );
+
+  GEOM::GEOM_Gen_ptr engine = _this();
+
+  GEOM_IFieldOperations_i* aServant =
+    new GEOM_IFieldOperations_i(_poa, engine, _impl->GetIFieldOperations(theStudyID));
+
+  // activate the CORBA servant
+  GEOM::GEOM_IFieldOperations_var operations = aServant->_this();
+  return operations._retn();
+}
+
 //============================================================================
 // function : GetPluginOperations
 // purpose  :
@@ -2415,13 +2472,14 @@ GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyI
  *  AddSubShape
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
+GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr   theMainShape,
                                                const GEOM::ListOfLong& theIndices)
 {
   if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
     return GEOM::GEOM_Object::_nil();
   CORBA::String_var entry = theMainShape->GetEntry();
-  Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+  Handle(GEOM_Object) aMainShape = Handle(GEOM_Object)::DownCast
+    ( _impl->GetObject( theMainShape->GetStudyID(), entry ));
   if (aMainShape.IsNull()) return GEOM::GEOM_Object::_nil();
 
   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
@@ -2432,7 +2490,7 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShap
 
   TCollection_AsciiString anEntry;
   TDF_Tool::Entry(anObject->GetEntry(), anEntry);
-  return GetObject(anObject->GetDocID(), anEntry.ToCString());
+  return GEOM::GEOM_Object::_narrow( GetObject(anObject->GetDocID(), anEntry.ToCString()));
 }
 
 //=============================================================================
@@ -2440,25 +2498,23 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShap
  *  RemoveObject
  */
 //=============================================================================
-void GEOM_Gen_i::RemoveObject(GEOM::GEOM_Object_ptr theObject)
+void GEOM_Gen_i::RemoveObject(GEOM::GEOM_BaseObject_ptr theObject)
 {
   CORBA::String_var anEntry = theObject->GetEntry();
-  Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
-  if (anObject.IsNull()) return;
-  _impl->RemoveObject(anObject);
-  return;
+  Handle(GEOM_BaseObject) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
+  if (!anObject.IsNull())
+    _impl->RemoveObject(anObject);
 }
 
-
 //=================================================================================
 // function : GetStringFromIOR()
 // purpose  : returns a string that represents  a 'GEOM::GEOM_Object_var'
 //=================================================================================
-char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Object_ptr theObject) {
+char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Object_ptr theObject)
+{
   return _orb->object_to_string(theObject);
 }
 
-
 //=================================================================================
 // function : GetIORFromString()
 // purpose  : returns a 'GEOM::GEOM_Object_var' from a string representing it
@@ -2477,22 +2533,49 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::GetIORFromString(const char* stringIOR) {
 // function : GetObject()
 // purpose  :
 //=================================================================================
-GEOM::GEOM_Object_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* theEntry)
+GEOM::GEOM_BaseObject_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* theEntry)
 {
-  GEOM::GEOM_Object_var obj;
-  Handle(GEOM_Object) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
+  GEOM::GEOM_BaseObject_var obj;
+  Handle(GEOM_BaseObject) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
   if (handle_object.IsNull()) return obj._retn();
 
   TCollection_AsciiString stringIOR = handle_object->GetIOR();
   if (stringIOR.Length() > 1) {
     CORBA::Object_var corba_object = _orb->string_to_object(stringIOR.ToCString());
-    if (!CORBA::is_nil(corba_object)) obj = GEOM::GEOM_Object::_narrow(corba_object);
+    if (!CORBA::is_nil(corba_object)) obj = GEOM::GEOM_BaseObject::_narrow(corba_object);
     return obj._retn();
   }
 
   GEOM::GEOM_Gen_ptr engine = _this();
   //transfer the reference to GEOM_Object_i
-  GEOM_Object_i* servant = new GEOM_Object_i (_poa, engine, handle_object);
+  GEOM_BaseObject_i* servant = 0;
+  switch( handle_object->GetType() ) {
+  case GEOM_FIELD: {
+    servant = new GEOM_Field_i (_poa, engine, Handle(GEOM_Field)::DownCast( handle_object ));
+    break;
+  }
+  case GEOM_FIELD_STEP: {
+    Handle(GEOM_FieldStep) step = Handle(GEOM_FieldStep)::DownCast( handle_object );
+    Handle(GEOM_Field)    field = step->GetField();
+    int type = ( !field.IsNull() ? field->GetDataType() : 0 );
+    switch( type ) {
+    case GEOM::FDT_Bool:
+      servant = new GEOM_BoolFieldStep_i (_poa, engine, step );
+      break;
+    case GEOM::FDT_Int:
+      servant = new GEOM_IntFieldStep_i (_poa, engine, step );
+      break;
+    case GEOM::FDT_Double:
+      servant = new GEOM_DoubleFieldStep_i (_poa, engine, step );
+      break;
+    default:
+      servant = new GEOM_StringFieldStep_i (_poa, engine, step );
+    }
+    break;
+  }
+  default:
+    servant = new GEOM_Object_i (_poa, engine, Handle(GEOM_Object)::DownCast( handle_object ));
+  }
   PortableServer::ObjectId_var id = _poa->activate_object(servant);
 
   obj = servant->_this();
index c87fe23cf2c4bbaa32f11cd4cdca7f2f799e39f7..8d8e9943d0ddab760fca58bd3500bccfa5ee9841 100644 (file)
@@ -49,6 +49,7 @@
 #include "GEOM_IInsertOperations_i.hh"
 #include "GEOM_IMeasureOperations_i.hh"
 #include "GEOM_IGroupOperations_i.hh"
+#include "GEOM_IFieldOperations_i.hh"
 
 #include <TopTools_IndexedMapOfShape.hxx>
 
@@ -159,10 +160,10 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   /*! \brief Adds theObject in the study with a name = theName, if
    *         theFather is not null the object is placed under theFather
    */
-  SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
-                                    GEOM::GEOM_Object_ptr theObject,
-                                    const char* theName,
-                                    GEOM::GEOM_Object_ptr theFather);
+  SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr       theStudy,
+                                    GEOM::GEOM_BaseObject_ptr theObject,
+                                    const char*               theName,
+                                    GEOM::GEOM_BaseObject_ptr theFather);
 
   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
    *         To be used from python scripts out of geompy.addToStudy (non-default usage)
@@ -256,6 +257,10 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
     throw (SALOME::SALOME_Exception);
 
+  //Returns a pointer to FiedlOperations interface
+  virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations (CORBA::Long theStudyID)
+    throw (SALOME::SALOME_Exception);
+
   //Returns a pointer to corresponding plugin operations interface
   virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
                                                           const char* theLibName)
@@ -265,7 +270,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
                                              const GEOM::ListOfLong& theIndices);
 
-  virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
+  virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
 
   virtual  char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
 
@@ -308,7 +313,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   // Internal methods                                                      //
   //-----------------------------------------------------------------------//
 
-  virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
+  virtual GEOM::GEOM_BaseObject_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
 
  private:
   GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr     theStudy,
diff --git a/src/GEOM_I/GEOM_IFieldOperations_i.cc b/src/GEOM_I/GEOM_IFieldOperations_i.cc
new file mode 100644 (file)
index 0000000..247154c
--- /dev/null
@@ -0,0 +1,163 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_IFieldOperations_i.hh"
+
+#include "utilities.h"
+#include "OpUtil.hxx"
+#include "Utils_ExceptHandlers.hxx"
+
+#include "GEOM_Engine.hxx"
+#include "GEOM_Object.hxx"
+#include "GEOM_Field.hxx"
+
+//=============================================================================
+/*
+ *   constructor:
+ */
+//=============================================================================
+GEOM_IFieldOperations_i::GEOM_IFieldOperations_i (PortableServer::POA_ptr thePOA,
+                                                  GEOM::GEOM_Gen_ptr theEngine,
+                                                  ::GEOMImpl_IFieldOperations* theImpl)
+  :GEOM_IOperations_i(thePOA, theEngine, theImpl)
+{
+  MESSAGE("GEOM_IFieldOperations_i::GEOM_IFieldOperations_i");
+}
+
+//=============================================================================
+/*
+ *  destructor
+ */
+//=============================================================================
+GEOM_IFieldOperations_i::~GEOM_IFieldOperations_i()
+{
+  MESSAGE("GEOM_IFieldOperations_i::~GEOM_IFieldOperations_i");
+}
+
+
+//=============================================================================
+/*
+ *  \brief Creates a field
+ */
+//=============================================================================
+
+GEOM::GEOM_Field_ptr
+GEOM_IFieldOperations_i::CreateField(GEOM::GEOM_Object_ptr     theShape,
+                                     const char*               theName,
+                                     GEOM::field_data_type     theType,
+                                     CORBA::Short              theDimension,
+                                     const GEOM::string_array& theComponentNames)
+{
+  GEOM::GEOM_Field_var aField;
+
+  Handle(TColStd_HArray1OfExtendedString) compNames;
+  if ( theComponentNames.length() > 0 )
+  {
+    compNames = new TColStd_HArray1OfExtendedString( 1, theComponentNames.length() );
+    for ( size_t i = 0; i < theComponentNames.length(); ++i )
+      compNames->SetValue( i+1, theComponentNames[ i ].in() );
+  }
+  Handle(GEOM_Object) aShapeRef = GetObjectImpl( theShape );
+  Handle(GEOM_Field)  aFieldRef = GetOperations()->CreateField( aShapeRef,
+                                                                theName,
+                                                                (int) theType,
+                                                                theDimension,
+                                                                compNames );
+  if ( !aFieldRef.IsNull() )
+    aField = GEOM::GEOM_Field::_narrow( GetBaseObject( aFieldRef ));
+
+  return aField._retn();
+}
+
+//=============================================================================
+/*
+ *  \brief Returns number of fields on a shape
+ */
+//=============================================================================
+
+CORBA::Long GEOM_IFieldOperations_i::CountFields( GEOM::GEOM_Object_ptr shape)
+{
+  Handle(GEOM_Object) go = GetObjectImpl( shape );
+
+  return ( CORBA::Long) GetOperations()->CountFields( go );
+}
+
+//=============================================================================
+/*
+ *  \brief Returns all fields on a shape
+ */
+//=============================================================================
+
+GEOM::ListOfFields* GEOM_IFieldOperations_i::GetFields( GEOM::GEOM_Object_ptr shape )
+{
+  GEOM::ListOfFields_var fields = new GEOM::ListOfFields;
+
+  Handle(GEOM_Object) go = GetObjectImpl( shape );
+
+  Handle(TColStd_HSequenceOfTransient) seq = GetOperations()->GetFields( go );
+  if ( !seq.IsNull() )
+  {
+    fields->length( seq->Length() );
+    int nbF = 0;
+    for ( int i = 1; i <= seq->Length(); ++i )
+    {
+      Handle(GEOM_Field)      f = Handle(GEOM_Field)::DownCast( seq->Value( i ));
+      GEOM::GEOM_Field_var fvar = GEOM::GEOM_Field::_narrow( GetBaseObject( f ));
+      if ( !fvar->_is_nil() )
+        fields[ nbF++ ] = fvar._retn();
+    }
+    fields->length( nbF );
+  }
+  return fields._retn();
+}
+
+//=============================================================================
+/*
+ *  \brief Returns all fields on a shape
+ */
+//=============================================================================
+
+GEOM::GEOM_Field_ptr GEOM_IFieldOperations_i::GetField( GEOM::GEOM_Object_ptr shape,
+                                                        const char*           name)
+{
+  GEOM::GEOM_Field_var field;
+
+  Handle(GEOM_Object) go = GetObjectImpl( shape );
+
+  Handle(GEOM_Field) f = GetOperations()->GetField( go, name );
+  field = GEOM::GEOM_Field::_narrow( GetBaseObject( f ));
+
+  return field._retn();
+}
+
+//=============================================================================
+/*
+ *  \brief Returns number of sub-shapes of given dimension
+ */
+//=============================================================================
+
+::CORBA::Long GEOM_IFieldOperations_i::GetNbSubShapes(::GEOM::GEOM_Object_ptr shape,
+                                                      ::CORBA::Short          fieldDim)
+{
+  Handle(GEOM_Object) go = GetObjectImpl( shape );
+  return GEOM_Field::GetNbSubShapes( go, fieldDim );
+}
diff --git a/src/GEOM_I/GEOM_IFieldOperations_i.hh b/src/GEOM_I/GEOM_IFieldOperations_i.hh
new file mode 100644 (file)
index 0000000..aa8a058
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2007-2013  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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _GEOM_IFieldOperations_i_HeaderFile
+#define _GEOM_IFieldOperations_i_HeaderFile
+
+#include "GEOMImpl_Gen.hxx"
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include "GEOM_IOperations_i.hh"
+#include "GEOM_Object_i.hh"
+
+#include "GEOMImpl_IFieldOperations.hxx"
+
+class GEOM_I_EXPORT GEOM_IFieldOperations_i :
+  public virtual POA_GEOM::GEOM_IFieldOperations,
+  public virtual GEOM_IOperations_i
+{
+ public:
+  GEOM_IFieldOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
+                           ::GEOMImpl_IFieldOperations* theImpl);
+  ~GEOM_IFieldOperations_i();
+
+  /*!
+   *  \brief Creates a field
+   */
+  GEOM::GEOM_Field_ptr CreateField (GEOM::GEOM_Object_ptr     theShape,
+                                    const char*               theName,
+                                    GEOM::field_data_type     theType,
+                                    CORBA::Short              theDimension,
+                                    const GEOM::string_array& theComponentNames);
+  /*!
+   *  \brief Returns number of fields on a shape
+   */
+  CORBA::Long CountFields( GEOM::GEOM_Object_ptr shape);
+
+  /*!
+   *  \brief Returns all fields on a shape
+   */
+  GEOM::ListOfFields* GetFields( GEOM::GEOM_Object_ptr shape );
+
+  /*!
+   *  \brief Returns a field on a shape by its name
+   */
+  GEOM::GEOM_Field_ptr GetField( GEOM::GEOM_Object_ptr shape,
+                                 const char*           name);
+  /*!
+   *  \brief Returns number of sub-shapes of given dimension
+   */
+  ::CORBA::Long GetNbSubShapes(::GEOM::GEOM_Object_ptr shape,
+                               ::CORBA::Short          fieldDim);
+
+  ::GEOMImpl_IFieldOperations* GetOperations()
+  { return (::GEOMImpl_IFieldOperations*)GetImpl(); }
+};
+
+#endif
index c7363fe9e22c7e9959c82362d4c6ce369ad2e40e..cc3d8667ac4f34d4f982b3740f8b09e4063acf48 100644 (file)
@@ -91,12 +91,9 @@ Handle(TColStd_HArray1OfExtendedString) GEOM_IHealingOperations_i::Convert
   if ( n <= 0 )
     return anOutArray;
   anOutArray = new TColStd_HArray1OfExtendedString( 1, n );
-  char* str;
   for ( int i = 0; i < n; i++ )
-  {
-    str = CORBA::string_dup( theInArray[i] );
-    anOutArray->SetValue( i+1, TCollection_ExtendedString( str ) );
-  }
+    anOutArray->SetValue( i+1, TCollection_ExtendedString( theInArray[i].in() ) );
+
   return anOutArray;
 }
 
index ddb90948fff925bfd615b17189ad9bcdf2a294c7..329e67dee9c157361de78f0b29a138471c2cca0e 100644 (file)
@@ -134,9 +134,10 @@ void GEOM_IOperations_i::AbortOperation()
  *  GetObject
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IOperations_i::GetObject(Handle(GEOM_Object) theObject)
+GEOM::GEOM_BaseObject_ptr
+GEOM_IOperations_i::GetBaseObject(Handle(GEOM_BaseObject) theObject)
 {
-  GEOM::GEOM_Object_var GO;
+  GEOM::GEOM_BaseObject_var GO;
   if (theObject.IsNull()) return GO._retn();
   TCollection_AsciiString anEntry;
   TDF_Tool::Entry(theObject->GetEntry(), anEntry);
@@ -149,17 +150,37 @@ GEOM::GEOM_Object_ptr GEOM_IOperations_i::GetObject(Handle(GEOM_Object) theObjec
  *  GetObjectImpl
  */
 //=============================================================================
-Handle(GEOM_Object) GEOM_IOperations_i::GetObjectImpl(GEOM::GEOM_Object_ptr theObject)
+Handle(GEOM_BaseObject)
+GEOM_IOperations_i::GetBaseObjectImpl(GEOM::GEOM_BaseObject_ptr theObject)
 {
-  Handle(GEOM_Object) anImpl;
+  Handle(GEOM_BaseObject) anImpl;
   if (!CORBA::is_nil(theObject)) {
     CORBA::String_var anEntry = theObject->GetEntry();
-    anImpl = GetImpl()->GetEngine()->GetObject
-      (theObject->GetStudyID(), anEntry);
+    anImpl = GetImpl()->GetEngine()->GetObject( theObject->GetStudyID(), anEntry );
   }
   return anImpl;
 }
 
+//=============================================================================
+/*!
+ *  GetObject
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IOperations_i::GetObject(Handle(GEOM_Object) theObject)
+{
+  return GEOM::GEOM_Object::_narrow( GetBaseObject( theObject ));
+}
+
+//=============================================================================
+/*!
+ *  GetObjectImpl
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOM_IOperations_i::GetObjectImpl(GEOM::GEOM_Object_ptr theObject)
+{
+  return Handle(GEOM_Object)::DownCast( GetBaseObjectImpl( theObject ));
+}
+
 //=============================================================================
 /*!
  *  GetListOfObjectsImpl
index 4d8757cd8331ae99210df05ab7e86f3186862b98..7f67787ebe88fac51dc7e3b007f89c41b241668c 100644 (file)
@@ -47,6 +47,8 @@ class GEOM_I_EXPORT GEOM_IOperations_i : public virtual POA_GEOM::GEOM_IOperatio
 
   virtual CORBA::Long GetStudyID();    
 
+  virtual GEOM::GEOM_BaseObject_ptr GetBaseObject(Handle(GEOM_BaseObject) theObject);
+  virtual Handle(GEOM_BaseObject) GetBaseObjectImpl(GEOM::GEOM_BaseObject_ptr theObject);
   virtual GEOM::GEOM_Object_ptr GetObject(Handle(GEOM_Object) theObject);
   virtual Handle(GEOM_Object) GetObjectImpl(GEOM::GEOM_Object_ptr theObject);
 
index 7bdb0a90d7023d05b75e53c61781f38e5f8b6e52..efa602ef7677a31e24b71e53af995d8cad949aef 100644 (file)
 //=============================================================================
 
 GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
-                             Handle(GEOM_Object) theImpl)
-: SALOME::GenericObj_i( thePOA ), _engine(theEngine), _impl(theImpl)
+                             Handle(GEOM_Object) theImpl) :
+  SALOME::GenericObj_i( thePOA ),
+  GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+  _impl( theImpl )
 {
 }
 
@@ -74,43 +76,6 @@ GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr
 GEOM_Object_i::~GEOM_Object_i()
 {
   MESSAGE("GEOM_Object_i::~GEOM_Object_i");
-  GEOM_Engine::GetEngine()->RemoveObject(_impl);
-}
-
-
-//=============================================================================
-/*!
- *  GetEntry
- */
-//=============================================================================
-char* GEOM_Object_i::GetEntry()
-{
-  const TDF_Label& aLabel = _impl->GetEntry();
-  TCollection_AsciiString anEntry;
-  TDF_Tool::Entry(aLabel, anEntry);
-  const char* anEntstr = anEntry.ToCString();
-  return CORBA::string_dup(anEntstr);
-}
-
-//=============================================================================
-/*!
- *  GetStudyID
- */
-//=============================================================================
-CORBA::Long GEOM_Object_i::GetStudyID()
-{
-   return _impl->GetDocID();
-}
-
-
-//=============================================================================
-/*!
- *  GetType
- */
-//=============================================================================
-CORBA::Long GEOM_Object_i::GetType()
-{
-  return _impl->GetType();
 }
 
 //=============================================================================
@@ -193,28 +158,6 @@ GEOM::shape_type GEOM_Object_i::GetMaxShapeType()
   return getMinMaxShapeType( _impl->GetValue(), false );
 }
 
-//=============================================================================
-/*!
- *  SetName
- */
-//=============================================================================
-void GEOM_Object_i::SetName(const char* theName)
-{
-  _impl->SetName(theName);
-}
-
-
-//=============================================================================
-/*!
- *  GetName
- */
-//=============================================================================
-char* GEOM_Object_i::GetName()
-{
-  TCollection_AsciiString aName = _impl->GetName();
-  return CORBA::string_dup( aName.ToCString() );
-}
-
 //=============================================================================
 /*!
  *  SetColor
@@ -329,91 +272,6 @@ CORBA::Long GEOM_Object_i::GetMarkerTexture()
   return _impl->GetMarkerTexture();
 }
 
-
-//=============================================================================
-/*!
- *  SetStudyEntry
- */
-//=============================================================================
-void GEOM_Object_i::SetStudyEntry(const char* theEntry)
-{
-  _impl->SetAuxData(theEntry);
-}
-
-
-//=============================================================================
-/*!
- *  GetStudyEntry
- */
-//=============================================================================
-char* GEOM_Object_i::GetStudyEntry()
-{
-  TCollection_AsciiString anEntry = _impl->GetAuxData();
-  if(!anEntry.IsEmpty()) return CORBA::string_dup(anEntry.ToCString());
-  return CORBA::string_dup("");
-}
-
-
-//=============================================================================
-/*!
- *  GetDependency
- */
-//=============================================================================
-GEOM::ListOfGO* GEOM_Object_i::GetDependency()
-{
-  GEOM::ListOfGO_var aList = new GEOM::ListOfGO();
-  aList->length(0);
-
-  Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllDependency();
-  if (aSeq.IsNull()) return aList._retn();
-  int aLength = aSeq->Length();
-  if (aLength == 0) return aList._retn();
-
-  aList->length(aLength);
-
-  TCollection_AsciiString anEntry;
-
-  for (int i = 1; i<=aLength; i++) {
-    Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i));
-    if (anObj.IsNull()) continue;
-    TDF_Tool::Entry(anObj->GetEntry(), anEntry);
-    GEOM::GEOM_Object_var obj = _engine->GetObject(anObj->GetDocID(), (char*) anEntry.ToCString());
-    aList[i-1] = obj;
-  }
-
-  return aList._retn();
-}
-
-//=============================================================================
-/*!
- * GetLastDependency
- */
-//=============================================================================
-GEOM::ListOfGO* GEOM_Object_i::GetLastDependency()
-{
-  GEOM::ListOfGO_var aList = new GEOM::ListOfGO();
-  aList->length(0);
-
-  Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetLastDependency();
-  if (aSeq.IsNull()) return aList._retn();
-  int aLength = aSeq->Length();
-  if (aLength == 0) return aList._retn();
-
-  aList->length(aLength);
-
-  TCollection_AsciiString anEntry;
-
-  for (int i = 1; i<=aLength; i++) {
-     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i));
-     if (anObj.IsNull()) continue;
-     TDF_Tool::Entry(anObj->GetEntry(), anEntry);
-     GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_duplicate(_engine->GetObject(anObj->GetDocID(), anEntry.ToCString()));
-     aList[i-1] = obj;
-  }
-
-  return aList._retn();
-}
-
 //=================================================================================
 // function : GetShapeStream
 // Transfer resulting shape to client as sequence of bytes
@@ -494,7 +352,8 @@ GEOM::GEOM_Object_ptr GEOM_Object_i::GetMainShape()
     if(aLabel.IsNull()) return obj._retn();
     TCollection_AsciiString anEntry;
     TDF_Tool::Entry(aLabel, anEntry);
-    return _engine->GetObject(_impl->GetDocID(), anEntry.ToCString());
+    return GEOM::GEOM_Object::_narrow
+      ( _engine->GetObject(_impl->GetDocID(), anEntry.ToCString()) );
   }
 
   return obj._retn();
@@ -510,67 +369,10 @@ bool GEOM_Object_i::IsSame(GEOM::GEOM_Object_ptr other)
   TopoDS_Shape thisShape  = _impl->GetValue();
   TopoDS_Shape otherShape;
   if ( !CORBA::is_nil( other ) ) {
-    Handle(GEOM_Object) otherObject = GEOM_Engine::GetEngine()->GetObject( other->GetStudyID(), other->GetEntry(), false );
+    Handle(GEOM_Object) otherObject = Handle(GEOM_Object)::DownCast
+      ( GEOM_Engine::GetEngine()->GetObject( other->GetStudyID(), other->GetEntry(), false ));
     if ( !otherObject.IsNull() )
       otherShape = otherObject->GetValue();
   }
   return thisShape.IsSame( otherShape );
 }
-
-void GEOM_Object_i::SetParameters(const char* theParameters)
-{
-  _impl->SetParameters((char*)theParameters);
-}
-
-char* GEOM_Object_i::GetParameters()
-{
-  return CORBA::string_dup(_impl->GetParameters().ToCString());
-}
-
-GEOM::CreationInformation* GEOM_Object_i::GetCreationInformation()
-{
-  GEOM::CreationInformation_var info = new GEOM::CreationInformation;
-
-  Handle(GEOM_BaseDriver) driver =
-    Handle(GEOM_BaseDriver)::DownCast( _impl->GetCreationDriver() );
-  if ( !driver.IsNull() )
-  {
-    std::vector<GEOM_Param> params;
-    std::string             operationName;
-    try
-    {
-      OCC_CATCH_SIGNALS;
-      if ( driver->GetCreationInformation( operationName, params ))
-      {
-        info->operationName = operationName.c_str();
-        info->params.length( params.size() );
-        for ( size_t i = 0; i < params.size(); ++i )
-        {
-          info->params[i].name  = params[i].name.c_str();
-          info->params[i].value = params[i].value.c_str();
-        }
-      }
-#ifdef _DEBUG_
-      if ( operationName.empty() )
-      {
-        cout << endl << endl << endl << "Warning: " << endl << "Dear developer!!!" << endl
-             << "  Consider implementing "
-             <<    typeid(*(driver.operator->())).name() << "::GetCreationInformation() " << endl
-             << "  for the case of operation which has created '" << GetName() << "' object" << endl
-             << "PLEEEEEEEASE" << endl
-             << "\tPLEEEEEEEASE" << endl
-             << "\t\tPLEEEEEEEASE" << endl
-             << "\t\t\tPLEEEEEEEASE" << endl
-             << "\t\t\t\tPLEEEEEEEASE" << endl;
-      }
-#endif
-    }
-    catch(...)
-    {
-#ifdef _DEBUG_
-      cout << "Ecxeption in GEOM_Object_i::GetCreationInformation()" << endl;
-#endif
-    }
-  }
-  return info._retn();
-}
index eed3220a9c3c63fca0d67e3bc76ffad850044a57..47c1c301daac008cb175ec59db40c64c9a627f9e 100644 (file)
 #ifndef _GEOM_Object_i_HeaderFile
 #define _GEOM_Object_i_HeaderFile
 
-#include "GEOM_GEOM_I.hxx"
-
 #include "GEOMImpl_Gen.hxx"
+#include "GEOM_BaseObject_i.hh"
+#include "GEOM_Object.hxx"
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 
-#include "SALOME_GenericObj_i.hh"
-
-#include "GEOM_Object.hxx"
-
 #include <TopoDS_Shape.hxx>
 
-class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual SALOME::GenericObj_i
+class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual GEOM_BaseObject_i
 {
  public:
    GEOM_Object_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_Object) theImpl);
    ~GEOM_Object_i();
 
-  virtual char* GetEntry();
-
-  virtual CORBA::Long GetStudyID();
-
-  virtual CORBA::Long GetType();
-
   virtual GEOM::shape_type GetShapeType();
 
   virtual GEOM::shape_type GetTopologyType();
@@ -57,10 +47,6 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
 
   virtual GEOM::shape_type GetMaxShapeType();
 
-  virtual void SetName(const char* theName);
-
-  virtual char* GetName();
-
   virtual void SetColor(const SALOMEDS::Color& theColor);
 
   virtual SALOMEDS::Color GetColor();
@@ -79,14 +65,6 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
 
   virtual CORBA::Long GetMarkerTexture();
 
-  virtual void SetStudyEntry(const char* theEntry);
-
-  virtual char* GetStudyEntry();
-
-  virtual GEOM::ListOfGO* GetDependency();
-
-  virtual GEOM::ListOfGO* GetLastDependency();
-
   virtual SALOMEDS::TMPFile* GetShapeStream();
 
   virtual CORBA::LongLong getShape();
@@ -101,17 +79,10 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
 
   virtual bool IsShape();
 
-  virtual void SetParameters(const char* theParameters);
-
-  virtual char* GetParameters();
-
-  virtual GEOM::CreationInformation* GetCreationInformation();
-
   Handle(GEOM_Object) GetImpl() { return _impl; }
 
  private:
 
-  GEOM::GEOM_Gen_var _engine;
   Handle(GEOM_Object) _impl;
   TopoDS_Shape _geom;
 };
index b46b8a1de932433f013ebb441b37ae1040f89b72..6a70cb93eaf340cb592befa4353787b5932ec051 100644 (file)
@@ -38,9 +38,29 @@ namespace GEOM
   // A simple rule: use GEOM::GEOM_Object_wrap if an object is returned by a
   // GEOM operation (GEOM::GEOM_IBasicOperations etc).
   //
-  typedef SALOME::GenericObj_wrap< GEOM_Object              > GEOM_Object_wrap;
+  class GEOM_BasicObject;
+  class GEOM_Object;
+  class GEOM_Field;
+  class GEOM_FieldStep;
+  typedef SALOME::GenericObj_wrap< GEOM_BasicObject > GEOM_BaseObject_wrap;
+  typedef SALOME::GenericObj_wrap< GEOM_Object      > GEOM_Object_wrap;
+  typedef SALOME::GenericObj_wrap< GEOM_Field       > GEOM_Field_wrap;
+  typedef SALOME::GenericObj_wrap< GEOM_FieldStep   > GEOM_FieldStep_wrap;
   //
   // wrappers of operations
+  class GEOM_IBasicOperations;
+  class GEOM_ITransformOperations;
+  class GEOM_I3DPrimOperations;
+  class GEOM_IShapesOperations;
+  class GEOM_IBlocksOperations;
+  class GEOM_IBooleanOperations;
+  class GEOM_ICurvesOperations;
+  class GEOM_ILocalOperations;
+  class GEOM_IHealingOperations;
+  class GEOM_IInsertOperations;
+  class GEOM_IMeasureOperations;
+  class GEOM_IGroupOperations;
+  class GEOM_IAdvancedOperations;
   typedef SALOME::GenericObj_wrap< GEOM_IBasicOperations    > GEOM_IBasicOperations_wrap;
   typedef SALOME::GenericObj_wrap< GEOM_ITransformOperations> GEOM_ITransformOperations_wrap;
   typedef SALOME::GenericObj_wrap< GEOM_I3DPrimOperations   > GEOM_I3DPrimOperations_wrap;
index b0858f9ff33a7053968db799439acb582664951f..91e86c3cb64bbc25d586c3e6a5ac5b1474906c53 100644 (file)
 
 ##   @}
 ##   @defgroup l2_measure       Using measurement tools
+##   @defgroup l2_field         Field on Geometry
 
 ## @}
 
@@ -589,6 +590,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
               self.BlocksOp = None
               self.GroupOp  = None
               self.AdvOp    = None
+              self.FieldOp  = None
             pass
 
         ## Process object publication in the study, as follows:
@@ -632,6 +634,22 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                     pass
                 return _name
             # ---
+            def _publish( _name, _obj ):
+                fatherObj = None
+                if isinstance( _obj, GEOM._objref_GEOM_Field ):
+                    fatherObj = _obj.GetShape()
+                elif isinstance( _obj, GEOM._objref_GEOM_FieldStep ):
+                    fatherObj = _obj.GetField()
+                elif not _obj.IsMainShape():
+                    fatherObj = _obj.GetMainShape()
+                    pass
+                if fatherObj and fatherObj.GetStudyEntry():
+                    self.addToStudyInFather(fatherObj, _obj, _name)
+                else:
+                    self.addToStudy(_obj, _name)
+                    pass
+                return
+            # ---
             if not theObj:
                 return # null object
             if not theName and not self.myMaxNbSubShapesAllowed:
@@ -644,27 +662,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 idx = 0
                 for obj in theObj:
                     if not obj: continue # bad object
-                    ###if obj.GetStudyEntry(): continue # already published
                     name = _item_name(theName, theDefaultName, idx)
-                    if obj.IsMainShape() or not obj.GetMainShape().GetStudyEntry():
-                        self.addToStudy(obj, name) # "%s_%d"%(aName, idx)
-                    else:
-                        self.addToStudyInFather(obj.GetMainShape(), obj, name) # "%s_%d"%(aName, idx)
-                        pass
+                    _publish( name, obj )
                     idx = idx+1
                     if not theName and idx == self.myMaxNbSubShapesAllowed: break
                     pass
                 pass
             else:
                 # single object is published
-                ###if theObj.GetStudyEntry(): return # already published
                 name = _item_name(theName, theDefaultName)
-                if theObj.IsMainShape():
-                    self.addToStudy(theObj, name)
-                else:
-                    self.addToStudyInFather(theObj.GetMainShape(), theObj, name)
-                    pass
-                pass
+                _publish( name, theObj )
             pass
 
         ## @addtogroup l1_geomBuilder_auxiliary
@@ -696,6 +703,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self.MeasuOp  = self.GetIMeasureOperations  (self.myStudyId)
             self.BlocksOp = self.GetIBlocksOperations   (self.myStudyId)
             self.GroupOp  = self.GetIGroupOperations    (self.myStudyId)
+            self.FieldOp  = self.GetIFieldOperations    (self.myStudyId)
 
             # The below line is a right way to map all plugin functions to geomBuilder,
             # but AdvancedOperations are already mapped, that is why this line is commented
@@ -2245,7 +2253,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #  @param theParamMin the minimal value of the parameter.
         #  @param theParamMax the maximum value of the parameter.
         #  @param theParamStep the number of steps if theNewMethod = True, else step value of the parameter.
-        #  @param theCurveType the type of the curve.
+        #  @param theCurveType the type of the curve,
+        #         one of GEOM.Polyline, GEOM.Bezier, GEOM.Interpolation.
         #  @param theNewMethod flag for switching to the new method if the flag is set to false a deprecated method is used which can lead to a bug.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
@@ -2266,7 +2275,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 theParamMin the minimal value of the parameter.
                 theParamMax the maximum value of the parameter.
                 theParamStep the number of steps if theNewMethod = True, else step value of the parameter.
-                theCurveType the type of the curve.
+                theCurveType the type of the curve,
+                             one of GEOM.Polyline, GEOM.Bezier, GEOM.Interpolation.
                 theNewMethod flag for switching to the new method if the flag is set to false a deprecated
                              method is used which can lead to a bug.
                 theName Object name; when specified, this parameter is used
@@ -12464,10 +12474,210 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self.MoveListToFolder(ListOfSO, Folder)
             pass
 
+        ## @addtogroup l2_field
+        ## @{
+
+        ## Creates a field
+        #  @param shape the shape the field lies on
+        #  @param name the field name
+        #  @param type type of field data: 0 - bool, 1 - int, 2 - double, 3 - string
+        #  @param dimension dimension of the shape the field lies on
+        #         0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+        #  @param componentNames names of components
+        #  @return a created field
+        def CreateField(self, shape, name, type, dimension, componentNames):
+            """
+            Creates a field
+
+            Parameters:
+                shape the shape the field lies on
+                name  the field name
+                type  type of field data
+                dimension dimension of the shape the field lies on
+                          0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+                componentNames names of components
+            
+            Returns:
+                a created field
+            """
+            if isinstance( type, int ):
+                if type < 0 or type > 3:
+                    raise RuntimeError, "CreateField : Error: data type must be within [0-3] range"
+                type = [GEOM.FDT_Bool,GEOM.FDT_Int,GEOM.FDT_Double,GEOM.FDT_String][type]
+
+            f = self.FieldOp.CreateField( shape, name, type, dimension, componentNames)
+            RaiseIfFailed("CreateField", self.FieldOp)
+            global geom
+            geom._autoPublish( f, "", name)
+            return f
+
+        ## Removes a field from the GEOM component
+        #  @param field the field to remove
+        def RemoveField(self, field):
+            "Removes a field from the GEOM component"
+            global geom
+            if isinstance( field, GEOM._objref_GEOM_Field ):
+                geom.RemoveObject( field )
+            elif isinstance( field, geomField ):
+                geom.RemoveObject( field.field )
+            else:
+                raise RuntimeError, "RemoveField() : the object is not a field"
+            return
+
+        ## Returns number of fields on a shape
+        def CountFields(self, shape):
+            "Returns number of fields on a shape"
+            nb = self.FieldOp.CountFields( shape )
+            RaiseIfFailed("CountFields", self.FieldOp)
+            return nb
+
+        ## Returns all fields on a shape
+        def GetFields(self, shape):
+            "Returns all fields on a shape"
+            ff = self.FieldOp.GetFields( shape )
+            RaiseIfFailed("GetFields", self.FieldOp)
+            return ff
+
+        ## Returns a field on a shape by its name
+        def GetField(self, shape, name):
+            "Returns a field on a shape by its name"
+            f = self.FieldOp.GetField( shape, name )
+            RaiseIfFailed("GetField", self.FieldOp)
+            return f
+
+        # end of l2_field
+        ## @}
+
+
 import omniORB
 # Register the new proxy for GEOM_Gen
 omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)
 
+
+## Field on Geometry
+#  @ingroup l2_field
+class geomField( GEOM._objref_GEOM_Field ):
+
+    def __init__(self):
+        GEOM._objref_GEOM_Field.__init__(self)
+        self.field = GEOM._objref_GEOM_Field
+        return
+
+    ## Returns the shape the field lies on
+    def getShape(self):
+        "Returns the shape the field lies on"
+        return self.field.GetShape(self)
+
+    ## Returns the field name
+    def getName(self):
+        "Returns the field name"
+        return self.field.GetName(self)
+
+    ## Returns type of field data as integer [0-3]
+    def getType(self):
+        "Returns type of field data"
+        return self.field.GetDataType(self)._v
+
+    ## Returns type of field data:
+    #  one of GEOM.FDT_Bool, GEOM.FDT_Int, GEOM.FDT_Double, GEOM.FDT_String
+    def getTypeEnum(self):
+        "Returns type of field data"
+        return self.field.GetDataType(self)
+
+    ## Returns dimension of the shape the field lies on:
+    #  0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+    def getDimension(self):
+        """Returns dimension of the shape the field lies on:
+        0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape"""
+        return self.field.GetDimension(self)
+
+    ## Returns names of components
+    def getComponents(self):
+        "Returns names of components"
+        return self.field.GetComponents(self)
+
+    ## Adds a time step to the field
+    #  @param step the time step number futher used as the step identifier
+    #  @param stamp the time step time
+    #  @param values the values of the time step
+    def addStep(self, step, stamp, values):
+        "Adds a time step to the field"
+        stp = self.field.AddStep( self, step, stamp )
+        if not stp:
+            raise RuntimeError, \
+                  "Field.addStep() : Error: step %s already exists in this field"%step
+        global geom
+        geom._autoPublish( stp, "", "Step %s, %s"%(step,stamp))
+        self.setValues( step, values )
+        return stp
+
+    ## Remove a time step from the field
+    def removeStep(self,step):
+        "Remove a time step from the field"
+        self.field.RemoveStep( self, step )
+        return
+
+    ## Returns number of time steps in the field
+    def countSteps(self):
+        "Returns number of time steps in the field"
+        return self.field.CountSteps(self)
+
+    ## Returns a list of time step IDs in the field
+    def getSteps(self):
+        "Returns a list of time step IDs in the field"
+        return self.field.GetSteps(self)
+
+    ## Returns a time step by its ID
+    def getStep(self,step):
+        "Returns a time step by its ID"
+        stp = self.field.GetStep(self, step)
+        if not stp:
+            raise RuntimeError, "Step %s is missing from this field"%step
+        return stp
+
+    ## Returns the time of the field step
+    def getStamp(self,step):
+        "Returns the time of the field step"
+        return self.getStep(step).GetStamp()
+
+    ## Changes the time of the field step
+    def setStamp(self, step, stamp):
+        "Changes the time of the field step"
+        return self.getStep(step).SetStamp(stamp)
+
+    ## Returns values of the field step
+    def getValues(self, step):
+        "Returns values of the field step"
+        return self.getStep(step).GetValues()
+
+    ## Changes values of the field step
+    def setValues(self, step, values):
+        "Changes values of the field step"
+        stp = self.getStep(step)
+        errBeg = "Field.setValues(values) : Error: "
+        try:
+            ok = stp.SetValues( values )
+        except Exception, e:
+            excStr = str(e)
+            if excStr.find("WrongPythonType") > 0:
+                raise RuntimeError, errBeg +\
+                      "wrong type of values, %s values are expected"%str(self.getTypeEnum())[4:]
+            raise RuntimeError, errBeg + str(e)
+        if not ok:
+            nbOK = self.field.GetArraySize(self)
+            nbKO = len(values)
+            if nbOK != nbKO:
+                raise RuntimeError, errBeg + "len(values) must be %s but not %s"%(nbOK,nbKO)
+            else:
+                raise RuntimeError, errBeg + "failed"
+        return
+
+    pass # end of class geomField
+
+# Register the new proxy for GEOM_Field
+omniORB.registerObjref(GEOM._objref_GEOM_Field._NP_RepositoryId, geomField)
+
+
 ## Create a new geomBuilder instance.The geomBuilder class provides the Python
 #  interface to GEOM operations.
 #