]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
debug export XAO
authorfps <fps@opencascade.com>
Wed, 10 Apr 2013 12:53:46 +0000 (12:53 +0000)
committerfps <fps@opencascade.com>
Wed, 10 Apr 2013 12:53:46 +0000 (12:53 +0000)
15 files changed:
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx
src/ImportExportGUI/ImportExportGUI.cxx
src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx
src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h
src/Makefile.am
src/XAO/GeometricElement.cxx
src/XAO/GeometricElement.hxx
src/XAO/Geometry.cxx
src/XAO/Geometry.hxx
src/XAO/Group.hxx
src/XAO/Makefile.am
src/XAO/Xao.cxx
src/XAO/tests/ImportExportTest.cxx

index 5a21f005d8cbfe921862db89d5d39ea2d387b945..1e7b044857224026ebd56f45712777fdf5a239a3 100644 (file)
@@ -4013,14 +4013,14 @@ module GEOM
   {
     /*!
      *  Export a shape to XAO Format
-     *  \param theExportingShape Shape to export
-     *  \param theFileName The name of the exported file
-     *  \param thelGroups List of groups to export
-     *  \param thelFields List of fields to export
-     *  \return New GEOM_Object, containing the created shape.
+     *  \param exportingShape Shape to export
+     *  \param fileName The name of the exported file
+     *  \param groups List of groups to export
+     *  \param fields List of fields to export
+     *  \return boolean indicating if export was succeful.
      */
 
-     boolean ExportXAO (in GEOM_Object theExportingShape, in string theFileName, in ListOfGO thelGroups, in ListOfGO thelFields);
+     boolean ExportXAO(in GEOM_Object shape, in string fileName, in ListOfGO groups, in ListOfGO fields);
 
     /*@@ insert new functions before this line @@ do not remove this line @@*/
   };
index 1e29b3e6a6daf03c10e3bc48c9be4a3b308632b2..0ba232316bab42d9a916217457ce98610550299c 100644 (file)
@@ -626,7 +626,7 @@ module GEOM
     //-----------------------------------------------------------//
     // ImportExportOperations                                    //
     //-----------------------------------------------------------//
-    boolean ExportXAO (in GEOM_Object theExportingShape, in string theFileName, in GEOM_List thelGroups, in GEOM_List thelFields);
+    boolean ExportXAO(in GEOM_Object exportingShape, in string fileName, in GEOM_List groups, in GEOM_List fields);
 
     /*@@ insert new functions before this line @@ do not remove this line @@*/
  };
index 36bf1f3b75bd6789740143e1a593c3967450ab47..b2bb65309beb0e86e71f4ae21a55ff1ff5939c4c 100644 (file)
@@ -92,14 +92,6 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine*
         GEOM_IOperations(engine, docID)
 {
     MESSAGE("GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations");
-    /*myBasicOperations     = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID());
-     myBooleanOperations   = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID());
-     myShapesOperations    = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
-     myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID());
-     myBlocksOperations    = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID());
-     my3DPrimOperations    = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID());
-     myLocalOperations     = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID());
-     myHealingOperations   = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID());*/
     m_shapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
     m_groupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
 }
@@ -112,14 +104,6 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine*
 GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations()
 {
     MESSAGE("GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations");
-    /*delete myBasicOperations;
-     delete myBooleanOperations;
-     delete myShapesOperations;
-     delete myTransformOperations;
-     delete myBlocksOperations;
-     delete my3DPrimOperations;
-     delete myLocalOperations;
-     delete myHealingOperations;*/
     delete m_shapesOperations;
     delete m_groupOperations;
 }
@@ -139,11 +123,7 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
         std::list<Handle(GEOM_Object)> groupList,
         std::list<Handle(GEOM_Object)> fieldList)
 {
-    std::cout << ">> ExportXAO" << std::endl;
     SetErrorCode(KO);
-    bool isGood = false;
-
-    //
 
     // add a new shape function with parameters
     Handle(GEOM_Function) lastFunction = shape->GetLastFunction();
@@ -163,72 +143,17 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
     if (exportFunction->GetDriverGUID() != GEOMImpl_ExportXAODriver::GetID())
         return false;
 
-    /*GEOMImpl_IExportXAO aData (aRefFunction);
-
-     TCollection_AsciiString FileName = theFileName.c_str();
-     aData.SetExportingShape(aRefFunction);
-     aData.SetFileName(FileName);
-     aData.SetlGroups(thelGroups);
-     aData.SetlFields(thelFields);
-
-     //Compute the resulting value
-     try {
-     #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
-     OCC_CATCH_SIGNALS;
-     #endif
-     if (!GetSolver()->ComputeFunction(aFunction)) {
-     SetErrorCode("ExportXAO driver failed : Not enough space on disk, or you haven't permissions to write this directory");
-     return false;
-     }
-     }
-     catch (Standard_Failure) {
-     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-     SetErrorCode(aFail->GetMessageString());
-     return false;
-     }*/
     XAO::Xao* xaoObject = new XAO::Xao();
 
     XAO::Geometry* geometry = new XAO::Geometry();
     TopoDS_Shape topoShape = shape->GetValue();
-    std::ostringstream dumpStream;
-    BRepTools::Dump(topoShape, dumpStream);
-    geometry->setShape(dumpStream.str().c_str());
+    geometry->setShape(topoShape);
     geometry->setName(shape->GetName());
 
     Handle(TColStd_HSequenceOfTransient) subObjects = m_shapesOperations->GetExistingSubObjects(shape, false);
     int nbSubObjects = subObjects->Length();
-    std::cout << "nb sub obj = " << nbSubObjects << std::endl;
-    int nbVertices = 0, nbEdges = 0, nbFaces = 0, nbSolids = 0, nbGroups = 0;
-    for (int i = 1; i <= nbSubObjects; i++)
-    {
-        Handle(Standard_Transient) transientSubObject = subObjects->Value(i);
-        if (transientSubObject.IsNull())
-            continue;
-
-        Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast(transientSubObject);
-        if (subObject->GetType() == GEOM_GROUP)
-        {
-            nbGroups++;
-        }
-        else
-        {
-            switch (subObject->GetValue().ShapeType())
-            {
-                case TopAbs_VERTEX: nbVertices++; break;
-                case TopAbs_EDGE: nbEdges++; break;
-                case TopAbs_FACE: nbFaces++; break;
-                case TopAbs_SOLID: nbSolids++; break;
-            }
-        }
-    }
 
-    std::cout << "Nb = " << nbVertices << ", " << nbEdges << ", " << nbFaces << ", " << nbSolids << ", " << nbGroups << std::endl;
-    if (nbVertices > 0) geometry->setCountVertices(nbVertices);
-    if (nbEdges > 0) geometry->setCountEdges(nbEdges);
-    if (nbFaces > 0) geometry->setCountFaces(nbFaces);
-    if (nbSolids > 0) geometry->setCountSolids(nbSolids);
-
-    int vInd = 0, eInd = 0, fInd = 0, sInd = 0;
+    int tmpIndex;
     for (int i = 1; i <= nbSubObjects; i++)
     {
         Handle(Standard_Transient) transientSubObject = subObjects->Value(i);
@@ -236,79 +161,94 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
             continue;
 
         Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast(transientSubObject);
-        std::cout << " sub[" << i << "] N=" << subObject->GetName()
-                //<< " E=" << subObject->GetEntry()
-                //<< " D=" << subObject->GetDocID()
-                << " T=" << subObject->GetType() << std::endl;
         if (subObject->GetType() != GEOM_GROUP)
         {
-            int index = m_shapesOperations->GetSubShapeIndex(shape, subObject);
-            const char* strIndex = XAO::XaoUtils::intToString(index);
-            std::cout << "    index= " << index << std::endl;
+            int subIndex = m_shapesOperations->GetSubShapeIndex(shape, subObject);
+            // convert index to a string
+            std::stringstream str;
+            str << subIndex;
+            std::string strIndex = str.str();
+
             switch (subObject->GetValue().ShapeType())
             {
                 case TopAbs_VERTEX:
-                    geometry->setVertex(vInd++, subObject->GetName(), strIndex);
+                    tmpIndex = geometry->getVertexIndexByReference(strIndex.c_str());
+                    geometry->setVertexName(tmpIndex, subObject->GetName());
                     break;
                 case TopAbs_EDGE:
-                    geometry->setEdge(eInd++, subObject->GetName(), strIndex);
+                    tmpIndex = geometry->getEdgeIndexByReference(strIndex.c_str());
+                    geometry->setEdgeName(tmpIndex, subObject->GetName());
                     break;
                 case TopAbs_FACE:
-                    geometry->setFace(fInd++, subObject->GetName(), strIndex);
+                    tmpIndex = geometry->getFaceIndexByReference(strIndex.c_str());
+                    geometry->setFaceName(tmpIndex, subObject->GetName());
                     break;
                 case TopAbs_SOLID:
-                    geometry->setSolid(sInd++, subObject->GetName(), strIndex);
+                    tmpIndex = geometry->getSolidIndexByReference(strIndex.c_str());
+                    geometry->setSolidName(tmpIndex, subObject->GetName());
                     break;
             }
         }
     }
     xaoObject->setGeometry(geometry);
 
-    xaoObject->exportToFile(fileName.c_str());
-
-    /*
     // adding groups
     std::list<Handle(GEOM_Object)>::iterator itG1 = groupList.begin();
-    int gInd = 0;
     while (itG1 != groupList.end())
     {
-        std::cout << "Group = " << gInd++ << std::endl;
         Handle(GEOM_Object) itGroup = (*itG1++);
-        XAO::Group* group = new XAO::Group();
-        group->setName(itGroup->GetName());
         Handle(TColStd_HArray1OfInteger) groupIds = m_groupOperations->GetObjects(itGroup);
         TopAbs_ShapeEnum shapeGroup = m_groupOperations->GetType(itGroup);
-        std::cout << "GroupShape = " << shapeGroup << std::endl;
-        if (shapeGroup == TopAbs_VERTEX)
+
+        XAO::Group* group = new XAO::Group();
+        group->setName(itGroup->GetName());
+        switch (shapeGroup)
         {
-            group->setDimension(0);
-            for (int i = 1; i <= groupIds->Length(); i++)
-            {
-                const char* index = geometry->getVertexReference(groupIds->Value(i));
-                group->addElement(index);
-            }
+            case TopAbs_VERTEX:
+                group->setDimension(0);
+                for (int i = 1; i <= groupIds->Length(); i++)
+                {
+                    const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+                    const int index = geometry->getVertexIndexByReference(ref);
+                    group->addElement(index);
+                }
+                break;
+            case TopAbs_EDGE:
+                group->setDimension(1);
+                for (int i = 1; i <= groupIds->Length(); i++)
+                {
+                    const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+                    const int index = geometry->getEdgeIndexByReference(ref);
+                    group->addElement(index);
+                }
+                break;
+            case TopAbs_FACE:
+                group->setDimension(2);
+                for (int i = 1; i <= groupIds->Length(); i++)
+                {
+                    const char* ref = XAO::XaoUtils::intToString((int)(groupIds->Value(i)));
+                    const int index = geometry->getFaceIndexByReference(ref);
+                    group->addElement(index);
+                }
+                break;
+            case TopAbs_SOLID:
+                group->setDimension(3);
+                for (int i = 1; i <= groupIds->Length(); i++)
+                {
+                    const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+                    const int index = geometry->getSolidIndexByReference(ref);
+                    group->addElement(index);
+                }
+                break;
         }
+
         xaoObject->addGroup(group);
-        /*{
-         case TopAbs_SOLID:
-         Group->setType(3);
-         break;
-         case TopAbs_FACE:
-         Group->setType(2);
-         break;
-         case TopAbs_EDGE:
-         Group->setType(1);
-         break;
-         case TopAbs_VERTEX:
-         Group->setType(0);
-         break;
-         }  *
-
-    }*/
-
-    /*
+    }
+
+    xaoObject->exportToFile(fileName.c_str());
+
     // make a Python command
-    TCollection_AsciiString fileNameStr = fileName.c_str();
+    /*TCollection_AsciiString fileNameStr = fileName.c_str();
     GEOM::TPythonDump pd(exportFunction);
     std::list<Handle(GEOM_Object)>::iterator itG = groupList.begin();
     std::list<Handle(GEOM_Object)>::iterator itF = fieldList.begin();
@@ -329,6 +269,6 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
 
     SetErrorCode(OK);
 
-    return isGood;
+    return true;
 }
 /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
index 05eba148bc54f2113748d5a9f8c83fc1d5ca90fe..a79265304ed58bc790efb78c1032c0defc482c6d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 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
@@ -65,7 +65,6 @@ bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent)
 
     getGeometryGUI()->EmitSignalDeactivateDialog();
 
-
     QDialog* dialog = NULL;
     switch (commandId)
     {
index 9fc2dc54516b71310bfc86601c48ef8d9b26a7d6..4e069442d7623b0eaa64d744a07e41a798065407 100644 (file)
@@ -167,12 +167,13 @@ void ImportExportGUI_ExportXAODlg::processObject()
     else
     {
         ledShape->setText(GEOMBase::GetName(m_mainObj));
-        GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations(getStudyId());
-        GEOM::ListOfGO_var Groups = aShOp->GetExistingSubObjects(m_mainObj, true);
-        // Affichage des noms des groupes
-        for (int i = 0, n = Groups->length(); i < n; i++)
+        GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+        GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true);
+        // add groups names
+        for (int i = 0, n = groups->length(); i < n; i++)
         {
-            lstGroups->addItem(GEOMBase::GetName(Groups[i]));
+            lstGroups->addItem(GEOMBase::GetName(groups[i]));
+            m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
         }
     }
 }
@@ -296,20 +297,16 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
     GEOM::ListOfGO_var groups = shapesOp->GetExistingSubObjects(m_mainObj, true);
     GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
 
-    std::cout << " == Groups" << std::endl;
     groups->length(m_groups.count());
     for (int i = 0; i < m_groups.count(); i++)
         groups[i] = m_groups[i].copy();
 
-    std::cout << " == Fields" << std::endl;
     fields->length(m_fields.count());
     for (int i = 0; i < m_fields.count(); i++)
         fields[i] = m_fields[i].copy();
 
     // call engine function
-    std::cout << " >> ExportXAO" << std::endl;
     res = ieOp->ExportXAO(m_mainObj, ledFileName->text().toStdString().c_str(), groups, fields);
-    std::cout << " << ExportXAO" << std::endl;
 
     return res;
 }
index 825071e31d44c007d938880e006722995dea8aac..c0c2126735a7cf2187a292d6e2b57776ca4c3ce3 100644 (file)
@@ -55,7 +55,6 @@ private:
     GEOM::GEOM_Object_var m_mainObj;
     QList<GEOM::GeomObjPtr> m_groups;
     QList<GEOM::GeomObjPtr> m_fields;
-    //ImportExportGUI_1Sel1LineEdit2ListWidget*   myGrp;
     QLineEdit* ledShape;
     QLineEdit* ledFileName;
     QListWidget* lstGroups;
@@ -69,8 +68,6 @@ private slots:
     void LineEditReturnPressed();
     void SelectionIntoArgument();
     void SetEditCurrentArgument();
-    //void ValueChangedInSpinBox();
-    //void SetDoubleSpinBoxStep( double );
 };
 
 #endif // IMPORTEXPORTGUI_EXPORTXAODLG_H
index 6e93da55079e0b7779e1f11f99a76eaec40ee4f1..873ea299c5ecf0c26f49724144ac82a526992a26 100644 (file)
@@ -37,6 +37,10 @@ if GEOM_ENABLE_GUI
              GroupGUI BlocksGUI AdvancedGUI ImportExportGUI GEOM_SWIG_WITHIHM
 endif
 
+if CPPUNIT_IS_OK
+  SUBDIRS += XAO/tests
+endif
+
 DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \
                SKETCHER OCC2VTK GEOM BREPExport \
                BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \
index 4979b184b92a6aac2e03773c6b59c4484d36cac5..264ddd386525da8ec04d323e037d0d81c36a26c1 100644 (file)
@@ -18,6 +18,7 @@
 //
 // Author : Frederic Pons (OpenCascade)
 
+#include <cstring>
 #include <Utils_SALOME_Exception.hxx>
 
 #include "GeometricElement.hxx"
@@ -71,7 +72,6 @@ void GeometricElementList::setElement(const int index, const char* name, const c
     m_elements[index].setReference(reference);
 }
 
-
 const char* GeometricElementList::getName(const int index)
 {
     if (m_count == 0 || index > m_count)
@@ -103,3 +103,19 @@ void GeometricElementList::setReference(const int index, const char* name)
 
     m_elements[index].setReference(name);
 }
+
+const int GeometricElementList::getIndexByReference(const char* ref)
+{
+    for (int index = 0; index < m_count; ++index)
+    {
+        if (strcmp(ref, m_elements[index].getReference()) == 0)
+        {
+            return index;
+        }
+    }
+
+    return 0;
+//    std::string msg = "Cannot find element with reference ";
+//    msg += name;
+//    throw SALOME_Exception(msg.c_str());
+}
index 3863b5849478ecfad44a3433cc9d183cfd95ca32..93e15b3bd1ac8180fe382c6bb3c09a87865e1e30 100644 (file)
@@ -75,6 +75,7 @@ namespace XAO
         void setName(const int index, const char* name);
         const char* getReference(const int index);
         void setReference(const int index, const char* reference);
+        const int getIndexByReference(const char* reference);
 
     private:
         int m_count;
index efade0422b9f3c5ae2cb5413ebeb32db7001fc00..5dc25f7510fd8a5bf42ef23783bd7a36de90954a 100644 (file)
@@ -85,53 +85,6 @@ const char* Geometry::getBREP()
     return streamShape.str().c_str();
 }
 
-/*
-void Geometry::changeVertexName(int id, const char* name)
-{
-    if (m_nbVertices == 0)
-        Standard_TypeMismatch::Raise("Problem with number of vertices");
-
-    if (m_verticesNames == NULL)
-        m_verticesNames = new std::string[m_nbVertices];
-
-    int index = findVertex(id);
-
-    if (index == -1)
-        Standard_TypeMismatch::Raise("Problem with the id of the vertex");
-
-    m_verticesNames[index] = name;
-}
-
-const char* Geometry::findVertexName(int id)
-{
-    if (m_nbVertices == 0)
-    {
-        Standard_TypeMismatch::Raise("Problem with number of vertices");
-        return "";
-    }
-
-    int index = findVertex(id);
-
-    if (index == -1)
-    {
-        Standard_TypeMismatch::Raise("Problem with the id of the vertex");
-        return "";
-    }
-
-    return m_verticesNames[index].c_str();
-}*/
-/*
-int Geometry::findVertex(int id)
-{
-    int index = -1;
-    for (int i = 0, n = m_nbVertices; i < n; i++)
-    {
-        if (m_verticesIds[i] == id)
-            return i;
-    }
-    return index;
-}*/
-
 void Geometry::initListIds(const Standard_Integer shapeType)
 {
     TopTools_MapOfShape mapShape;
@@ -145,50 +98,49 @@ void Geometry::initListIds(const Standard_Integer shapeType)
     }
 
     if (listShape.IsEmpty())
-    {
         return;
-    }
 
-    TopTools_IndexedMapOfShape anIndices;
-    TopExp::MapShapes(m_shape, anIndices);
+    TopTools_IndexedMapOfShape indices;
+    TopExp::MapShapes(m_shape, indices);
     //Handle (TColStd_HArray1OfInteger) anArray;
 
-    std::list<int> aList;
+    std::list<int> indexList;
     TopTools_ListIteratorOfListOfShape itSub(listShape);
     for (int index = 1; itSub.More(); itSub.Next(), ++index)
     {
         TopoDS_Shape value = itSub.Value();
-        aList.push_back(anIndices.FindIndex(value));
+        //std::cout << "index = " << indices.FindIndex(value) << std::endl;
+        indexList.push_back(indices.FindIndex(value));
     }
 
-    std::list<int>::iterator it = aList.begin();
+    std::list<int>::iterator it = indexList.begin();
     switch (shapeType)
     {
         case TopAbs_VERTEX: /* Fill vertices ids */
         {
-            m_vertices.setSize(aList.size());
-            for (int i = 0; it != aList.end(); it++, i++)
+            m_vertices.setSize(indexList.size());
+            for (int i = 0; it != indexList.end(); it++, i++)
                 m_vertices.setReference(i, XaoUtils::intToString((*it)));
             break;
         }
         case TopAbs_EDGE: /* Fill edges ids */
         {
-            m_edges.setSize(aList.size());
-            for (int i = 0; it != aList.end(); it++, i++)
+            m_edges.setSize(indexList.size());
+            for (int i = 0; it != indexList.end(); it++, i++)
                 m_edges.setReference(i, XaoUtils::intToString((*it)));
             break;
         }
         case TopAbs_FACE: /* Fill faces ids */
         {
-            m_faces.setSize(aList.size());
-            for (int i = 0; it != aList.end(); it++, i++)
+            m_faces.setSize(indexList.size());
+            for (int i = 0; it != indexList.end(); it++, i++)
                 m_faces.setReference(i, XaoUtils::intToString((*it)));
             break;
         }
         case TopAbs_SOLID: /* Fill solids ids */
         {
-            m_solids.setSize(aList.size());
-            for (int i = 0; it != aList.end(); it++, i++)
+            m_solids.setSize(indexList.size());
+            for (int i = 0; it != indexList.end(); it++, i++)
                 m_solids.setReference(i, XaoUtils::intToString((*it)));
             break;
         }
index a4580a752dd59e2f1bdbee15bfda502a6f4d78ec..aaf4b6bd6e6e9ee884c04a8fe4df6803ad27d5aa 100644 (file)
@@ -73,10 +73,10 @@ namespace XAO
         void setCountFaces(const int nb) { m_faces.setSize(nb); }
         void setCountSolids(const int nb) { m_solids.setSize(nb); }
 
-        void setVertex(const int index, const char* name, const char* reference) { m_vertices.setElement(index, name,reference); }
-        void setEdge(const int index, const char* name, const char* reference) { m_edges.setElement(index, name,reference); }
-        void setFace(const int index, const char* name, const char* reference) { m_faces.setElement(index, name,reference); }
-        void setSolid(const int index, const char* name, const char* reference) { m_solids.setElement(index, name,reference); }
+        void setVertex(const int index, const char* name, const char* reference) { m_vertices.setElement(index, name, reference); }
+        void setEdge(const int index, const char* name, const char* reference) { m_edges.setElement(index, name, reference); }
+        void setFace(const int index, const char* name, const char* reference) { m_faces.setElement(index, name, reference); }
+        void setSolid(const int index, const char* name, const char* reference) { m_solids.setElement(index, name, reference); }
 
         const char* getVertexName(const int index) { return m_vertices.getName(index); }
         const char* getEdgeName(const int index) { return m_edges.getName(index); }
@@ -98,10 +98,10 @@ namespace XAO
         void setFaceReference(const int index, const char* reference) { m_faces.setReference(index, reference); }
         void setSolidReference(const int index, const char* reference) { m_solids.setReference(index, reference); }
 
-//        int findVertex(int id);
-//        void changeVertexName(const int id, const char* name);
-//        const char* findVertexName(int id);
-
+        const int getVertexIndexByReference(const char* reference) { return m_vertices.getIndexByReference(reference); }
+        const int getEdgeIndexByReference(const char* reference) { return m_edges.getIndexByReference(reference); }
+        const int getFaceIndexByReference(const char* reference) { return m_faces.getIndexByReference(reference); }
+        const int getSolidIndexByReference(const char* reference) { return m_solids.getIndexByReference(reference); }
 
     private:
         void initListIds(const Standard_Integer shapeType);
index 9f9a8c782091297d6b2dfd048e000adb00fe0e48..657cdf69564685e292110689c3357c61b18599a3 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef __XAO_GROUP_HXX__
 #define __XAO_GROUP_HXX__
 
+# include <iostream>
 #include <string>
 #include <vector>
 
@@ -55,21 +56,21 @@ namespace XAO
             return m_elements.size();
         }
 
-        void addElement(const char* value)
+        void addElement(const int value)
         {
             m_elements.push_back(value);
         }
 
-        const char* getElement(const int index)
+        const int getElement(const int index)
         {
-            return m_elements[index].c_str();
+            return m_elements[index];
         }
 
     private:
         std::string m_name;
         int m_dimension;
         int m_count;
-        std::vector<std::string> m_elements;
+        std::vector<int> m_elements;
     };
 }
 
index 2f7d7dd2d8b636f778a509e7159f8c4ec230453a..a3e47f85d1c12ded7a927453d7f3f2c45170fde0 100644 (file)
 #
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
-if CPPUNIT_IS_OK
-  SUBDIRS = . tests
-endif
-
 # ===============================================================
 # Files to be installed
 # ===============================================================
index 2c2361a5a57eb9ea475e35d8be6d8a49c24670b3..863b928f1404a9769232152f04291dbb16f3d860 100644 (file)
@@ -109,6 +109,8 @@ Group* Xao::getGroup(const int index)
         if (i == index)
             return (*it);
     }
+
+    return NULL;
 }
 
 
@@ -229,7 +231,7 @@ void Xao::exportGroups(xmlNodePtr xao)
         for (int i = 0; i < grp->getCount(); ++i)
         {
             xmlNodePtr elt = xmlNewChild(group, 0, C_TAG_ELEMENT, 0);
-            xmlNewProp(elt, C_ATTR_ELEMENT_INDEX, BAD_CAST grp->getElement(i));
+            xmlNewProp(elt, C_ATTR_ELEMENT_INDEX, BAD_CAST XaoUtils::intToString(grp->getElement(i)));
         }
     }
 }
@@ -507,7 +509,7 @@ void Xao::parseGroupNode(xmlNodePtr groupNode)
             xmlChar* index = xmlGetProp(node, C_ATTR_ELEMENT_INDEX);
             if (index == NULL)
                 throw SALOME_Exception("Bad index for group element");
-            group->addElement((char*)index);
+            group->addElement(atoi((char*)index));
             xmlFree(index);
         }
     }
index 31ccd85cd6446d7a5004b52b79f21a94125339ae..30ef338d59174beb631d86f433f782e00432b190 100644 (file)
@@ -83,15 +83,15 @@ void ImportExportTest::testExportGeometry()
     xao.addGroup(group);
     group->setName("boite1");
     group->setDimension(3);
-    group->addElement("1");
+    group->addElement(1);
 
     group = new Group();
     xao.addGroup(group);
     group->setName("faces");
     group->setDimension(2);
-    group->addElement("5");
-    group->addElement("8");
-    group->addElement("9");
+    group->addElement(5);
+    group->addElement(8);
+    group->addElement(9);
 
     bool res = xao.exportToFile("mygeom.xao");
     CPPUNIT_ASSERT(res);
@@ -113,7 +113,7 @@ void ImportExportTest::testGeometryError()
 
 void ImportExportTest::testImportXao()
 {
-    std::cout << std::endl;
+    //std::cout << std::endl;
     Xao xao;
     xao.importFromFile(getTestFile("test.xao").c_str());
     CPPUNIT_ASSERT(strcmp(xao.getAuthor(), "me") == 0);
@@ -156,12 +156,12 @@ void ImportExportTest::testImportXao()
     CPPUNIT_ASSERT(group->getCount() == 1);
     CPPUNIT_ASSERT(strcmp(group->getName(), "boite_1") == 0);
     CPPUNIT_ASSERT(group->getDimension() == 3);
-    CPPUNIT_ASSERT(strcmp(group->getElement(0), "1") == 0);
+    CPPUNIT_ASSERT(group->getElement(0) == 1);
     group = xao.getGroup(1);
     CPPUNIT_ASSERT(group->getCount() == 3);
     CPPUNIT_ASSERT(strcmp(group->getName(), "") == 0);
     CPPUNIT_ASSERT(group->getDimension() == 2);
-    CPPUNIT_ASSERT(strcmp(group->getElement(0), "5") == 0);
-    CPPUNIT_ASSERT(strcmp(group->getElement(1), "8") == 0);
-    CPPUNIT_ASSERT(strcmp(group->getElement(2), "9") == 0);
+    CPPUNIT_ASSERT(group->getElement(0) == 5);
+    CPPUNIT_ASSERT(group->getElement(1) == 8);
+    CPPUNIT_ASSERT(group->getElement(2) == 9);
 }