]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
import and export XAO with Fields
authorfps <fps@opencascade.com>
Tue, 12 Nov 2013 16:32:55 +0000 (16:32 +0000)
committerfps <fps@opencascade.com>
Tue, 12 Nov 2013 16:32:55 +0000 (16:32 +0000)
14 files changed:
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
src/GEOMBase/GEOM_GenericObjPtr.h
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
src/GEOMImpl/GEOMImpl_IInsertOperations.hxx
src/GEOM_I/GEOM_IInsertOperations_i.cc
src/GEOM_I/GEOM_IInsertOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx
src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h
src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx
src/XAO/XAO_Geometry.cxx
src/XAO/XAO_XaoExporter.cxx

index 6d6d5ccf52b195240314dc68f5232a2e446d0576..ad612446c8ffa5f352103ae8ffa1d82aad26ec5f 100644 (file)
@@ -3743,7 +3743,7 @@ module GEOM
      *  \return boolean indicating if export was successful.
      */
     boolean ExportXAO(in GEOM_Object shape,
-                     in ListOfGO groups, in ListOfGO fields,
+                     in ListOfGO groups, in ListOfFields fields,
                      in string author, in string fileName);
     
     /*!
@@ -3756,7 +3756,7 @@ module GEOM
      *  \return boolean indicating if import was successful.
      */
     boolean ImportXAO(in string fileName, out GEOM_Object shape,
-                     out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
+                     out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
   };
 
  // # GEOM_IKindOfShape:
index 43890593252962f67eb2c0c9c007552a9e76b755..b0653b468bf4b813224b0f897988df610c492296 100644 (file)
@@ -269,10 +269,10 @@ module GEOM
     void ExportTranslators (out string_array theFormats,
                             out string_array thePatterns) ;
     boolean ExportXAO(in GEOM_Object shape,
-                     in ListOfGO groups, in ListOfGO fields,
-                     in string author, in string fileName);
+                      in ListOfGO groups, in ListOfFields fields,
+                      in string author, in string fileName);
     boolean ImportXAO(in string fileName, out GEOM_Object shape,
-                     out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
+                      out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
 
     //-----------------------------------------------------------//
     // TransformOperations                                       //
index 0cb831b0f84202398cdec24a5d7590a30b74c98a..b86a4cf41a8fe46238caac73880f9926a04eb615 100644 (file)
@@ -216,6 +216,7 @@ namespace GEOM
   };
   
   typedef GenericObjPtr<GEOM::GEOM_Object>               GeomObjPtr;
+  typedef GenericObjPtr<GEOM::GEOM_Field>                GeomFieldPtr;
   typedef GenericObjPtr<GEOM::GEOM_IBasicOperations>     BasicOpPtr;
   typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr;
   typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations>    I3DPrimOpPtr;
index a3e2fcef39a31390b4f2d3ca85821405aeed5898..cc03711a0cfe83f631037e30f31c09c4b398b5d7 100644 (file)
@@ -32,6 +32,7 @@
 #include <GEOMImpl_Types.hxx>
 #include "GEOMImpl_IShapesOperations.hxx"
 #include "GEOMImpl_IGroupOperations.hxx"
+#include "GEOMImpl_IFieldOperations.hxx"
 #include "GEOMImpl_XAODriver.hxx"
 #include "GEOMImpl_IImportExportXAO.hxx"
 
 #include <XAO_Group.hxx>
 #include <XAO_Field.hxx>
 #include <XAO_XaoUtils.hxx>
+#include <XAO_BooleanField.hxx>
+#include <XAO_IntegerField.hxx>
+#include <XAO_DoubleField.hxx>
+#include <XAO_StringField.hxx>
+#include <XAO_BooleanStep.hxx>
+#include <XAO_IntegerStep.hxx>
+#include <XAO_DoubleStep.hxx>
+#include <XAO_StringStep.hxx>
 
 #include <Basics_OCCTVersion.hxx>
 
@@ -67,6 +76,7 @@
 
 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
 #include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_HArray1OfReal.hxx>
 #else
 #include <TDataStd_HArray1OfByte.hxx>
 #endif
@@ -100,6 +110,7 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
   MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
   myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
   myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
+  myFieldOperations = new GEOMImpl_IFieldOperations(GetEngine(), GetDocID());
 }
 
 //=============================================================================
@@ -112,6 +123,7 @@ GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
   MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
   delete myShapesOperations;
   delete myGroupOperations;
+  delete myFieldOperations;
 }
 
 //=============================================================================
@@ -837,7 +849,9 @@ XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape)
   return dim;
 }
 
-void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList,
+                                              XAO::Xao* xaoObject,
+                                              XAO::BrepGeometry* geometry)
 {
   // add the groups
   std::list<Handle(GEOM_Object)>::iterator groupIterator = groupList.begin();
@@ -855,42 +869,129 @@ void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> gro
     case TopAbs_VERTEX:
       for (int i = 1; i <= groupIds->Length(); i++)
       {
-       std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
-       int index = geometry->getVertexIndexByReference(ref);
-       group->add(index);
+        std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+        int index = geometry->getVertexIndexByReference(ref);
+        group->add(index);
       }
       break;
     case TopAbs_EDGE:
       for (int i = 1; i <= groupIds->Length(); i++)
       {
-       std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
-       int index = geometry->getEdgeIndexByReference(ref);
-       group->add(index);
+        std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+        int index = geometry->getEdgeIndexByReference(ref);
+        group->add(index);
       }
       break;
     case TopAbs_FACE:
       for (int i = 1; i <= groupIds->Length(); i++)
       {
-       std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
-       int index = geometry->getFaceIndexByReference(ref);
-       group->add(index);
+        std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+        int index = geometry->getFaceIndexByReference(ref);
+        group->add(index);
       }
       break;
     case TopAbs_SOLID:
       for (int i = 1; i <= groupIds->Length(); i++)
       {
-       std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
-       int index = geometry->getSolidIndexByReference(ref);
-       group->add(index);
+        std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+        int index = geometry->getSolidIndexByReference(ref);
+        group->add(index);
       }
       break;
     }
   }
 }
 
-void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Field)> fieldList,
+                                              XAO::Xao* xaoObject,
+                                              XAO::BrepGeometry* geometry)
 {
-  // TODO
+    std::list<Handle(GEOM_Field)>::iterator fieldIterator = fieldList.begin();
+    while (fieldIterator != fieldList.end())
+    {
+        Handle(GEOM_Field) currField = (*fieldIterator++);
+
+        int fdim = currField->GetDimension();
+        int ftype = currField->GetDataType();
+        int nbComponents = currField->GetNbComponents();
+        std::string name = currField->GetName().ToCString();
+
+        XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name);
+
+        Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents();
+        std::cout << "nb comp " << nbComponents << std::endl;
+        std::cout << components->Lower() << " - " << components->Upper() << std::endl;
+        for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j)
+        {
+            field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString());
+        }
+
+        std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps();
+        std::list<Handle(GEOM_FieldStep)>::iterator stepIterator = steps.begin();
+        while (stepIterator != steps.end())
+        {
+            Handle(GEOM_FieldStep) currStep = (*stepIterator++);
+
+            XAO::Step* step = field->addNewStep(currStep->GetID());
+            step->setStamp(currStep->GetStamp());
+
+            switch (ftype)
+            {
+                case 0: // bool
+                {
+                    XAO::BooleanStep* bs = (XAO::BooleanStep*)step;
+                    Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues();
+                    std::vector<bool> bv;
+                    bv.reserve(bvalues->Upper());
+                    for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i )
+                    {
+                        bv.push_back(bvalues->Value(i) != 0);
+                    }
+                    bs->setValues(bv);
+                    break;
+                }
+                case 1: // integer
+                {
+                    XAO::IntegerStep* is = (XAO::IntegerStep*)step;
+                    Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues();
+                    std::vector<int> iv;
+                    iv.reserve(ivalues->Upper());
+                    for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i )
+                    {
+                        iv.push_back(ivalues->Value(i));
+                    }
+                    is->setValues(iv);
+                    break;
+                }
+                case 2: // double
+                {
+                    XAO::DoubleStep* ds = (XAO::DoubleStep*)step;
+                    Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues();
+                    std::vector<double> dv;
+                    dv.reserve(dvalues->Upper());
+                    for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i )
+                    {
+                        dv.push_back(dvalues->Value(i));
+                    }
+                    ds->setValues(dv);
+                    break;
+                }
+                case 3: // string
+                {
+                    XAO::StringStep* ss = (XAO::StringStep*)step;
+                    Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues();
+                    std::vector<std::string> sv;
+                    sv.reserve(svalues->Upper());
+                    for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i )
+                    {
+                        sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString());
+                    }
+                    ss->setValues(sv);
+                    break;
+                }
+            }
+        }
+    }
 }
 
 void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry)
@@ -911,17 +1012,17 @@ void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shap
       switch (subObject->GetValue().ShapeType())
       {
       case TopAbs_VERTEX:
-       geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
-       break;
+        geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
+        break;
       case TopAbs_EDGE:
-       geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
-       break;
+        geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
+        break;
       case TopAbs_FACE:
-       geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
-       break;
+        geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
+        break;
       case TopAbs_SOLID:
-       geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
-       break;
+        geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
+        break;
       }
     }
   }
@@ -938,13 +1039,13 @@ void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shap
  */
 //=============================================================================
 bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
-                                          std::list<Handle(GEOM_Object)> groupList,
-                                          std::list<Handle(GEOM_Object)> fieldList,
-                                          const char* author,
-                                          const char* fileName)
+                                           std::list<Handle(GEOM_Object)> groupList,
+                                           std::list<Handle(GEOM_Field)> fieldList,
+                                           const char* author,
+                                           const char* fileName)
 {
   SetErrorCode(KO);
-  
+
   if (shape.IsNull()) return false;
   
   // add a new shape function with parameters
@@ -1000,7 +1101,7 @@ bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
   pd << "], [";
   if (fieldList.size() > 0)
   {
-    std::list<Handle(GEOM_Object)>::iterator itField = fieldList.begin();
+    std::list<Handle(GEOM_Field)>::iterator itField = fieldList.begin();
     pd << (*itField++);
     while (itField != fieldList.end())
     {
@@ -1017,8 +1118,8 @@ bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
 }
 
 void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
-                                                Handle(GEOM_Function) function, int shapeType, int dim,
-                                                Handle(TColStd_HSequenceOfTransient)& subShapeList)
+                                                 Handle(GEOM_Function) function, int shapeType, int dim,
+                                                 Handle(TColStd_HSequenceOfTransient)& subShapeList)
 {
   Handle(GEOM_Object) subShape;
   Handle(GEOM_Function) aFunction;
@@ -1070,10 +1171,10 @@ void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
  */
 //=============================================================================
 bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
-                                          Handle(GEOM_Object)& shape,
-                                          Handle(TColStd_HSequenceOfTransient)& subShapes,
-                                          Handle(TColStd_HSequenceOfTransient)& groups,
-                                          Handle(TColStd_HSequenceOfTransient)& fields)
+                                           Handle(GEOM_Object)& shape,
+                                           Handle(TColStd_HSequenceOfTransient)& subShapes,
+                                           Handle(TColStd_HSequenceOfTransient)& groups,
+                                           Handle(TColStd_HSequenceOfTransient)& fields)
 {
   SetErrorCode(KO);
   
@@ -1158,7 +1259,102 @@ bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
     function = group->GetLastFunction();
   }
   
-  // TODO: create the fields
+  // create the fields
+  int nbFields = xaoObject->countFields();
+  for (int i = 0; i < nbFields; ++i)
+  {
+    XAO::Field* xaoField = xaoObject->getField(i);
+
+    Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents());
+    for (int j = 0; j < xaoField->countComponents(); ++j)
+    {
+        components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str());
+    }
+
+    Handle(GEOM_Field) field = myFieldOperations->CreateField(shape,
+                 xaoField->getName().c_str(),
+                 (int)xaoField->getType(),
+                 (int)xaoField->getDimension(),
+                 components);
+
+    switch (xaoField->getType())
+    {
+        case XAO::BOOLEAN:
+        {
+            XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField;
+            for (int j = 0; j < xaoField->countSteps(); ++j)
+            {
+                XAO::BooleanStep* bstep = bfield->getStep(j);
+                Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp());
+
+                Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues());
+                std::vector<bool> bvalues = bstep->getValues();
+                for (int k = 0; k < bstep->countValues(); ++k)
+                {
+                    values->SetValue(0, bvalues[k] ? 1 : 0);
+                }
+                step->SetValues(values);
+            }
+            break;
+        }
+        case XAO::INTEGER:
+        {
+            XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField;
+            for (int j = 0; j < xaoField->countSteps(); ++j)
+            {
+                XAO::IntegerStep* istep = ifield->getStep(j);
+                Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp());
+
+                Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues());
+                std::vector<int> ivalues = istep->getValues();
+                for (int k = 0; k < istep->countValues(); ++k)
+                {
+                    values->SetValue(0, ivalues[k]);
+                }
+                step->SetValues(values);
+            }
+            break;
+        }
+        case XAO::DOUBLE:
+        {
+            XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField;
+            for (int j = 0; j < xaoField->countSteps(); ++j)
+            {
+                XAO::DoubleStep* dstep = dfield->getStep(j);
+                Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp());
+
+                Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues());
+                std::vector<double> dvalues = dstep->getValues();
+                for (int k = 0; k < dstep->countValues(); ++k)
+                {
+                    values->SetValue(0, dvalues[k]);
+                }
+                step->SetValues(values);
+            }
+            break;
+        }
+        case XAO::STRING:
+        {
+            XAO::StringField* sfield = (XAO::StringField*)xaoField;
+            for (int j = 0; j < xaoField->countSteps(); ++j)
+            {
+                XAO::StringStep* sstep = sfield->getStep(j);
+                Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp());
+
+                Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues());
+                std::vector<std::string> svalues = sstep->getValues();
+                for (int k = 0; k < sstep->countValues(); ++k)
+                {
+                    values->SetValue(0, TCollection_ExtendedString(svalues[k].c_str()));
+                }
+                step->SetValues(values);
+            }
+            break;
+        }
+    }
+
+    fields->Append(field);
+  }
   
   // make a Python command
   GEOM::TPythonDump pd(function);
index d5b7befbfda69777c824a21cb0fa2b73318881df..3173e545e5cdb072bfee6ea0016cab841f2bcf5c 100644 (file)
@@ -26,6 +26,7 @@
 #include "GEOM_IOperations.hxx"
 #include "GEOM_Engine.hxx"
 #include "GEOM_Object.hxx"
+#include "GEOM_Field.hxx"
 
 #include <Basics_OCCTVersion.hxx>
 
@@ -40,6 +41,7 @@
 
 class GEOMImpl_IShapesOperations;
 class GEOMImpl_IGroupOperations;
+class GEOMImpl_IFieldOperations;
 
 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
 class Handle_TColStd_HArray1OfByte;
@@ -101,36 +103,37 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
                                                            int& theWidth, int& theHeight);
 
   Standard_EXPORT std::list<int> GetAllTextures();
-                                                          
+
   Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
-                                std::list<Handle(GEOM_Object)> groupList,
-                                std::list<Handle(GEOM_Object)> fieldList,
-                                const char* author,
-                                const char* fileName);
+                                 std::list<Handle(GEOM_Object)> groupList,
+                                 std::list<Handle(GEOM_Field)> fieldList,
+                                 const char* author,
+                                 const char* fileName);
 
   Standard_EXPORT bool ImportXAO(const char* fileName,
-                                Handle(GEOM_Object)& shape,
-                                Handle(TColStd_HSequenceOfTransient)& subShapes,
-                                Handle(TColStd_HSequenceOfTransient)& groups,
-                                Handle(TColStd_HSequenceOfTransient)& fields);
+                                 Handle(GEOM_Object)& shape,
+                                 Handle(TColStd_HSequenceOfTransient)& subShapes,
+                                 Handle(TColStd_HSequenceOfTransient)& groups,
+                                 Handle(TColStd_HSequenceOfTransient)& fields);
 
  private:
   Standard_Boolean InitResMgr ();
 
   void importSubShapes(XAO::Geometry* xaoGeometry, Handle(GEOM_Function) function,
-                      int shapeType, int dim,
-                      Handle(TColStd_HSequenceOfTransient)& subshapeList);
+                       int shapeType, int dim,
+                       Handle(TColStd_HSequenceOfTransient)& subshapeList);
   void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry);
-  void exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject,
-                   XAO::BrepGeometry* geometry);
+  void exportFields(std::list<Handle(GEOM_Field)> fieldList, XAO::Xao* xaoObject,
+                    XAO::BrepGeometry* geometry);
   void exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject,
-                   XAO::BrepGeometry* geometry);
+                    XAO::BrepGeometry* geometry);
 
  private:
   Handle(Resource_Manager) myResMgr;
   Handle(Resource_Manager) myResMgrUser;
   GEOMImpl_IShapesOperations* myShapesOperations;
   GEOMImpl_IGroupOperations* myGroupOperations;
+  GEOMImpl_IFieldOperations* myFieldOperations;
 };
 
 #endif
index d4818618fdd4b452ee77b6bcd047931995814212..217655cf6122d4c7049d3ebd1664c5f47c2caddf 100644 (file)
@@ -373,8 +373,10 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
  */
 //=============================================================================
 CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
-                                                  const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
-                                                  const char* author, const char* fileName)
+                                                   const GEOM::ListOfGO& groups,
+                                                   const GEOM::ListOfFields&  fields,
+                                                   const char* author,
+                                                   const char* fileName)
 {
   bool isGood = false;
   // Set a not done flag
@@ -392,13 +394,13 @@ CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
     if (gobj.IsNull()) return false;
     groupsObj.push_back(gobj);
   }
-  
+
   // Get the reference fields
   ind = 0;
-  std::list<Handle(GEOM_Object)> fieldsObj;
+  std::list<Handle(GEOM_Field)> fieldsObj;
   for (; ind < fields.length(); ind++)
   {
-    Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]);
+    Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
     if (fobj.IsNull()) return false;
     fieldsObj.push_back(fobj);
   }
@@ -424,17 +426,17 @@ CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
  */
 //=============================================================================
 CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
-                                                  GEOM::GEOM_Object_out shape,
-                                                  GEOM::ListOfGO_out subShapes,
-                                                  GEOM::ListOfGO_out groups,
-                                                  GEOM::ListOfGO_out fields)
+                                                   GEOM::GEOM_Object_out shape,
+                                                   GEOM::ListOfGO_out subShapes,
+                                                   GEOM::ListOfGO_out groups,
+                                                   GEOM::ListOfFields_out fields)
 {
   GEOM::GEOM_Object_var vshape;
   shape = vshape._retn();
   
   subShapes = new GEOM::ListOfGO;
   groups = new GEOM::ListOfGO;
-  fields = new GEOM::ListOfGO;
+  fields = new GEOM::ListOfFields;
   
   // Set a not done flag
   GetOperations()->SetNotDone();
@@ -469,7 +471,8 @@ CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
   fields->length(n);
   for (int i = 1; i <= n; i++)
   {
-    (*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i)));
+      // TODO: FPS
+      //(*fields)[i - 1] = GetObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i)));
   }
   
   shape = GetObject(hshape);
index aca7a55f758c5e307e25492244db163679984a81..69bd1cdf48251da0c248dad8e7ad192b409cba9b 100644 (file)
@@ -74,16 +74,16 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
   GEOM::ListOfLong* GetAllTextures();
   
   CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape,
-                           const GEOM::ListOfGO& groups,
-                           const GEOM::ListOfGO& fields,
-                           const char* author,
-                           const char* fileName);
+                            const GEOM::ListOfGO& groups,
+                            const GEOM::ListOfFields&  fields,
+                            const char* author,
+                            const char* fileName);
 
   CORBA::Boolean ImportXAO (const char* fileName,
-                           GEOM::GEOM_Object_out shape,
-                           GEOM::ListOfGO_out subShapes,
-                           GEOM::ListOfGO_out groups,
-                           GEOM::ListOfGO_out fields);
+                            GEOM::GEOM_Object_out shape,
+                            GEOM::ListOfGO_out subShapes,
+                            GEOM::ListOfGO_out groups,
+                            GEOM::ListOfFields_out fields);
   
   ::GEOMImpl_IInsertOperations* GetOperations()
   { return (::GEOMImpl_IInsertOperations*)GetImpl(); }
index 2d563ef8c10990a2825e87f4bc62a6bdd545ab11..946f958d29bdf8e8714993ca95f092443680fcbb 100644 (file)
@@ -3332,7 +3332,7 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup)
 //  ExportXAO
 //=============================================================================
 CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
-                                        const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
+                                        const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
                                         const char* author, const char* fileName)
 {
   beginService( " GEOM_Superv_i::ExportXAO" );
@@ -3347,7 +3347,7 @@ CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
 //  ImportXAO
 //=============================================================================
 CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape, 
-                                        GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields)
+                                        GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields)
 {
   return false;
 }
index 6136b3e74c735154cc6dd0cbbba5e9cd74e0ec43..daff0facb57168e52f0efe84cb77b97517fed803 100644 (file)
@@ -692,10 +692,10 @@ public:
   // ImportExport Operations                                   //
   //-----------------------------------------------------------//
   CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
-                           const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
+                           const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
                            const char* author, const char* fileName);
   CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape, 
-                           GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields);
+                           GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields);
 
   //-----------------------------------------------------------//
   // Advanced Operations                                       //
index 93651b27c6c26e3951ae585d16c171d6702cab82..4cf4408b837e791bdf42fd0fa899fe2565a0d4c1 100644 (file)
 
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_OverrideCursor.h>
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
 #include <LightApp_SelectionMgr.h>
 
 #include <QLabel>
@@ -32,7 +34,6 @@
 #include <QListWidget>
 #include <QFileDialog>
 #include <QMap>
-//#include <ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h>
 
 // OCCT Includes
 #include <TopoDS_Shape.hxx>
@@ -43,7 +44,6 @@
 
 #include <GEOMImpl_Types.hxx>
 #include "ImportExportGUI_ExportXAODlg.h"
-//#include "ImportExportGUI_Widgets.h"
 
 //=================================================================================
 // Constructor
@@ -137,7 +137,7 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometry
     lstGroups = new QListWidget(gbxFilter);
     lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection);
     lstFields = new QListWidget(gbxFilter);
-    lstFields   ->setSelectionMode(QAbstractItemView::ExtendedSelection);
+    lstFields->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
     line++; col = 0;
     gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1);
@@ -184,7 +184,6 @@ void ImportExportGUI_ExportXAODlg::Init()
 
     connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
 
-
     initName(tr("GEOM_EXPORTXAO"));
     SelectionIntoArgument();
 }
@@ -217,11 +216,25 @@ void ImportExportGUI_ExportXAODlg::processObject()
             item->setData(Qt::UserRole, QVariant(i));
             item->setText(GEOMBase::GetName(groups[i]));
             lstGroups->addItem(item);
+            item->setSelected(true);
             m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
         }
         lstGroups->sortItems(Qt::AscendingOrder);
 
-        // TODO: add fields
+        // add fields
+        GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId());
+
+        GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj);
+        for (int i = 0, n = fields->length(); i < n; i++)
+        {
+            QListWidgetItem* item = new QListWidgetItem();
+            item->setData(Qt::UserRole, QVariant(i));
+            item->setText(fields[i]->GetName());
+            lstFields->addItem(item);
+            item->setSelected(true);
+            m_fields.append(GEOM::GeomFieldPtr(fields[i].in()));
+        }
+        lstFields->sortItems(Qt::AscendingOrder);
     }
 }
 
@@ -231,8 +244,10 @@ void ImportExportGUI_ExportXAODlg::processObject()
 //=================================================================================
 void ImportExportGUI_ExportXAODlg::ClickOnOk()
 {
+    setIsApplyAndClose(true);
     if (ClickOnApply())
         ClickOnCancel();
+    setIsApplyAndClose(false);
 }
 
 //=================================================================================
@@ -241,10 +256,46 @@ void ImportExportGUI_ExportXAODlg::ClickOnOk()
 //=================================================================================
 bool ImportExportGUI_ExportXAODlg::ClickOnApply()
 {
-    if (!onAccept())
+    if (!isApplyAndClose())
+    {
+        setIsDisableBrowsing(true);
+        setIsDisplayResult(false);
+    }
+
+    QString msg;
+    if (!isValid(msg))
+    {
+        showError(msg);
         return false;
+    }
+    SUIT_OverrideCursor wc;
+    SUIT_Session::session()->activeApplication()->putInfo("");
 
-    initName();
+    try
+    {
+        if (openCommand())
+            if (!execute(/*isApplyAndClose()*/))
+            {
+                abortCommand();
+                showError();
+                return false;
+            }
+    }
+    catch (const SALOME::SALOME_Exception& e)
+    {
+        SalomeApp_Tools::QtCatchCorbaException(e);
+        abortCommand();
+        return false;
+    }
+    commitCommand();
+
+    if (!isApplyAndClose())
+    {
+        setIsDisableBrowsing(false);
+        setIsDisplayResult(true);
+    }
+
+    processObject();
 
     return true;
 }
@@ -343,7 +394,7 @@ bool ImportExportGUI_ExportXAODlg::isValid(QString& msg)
 // function : execute
 // purpose  :
 //=================================================================================
-bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
+bool ImportExportGUI_ExportXAODlg::execute()
 {
     bool res = false;
 
@@ -364,8 +415,9 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
 
     // get selected fields
     QList<QListWidgetItem*> selFields = lstFields->selectedItems();
-    GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
+    GEOM::ListOfFields_var fields = new GEOM::ListOfFields();
     fields->length(m_fields.count());
+    i = 0;
     for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it)
     {
         QListWidgetItem* item = (*it);
@@ -376,8 +428,8 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
     // call engine function
     GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
     res = ieOp->ExportXAO(m_mainObj, groups, fields,
-            author.toStdString().c_str(),
-            fileName.toStdString().c_str());
+                          author.toStdString().c_str(),
+                          fileName.toStdString().c_str());
 
     return res;
 }
index 1f009b8d625eeda7a52147a1d7bbb16a4484bf44..2beb2989b516cb43d6ce2419539ccbb4eb3f0b08 100644 (file)
@@ -44,7 +44,7 @@ protected:
     // redefined from GEOMBase_Helper
     virtual GEOM::GEOM_IOperations_ptr createOperation();
     virtual bool isValid(QString&);
-    virtual bool execute(ObjectList&);
+    virtual bool execute();
 
 private:
     void Init();
@@ -54,7 +54,7 @@ private:
 private:
     GEOM::GEOM_Object_var m_mainObj;
     QList<GEOM::GeomObjPtr> m_groups;
-    QList<GEOM::GeomObjPtr> m_fields;
+    QList<GEOM::GeomFieldPtr> m_fields;
     QLineEdit* ledShape;
     QLineEdit* ledFileName;
     QLineEdit* ledAuthor;
@@ -67,7 +67,6 @@ private slots:
     void ClickOnOk();
     bool ClickOnApply();
     void ActivateThisDialog();
-//  void LineEditReturnPressed();
     void SelectionIntoArgument();
     void SetEditCurrentArgument();
     void btnFileSelectClicked();
index fe2200947b46342eda21b71e9b1fcd4f14171119..e3b17f678a67aad876a17e1a46b02321d471465a 100644 (file)
@@ -156,7 +156,7 @@ bool ImportExportGUI_ImportXAODlg::ClickOnApply()
 void ImportExportGUI_ImportXAODlg::btnFileSelectClicked()
 {
     QString selFile = QFileDialog::getOpenFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
-            QString(), tr("XAO_FILES"));
+                                                   QString(), tr("XAO_FILES"));
     if (!selFile.isEmpty())
     {
         ledFileName->setText(selFile);
@@ -214,7 +214,8 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
 
     QString fileName = ledFileName->text();
     GEOM::GEOM_Object_var shape;
-    GEOM::ListOfGO_var groups, fields, subShapes;
+    GEOM::ListOfGO_var groups, subShapes;
+    GEOM::ListOfFields_var fields;
 
     GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
     res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields);
@@ -239,7 +240,7 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
     }
     for (int i = 0; i < fields->length(); i++)
     {
-        objects.push_back(GEOM::GEOM_Object::_duplicate(fields[i]));
+        //objects.push_back(GEOM::GEOM_Field::_duplicate(fields[i]));
     }
 
     return res;
index b774b31af9ceada68cf28e95adff8735f48d0518..38cbb0226ed8ae59abf8aa53851847a5d4682981 100644 (file)
@@ -67,6 +67,8 @@ throw (XAO_Exception)
         return countFaces();
     if (dim == XAO::SOLID)
         return countSolids();
+    if (dim == XAO::WHOLE)
+        return 1;
 
     throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
 }
index d41b1f74f31a875536458bac1f9b05fbc03a3ed2..bd34efafb2354a80167cba36ad47df041bd995b9 100644 (file)
@@ -86,7 +86,7 @@ namespace {
     xmlDocPtr exportXMLDoc(Xao* xaoObject);
     void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
     void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
-                                XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
+                                 XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
     void exportGroups(Xao* xaoObject, xmlNodePtr xao);
     void exportFields(Xao* xaoObject, xmlNodePtr xao);
     void exportStep(Step* step, Field* field, xmlNodePtr nodeSteps);
@@ -109,13 +109,13 @@ namespace {
     void parseStepElementNode(xmlNodePtr eltNode, Step* step);
 
     std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
-                              const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
+                               const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
     int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
-                       const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
+                        const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
 
   std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
-                            const bool& required, const std::string& defaultValue,
-                            const std::string& exception /*= std::string() */)
+                             const bool& required, const std::string& defaultValue,
+                             const std::string& exception /*= std::string() */)
   {
     xmlChar* strAttr = xmlGetProp(node, attribute);
     if (strAttr == NULL)
@@ -138,8 +138,8 @@ namespace {
   }
 
   int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
-                     const bool& required, const int& defaultValue,
-                     const std::string& exception /*= std::string() */)
+                      const bool& required, const int& defaultValue,
+                      const std::string& exception /*= std::string() */)
   {
     xmlChar* strAttr = xmlGetProp(node, attribute);
     if (strAttr == NULL)
@@ -183,7 +183,7 @@ namespace {
   }
 
   void exportGeometricElements(Geometry* xaoGeometry,
-                              xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
+                               xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
   {
     xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
     xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countElements(dim)).c_str());
@@ -592,12 +592,16 @@ namespace {
             int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1);
             xmlChar* data = xmlNodeGetContent(valNode->children);
 
-            if (data == NULL)
+            std::string value = (char*)data;
+            if (data != NULL)
+            {
+                value = (char*)data;
+            }
+            else if (step->getType() != XAO::STRING)
             {
                 throw XAO_Exception(MsgBuilder() << "Line " << valNode->line << ": no content for value.");
             }
 
-            std::string value = (char*)data;
             step->setStringValue(index, component, value);
         }
     }