// Handling data
std::list<std::string> aListOfMedias;
- std::list<std::wstring> aListOfVolumes;
+ std::map<std::wstring, std::string> aListOfVolumes;
std::map<std::string, std::vector <std::array<std::string, 2>>> aCopyData;
// Add feature in the file
anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
}
- // Add volume to known ones
- aListOfVolumes.push_back(anObjectName);
+ // Add volume to known ones with no translation
+ aListOfVolumes[anObjectName] = "";
}
else if (aFeature->getKind() == "AddNode")
{
std::wstring anObjectName = aFeature->firstResult()->data()->name();
//Filter copied volumes
- std::list<std::wstring>::iterator anIter = std::find(aListOfVolumes.begin(), aListOfVolumes.end(), aFeatureDimensions["tool"]);
+ auto anIter = aListOfVolumes.find(aFeatureDimensions["tool"]);
if (anIter != aListOfVolumes.end())
- anAlgo->buildAddNode(aFeatureDimensions, aCopyData);
+ anAlgo->buildAddNode(aFeatureDimensions, anIter->second, aCopyData);
}
else if (aFeature->getKind() == "Copy")
{
if (aFeatureDimensions.size())
{
std::map<std::string, std::string>::iterator it;
-
for (std::map<std::string, std::string>::iterator it = aFeatureDimensions.begin(); it != aFeatureDimensions.end(); it++)
- for (auto jt = aCopyData.begin(); jt != aCopyData.end(); jt++)
- for (int k = 0; k < jt->second.size(); k++ )
- if (jt->second[k][0] == it->first)
- jt->second[k][1] = it->second;
+ {
+ std::wstring aWStr(it->first.begin(), it->first.end());
+ if (aListOfVolumes.find(aWStr) != aListOfVolumes.end())
+ aListOfVolumes[aWStr] = it->second;
+ else
+ {
+ for (auto jt = aCopyData.begin(); jt != aCopyData.end(); jt++)
+ for (int k = 0; k < jt->second.size(); k++ )
+ if (jt->second[k][0] == it->first)
+ jt->second[k][1] = it->second;
+ }
+ }
} else {std::cout << "Ignoring translation" << std::endl;} //Filter translation not on volume or addNode
}
}
//=================================================================================================
void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map<std::string, std::wstring> theFeatureDim,
+ const std::string theVolumeTranslation,
const std::map<std::string, std::vector<std::array<std::string, 2>>> theCopyData)
{
static int theAddNodeIndex = 0;
myContent << "\t"
<< "//Exporting AddNode " << theAddNodeIndex << std::endl;
- myContent << "\t"
- << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ");"
- << std::endl;
+ if (theVolumeTranslation.empty())
+ {
+ myContent << "\t"
+ << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ");"
+ << std::endl;
+ }
+ else
+ {
+ myContent << "\t"
+ << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ", "
+ << "new TGeoTranslation(" << theVolumeTranslation << "));"
+ << std::endl;
+ }
for (auto const &[key, val] : theCopyData){
if (key == aToolName){