diff --git a/doc/salome/gui/GEOM/input/export_xao.doc b/doc/salome/gui/GEOM/input/export_xao.doc
new file mode 100644
index 000000000..5d1748f66
--- /dev/null
+++ b/doc/salome/gui/GEOM/input/export_xao.doc
@@ -0,0 +1,21 @@
+/*!
+
+\page export_xao_page Export XAO
+
+To export a shape in the \b XAO format, in the Main Menu select New Entity ->
+Import / Export -> Export XAO
+
+Specify the parameters of the Export XAO dialog box and press "Apply" or "Apply & Close" button.
+
+
+TUI Command:geompy.MakeExportXAO(Shape, FileName, Groups, Fields)
+
+Arguments:
+- \b Shape - The shape to export
+- \b FileName - The name of the file to create
+- \b Groups - The list of groups to export
+- \b Fields - The list of fields to export
+
+\image html exportxao_dlg.png
+
+*/
diff --git a/doc/salome/gui/GEOM/input/import_xao.doc b/doc/salome/gui/GEOM/input/import_xao.doc
new file mode 100644
index 000000000..58ddfd11e
--- /dev/null
+++ b/doc/salome/gui/GEOM/input/import_xao.doc
@@ -0,0 +1,8 @@
+/*!
+
+\page import_xao_page Import XAO
+
+To import a shape in the \b XAO format, in the Main Menu select New Entity ->
+Import / Export -> Import XAO
+
+*/
diff --git a/doc/salome/gui/GEOM/input/index.doc b/doc/salome/gui/GEOM/input/index.doc
index db275aa4a..af0fc6f51 100644
--- a/doc/salome/gui/GEOM/input/index.doc
+++ b/doc/salome/gui/GEOM/input/index.doc
@@ -4,18 +4,18 @@
\image html geomscreen.png
-\b Geometry module of SALOME is destined for:
+\b Geometry module of SALOME is destined for:
- \subpage import_export_geom_obj_page "import and export of geometrical models"
in IGES, BREP and STEP formats;
- \subpage create_geom_obj_page "construction of geometrical objects"
- using a wide range of functions;
+ using a wide range of functions;
- \subpage view_geom_obj_page "viewing geometrical objects" in the OCC
- viewer;
+ viewer;
- \subpage transform_geom_obj_page "transformation of geometrical objects"
using various algorithms;
- \subpage repairing_operations_page "optimization of geometrical objects";
- viewing \subpage geometrical_obj_prop_page "geometrical object properties"
- and other information about geometrical objects using
+ and other information about geometrical objects using
\subpage using_measurement_tools_page "measurement tools";
- \subpage pictures_page "designing shapes from pictures";
- easily setting parameters via the variables predefined in
@@ -24,6 +24,8 @@
The possibility to classify the created geometrical objects by moving it into early created container (folder) is detailed on
\subpage arranging_study_objects_page section.
+XAO format describing a shape with its topology, groups and fields is detailed on \subpage xao_format_page section.
+
Geometry module preferences are described in the
\subpage geometry_preferences_page section of SALOME Geometry Help.
diff --git a/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc
new file mode 100644
index 000000000..5a02d6460
--- /dev/null
+++ b/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc
@@ -0,0 +1,18 @@
+\anchor tui_creation_exportxao
+
Creation of ExportXAO
+
+\code
+import geompy
+import salome
+gg = salome.ImportComponentGUI("GEOM")
+
+# create ExportXAO object
+exportxao = geompy.MakeExportXAO([value], [value], [value], [value])
+
+# add object in the study
+id_exportxao = geompy.addToStudy(exportxao,"ExportXAO")
+
+# display exportxao
+gg.createAndDisplayGO(id_exportxao)
+\endcode
+
diff --git a/doc/salome/gui/GEOM/input/xao_format.doc b/doc/salome/gui/GEOM/input/xao_format.doc
new file mode 100644
index 000000000..b5c60a92d
--- /dev/null
+++ b/doc/salome/gui/GEOM/input/xao_format.doc
@@ -0,0 +1,10 @@
+/*!
+
+\page xao_format_page The XAO format
+
+XAO is a file format which describes a shape with its topology, groups and fields.
+
+- \subpage export_xao_page "Export"
+- \subpage import_xao_page "Import"
+
+*/
diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl
index 211d7c358..8984f724d 100644
--- a/idl/GEOM_Gen.idl
+++ b/idl/GEOM_Gen.idl
@@ -3703,6 +3703,31 @@ module GEOM
* \return list of all texture IDs avaiable for the current study
*/
ListOfLong GetAllTextures();
+
+ /*!
+ * Export a shape to XAO format
+ * \param shape The shape to export
+ * \param groups The list of groups to export
+ * \param fields The list of fields to export
+ * \param author The author of the export
+ * \param fileName The name of the file to export
+ * \return boolean indicating if export was successful.
+ */
+ boolean ExportXAO(in GEOM_Object shape,
+ in ListOfGO groups, in ListOfGO fields,
+ in string author, in string fileName);
+
+ /*!
+ * Import a shape from XAO format
+ * \param fileName The name of the file to import
+ * \param shape The imported shape
+ * \param subShapes The list of imported subShapes
+ * \param groups The list of imported groups
+ * \param fields The list of imported fields
+ * \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);
};
// # GEOM_IKindOfShape:
diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl
index 29bcea81b..0e7e85ca3 100644
--- a/idl/GEOM_Superv.idl
+++ b/idl/GEOM_Superv.idl
@@ -262,6 +262,11 @@ module GEOM
out string_array thePatterns) ;
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);
+ boolean ImportXAO(in string fileName, out GEOM_Object shape,
+ out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
//-----------------------------------------------------------//
// TransformOperations //
diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt
index d6b0e279b..274162faa 100755
--- a/resources/CMakeLists.txt
+++ b/resources/CMakeLists.txt
@@ -261,6 +261,7 @@ SET( _res_files
dlg_pipetshapefilletrf.png
dividedcylinder.png dividedcylinder_r_h.png
smoothingsurface.png smoothingsurface_lpoints.png tree_smoothingsurface.png
+ exportxao.png importxao.png
##@@ insert new functions before this line @@ do not remove this line @@##
)
INSTALL(FILES ${_res_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA})
diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in
index 00803d946..4ce7fe077 100644
--- a/resources/GEOMCatalog.xml.in
+++ b/resources/GEOMCatalog.xml.in
@@ -54,6 +54,7 @@
+
@@ -73,7 +74,7 @@
Geometry component1ModuleGeom.png
- 1
+ 1
@@ -594,44 +595,44 @@
-
- GetDumpName
-
-
- unknown
- 0
-
-
- theStudyEntry
- string
- unknown
-
-
-
-
- return
- string
- unknown
-
-
-
-
-
- GetAllDumpNames
-
-
- unknown
- 0
-
-
-
- return
- string_array
- unknown
-
-
-
-
+
+ GetDumpName
+
+
+ unknown
+ 0
+
+
+ theStudyEntry
+ string
+ unknown
+
+
+
+
+ return
+ string
+ unknown
+
+
+
+
+
+ GetAllDumpNames
+
+
+ unknown
+ 0
+
+
+
+ return
+ string_array
+ unknown
+
+
+
+ hostname = localhost
@@ -5301,6 +5302,43 @@
+
+ MakeExportXAO
+
+
+ unknown
+ 0
+
+
+ theFileName
+ string
+ The name of the exported file
+
+
+ theExportingShape
+ GEOM_Object
+ Shape to export
+
+
+ thelGroups
+ GEOM_List
+ List of groups to export
+
+
+ thelFields
+ GEOM_List
+ List of fields to export
+
+
+
+
+ return
+ bool
+ Result object
+
+
+
+
diff --git a/resources/exportxao.png b/resources/exportxao.png
new file mode 100644
index 000000000..25e5b3d1f
Binary files /dev/null and b/resources/exportxao.png differ
diff --git a/resources/importxao.png b/resources/importxao.png
new file mode 100644
index 000000000..bfb0e07fd
Binary files /dev/null and b/resources/importxao.png differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72fe59f5e..5a8ebe488 100755
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,7 +23,8 @@
SET(SUBDIRS_COMMON
ARCHIMEDE BlockFix GEOMAlgo SKETCHER GEOM BREPExport
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport
- ShHealOper GEOMUtils GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY
+ ShHealOper GEOMUtils XAO XAO_Swig GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY
+ AdvancedEngine
)
##
@@ -43,7 +44,7 @@ IF(SALOME_BUILD_GUI)
OBJECT OCC2VTK VTKExport DlgRef GEOMFiltersSelection Material GEOMGUI
GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI
EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
- RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI AdvancedEngine
+ RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI
GEOM_SWIG_WITHIHM
)
ENDIF()
diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx
index 56282b716..28179f5a2 100755
--- a/src/GEOMBase/GEOMBase_Helper.cxx
+++ b/src/GEOMBase/GEOMBase_Helper.cxx
@@ -836,21 +836,24 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it, currObj++ ) {
GEOM::GEOM_Object_var obj=*it;
if ( publish ) {
- QString aName = getNewObjectName(currObj);
- if ( nbObjs > 1 ) {
- if (aName.isEmpty())
- aName = getPrefix(obj);
- if (nbObjs <= 30) {
- // Try to find a unique name
- aName = GEOMBase::GetDefaultName(aName, extractPrefix());
- } else {
- // Don't check name uniqueness in case of numerous objects
- aName = aName + "_" + QString::number(aNumber++);
- }
- } else {
- // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
- if ( aName.isEmpty() )
- aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
+ QString aName = getObjectName(obj);
+ if (aName.isEmpty()) {
+ aName = getNewObjectName(currObj);
+ if ( nbObjs > 1 ) {
+ if (aName.isEmpty())
+ aName = getPrefix(obj);
+ if (nbObjs <= 30) {
+ // Try to find a unique name
+ aName = GEOMBase::GetDefaultName(aName, extractPrefix());
+ } else {
+ // Don't check name uniqueness in case of numerous objects
+ aName = aName + "_" + QString::number(aNumber++);
+ }
+ } else {
+ // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
+ if ( aName.isEmpty() )
+ aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
+ }
}
anEntryList << addInStudy( obj, aName.toLatin1().constData() );
// updateView=false
@@ -978,13 +981,22 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj )
return GEOM::GEOM_Object::_nil();
}
+//================================================================
+// Function : getObjectName
+// Purpose : Redefine this method to return proper name for the given object
+//================================================================
+QString GEOMBase_Helper::getObjectName(GEOM::GEOM_Object_ptr object) const
+{
+ return QString();
+}
+
//================================================================
// Function : getNewObjectName
// Purpose : Redefine this method to return proper name for a new object
//================================================================
QString GEOMBase_Helper::getNewObjectName (int) const
{
- return QString::null;
+ return QString();
}
//================================================================
diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h
index ab5249e1e..6b8fe6e04 100755
--- a/src/GEOMBase/GEOMBase_Helper.h
+++ b/src/GEOMBase/GEOMBase_Helper.h
@@ -164,6 +164,7 @@ protected:
// as a top-level object.
virtual QString getNewObjectName (int CurrObj = -1) const;
+ virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const;
virtual bool extractPrefix() const;
virtual void addSubshapesToStudy();
diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts
index 824d4e03a..19abbc79f 100644
--- a/src/GEOMGUI/GEOM_images.ts
+++ b/src/GEOMGUI/GEOM_images.ts
@@ -1227,5 +1227,26 @@
scale_along_axes.png
+
+
+ exportxao.png
+
+
+
+ exportxao.png
+
+
+
+ importxao.png
+
+
+
+ importxao.png
+
+
+
+ tree_exportxao.png
+
+
diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts
index c11b96858..454082125 100644
--- a/src/GEOMGUI/GEOM_msg_en.ts
+++ b/src/GEOMGUI/GEOM_msg_en.ts
@@ -4881,6 +4881,50 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif
Select image...
+
+
+ Import / Export
+
+
+
+ Export to XAO
+
+
+
+ Export XAO
+
+
+
+ Export shape to XAO format
+
+
+
+ Import from XAO
+
+
+
+ Import XAO
+
+
+
+ Import shape from XAO format
+
+
+
+ Export XAO
+
+
+
+ Export to XAO
+
+
+
+ XAO files (*.xao)
+
+
+
+ Import / Export
+ BasicGUI_CurveDlg
@@ -5768,4 +5812,62 @@ Do you want to create new material?
(No info available)
+
+ ImportExportGUI_ExportXAODlg
+
+
+ Export XAO
+
+
+
+ Export XAO
+
+
+
+ Shape
+
+
+
+ File Name
+
+
+
+ Author
+
+
+
+ Groups
+
+
+
+ Fields
+
+
+
+ ImportExportGUI_ImportXAODlg
+
+
+ Import XAO
+
+
+
+ Import XAO
+
+
+
+ Shape
+
+
+
+ File Name
+
+
+
+ Groups
+
+
+
+ Fields
+
+
diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts
index 11bde0082..f013178ac 100644
--- a/src/GEOMGUI/GEOM_msg_fr.ts
+++ b/src/GEOMGUI/GEOM_msg_fr.ts
@@ -4895,6 +4895,50 @@ le paramètre '%1' aux préférences du module Géométrie.GEOM_SELECT_IMAGE
Sélectionner une image...
+
+
+ Import / Export
+
+
+
+ Export XAO
+
+
+
+ Export XAO
+
+
+
+ Exporter une forme au format XAO
+
+
+
+ Import XAO
+
+
+
+ Import XAO
+
+
+
+ Importer une forme au format XAO
+
+
+
+ Export XAO
+
+
+
+ Export XAO
+
+
+
+ Fichiers XAO (*.xao)
+
+
+
+ Import / Export
+ BasicGUI_CurveDlg
@@ -5782,6 +5826,64 @@ Voulez-vous en créer un nouveau ?
Information
+
+ ImportExportGUI_ExportXAODlg
+
+
+ Export XAO
+
+
+
+ Export XAO
+
+
+
+ Objet
+
+
+
+ Fichier
+
+
+
+ Auteur
+
+
+
+ Groupes
+
+
+
+ Champs
+
+
+
+ ImportExportGUI_ImportXAODlg
+
+
+ Import XAO
+
+
+
+ Import XAO
+
+
+
+ Objet
+
+
+
+ Fichier
+
+
+
+ Groupes
+
+
+
+ Champs
+
+
diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx
index 6efdf1648..c447d1434 100644
--- a/src/GEOMGUI/GeometryGUI.cxx
+++ b/src/GEOMGUI/GeometryGUI.cxx
@@ -641,6 +641,10 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
libName = "BlocksGUI";
break;
+ case GEOMOp::OpExportXAO: // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO
+ case GEOMOp::OpImportXAO: // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO
+ libName = "ImportExportGUI";
+ break;
//case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
//case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
//case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
@@ -1052,6 +1056,10 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
"Geometry:Decrease number of isolines");
+ // Import/Export XAO
+ createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" );
+ createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" );
+
//createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
//createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
//createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
@@ -1105,6 +1113,10 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::OpPipePath, genId, -1 );
#endif
+ int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), newEntId, -1 );
+ createMenu( GEOMOp::OpExportXAO, impexpId, -1 );
+ createMenu( GEOMOp::OpImportXAO, impexpId, -1 );
+
//int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
//createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
@@ -1380,6 +1392,10 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::OpFeatureDetect, picturesTbId );
#endif
+ int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) );
+ createTool( GEOMOp::OpExportXAO, impexpTbId );
+ createTool( GEOMOp::OpImportXAO, impexpTbId );
+
//int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
//createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h
index 86963a94b..bb1b4292b 100644
--- a/src/GEOMGUI/GeometryGUI_Operations.h
+++ b/src/GEOMGUI/GeometryGUI_Operations.h
@@ -193,6 +193,9 @@ namespace GEOMOp {
OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE
OpPropagate = 6103, // MENU BLOCKS - PROPAGATE
OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS
+ // ImportExport ----------------//--------------------------------
+ OpExportXAO = 6200, // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO
+ OpImportXAO = 6201, // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO
// AdvancedGUI -----------------//--------------------------------
OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base)
//OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
diff --git a/src/GEOMImpl/CMakeLists.txt b/src/GEOMImpl/CMakeLists.txt
index 4f028766f..e048cf955 100755
--- a/src/GEOMImpl/CMakeLists.txt
+++ b/src/GEOMImpl/CMakeLists.txt
@@ -25,19 +25,22 @@ INCLUDE_DIRECTORIES(
${PTHREAD_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
+ ${LIBXML2_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src/ShHealOper
- ${PROJECT_SOURCE_DIR}/src/GEOM
- ${PROJECT_SOURCE_DIR}/src/BlockFix
- ${PROJECT_SOURCE_DIR}/src/GEOMAlgo
- ${PROJECT_SOURCE_DIR}/src/GEOMUtils
- ${PROJECT_SOURCE_DIR}/src/SKETCHER
- ${PROJECT_SOURCE_DIR}/src/ARCHIMEDE
+ ${PROJECT_SOURCE_DIR}/src/GEOM
+ ${PROJECT_SOURCE_DIR}/src/BlockFix
+ ${PROJECT_SOURCE_DIR}/src/GEOMAlgo
+ ${PROJECT_SOURCE_DIR}/src/GEOMUtils
+ ${PROJECT_SOURCE_DIR}/src/SKETCHER
+ ${PROJECT_SOURCE_DIR}/src/ARCHIMEDE
+ ${PROJECT_SOURCE_DIR}/src/XAO
${CMAKE_CURRENT_SOURCE_DIR}
)
# additional preprocessor / compiler flags
ADD_DEFINITIONS(
${CAS_DEFINITIONS}
+ ${LIBXML2_DEFINITIONS}
${PYTHON_DEFINITIONS}
)
@@ -46,7 +49,8 @@ SET(_link_LIBRARIES
${CAS_TKFeat}
${CAS_TKFillet}
${PYTHON_LIBRARIES}
- ShHealOper GEOMbasic BlockFix GEOMAlgo GEOMUtils GEOMSketcher GEOMArchimede
+ ${LIBXML2_LIBRARIES}
+ ShHealOper GEOMbasic BlockFix GEOMAlgo GEOMUtils GEOMSketcher GEOMArchimede XAO
${KERNEL_SALOMELocalTrace}
)
@@ -168,6 +172,8 @@ SET(GEOMImpl_HEADERS
GEOMImpl_GlueDriver.hxx
GEOMImpl_Types.hxx
GEOM_GEOMImpl.hxx
+ GEOMImpl_IImportExportXAO.hxx
+ GEOMImpl_XAODriver.hxx
)
# --- sources ---
@@ -236,6 +242,7 @@ SET(GEOMImpl_SOURCES
GEOMImpl_FillingDriver.cxx
GEOMImpl_GlueDriver.cxx
GEOMImpl_FieldDriver.cxx
+ GEOMImpl_XAODriver.cxx
)
# --- rules ---
diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx
index 515ffa9fb..cf903776a 100644
--- a/src/GEOMImpl/GEOMImpl_Gen.cxx
+++ b/src/GEOMImpl/GEOMImpl_Gen.cxx
@@ -83,6 +83,7 @@
#include
#include
#include
+#include
//=============================================================================
/*!
@@ -167,6 +168,11 @@ GEOMImpl_Gen::GEOMImpl_Gen()
// Field
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FieldDriver::GetID(), new GEOMImpl_FieldDriver());
+ // XAO operations
+ TFunction_DriverTable::Get()->AddDriver(GEOMImpl_XAODriver::GetID(), new GEOMImpl_XAODriver());
+
+ /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
+
SetEngine(this);
}
diff --git a/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx b/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx
new file mode 100644
index 000000000..a5047037e
--- /dev/null
+++ b/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx
@@ -0,0 +1,41 @@
+// Copyright (C) 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_IImportExportXAO_HXX_
+#define _GEOMImpl_IImportExportXAO_HXX_
+
+#include "GEOM_Function.hxx"
+
+#define IMPORTEXPORTXAO_ARG_DATA 1
+
+class GEOMImpl_IImportExportXAO
+{
+public:
+ GEOMImpl_IImportExportXAO(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+
+ void SetData(const TCollection_AsciiString& data) { _func->SetString(IMPORTEXPORTXAO_ARG_DATA, data); }
+ const TCollection_AsciiString GetData() { return _func->GetString(IMPORTEXPORTXAO_ARG_DATA); }
+
+private:
+ Handle(GEOM_Function) _func;
+};
+
+#endif // _GEOMImpl_IExportXAO_HXX_
diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
index 39ca36f16..311e43eb1 100644
--- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
+++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
@@ -30,9 +30,21 @@
#include
#include
#include
+#include "GEOMImpl_IShapesOperations.hxx"
+#include "GEOMImpl_IGroupOperations.hxx"
+#include "GEOMImpl_XAODriver.hxx"
+#include "GEOMImpl_IImportExportXAO.hxx"
#include
#include
+#include "GEOM_ISubShape.hxx"
+
+#include
+#include
+#include
+#include
+#include
+#include
#include
@@ -44,6 +56,7 @@
#include
#include
#include
+#include
#include
#include
@@ -70,6 +83,8 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
: GEOM_IOperations(theEngine, theDocID)
{
MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
+ myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
+ myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
}
//=============================================================================
@@ -80,6 +95,8 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
{
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
+ delete myShapesOperations;
+ delete myGroupOperations;
}
//=============================================================================
@@ -755,3 +772,404 @@ std::list GEOMImpl_IInsertOperations::GetAllTextures()
SetErrorCode(OK);
return id_list;
}
+
+TopAbs_ShapeEnum getGroupDimension(XAO::Group* group)
+{
+ XAO::Dimension dim = group->getDimension();
+ TopAbs_ShapeEnum rdim;
+ switch ( dim )
+ {
+ case XAO::VERTEX:
+ rdim = TopAbs_VERTEX; break;
+ case XAO::EDGE:
+ rdim = TopAbs_EDGE; break;
+ case XAO::FACE:
+ rdim = TopAbs_FACE; break;
+ case XAO::SOLID:
+ rdim = TopAbs_SOLID; break;
+ default:
+ rdim = TopAbs_COMPOUND; break;
+ }
+ return rdim;
+}
+
+XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape)
+{
+ XAO::Dimension dim;
+ switch( shape ) {
+ case TopAbs_VERTEX:
+ dim = XAO::VERTEX; break;
+ case TopAbs_EDGE:
+ dim = XAO::EDGE; break;
+ case TopAbs_FACE:
+ dim = XAO::FACE; break;
+ case TopAbs_SOLID:
+ dim = XAO::SOLID; break;
+ default:
+ throw SALOME_Exception("Bad type"); // TODO
+ }
+ return dim;
+}
+
+void GEOMImpl_IInsertOperations::exportGroups(std::list groupList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+{
+ // add the groups
+ std::list::iterator groupIterator = groupList.begin();
+ while (groupIterator != groupList.end())
+ {
+ Handle(GEOM_Object) currGroup = (*groupIterator++);
+ Handle(TColStd_HArray1OfInteger) groupIds = myGroupOperations->GetObjects(currGroup);
+
+ TopAbs_ShapeEnum shapeGroup = myGroupOperations->GetType(currGroup);
+ XAO::Dimension dim = shapeEnumToDimension(shapeGroup);
+ XAO::Group* group = xaoObject->addGroup(dim, currGroup->GetName().ToCString());
+
+ switch (shapeGroup)
+ {
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
+ break;
+ }
+ }
+}
+
+void GEOMImpl_IInsertOperations::exportFields(std::list fieldList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+{
+ // TODO
+}
+
+void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry)
+{
+ Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects(shape, false);
+ int nbSubObjects = subObjects->Length();
+ // set the names of the sub shapes
+ 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)
+ {
+ int subIndex = myShapesOperations->GetSubShapeIndex(shape, subObject);
+ switch (subObject->GetValue().ShapeType())
+ {
+ case TopAbs_VERTEX:
+ geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
+ break;
+ case TopAbs_EDGE:
+ geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
+ break;
+ case TopAbs_FACE:
+ geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
+ break;
+ case TopAbs_SOLID:
+ geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
+ break;
+ }
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ * Export a shape to XAO format
+ * \param shape The shape to export
+ * \param groups The list of groups to export
+ * \param fields The list of fields to export
+ * \param fileName The name of the file to exported
+ * \return boolean indicating if export was succeful.
+ */
+//=============================================================================
+bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
+ std::list groupList,
+ std::list fieldList,
+ const char* author,
+ const char* fileName)
+{
+ SetErrorCode(KO);
+
+ if (shape.IsNull()) return false;
+
+ // add a new shape function with parameters
+ Handle(GEOM_Function) lastFunction = shape->GetLastFunction();
+ if (lastFunction.IsNull()) return false;
+
+ // add a new result object
+ Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
+
+ // add an Export function
+ Handle(GEOM_Function) exportFunction = result->AddFunction(GEOMImpl_XAODriver::GetID(), IMPORTEXPORT_EXPORTXAO);
+ if (exportFunction.IsNull()) return false;
+ if (exportFunction->GetDriverGUID() != GEOMImpl_XAODriver::GetID()) return false;
+
+ // create the XAO object
+ XAO::Xao* xaoObject = new XAO::Xao();
+ xaoObject->setAuthor(author);
+
+ // add the geometry
+ XAO::BrepGeometry* geometry = (XAO::BrepGeometry*)XAO::Geometry::createGeometry(XAO::BREP);
+ TopoDS_Shape topoShape = shape->GetValue();
+ exportFunction->SetValue(topoShape);
+ XAO::BrepGeometry* brep = (XAO::BrepGeometry*)geometry;
+ brep->setTopoDS_Shape(topoShape);
+
+ geometry->setName(shape->GetName().ToCString());
+ exportSubshapes(shape, geometry);
+ xaoObject->setGeometry(geometry);
+
+ exportGroups(groupList, xaoObject, geometry);
+ exportFields(fieldList, xaoObject, geometry);
+
+ // export the XAO to the file
+ xaoObject->exportXAO(fileName);
+
+ // make a Python command
+ GEOM::TPythonDump pd(exportFunction);
+ pd << "exported = geompy.ExportXAO(" << shape;
+
+ // list of groups
+ pd << ", [";
+ if (groupList.size() > 0)
+ {
+ std::list::iterator itGroup = groupList.begin();
+ pd << (*itGroup++);
+ while (itGroup != groupList.end())
+ {
+ pd << ", " << (*itGroup++);
+ }
+ }
+
+ // list of fields
+ pd << "], [";
+ if (fieldList.size() > 0)
+ {
+ std::list::iterator itField = fieldList.begin();
+ pd << (*itField++);
+ while (itField != fieldList.end())
+ {
+ pd << ", " << (*itField++);
+ }
+ }
+ pd << "], ";
+ pd << author << ", \"" << fileName << "\")";
+
+ SetErrorCode(OK);
+ delete xaoObject;
+
+ return true;
+}
+
+void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
+ Handle(GEOM_Function) function, int shapeType, int dim,
+ Handle(TColStd_HSequenceOfTransient)& subShapeList)
+{
+ Handle(GEOM_Object) subShape;
+ Handle(GEOM_Function) aFunction;
+ Handle(TColStd_HArray1OfInteger) anArray;
+
+ XAO::GeometricElementList::iterator elementIterator = xaoGeometry->begin((XAO::Dimension)dim);
+ for (; elementIterator != xaoGeometry->end((XAO::Dimension)dim); elementIterator++)
+ {
+ XAO::GeometricElement element = elementIterator->second;
+ if (!element.hasName())
+ continue;
+
+ std::string name = element.getName();
+ std::string ref = element.getReference();
+ int iref = XAO::XaoUtils::stringToInt(ref);
+
+ anArray = new TColStd_HArray1OfInteger(1, 1);
+ anArray->SetValue(1, iref);
+
+ subShape = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+ Handle(GEOM_Function) aFunction = subShape->AddFunction(GEOM_Object::GetSubShapeID(), 1);
+ if (aFunction.IsNull())
+ return;
+
+ subShape->SetName(name.c_str());
+ subShape->SetType(shapeType);
+
+ GEOM_ISubShape aSSI(aFunction);
+ aSSI.SetMainShape(function);
+ aSSI.SetIndices(anArray);
+
+ //aFunction->SetValue(aValue);
+ subShapeList->Append(subShape);
+
+ // Put this subshape in the list of sub-shapes of theMainShape
+ function->AddSubShapeReference(aFunction);
+ }
+}
+
+//=============================================================================
+/*!
+ * Import a shape from XAO format
+ * \param fileName The name of the file to import
+ * \param shape The imported shape
+ * \param subShapes The list of imported groups
+ * \param groups The list of imported groups
+ * \param fields The list of imported fields
+ * \return boolean indicating if import was succeful.
+ */
+//=============================================================================
+bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
+ Handle(GEOM_Object)& shape,
+ Handle(TColStd_HSequenceOfTransient)& subShapes,
+ Handle(TColStd_HSequenceOfTransient)& groups,
+ Handle(TColStd_HSequenceOfTransient)& fields)
+{
+ SetErrorCode(KO);
+
+ if (fileName == NULL || groups.IsNull() || fields.IsNull())
+ return false;
+
+ // Read the XAO
+ XAO::Xao* xaoObject = new XAO::Xao();
+ try
+ {
+ xaoObject->importXAO(fileName);
+ }
+ catch (XAO::XAO_Exception& exc)
+ {
+ delete xaoObject;
+ SetErrorCode(exc.what());
+ return false;
+ }
+
+ XAO::Geometry* xaoGeometry = xaoObject->getGeometry();
+ if (xaoGeometry == NULL)
+ {
+ delete xaoObject;
+ SetErrorCode("Cannot import XAO: geometry format not supported.");
+ return false;
+ }
+
+ // create the shape
+ shape = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
+ Handle(GEOM_Function) function = shape->AddFunction(GEOMImpl_XAODriver::GetID(), IMPORTEXPORT_EXPORTXAO);
+ if (function.IsNull()) return false;
+ if (function->GetDriverGUID() != GEOMImpl_XAODriver::GetID()) return false;
+
+ // set the geometry
+ if (xaoGeometry->getFormat() == XAO::BREP)
+ {
+ XAO::BrepGeometry* brep = (XAO::BrepGeometry*)xaoGeometry;
+ TopoDS_Shape geomShape = brep->getTopoDS_Shape();
+ function->SetValue(geomShape);
+ shape->SetName(xaoGeometry->getName().c_str());
+ }
+ else
+ {
+ delete xaoObject;
+ SetErrorCode("Cannot import XAO: geometry format not supported.");
+ return false;
+ }
+
+ // create sub shapes with names
+ importSubShapes(xaoGeometry, function, GEOM_POINT, XAO::VERTEX, subShapes);
+ importSubShapes(xaoGeometry, function, GEOM_EDGE, XAO::EDGE, subShapes);
+ importSubShapes(xaoGeometry, function, GEOM_FACE, XAO::FACE, subShapes);
+ importSubShapes(xaoGeometry, function, GEOM_SOLID, XAO::SOLID, subShapes);
+
+ // create groups
+ int nbGroups = xaoObject->countGroups();
+ for (int i = 0; i < nbGroups; ++i)
+ {
+ XAO::Group* xaoGroup = xaoObject->getGroup(i);
+
+ // build an array with the indexes of the sub shapes
+ int nbElt = xaoGroup->count();
+ Handle(TColStd_HArray1OfInteger) array = new TColStd_HArray1OfInteger(1, nbElt);
+ int j = 0;
+ for (std::set::iterator it = xaoGroup->begin(); it != xaoGroup->end(); ++it)
+ {
+ int index = (*it);
+ std::string ref = xaoGeometry->getElementReference(xaoGroup->getDimension(), index);
+ array->SetValue(++j, XAO::XaoUtils::stringToInt(ref));
+ }
+
+ // create the group with the array of sub shapes indexes
+ Handle(GEOM_Object) group = GetEngine()->AddSubShape(shape, array);
+ group->SetType(GEOM_GROUP);
+ group->SetName(xaoGroup->getName().c_str());
+
+ // Set a sub-shape type
+ TDF_Label freeLabel = group->GetFreeLabel();
+ TDataStd_Integer::Set(freeLabel, (Standard_Integer) getGroupDimension(xaoGroup));
+ groups->Append(group);
+
+ function = group->GetLastFunction();
+ }
+
+ // TODO: create the fields
+
+ // make a Python command
+ GEOM::TPythonDump pd(function);
+ pd << "(imported, " << shape << ", ";
+
+ // list of sub shapes
+ pd << "[";
+ int nbSubshapes = subShapes->Length();
+ std::cout << "Nb SubShapes = " << nbSubshapes << std::endl;
+ if (nbSubshapes > 0)
+ {
+ for (int i = 1; i <= nbSubshapes; i++)
+ {
+ Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(subShapes->Value(i));
+ pd << obj << ((i < nbSubshapes) ? ", " : "");
+ }
+ }
+ pd << "], [";
+
+ // list of groups
+ if (nbGroups > 0)
+ {
+ for (int i = 1; i <= nbGroups; i++)
+ {
+ Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(groups->Value(i));
+ pd << obj << ((i < nbGroups) ? ", " : "");
+ }
+ }
+
+ pd << "], [";
+
+ // list of fields
+ pd << "]";
+ pd << ") = geompy.ImportXAO(\"" << fileName << "\")";
+
+ delete xaoObject;
+ SetErrorCode(OK);
+
+ return true;
+}
diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx
index 2b75ab840..d5b7befbf 100644
--- a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx
+++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx
@@ -38,12 +38,21 @@
#include
+class GEOMImpl_IShapesOperations;
+class GEOMImpl_IGroupOperations;
+
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
class Handle_TColStd_HArray1OfByte;
#else
class Handle_TDataStd_HArray1OfByte;
#endif
+namespace XAO {
+ class Geometry;
+ class BrepGeometry;
+ class Xao;
+}
+
class GEOMImpl_IInsertOperations : public GEOM_IOperations {
public:
Standard_EXPORT GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID);
@@ -51,10 +60,10 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakeCopy (Handle(GEOM_Object) theOriginal);
-
+
Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType);
-
+
Standard_EXPORT TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType,
const TCollection_AsciiString& theParameterName);
@@ -62,21 +71,21 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType);
-
+
Standard_EXPORT Standard_Boolean ImportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
-
+
Standard_EXPORT Standard_Boolean ExportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
Handle(TColStd_HSequenceOfAsciiString)& thePatterns);
-
+
Standard_EXPORT Standard_Boolean IsSupported (const Standard_Boolean isImport,
const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName);
-
+
Standard_EXPORT Handle(GEOM_Object) RestoreShape (std::istringstream& theStream);
-
+
Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile);
-
+
Standard_EXPORT int AddTexture(int theWidth, int theHeight,
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
const Handle(TColStd_HArray1OfByte)& theTexture);
@@ -89,16 +98,39 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
#else
Standard_EXPORT Handle(TDataStd_HArray1OfByte) GetTexture(int theTextureId,
#endif
- int& theWidth, int& theHeight);
+ int& theWidth, int& theHeight);
Standard_EXPORT std::list GetAllTextures();
+
+ Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
+ std::list groupList,
+ std::list 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);
private:
Standard_Boolean InitResMgr ();
+ void importSubShapes(XAO::Geometry* xaoGeometry, Handle(GEOM_Function) function,
+ int shapeType, int dim,
+ Handle(TColStd_HSequenceOfTransient)& subshapeList);
+ void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry);
+ void exportFields(std::list fieldList, XAO::Xao* xaoObject,
+ XAO::BrepGeometry* geometry);
+ void exportGroups(std::list groupList, XAO::Xao* xaoObject,
+ XAO::BrepGeometry* geometry);
+
private:
Handle(Resource_Manager) myResMgr;
Handle(Resource_Manager) myResMgrUser;
+ GEOMImpl_IShapesOperations* myShapesOperations;
+ GEOMImpl_IGroupOperations* myGroupOperations;
};
#endif
diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx
index 554c86401..e03c94d15 100755
--- a/src/GEOMImpl/GEOMImpl_Types.hxx
+++ b/src/GEOMImpl/GEOMImpl_Types.hxx
@@ -109,6 +109,8 @@
#define GEOM_FIELD 52 // == GEOM_FIELD_OBJTYPE constant
#define GEOM_FIELD_STEP 53 // == GEOM_FIELD_STEP_OBJTYPE constant
+#define GEOM_EXPORTXAO 54
+
//GEOM_Function types
#define COPY_WITH_REF 1
@@ -355,5 +357,9 @@
#define MARKER_SHAPE 2
#define MARKER_PNT2VEC 3
+// import/export XAO
+#define IMPORTEXPORT_EXPORTXAO 1
+#define IMPORTEXPORT_IMPORTXAO 2
+
// Advanced functions (base = 200)
#define ADVANCED_BASE 200 // NO OPERATION (advanced operations base)
diff --git a/src/GEOMImpl/GEOMImpl_XAODriver.cxx b/src/GEOMImpl/GEOMImpl_XAODriver.cxx
new file mode 100644
index 000000000..2047e66d5
--- /dev/null
+++ b/src/GEOMImpl/GEOMImpl_XAODriver.cxx
@@ -0,0 +1,128 @@
+// 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
+// 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
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "XAO_Xao.hxx"
+#include "XAO_Geometry.hxx"
+#include "XAO_Group.hxx"
+#include "XAO_XaoUtils.hxx"
+//@@ include required header files here @@//
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& GEOMImpl_XAODriver::GetID()
+{
+ static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16");
+ return aGUID;
+}
+
+//=======================================================================
+//function : GEOMImpl_XAODriver
+//purpose :
+//=======================================================================
+GEOMImpl_XAODriver::GEOMImpl_XAODriver()
+{
+}
+
+//=======================================================================
+//function : Execute
+//purpose :
+//=======================================================================
+Standard_Integer GEOMImpl_XAODriver::Execute(TFunction_Logbook& log) const
+{
+ if (Label().IsNull()) return 0;
+ Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
+
+ GEOMImpl_IImportExportXAO iexao(function);
+ TCollection_AsciiString xao = iexao.GetData();
+
+ TopoDS_Shape shape;
+
+ Standard_Integer functionType = function->GetType();
+ if (functionType == IMPORTEXPORT_EXPORTXAO)
+ {
+ }
+ else if (functionType == IMPORTEXPORT_IMPORTXAO)
+ {
+ }
+ else
+ {
+ // other construction modes here
+ }
+
+ if (shape.IsNull()) return 0;
+
+ function->SetValue(shape);
+
+ log.SetTouched(Label());
+
+ return 1;
+}
+
+//=======================================================================
+//function : GEOMImpl_XAODriver_Type_
+//purpose :
+//=======================================================================
+Standard_EXPORT Handle_Standard_Type& GEOMImpl_XAODriver_Type_()
+{
+ static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
+ if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
+ static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
+ if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
+ static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
+ if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
+
+ static Handle_Standard_Transient _Ancestors[] = { aType1, aType2, aType3, NULL };
+ static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_XAODriver",
+ sizeof(GEOMImpl_XAODriver),
+ 1,
+ (Standard_Address) _Ancestors,
+ (Standard_Address) NULL);
+ return _aType;
+}
+
+//=======================================================================
+//function : DownCast
+//purpose :
+//=======================================================================
+const Handle(GEOMImpl_XAODriver) Handle(GEOMImpl_XAODriver)::DownCast(
+ const Handle(Standard_Transient)& AnObject)
+{
+ Handle(GEOMImpl_XAODriver) _anOtherObject;
+
+ if (!AnObject.IsNull())
+ {
+ if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_XAODriver)))
+ {
+ _anOtherObject = Handle(GEOMImpl_XAODriver)((Handle(GEOMImpl_XAODriver)&) AnObject);
+ }
+ }
+
+ return _anOtherObject;
+}
diff --git a/src/GEOMImpl/GEOMImpl_XAODriver.hxx b/src/GEOMImpl/GEOMImpl_XAODriver.hxx
new file mode 100644
index 000000000..b094b4a8c
--- /dev/null
+++ b/src/GEOMImpl/GEOMImpl_XAODriver.hxx
@@ -0,0 +1,147 @@
+// Copyright (C) 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_XAODriver_HXX
+#define _GEOMImpl_XAODriver_HXX
+
+#include
+
+class Handle_Standard_Type;
+class GEOMImpl_XAODriver;
+
+Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_XAODriver);
+
+class Handle(GEOMImpl_XAODriver): public Handle(TFunction_Driver)
+{
+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(GEOMImpl_XAODriver) () :
+ Handle(TFunction_Driver)()
+ {
+ }
+ Handle(GEOMImpl_XAODriver) (const Handle(GEOMImpl_XAODriver)& aHandle) :
+ Handle(TFunction_Driver)(aHandle)
+ {
+ }
+
+ Handle(GEOMImpl_XAODriver) (const GEOMImpl_XAODriver* anItem) :
+ Handle(TFunction_Driver)((TFunction_Driver *) anItem)
+ {
+ }
+
+ Handle(GEOMImpl_XAODriver)& operator=(const Handle(GEOMImpl_XAODriver)& aHandle)
+ {
+ Assign(aHandle.Access());
+ return *this;
+ }
+
+ Handle(GEOMImpl_XAODriver)& operator=(const GEOMImpl_XAODriver* anItem)
+ {
+ Assign((Standard_Transient *) anItem);
+ return *this;
+ }
+
+ GEOMImpl_XAODriver* operator->()
+ {
+ return (GEOMImpl_XAODriver *) ControlAccess();
+ }
+
+ GEOMImpl_XAODriver* operator->() const
+ {
+ return (GEOMImpl_XAODriver *) ControlAccess();
+ }
+
+ Standard_EXPORT
+ ~Handle(GEOMImpl_XAODriver)()
+ {
+ }
+
+ Standard_EXPORT
+ static const Handle(GEOMImpl_XAODriver) DownCast(const Handle(Standard_Transient)& AnObject);
+};
+
+class GEOMImpl_XAODriver: public TFunction_Driver
+{
+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);
+ }
+
+ // Methods PUBLIC
+ //
+ Standard_EXPORT
+ GEOMImpl_XAODriver();
+ 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_XAODriver()
+ {
+ }
+
+ // Type management
+ //
+ Standard_EXPORT
+ friend Handle_Standard_Type& GEOMImpl_ExportXAODriver_Type_();
+ Standard_EXPORT
+ const Handle(Standard_Type)& DynamicType() const
+ {
+ return STANDARD_TYPE(GEOMImpl_XAODriver);
+ }
+ Standard_EXPORT
+ Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
+ {
+ return (STANDARD_TYPE(GEOMImpl_XAODriver) == AType || TFunction_Driver::IsKind(AType));
+ }
+};
+
+#endif // _GEOMImpl_XAODriver_HXX
diff --git a/src/GEOMImpl/GUID.txt b/src/GEOMImpl/GUID.txt
index f150f7127..34a83e707 100755
--- a/src/GEOMImpl/GUID.txt
+++ b/src/GEOMImpl/GUID.txt
@@ -71,5 +71,8 @@ FF1BBB69-5D14-4df2-980B-3A668264EA16 // Modify the Location
FF1BBB70-5D14-4df2-980B-3A668264EA16 // Projection
+FF1BBB71-5D14-4df2-980B-3A668264EA16 // Export XAO
+
1C3A0F3F-729D-4E83-8232-78E74FC5637C // Pipe T-Shape
+
1C3A0F30-729D-4E83-8232-78E74FC5637C // Smoothing Surface
diff --git a/src/GEOM_I/CMakeLists.txt b/src/GEOM_I/CMakeLists.txt
index d3ebabcc2..e70634e89 100755
--- a/src/GEOM_I/CMakeLists.txt
+++ b/src/GEOM_I/CMakeLists.txt
@@ -24,10 +24,12 @@ INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
${PTHREAD_INCLUDE_DIR}
${CAS_INCLUDE_DIRS}
+ ${LIBXML2_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOM
${PROJECT_SOURCE_DIR}/src/GEOMAlgo
+ ${PROJECT_SOURCE_DIR}/src/XAO
${PROJECT_BINARY_DIR}/idl
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
@@ -36,6 +38,7 @@ INCLUDE_DIRECTORIES(
# additional preprocessor / compiler flags
ADD_DEFINITIONS(
${CAS_DEFINITIONS}
+ ${LIBXML2_DEFINITIONS}
${OMNIORB_DEFINITIONS}
)
@@ -102,4 +105,4 @@ ADD_LIBRARY(GEOMEngine ${GEOMEngine_SOURCES})
TARGET_LINK_LIBRARIES(GEOMEngine ${_link_LIBRARIES})
INSTALL(TARGETS GEOMEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-INSTALL(FILES ${GEOMEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
\ No newline at end of file
+INSTALL(FILES ${GEOMEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc
index af72b8764..6e68699cd 100644
--- a/src/GEOM_I/GEOM_IInsertOperations_i.cc
+++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc
@@ -360,3 +360,119 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
anIDs[i] = *anIt;
return anIDs._retn();
}
+
+//=============================================================================
+/*!
+ * Export a shape to XAO format
+ * \param shape The shape to export
+ * \param groups The list of groups to export
+ * \param fields The list of fields to export
+ * \param author The author of the export
+ * \param fileName The name of the exported file
+ * \return boolean indicating if export was succeful.
+ */
+//=============================================================================
+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)
+{
+ bool isGood = false;
+ // Set a not done flag
+ GetOperations()->SetNotDone();
+
+ // Get the reference shape
+ Handle(GEOM_Object) reference = GetObjectImpl(shape);
+
+ // Get the reference groups
+ int ind = 0;
+ std::list groupsObj;
+ for (; ind < groups.length(); ind++)
+ {
+ Handle(GEOM_Object) gobj = GetObjectImpl(groups[ind]);
+ if (gobj.IsNull()) return false;
+ groupsObj.push_back(gobj);
+ }
+
+ // Get the reference fields
+ ind = 0;
+ std::list fieldsObj;
+ for (; ind < fields.length(); ind++)
+ {
+ Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]);
+ if (fobj.IsNull()) return false;
+ fieldsObj.push_back(fobj);
+ }
+
+ if (!reference.IsNull())
+ {
+ // Export XAO
+ isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, author, fileName);
+ }
+
+ return isGood;
+}
+
+//=============================================================================
+/*!
+ * Import a shape from XAO format
+ * \param fileName The name of the file to import
+ * \param shape The imported shape
+ * \param subShapes The list of imported subShapes
+ * \param groups The list of imported groups
+ * \param fields The list of imported fields
+ * \return boolean indicating if import was succeful.
+ */
+//=============================================================================
+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_var vshape;
+ shape = vshape._retn();
+
+ subShapes = new GEOM::ListOfGO;
+ groups = new GEOM::ListOfGO;
+ fields = new GEOM::ListOfGO;
+
+ // Set a not done flag
+ GetOperations()->SetNotDone();
+
+ Handle(TColStd_HSequenceOfTransient) importedSubShapes = new TColStd_HSequenceOfTransient();
+ Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient();
+ Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient();
+ Handle(GEOM_Object) hshape;
+ bool res = GetOperations()->ImportXAO(fileName, hshape, importedSubShapes, importedGroups, importedFields);
+
+ if (!GetOperations()->IsDone() || !res)
+ return false;
+
+ // parse fields
+ int n = importedSubShapes->Length();
+ subShapes->length(n);
+ for (int i = 1; i <= n; i++)
+ {
+ (*subShapes)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedSubShapes->Value(i)));
+ }
+
+ // parse groups
+ n = importedGroups->Length();
+ groups->length(n);
+ for (int i = 1; i <= n; i++)
+ {
+ (*groups)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedGroups->Value(i)));
+ }
+
+ // parse fields
+ n = importedFields->Length();
+ fields->length(n);
+ for (int i = 1; i <= n; i++)
+ {
+ (*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i)));
+ }
+
+ shape = GetObject(hshape);
+
+ return res;
+}
diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.hh b/src/GEOM_I/GEOM_IInsertOperations_i.hh
index 68e0f2e28..aca7a55f7 100644
--- a/src/GEOM_I/GEOM_IInsertOperations_i.hh
+++ b/src/GEOM_I/GEOM_IInsertOperations_i.hh
@@ -72,7 +72,19 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
CORBA::Long& theHeight);
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);
+ CORBA::Boolean ImportXAO (const char* fileName,
+ GEOM::GEOM_Object_out shape,
+ GEOM::ListOfGO_out subShapes,
+ GEOM::ListOfGO_out groups,
+ GEOM::ListOfGO_out fields);
+
::GEOMImpl_IInsertOperations* GetOperations()
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); }
};
diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc
index 556910df6..33b95bef2 100644
--- a/src/GEOM_I_Superv/GEOM_Superv_i.cc
+++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc
@@ -3288,6 +3288,30 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup)
return aListPtr->_this();
}
+//=============================================================================
+// ExportXAO
+//=============================================================================
+CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
+ const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
+ const char* author, const char* fileName)
+{
+ beginService( " GEOM_Superv_i::ExportXAO" );
+ MESSAGE("GEOM_Superv_i::ExportXAO");
+ getInsOp();
+ CORBA::Boolean isGood = myInsOp->ExportXAO(shape, groups, fields, author, fileName);
+ endService( " GEOM_Superv_i::ExportXAO" );
+ return isGood;
+}
+
+//=============================================================================
+// 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)
+{
+ return false;
+}
+
//=============================== Advanced Operations =============================
//=============================================================================
// MakePipeTShape
diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh
index 32ab561ce..ee8657090 100644
--- a/src/GEOM_I_Superv/GEOM_Superv_i.hh
+++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh
@@ -682,6 +682,15 @@ public:
GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup);
GEOM::GEOM_List_ptr GetObjects (GEOM::GEOM_Object_ptr theGroup);
+ //-----------------------------------------------------------//
+ // ImportExport Operations //
+ //-----------------------------------------------------------//
+ CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
+ const GEOM::ListOfGO& groups, const GEOM::ListOfGO& 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);
+
//-----------------------------------------------------------//
// Advanced Operations //
//-----------------------------------------------------------//
diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py
index 91e86c3cb..c4f9c9673 100644
--- a/src/GEOM_SWIG/geomBuilder.py
+++ b/src/GEOM_SWIG/geomBuilder.py
@@ -12288,6 +12288,36 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
RaiseIfFailed("MakeSmoothingSurface", self.AdvOp)
return anObj
+ ## Export a shape to XAO format
+ # @param shape The shape to export
+ # @param groups The list of groups to export
+ # @param fields The list of fields to export
+ # @param author The author of the export
+ # @param fileName The name of the file to export
+ # @return boolean
+ #
+ # @ref tui_exportxao "Example"
+ def ExportXAO(self, shape, groups, fields, author, fileName):
+ res = self.InsertOp.ExportXAO(shape, groups, fields, author, fileName)
+ RaiseIfFailed("ExportXAO", self.InsertOp)
+ return res
+
+ ## Import a shape from XAO format
+ # @param shape Shape to export
+ # @param fileName The name of the file to import
+ # @return tuple (res, shape, subShapes, groups, fields)
+ # res Flag indicating if the import was successful
+ # shape The imported shape
+ # subShapes The list of imported subShapes
+ # groups The list of imported groups
+ # fields The list of imported fields
+ #
+ # @ref tui_importxao "Example"
+ def ImportXAO(self, fileName):
+ res = self.InsertOp.ImportXAO(fileName)
+ RaiseIfFailed("ImportXAO", self.InsertOp)
+ return res
+
#@@ insert new functions before this line @@ do not remove this line @@#
# end of l4_advanced
diff --git a/src/ImportExportGUI/CMakeLists.txt b/src/ImportExportGUI/CMakeLists.txt
new file mode 100644
index 000000000..2ffcf72f0
--- /dev/null
+++ b/src/ImportExportGUI/CMakeLists.txt
@@ -0,0 +1,91 @@
+# Copyright (C) 2012-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(UseQt4Ext)
+INCLUDE(${QT_USE_FILE})
+
+# --- options ---
+
+# additional include directories
+INCLUDE_DIRECTORIES(
+ ${QT_INCLUDE_DIRS}
+ ${PTHREAD_INCLUDE_DIR}
+ ${VTK_INCLUDE_DIRS}
+ ${OMNIORB_INCLUDE_DIR}
+ ${CAS_INCLUDE_DIRS}
+ ${KERNEL_INCLUDE_DIRS}
+ ${GUI_INCLUDE_DIRS}
+ ${PROJECT_BINARY_DIR}/idl
+ ${PROJECT_BINARY_DIR}
+ ${PROJECT_SOURCE_DIR}/src/OBJECT
+ ${PROJECT_SOURCE_DIR}/src/GEOMClient
+ ${PROJECT_SOURCE_DIR}/src/GEOMImpl
+ ${PROJECT_SOURCE_DIR}/src/GEOMGUI
+ ${PROJECT_SOURCE_DIR}/src/GEOMBase
+ ${PROJECT_SOURCE_DIR}/src/DlgRef
+ ${PROJECT_BINARY_DIR}/src/DlgRef
+ )
+
+# additional preprocessor / compiler flags
+ADD_DEFINITIONS(
+ ${CAS_DEFINITIONS}
+ ${OMNIORB_DEFINITIONS}
+ ${QT_DEFINITIONS}
+ )
+
+# libraries to link to
+SET(_link_LIBRARIES
+ GEOMObject
+ GEOMClient
+ GEOMImpl
+ GEOMBase
+ GEOM
+ DlgRef
+ )
+
+# --- headers ---
+
+# header files / no moc processing
+SET(ImportExportGUI_HEADERS
+ ImportExportGUI.h
+ )
+
+# header files / to be processed by moc
+SET(_moc_HEADERS
+ ImportExportGUI_ExportXAODlg.h
+ ImportExportGUI_ImportXAODlg.h
+ )
+
+# --- sources ---
+
+# sources / moc wrappings
+QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+
+SET(ImportExportGUI_SOURCES
+ ImportExportGUI.cxx
+ ImportExportGUI_ExportXAODlg.cxx
+ ImportExportGUI_ImportXAODlg.cxx
+ ${_moc_SOURCES}
+ )
+
+# --- rules ---
+
+ADD_LIBRARY(ImportExportGUI ${ImportExportGUI_SOURCES})
+TARGET_LINK_LIBRARIES(ImportExportGUI ${_link_LIBRARIES})
+INSTALL(TARGETS ImportExportGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
diff --git a/src/ImportExportGUI/ImportExportGUI.cxx b/src/ImportExportGUI/ImportExportGUI.cxx
new file mode 100644
index 000000000..a011e8a64
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI.cxx
@@ -0,0 +1,98 @@
+// 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
+// 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
+#include
+
+#include "GeometryGUI.h"
+#include "GeometryGUI_Operations.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "ImportExportGUI_ExportXAODlg.h"
+#include "ImportExportGUI_ImportXAODlg.h"
+#include "ImportExportGUI.h"
+//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
+
+
+//=======================================================================
+// function : ImportExportGUI()
+// purpose : Constructor
+//=======================================================================
+ImportExportGUI::ImportExportGUI(GeometryGUI* parent) :
+ GEOMGUI(parent)
+{
+}
+
+//=======================================================================
+// function : ~ImportExportGUI
+// purpose : Destructor
+//=======================================================================
+ImportExportGUI::~ImportExportGUI()
+{
+}
+
+//=======================================================================
+// function : OnGUIEvent()
+// purpose :
+//=======================================================================
+bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent)
+{
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if (!app) return false;
+
+ getGeometryGUI()->EmitSignalDeactivateDialog();
+
+ QDialog* dialog = NULL;
+ switch (commandId)
+ {
+ case GEOMOp::OpExportXAO:
+ dialog = new ImportExportGUI_ExportXAODlg(getGeometryGUI(), parent);
+ break;
+ case GEOMOp::OpImportXAO:
+ dialog = new ImportExportGUI_ImportXAODlg(getGeometryGUI(), parent);
+ break;
+ //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
+ default:
+ app->putInfo(tr("GEOM_PRP_COMMAND").arg(commandId));
+ break;
+ }
+
+ if (dialog != NULL)
+ dialog->show();
+
+ return true;
+}
+
+//=====================================================================================
+// EXPORTED METHODS
+//=====================================================================================
+extern "C"
+{
+#ifdef WIN32
+ __declspec( dllexport )
+#endif
+ GEOMGUI* GetLibGUI(GeometryGUI* parent)
+ {
+ return new ImportExportGUI(parent);
+ }
+}
diff --git a/src/ImportExportGUI/ImportExportGUI.h b/src/ImportExportGUI/ImportExportGUI.h
new file mode 100644
index 000000000..a2165bd9d
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI.h
@@ -0,0 +1,41 @@
+// 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
+// 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 : ImportExportGUI.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+#ifndef IMPORTEXPORTGUI_H
+#define IMPORTEXPORTGUI_H
+
+#include "GEOMGUI.h"
+
+//=================================================================================
+// class : ImportExportGUI
+// purpose :
+//=================================================================================
+class ImportExportGUI: public GEOMGUI
+{
+public:
+ ImportExportGUI(GeometryGUI* parent);
+ ~ImportExportGUI();
+
+ bool OnGUIEvent(int commandId, SUIT_Desktop* parent);
+};
+
+#endif // IMPORTEXPORTGUI_H
diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx
new file mode 100644
index 000000000..93651b27c
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx
@@ -0,0 +1,383 @@
+// 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
+// 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
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+//#include
+
+// OCCT Includes
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include "ImportExportGUI_ExportXAODlg.h"
+//#include "ImportExportGUI_Widgets.h"
+
+//=================================================================================
+// Constructor
+//=================================================================================
+ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometryGUI, QWidget* parent)
+:
+ GEOMBase_Skeleton(geometryGUI, parent, false)
+{
+ m_mainObj = GEOM::GEOM_Object::_nil();
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_EXPORTXAO")));
+ QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(tr("GEOM_EXPORTXAO_TITLE"));
+
+ /***************************************************************/
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXPORTXAO_TITLE"));
+ mainFrame()->RadioButton1->setIcon(imageOp);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ // hide name
+ mainFrame()->GroupBoxName->hide();
+
+ //****************************
+ // Selection Group box
+ QGroupBox* gbxExport = new QGroupBox(parent);
+
+ QGridLayout* gridLayoutExport = new QGridLayout(gbxExport);
+#ifndef Q_OS_MAC
+ gridLayoutExport->setSpacing(6);
+ gridLayoutExport->setContentsMargins(9, 9, 9, 9);
+#endif
+ gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport"));
+
+ // Line 0
+ QLabel* lblShape = new QLabel(tr("GEOM_EXPORTXAO_EXPORTINGSHAPE"), gbxExport);
+ btnShapeSelect = new QPushButton(gbxExport);
+ btnShapeSelect->setIcon(iconSelect);
+ ledShape = new QLineEdit(gbxExport);
+ ledShape->setMinimumSize(QSize(100, 0));
+
+ int line = 0, col = 0;
+ gridLayoutExport->addWidget(lblShape, line, col++, 1, 1);
+ gridLayoutExport->addWidget(btnShapeSelect, line, col++, 1, 1);
+ gridLayoutExport->addWidget(ledShape, line, col++, 1, 1);
+
+ // Line 1
+ QLabel* lblFileName = new QLabel(tr("GEOM_EXPORTXAO_FILENAME"), gbxExport);
+ btnFileSelect = new QPushButton(gbxExport);
+ ledFileName = new QLineEdit(gbxExport);
+ btnFileSelect->setText("...");
+
+ line++; col = 0;
+ gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1);
+ gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1);
+ gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1);
+
+ // Line 2
+ QLabel* lblAuthor = new QLabel(tr("GEOM_EXPORTXAO_AUTHOR"), gbxExport);
+ ledAuthor = new QLineEdit(gbxExport);
+
+ line++; col = 0;
+ gridLayoutExport->addWidget(lblAuthor, line, col++, 2, 1);
+ col++; // span
+ gridLayoutExport->addWidget(ledAuthor, line, col++, 1, 1);
+
+ //****************************
+ // Filter Group box
+ QGroupBox* gbxFilter = new QGroupBox(parent);
+
+ QGridLayout* gridLayoutFilter = new QGridLayout(gbxFilter);
+#ifndef Q_OS_MAC
+ gridLayoutFilter->setSpacing(6);
+ gridLayoutFilter->setContentsMargins(9, 9, 9, 9);
+#endif
+ gridLayoutFilter->setObjectName(QString::fromUtf8("gbxFilter"));
+
+ // Line 0
+ QLabel* lblGroups = new QLabel(tr("GEOM_EXPORTXAO_LGROUPS"), gbxFilter);
+ QLabel* lblFields = new QLabel(tr("GEOM_EXPORTXAO_LFIELDS"), gbxFilter);
+
+ line = 0, col = 0;
+ gridLayoutFilter->addWidget(lblGroups, line, col++, 1, 1);
+ gridLayoutFilter->addWidget(lblFields, line, col++, 1, 1);
+
+ // Line 1
+ lstGroups = new QListWidget(gbxFilter);
+ lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ lstFields = new QListWidget(gbxFilter);
+ lstFields ->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ line++; col = 0;
+ gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1);
+ gridLayoutFilter->addWidget(lstFields, line, col++, 1, 1);
+
+ //****************************
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0);
+ layout->setSpacing(6);
+ layout->addWidget(gbxExport);
+ layout->addWidget(gbxFilter);
+
+ // set help
+ setHelpFileName("create_exportxao_page.html");
+
+ Init();
+}
+
+//=================================================================================
+// Destructor
+//=================================================================================
+ImportExportGUI_ExportXAODlg::~ImportExportGUI_ExportXAODlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::Init()
+{
+ // Get setting of step value from file configuration
+ m_groups.clear();
+ m_fields.clear();
+
+ // Signal/slot connections
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+ connect(btnShapeSelect, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(((SalomeApp_Application*) (SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+
+ connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
+
+
+ initName(tr("GEOM_EXPORTXAO"));
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : processObject()
+// purpose : Fill dialog fields in accordance with myObj
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::processObject()
+{
+ lstGroups->clear();
+ lstFields->clear();
+ m_groups.clear();
+ m_fields.clear();
+
+ if (m_mainObj->_is_nil())
+ {
+ ledShape->setText("");
+ }
+ else
+ {
+ ledShape->setText(GEOMBase::GetName(m_mainObj));
+ GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+
+ // add groups names
+ GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true);
+ for (int i = 0, n = groups->length(); i < n; i++)
+ {
+ QListWidgetItem* item = new QListWidgetItem();
+ item->setData(Qt::UserRole, QVariant(i));
+ item->setText(GEOMBase::GetName(groups[i]));
+ lstGroups->addItem(item);
+ m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
+ }
+ lstGroups->sortItems(Qt::AscendingOrder);
+
+ // TODO: add fields
+ }
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::ClickOnOk()
+{
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ExportXAODlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ initName();
+
+ return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::SelectionIntoArgument()
+{
+ m_mainObj = GEOM::GEOM_Object::_nil();
+
+ LightApp_SelectionMgr* selMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO selList;
+ selMgr->selectedObjects(selList);
+
+ if (selList.Extent() == 1)
+ {
+ m_mainObj = GEOMBase::ConvertIOinGEOMObject(selList.First());
+ }
+
+ processObject();
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::SetEditCurrentArgument()
+{
+ ledShape->setFocus();
+ myEditCurrentArgument = ledShape;
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : btnFileSelectClicked()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::btnFileSelectClicked()
+{
+ QString selFile = QFileDialog::getSaveFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
+ QString(), tr("XAO_FILES"));
+ if (!selFile.isEmpty())
+ {
+ ledFileName->setText(selFile);
+ }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+}
+
+//=================================================================================
+// function : enterEvent [REDEFINED]
+// purpose :
+//=================================================================================
+void ImportExportGUI_ExportXAODlg::enterEvent(QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr ImportExportGUI_ExportXAODlg::createOperation()
+{
+ return getGeomEngine()->GetIInsertOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ExportXAODlg::isValid(QString& msg)
+{
+ // check shape
+ if (ledShape->text().isEmpty())
+ return false;
+
+ // check file name
+ if (ledFileName->text().isEmpty())
+ return false;
+
+ return true;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
+{
+ bool res = false;
+
+ QString author = ledAuthor->text();
+ QString fileName = ledFileName->text();
+
+ // get selected groups
+ QList selGroups = lstGroups->selectedItems();
+ GEOM::ListOfGO_var groups = new GEOM::ListOfGO();
+ groups->length(selGroups.count());
+ int i = 0;
+ for (QList::iterator it = selGroups.begin(); it != selGroups.end(); ++it)
+ {
+ QListWidgetItem* item = (*it);
+ int index = item->data(Qt::UserRole).toInt();
+ groups[i++] = m_groups[index].copy();
+ }
+
+ // get selected fields
+ QList selFields = lstFields->selectedItems();
+ GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
+ fields->length(m_fields.count());
+ for (QList::iterator it = selFields.begin(); it != selFields.end(); ++it)
+ {
+ QListWidgetItem* item = (*it);
+ int index = item->data(Qt::UserRole).toInt();
+ fields[i++] = m_fields[index].copy();
+ }
+
+ // 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());
+
+ return res;
+}
diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h
new file mode 100644
index 000000000..acc4737cd
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h
@@ -0,0 +1,76 @@
+// 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
+// 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 IMPORTEXPORTGUI_EXPORTXAODLG_H
+#define IMPORTEXPORTGUI_EXPORTXAODLG_H
+
+#include
+#include
+
+class QLineEdit;
+class QButtonGroup;
+class QListWidget;
+
+//class ImportExportGUI_1Sel1LineEdit2ListWidget;
+
+//=================================================================================
+// class : ImportExportGUI_ExportXAODlg
+// purpose :
+//=================================================================================
+class ImportExportGUI_ExportXAODlg: public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ ImportExportGUI_ExportXAODlg(GeometryGUI*, QWidget* = 0);
+ ~ImportExportGUI_ExportXAODlg();
+
+protected:
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid(QString&);
+ virtual bool execute(ObjectList&);
+
+private:
+ void Init();
+ void enterEvent(QEvent*);
+ void processObject();
+
+private:
+ GEOM::GEOM_Object_var m_mainObj;
+ QList m_groups;
+ QList m_fields;
+ QLineEdit* ledShape;
+ QLineEdit* ledFileName;
+ QLineEdit* ledAuthor;
+ QListWidget* lstGroups;
+ QListWidget* lstFields;
+ QPushButton* btnShapeSelect;
+ QPushButton* btnFileSelect;
+
+private slots:
+ void ClickOnOk();
+ bool ClickOnApply();
+ void ActivateThisDialog();
+ void LineEditReturnPressed();
+ void SelectionIntoArgument();
+ void SetEditCurrentArgument();
+ void btnFileSelectClicked();
+};
+
+#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H
diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx
new file mode 100644
index 000000000..fe2200947
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx
@@ -0,0 +1,266 @@
+// 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
+// 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
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+// OCCT Includes
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include "ImportExportGUI_ImportXAODlg.h"
+
+//=================================================================================
+// Constructor
+//=================================================================================
+ImportExportGUI_ImportXAODlg::ImportExportGUI_ImportXAODlg(GeometryGUI* geometryGUI, QWidget* parent)
+:
+ GEOMBase_Skeleton(geometryGUI, parent, false)
+{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_IMPORTXAO")));
+ QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(tr("GEOM_IMPORTXAO_TITLE"));
+
+ /***************************************************************/
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_IMPORTXAO_TITLE"));
+ mainFrame()->RadioButton1->setIcon(imageOp);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ // hide name
+ mainFrame()->GroupBoxName->hide();
+
+ //****************************
+ // Selection Group box
+ QGroupBox* gbxExport = new QGroupBox(parent);
+
+ QGridLayout* gridLayoutExport = new QGridLayout(gbxExport);
+#ifndef Q_OS_MAC
+ gridLayoutExport->setSpacing(6);
+ gridLayoutExport->setContentsMargins(9, 9, 9, 9);
+#endif
+ gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport"));
+
+ int line = 0, col = 0;
+ QLabel* lblFileName = new QLabel(tr("GEOM_IMPORTXAO_FILENAME"), gbxExport);
+ btnFileSelect = new QPushButton(gbxExport);
+ ledFileName = new QLineEdit(gbxExport);
+ btnFileSelect->setText("...");
+
+ line++; col = 0;
+ gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1);
+ gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1);
+ gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1);
+
+ //****************************
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0);
+ layout->setSpacing(6);
+ layout->addWidget(gbxExport);
+
+ // set help
+ setHelpFileName("create_importxao_page.html");
+
+ Init();
+}
+
+//=================================================================================
+// Destructor
+//=================================================================================
+ImportExportGUI_ImportXAODlg::~ImportExportGUI_ImportXAODlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ImportXAODlg::Init()
+{
+ // Signal/slot connections
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+ connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
+
+ initName(tr("GEOM_IMPORTXAO"));
+ //SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ImportXAODlg::ClickOnOk()
+{
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ImportXAODlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ initName();
+
+ return true;
+}
+
+//=================================================================================
+// function : btnFileSelectClicked()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ImportXAODlg::btnFileSelectClicked()
+{
+ QString selFile = QFileDialog::getOpenFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
+ QString(), tr("XAO_FILES"));
+ if (!selFile.isEmpty())
+ {
+ ledFileName->setText(selFile);
+ }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void ImportExportGUI_ImportXAODlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+}
+
+//=================================================================================
+// function : enterEvent [REDEFINED]
+// purpose :
+//=================================================================================
+void ImportExportGUI_ImportXAODlg::enterEvent(QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr ImportExportGUI_ImportXAODlg::createOperation()
+{
+ return getGeomEngine()->GetIInsertOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ImportXAODlg::isValid(QString& msg)
+{
+ // check file name
+ if (ledFileName->text().isEmpty())
+ return false;
+
+ return true;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
+{
+ bool res = false;
+
+ QString fileName = ledFileName->text();
+ GEOM::GEOM_Object_var shape;
+ GEOM::ListOfGO_var groups, fields, subShapes;
+
+ GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
+ res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields);
+
+ if (!shape->_is_nil())
+ {
+ m_mainShape = shape;
+ objects.push_back(shape._retn());
+ }
+ else
+ {
+ m_mainShape = NULL;
+ }
+
+ for (int i = 0; i < subShapes->length(); i++)
+ {
+ objects.push_back(GEOM::GEOM_Object::_duplicate(subShapes[i]));
+ }
+ for (int i = 0; i < groups->length(); i++)
+ {
+ objects.push_back(GEOM::GEOM_Object::_duplicate(groups[i]));
+ }
+ for (int i = 0; i < fields->length(); i++)
+ {
+ objects.push_back(GEOM::GEOM_Object::_duplicate(fields[i]));
+ }
+
+ return res;
+}
+
+GEOM::GEOM_Object_ptr ImportExportGUI_ImportXAODlg::getFather(GEOM::GEOM_Object_ptr object)
+{
+ GEOM::GEOM_Object_var fatherObj;
+ if (object->GetType() != GEOM_IMPORT && m_mainShape != NULL)
+ {
+ //GEOM::GEOM_IGroupOperations_var groupOper = getGeomEngine()->GetIGroupOperations(getStudyId());
+ //fatherObj = groupOper->GetMainShape(object);
+ fatherObj = m_mainShape;
+ }
+ return fatherObj._retn();
+}
+
+QString ImportExportGUI_ImportXAODlg::getObjectName(GEOM::GEOM_Object_ptr object) const
+{
+ if (object->_is_nil())
+ return QString::null;
+ return object->GetName();
+}
+
diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h
new file mode 100644
index 000000000..085c7bd90
--- /dev/null
+++ b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h
@@ -0,0 +1,66 @@
+// 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
+// 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 IMPORTEXPORTGUI_IMPORTXAODLG_H
+#define IMPORTEXPORTGUI_IMPORTXAODLG_H
+
+#include
+#include
+
+class QLineEdit;
+class QButtonGroup;
+class QListWidget;
+
+//=================================================================================
+// class : ImportExportGUI_ImportXAODlg
+// purpose :
+//=================================================================================
+class ImportExportGUI_ImportXAODlg: public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ ImportExportGUI_ImportXAODlg(GeometryGUI*, QWidget* = 0);
+ ~ImportExportGUI_ImportXAODlg();
+
+protected:
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid(QString&);
+ virtual bool execute(ObjectList&);
+ virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr object);
+ virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const;
+
+private:
+ void Init();
+ void enterEvent(QEvent*);
+
+private:
+ QLineEdit* ledFileName;
+ QPushButton* btnFileSelect;
+ GEOM::GEOM_Object_var m_mainShape;
+
+private slots:
+ void ClickOnOk();
+ bool ClickOnApply();
+ void ActivateThisDialog();
+ void LineEditReturnPressed();
+ void btnFileSelectClicked();
+};
+
+#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H
diff --git a/src/XAO/CMakeLists.txt b/src/XAO/CMakeLists.txt
new file mode 100644
index 000000000..b0ab3a4cd
--- /dev/null
+++ b/src/XAO/CMakeLists.txt
@@ -0,0 +1,97 @@
+# Copyright (C) 2012-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
+#
+
+IF(SALOME_BUILD_TESTS)
+ ADD_SUBDIRECTORY(tests)
+ENDIF(SALOME_BUILD_TESTS)
+
+# --- options ---
+
+# additional include directories
+INCLUDE_DIRECTORIES(
+ ${PTHREAD_INCLUDE_DIR}
+ ${LIBXML2_INCLUDE_DIR}
+ ${CAS_INCLUDE_DIRS}
+ )
+
+# additional preprocessor / compiler flags
+ADD_DEFINITIONS(
+ ${LIBXML2_DEFINITIONS}
+ ${CAS_DEFINITIONS}
+ )
+
+# libraries to link to
+SET(_link_LIBRARIES
+ ${PTHREAD_LIBRARIES}
+ ${LIBXML2_LIBRARIES}
+ ${CAS_TKBRep} ${CAS_TKTopAlgo}
+ )
+
+# --- headers ---
+
+SET(XAO_HEADERS
+ XAO_BooleanField.hxx
+ XAO_BooleanStep.hxx
+ XAO_BrepGeometry.hxx
+ XAO_DoubleField.hxx
+ XAO_DoubleStep.hxx
+ XAO_Exception.hxx
+ XAO_Field.hxx
+ XAO_GeometricElement.hxx
+ XAO_Geometry.hxx
+ XAO_Group.hxx
+ XAO_IntegerField.hxx
+ XAO_IntegerStep.hxx
+ XAO_Step.hxx
+ XAO_StringField.hxx
+ XAO_StringStep.hxx
+ XAO_Xao.hxx
+ XAO_XaoExporter.hxx
+ XAO_XaoUtils.hxx
+ )
+
+# --- sources ---
+
+SET(XAO_SOURCES
+ XAO_BooleanField.cxx
+ XAO_BooleanStep.cxx
+ XAO_BrepGeometry.cxx
+ XAO_DoubleField.cxx
+ XAO_DoubleStep.cxx
+ XAO_Field.cxx
+ XAO_GeometricElement.cxx
+ XAO_Geometry.cxx
+ XAO_Group.cxx
+ XAO_IntegerField.cxx
+ XAO_IntegerStep.cxx
+ XAO_Step.cxx
+ XAO_StringField.cxx
+ XAO_StringStep.cxx
+ XAO_Xao.cxx
+ XAO_XaoExporter.cxx
+ XAO_XaoUtils.cxx
+ )
+
+# --- rules ---
+
+ADD_LIBRARY(XAO ${XAO_SOURCES})
+TARGET_LINK_LIBRARIES(XAO ${_link_LIBRARIES})
+INSTALL(TARGETS XAO EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
+INSTALL(FILES ${XAO_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/XAO/XAO_BooleanField.cxx b/src/XAO/XAO_BooleanField.cxx
new file mode 100644
index 000000000..c0d1532c9
--- /dev/null
+++ b/src/XAO/XAO_BooleanField.cxx
@@ -0,0 +1,61 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include "XAO_BooleanField.hxx"
+#include "XAO_BooleanStep.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+BooleanField::BooleanField(const XAO::Dimension& dimension,
+ const int& nbElements, const int& nbComponents, const std::string& name)
+ : Field(dimension, nbElements, nbComponents, name)
+{
+}
+
+Step* BooleanField::addNewStep(const int& step)
+throw (XAO_Exception)
+{
+ return addStep(step, 0);
+}
+
+BooleanStep* BooleanField::addStep(const int& step)
+throw (XAO_Exception)
+{
+ return addStep(step, 0);
+}
+
+BooleanStep* BooleanField::addStep(const int& step, const int& stamp)
+throw (XAO_Exception)
+{
+ if (hasStep(step))
+ throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists.");
+
+ BooleanStep* bstep = new BooleanStep(step, stamp, m_nbElements, m_nbComponents);
+ m_steps.push_back(bstep);
+ return bstep;
+}
+
+BooleanStep* BooleanField::getStep(const int& index)
+throw (XAO_Exception)
+{
+ checkStepIndex(index);
+ return (BooleanStep*)m_steps[index];
+}
diff --git a/src/XAO/XAO_BooleanField.hxx b/src/XAO/XAO_BooleanField.hxx
new file mode 100644
index 000000000..9860c4643
--- /dev/null
+++ b/src/XAO/XAO_BooleanField.hxx
@@ -0,0 +1,77 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_BOOLEANFIELD_HXX__
+#define __XAO_BOOLEANFIELD_HXX__
+
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Field.hxx"
+#include "XAO_BooleanStep.hxx"
+
+namespace XAO
+{
+ /**
+ * @class BooleanField
+ * Represents a field with boolean values.
+ */
+ class BooleanField : public Field
+ {
+ public:
+ /**
+ * Constructor.
+ * @param dimension the dimension of the field.
+ * @param nbElements the number of elements.
+ * @param nbComponents the number of components.
+ * @param name the name of the field.
+ */
+ BooleanField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name);
+
+ virtual const XAO::Type getType() { return XAO::BOOLEAN; }
+
+ virtual Step* addNewStep(const int& step) throw (XAO_Exception);
+
+ /**
+ * Adds a new step.
+ * @param step the number of the step.
+ * @return the newly created step.
+ */
+ BooleanStep* addStep(const int& step) throw (XAO_Exception);
+
+ /**
+ * Adds a new step.
+ * @param step the number of the step.
+ * @param stamp the stamp of the step.
+ * @return the newly created step.
+ */
+ BooleanStep* addStep(const int& step, const int& stamp)
+ throw (XAO_Exception);
+
+ /**
+ * Gets the step of given index.
+ * @param index the index.
+ * @return the step for the given index.
+ */
+ BooleanStep* getStep(const int& index) throw (XAO_Exception);
+ };
+}
+
+#endif /* __XAO_BOOLEANFIELD_HXX__ */
diff --git a/src/XAO/XAO_BooleanStep.cxx b/src/XAO/XAO_BooleanStep.cxx
new file mode 100644
index 000000000..7a0d81ade
--- /dev/null
+++ b/src/XAO/XAO_BooleanStep.cxx
@@ -0,0 +1,148 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include "XAO_BooleanStep.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+BooleanStep::BooleanStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
+{
+ m_nbElements = nbElements;
+ m_nbComponents = nbComponents;
+ m_step = step;
+ m_stamp = stamp;
+
+ m_values.reserve(m_nbElements);
+ for (int i = 0; i < m_nbElements; ++i)
+ {
+ std::vector row;
+ row.reserve(m_nbComponents);
+ for (int j = 0; j < m_nbComponents; ++j)
+ row.push_back(false);
+ m_values.push_back(row);
+ }
+}
+
+std::vector BooleanStep::getValues()
+{
+ std::vector result;
+ result.reserve(m_nbElements * m_nbComponents);
+
+ std::vector< std::vector >::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); ++it)
+ {
+ std::vector eltValues = *it;
+ result.insert(result.end(), eltValues.begin(), eltValues.end());
+ }
+
+ return result;
+}
+
+std::vector BooleanStep::getElement(const int& element)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+
+ std::vector result(m_values[element]);
+ return result;
+}
+
+std::vector BooleanStep::getComponent(const int& component)
+throw (XAO_Exception)
+{
+ checkComponentIndex(component);
+
+ std::vector result;
+ result.reserve(m_nbElements);
+
+ std::vector< std::vector >::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); ++it)
+ {
+ std::vector eltValues = *it;
+ result.push_back(eltValues[component]);
+ }
+
+ return result;
+}
+
+const bool BooleanStep::getValue(const int& element, const int& component)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkComponentIndex(component);
+
+ return m_values[element][component];
+}
+
+const std::string BooleanStep::getStringValue(const int& element, const int& component)
+throw (XAO_Exception)
+{
+ return XaoUtils::booleanToString(getValue(element, component));
+}
+
+void BooleanStep::setValues(const std::vector& values)
+throw (XAO_Exception)
+{
+ checkNbValues((int)values.size());
+
+ for (int i = 0; i < m_nbElements; ++i)
+ {
+ for (int j = 0; j < m_nbComponents; ++j)
+ {
+ m_values[i][j] = values[i * m_nbComponents + j];
+ }
+ }
+}
+
+void BooleanStep::setElement(const int& element, const std::vector& elements)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkNbComponents(elements.size());
+
+ for (int i = 0; i < m_nbComponents; ++i)
+ m_values[element][i] = elements[i];
+}
+
+void BooleanStep::setComponent(const int& component, const std::vector& components)
+throw (XAO_Exception)
+{
+ checkComponentIndex(component);
+ checkNbElements(components.size());
+
+ for (int i = 0; i < m_nbElements; ++i)
+ m_values[i][component] = components[i];
+}
+
+void BooleanStep::setValue(const int& element, const int& component, const bool& value)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkComponentIndex(component);
+
+ m_values[element][component] = value;
+}
+
+void BooleanStep::setStringValue(const int& element, const int& component, const std::string& value)
+throw (XAO_Exception)
+{
+ setValue(element, component, XaoUtils::stringToBoolean(value));
+}
diff --git a/src/XAO/XAO_BooleanStep.hxx b/src/XAO/XAO_BooleanStep.hxx
new file mode 100644
index 000000000..9986a069a
--- /dev/null
+++ b/src/XAO/XAO_BooleanStep.hxx
@@ -0,0 +1,114 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_BOOLEANSTEP_HXX__
+#define __XAO_BOOLEANSTEP_HXX__
+
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Step.hxx"
+
+namespace XAO
+{
+ /**
+ * @class BooleanStep
+ * Step with boolean values.
+ */
+ class BooleanStep : public Step
+ {
+ public:
+ /**
+ * Constructor.
+ * @param step the step number.
+ * @param stamp the stamp of the step.
+ * @param nbElements the number elements of the geometry.
+ * @param nbComponents the number of components of the field.
+ */
+ BooleanStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
+
+ virtual const XAO::Type getType() { return XAO::BOOLEAN; }
+
+ /**
+ * Gets all the values in a vector by elements and by components.
+ * @return a vector containing all the values.
+ */
+ std::vector getValues();
+
+ /**
+ * Gets all the values for an element.
+ * @param element the index of the element to get.
+ * @return a vector containing all the values for the given element.
+ */
+ std::vector getElement(const int& element) throw (XAO_Exception);
+
+ /**
+ * Gets all the values for a component.
+ * @param component the index of the component to get.
+ * @return a vector containing all the values for the given component.
+ */
+ std::vector getComponent(const int& component) throw (XAO_Exception);
+
+ /**
+ * Gets a value for an element and a component.
+ * @param element the index of the element.
+ * @param component the index of the component.
+ * @return the value.
+ */
+ const bool getValue(const int& element, const int& component) throw (XAO_Exception);
+
+ /**
+ * Sets all the values from a list.
+ * @param values the list of values to set.
+ */
+ void setValues(const std::vector& values) throw (XAO_Exception);
+
+ /**
+ * Sets the values for an element.
+ * @param element the index of the element to set.
+ * @param elements the values to set.
+ */
+ void setElement(const int& element, const std::vector& elements) throw (XAO_Exception);
+
+ /**
+ * Sets the values for a component.
+ * @param component the index of the component to set.
+ * @param components the values to set.
+ */
+ void setComponent(const int& component, const std::vector& components) throw (XAO_Exception);
+
+ /**
+ * Sets the value for an element and a component.
+ * @param element the index of the element.
+ * @param component the index of the component.
+ * @param value the value.
+ */
+ void setValue(const int& element, const int& component, const bool& value) throw (XAO_Exception);
+
+ virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception);
+ virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception);
+
+ private:
+ std::vector< std::vector > m_values;
+ };
+}
+
+
+#endif /* __XAO_BOOLEANSTEP_HXX__ */
diff --git a/src/XAO/XAO_BrepGeometry.cxx b/src/XAO/XAO_BrepGeometry.cxx
new file mode 100644
index 000000000..042f935f9
--- /dev/null
+++ b/src/XAO/XAO_BrepGeometry.cxx
@@ -0,0 +1,401 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "XAO_BrepGeometry.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+BrepGeometry::BrepGeometry() : Geometry("")
+{
+}
+
+BrepGeometry::BrepGeometry(const std::string& name) : Geometry(name)
+{
+}
+
+const std::string BrepGeometry::getShapeString()
+{
+ std::ostringstream streamShape;
+ BRepTools::Write(m_shape, streamShape);
+ std::string data = streamShape.str();
+ char* res = new char[data.size()];
+ strcpy(res, data.c_str());
+ return res;
+}
+
+void BrepGeometry::setShapeString(const std::string& shape)
+{
+ std::istringstream streamBrep(shape.c_str());
+ BRep_Builder builder;
+ BRepTools::Read(m_shape, streamBrep, builder);
+
+ initIds();
+}
+
+TopoDS_Shape BrepGeometry::getTopoDS_Shape()
+{
+ return m_shape;
+}
+
+void BrepGeometry::setTopoDS_Shape(const TopoDS_Shape& shape)
+{
+ m_shape = shape;
+ initIds();
+}
+
+void BrepGeometry::initIds()
+{
+ // intialization of Ids
+ initListIds(TopAbs_VERTEX, m_vertices);
+ initListIds(TopAbs_EDGE, m_edges);
+ initListIds(TopAbs_FACE, m_faces);
+ initListIds(TopAbs_SOLID, m_solids);
+}
+
+void BrepGeometry::initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList)
+{
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ int nbElt = 0;
+ TopExp_Explorer exp(m_shape, shapeType);
+ for (; exp.More(); exp.Next())
+ {
+ if (mapShape.Add(exp.Current()))
+ {
+ listShape.Append(exp.Current());
+ nbElt++;
+ }
+ }
+
+ if (listShape.IsEmpty())
+ return;
+
+ TopTools_IndexedMapOfShape indices;
+ TopExp::MapShapes(m_shape, indices);
+
+ eltList.setSize(nbElt);
+ TopTools_ListIteratorOfListOfShape itSub(listShape);
+ for (int index = 0; itSub.More(); itSub.Next(), ++index)
+ {
+ TopoDS_Shape value = itSub.Value();
+ int ref = indices.FindIndex(value);
+ eltList.setReference(index, XaoUtils::intToString(ref));
+ }
+}
+
+TopoDS_Shape BrepGeometry::getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex)
+throw (XAO_Exception)
+{
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ TopExp_Explorer exp(mainShape, shapeType);
+ for (; exp.More(); exp.Next())
+ {
+ if (mapShape.Add(exp.Current()))
+ listShape.Append(exp.Current());
+ }
+
+ if (!listShape.IsEmpty())
+ {
+ TopTools_ListIteratorOfListOfShape itSub(listShape);
+ for (int index = 0; itSub.More(); itSub.Next(), ++index)
+ {
+ if (shapeIndex == index)
+ {
+ TopoDS_Shape value = itSub.Value();
+ return value;
+ }
+ }
+ }
+
+ throw XAO_Exception(MsgBuilder() << "Shape with reference [" << shapeIndex << "] not found.");
+}
+
+// -----------------------------
+const int BrepGeometry::countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType)
+{
+ int res = 0;
+ TopExp_Explorer exp(shape, shapeType);
+ for (; exp.More(); exp.Next())
+ res++;
+
+ return res;
+}
+
+std::vector BrepGeometry::getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim)
+{
+ std::vector indexList;
+
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ TopExp_Explorer exp(shape, shapeType);
+ for (; exp.More(); exp.Next())
+ {
+ if (mapShape.Add(exp.Current()))
+ listShape.Append(exp.Current());
+ }
+
+ if (!listShape.IsEmpty())
+ {
+ // use the shape of the geometry for the indices
+ TopTools_IndexedMapOfShape indices;
+ TopExp::MapShapes(m_shape, indices);
+
+ TopTools_ListIteratorOfListOfShape itSub(listShape);
+ for (int index = 0; itSub.More(); itSub.Next(), ++index)
+ {
+ TopoDS_Shape value = itSub.Value();
+ int id = indices.FindIndex(value);
+ indexList.push_back(findElement(dim, id));
+ }
+ }
+
+ return indexList;
+}
+
+void BrepGeometry::getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB)
+{
+ TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex);
+ std::vector vertices = getGeometricalElements(edge, TopAbs_VERTEX, XAO::VERTEX);
+ assert(vertices.size() == 2);
+
+ vertexA = vertices[0];
+ vertexB = vertices[1];
+}
+
+const int BrepGeometry::countFaceWires(const int& faceIndex)
+{
+ TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
+ return countGeometricalElements(face, TopAbs_WIRE);
+}
+
+std::vector BrepGeometry::getFaceEdges(const int& faceIndex, const int& wireIndex)
+{
+ // get the face
+ TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
+ // get the wire
+ TopoDS_Shape wire = getSubShape(face, TopAbs_WIRE, wireIndex);
+ return getGeometricalElements(wire, TopAbs_EDGE, XAO::EDGE);
+}
+
+const int BrepGeometry::countSolidShells(const int& solidIndex)
+{
+ TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
+ return countGeometricalElements(solid, TopAbs_SHELL);
+}
+
+std::vector BrepGeometry::getSolidFaces(const int& solidIndex, const int& shellIndex)
+{
+ TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
+ TopoDS_Shape shell = getSubShape(solid, TopAbs_SHELL, shellIndex);
+ return getGeometricalElements(shell, TopAbs_FACE, XAO::FACE);
+}
+
+void BrepGeometry::getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
+throw (XAO_Exception)
+{
+ xCoord = 0.;
+ yCoord = 0.;
+ zCoord = 0.;
+
+ TopoDS_Shape vertex = getSubShape(m_shape, TopAbs_VERTEX, vertexIndex);
+ if (vertex.ShapeType() != TopAbs_VERTEX)
+ throw XAO_Exception(MsgBuilder() << "Shape " << vertexIndex<< " is not a point.");
+
+ TopoDS_Vertex point = TopoDS::Vertex(vertex);
+ if (!point.IsNull())
+ {
+ gp_Pnt aPnt = BRep_Tool::Pnt(point);
+ xCoord = aPnt.X();
+ yCoord = aPnt.Y();
+ zCoord = aPnt.Z();
+ }
+}
+
+// -----------------------------
+const double BrepGeometry::getEdgeLength(const int& edgeIndex)
+{
+ TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex);
+ GProp_GProps system;
+ BRepGProp::LinearProperties(edge, system);
+ return system.Mass();
+}
+
+const double BrepGeometry::getFaceArea(const int& faceIndex)
+{
+ TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
+ GProp_GProps system;
+ BRepGProp::SurfaceProperties(face, system);
+ return system.Mass();
+}
+
+const double BrepGeometry::getSolidVolume(const int& solidIndex)
+{
+ TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
+ GProp_GProps system;
+ BRepGProp::VolumeProperties(solid, system);
+ return system.Mass();
+}
+
+// -----------------------------
+const int BrepGeometry::getVertexID(const int& index)
+{
+ return XaoUtils::stringToInt(getVertexReference(index));
+}
+
+const int BrepGeometry::getEdgeID(const int& index)
+{
+ return XaoUtils::stringToInt(getEdgeReference(index));
+}
+
+const int BrepGeometry::getFaceID(const int& index)
+{
+ return XaoUtils::stringToInt(getFaceReference(index));
+}
+
+const int BrepGeometry::getSolidID(const int& index)
+{
+ return XaoUtils::stringToInt(getSolidReference(index));
+}
+
+// -----------------------------
+void BrepGeometry::setVertexID(const int& index, const int& id)
+{
+ setVertexReference(index, XaoUtils::intToString(id));
+}
+
+void BrepGeometry::setEdgeID(const int& index, const int& id)
+{
+ setEdgeReference(index, XaoUtils::intToString(id));
+}
+
+void BrepGeometry::setFaceID(const int& index, const int& id)
+{
+ setEdgeReference(index, XaoUtils::intToString(id));
+}
+
+void BrepGeometry::setSolidID(const int& index, const int& id)
+{
+ setEdgeReference(index, XaoUtils::intToString(id));
+}
+
+// -----------------------------
+const int BrepGeometry::findElement(const XAO::Dimension& dim, const int& id)
+throw (XAO_Exception)
+{
+ if (dim == XAO::VERTEX)
+ return findVertex(id);
+ if (dim == XAO::EDGE)
+ return findEdge(id);
+ if (dim == XAO::FACE)
+ return findFace(id);
+ if (dim == XAO::SOLID)
+ return findSolid(id);
+
+ throw XAO_Exception(MsgBuilder() << "Unknown Dimension: " << dim);
+}
+
+const int BrepGeometry::findVertex(const int& id)
+{
+ return getVertexIndexByReference(XaoUtils::intToString(id));
+}
+
+const int BrepGeometry::findEdge(const int& id)
+{
+ return getEdgeIndexByReference(XaoUtils::intToString(id));
+}
+
+const int BrepGeometry::findFace(const int& id)
+{
+ return getFaceIndexByReference(XaoUtils::intToString(id));
+}
+
+const int BrepGeometry::findSolid(const int& id)
+{
+ return getSolidIndexByReference(XaoUtils::intToString(id));
+}
+
+// -----------------------------
+const std::string BrepGeometry::findVertexName(const int& id)
+{
+ return getVertexName(findVertex(id));
+}
+
+const std::string BrepGeometry::findEdgeName(const int& id)
+{
+ return getEdgeName(findEdge(id));
+}
+
+const std::string BrepGeometry::findFaceName(const int& id)
+{
+ return getFaceName(findFace(id));
+}
+
+const std::string BrepGeometry::findSolidName(const int& id)
+{
+ return getSolidName(findSolid(id));
+}
+
+// -----------------------------
+void BrepGeometry::changeVertexName(const int& id, const std::string& name)
+throw (XAO_Exception)
+{
+ setVertexName(findVertex(id), name);
+}
+
+void BrepGeometry::changeEdgeName(const int& id, const std::string& name)
+throw (XAO_Exception)
+{
+ setEdgeName(findEdge(id), name);
+}
+
+void BrepGeometry::changeFaceName(const int& id, const std::string& name)
+throw (XAO_Exception)
+{
+ setFaceName(findFace(id), name);
+}
+
+void BrepGeometry::changeSolidName(const int& id, const std::string& name)
+throw (XAO_Exception)
+{
+ setSolidName(findSolid(id), name);
+}
diff --git a/src/XAO/XAO_BrepGeometry.hxx b/src/XAO/XAO_BrepGeometry.hxx
new file mode 100644
index 000000000..a457b3a77
--- /dev/null
+++ b/src/XAO/XAO_BrepGeometry.hxx
@@ -0,0 +1,318 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_BREPGEOMETRY_HXX__
+#define __XAO_BREPGEOMETRY_HXX__
+
+#include
+#include
+
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Geometry.hxx"
+
+namespace XAO
+{
+ /**
+ * @class BrepGeometry
+ * Representation of a BRep Geometry.
+ */
+ class BrepGeometry : public Geometry
+ {
+ public:
+ /**
+ * Default Constructor.
+ */
+ BrepGeometry();
+
+ /**
+ * Constructor.
+ * @param name the name of the geometry.
+ */
+ BrepGeometry(const std::string& name);
+
+ virtual ~BrepGeometry() {}
+
+ /**
+ * Gets the format of the geometry.
+ * @return the format of the geometry.
+ */
+ virtual const XAO::Format getFormat() { return XAO::BREP; }
+
+ /**
+ * Gets the shape as a string.
+ * @return the shape as a string.
+ */
+ virtual const std::string getShapeString();
+
+ /**
+ * Sets the shape from a string.
+ * @param shape the shape as a string.
+ */
+ virtual void setShapeString(const std::string& shape);
+
+#ifdef SWIG
+ %pythoncode %{
+ def setShape(self, shape):
+ if shape is not None and 'GetShapeStream' in dir(shape):
+ self.setShapeString(shape.GetShapeStream())
+ else:
+ raise XAO_Exception("Cannot set shape")
+ %}
+#endif
+
+ /**
+ * Gets the shape as a TopoDS_Shape.
+ * @return the TopoDS_Shape.
+ */
+ TopoDS_Shape getTopoDS_Shape();
+
+ /**
+ * Sets the shape from a TopoDS_Shape.
+ * @param shape the TopoDS_Shape to set.
+ */
+ void setTopoDS_Shape(const TopoDS_Shape& shape);
+
+ /**
+ * Gives the two extrimities of an edge.
+ * @param edgeIndex the index of the edge.
+ * @param vertexA
+ * @param vertexB
+ */
+ void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
+
+ /**
+ * Gets the number of wires of a face (including holes).
+ * @param faceIndex the index of the face.
+ * @return the number of wires.
+ */
+ const int countFaceWires(const int& faceIndex);
+
+ /**
+ * Gets the indices of the wires of the face.
+ * @param faceIndex the index of the face.
+ * @param wireIndex the index of the wire.
+ * @return the list of wires for the given face.
+ */
+ std::vector getFaceEdges(const int& faceIndex, const int& wireIndex);
+
+ /**
+ * Gets the number of shells of a solid (including cavities).
+ * @param solidIndex the index of the solid.
+ * @return the number of shells.
+ */
+ const int countSolidShells(const int& solidIndex);
+
+ /**
+ * Gets the indices of the shells of the solids.
+ * @param solidIndex the index of the solid.
+ * @param shellIndex the index of the shell (for the given solid).
+ * @return the list of shells for the given solid.
+ */
+ std::vector getSolidFaces(const int& solidIndex, const int& shellIndex);
+
+ /**
+ * Gets the coordinates of a vertex.
+ * @param vertexIndex the index of the vertex.
+ * @param xCoord the X coordinate.
+ * @param yCoord the Y coordinate.
+ * @param zCoord the Z coordinate.
+ */
+ void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
+ throw (XAO_Exception);
+
+ /**
+ * Gets the length of an edge.
+ * @param index the index of the edge.
+ * @return the length of the edge.
+ */
+ const double getEdgeLength(const int& index);
+
+ /**
+ * Gets the are of a face.
+ * @param index the index of a face.
+ * @return the area of the face.
+ */
+ const double getFaceArea(const int& index);
+
+ /**
+ * Gets the volume of a solid.
+ * @param index the index of the solid.
+ * @return the volume of the solid.
+ */
+ const double getSolidVolume(const int& index);
+
+ /**
+ * Gets the ID of a vertex.
+ * @param index the index of the vertex.
+ * @return the ID of the vertex.
+ */
+ const int getVertexID(const int& index);
+
+ /**
+ * Gets the ID of an edge.
+ * @param index the index of the edge.
+ * @return the ID of the edge.
+ */
+ const int getEdgeID(const int& index);
+
+ /**
+ * Gets the ID of a face.
+ * @param index the index of the face.
+ * @return the ID of the face.
+ */
+ const int getFaceID(const int& index);
+
+ /**
+ * Gets the ID of a solid.
+ * @param index the index of the solid.
+ * @return the ID of the solid.
+ */
+ const int getSolidID(const int& index);
+
+ /**
+ * Sets the ID of a vertex.
+ * @param index the index of the vertex to set.
+ * @param id the id to set.
+ */
+ void setVertexID(const int& index, const int& id);
+
+ /**
+ * Sets the ID of an edge.
+ * @param index the index of the edge to set.
+ * @param id the id to set.
+ */
+ void setEdgeID(const int& index, const int& id);
+
+ /**
+ * Sets the ID of a face.
+ * @param index the index of the face to set.
+ * @param id the id to set.
+ */
+ void setFaceID(const int& index, const int& id);
+
+ /**
+ * Sets the ID of a solid.
+ * @param index the index of the solid to set.
+ * @param id the id to set.
+ */
+ void setSolidID(const int& index, const int& id);
+
+ /**
+ * Finds a vertex with its ID.
+ * @param id the ID of the vertex.
+ * @return the index of the vertex.
+ */
+ const int findVertex(const int& id);
+
+ /**
+ * Finds an edge with its ID.
+ * @param id the ID of the edge.
+ * @return the index of the edge.
+ */
+ const int findEdge(const int& id);
+
+ /**
+ * Finds a face with its ID.
+ * @param id the ID of the face.
+ * @return the index of the face.
+ */
+ const int findFace(const int& id);
+
+ /**
+ * Finds a solid with its ID.
+ * @param id the ID of the solid.
+ * @return th index of the solid.
+ */
+ const int findSolid(const int& id);
+
+ /**
+ * Finds the name of a vertex with its ID.
+ * @param id the ID of the vertex.
+ * @return the name of the vertex.
+ */
+ const std::string findVertexName(const int& id);
+
+ /**
+ * Finds the name of an edge with its ID.
+ * @param id the ID of the edge.
+ * @return the name of the edge.
+ */
+ const std::string findEdgeName(const int& id);
+
+ /**
+ * Finds the name of a face with its ID.
+ * @param id the ID of the face.
+ * @return the name of the face.
+ */
+ const std::string findFaceName(const int& id);
+
+ /**
+ * Finds the name of a solid with its ID.
+ * @param id the ID of the solid.
+ * @return the name of the solid.
+ */
+ const std::string findSolidName(const int& id);
+
+ /**
+ * Changes the name of a vertex.
+ * @param id the ID of the vertex.
+ * @param name the name to set.
+ */
+ void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception);
+
+ /**
+ * Changes the name of an edge.
+ * @param id the ID of the edge
+ * @param name the name to set.
+ */
+ void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception);
+
+ /**
+ * Changes the name of a face.
+ * @param id the ID of the face.
+ * @param name the name to set.
+ */
+ void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception);
+
+ /**
+ * Changes the name of a solid.
+ * @param id the ID of the solid.
+ * @param name the name to set.
+ */
+ void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception);
+
+ private:
+ void initIds();
+ void initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList);
+ TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex)
+ throw (XAO_Exception);
+ const int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType);
+ std::vector getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim);
+ const int findElement(const XAO::Dimension& dim, const int& id)
+ throw (XAO_Exception);
+
+ private:
+ TopoDS_Shape m_shape;
+ };
+}
+
+#endif // __XAO_BREPGEOMETRY_HXX__
diff --git a/src/XAO/XAO_DoubleField.cxx b/src/XAO/XAO_DoubleField.cxx
new file mode 100644
index 000000000..b07ebabca
--- /dev/null
+++ b/src/XAO/XAO_DoubleField.cxx
@@ -0,0 +1,60 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include "XAO_DoubleField.hxx"
+#include "XAO_DoubleStep.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+DoubleField::DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name)
+ : Field(dimension, nbElements, nbComponents, name)
+{
+}
+
+Step* DoubleField::addNewStep(const int& step)
+throw (XAO_Exception)
+{
+ return addStep(step, 0);
+}
+
+DoubleStep* DoubleField::addStep(const int& step)
+throw (XAO_Exception)
+{
+ return addStep(step, 0);
+}
+
+DoubleStep* DoubleField::addStep(const int& step, const int& stamp)
+throw (XAO_Exception)
+{
+ if (hasStep(step))
+ throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists.");
+
+ DoubleStep* bstep = new DoubleStep(step, stamp, m_nbElements, m_nbComponents);
+ m_steps.push_back(bstep);
+ return bstep;
+}
+
+DoubleStep* DoubleField::getStep(const int& index)
+throw (XAO_Exception)
+{
+ checkStepIndex(index);
+ return (DoubleStep*)m_steps[index];
+}
diff --git a/src/XAO/XAO_DoubleField.hxx b/src/XAO/XAO_DoubleField.hxx
new file mode 100644
index 000000000..040a503b7
--- /dev/null
+++ b/src/XAO/XAO_DoubleField.hxx
@@ -0,0 +1,76 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_DOUBLEFIELD_HXX__
+#define __XAO_DOUBLEFIELD_HXX__
+
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Field.hxx"
+#include "XAO_DoubleStep.hxx"
+
+namespace XAO
+{
+ /**
+ * @class DoubleField
+ * Represents a field with double values.
+ */
+ class DoubleField : public Field
+ {
+ public:
+ /**
+ * Constructor.
+ * @param dimension the dimension of the field.
+ * @param nbElements the number of elements.
+ * @param nbComponents the number of components.
+ * @param name the name of the field.
+ */
+ DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name);
+
+ virtual const XAO::Type getType() { return XAO::DOUBLE; }
+
+ virtual Step* addNewStep(const int& step) throw (XAO_Exception);
+
+ /**
+ * Adds a new step.
+ * @param step the number of the step.
+ * @return the newly created step.
+ */
+ DoubleStep* addStep(const int& step) throw (XAO_Exception);
+
+ /**
+ * Adds a new step.
+ * @param step the number of the step.
+ * @param stamp the stamp of the step.
+ * @return the newly created step.
+ */
+ DoubleStep* addStep(const int& step, const int& stamp) throw (XAO_Exception);
+
+ /**
+ * Gets the step of given index.
+ * @param index the index.
+ * @return the step for the given index.
+ */
+ DoubleStep* getStep(const int& index) throw (XAO_Exception);
+ };
+}
+
+#endif /* __XAO_DOUBLEFIELD_HXX__ */
diff --git a/src/XAO/XAO_DoubleStep.cxx b/src/XAO/XAO_DoubleStep.cxx
new file mode 100644
index 000000000..aa5aa3cd3
--- /dev/null
+++ b/src/XAO/XAO_DoubleStep.cxx
@@ -0,0 +1,148 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include "XAO_DoubleStep.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+DoubleStep::DoubleStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
+{
+ m_nbElements = nbElements;
+ m_nbComponents = nbComponents;
+ m_step = step;
+ m_stamp = stamp;
+
+ m_values.reserve(m_nbElements);
+ for (int i = 0; i < m_nbElements; ++i)
+ {
+ std::vector row;
+ row.reserve(m_nbComponents);
+ for (int j = 0; j < m_nbComponents; ++j)
+ row.push_back(0);
+ m_values.push_back(row);
+ }
+}
+
+std::vector DoubleStep::getValues()
+{
+ std::vector result;
+ result.reserve(m_nbElements * m_nbComponents);
+
+ std::vector< std::vector >::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); ++it)
+ {
+ std::vector eltValues = *it;
+ result.insert(result.end(), eltValues.begin(), eltValues.end());
+ }
+
+ return result;
+}
+
+std::vector DoubleStep::getElement(const int& element)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+
+ std::vector result(m_values[element]);
+ return result;
+}
+
+std::vector DoubleStep::getComponent(const int& component)
+throw (XAO_Exception)
+{
+ checkComponentIndex(component);
+
+ std::vector result;
+ result.reserve(m_nbElements);
+
+ std::vector< std::vector >::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); ++it)
+ {
+ std::vector eltValues = *it;
+ result.push_back(eltValues[component]);
+ }
+
+ return result;
+}
+
+const double DoubleStep::getValue(const int& element, const int& component)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkComponentIndex(component);
+
+ return m_values[element][component];
+}
+
+const std::string DoubleStep::getStringValue(const int& element, const int& component)
+throw (XAO_Exception)
+{
+ return XaoUtils::doubleToString(getValue(element, component));
+}
+
+void DoubleStep::setValues(const std::vector& values)
+throw (XAO_Exception)
+{
+ checkNbValues(values.size());
+
+ for (int i = 0; i < m_nbElements; ++i)
+ {
+ for (int j = 0; j < m_nbComponents; ++j)
+ {
+ m_values[i][j] = values[i * m_nbComponents + j];
+ }
+ }
+}
+
+void DoubleStep::setElement(const int& element, const std::vector& elements)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkNbComponents(elements.size());
+
+ for (int i = 0; i < m_nbComponents; ++i)
+ m_values[element][i] = elements[i];
+}
+
+void DoubleStep::setComponent(const int& component, const std::vector& components)
+throw (XAO_Exception)
+{
+ checkElementIndex(component);
+ checkNbElements(components.size());
+
+ for (int i = 0; i < m_nbElements; ++i)
+ m_values[i][component] = components[i];
+}
+
+void DoubleStep::setValue(const int& element, const int& component, const double& value)
+throw (XAO_Exception)
+{
+ checkElementIndex(element);
+ checkComponentIndex(component);
+
+ m_values[element][component] = value;
+}
+
+void DoubleStep::setStringValue(const int& element, const int& component, const std::string& value)
+throw (XAO_Exception)
+{
+ setValue(element, component, XaoUtils::stringToDouble(value));
+}
diff --git a/src/XAO/XAO_DoubleStep.hxx b/src/XAO/XAO_DoubleStep.hxx
new file mode 100644
index 000000000..5f4f3e34a
--- /dev/null
+++ b/src/XAO/XAO_DoubleStep.hxx
@@ -0,0 +1,114 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_DOUBLESTEP_HXX__
+#define __XAO_DOUBLESTEP_HXX__
+
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Step.hxx"
+
+namespace XAO
+{
+ /**
+ * @class DoubleStep
+ * Step with double values.
+ */
+ class DoubleStep : public Step
+ {
+ public:
+ /**
+ * Constructor.
+ * @param step the step number.
+ * @param stamp the stamp of the step.
+ * @param nbElements the number elements of the geometry.
+ * @param nbComponents the number of components of the field.
+ */
+ DoubleStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
+
+ virtual const XAO::Type getType() { return XAO::DOUBLE; }
+
+ /**
+ * Gets all the values of the step as a list.
+ * @return a vector containing all the values of the step.
+ */
+ std::vector getValues();
+
+ /**
+ * Gets all the values for a given element.
+ * @param element the index of the element.
+ * @return a vector containing all the values for the given element.
+ */
+ std::vector getElement(const int& element) throw (XAO_Exception);
+
+ /**
+ * Gets all the values for a given component.
+ * @param component the index of the component.
+ * @return a vector containing all the values for the given component.
+ */
+ std::vector getComponent(const int& component) throw (XAO_Exception);
+
+ /**
+ * Gets the value for an element and a component.
+ * @param element the index of the element.
+ * @param component the index of the component.
+ * @return the value for the given element and component.
+ */
+ const double getValue(const int& element, const int& component) throw (XAO_Exception);
+
+ /**
+ * Sets all the values from a list.
+ * @param values the list of values to set.
+ */
+ void setValues(const std::vector& values) throw (XAO_Exception);
+
+ /**
+ * Sets the values for an element.
+ * @param element the index of the element to set.
+ * @param elements the values to set.
+ */
+ void setElement(const int& element, const std::vector& elements) throw (XAO_Exception);
+
+ /**
+ * Sets the values for a component.
+ * @param component the index of the component to set.
+ * @param components the values to set.
+ */
+ void setComponent(const int& component, const std::vector& components) throw (XAO_Exception);
+
+ /**
+ * Sets the value for an element and a component.
+ * @param element the index of the element.
+ * @param component the index of the component.
+ * @param value the value.
+ */
+ void setValue(const int& element, const int& component, const double& value) throw (XAO_Exception);
+
+ virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception);
+ virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception);
+
+ private:
+ std::vector< std::vector > m_values;
+ };
+}
+
+
+#endif /* __XAO_DOUBLESTEP_HXX__ */
diff --git a/src/XAO/XAO_Exception.hxx b/src/XAO/XAO_Exception.hxx
new file mode 100644
index 000000000..dce64a967
--- /dev/null
+++ b/src/XAO/XAO_Exception.hxx
@@ -0,0 +1,67 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_EXCEPTION_HXX__
+#define __XAO_EXCEPTION_HXX__
+
+namespace XAO
+{
+ /**
+ * \class XAO_Exception
+ * Exception for XAO operations.
+ */
+ class XAO_Exception : public std::exception
+ {
+ public:
+ /**
+ * Default constructor.
+ * @param message the exception message.
+ */
+ XAO_Exception(const char* message) : m_message(message)
+ {
+ }
+
+ virtual ~XAO_Exception() throw() {};
+
+ /**
+ * Returns the error message.
+ * @return the error message.
+ */
+ virtual const char* what() const throw ()
+ {
+ return m_message;
+ }
+
+#ifdef SWIG
+ %extend
+ {
+ std::string __str__() const
+ {
+ return std::string(self->what());
+ }
+ }
+#endif
+
+ private:
+ const char* m_message;
+ };
+}
+
+#endif /* __XAO_EXCEPTION_HXX__ */
diff --git a/src/XAO/XAO_Field.cxx b/src/XAO/XAO_Field.cxx
new file mode 100644
index 000000000..51d73616c
--- /dev/null
+++ b/src/XAO/XAO_Field.cxx
@@ -0,0 +1,138 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include
+#include
+
+#include "XAO_Xao.hxx"
+#include "XAO_Field.hxx"
+#include "XAO_BooleanField.hxx"
+#include "XAO_IntegerField.hxx"
+#include "XAO_DoubleField.hxx"
+#include "XAO_StringField.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+// -------------------------------------------------------
+
+Field::Field(const XAO::Dimension& dimension,
+ const int& nbElements, const int& nbComponents, const std::string& name)
+ : m_name(name), m_dimension(dimension), m_nbElements(nbElements), m_nbComponents(nbComponents)
+{
+ m_components.reserve(nbComponents);
+ for (int i = 0; i < nbComponents; ++i)
+ m_components.push_back("");
+}
+
+Field::~Field()
+{
+ for (int i = 0; i < m_steps.size(); ++i)
+ delete m_steps[i];
+}
+
+Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension,
+ const int& nbElements, const int& nbComponents, const std::string& name)
+throw (XAO_Exception)
+{
+ if (type == XAO::BOOLEAN)
+ return new BooleanField(dimension, nbElements, nbComponents, name);
+ if (type == XAO::INTEGER)
+ return new IntegerField(dimension, nbElements, nbComponents, name);
+ if (type == XAO::DOUBLE)
+ return new DoubleField(dimension, nbElements, nbComponents, name);
+ if (type == XAO::STRING)
+ return new StringField(dimension, nbElements, nbComponents, name);
+
+ throw XAO_Exception(MsgBuilder() << "Bad Type: " << type);
+}
+
+const std::string Field::getComponentName(const int& index)
+throw (XAO_Exception)
+{
+ checkComponent(index);
+ return m_components[index];
+}
+
+void Field::setComponentName(const int& index, const std::string& name)
+throw (XAO_Exception)
+{
+ checkComponent(index);
+ m_components[index] = name;
+}
+
+void Field::setComponentsNames(const std::vector& names)
+throw (XAO_Exception)
+{
+ for (int i = 0; i < names.size(); ++i)
+ {
+ if (i < m_nbComponents)
+ m_components[i] = names[i];
+ }
+}
+
+bool Field::removeStep(Step* step)
+{
+ std::vector::iterator it = m_steps.begin();
+ for (; it != m_steps.end(); ++it)
+ {
+ Step* current = *it;
+ if (step == current)
+ {
+ m_steps.erase(it);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool Field::hasStep(const int& step)
+{
+ std::vector::iterator it = m_steps.begin();
+ for (; it != m_steps.end(); ++it)
+ {
+ Step* current = *it;
+ if (current->getStep() == step)
+ return true;
+ }
+
+ return false;
+}
+
+void Field::checkComponent(const int& component)
+throw (XAO_Exception)
+{
+ if (component < m_nbComponents && component >= 0)
+ return;
+
+ throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
+ << m_nbComponents-1 << "]: " << component);
+}
+
+void Field::checkStepIndex(const int& step)
+throw (XAO_Exception)
+{
+ if (step < m_steps.size() && step >= 0)
+ return;
+
+ throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
+ << m_steps.size()-1 << "]: " << step);
+}
diff --git a/src/XAO/XAO_Field.hxx b/src/XAO/XAO_Field.hxx
new file mode 100644
index 000000000..e1931d587
--- /dev/null
+++ b/src/XAO/XAO_Field.hxx
@@ -0,0 +1,213 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_FIELD_HXX__
+#define __XAO_FIELD_HXX__
+
+#include
+#include
+
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Step.hxx"
+
+namespace XAO
+{
+ typedef std::vector::iterator stepIterator;
+
+ /**
+ * @class Field
+ * A geometrical Field.
+ */
+ class Field
+ {
+ protected:
+ /**
+ * Constructor.
+ * @param dimension the dimension ot the field.
+ * @param nbElements the number of elements.
+ * @param nbComponents the number of components.
+ * @param name the name of the field.
+ */
+ Field(const XAO::Dimension& dimension,
+ const int& nbElements, const int& nbComponents, const std::string& name);
+
+ public:
+ /**
+ /**
+ * Creates a Field of the given type.
+ * @param type the type of the field to create.
+ * @param dimension the dimension.
+ * @param nbElements the number of geometrical elements.
+ * @param nbComponents the number of components.
+ * @name the name of the field.
+ * @return the created field.
+ */
+ static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension,
+ const int& nbElements, const int& nbComponents,
+ const std::string& name = std::string(""))
+ throw (XAO_Exception);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Field();
+
+ /**
+ * Gets the Type of the field.
+ * @return the Type of the field.
+ */
+ virtual const XAO::Type getType() = 0;
+
+ /**
+ * Gets the name of the Field.
+ * @return the name of the Field.
+ */
+ const std::string getName() const
+ {
+ return m_name;
+ }
+
+ /**
+ * Sets the name of the Field.
+ * @param name the name to set.
+ */
+ void setName(const std::string& name)
+ {
+ m_name = name;
+ }
+
+ /**
+ * Gets the Dimension of the Field.
+ * @return the Dimension of the Field.
+ */
+ const XAO::Dimension getDimension() const
+ {
+ return m_dimension;
+ }
+
+ /**
+ * Gets the number of elements of each step.
+ * @return the number of elements of each step.
+ */
+ const int countElements() const
+ {
+ return m_nbElements;
+ }
+
+ /**
+ * Gets the number of components.
+ * @return the number of components.
+ */
+ const int countComponents() const
+ {
+ return m_nbComponents;
+ }
+
+ /**
+ * Gets the number of values for each step.
+ * @return the number of values for each step.
+ */
+ const int countValues() const
+ {
+ return m_nbElements * m_nbComponents;
+ }
+
+ /**
+ * Gets the number of the steps.
+ * @return the number of steps.
+ */
+ const int countSteps() const { return m_steps.size(); }
+
+ /**
+ * Gets the name of a component.
+ * @param index the index of the component to get.
+ * @return the name of the component for the given index.
+ */
+ const std::string getComponentName(const int& index) throw (XAO_Exception);
+
+ /**
+ * Sets the name of a component.
+ * @param componentIndex the index of the component to set.
+ * @param name the name to set.
+ */
+ void setComponentName(const int& componentIndex, const std::string& name) throw (XAO_Exception);
+
+ /**
+ * Sets the name of the components.
+ * @param names the names to set.
+ */
+ void setComponentsNames(const std::vector& names) throw (XAO_Exception);
+
+ /**
+ * Adds a new step of the same type than the field.
+ * @param number the numer of the step.
+ * @return the new create step.
+ */
+ virtual Step* addNewStep(const int& number) throw (XAO_Exception) = 0;
+
+ /**
+ * Remove a step.
+ * @param step the step to remove.
+ * @return true if the step has been removed, false otherwise.
+ */
+ bool removeStep(Step* step);
+
+ /**
+ * Verifies if the field has a step with the given step number.
+ * @param step the step number.
+ * @return true if the field has a step for the given number.
+ */
+ bool hasStep(const int& step);
+
+ /**
+ * Returns the first step.
+ * @return an iterator on the first step.
+ */
+ stepIterator begin() { return m_steps.begin(); }
+
+ /**
+ * Returns the last step.
+ * @return an iterator on the last step.
+ */
+ stepIterator end() { return m_steps.end(); }
+
+ protected:
+ void checkComponent(const int& component) throw (XAO_Exception);
+ void checkStepIndex(const int& step) throw (XAO_Exception);
+
+ protected:
+ /** The name of the Field. */
+ std::string m_name;
+ /** The dimension of the Field. */
+ XAO::Dimension m_dimension;
+
+ /** The number of components. */
+ int m_nbComponents;
+ /** The components of the field. */
+ std::vector m_components;
+ /** The number of elements. */
+ int m_nbElements;
+
+ /** The list of steps. */
+ std::vector m_steps;
+ };
+}
+
+#endif
diff --git a/src/XAO/XAO_GeometricElement.cxx b/src/XAO/XAO_GeometricElement.cxx
new file mode 100644
index 000000000..4e3de3096
--- /dev/null
+++ b/src/XAO/XAO_GeometricElement.cxx
@@ -0,0 +1,131 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#include "XAO_GeometricElement.hxx"
+#include "XAO_XaoUtils.hxx"
+
+using namespace XAO;
+
+
+GeometricElement::GeometricElement()
+{
+ m_name = "";
+ m_reference = "";
+}
+
+GeometricElement::GeometricElement(const std::string& name, const std::string& reference)
+{
+ m_name = name;
+ m_reference = reference;
+}
+
+GeometricElement::~GeometricElement()
+{
+}
+
+const bool GeometricElement::hasName()
+{
+ return !m_name.empty();
+}
+
+GeometricElementList::GeometricElementList()
+{
+ setSize(0);
+}
+
+GeometricElementList::GeometricElementList(const int& count)
+{
+ setSize(count);
+}
+
+void GeometricElementList::setSize(const int& nb)
+{
+ m_count = nb;
+ m_elements.clear();
+ for (int i = 0; i < nb; ++i)
+ {
+ m_elements[i] = GeometricElement();
+ }
+}
+
+void GeometricElementList::checkElementIndex(const int& index) const
+throw (XAO_Exception)
+{
+ if (m_count >= 0 && index < m_count)
+ return;
+
+ throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, "
+ << m_count-1 << "]: " << index);
+}
+
+void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ m_elements[index].setName(name);
+ m_elements[index].setReference(reference);
+}
+
+const std::string GeometricElementList::getName(const int& index)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ return m_elements[index].getName();
+}
+
+void GeometricElementList::setName(const int& index, const std::string& name)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ m_elements[index].setName(name);
+}
+
+const bool GeometricElementList::hasName(const int& index)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ return m_elements[index].hasName();
+}
+
+const std::string GeometricElementList::getReference(const int& index)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ return m_elements[index].getReference();
+}
+
+void GeometricElementList::setReference(const int& index, const std::string& name)
+throw (XAO_Exception)
+{
+ checkElementIndex(index);
+ m_elements[index].setReference(name);
+}
+
+const int GeometricElementList::getIndexByReference(const std::string& ref)
+throw (XAO_Exception)
+{
+ for (int index = 0; index < m_count; ++index)
+ {
+ if (ref == m_elements[index].getReference())
+ return index;
+ }
+
+ throw XAO_Exception(MsgBuilder() << "Reference not found: " << ref);
+}
diff --git a/src/XAO/XAO_GeometricElement.hxx b/src/XAO/XAO_GeometricElement.hxx
new file mode 100644
index 000000000..f0496479e
--- /dev/null
+++ b/src/XAO/XAO_GeometricElement.hxx
@@ -0,0 +1,213 @@
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// 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
+//
+// Author : Frederic Pons (OpenCascade)
+
+#ifndef __XAO_GEOMETRICELEMENT_HXX__
+#define __XAO_GEOMETRICELEMENT_HXX__
+
+#include
+#include