From: mpa Date: Wed, 3 Sep 2014 08:40:01 +0000 (+0400) Subject: Implementation of ACISPLUGIN as a GEOM plugin (add renamed files) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=078482e428af0ad5c9c7278f5d1fd3b747f82f38;p=plugins%2Facisplugin.git Implementation of ACISPLUGIN as a GEOM plugin (add renamed files) --- diff --git a/src/ACISExport/ACISExport.cxx b/src/ACISExport/ACISExport.cxx deleted file mode 100644 index aaecd27..0000000 --- a/src/ACISExport/ACISExport.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2014 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, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#include - -#include -#include -#include -#include - -#ifdef ACIS_HASLICENSE -#include - -#include -#include -#endif // ACIS_HASLICENSE - -extern "C" -{ - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - ACISPLUGIN_EXPORT - int GetVersion() - { - return ACISPLUGIN_VERSION; - } - - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - ACISPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)ACISPLUGIN_VERSION_STR; - } - - /*! - \brief Export shape to the ACIS format. - \param theShape shape being exported - \param theFileName file path - \param theFormatName file format signature - \return error status (0 in case of success) - */ - ACISPLUGIN_EXPORT - int Export(const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName) - { -#ifdef ACIS_HASLICENSE - try { - OCCLicense_Activate("SAT-W-"OCC_VERSION_STRING, ACIS_WRITE_LICENSE); - } - catch (Standard_LicenseError) { - return 1; - } -#endif // ACIS_HASLICENSE - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - SatControl_Writer aWriter; - - try { - IFSelect_ReturnStatus status ; - status = aWriter.TransferShape(theShape); - if ( status == IFSelect_RetDone ) - status = aWriter.WriteFile( theFileName.ToCString() ) ; - if ( status == IFSelect_RetDone ) - return 1; - } - catch(Standard_Failure) { - return 1; - } - return 0; - } -} // end of extern "C" diff --git a/src/ACISImport/ACISImport.cxx b/src/ACISImport/ACISImport.cxx deleted file mode 100644 index 352cc63..0000000 --- a/src/ACISImport/ACISImport.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2014 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, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ACIS_HASLICENSE -#include - -#include -#include -#endif // ACIS_HASLICENSE - -extern "C" -{ - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - ACISPLUGIN_EXPORT - int GetVersion() - { - return ACISPLUGIN_VERSION; - } - - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - ACISPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)ACISPLUGIN_VERSION_STR; - } - - /*! - \brief Import shape from the ACIS format. - \param theFileName file path - \param theFormatName file format signature - \param theError error description, if there's any, is returned via this parameter - \param theShapeLabel a label in the CAF tree where shape attributes are set to - \return imported shape - */ - ACISPLUGIN_EXPORT - TopoDS_Shape Import(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - -#ifdef ACIS_HASLICENSE - try { - OCCLicense_Activate( "SAT-R-"OCC_VERSION_STRING, ACIS_READ_LICENSE); - } - catch (Standard_LicenseError) { - return aResShape; - } -#endif // ACIS_HASLICENSE - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - SatControl_Reader aReader; - - try { - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - aReader.TransferRoots(); - aResShape = aReader.OneShape(); - Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); - Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); - if( !TR.IsNull() ) { - Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); - Standard_Integer nb = Model->NbEntities(); - for (Standard_Integer i = 1; i <= nb; i ++) { - Handle(AcisEnt_Attrib) attr = Handle(AcisEnt_Attrib)::DownCast ( Model->Value(i) ); - if ( attr.IsNull() ) continue; //not only Entity Label (f.18) but Name Property also - - TCollection_AsciiString aName; - if ( attr->IsKind(STANDARD_TYPE(AcisAttr_AttribGenName)) ) { - Handle(AcisAttr_AttribGenName) attrname = Handle(AcisAttr_AttribGenName)::DownCast ( attr ); - aName = attrname->myNameAttr; - } - else continue; // no name assigned - - // find target entity - Handle(AcisEnt_Entity) ent; - do { - ent = attr->myEntity; - attr = Handle(AcisEnt_Attrib)::DownCast ( ent ); - } while ( ! attr.IsNull() ); - if ( ent.IsNull() ) continue; // strange - no normal entity found ? - - // find target shape - Handle(Transfer_Binder) binder = TP->Find ( ent ); - if ( binder.IsNull() ) continue; - TopoDS_Shape S = TransferBRep::ShapeResult (binder); - if ( S.IsNull() ) continue; - - //if( S.IsEqual(aResShape) ) continue; - - // create label and set shape - TDF_Label L; - TDF_TagSource aTag; - L = aTag.NewChild(theShapeLabel); - TNaming_Builder tnBuild(L); - tnBuild.Generated(S); - - // set a name - TCollection_ExtendedString str(aName); - TDataStd_Name::Set(L,str); - } - } - } - else { - theError = "Wrong format of the imported file. Can't import file."; - aResShape.Nullify(); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - aResShape.Nullify(); - } - return aResShape; - } -} // end of extern "C" - diff --git a/src/ACISPlugin_Engine.hxx b/src/ACISPlugin_Engine.hxx new file mode 100644 index 0000000..94ba750 --- /dev/null +++ b/src/ACISPlugin_Engine.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2014 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, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#if !defined (__ACISPLUGIN_EXPORTS_H) +#define __ACISPLUGIN_EXPORTS_H + +#ifdef WIN32 +# if defined ACISExport_EXPORTS || defined ACISEXPORTS_EXPORTS || defined ACISImport_EXPORTS || defined ACISIMPORT_EXPORTS +# define ACISPLUGIN_EXPORT __declspec(dllexport) +# else +# define ACISPLUGIN_EXPORT __declspec(dllimport) +# endif +#else // WIN32 +# define ACISPLUGIN_EXPORT +#endif // WIN32 + +#endif // __ACISPLUGIN_EXPORTS_H diff --git a/src/ACISPlugin_ExportDriver.cxx b/src/ACISPlugin_ExportDriver.cxx new file mode 100644 index 0000000..aaecd27 --- /dev/null +++ b/src/ACISPlugin_ExportDriver.cxx @@ -0,0 +1,98 @@ +// Copyright (C) 2014 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, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include + +#include + +#include +#include +#include +#include + +#ifdef ACIS_HASLICENSE +#include + +#include +#include +#endif // ACIS_HASLICENSE + +extern "C" +{ + /*! + \brief Get version of the plugin. + \return the version of the plugin + */ + ACISPLUGIN_EXPORT + int GetVersion() + { + return ACISPLUGIN_VERSION; + } + + /*! + \brief Get version of the plugin. + \return the string representation of the plugin's version + */ + ACISPLUGIN_EXPORT + char* GetVersionStr() + { + return (char*)ACISPLUGIN_VERSION_STR; + } + + /*! + \brief Export shape to the ACIS format. + \param theShape shape being exported + \param theFileName file path + \param theFormatName file format signature + \return error status (0 in case of success) + */ + ACISPLUGIN_EXPORT + int Export(const TopoDS_Shape& theShape, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName) + { +#ifdef ACIS_HASLICENSE + try { + OCCLicense_Activate("SAT-W-"OCC_VERSION_STRING, ACIS_WRITE_LICENSE); + } + catch (Standard_LicenseError) { + return 1; + } +#endif // ACIS_HASLICENSE + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + SatControl_Writer aWriter; + + try { + IFSelect_ReturnStatus status ; + status = aWriter.TransferShape(theShape); + if ( status == IFSelect_RetDone ) + status = aWriter.WriteFile( theFileName.ToCString() ) ; + if ( status == IFSelect_RetDone ) + return 1; + } + catch(Standard_Failure) { + return 1; + } + return 0; + } +} // end of extern "C" diff --git a/src/ACISPlugin_ImportDriver.cxx b/src/ACISPlugin_ImportDriver.cxx new file mode 100644 index 0000000..352cc63 --- /dev/null +++ b/src/ACISPlugin_ImportDriver.cxx @@ -0,0 +1,163 @@ +// Copyright (C) 2014 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, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ACIS_HASLICENSE +#include + +#include +#include +#endif // ACIS_HASLICENSE + +extern "C" +{ + /*! + \brief Get version of the plugin. + \return the version of the plugin + */ + ACISPLUGIN_EXPORT + int GetVersion() + { + return ACISPLUGIN_VERSION; + } + + /*! + \brief Get version of the plugin. + \return the string representation of the plugin's version + */ + ACISPLUGIN_EXPORT + char* GetVersionStr() + { + return (char*)ACISPLUGIN_VERSION_STR; + } + + /*! + \brief Import shape from the ACIS format. + \param theFileName file path + \param theFormatName file format signature + \param theError error description, if there's any, is returned via this parameter + \param theShapeLabel a label in the CAF tree where shape attributes are set to + \return imported shape + */ + ACISPLUGIN_EXPORT + TopoDS_Shape Import(const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& /*theFormatName*/, + TCollection_AsciiString& theError, + const TDF_Label& theShapeLabel) + { + TopoDS_Shape aResShape; + +#ifdef ACIS_HASLICENSE + try { + OCCLicense_Activate( "SAT-R-"OCC_VERSION_STRING, ACIS_READ_LICENSE); + } + catch (Standard_LicenseError) { + return aResShape; + } +#endif // ACIS_HASLICENSE + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + SatControl_Reader aReader; + + try { + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + if (status == IFSelect_RetDone) { + aReader.TransferRoots(); + aResShape = aReader.OneShape(); + Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if( !TR.IsNull() ) { + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + Standard_Integer nb = Model->NbEntities(); + for (Standard_Integer i = 1; i <= nb; i ++) { + Handle(AcisEnt_Attrib) attr = Handle(AcisEnt_Attrib)::DownCast ( Model->Value(i) ); + if ( attr.IsNull() ) continue; //not only Entity Label (f.18) but Name Property also + + TCollection_AsciiString aName; + if ( attr->IsKind(STANDARD_TYPE(AcisAttr_AttribGenName)) ) { + Handle(AcisAttr_AttribGenName) attrname = Handle(AcisAttr_AttribGenName)::DownCast ( attr ); + aName = attrname->myNameAttr; + } + else continue; // no name assigned + + // find target entity + Handle(AcisEnt_Entity) ent; + do { + ent = attr->myEntity; + attr = Handle(AcisEnt_Attrib)::DownCast ( ent ); + } while ( ! attr.IsNull() ); + if ( ent.IsNull() ) continue; // strange - no normal entity found ? + + // find target shape + Handle(Transfer_Binder) binder = TP->Find ( ent ); + if ( binder.IsNull() ) continue; + TopoDS_Shape S = TransferBRep::ShapeResult (binder); + if ( S.IsNull() ) continue; + + //if( S.IsEqual(aResShape) ) continue; + + // create label and set shape + TDF_Label L; + TDF_TagSource aTag; + L = aTag.NewChild(theShapeLabel); + TNaming_Builder tnBuild(L); + tnBuild.Generated(S); + + // set a name + TCollection_ExtendedString str(aName); + TDataStd_Name::Set(L,str); + } + } + } + else { + theError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + aResShape.Nullify(); + } + return aResShape; + } +} // end of extern "C" + diff --git a/src/ACISPlugin_license.h.in b/src/ACISPlugin_license.h.in new file mode 100644 index 0000000..e41270c --- /dev/null +++ b/src/ACISPlugin_license.h.in @@ -0,0 +1,26 @@ +// Copyright (C) 2014 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, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#if !defined(__ACISPLUGIN_LICENSE_H) +#define __ACISPLUGIN_LICENSE_H + +#define ACIS_READ_LICENSE "@ACIS_READ_LICENSE@" +#define ACIS_WRITE_LICENSE "@ACIS_WRITE_LICENSE@" + +#endif // __ACISPLUGIN_LICENSE_H diff --git a/src/common/ACISPLUGIN_exports.h b/src/common/ACISPLUGIN_exports.h deleted file mode 100644 index 94ba750..0000000 --- a/src/common/ACISPLUGIN_exports.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2014 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, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#if !defined (__ACISPLUGIN_EXPORTS_H) -#define __ACISPLUGIN_EXPORTS_H - -#ifdef WIN32 -# if defined ACISExport_EXPORTS || defined ACISEXPORTS_EXPORTS || defined ACISImport_EXPORTS || defined ACISIMPORT_EXPORTS -# define ACISPLUGIN_EXPORT __declspec(dllexport) -# else -# define ACISPLUGIN_EXPORT __declspec(dllimport) -# endif -#else // WIN32 -# define ACISPLUGIN_EXPORT -#endif // WIN32 - -#endif // __ACISPLUGIN_EXPORTS_H diff --git a/src/common/ACISPLUGIN_license.h.in b/src/common/ACISPLUGIN_license.h.in deleted file mode 100644 index e41270c..0000000 --- a/src/common/ACISPLUGIN_license.h.in +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2014 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, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#if !defined(__ACISPLUGIN_LICENSE_H) -#define __ACISPLUGIN_LICENSE_H - -#define ACIS_READ_LICENSE "@ACIS_READ_LICENSE@" -#define ACIS_WRITE_LICENSE "@ACIS_WRITE_LICENSE@" - -#endif // __ACISPLUGIN_LICENSE_H