Start Field on CAD

This commit is contained in:
ngo 2013-01-14 13:10:35 +00:00
parent eb33929a62
commit de1c051cb1
22 changed files with 1021 additions and 3 deletions

View File

@ -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)

View File

@ -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 \

View File

@ -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 )

View File

@ -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 \

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

View File

@ -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

48
src/XAO/Field.cxx Normal file
View File

@ -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;
}

79
src/XAO/Field.hxx Normal file
View File

@ -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 <string>
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

124
src/XAO/Geometry.cxx Normal file
View File

@ -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 <Standard_TypeMismatch.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <TopAbs.hxx>
//#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <ostream>
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;
}

84
src/XAO/Geometry.hxx Normal file
View File

@ -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 <string>
#include <SALOMEconfig.h>
#include <TopoDS_Shape.hxx>
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

42
src/XAO/Group.cxx Normal file
View File

@ -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;
}

51
src/XAO/Group.hxx Normal file
View File

@ -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 <string>
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

58
src/XAO/Makefile.am Normal file
View File

@ -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)

43
src/XAO/Xao.cxx Normal file
View File

@ -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;
}

60
src/XAO/Xao.hxx Normal file
View File

@ -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 <string>
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

65
src/XAOExport/Makefile.am Normal file
View File

@ -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

184
src/XAOExport/XAOExport.cxx Normal file
View File

@ -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
// <nathalie.gore@opencascade.com>
//
#include "utilities.h"
#include <BRepTools.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <fstream>
#include <sstream>
#include <iostream>
#include <ostream>
using namespace std;
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ViewManager.h>
#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <GEOMBase_Helper.h>
#include <GEOMBase_Skeleton.h>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Engine.hxx>
#include <GEOMImpl_Gen.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#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<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
if (!app)
return 0;
//SalomeApp_Study* anActiveStudy = ( SalomeApp_Study* ) app->activeStudy();
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( 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;
}
}

46
src/XAOImport/Makefile.am Normal file
View File

@ -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)

112
src/XAOImport/XAOImport.cxx Normal file
View File

@ -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
// <nathalie.gore@opencascade.com>
//
#include "utilities.h"
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <TDF_Label.hxx>
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
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;
}
}