}
-/// Constructor with values for export in other formats than XAO.
+/// Constructor with values for export in other formats than XAO or ROOT.
ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::string & theFilePath,
const std::list<ModelHighAPI_Selection> & theSelectionList,
apply(); // finish operation to make sure the export is done on the current state of the history
}
+/// Constructor with values for ROOT export.
+ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string & theFilePath,
+ const std::string & theManagerName,
+ const std::string & theManagerTitle,
+ const std::string & theMatFile,
+ const std::string & theRootNameFile,
+ const ModelHighAPI_Selection & theMainObject)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+ fillAttribute("ROOT", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID()));
+ fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::ROOT_FILE_PATH_ID()));
+ fillAttribute(theManagerName, theFeature->string(ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID()));
+ fillAttribute(theManagerTitle, theFeature->string(ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID()));
+ fillAttribute(theMatFile, theFeature->string(ExchangePlugin_ExportFeature::MAT_FILE_ID()));
+ fillAttribute(theRootNameFile, theFeature->string(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID()));
+ fillAttribute(theMainObject, theFeature->selection(ExchangePlugin_ExportFeature::MAIN_OBJECT_ID()));
+ fillAttribute("ROOT", theFeature->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID()));
+ execute();
+ apply(); // finish operation to make sure the export is done on the current state of the history
+}
+
ExchangeAPI_Export::~ExchangeAPI_Export()
{
}
theDumper << ", '" << theGeometryName << "'";
theDumper << ")" << std::endl;
}
+ else if (exportType == "ROOT") {
+ std::string aTmpROOTFile =
+ aBase->string(ExchangePlugin_ExportFeature::ROOT_FILE_PATH_ID())->value();
+ correctSeparators(aTmpROOTFile);
+ theDumper << "exportToROOT(" << aDocName << ", '" << aTmpROOTFile << "'" ;
+ std::string theManagerName = aBase->string(ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID())->value();
+ theDumper << ", '" << theManagerName << "'";
+ std::string theManagerTitle =aBase->string(ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID())->value();
+ theDumper << ", '" << theManagerTitle << "'";
+ std::string theMatFile = aBase->string(ExchangePlugin_ExportFeature::MAT_FILE_ID())->value();
+ theDumper << ", '" << theMatFile << "'";
+ std::string theExpNameFile = aBase->string(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID())->value();
+ theDumper << ", '" << theExpNameFile << "'";
+ AttributeSelectionPtr anAttrObject =
+ aBase->selection(ExchangePlugin_ExportFeature::MAIN_OBJECT_ID());
+ theDumper << ", " << anAttrObject;
+ theDumper << ")" << std::endl;
+ }
else {
std::string aFilePath = aBase->string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->value();
correctSeparators(aFilePath);
return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theSelectedShape, "XAO"));
}
+ExportPtr exportToROOT(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const std::string & theFilePath,
+ const std::string & theManagerName,
+ const std::string & theManagerTitle,
+ const std::string & theMatFile,
+ const std::string & theRootNameFile,
+ const ModelHighAPI_Selection& theMainObject)
+{
+ apply(); // finish previous operation to make sure all previous operations are done
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(ExchangePlugin_ExportFeature::ID());
+ return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theManagerName, theManagerTitle,
+ theMatFile, theRootNameFile, theMainObject));
+}
+
//--------------------------------------------------------------------------------------
/// Constructor with values for XAO of selected result export.
EXCHANGEAPI_EXPORT
- explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string & theFilePath,
- const ModelHighAPI_Selection& theResult,
- const std::string & theAuthor,
- const std::string & theGeometryName = std::string());
+ explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string & theFilePath,
+ const ModelHighAPI_Selection& theResult,
+ const std::string & theAuthor,
+ const std::string & theGeometryName = std::string());
- /// Constructor with values for export in other formats than XAO.
+ /// Constructor with values for export in other formats than XAO or ROOT.
EXCHANGEAPI_EXPORT
explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::string & theFilePath,
const std::list<ModelHighAPI_Selection> & theSelectionList,
const std::string & theFileFormat = std::string());
+
+ EXCHANGEAPI_EXPORT
+ explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string & theFilePath,
+ const std::string & theManagerName,
+ const std::string & theManagerTitle,
+ const std::string & theMatFile,
+ const std::string & theRootNameFile,
+ const ModelHighAPI_Selection & theMainObject);
/// Destructor.
EXCHANGEAPI_EXPORT
virtual ~ExchangeAPI_Export();
- INTERFACE_7(ExchangePlugin_ExportFeature::ID(),
+ INTERFACE_12(ExchangePlugin_ExportFeature::ID(),
exportType, ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(),
ModelAPI_AttributeString, /** ExportType */,
filePath, ExchangePlugin_ExportFeature::FILE_PATH_ID(),
xaoAuthor, ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(),
ModelAPI_AttributeString, /** xao author */,
xaoGeometryName, ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
- ModelAPI_AttributeString, /** xao geometry name */)
+ ModelAPI_AttributeString, /** xao geometry name */,
+ rootFilePath, ExchangePlugin_ExportFeature::ROOT_FILE_PATH_ID(),
+ ModelAPI_AttributeString, /** root file path */,
+ rootMainObject, ExchangePlugin_ExportFeature::MAIN_OBJECT_ID(),
+ ModelAPI_AttributeSelection, /**root main ovject */,
+ rootManagerName, ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID(),
+ ModelAPI_AttributeString, /** root manager name */,
+ rootManagerTitle, ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID(),
+ ModelAPI_AttributeString, /** root manager title */,
+ rootNameFile , ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID(),
+ ModelAPI_AttributeString, /** root name file */
+ )
/// Dump wrapped feature
EXCHANGEAPI_EXPORT
const std::string & theAuthor = std::string(),
const std::string & theGeometryName = std::string());
+ /**\ingroup CPPHighAPI
+ * \brief Exports to ROOT file all features of the current document.
+ */
+ EXCHANGEAPI_EXPORT
+ ExportPtr exportToROOT(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const std::string & theFilePath,
+ const std::string & theManagerName,
+ const std::string & theManagerTitle,
+ const std::string & theMatFile,
+ const std::string & theRootNameFile,
+ const ModelHighAPI_Selection& theMainObject);
+
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
#endif /* SRC_EXCHANGEAPI_EXCHANGEAPI_EXPORT_H_ */
${PROJECT_SOURCE_DIR}/src/XAO
${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin
${PROJECT_SOURCE_DIR}/src/CollectionPlugin
+ ${PROJECT_SOURCE_DIR}/src/FeaturesPlugin
)
SET(PROJECT_HEADERS
Test2459.py
TestExportToXAOWithFields.py
TestExportToXAOWithGroupNotUpdated.py
+ TestExportToROOT.py
TestExport_FiniteValidator.py
)
ModelAPI_AttributeString::typeId());
data()->addAttribute(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_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());
anAlgo->buildBox(anObjectName, anOx, anOy, anOz, aDx, aDy, aDz);
aListNamesOfFeatures.push_back(anObjectName);
aListNamesOfFeatures.push_back(aCurFeature->data()->name());
+ } else if (aCurFeature->getKind() == "Translation") {
+ double aDx, aDy, aDz;
+ std::string anObjectName = aCurFeature->firstResult()->data()->name();
+ ExchangePlugin_ExportRoot::computeTranslation(aCurFeature, aDx, aDy, aDz);
+ anAlgo->buildTranslation(anObjectName, aDx, aDy, aDz);
+ aListNamesOfFeatures.push_back(anObjectName);
+ aListNamesOfFeatures.push_back(aCurFeature->data()->name());
}
}
}
}
- anAlgo->buildEnd();
+ std::string aExportFileName = string(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID())->value();
+ AttributeSelectionPtr anObjectAttr = selection(MAIN_OBJECT_ID());
+ FeaturePtr aFeature = anObjectAttr->contextFeature();
+ std::string aNameShape ="";
+ if (aFeature.get()) {
+ aNameShape = aFeature->firstResult()->data()->name();
+ } else {
+ ObjectPtr anObject = anObjectAttr->contextObject();
+ aNameShape = anObject->data()->name();
+ }
+
+ anAlgo->buildEnd(aNameShape, aExportFileName);
// Create the file with the content
anAlgo->write();
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()
{
#include <CollectionPlugin_Group.h>
#include <ExchangePlugin_Tools.h>
+#include <FeaturesPlugin_Translation.h>
#include <PrimitivesPlugin_Box.h>
#include <fstream>
double& OX, double& OY, double& OZ,
double& DX, double& DY, double& DZ)
{
- std::string aMethodName = theCurFeature->data()->string(PrimitivesPlugin_Box::CREATION_METHOD())->value();
+ std::string aMethodName =
+ theCurFeature->data()->string(PrimitivesPlugin_Box::CREATION_METHOD())->value();
if (aMethodName == "BoxByDimensions") {
DX = (theCurFeature->data()->real(PrimitivesPlugin_Box::DX_ID())->value())/2;
DY = (theCurFeature->data()->real(PrimitivesPlugin_Box::DY_ID())->value())/2;
OY = DY;
OZ = DZ;
} else if (aMethodName == "BoxByTwoPoints") {
- AttributeSelectionPtr aRef1 = theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_FIRST_ID());
- AttributeSelectionPtr aRef2 = theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_SECOND_ID());
+ AttributeSelectionPtr aRef1 =
+ theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_FIRST_ID());
+ AttributeSelectionPtr aRef2 =
+ theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_SECOND_ID());
GeomShapePtr aShape1 = aRef1->value();
if (!aShape1.get())
aShape1 = aRef1->context()->shape();
}
}
+void ExchangePlugin_ExportRoot::computeTranslation(FeaturePtr theCurFeature,
+ double& DX, double& DY, double& DZ)
+{
+ std::string aMethodName =
+ theCurFeature->data()->string(FeaturesPlugin_Translation::CREATION_METHOD())->value();
+ if (aMethodName == "ByDimensions") {
+ DX = theCurFeature->data()->real(FeaturesPlugin_Translation::DX_ID())->value();
+ DY = theCurFeature->data()->real(FeaturesPlugin_Translation::DY_ID())->value();
+ DZ = theCurFeature->data()->real(FeaturesPlugin_Translation::DZ_ID())->value();
+ }
+}
+
void ExchangePlugin_ExportRoot::computeGroup(FeaturePtr theCurFeature,
std::vector<std::string>& theListNames)
{
static void computeBox(FeaturePtr theCurFeature,
double& OX, double& OY, double& OZ, double& DX, double& DY, double& DZ);
+ /// Compute ....
+ static void computeTranslation(FeaturePtr theCurFeature, double& DX, double& DY, double& DZ);
+
/// Compute ....
static void computeGroup(FeaturePtr theCurFeature, std::vector<std::string>& theListNames);
};
</stringvalue>
<stringvalue id="root_manager_title"
label="Manager title"
- placeholder="Please input the title of the manager">
+ placeholder="Please input the title of the title">
</stringvalue>
+ <stringvalue id="root_name_file"
+ label="Name file export"
+ placeholder="Please input the name of file export">
+ </stringvalue>
+ <shape_selector id="root_main_object"
+ icon=""
+ label="Main object"
+ tooltip="Select solid object"
+ shape_types="solids"
+ default=""
+ geometrical_selection="true">
+ <validator id="GeomValidators_ShapeType" parameters="solid"/>
+ </shape_selector>
<file_selector id="mat_file" title="Materials file" path="">
</file_selector>
</case>
{
myContent += "Double_t point_"+theObjectName+"[3] = {"+doubleToString(theOX)+",";
myContent += doubleToString(theOY)+","+doubleToString(theOZ)+"};\n";
- myContent += "TGeoBBox* " + theObjectName + "= new TGeoBBox(\"" +theObjectName + "\",";
+ myContent += "TGeoBBox *" + theObjectName + "_tmp = new TGeoBBox(\"" +theObjectName + "_tmp\",";
myContent += doubleToString(theDX)+","+doubleToString(theDY)+","+doubleToString(theDZ)+",point_";
myContent += theObjectName + ");\n";
}
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::buildTranslation(const std::string& theObjectName,
+ const double theDX, const double theDY,
+ const double theDZ)
+{
+ myContent += "TGeoTranslation *" + theObjectName;
+ myContent += "_tmp = new TGeoTranslation(\"" + theObjectName + "_tmp\",";
+ myContent += doubleToString(theDX) + "," + doubleToString(theDY) + ",";
+ myContent += doubleToString(theDZ) + ");\n";
+}
//=================================================================================================
void GeomAlgoAPI_ROOTExport::buildMatAndMedium(
const std::string theGeometryName,
const std::string theMediumName)
{
- myContent += "TGeoVolume *" + theName + " = new TGeoVolume(\"" + theName;
- myContent += "\"," + theGeometryName + "," + theMediumName + ");\n";
+ myContent += "TGeoVolume *" + theGeometryName + " = new TGeoVolume(\"" + theName;
+ myContent += "\"," + theGeometryName + "_tmp," + theMediumName + ");\n";
}
//=================================================================================================
-void GeomAlgoAPI_ROOTExport::buildEnd()
+void GeomAlgoAPI_ROOTExport::buildEnd(const std::string theSolidName,
+ const std::string theExportName)
{
+ myContent += "// ####################################\n";
+ myContent += "geom->SetTopVolume(" + theSolidName + ");\n";
+ myContent += "geom->CloseGeometry();\n";
+ myContent += theSolidName + "->SetVisContainers(kTRUE);\n";
+ myContent += "geom->SetTopVisible(kTRUE);\n";
+ myContent += "geom->Export(\"" + theExportName + "\");\n";
+ myContent += "geom->CheckOverlaps(0.0001);\n";
+ myContent += "geom->PrintOverlaps();\n";
+ myContent += theSolidName + "->Draw();\n";
myContent += "}";
}
GEOMALGOAPI_EXPORT void buildBox(const std::string& theObjectName,
const double theOX, const double theOY, const double theOZ,
const double theDX, const double theDY, const double theDZ);
+
+ /// Build translation
+ GEOMALGOAPI_EXPORT void buildTranslation(const std::string& theObjectName,
+ const double theDX, const double theDY,
+ const double theDZ);
/// Build mat and medium
GEOMALGOAPI_EXPORT void buildMatAndMedium(
const std::string theMediumName);
/// Build the end of file
- GEOMALGOAPI_EXPORT void buildEnd();
+ GEOMALGOAPI_EXPORT void buildEnd(const std::string theName, const std::string theExportName);
/// Write the file
GEOMALGOAPI_EXPORT bool write();
"""Package for Exchange plugin for the Parametric Geometry API of the Modeler.
"""
-from ExchangeAPI import addImport, exportToFile, exportToXAO
\ No newline at end of file
+from ExchangeAPI import addImport, exportToFile, exportToXAO, exportToROOT