// LCOV_EXCL_STOP
}
-#include <iostream>
-
void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
{
// Get data from feature
// Create the head of file
anAlgo->buildHead(listNames.front(), aName, aTitle);
- // // Materials and mediums
+ // TODO : Use material files for media list
// std::map<std::string, std::vector<std::string> > aMaterials;
// std::map<std::string, std::vector<std::string> > aMedias;
// readFileMat(aFileMat, aMaterials, aMedias);
// anAlgo->buildMaterialsMedias(aMaterials, aMedias);
// Handling data
+ std::list<std::string> aListOfMedias;
std::list<std::wstring> aListOfVolumes;
std::map<std::string, std::vector <std::array<std::string, 2>>> aCopyData;
// Add feature in the file
std::list<FeaturePtr> aFeatures = document()->allFeatures();
std::list<FeaturePtr>::iterator itFeature = aFeatures.begin();
- std::map<std::wstring, std::string> aMapFeauturesObject;
int aMediumIndex = 0;
for (; itFeature != aFeatures.end(); ++itFeature)
{
std::map<std::string, std::string> aFeatureDimensions;
aFeatureDimensions = ExchangePlugin_ExportRoot::computeVolume(aFeature);
std::wstring anObjectName = aFeature->firstResult()->data()->name();
- anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
+
+ //Filter on already created medias
+ std::list<std::string>::iterator anIter = std::find(aListOfMedias.begin(), aListOfMedias.end(), aFeatureDimensions["medium"]);
+ if (anIter != aListOfMedias.end())
+ anAlgo->buildVolume(anObjectName, aFeatureDimensions, -1);
+ else
+ {
+ aListOfMedias.push_back(aFeatureDimensions["medium"]);
+ anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
+ }
// Add volume to known ones
aListOfVolumes.push_back(anObjectName);
for (int k = 0; k < jt->second.size(); k++ )
if (jt->second[k][0] == it->first)
jt->second[k][1] = it->second;
- // TODO : Add TR TO ACopyData the AddNode get the TR value
- } else {std::cout << "Ignoring translation" << std::endl;}
+ } else {std::cout << "Ignoring translation" << std::endl;} //Filter translation not on volume or addNode
}
}
aFeature = anObjectAttr->contextFeature();
std::string aNameShape = "";
if (aFeature.get())
- {
aNameShape = Locale::Convert::toString(aFeature->firstResult()->data()->name());
- }
else
{
ObjectPtr anObject = anObjectAttr->contextObject();
#include <ModelAPI_AttributeSelectionList.h>
#include <string>
-#include <iostream>
#include <iomanip>
#include <sstream>
-
#include "math.h"
namespace ExchangePlugin_ExportRoot
AttributeSelectionPtr aSelection = aBaseObjectList->value(anIndex);
ResultPtr aMainResult = aSelection->context();
FeaturePtr aSelectionFeature = aMainResult->document()->feature(aMainResult);
-
- std::cout << "Copy feature kind is : " << aSelectionFeature->getKind() << std::endl;
-
std::wstring aWSelName = aMainResult ? aMainResult->data()->name() : aSelectionFeature->firstResult()->data()->name();
std::string aSelName(aWSelName.begin(), aWSelName.end());
std::vector<std::array<std::string, 2>> aNewBaseCopies;
AttributeSelectionPtr aSelection = aBaseObjectList->value(anIndex);
ResultPtr aMainResult = aSelection->context();
FeaturePtr aSelectionFeature = aMainResult->document()->feature(aMainResult);
-
- std::cout << "Translation feature kind is : " << aSelectionFeature->getKind() << std::endl;
-
std::wstring aWSelName = aMainResult ? aMainResult->data()->name() : aSelectionFeature->firstResult()->data()->name();
std::string aSelName(aWSelName.begin(), aWSelName.end());
//Add it to translated objects
std::map<std::string, std::string> aFeatureDim;
return aFeatureDim;
}
- // else if (aMethodType == FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE())
- // {
- // double anAxisOffset;
- // AttributeSelectionPtr anAxis;
-
- // anAxis = theFeature->data()->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
- // anAxisOffset = (theFeature->data()->real(FeaturesPlugin_Translation::DISTANCE_ID())->value());
-
- // // Get feature
- // ResultPtr aResult = anAxis->context();
- // FeaturePtr anAxisFeature = aResult->document()->feature(aResult);
- // std::wstring anAxisName = aResult ? aResult->data()->name() : anAxisFeature->firstResult()->data()->name();
-
- // std::map<std::string, std::string> aFeatureDim;
- // return aFeatureDim;
- // }
- // else if (aMethodType == FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS())
- // {
- // std::map<std::string, std::string> aFeatureDim;
- // return aFeatureDim;
- // }
}
} // namespace ExchangePlugin_ExportRoot
-
-// std::map<std::string, std::vector<std::array<std : string, 2>>> aCopyData;
myContent << "\t"
<< "//Exporting " << anObjectName << std::endl;
- myContent << "\t"
- << "TGeoMedium *" << theFeatureDim["medium"] << " = new TGeoMedium(\""
- << theFeatureDim["medium"] << "\", "
- << theMediumIndex << ", "
- << "matDummy);"
- << std::endl;
+ if (theMediumIndex != -1)
+ {
+ myContent << "\t"
+ << "TGeoMedium *" << theFeatureDim["medium"] << " = new TGeoMedium(\""
+ << theFeatureDim["medium"] << "\", "
+ << theMediumIndex << ", "
+ << "matDummy);"
+ << std::endl;
+ }
myContent << "\t"
<< "TGeoVolume *" << anObjectName << " = new TGeoVolume(\""
myContent << "\t"
<< aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ");"
- << std::endl
<< std::endl;
for (auto const &[key, val] : theCopyData){
myContent << "\t"
<< aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ", "
<< "new TGeoTranslation(" << el[1] <<"));"
- << std::endl
<< std::endl;
}
}
}
+ myContent << std::endl;
}
//=================================================================================================