From: cg246364 Date: Thu, 30 Sep 2021 05:09:55 +0000 (+0200) Subject: Add export boxes in ROOT format X-Git-Tag: OPERA_v0.5-s990~1^2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b88999a4777e5e2e3e92e5af36cb2db9274d2c71;p=modules%2Fshaper.git Add export boxes in ROOT format --- diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index a155317e9..36f0a39df 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/XAO ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin ${PROJECT_SOURCE_DIR}/src/PartSetPlugin + ${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin ${OpenCASCADE_INCLUDE_DIR} ) @@ -45,6 +46,7 @@ SET(PROJECT_HEADERS ExchangePlugin_ImportPart.h ExchangePlugin_ExportPart.h ExchangePlugin_Import.h + ExchangePlugin_ExportRoot.h ) SET(PROJECT_SOURCES @@ -57,6 +59,7 @@ SET(PROJECT_SOURCES ExchangePlugin_ImportPart.cpp ExchangePlugin_ExportPart.cpp ExchangePlugin_Import.cpp + ExchangePlugin_ExportRoot.cpp ) SET(XML_RESOURCES diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 6ae4199ec..cd57a9d6f 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -20,8 +20,10 @@ #include #include +#include #include #include +#include #ifdef _DEBUG #include #include @@ -34,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +46,8 @@ #include #include +#include + #include #include @@ -71,6 +76,12 @@ #include +#ifdef WIN32 +# define _separator_ '\\' +#else +# define _separator_ '/' +#endif + ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature() { } @@ -129,6 +140,19 @@ void ExchangePlugin_ExportFeature::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID()); + data()->addAttribute(ExchangePlugin_ExportFeature::ROOT_FILE_PATH_ID(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::MAIN_OBJECT_ID(), + ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::MAT_FILE_ID(), + ModelAPI_AttributeString::typeId()); + // to support previous version of document, move the selection list // if the type of export operation is XAO AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID()); @@ -153,7 +177,10 @@ void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID) string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value()); } - + else if (theID == ROOT_FILE_PATH_ID()) { + string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( + string(ExchangePlugin_ExportFeature::ROOT_FILE_PATH_ID())->value()); + } } /* @@ -167,6 +194,7 @@ void ExchangePlugin_ExportFeature::execute() AttributeStringPtr aFilePathAttr = this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID()); + std::string aFilePath = aFilePathAttr->value(); if (aFilePath.empty()) return; @@ -188,6 +216,8 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, aFormatName = "STEP"; } else if (anExtension == "IGES" || anExtension == "IGS") { aFormatName = "IGES-5.1"; + } else if (anExtension == "C") { + aFormatName = "ROOT"; } else { aFormatName = anExtension; } @@ -196,9 +226,12 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, if (aFormatName == "XAO") { exportXAO(theFileName); return; - }else if (aFormatName == "STL") { + } else if (aFormatName == "STL") { exportSTL(theFileName); return; + } else if (aFormatName == "ROOT") { + exportROOT(theFileName); + return; } // make shape for export from selected shapes @@ -661,6 +694,66 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) // LCOV_EXCL_STOP } +void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName) +{ + std::string aName = string(ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID())->value(); + std::string aTitle = string(ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID())->value(); + std::string aFileMat = string(ExchangePlugin_ExportFeature::MAT_FILE_ID())->value(); + + FeaturePtr aFeature; + + std::shared_ptr anAlgo(new GeomAlgoAPI_ROOTExport(theFileName)); + + std::list listNames = ExchangePlugin_Tools::split(theFileName, _separator_); + listNames = ExchangePlugin_Tools::split(listNames.back(), '.'); + + // Create the head of file + anAlgo->buildHead(listNames.front(), aName, aTitle); + + // Materials and mediums + std::map > aMaterials; + std::map > aMedias; + readFileMat(aFileMat, aMaterials, aMedias); + anAlgo->buildMaterialsMedias(aMaterials, aMedias); + + // Create the end of files + std::string aExportFileName = string(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID())->value(); + AttributeSelectionPtr anObjectAttr = selection(MAIN_OBJECT_ID()); + aFeature = anObjectAttr->contextFeature(); + std::string aNameShape =""; + if (aFeature.get()) { + aNameShape = Locale::Convert::toString(aFeature->firstResult()->data()->name()); + } else { + ObjectPtr anObject = anObjectAttr->contextObject(); + aNameShape = Locale::Convert::toString(anObject->data()->name()); + } + + // Add feature in the file + std::list aFeatures = document()->allFeatures(); + std::list::iterator itFeature = aFeatures.begin(); + std::vector aListNamesOfFeatures; + std::map aMapFeauturesObject; + for(; itFeature != aFeatures.end(); ++itFeature) + { + aFeature = *itFeature; + if (aFeature->getKind() == "Box") + { + std::vector aCenterDims; + aCenterDims = ExchangePlugin_ExportRoot::computeBox(aFeature); + std::wstring anObjectName = aFeature->firstResult()->data()->name(); + anAlgo->buildBox(anObjectName, aCenterDims); + aListNamesOfFeatures.push_back(anObjectName); + aListNamesOfFeatures.push_back(aFeature->data()->name()); + } + } + + // Create the end of file + anAlgo->buildEnd(aNameShape, aExportFileName); + + // Create the file with the content + anAlgo->write(); +} + bool ExchangePlugin_ExportFeature::isMacro() const { if (!data().get() || !data()->isValid()) @@ -685,3 +778,41 @@ bool ExchangePlugin_ExportFeature::isMacro() const } return true; } + + +//================================================================================================= +void ExchangePlugin_ExportFeature::readFileMat(const std::string theFileMat, + std::map >& theMaterials, + std::map >& theMedias) +{ + std::string aLine; + std::ifstream aFile(theFileMat); + if (aFile.is_open()) + { + while(getline(aFile, aLine)) + { + std::list aList = ExchangePlugin_Tools::split(aLine, ' '); + std::list::iterator itList = aList.begin(); + + bool isFirst = true; + std::string aName; + std::vector aData; + for (; itList != aList.end(); ++itList) + { + std::string anElem = *itList; + if (isFirst) + { + aName = anElem; + isFirst = false; + } else { + aData.push_back(anElem); + } + } + if (aName == "mat") + theMaterials[aData[0]] = aData; + else if (aName == "medium") + theMedias[aData[0]] = aData; + } + aFile.close(); + } +} diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h index ffd9deab8..a059b5b8c 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h @@ -150,6 +150,43 @@ public: static const std::string MY_XAO_GEOMETRY_NAME_ID("xao_geometry_name"); return MY_XAO_GEOMETRY_NAME_ID; } + /// attribute name of root file path + inline static const std::string& ROOT_FILE_PATH_ID() + { + static const std::string MY_ROOT_FILE_PATH_ID("root_file_path"); + return MY_ROOT_FILE_PATH_ID; + } + /// attribute name of author for XAO format + inline static const std::string& ROOT_MANAGER_NAME_ID() + { + static const std::string MY_ROOT_MANAGER_NAME_ID("root_manager_name"); + return MY_ROOT_MANAGER_NAME_ID; + } + /// attribute name of geometry name for XAO format + inline static const std::string& ROOT_MANAGER_TITLE_ID() + { + static const std::string MY_ROOT_MANAGER_TITLE_ID("root_manager_title"); + return MY_ROOT_MANAGER_TITLE_ID; + } + /// attribute name of file export + inline static const std::string& EXP_NAME_FILE_ID() + { + static const std::string MY_EXP_NAME_FILE_ID("root_name_file"); + return MY_EXP_NAME_FILE_ID; + } + /// Attribute name of the main solid. + inline static const std::string& MAIN_OBJECT_ID() + { + static const std::string MY_MAIN_OBJECT_ID("root_main_object"); + return MY_MAIN_OBJECT_ID; + } + /// attribute name of materials file + inline static const std::string& MAT_FILE_ID() + { + static const std::string MY_MAT_FILE_ID("mat_file"); + return MY_MAT_FILE_ID; + } + /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature(); /// Default destructor @@ -192,6 +229,15 @@ protected: /// Performs export to STL file EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName); + + /// Performs export to ROOT file + EXCHANGEPLUGIN_EXPORT void exportROOT(const std::string& theFileName); + +private: + /// Read materials and mediums in a file + void readFileMat(const std::string theFileMat, + std::map >& theMaterials, + std::map >& theMediums); }; #endif /* EXPORT_EXPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp new file mode 100644 index 000000000..721f3632b --- /dev/null +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp @@ -0,0 +1,98 @@ +// Copyright (C) 2014-2021 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, 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 "math.h" + +namespace ExchangePlugin_ExportRoot +{ + //=============================================================================================== + std::vector computeBox(FeaturePtr theFeature) + { + std::string aMethodName = + theFeature->data()->string(PrimitivesPlugin_Box::CREATION_METHOD())->value(); + + double OX, OY, OZ; + double DX, DY, DZ; + + if (aMethodName == "BoxByDimensions") { + DX = (theFeature->data()->real(PrimitivesPlugin_Box::DX_ID())->value())/2; + DY = (theFeature->data()->real(PrimitivesPlugin_Box::DY_ID())->value())/2; + DZ = (theFeature->data()->real(PrimitivesPlugin_Box::DZ_ID())->value())/2; + OX = DX; + OY = DY; + OZ = DZ; + } else if (aMethodName == "BoxByTwoPoints") { + // Get the first point + AttributeSelectionPtr aRef1 = + theFeature->data()->selection(PrimitivesPlugin_Box::POINT_FIRST_ID()); + GeomShapePtr aShape1 = aRef1->value(); + if (!aShape1.get()) + aShape1 = aRef1->context()->shape(); + std::shared_ptr aFirstPoint = GeomAlgoAPI_PointBuilder::point(aShape1); + // Get the second point + AttributeSelectionPtr aRef2 = + theFeature->data()->selection(PrimitivesPlugin_Box::POINT_SECOND_ID()); + GeomShapePtr aShape2 = aRef2->value(); + if (!aShape2.get()) + aShape2 = aRef2->context()->shape(); + std::shared_ptr aSecondPoint = GeomAlgoAPI_PointBuilder::point(aShape2); + DX = fabs(aSecondPoint->x() - aFirstPoint->x())/2; + DY = fabs(aSecondPoint->y() - aFirstPoint->y())/2; + DZ = fabs(aSecondPoint->z() - aFirstPoint->z())/2; + OX = fmin(aFirstPoint->x(), aSecondPoint->x()) + DX; + OY = fmin(aFirstPoint->y(), aSecondPoint->y()) + DY; + OZ = fmin(aFirstPoint->z(), aSecondPoint->z()) + DZ; + } else if (aMethodName == "BoxByOnePointAndDims") { + OX = theFeature->data()->real(PrimitivesPlugin_Box::OX_ID())->value(); + OY = theFeature->data()->real(PrimitivesPlugin_Box::OY_ID())->value(); + OZ = theFeature->data()->real(PrimitivesPlugin_Box::OZ_ID())->value(); + DX = theFeature->data()->real(PrimitivesPlugin_Box::HALF_DX_ID())->value(); + DY = theFeature->data()->real(PrimitivesPlugin_Box::HALF_DY_ID())->value(); + DZ = theFeature->data()->real(PrimitivesPlugin_Box::HALF_DZ_ID())->value(); + } else { + // ToDo error + return; + } + + std::vector aCenterDims; + // Put the center + aCenterDims.push_back(OX); + aCenterDims.push_back(OY); + aCenterDims.push_back(OZ); + + // Put the dimensions + aCenterDims.push_back(DX); + aCenterDims.push_back(DY); + aCenterDims.push_back(DZ); + + return aCenterDims; + + } +} // namespace ExchangePlugin_ExportRoot diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.h b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h new file mode 100644 index 000000000..73b6b7dda --- /dev/null +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h @@ -0,0 +1,32 @@ +// Copyright (C) 2014-2021 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, 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 +// + +#ifndef EXCHANGEPLUGIN_EXPORTROOT_H_ +#define EXCHANGEPLUGIN_EXPORTROOT_H_ + +namespace ExchangePlugin_ExportRoot +{ + /// Returns the coordinates of the center and the dimensions of a box + /// \param[in] theFeature a feature to obtain AttributeRefAttr + /// \param[out] theCenter coordinates of the center of the box + /// \param[out] theDimensions dimensions of the box + EXCHANGEPLUGIN_EXPORT std::vector computeBox(FeaturePtr theFeature); +} + +#endif /* EXCHANGEPLUGIN_EXPORTROOT_H_ */ diff --git a/src/ExchangePlugin/export_widget.xml b/src/ExchangePlugin/export_widget.xml index 83b9aba4d..b36da145f 100644 --- a/src/ExchangePlugin/export_widget.xml +++ b/src/ExchangePlugin/export_widget.xml @@ -80,5 +80,37 @@ + + + + + + + + + + + + + + + + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 4073754d5..de027193c 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -92,6 +92,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Defeaturing.h GeomAlgoAPI_BoundingBox.h GeomAlgoAPI_Tube.h + GeomAlgoAPI_ROOTExport.h ) SET(PROJECT_SOURCES @@ -163,6 +164,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Defeaturing.cpp GeomAlgoAPI_BoundingBox.cpp GeomAlgoAPI_Tube.cpp + GeomAlgoAPI_ROOTExport.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp new file mode 100644 index 000000000..de4214ab7 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp @@ -0,0 +1,122 @@ +// Copyright (C) 2014-2021 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, 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 + +//================================================================================================= +static std::string doubleToString(const double& theValue) +{ + std::ostringstream str; + str << theValue; + return str.str(); +} + +//================================================================================================= +GeomAlgoAPI_ROOTExport::GeomAlgoAPI_ROOTExport(const std::string& theFileName) +{ + myFileName = theFileName; +} + +//================================================================================================= +void GeomAlgoAPI_ROOTExport::buildHead(const std::string& theMethodName, const std::string& theName, + const std::string& theTitle) +{ + myContent << "void " << theMethodName << "() {" << std::endl; + myContent << "gSystem->Load(\"libGeom\");" << std::endl; + myContent << "TGeoManager *geom = new TGeoManager(\"" << theName; + myContent << "\",\"" << theTitle << "\");" << std::endl; + myContent << std::endl; +} + +//================================================================================================= +void GeomAlgoAPI_ROOTExport::buildEnd(const std::string theSolidName, + const std::string theExportName) +{ + myContent << "// ####################################" << std::endl; + myContent << "geom->SetTopVolume(" << theSolidName << ");" << std::endl; + myContent << "geom->CloseGeometry();" << std::endl; + myContent << theSolidName + "->SetVisContainers(kTRUE);" << std::endl; + myContent << "geom->SetTopVisible(kTRUE);" << std::endl; + myContent << "geom->Export(\"" + theExportName + "\");" << std::endl; + myContent << "geom->CheckOverlaps(0.0001);" << std::endl; + myContent << "geom->PrintOverlaps();" << std::endl; + myContent << theSolidName + "->Draw();" << std::endl; + myContent << "}" << std::endl; +} + +//================================================================================================= +void GeomAlgoAPI_ROOTExport::buildMaterialsMedias( + const std::map > theMaterials, + const std::map > theMedias) +{ + const std::map >::const_iterator + anItMat = theMaterials.begin(), aLastMat = theMaterials.end(); + for(; anItMat != aLastMat; anItMat++) { + std::vector aValues = anItMat->second; + myContent << "TGeoMaterial *" << anItMat->first << " = new TGeoMaterial(\"" << aValues[1] << + "\"," << aValues[2] << "," << aValues[3] << "," << aValues[4] << ");" << std::endl; + } + + const std::map >::const_iterator + anItMed = theMedias.begin(), aLastMed = theMedias.end(); + for(; anItMed != aLastMed; anItMed++) { + std::vector aValues = anItMed->second; + myContent << "TGeoMedium *" << anItMed->first << " = new TGeoMedium(\"" << aValues[1] << + "\"," << aValues[2] << "," << aValues[3] << ");" << std::endl; + } + myContent << std::endl; +} + +//================================================================================================= +void GeomAlgoAPI_ROOTExport::buildBox(const std::wstring& theObjectName, + const std::vector theCenterDims) +{ + std::string anObjectName(theObjectName.begin(), theObjectName.end()); + + myContent << "Double_t point_" << anObjectName << "[3] = {"; + myContent << doubleToString(theCenterDims[0]) << "," << doubleToString(theCenterDims[1]) << ","; + myContent << (theCenterDims[2]) << "};" << std::endl; + + myContent << "TGeoBBox *" << anObjectName << " = new TGeoBBox(\""; + myContent << anObjectName << "\","; + myContent << doubleToString(theCenterDims[3]) << "," << doubleToString(theCenterDims[4]) << ","; + myContent << doubleToString(theCenterDims[5]) << ",point_"; + myContent << anObjectName << ");" << std::endl << std::endl; +} + +//================================================================================================= +bool GeomAlgoAPI_ROOTExport::write() +{ + std::ofstream aFile; + OSD_OpenStream(aFile, myFileName.c_str(), std::ofstream::out); + if (!aFile.is_open()) + return false; + + aFile << myContent.str() << std::endl; + aFile.close(); + return true; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h new file mode 100644 index 000000000..f300e9e01 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h @@ -0,0 +1,64 @@ +// Copyright (C) 2014-2021 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, 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 +// + +#ifndef GEOMALGOAPI_ROOTEXPORT_H_ +#define GEOMALGOAPI_ROOTEXPORT_H_ + +#include + +#include +#include +#include +#include + +/**\class GeomAlgoAPI_ROOTExport + * \ingroup DataAlgo + * \brief Allows to export results to a root file + */ +class GeomAlgoAPI_ROOTExport +{ + public: + GEOMALGOAPI_EXPORT GeomAlgoAPI_ROOTExport(const std::string& theFileName); + + /// Build the head of file + GEOMALGOAPI_EXPORT void buildHead(const std::string& theMethodName, const std::string& theName, + const std::string& theTitle); + + /// Build the end of file + GEOMALGOAPI_EXPORT void buildEnd(const std::string theSolidName, + const std::string theExportName); + + /// Build the materials ans mediums + GEOMALGOAPI_EXPORT void buildMaterialsMedias( + const std::map > theMaterials, + const std::map > theMedias); + + /// Build box + GEOMALGOAPI_EXPORT void buildBox(const std::wstring& theObjectName, + const std::vector theCenterDims); + + /// Write the file + GEOMALGOAPI_EXPORT bool write(); + + private: + std::string myFileName; /// File name for materials and medias + std::ostringstream myContent; /// X coordinate of the center to create a box. +}; + +#endif // GEOMALGOAPI_ROOTEXPORT_H_ diff --git a/src/PrimitivesPlugin/doc/images/Tube_button.png b/src/PrimitivesPlugin/doc/images/Tube_button.png index 3e274917c..26db05d57 100755 Binary files a/src/PrimitivesPlugin/doc/images/Tube_button.png and b/src/PrimitivesPlugin/doc/images/Tube_button.png differ diff --git a/src/PrimitivesPlugin/icons/tube.png b/src/PrimitivesPlugin/icons/tube.png index 3e274917c..26db05d57 100755 Binary files a/src/PrimitivesPlugin/icons/tube.png and b/src/PrimitivesPlugin/icons/tube.png differ