From e508f5a4ccb3200073fcfc051f267ea9be0cfbd9 Mon Sep 17 00:00:00 2001 From: fps Date: Thu, 28 Mar 2013 08:49:23 +0000 Subject: [PATCH] last changes from nge --- configure.ac | 3 +- src/GEOMImpl/GEOMImpl_ExportXAODriver.cxx | 2 +- .../GEOMImpl_IImportExportOperations.cxx | 97 +++++++++- .../GEOMImpl_IImportExportOperations.hxx | 12 +- src/GEOMImpl/GEOMImpl_Types.hxx | 2 + src/GEOMImpl/Makefile.am | 2 + src/GEOM_I_Superv/GEOM_Superv_i.hh | 1 + src/ImportExportGUI/ImportExportGUI.cxx | 10 +- ...tExportGUI_1Sel1LineEdit2ListWidget_QTD.ui | 107 ----------- .../ImportExportGUI_ExportXAODlg.cxx | 135 +++++++++----- .../ImportExportGUI_ExportXAODlg.h | 16 +- .../ImportExportGUI_Widgets.cxx | 37 ---- src/ImportExportGUI/ImportExportGUI_Widgets.h | 42 ----- src/ImportExportGUI/Makefile.am | 34 ++-- src/Makefile.am | 6 +- src/XAO/Geometry.cxx | 150 +++++++++++++-- src/XAO/Geometry.hxx | 37 ++-- src/XAO/Group.cxx | 7 - src/XAO/Group.hxx | 24 ++- src/XAO/Makefile.am | 13 +- src/XAO/Xao.cxx | 56 +++++- src/XAO/Xao.hxx | 44 +++-- src/XAOExport/Makefile.am | 65 ------- src/XAOExport/XAOExport.cxx | 174 ------------------ src/XAOImport/Makefile.am | 46 ----- src/XAOImport/XAOImport.cxx | 112 ----------- 26 files changed, 495 insertions(+), 739 deletions(-) delete mode 100644 src/ImportExportGUI/ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.ui delete mode 100644 src/ImportExportGUI/ImportExportGUI_Widgets.cxx delete mode 100644 src/ImportExportGUI/ImportExportGUI_Widgets.h delete mode 100644 src/XAOExport/Makefile.am delete mode 100644 src/XAOExport/XAOExport.cxx delete mode 100644 src/XAOImport/Makefile.am delete mode 100644 src/XAOImport/XAOImport.cxx diff --git a/configure.ac b/configure.ac index 0fdd3c51f..1605a48f0 100644 --- a/configure.ac +++ b/configure.ac @@ -372,7 +372,7 @@ else fi echo -obligatory_vars="cc_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok omniORB_ok boost_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok" +obligatory_vars="cc_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok omniORB_ok boost_ok libxml_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok" optional_vars="opencv_ok" gui_vars="OpenGL_ok qt_ok gui_ok" @@ -495,6 +495,7 @@ AC_OUTPUT([ \ doc/salome/tui/static/header.html \ src/Makefile \ src/AdvancedGUI/Makefile \ + src/XAO/Makefile \ src/ImportExportGUI/Makefile \ src/ARCHIMEDE/Makefile \ src/BREPExport/Makefile \ diff --git a/src/GEOMImpl/GEOMImpl_ExportXAODriver.cxx b/src/GEOMImpl/GEOMImpl_ExportXAODriver.cxx index 60cc8fcfa..7a4911a6c 100644 --- a/src/GEOMImpl/GEOMImpl_ExportXAODriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ExportXAODriver.cxx @@ -37,7 +37,7 @@ //======================================================================= const Standard_GUID& GEOMImpl_ExportXAODriver::GetID() { - static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16"); + static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); return aGUID; } diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx index bd49205f0..ceba312da 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx @@ -43,6 +43,10 @@ #include "GEOM_Function.hxx" #include "GEOM_PythonDump.hxx" +#include "Xao.hxx" +#include "Geometry.hxx" +#include "Group.hxx" + #include #include /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ @@ -51,10 +55,14 @@ #include #include #include +#include #include #include +#include +#include + #include #include #include @@ -78,14 +86,16 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine* GEOM_IOperations(theEngine, theDocID) { MESSAGE("GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations"); - myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); + /*myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID()); myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID()); my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID()); myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID()); - myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID()); + myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID());*/ + myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); + myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); } //============================================================================= @@ -96,14 +106,16 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine* GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations() { MESSAGE("GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations"); - delete myBasicOperations; + /*delete myBasicOperations; delete myBooleanOperations; delete myShapesOperations; delete myTransformOperations; delete myBlocksOperations; delete my3DPrimOperations; delete myLocalOperations; - delete myHealingOperations; + delete myHealingOperations;*/ + delete myShapesOperations; + delete myGroupOperations; } //============================================================================= @@ -120,6 +132,8 @@ bool GEOMImpl_IImportExportOperations::ExportXAO (Handle(GEOM_Object) theExporti { SetErrorCode(KO); bool isGood = false; + + // //Add a new shape function with parameters Handle(GEOM_Function) aRefFunction = theExportingShape->GetLastFunction(); @@ -135,13 +149,13 @@ bool GEOMImpl_IImportExportOperations::ExportXAO (Handle(GEOM_Object) theExporti //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_ExportXAODriver::GetID()) return false; - GEOMImpl_IExportXAO aData (aRefFunction); + /*GEOMImpl_IExportXAO aData (aRefFunction); TCollection_AsciiString FileName = theFileName.c_str(); aData.SetExportingShape(aRefFunction); aData.SetFileName(FileName); - /* A MODIFIER aData.SetlGroups(thelGroups); - aData.SetlFields(thelFields);*/ + aData.SetlGroups(thelGroups); + aData.SetlFields(thelFields); //Compute the resulting value try { @@ -157,14 +171,81 @@ bool GEOMImpl_IImportExportOperations::ExportXAO (Handle(GEOM_Object) theExporti Handle(Standard_Failure) aFail = Standard_Failure::Caught(); SetErrorCode(aFail->GetMessageString()); return false; + }*/ + TCollection_AsciiString FileName = theFileName.c_str(); + XAO::Xao *myXao = new XAO::Xao(); + XAO::Geometry *myGeometry = new XAO::Geometry(); + myGeometry->setShape(theExportingShape->GetValue()); + myGeometry->setName(theExportingShape->GetName()); + Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects(theExportingShape, false); + int nbSubObjects = subObjects->Length(); + for (int i = 1 ; i <= nbSubObjects ; i++) { + Handle(Standard_Transient) anTransientSubObject = subObjects->Value(i); + if (anTransientSubObject.IsNull()) + continue; + Handle(GEOM_Object) asubObject = Handle(GEOM_Object)::DownCast(anTransientSubObject); + if (asubObject->GetType() != GEOM_GROUP) + { + int index = myShapesOperations->GetSubShapeIndex(theExportingShape,asubObject); + switch (asubObject->GetValue().ShapeType() ) + { + case TopAbs_SOLID: + break; + case TopAbs_FACE: + break; + case TopAbs_EDGE: + break; + case TopAbs_VERTEX: + myGeometry->setVertexName(index,asubObject->GetName()); + break; + } + } } + myXao->setGeometry(myGeometry); + + // Adding groups + std::list::iterator itG1 = thelGroups.begin(); + while (itG1 != thelGroups.end()) { + Handle(GEOM_Object) itGroup = (*itG1++); + XAO::Group *Group = new XAO::Group(); + Group->setName(itGroup->GetName()); + Handle(TColStd_HArray1OfInteger) groupIds = myGroupOperations->GetObjects(itGroup); + TopAbs_ShapeEnum shapeGroup = myGroupOperations->GetType(itGroup); + if (shapeGroup == TopAbs_VERTEX) + { + Group->setType(0); + for (int i = 1; i <= groupIds->Length(); i++) + { + int index = myGeometry->findVertex(groupIds->Value(i)); + Group->addValue(index); + } + } + myXao->addGroup(Group); + /*{ + case TopAbs_SOLID: + Group->setType(3); + break; + case TopAbs_FACE: + Group->setType(2); + break; + case TopAbs_EDGE: + Group->setType(1); + break; + case TopAbs_VERTEX: + Group->setType(0); + break; + } */ + + + } + //Make a Python command GEOM::TPythonDump pd (aFunction); std::list::iterator itG = thelGroups.begin(); std::list::iterator itF = thelFields.begin(); pd << /*isGood <<*/ " = geompy.ExportXAO(" << theExportingShape << ", " << FileName.ToCString() << ", ["; - //itG = thePoints.begin(); + pd << (*itG++); while (itG != thelGroups.end()) { pd << ", " << (*itG++); diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx index 72328f4fd..e4b1ffc0a 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx @@ -29,26 +29,30 @@ #include -class GEOMImpl_IBasicOperations; +/*class GEOMImpl_IBasicOperations; class GEOMImpl_IBooleanOperations; class GEOMImpl_IShapesOperations; class GEOMImpl_ITransformOperations; class GEOMImpl_IBlocksOperations; class GEOMImpl_I3DPrimOperations; class GEOMImpl_ILocalOperations; -class GEOMImpl_IHealingOperations; +class GEOMImpl_IHealingOperations;*/ +class GEOMImpl_IShapesOperations; +class GEOMImpl_IGroupOperations; class GEOMImpl_IImportExportOperations: public GEOM_IOperations { private: - GEOMImpl_IBasicOperations* myBasicOperations; + /*GEOMImpl_IBasicOperations* myBasicOperations; GEOMImpl_IBooleanOperations* myBooleanOperations; GEOMImpl_IShapesOperations* myShapesOperations; GEOMImpl_ITransformOperations* myTransformOperations; GEOMImpl_IBlocksOperations* myBlocksOperations; GEOMImpl_I3DPrimOperations* my3DPrimOperations; GEOMImpl_ILocalOperations* myLocalOperations; - GEOMImpl_IHealingOperations* myHealingOperations; + GEOMImpl_IHealingOperations* myHealingOperations;*/ + GEOMImpl_IShapesOperations* myShapesOperations; + GEOMImpl_IGroupOperations* myGroupOperations; public: Standard_EXPORT GEOMImpl_IImportExportOperations(GEOM_Engine* theEngine, int theDocID); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index d69db7058..130737c81 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -80,6 +80,8 @@ #define GEOM_GROUP 37 +#define GEOM_FIELD 370 + #define GEOM_BLOCK 38 #define GEOM_MARKER 39 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 8abb1c9be..4d0821d97 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -249,6 +249,7 @@ libGEOMimpl_la_CPPFLAGS = \ -I$(srcdir)/../GEOMAlgo \ -I$(srcdir)/../SKETCHER \ -I$(srcdir)/../ARCHIMEDE \ + -I$(srcdir)/../XAO \ -I$(top_builddir)/idl libGEOMimpl_la_LDFLAGS = \ @@ -257,6 +258,7 @@ libGEOMimpl_la_LDFLAGS = \ ../ShHealOper/libShHealOper.la \ ../ARCHIMEDE/libGEOMArchimede.la \ ../SKETCHER/libGEOMSketcher.la \ + ../XAO/libXAO.la \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \ $(STDLIB) \ $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \ diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 4ded8898f..bd6b4cf85 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -736,6 +736,7 @@ private: GEOM::GEOM_ILocalOperations_var myLocalOp; GEOM::GEOM_IGroupOperations_var myGroupOp; GEOM::GEOM_IAdvancedOperations_var myAdvancedOp; + GEOM::GEOM_IImportExportOperations_var myImportExportOp; }; #endif diff --git a/src/ImportExportGUI/ImportExportGUI.cxx b/src/ImportExportGUI/ImportExportGUI.cxx index 2d111202e..7b9f7adb2 100644 --- a/src/ImportExportGUI/ImportExportGUI.cxx +++ b/src/ImportExportGUI/ImportExportGUI.cxx @@ -25,13 +25,17 @@ #include "GeometryGUI.h" #include "GeometryGUI_Operations.h" +#include #include +#include +#include #include #include "ImportExportGUI_ExportXAODlg.h" //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// -#include +#include +#include //======================================================================= // function : ImportExportGUI() @@ -62,7 +66,9 @@ bool ImportExportGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) QDialog* aDlg = NULL; - switch ( theCommandID ) { case GEOMOp::OpExportXAO: + switch ( theCommandID ) { + case GEOMOp::OpExportXAO: + cout << "test" << endl; aDlg = new ImportExportGUI_ExportXAODlg( getGeometryGUI(), parent ); break; //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// diff --git a/src/ImportExportGUI/ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.ui b/src/ImportExportGUI/ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.ui deleted file mode 100644 index 12090f439..000000000 --- a/src/ImportExportGUI/ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.ui +++ /dev/null @@ -1,107 +0,0 @@ - - - ImportExportGUI_1Sel1LineEdit2ListWidget_QTD - - - - 0 - 0 - 222 - 178 - - - - - - - - 0 - - - 6 - - - - - - - - - 9 - - - 6 - - - - - - - - TL2 - - - - - - - - 0 - 0 - - - - - - - - - - - TL1 - - - - - - - - 100 - 0 - - - - - - - - TL3 - - - - - - - TL4 - - - - - - - - - - - - - - - - PushButton1 - LineEdit1 - LineEdit2 - - - - diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx index f7c2940fe..5216e1f8b 100644 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx +++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com #include "ImportExportGUI_ExportXAODlg.h" -#include "ImportExportGUI_Widgets.h" +//#include "ImportExportGUI_Widgets.h" #include #include @@ -29,10 +29,13 @@ #include #include #include +#include #include #include #include +#include +#include #include //#include @@ -51,9 +54,11 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg (GeometryGUI* theGeometryGUI, QWidget* parent) : GEOMBase_Skeleton(theGeometryGUI, parent, false) { + myMainObj = GEOM::GEOM_Object::_nil(); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QPixmap imageOp (resMgr->loadPixmap("GEOM", tr("ICON_DLG_EXPORTXAO_EXPORTINGSHAPE_FILENAME_LGROUPS_LFIELDS"))); - QPixmap imageSel (resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap iconSelect (resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setWindowTitle(tr("GEOM_EXPORTXAO_TITLE")); @@ -65,13 +70,57 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg (GeometryGUI* theGeom mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->close(); - myGrp = new ImportExportGUI_1Sel1LineEdit2ListWidget( centralWidget() ); - myGrp->GroupBox1->setTitle( tr( "GEOM_EXPORTXAO" ) ); - myGrp->TextLabel1->setText( tr( "GEOM_EXPORTXAO_EXPORTINGSHAPE" ) ); - myGrp->TextLabel2->setText( tr( "GEOM_EXPORTXAO_FILENAME" ) ); - myGrp->TextLabel3->setText( tr( "GEOM_EXPORTXAO_LGROUPS" ) ); - myGrp->TextLabel4->setText( tr( "GEOM_EXPORTXAO_LFIELDS" ) ); - myGrp->PushButton1->setIcon( imageSel ); + + QGroupBox *GroupBoxExport = new QGroupBox(parent); + + QGridLayout *gridLayoutExport = new QGridLayout(GroupBoxExport); +#ifndef Q_OS_MAC + gridLayoutExport->setSpacing(6); +#endif +#ifndef Q_OS_MAC + gridLayoutExport->setContentsMargins(9, 9, 9, 9); +#endif + gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); + + //**************************** + QLabel *TextLabel1 = new QLabel(tr( "GEOM_EXPORTXAO_EXPORTINGSHAPE" ),GroupBoxExport); + gridLayoutExport->addWidget(TextLabel1, 0, 0, 1, 1); + + mySelBtn = new QPushButton(GroupBoxExport); + mySelBtn->setIcon(iconSelect); + gridLayoutExport->addWidget(mySelBtn, 0, 1, 1, 1); + + myMainShape = new QLineEdit(GroupBoxExport); + myMainShape->setMinimumSize(QSize(100, 0)); + gridLayoutExport->addWidget(myMainShape, 0, 2, 1, 1); + + //**************************** + QLabel *TextLabel2 = new QLabel(tr( "GEOM_EXPORTXAO_FILENAME" ),GroupBoxExport); + gridLayoutExport->addWidget(TextLabel2, 1, 0, 1, 1); + + myMainFile = new QLineEdit(GroupBoxExport); + gridLayoutExport->addWidget(myMainFile, 1, 1, 1, 2); + + //**************************** + QLabel *TextLabel3 = new QLabel(tr( "GEOM_EXPORTXAO_LGROUPS" ),GroupBoxExport); + gridLayoutExport->addWidget(TextLabel3, 2, 0, 1, 2); + + myListGroups = new QListWidget(GroupBoxExport); + gridLayoutExport->addWidget(myListGroups, 3, 0, 1, 2); + + QLabel *TextLabel4 = new QLabel(tr( "GEOM_EXPORTXAO_LFIELDS" ),GroupBoxExport); + gridLayoutExport->addWidget(TextLabel4, 2, 2, 1, 1); + + myListFields = new QListWidget(GroupBoxExport); + gridLayoutExport->addWidget(myListFields, 3, 2, 1, 1); + + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupBoxExport); + + //QWidget::setTabOrder(PushButton1, LineEdit1); + //QWidget::setTabOrder(LineEdit1, LineEdit2); setHelpFileName("create_exportxao_page.html"); @@ -93,12 +142,14 @@ ImportExportGUI_ExportXAODlg::~ImportExportGUI_ExportXAODlg() void ImportExportGUI_ExportXAODlg::Init() { // Get setting of step value from file configuration + myGroups.clear(); + myFields.clear(); // Signal/slot connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( mySelBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -113,14 +164,18 @@ void ImportExportGUI_ExportXAODlg::Init() void ImportExportGUI_ExportXAODlg::processObject() { if ( myMainObj->_is_nil() ) { - myGrp->LineEdit1->setText( "" ); - myGrp->LineEdit2->setText( "" ); - erasePreview(); + myMainShape->setText( "" ); + myMainFile->setText( "" ); } else { - myGrp->LineEdit1->setText( GEOMBase::GetName( myMainObj ) ); - - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + myMainShape->setText( GEOMBase::GetName( myMainObj ) ); + GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + GEOM::ListOfGO_var Groups = aShOp->GetExistingSubObjects(myMainObj, true); + // Affichage des noms des groupes + for ( int i = 0, n = Groups->length(); i < n; i++ ) + { + myListGroups->addItem( GEOMBase::GetName( Groups[i] ) ); + } } } @@ -154,7 +209,6 @@ bool ImportExportGUI_ExportXAODlg::ClickOnApply() //================================================================================= void ImportExportGUI_ExportXAODlg::SelectionIntoArgument() { - erasePreview(); myMainObj = GEOM::GEOM_Object::_nil(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -166,15 +220,15 @@ void ImportExportGUI_ExportXAODlg::SelectionIntoArgument() return; } - GEOM::GEOM_Object_var aSelectedObject = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); + /*GEOM::GEOM_Object_var aSelectedObject*/myMainObj = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( aSelectedObject->_is_nil() ) { + /*if ( aSelectedObject->_is_nil() ) { processObject(); return; - } + }*/ - myMainObj = aSelectedObject; + //myMainObj = aSelectedObject; + processObject(); } @@ -184,8 +238,8 @@ void ImportExportGUI_ExportXAODlg::SelectionIntoArgument() //================================================================================= void ImportExportGUI_ExportXAODlg::SetEditCurrentArgument() { - myGrp->LineEdit1->setFocus(); - myEditCurrentArgument = myGrp->LineEdit1; + myMainShape->setFocus(); + myEditCurrentArgument = myMainShape; SelectionIntoArgument(); } //================================================================================= @@ -240,29 +294,20 @@ bool ImportExportGUI_ExportXAODlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; GEOM::GEOM_IImportExportOperations_var anOper = GEOM::GEOM_IImportExportOperations::_narrow(getOperation()); - - /*//@@ retrieve input values from the widgets here @@// - CORBA::Double theExportingShape = @@ init parameter value from dialog box @@; - CORBA::String_var theFileName = @@ init parameter value from dialog box @@; - CORBA::Boolean thelGroups = @@ init parameter value from dialog box @@; - CORBA::Boolean thelFields = @@ init parameter value from dialog box @@; + GEOM::GEOM_IShapesOperations_var anShapesOper = getGeomEngine()->GetIShapesOperations(getStudyId()); + GEOM::ListOfGO_var mylGroups = anShapesOper->GetExistingSubObjects(myMainObj, true); + GEOM::ListOfGO_var mylFields = new GEOM::ListOfGO(); + + mylGroups->length( myGroups.count() ); + for ( int i = 0; i < myGroups.count(); i++ ) + mylGroups[i] = myGroups[i].copy(); + + mylFields->length( myFields.count() ); + for ( int i = 0; i < myFields.count(); i++ ) + mylFields[i] = myFields[i].copy(); // call engine function - anObj = anOper->ExportXAO(theExportingShape, theFileName, thelGroups, thelFields); - res = !anObj->_is_nil(); - if (res && !IsPreview()) - { - QStringList aParameters; - //@@ put stringified input parameters to the string list here to store in the data model for notebook @@// - aParameters << @@ stringified parameter value @@; // ExportingShape parameter - aParameters << @@ stringified parameter value @@; // FileName parameter - aParameters << @@ stringified parameter value @@; // lGroups parameter - aParameters << @@ stringified parameter value @@; // lFields parameter - if ( aParameters.count() > 0 ) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); - } - - if (res) - objects.push_back(anObj._retn());*/ + res = anOper->ExportXAO(myMainObj, myMainFile->text().toStdString().c_str(), mylGroups, mylFields); return res; } diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h index 3c5fb4243..f89324ae7 100644 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h +++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h @@ -23,11 +23,13 @@ #define IMPORTEXPORTGUI_EXPORTXAODLG_H #include +#include "GEOM_GenericObjPtr.h" -class QGroupBox; class QLineEdit; class QButtonGroup; -class ImportExportGUI_1Sel1LineEdit2ListWidget; +class QListWidget; + +//class ImportExportGUI_1Sel1LineEdit2ListWidget; //================================================================================= // class : ImportExportGUI_ExportXAODlg @@ -54,12 +56,20 @@ private: private: GEOM::GEOM_Object_var myMainObj; - ImportExportGUI_1Sel1LineEdit2ListWidget* myGrp; + QList myGroups; + QList myFields; + //ImportExportGUI_1Sel1LineEdit2ListWidget* myGrp; + QLineEdit *myMainShape; + QLineEdit *myMainFile; + QListWidget *myListGroups; + QListWidget *myListFields; + QPushButton *mySelBtn; private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); //void ValueChangedInSpinBox(); diff --git a/src/ImportExportGUI/ImportExportGUI_Widgets.cxx b/src/ImportExportGUI/ImportExportGUI_Widgets.cxx deleted file mode 100644 index 0324dfb6d..000000000 --- a/src/ImportExportGUI/ImportExportGUI_Widgets.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2012 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_Widgets.cxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// -#include "ImportExportGUI_Widgets.h" - -////////////////////////////////////////// -// ImportExportGUI_1Sel1LineEdit2ListWidget -////////////////////////////////////////// - -ImportExportGUI_1Sel1LineEdit2ListWidget::ImportExportGUI_1Sel1LineEdit2ListWidget( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} -ImportExportGUI_1Sel1LineEdit2ListWidget::~ImportExportGUI_1Sel1LineEdit2ListWidget() -{ -} - diff --git a/src/ImportExportGUI/ImportExportGUI_Widgets.h b/src/ImportExportGUI/ImportExportGUI_Widgets.h deleted file mode 100644 index 865542805..000000000 --- a/src/ImportExportGUI/ImportExportGUI_Widgets.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2012 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_Widgets.h -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// -#ifndef IMPORTEXPORTGUI_WIDGETS_H -#define IMPORTEXPORTGUI_WIDGETS_H - -////////////////////////////////////////// -// ImportExportGUI_1Sel1LineEdit2ListWidget -////////////////////////////////////////// - -#include "ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h" - -class ImportExportGUI_1Sel1LineEdit2ListWidget : public QWidget, - public Ui::ImportExportGUI_1Sel1LineEdit2ListWidget_QTD -{ - Q_OBJECT - -public: - ImportExportGUI_1Sel1LineEdit2ListWidget( QWidget* = 0, Qt::WindowFlags = 0 ); - ~ImportExportGUI_1Sel1LineEdit2ListWidget(); -}; - -#endif // MEASUREGUI_WIDGETS_H diff --git a/src/ImportExportGUI/Makefile.am b/src/ImportExportGUI/Makefile.am index 1959304e6..28d9303b5 100644 --- a/src/ImportExportGUI/Makefile.am +++ b/src/ImportExportGUI/Makefile.am @@ -22,33 +22,35 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am +# Libraries targets +lib_LTLIBRARIES = libImportExportGUI.la + # header files salomeinclude_HEADERS = \ - ImportExportGUI.h \ - ImportExportGUI_Widgets.h + ImportExportGUI.h \ + ImportExportGUI_ExportXAODlg.h -IMPORTEXPORT_INCLUDES = -IMPORTEXPORT_INCLUDES += ImportExportGUI_ExportXAODlg.h +#IMPORTEXPORT_INCLUDES = +#IMPORTEXPORT_INCLUDES += ImportExportGUI_ExportXAODlg.h ##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@## -salomeinclude_HEADERS += $(IMPORTEXPORT_INCLUDES) - -# Libraries targets -lib_LTLIBRARIES = libImportExportGUI.la +#salomeinclude_HEADERS += $(IMPORTEXPORT_INCLUDES) dist_libImportExportGUI_la_SOURCES = \ - ImportExportGUI.cxx \ - ImportExportGUI_Widgets.cxx + ImportExportGUI_ExportXAODlg.h \ + ImportExportGUI.h \ + ImportExportGUI_ExportXAODlg.cxx \ + ImportExportGUI.cxx -IMPORTEXPORT_SOURCES = -IMPORTEXPORT_SOURCES += ImportExportGUI_ExportXAODlg.h ImportExportGUI_ExportXAODlg.cxx +#IMPORTEXPORT_SOURCES = +#IMPORTEXPORT_SOURCES += ImportExportGUI_ExportXAODlg.h ImportExportGUI_ExportXAODlg.cxx ##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@## -dist_libImportExportGUI_la_SOURCES += $(IMPORTEXPORT_SOURCES) +#dist_libImportExportGUI_la_SOURCES += $(IMPORTEXPORT_SOURCES) MOC_FILES = -IMPORTEXPORT_MOC_FILES = +IMPORTEXPORT_MOC_FILES = ImportExportGUI_moc.cxx IMPORTEXPORT_MOC_FILES += ImportExportGUI_ExportXAODlg_moc.cxx ##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@## @@ -57,10 +59,6 @@ MOC_FILES += $(IMPORTEXPORT_MOC_FILES) nodist_libImportExportGUI_la_SOURCES = \ $(MOC_FILES) -UIC_FILES = \ - ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h - -BUILT_SOURCES = $(UIC_FILES) # additional information to compile and link file libImportExportGUI_la_CPPFLAGS = \ diff --git a/src/Makefile.am b/src/Makefile.am index 8646ff650..6e93da550 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,7 @@ SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM \ BREPExport BREPImport IGESExport IGESImport STEPExport \ - STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \ + STEPImport STLExport VTKExport ShHealOper XAO GEOMImpl GEOM_I \ GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY if WITH_OPENCV @@ -40,9 +40,9 @@ endif DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ SKETCHER OCC2VTK GEOM BREPExport \ BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \ - VTKExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \ + VTKExport ShHealOper XAO GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \ GEOM_SWIG OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI \ GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition diff --git a/src/XAO/Geometry.cxx b/src/XAO/Geometry.cxx index 848280774..38d27d7bf 100644 --- a/src/XAO/Geometry.cxx +++ b/src/XAO/Geometry.cxx @@ -30,6 +30,18 @@ #include #include #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace std; using namespace XAO; @@ -78,47 +90,161 @@ Geometry::~Geometry() delete _myIdsSolids; } -Geometry *Geometry::New() +void Geometry::setShape(TopoDS_Shape Shape) { - return new Geometry; + _myShape = Shape; + + // intialization of Ids + initListIds(TopAbs_VERTEX); + initListIds(TopAbs_EDGE); + initListIds(TopAbs_FACE); + initListIds(TopAbs_SOLID); } -void Geometry::initShapeFromBREP(const char * brep ) +void Geometry::setShape(const char * brep ) { istringstream streamBrep(brep); BRep_Builder aBuilder; BRepTools::Read(_myShape, streamBrep, aBuilder); + + // intialization of Ids + initListIds(TopAbs_VERTEX); + initListIds(TopAbs_EDGE); + initListIds(TopAbs_FACE); + initListIds(TopAbs_SOLID); } -const char * Geometry::convertShapeToBREP() +const char * Geometry::getBREP() { ostringstream streamShape; BRepTools::Write(_myShape, streamShape); return streamShape.str().c_str(); } -void Geometry::setNameVerticesAt(int i, const char *myName) +void Geometry::setVertexName(int index, const char *myName) { - if (_myNbVertices == 0 || i > _myNbVertices) + if (_myNbVertices == 0 || index > _myNbVertices) Standard_TypeMismatch::Raise("Problem with number of vertices"); if (_myNamesVertices == NULL) _myNamesVertices = new std::string[_myNbVertices]; - _myNamesVertices[i] = myName; + _myNamesVertices[index] = myName; } -void Geometry::setNamesVertices(const char **myNames) +void Geometry::changeVertexName(int id, const char *myName) { + if (_myNbVertices == 0) + Standard_TypeMismatch::Raise("Problem with number of vertices"); + if (_myNamesVertices == NULL) _myNamesVertices = new std::string[_myNbVertices]; - for (int i = 0;i < _myNbVertices; i++) - _myNamesVertices[i] = * myNames[i]; + int index = findVertex(id); + + if (index == -1) + Standard_TypeMismatch::Raise("Problem with the id of the vertex"); + + _myNamesVertices[index] = myName; +} + +const char * Geometry::findVertexName(int id) +{ + if (_myNbVertices == 0) { + Standard_TypeMismatch::Raise("Problem with number of vertices"); + return ""; + } + + int index = findVertex(id); + + if (index == -1) { + Standard_TypeMismatch::Raise("Problem with the id of the vertex"); + return ""; + } + + return _myNamesVertices[index].c_str(); +} + +int Geometry::findVertex(int id) +{ + int index = -1; + for (int i = 0, n = _myNbVertices; i < n; i++) + { + if (_myIdsVertices[i] == id) + return i; + } + return index; } -void Geometry::initIdsVertices() +void Geometry::initListIds(const Standard_Integer theShapeType) { - //TopTools_ListOfShape listShape; + std::list aList; + + TopTools_MapOfShape mapShape; + TopTools_ListOfShape listShape; + + TopExp_Explorer exp (_myShape, TopAbs_ShapeEnum(theShapeType)); + for (; exp.More(); exp.Next()) + if (mapShape.Add(exp.Current())) + listShape.Append(exp.Current()); + + if (listShape.IsEmpty()) { + return ; + } + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(_myShape, anIndices); + Handle(TColStd_HArray1OfInteger) anArray; + + TopTools_ListIteratorOfListOfShape itSub (listShape); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + TopoDS_Shape aValue = itSub.Value(); + aList.push_back(anIndices.FindIndex(aValue)); + } + + std::list::iterator it = aList.begin(); + switch ( theShapeType ) { + case TopAbs_VERTEX: /* Fill vertices ids */ + { + _myNbVertices = aList.size(); + if (_myIdsVertices != NULL) + delete _myIdsVertices; + _myIdsVertices = new int[_myNbVertices]; + for (int i = 0; it != aList.end(); it++, i++) + _myIdsVertices[i] = (*it); + break; + } + case TopAbs_EDGE: /* Fill edges ids */ + { + _myNbEdges = aList.size(); + if (_myIdsEdges != NULL) + delete _myIdsEdges; + _myIdsEdges = new int[_myNbEdges]; + for (int i = 0; it != aList.end(); it++, i++) + _myIdsEdges[i] = (*it); + break; + } + case TopAbs_FACE: /* Fill faces ids */ + { + _myNbFaces = aList.size(); + if (_myIdsFaces != NULL) + delete _myIdsFaces; + _myIdsFaces = new int[_myNbFaces]; + for (int i = 0; it != aList.end(); it++, i++) + _myIdsFaces[i] = (*it); + break; + } + case TopAbs_SOLID: /* Fill solids ids */ + { + _myNbSolids = aList.size(); + if (_myIdsSolids != NULL) + delete _myIdsSolids; + _myIdsSolids = new int[_myNbSolids]; + for (int i = 0; it != aList.end(); it++, i++) + _myIdsSolids[i] = (*it); + break; + } + } + } diff --git a/src/XAO/Geometry.hxx b/src/XAO/Geometry.hxx index 4923df0fa..11accc149 100644 --- a/src/XAO/Geometry.hxx +++ b/src/XAO/Geometry.hxx @@ -31,36 +31,35 @@ namespace XAO class Geometry { public: - static Geometry *New(); + Geometry(); + ~Geometry(); + void setName(const char *name) { _myName=name; } const char *getName() const { return _myName.c_str(); } + void setFormat(const char *format) { _myFormat=format; } const char *getFormat() const { return _myFormat.c_str(); } - void setShape(TopoDS_Shape &Shape) { _myShape=Shape; } + void setShape(TopoDS_Shape Shape); TopoDS_Shape getShape() { return _myShape; } - void initShapeFromBREP(const char * brep ); - const char * convertShapeToBREP(); + void setShape(const char * brep ); + const char * getBREP(); - void setNbVertices(int nb) { _myNbVertices=nb; } - int getNbVertices() { return _myNbVertices; } - void setNameVerticesAt(int i, const char *myName); - void setNamesVertices(const char **myNames); - const char * getNameVerticesAt(int i) { return _myNamesVertices[i].c_str(); } - void initIdsVertices(); - int * getIdsVertices(); + int countVertices() { return _myNbVertices; } + int findVertex(int id); + void setVertexName(int index, const char *myName); + const char * getVertexName(int index) { return _myNamesVertices[index].c_str(); } + void changeVertexName(int id, const char *myName); + const char * findVertexName(int id); - void setNbEdges(int nb) { _myNbEdges=nb; } - int getNbEdges() { return _myNbEdges; } - void setNbFaces(int nb) { _myNbFaces=nb; } - int getNbFaces() { return _myNbFaces; } - void setNbSolids(int nb) { _myNbSolids=nb; } - int getNbSolids() { return _myNbSolids; } + int countEdges() { return _myNbEdges; } + int countFaces() { return _myNbFaces; } + int countSolids() { return _myNbSolids; } + private: - Geometry(); - ~Geometry(); + void initListIds(const Standard_Integer theShapeType); private: TopoDS_Shape _myShape; diff --git a/src/XAO/Group.cxx b/src/XAO/Group.cxx index e5951e3e1..fbc862ad4 100644 --- a/src/XAO/Group.cxx +++ b/src/XAO/Group.cxx @@ -26,17 +26,10 @@ Group::Group() { _myType = 0; _myCount = 0; - _myValues = NULL; } Group::~Group() { - if (_myValues != NULL) - delete _myValues; } -Group *Group::New() -{ - return new Group; -} diff --git a/src/XAO/Group.hxx b/src/XAO/Group.hxx index 25d88ba67..952bd319f 100644 --- a/src/XAO/Group.hxx +++ b/src/XAO/Group.hxx @@ -22,29 +22,35 @@ #define __XAO_GROUP_HXX__ #include +#include namespace XAO { class Group { public: - static Group *New(); + Group(); + ~Group(); + void setName(const char *name) { _myName=name; } const char *getName() const { return _myName.c_str(); } + void setType(int type) { _myType=type; } int getType() { return _myType; } - void setCount(int nb) { _myCount=nb; } - int getCount() { return _myCount; } + + int getCount() { return _myValues.size(); } + + void addValue(int value) {_myValues.push_back(value);} + //int getValue(int index) { return _myValues[index]; } private: - Group(); - ~Group(); + void sort() {_myValues.sort();} private: - std::string _myName; - int _myType; - int _myCount; - int *_myValues; + std::string _myName; + int _myType; + int _myCount; + std::list _myValues; }; } diff --git a/src/XAO/Makefile.am b/src/XAO/Makefile.am index 0d6e5374b..eae1a4414 100644 --- a/src/XAO/Makefile.am +++ b/src/XAO/Makefile.am @@ -44,15 +44,14 @@ dist_libXAO_la_SOURCES = \ libXAO_la_CPPFLAGS = \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ - $(KERNEL_CXXFLAGS) \ - $(GEOM_CXXFLAGS) \ - $(CAS_CPPFLAGS) \ - -I$(top_builddir) \ + $(GEOM_CXXFLAGS) \ + $(CAS_CPPFLAGS) \ + $(LIBXML_INCLUDES) \ + -I$(top_builddir) \ -I$(top_builddir)/idl libXAO_la_LDFLAGS = \ - $(CAS_LDPATH) \ + $(CAS_LDPATH) \ + $(LIBXML_LIBS) \ $(GEOM_LDFLAGS) diff --git a/src/XAO/Xao.cxx b/src/XAO/Xao.cxx index dd311aafc..179a2b7fd 100644 --- a/src/XAO/Xao.cxx +++ b/src/XAO/Xao.cxx @@ -23,21 +23,71 @@ #include "Group.hxx" #include "Field.hxx" +#include +#include +#include +#include + +#include +#include +#include +#include + using namespace XAO; Xao::Xao() { _myAuthor = "Nathalie Gore"; _myVersion = "1.0"; + _myGeometry = NULL; + _myNbGroups = 0; } -Xao::~Xao() +Xao::Xao(const char *author, const char *version) { + _myAuthor = author; + _myVersion = version; + _myGeometry = NULL; + _myNbGroups = 0; } -Xao *Xao::New() + +Xao::~Xao() { - return new Xao; + if (_myGeometry != NULL) + { + delete _myGeometry; + _myGeometry = NULL; + } } +bool Xao::Export(const char* fileName) +{ + if (_myGeometry == NULL) + return false; + + xmlDocPtr master_doc = 0; + xmlNodePtr xao_node = 0; + + //Creating the Xml document + master_doc = xmlNewDoc(BAD_CAST "1.0"); + xao_node = xmlNewNode(0, BAD_CAST "XAO"); + xmlDocSetRootElement(master_doc,xao_node); + + xmlNodePtr version_node = xmlNewChild(xao_node,0, BAD_CAST "version", BAD_CAST _myVersion.c_str()); + xmlNodePtr author_node = xmlNewChild(xao_node,0, BAD_CAST "author", BAD_CAST _myAuthor.c_str()); + + // Geometric part + xmlNodePtr geom_node = xmlNewChild(xao_node,0, BAD_CAST "geometry",0); + xmlNodePtr name_geom_node = xmlNewChild(geom_node,0, BAD_CAST "name",BAD_CAST _myGeometry->getName()); + xmlNodePtr format_geom_node = xmlNewChild(geom_node,0, BAD_CAST "name",BAD_CAST _myGeometry->getFormat()); + xmlNodePtr shape_geom_node = xmlNewChild(geom_node,0, BAD_CAST "shape",BAD_CAST _myGeometry->getBREP()); + + /*xmlNodePtr topo_geom_node = xmlNewChild(geom_node,0, BAD_CAST "topology",0); + ostringstream stream; + stream << _myGeometry->countVertices(); + xmlNodePtr count_topo_geom_node = xmlNewChild(count_topo_geom_node,0, BAD_CAST "topology", BAD_CAST stream.str().c_str());*/ + + +} diff --git a/src/XAO/Xao.hxx b/src/XAO/Xao.hxx index 0835e2048..09a695845 100644 --- a/src/XAO/Xao.hxx +++ b/src/XAO/Xao.hxx @@ -22,9 +22,17 @@ #define __XAO_XAO_HXX__ #include +#include namespace XAO { + enum Kind{ + VERTEX, + EDGE, + FACE, + SOLID + }; + class Geometry; class Group; class Field; @@ -32,28 +40,36 @@ namespace XAO class Xao { public: - static Xao *New(); + Xao(); + Xao(const char *author, const char *version); + ~Xao(); + void setAuthor(const char *author) { _myAuthor=author; } const char *getAuthor() const { return _myAuthor.c_str(); } + void setVersion(const char *version) { _myVersion=version; } const char *getVersion() const { return _myVersion.c_str(); } - void setNbGroups(int nb) { _myNbGroups=nb; } - int getNbGroups() { return _myNbGroups; } - void setNbFields(int nb) { _myNbFields=nb; } + + void setGeometry(Geometry *myGeometry) { _myGeometry=myGeometry; } + const Geometry *getGeometry() const { return _myGeometry; } + + int getNbGroups() { return _myGroups.size(); } + void addGroup(Group *myGroup) { _myGroups.push_back(myGroup); } + void removeGroup(Group *myGroup) { _myGroups.remove(myGroup); } + int getNbFields() { return _myNbFields; } + + bool Export(const char* fileName); - private: - Xao(); - ~Xao(); private: - Geometry *_myGeom; - int _myNbGroups; - Group *_myGroups; - int _myNbFields; - Field *_myFields; - std::string _myAuthor; - std::string _myVersion; + std::string _myAuthor; + std::string _myVersion; + Geometry *_myGeometry; + int _myNbGroups; + std::list _myGroups; + int _myNbFields; + //std::list _myFields; }; } diff --git a/src/XAOExport/Makefile.am b/src/XAOExport/Makefile.am deleted file mode 100644 index 581a7c8e4..000000000 --- a/src/XAOExport/Makefile.am +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2007-2012 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 : Makefile.in -# Author : Nathalie Gore -# Modified by : Nathalie Gore (OCN) - autotools usage -# Module : GEOM -# $Header: /home/server/cvs/GEOM/GEOM_SRC/src/XAOExport/Makefile.am,v 1.4 2012-08-09 07:43:00 vsr Exp $ -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# Libraries targets -lib_LTLIBRARIES = libXAOExport.la - -# Sources files -dist_libXAOExport_la_SOURCES = \ - XAOExport.cxx - -# additional information to compile and link file - -libXAOExport_la_CPPFLAGS = \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ - $(QT_INCLUDES) \ - $(LIBXML_INCLUDES) \ - $(CAS_CPPFLAGS) \ - $(GUI_CXXFLAGS) \ - $(KERNEL_CXXFLAGS) \ - $(BOOST_CPPFLAGS) \ - -I$(srcdir)/../GEOMBase \ - -I$(srcdir)/../GEOMClient \ - -I$(srcdir)/../OBJECT \ - -I$(srcdir)/../GEOMImpl \ - -I$(srcdir)/../GEOM \ - -I$(srcdir)/../GEOMGUI \ - -I$(srcdir)/../GEOMAlgo \ - -I$(top_builddir)/idl - -libXAOExport_la_LDFLAGS = \ - $(LIBXML_LIBS) \ - $(KERNEL_LDFLAGS) -lSALOMELocalTrace \ - $(GUI_LDFLAGS) -lsuit -lSalomeApp -lSVTK \ - ../GEOMBase/libGEOMBase.la \ - ../GEOMGUI/libGEOM.la \ - ../GEOMImpl/libGEOMimpl.la \ - ../GEOMAlgo/libGEOMAlgo.la \ - ../../idl/libSalomeIDLGEOM.la \ - $(STDLIB) \ - $(CAS_LDPATH) -lTKBRep diff --git a/src/XAOExport/XAOExport.cxx b/src/XAOExport/XAOExport.cxx deleted file mode 100644 index 777cf4cd6..000000000 --- a/src/XAOExport/XAOExport.cxx +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2007-2012 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 -// - -// File: XAOExport.cxx -// Created: Thu Dec 04 08:00:00 2012 -// Author: Nathalie Gore -// -// -#include "utilities.h" - -#include - -#include -#include -#include - -#include -#include -#include -#include -using namespace std; - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifdef WNT - #if defined XAOEXPORT_EXPORTS || defined XAOExport_EXPORTS - #if defined WIN32 - #define XAOEXPORT_EXPORT __declspec( dllexport ) - #else - #define XAOEXPORT_EXPORT - #endif - #else - #if defined WIN32 - #define XAOEXPORT_EXPORT __declspec( dllimport ) - #else - #define XAOEXPORT_EXPORT - #endif - #endif -#else - #define XAOEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ -XAOEXPORT_EXPORT - int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) - { - MESSAGE("Export XAO into file " << theFileName.ToCString()); - SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); - if (!app) - return 0; - - //SalomeApp_Study* anActiveStudy = ( SalomeApp_Study* ) app->activeStudy(); - SalomeApp_Study* anActiveStudy = dynamic_cast( app->activeStudy() ); - if (!anActiveStudy) - return 0; - - LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - if (!aSelMgr) - return 0; - - // get selection - SALOME_ListIO aList; - aSelMgr->selectedObjects(aList, "ObjectBrowser", false); - SALOME_ListIteratorOfListIO It (aList); - - SUIT_OverrideCursor(); - - QString nameShape; - GEOM::ListOfLong_var aSubShapesId; - for (; It.More(); It.Next()) - { - Handle(SALOME_InteractiveObject) anIObject = It.Value(); - if (anIObject->hasEntry()) - { - _PTR(SObject) SO (anActiveStudy->studyDS()->FindObjectID(anIObject->getEntry())); - if (!SO) - return 0; - GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(SO)); - if (CORBA::is_nil(anObj)) - return 0; - //nameShape = GEOMBase::GetName( anObj.get() ); - nameShape = anObj->GetName(); - - GEOM::GEOM_IShapesOperations_var aShOp = GeometryGUI::GetGeomGen()->GetIShapesOperations(anObj->GetStudyID()); - aSubShapesId = aShOp->SubShapeAllIDs(anObj, TopAbs_VERTEX, false); - } - } - - - ostringstream streamShape; - BRepTools::Write(theShape, streamShape); - - xmlDocPtr master_doc = 0; - xmlNodePtr geometry_node = 0; - - //Creating the Xml document - master_doc = xmlNewDoc(BAD_CAST "1.0"); - geometry_node = xmlNewNode(0, BAD_CAST "geometry"); - xmlDocSetRootElement(master_doc,geometry_node); - - // Creating child nodes - xmlNodePtr version_geom_node = xmlNewChild(geometry_node, 0, BAD_CAST "version",BAD_CAST "1.0"); - xmlNodePtr name_geom_node = xmlNewChild(geometry_node, 0, BAD_CAST "name",BAD_CAST nameShape.toStdString().c_str()); - xmlNodePtr format_geom_node = xmlNewChild(geometry_node, 0, BAD_CAST "format",BAD_CAST "BREP"); - xmlNodePtr shape_geom_node = xmlNewChild(geometry_node, 0, BAD_CAST "shape",BAD_CAST streamShape.str().c_str()); - xmlNodePtr topo_geom_node = xmlNewChild(geometry_node, 0, BAD_CAST "shape",BAD_CAST streamShape.str().c_str()); - - // Topomogy description - xmlNodePtr vertices_topo_geom_node = xmlNewChild(topo_geom_node,0, BAD_CAST "vertices",0); - xmlNodePtr count_vertices_topo_geom_node = xmlNewChild(vertices_topo_geom_node,0, BAD_CAST "count",BAD_CAST "12"); - - //std::string myfile(theFileName); - xmlSaveFormatFileEnc(theFileName.ToCString(), master_doc, "UTF-8", 1); - - xmlFreeDoc(master_doc); - - xmlCleanupParser(); - return 1; - } -} diff --git a/src/XAOImport/Makefile.am b/src/XAOImport/Makefile.am deleted file mode 100644 index 9948b3db7..000000000 --- a/src/XAOImport/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2007-2012 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 : Makefile.in -# Author : Nathalie Gore -# Modified by : Nathalie Gore (OCN) - autotools usage -# Module : GEOM -# $Header: /home/server/cvs/GEOM/GEOM_SRC/src/XAOImport/Makefile.am,v 1.4 2012-08-09 07:43:02 vsr Exp $ -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# Libraries targets -lib_LTLIBRARIES = libXAOImport.la - -# Sources files -dist_libXAOImport_la_SOURCES = \ - XAOImport.cxx - -# additional information to compile and link file - -libXAOImport_la_CPPFLAGS = \ - $(LIBXML_INCLUDES) \ - $(KERNEL_CXXFLAGS) \ - $(CAS_CPPFLAGS) - -libXAOImport_la_LDFLAGS = \ - $(LIBXML_LIBS) \ - $(KERNEL_LDFLAGS) -lSALOMELocalTrace \ - $(CAS_LDPATH) -lTKBRep \ - $(STDLIB) diff --git a/src/XAOImport/XAOImport.cxx b/src/XAOImport/XAOImport.cxx deleted file mode 100644 index 4ae50c077..000000000 --- a/src/XAOImport/XAOImport.cxx +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2007-2012 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 -// - -// File: XAOImport.cxx -// Created: Thu Dec 04 08:00:00 2012 -// Author: Nathalie Gore -// -// -#include "utilities.h" - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -using namespace std; - - -#ifdef WNT - #if defined XAOIMPORT_EXPORTS || defined XAOImport_EXPORTS - #if defined WIN32 - #define XAOIMPORT_EXPORT __declspec( dllexport ) - #else - #define XAOIMPORT_EXPORT - #endif - #else - #if defined WIN32 - #define XAOIMPORT_EXPORT __declspec( dllimport ) - #else - #define XAOIMPORT_EXPORT - #endif - #endif -#else - #define XAOIMPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ -XAOIMPORT_EXPORT - TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label&) - { - MESSAGE("Import XAO from file " << theFileName); - - // Read file - ifstream is; - is.open (theFileName.ToCString(), ios::binary ); - - // ***** get length of file: - is.seekg (0, std::ios::end); - long length = is.tellg(); - is.seekg (0, std::ios::beg); - - // ***** allocate memory: - char *buffer = new char [length]; - - // ***** read data as a block: - is.read (buffer,length); - - // ***** create string stream of memory contents - // NOTE: this ends up copying the buffer!!! - istringstream streamBrep( buffer ); - - // ***** delete temporary buffer - delete [] buffer; - - // ***** close filestream - is.close(); - - // Import file - TopoDS_Shape aShape; - BRep_Builder B; - BRepTools::Read(aShape, streamBrep, B); - if (aShape.IsNull()) { - theError = "XAO Import failed"; - } - return aShape; - } -} -- 2.39.2