std::list<FeaturePtr>::iterator itFeature = aFeatures.begin();
std::vector<std::wstring> aListNamesOfFeatures;
std::map<std::wstring, std::string> aMapFeauturesObject;
+ int aMediumIndex = 0;
for (; itFeature != aFeatures.end(); ++itFeature)
{
aFeature = *itFeature;
- std::map<std::string, double> aFeatureDimensions;
if (aFeature->getKind() == "Box")
{
+ std::map<std::string, double> aFeatureDimensions;
aFeatureDimensions = ExchangePlugin_ExportRoot::computeBox(aFeature);
std::wstring anObjectName = aFeature->firstResult()->data()->name();
anAlgo->buildBox(anObjectName, aFeatureDimensions);
}
else if (aFeature->getKind() == "Cylinder")
{
+ std::map<std::string, double> aFeatureDimensions;
aFeatureDimensions = ExchangePlugin_ExportRoot::computeCylinder(aFeature);
std::wstring anObjectName = aFeature->firstResult()->data()->name();
anAlgo->buildTube(anObjectName, aFeatureDimensions);
aListNamesOfFeatures.push_back(anObjectName);
aListNamesOfFeatures.push_back(aFeature->data()->name());
}
+ else if (aFeature->getKind() == "Volume")
+ {
+ std::map<std::string, std::string> aFeatureDimensions;
+ aFeatureDimensions = ExchangePlugin_ExportRoot::computeVolume(aFeature);
+ std::wstring anObjectName = aFeature->firstResult()->data()->name();
+ anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
+ aListNamesOfFeatures.push_back(anObjectName);
+ aListNamesOfFeatures.push_back(aFeature->data()->name());
+ }
}
// Create the end of files
#include <PrimitivesPlugin_Box.h>
#include <PrimitivesPlugin_Cylinder.h>
+#include <OperaPlugin_Volume.h>
+
#include <GeomAlgoAPI_PointBuilder.h>
#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
#include <string>
#include <iostream>
#include "math.h"
-namespace ExchangePlugin_ExportRoot
+ namespace ExchangePlugin_ExportRoot
{
//===============================================================================================
std::map<std::string, double> computeBox(FeaturePtr theFeature)
//===============================================================================================
std::map<std::string, double> computeCylinder(FeaturePtr theFeature)
{
- std::string aMethodName =
- theFeature->data()->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
-
double radius, halfdz;
radius = (theFeature->data()->real(PrimitivesPlugin_Cylinder::RADIUS_ID())->value());
halfdz = (theFeature->data()->real(PrimitivesPlugin_Cylinder::HEIGHT_ID())->value()) / 2;
return aFeatureDim;
}
+ //===============================================================================================
+ std::map<std::string, std::string> computeVolume(FeaturePtr theFeature)
+ {
+ std::string aMedium;
+
+ //Get attributes
+ aMedium = (theFeature->data()->string(OperaPlugin_Volume::MEDIUM_ID())->value());
+ AttributeSelectionPtr aSel = theFeature->data()->selectionList(OperaPlugin_Volume::OBJECTS_LIST_ID())->value(0);
+
+ //Get feature
+ ResultPtr aResult = aSel->context();
+ FeaturePtr aSelFeature = aResult->document()->feature(aResult);
+ std::string aKind = aSelFeature->getKind();
+
+ // Debug data
+ std::wstring aWShapeName = aResult ? aResult->data()->name() : aSelFeature->firstResult()->data()->name();
+ std::cout << "The volume medium is : " << aMedium << std::endl;
+ std::cout << "Feature kind is : " << aKind << std::endl;
+ std::wcout << "Feature result name is : " << aWShapeName << std::endl;
+
+ //Data out
+ std::map<std::string, std::string> aFeatureDim;
+ aFeatureDim["medium"] = aMedium;
+
+ std::string aShapeName(aWShapeName.begin(), aWShapeName.end());
+ aFeatureDim["shape"] = aShapeName;
+
+ return aFeatureDim;
+ }
+
} // namespace ExchangePlugin_ExportRoot
<< "{" << std::endl
<< std::endl;
+ myContent << "\t// ############## HEADER ##############" << std::endl;
myContent << "\t"
<< "TGeoManager *geom = new TGeoManager(\""
<< theName << "\",\""
<< theTitle << "\");" << std::endl;
+ // TGeoMaterial *matDummy = new TGeoMaterial("Dummy", 0, 0, 0);
+ myContent << "\t"
+ << "TGeoMaterial *matDummy = new TGeoMaterial(\" Dummy\", 0, 0, 0);"
+ << std::endl;
+
myContent << "\t"
<< "// ####################################" << std::endl;
}
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::addMedium(const std::string theMediumName)
+{
+ myContent << "\t"
+ << "TGeoMedium *" << theMediumName
+ << " = new TGeoMedium(\"" << theMediumName
+ << "\", 1, matDummy);" << std::endl;
+}
//=================================================================================================
void GeomAlgoAPI_ROOTExport::buildBox(const std::wstring &theObjectName,
const std::map<std::string, double> theFeatureDim)
<< "//Exporting " << anObjectName << std::endl;
myContent << "\t"
- << "Double_t point_" << anObjectName << "[3] = {"
- << doubleToString(theFeatureDim["OX"]) << ","
- << doubleToString(theFeatureDim["OY"]) << ","
- << doubleToString(theFeatureDim["OZ"]) << "}" << std::endl;
+ << "Double_t origin_" << anObjectName << "[3] = {"
+ << doubleToString(theFeatureDim["OX"]) << ", "
+ << doubleToString(theFeatureDim["OY"]) << ", "
+ << doubleToString(theFeatureDim["OZ"]) << "};" << std::endl;
myContent << "\t"
<< "TGeoBBox *" << anObjectName << " = new TGeoBBox(\""
- << anObjectName << "\","
- << doubleToString(theFeatureDim["DX"]) << ","
- << doubleToString(theFeatureDim["DY"]) << ","
- << doubleToString(theFeatureDim["DZ"]) << ","
- << "point_" << anObjectName << ");" << std::endl
+ << anObjectName << "\", "
+ << doubleToString(theFeatureDim["DX"]) << ", "
+ << doubleToString(theFeatureDim["DY"]) << ", "
+ << doubleToString(theFeatureDim["DZ"]) << ", "
+ << "origin_" << anObjectName << ");" << std::endl
<< std::endl;
}
void GeomAlgoAPI_ROOTExport::buildTube(const std::wstring &theObjectName,
const std::map<std::string, double> theFeatureDim)
{
- // TGeoTube * fuelShape = new TGeoTube("fuelShape",0.,fuelRadius,halfdz);
std::string anObjectName(theObjectName.begin(), theObjectName.end());
myContent << "\t"
myContent << "\t"
<< "TGeoTube *" << anObjectName << " = new TGeoTube(\""
- << anObjectName << "\","
+ << anObjectName << "\", "
<< "0."
- << ","
- << doubleToString(theFeatureDim["radius"]) << ","
+ << ", "
+ << doubleToString(theFeatureDim["radius"]) << ", "
<< doubleToString(theFeatureDim["halfdz"]) << ");"
<< std::endl
<< std::endl;
}
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::buildVolume(const std::wstring &theObjectName,
+ const std::map<std::string, std::string> theFeatureDim,
+ const int theMediumIndex)
+{
+ std::string anObjectName(theObjectName.begin(), theObjectName.end());
+
+ myContent << "\t"
+ << "//Exporting " << anObjectName << std::endl;
+
+ myContent << "\t"
+ << "TGeoMedium *" << theFeatureDim["medium"] << " = new TGeoMedium(\""
+ << theFeatureDim["medium"] << "\", "
+ << theMediumIndex << ", "
+ << "matDummy);"
+ << std::endl;
+
+ myContent << "\t"
+ << "TGeoVolume *" << anObjectName << " = new TGeoVolume(\""
+ << anObjectName << "\", "
+ << theFeatureDim["shape"] << ", "
+ << theFeatureDim["medium"] << ");"
+ << std::endl
+ << std::endl;
+}
+
//=================================================================================================
void GeomAlgoAPI_ROOTExport::buildEnd(const std::string theSolidName,
const std::string theExportName)
{
myContent << "\t"
- << "// ####################################" << std::endl;
+ << "// ####################################" << std::endl
+ << "\t// ############## FOOTER ##############" << std::endl;
+
myContent << "\t"
<< "geom->SetTopVolume(" << theSolidName << ");" << std::endl;
myContent << "\t"