From b88999a4777e5e2e3e92e5af36cb2db9274d2c71 Mon Sep 17 00:00:00 2001 From: cg246364 Date: Thu, 30 Sep 2021 07:09:55 +0200 Subject: [PATCH] Add export boxes in ROOT format --- src/ExchangePlugin/CMakeLists.txt | 3 + .../ExchangePlugin_ExportFeature.cpp | 135 +++++++++++++++++- .../ExchangePlugin_ExportFeature.h | 46 ++++++ .../ExchangePlugin_ExportRoot.cpp | 98 +++++++++++++ .../ExchangePlugin_ExportRoot.h | 32 +++++ src/ExchangePlugin/export_widget.xml | 32 +++++ src/GeomAlgoAPI/CMakeLists.txt | 2 + src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp | 122 ++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h | 64 +++++++++ .../doc/images/Tube_button.png | Bin 820 -> 1789 bytes src/PrimitivesPlugin/icons/tube.png | Bin 820 -> 1789 bytes 11 files changed, 532 insertions(+), 2 deletions(-) create mode 100644 src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp create mode 100644 src/ExchangePlugin/ExchangePlugin_ExportRoot.h create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h 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 3e274917c286cfa01b0cfcbac596565dba4e1b5e..26db05d57efa2fbbf5f3d47e1229fd6621ca7c7b 100755 GIT binary patch literal 1789 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKU`)((b`HpPc6ZLt$u9~nNK8(3 z$t*6&NvsSoW?;~mn4FLhOO|GKyppK57poIDp2l!g{@FekYb)G!R z+Q-Of=b*}CASGI}``7`FMf$Is&RD6MZuQ(6ci?)`vJY3g*SpL%xVo5O-IObjQWXBO zcLY!7?(&k5kO*$bdHQJ*lfZ7~6JnZ7R$M3MF()l|z9H@KMup=yM})7(1mg*{%qPM; z&UvuRI{1V6#5GSRA%FKI=eMkkdDG84YMOJztCb;{X`L$blqF$P8Zw^$X*#v&%$FV^ zR`&#rrCJrwRA0Z;kdTy^Wo*!JNM_NmVg(Bw$)o2Kj?8**Y;fb?O%wui|m2PtC zY;4!6|NpNK0|wOmGY3ADANv1)zxdz(|H};nKFhMTF;_B(DyF_OJ$~^wFw84bBRtc5 zeHpZXYz_uiMm7d!Ad8WK2}npWu!7kP3|@@VaCQ)*20~4HCIbspO%#v@ffgWUgwsq5 znBXb|7BC~&Af<**WQFI*v z8Tlpoz>q7-O!mwxNi8ZU0)`^kMworLRiK-Nusk#`v&0T&0GcpVmyJFs$dG~%5VZR&lpD=!T_jVbL ziBew4tLhC(q}(Kw&wp+axKk_yt>h6oAx94~Ln`r&$Q19+Xf3Dt6 z%6mG!!gznq5O& z1@{kRq&H+wn{Xn=&{Szng-ze4@0%{%lVenoR%4MUPE0KoRlDcM;B;eMSJC@xcjheh z*wWBxv0LQUF30Po6(4>m&RE8|Z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