From de1c051cb1c953a24ffdb641f2b7c6db95c85445 Mon Sep 17 00:00:00 2001 From: ngo Date: Mon, 14 Jan 2013 13:10:35 +0000 Subject: [PATCH] Start Field on CAD --- adm_local/cmake_files/FindGEOM.cmake | 3 + configure.ac | 10 ++ resources/ImportExport | 8 +- resources/Makefile.am | 4 + resources/tree_field_edge.png | Bin 0 -> 286 bytes resources/tree_field_face.png | Bin 0 -> 534 bytes resources/tree_field_solid.png | Bin 0 -> 467 bytes resources/tree_field_vertex.png | Bin 0 -> 361 bytes src/Makefile.am | 3 +- src/XAO/Field.cxx | 48 +++++++ src/XAO/Field.hxx | 79 ++++++++++++ src/XAO/Geometry.cxx | 124 ++++++++++++++++++ src/XAO/Geometry.hxx | 84 ++++++++++++ src/XAO/Group.cxx | 42 ++++++ src/XAO/Group.hxx | 51 ++++++++ src/XAO/Makefile.am | 58 +++++++++ src/XAO/Xao.cxx | 43 +++++++ src/XAO/Xao.hxx | 60 +++++++++ src/XAOExport/Makefile.am | 65 ++++++++++ src/XAOExport/XAOExport.cxx | 184 +++++++++++++++++++++++++++ src/XAOImport/Makefile.am | 46 +++++++ src/XAOImport/XAOImport.cxx | 112 ++++++++++++++++ 22 files changed, 1021 insertions(+), 3 deletions(-) create mode 100644 resources/tree_field_edge.png create mode 100644 resources/tree_field_face.png create mode 100644 resources/tree_field_solid.png create mode 100644 resources/tree_field_vertex.png create mode 100644 src/XAO/Field.cxx create mode 100644 src/XAO/Field.hxx create mode 100644 src/XAO/Geometry.cxx create mode 100644 src/XAO/Geometry.hxx create mode 100644 src/XAO/Group.cxx create mode 100644 src/XAO/Group.hxx create mode 100644 src/XAO/Makefile.am create mode 100644 src/XAO/Xao.cxx create mode 100644 src/XAO/Xao.hxx create mode 100644 src/XAOExport/Makefile.am create mode 100644 src/XAOExport/XAOExport.cxx create mode 100644 src/XAOImport/Makefile.am create mode 100644 src/XAOImport/XAOImport.cxx diff --git a/adm_local/cmake_files/FindGEOM.cmake b/adm_local/cmake_files/FindGEOM.cmake index 6703e076a..6430d3f1f 100644 --- a/adm_local/cmake_files/FindGEOM.cmake +++ b/adm_local/cmake_files/FindGEOM.cmake @@ -60,3 +60,6 @@ FIND_LIBRARY(STEPImport STEPImport ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(STLExport STLExport ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(TransformationGUI TransformationGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(VTKExport VTKExport ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(XAOExport XAOExport ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(XAOImport XAOImport ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(XAO XAO ${GEOM_ROOT_DIR}/lib/salome) diff --git a/configure.ac b/configure.ac index 2ba331467..53a483bb4 100644 --- a/configure.ac +++ b/configure.ac @@ -310,6 +310,13 @@ echo CHECK_BOOST +echo +echo --------------------------------------------- +echo testing LIBXML2 +echo --------------------------------------------- + +CHECK_LIBXML + echo echo --------------------------------------------- echo Testing OpenCascade @@ -533,6 +540,9 @@ AC_OUTPUT([ \ src/ShapeRecognition/Makefile \ src/TransformationGUI/Makefile \ src/VTKExport/Makefile \ + src/XAO/Makefile \ + src/XAOExport/Makefile \ + src/XAOImport/Makefile \ resources/Makefile \ resources/GEOMCatalog.xml \ resources/SalomeApp.xml \ diff --git a/resources/ImportExport b/resources/ImportExport index f338de457..09f559732 100644 --- a/resources/ImportExport +++ b/resources/ImportExport @@ -1,10 +1,14 @@ -Import: BREP|IGES|STEP|ACIS -Export: BREP|IGES|IGES_5_3|STEP|STL_Bin|STL_ASCII|ACIS|VTK +Import: BREP|XAO|IGES|STEP|ACIS +Export: BREP|XAO|IGES|IGES_5_3|STEP|STL_Bin|STL_ASCII|ACIS|VTK BREP.Import: libBREPImport BREP.Export: libBREPExport BREP.Pattern: BREP Files ( *.brep ) +XAO.Import: libXAOImport +XAO.Export: libXAOExport +XAO.Pattern: XAO Files ( *.xao ) + IGES.Import: libIGESImport IGES.Export: libIGESExport IGES.Pattern: IGES Files ( *.iges *.igs ) diff --git a/resources/Makefile.am b/resources/Makefile.am index 57c92dd2d..621e9081b 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -182,6 +182,10 @@ tree_group_vertex.png \ tree_group_edge.png \ tree_group_face.png \ tree_group_solid.png \ +tree_field_vertex.png \ +tree_field_edge.png \ +tree_field_face.png \ +tree_field_solid.png \ tree_lcs.png \ vector.png \ vector_mode.png \ diff --git a/resources/tree_field_edge.png b/resources/tree_field_edge.png new file mode 100644 index 0000000000000000000000000000000000000000..27538a1db906b52cb30dee740a5681f781cda333 GIT binary patch literal 286 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPaw=4&bnAXo^C!o+gPZ!4!jq_6{ zUF1Dvz{9HFb20TzYC@Bd>&yi;n;Dr?BqJVw40Lk7G)3U#q|~Qh^un5Eaw;5?xU+Zn z@iQ$6>%YuU=?w9XU~f@iSADClwu0rX54)86dCx?P_M*C{i@x{%U1C#s?bkK0Qf{Xj z$EjJ~`DvFXZk$oBV!HhocUFF>g!xy$E4Nl>E)2+9AKLwD{sni_+L-d|XWuWeoB!PQ a0QZUgdWS{R?s@@T%HZkh=d#Wzp$PyUbZKV* literal 0 HcmV?d00001 diff --git a/resources/tree_field_face.png b/resources/tree_field_face.png new file mode 100644 index 0000000000000000000000000000000000000000..2a6b7af24dc3de148b3bd861ba9fad79e4e2c884 GIT binary patch literal 534 zcmV+x0_pvUP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyxC z2n`oRGk;s0bDcB7*uaNU+NvkXHm! z*eRT*6Y&oSq!3bDTbm}8kV*^BE?vOF_@eTBPKv|(k=!NR2bP^-c9`$%jH*_vqP1o= zo2h!eF4kJ6)2V7Un-Ymc7>~!wbzQO6G8&CkyWJM06qL(l5fNT;I-QOv5#b@3Ohz2X z;p*y&WHL!C7Q+FWe=9Yc&B}7QROj=V z>+kQMtTcP`jm@txhr-%EA_wLj>jXf-+d(< z4g)Y84wXr#)3RQ#75~8ZeI}F1-5b|+#kn|t&hsI=-R_aU-|z2#H6D+P<2Y!oQA%Nq zAruOswMJ{rVzE$vZOThmuGMOZqqQcV&kH~Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyxC z2o4u-$T3y`00C1;L_t(2&wWzON`gTYJ$GhSzJm%9d^!U;`Yl93Hxjhz0isn85WPYB zum^}*1Z{eN2*e(sRRqE;1tWX~QT*hz2tWG#`3_u|J7>-BnvNRs5BD1;!YR4VQL z)qTbOTa{w5$i-p-5rI+)N~v@{tu?+st^feXr_UIV$C3(3=FUw2)NdpzY{UP*(&4gxMg?g@&`^;m(5S`7ImfgP0+Dv@-CNC3g>vjmAC6>JR6(?{-d^_xy-sY3%V6)&2Z)^qv*}?-Bnv-LR$M|KhaBZT-J$Z@pQ&bxP2w z(+T|VqntQ6CY8q@dK|jpTGjXU>(5_5d(YCnlKb_`MDO=|?>p{QTsg(+jZ9mkQ42#d z595M$*=D}Z3@cW3J-@I?XXREk28rYy>$K|_Bst%Hbn^(m1oSk6r>mdKI;Vst0Ls#i Ai~s-t literal 0 HcmV?d00001 diff --git a/src/Makefile.am b/src/Makefile.am index 862b90287..9e1f269a5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,7 +34,7 @@ if GEOM_ENABLE_GUI SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase GEOMToolsGUI \ DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI \ BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI \ - GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM + GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM XAOExport XAO XAOImport endif DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ @@ -45,4 +45,5 @@ DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ + XAOExport XAOImport \ GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition diff --git a/src/XAO/Field.cxx b/src/XAO/Field.cxx new file mode 100644 index 000000000..173bb2db4 --- /dev/null +++ b/src/XAO/Field.cxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#include "Field.hxx" + +using namespace XAO; + +Field::Field() +{ + _myName = ""; + _myDimension = -1; + _myType = -1; + _myValuesCount = 0; + _myComponentCount = 0; + _myComponentNames = NULL; + _myStepCount = 0; + _mySteps = NULL; + _myStamps = NULL; + _myValues = NULL; +} + +Field::~Field() +{ +} + +Field *Field::New() +{ + return new Field; +} + + diff --git a/src/XAO/Field.hxx b/src/XAO/Field.hxx new file mode 100644 index 000000000..c7352f465 --- /dev/null +++ b/src/XAO/Field.hxx @@ -0,0 +1,79 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#ifndef __XAO_XAO_HXX__ +#define __XAO_XAO_HXX__ + +#include + +namespace XAO +{ + typedef enum + { + VERTEX = 0, + EDGE = 1, + FACE = 2, + SOLID = 3 + } FieldDimension; + + typedef enum + { + BOOLEAN = 0, + INTEGER = 1, + DOUBLE = 2, + STRING = 3 + } FieldType; + + class Field + { + public: + static Field *New(); + void setName(const char *name) { _myName=name; } + const char *getName() const { return _myName.c_str(); } + void setDimension(int nb) { _myDimension=nb; } + int getDimension() { return _myDimension; } + void setType(int type) { _myType=type; } + int getType() { return _myType; } + void setValuesCount(int nb) { _myValuesCount=nb; } + int getValuesCount() { return _myValuesCount; } + void setComponentCount(int nb) { _myComponentCount=nb; } + int getComponentCount() { return _myComponentCount; } + void setStepCount(int nb) { _myStepCount=nb; } + int getStepCount() { return _myStepCount; } + + private: + Field(); + ~Field(); + + private: + std::string _myName; + int _myDimension; + int _myType; + int _myValuesCount; + int _myComponentCount; + std::string *_myComponentNames; + int _myStepCount; + int *_mySteps; + double *_myStamps; + std::string **_myValues; + }; +} + +#endif diff --git a/src/XAO/Geometry.cxx b/src/XAO/Geometry.cxx new file mode 100644 index 000000000..848280774 --- /dev/null +++ b/src/XAO/Geometry.cxx @@ -0,0 +1,124 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#include "Geometry.hxx" +#include + +#include +#include +#include + +//#include +#include +#include +#include +#include +using namespace std; + +using namespace XAO; + +Geometry::Geometry() +{ + _myFormat = "BREP"; + + _myNbVertices = 0; + _myNamesVertices = NULL; + _myIdsVertices = NULL; + + _myNbEdges = 0; + _myNamesEdges = NULL; + _myIdsEdges = NULL; + + _myNbFaces = 0; + _myNamesFaces = NULL; + _myIdsFaces = NULL; + + _myNbSolids = 0; + _myNamesSolids = NULL; + _myIdsSolids = NULL; +} + +Geometry::~Geometry() +{ + if (_myNamesVertices != NULL) + delete _myNamesVertices; + if (_myIdsVertices != NULL) + delete _myIdsVertices; + + if (_myNamesEdges != NULL) + delete _myNamesEdges; + if (_myIdsEdges != NULL) + delete _myIdsEdges; + + if (_myNamesFaces != NULL) + delete _myNamesFaces; + if (_myIdsFaces != NULL) + delete _myIdsFaces; + + if (_myNamesSolids != NULL) + delete _myNamesSolids; + if (_myIdsSolids != NULL) + delete _myIdsSolids; +} + +Geometry *Geometry::New() +{ + return new Geometry; +} + +void Geometry::initShapeFromBREP(const char * brep ) +{ + istringstream streamBrep(brep); + BRep_Builder aBuilder; + BRepTools::Read(_myShape, streamBrep, aBuilder); +} + +const char * Geometry::convertShapeToBREP() +{ + ostringstream streamShape; + BRepTools::Write(_myShape, streamShape); + return streamShape.str().c_str(); +} + +void Geometry::setNameVerticesAt(int i, const char *myName) +{ + if (_myNbVertices == 0 || i > _myNbVertices) + Standard_TypeMismatch::Raise("Problem with number of vertices"); + + if (_myNamesVertices == NULL) + _myNamesVertices = new std::string[_myNbVertices]; + + _myNamesVertices[i] = myName; +} + +void Geometry::setNamesVertices(const char **myNames) +{ + if (_myNamesVertices == NULL) + _myNamesVertices = new std::string[_myNbVertices]; + + for (int i = 0;i < _myNbVertices; i++) + _myNamesVertices[i] = * myNames[i]; +} + +void Geometry::initIdsVertices() +{ + //TopTools_ListOfShape listShape; +} + diff --git a/src/XAO/Geometry.hxx b/src/XAO/Geometry.hxx new file mode 100644 index 000000000..4923df0fa --- /dev/null +++ b/src/XAO/Geometry.hxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#ifndef __XAO_GEOMETRY_HXX__ +#define __XAO_GEOMETRY_HXX__ + +#include + +#include +#include + +namespace XAO +{ + class Geometry + { + public: + static Geometry *New(); + 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; } + TopoDS_Shape getShape() { return _myShape; } + + void initShapeFromBREP(const char * brep ); + const char * convertShapeToBREP(); + + 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(); + + 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; } + + private: + Geometry(); + ~Geometry(); + + private: + TopoDS_Shape _myShape; + std::string _myName; + std::string _myFormat; + int _myNbVertices; + std::string *_myNamesVertices; + int *_myIdsVertices; + int _myNbEdges; + std::string *_myNamesEdges; + int *_myIdsEdges; + int _myNbFaces; + std::string *_myNamesFaces; + int *_myIdsFaces; + int _myNbSolids; + std::string *_myNamesSolids; + int *_myIdsSolids; + }; +} + +#endif diff --git a/src/XAO/Group.cxx b/src/XAO/Group.cxx new file mode 100644 index 000000000..e5951e3e1 --- /dev/null +++ b/src/XAO/Group.cxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#include "Group.hxx" + +using namespace XAO; + +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 new file mode 100644 index 000000000..25d88ba67 --- /dev/null +++ b/src/XAO/Group.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#ifndef __XAO_GROUP_HXX__ +#define __XAO_GROUP_HXX__ + +#include + +namespace XAO +{ + class Group + { + public: + static Group *New(); + 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; } + + private: + Group(); + ~Group(); + + private: + std::string _myName; + int _myType; + int _myCount; + int *_myValues; + }; +} + +#endif diff --git a/src/XAO/Makefile.am b/src/XAO/Makefile.am new file mode 100644 index 000000000..0d6e5374b --- /dev/null +++ b/src/XAO/Makefile.am @@ -0,0 +1,58 @@ +# Copyright (C) 2009-2012 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 +# +# File : Makefile.in +# Author : Nathalie Gore +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + + + +# =============================================================== +# Files to be installed +# =============================================================== +# +# header files +salomeinclude_HEADERS = \ + Xao.hxx \ + Geometry.hxx \ + Group.hxx \ + Field.hxx + +lib_LTLIBRARIES = libXAO.la +dist_libXAO_la_SOURCES = \ + Xao.cxx \ + Geometry.cxx \ + Group.cxx \ + Field.cxx + + + +libXAO_la_CPPFLAGS = \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + $(KERNEL_CXXFLAGS) \ + $(GEOM_CXXFLAGS) \ + $(CAS_CPPFLAGS) \ + -I$(top_builddir) \ + -I$(top_builddir)/idl + +libXAO_la_LDFLAGS = \ + $(CAS_LDPATH) \ + $(GEOM_LDFLAGS) + diff --git a/src/XAO/Xao.cxx b/src/XAO/Xao.cxx new file mode 100644 index 000000000..dd311aafc --- /dev/null +++ b/src/XAO/Xao.cxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#include "Xao.hxx" +#include "Geometry.hxx" +#include "Group.hxx" +#include "Field.hxx" + +using namespace XAO; + +Xao::Xao() +{ + _myAuthor = "Nathalie Gore"; + _myVersion = "1.0"; +} + +Xao::~Xao() +{ +} + +Xao *Xao::New() +{ + return new Xao; +} + + diff --git a/src/XAO/Xao.hxx b/src/XAO/Xao.hxx new file mode 100644 index 000000000..0835e2048 --- /dev/null +++ b/src/XAO/Xao.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2012 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 : Nathalie Gore (OpenCascade) + +#ifndef __XAO_XAO_HXX__ +#define __XAO_XAO_HXX__ + +#include + +namespace XAO +{ + class Geometry; + class Group; + class Field; + + class Xao + { + public: + static Xao *New(); + 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; } + int getNbFields() { return _myNbFields; } + + private: + Xao(); + ~Xao(); + + private: + Geometry *_myGeom; + int _myNbGroups; + Group *_myGroups; + int _myNbFields; + Field *_myFields; + std::string _myAuthor; + std::string _myVersion; + }; +} + +#endif diff --git a/src/XAOExport/Makefile.am b/src/XAOExport/Makefile.am new file mode 100644 index 000000000..581a7c8e4 --- /dev/null +++ b/src/XAOExport/Makefile.am @@ -0,0 +1,65 @@ +# 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 new file mode 100644 index 000000000..ed36cb0ec --- /dev/null +++ b/src/XAOExport/XAOExport.cxx @@ -0,0 +1,184 @@ +// 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_Engine* anEngine = GEOM_Engine::GetEngine(); + GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine; + if (aGen) { + /*GEOM::GEOM_IShapesOperations_var aShOp = anEngine->GetIShapesOperations(anObj->GetStudyID()); + aSubShapesId = aShOp->SubShapeAllIDs(anObj->GetMainObject(), TopAbs_VERTEX, false);*/ + GEOMImpl_IShapesOperations* anIShapesOperations = aGen->GetIShapesOperations(anObj->GetStudyID()); + aSubShapesId = anIShapesOperations->SubShapeAllIDs(anObj->GetMainShape()->GetImpl(), TopAbs_VERTEX, false); + } + //GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine(); + /*GEOM::GEOM_IShapesOperations_var aShOp = GEOMBase_Helper::getGeomEngine()->GetIShapesOperations(anObj->GetStudyID()); + aSubShapesId = aShOp->SubShapeAllIDs(anObj->GetMainObject(), 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 new file mode 100644 index 000000000..9948b3db7 --- /dev/null +++ b/src/XAOImport/Makefile.am @@ -0,0 +1,46 @@ +# 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 new file mode 100644 index 000000000..4ae50c077 --- /dev/null +++ b/src/XAOImport/XAOImport.cxx @@ -0,0 +1,112 @@ +// 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