#include <ExchangePlugin_Tools.h>
#include <PrimitivesPlugin_Box.h>
+// ToDo : a supprimer
+#include <FeaturesPlugin_Partition.h>
+#include <FeaturesPlugin_Translation.h>
#ifdef WIN32
# define _separator_ '\\'
std::list<FeaturePtr> theExport = document()->allFeatures();
std::list<FeaturePtr>::iterator itExport = theExport.begin();
std::vector<std::string> aListNamesOfFeatures;
+ std::map<std::string,std::string> aMapFeatureObject;
for (; itExport != theExport.end(); ++itExport)
{
FeaturePtr aCurFeature = *itExport;
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());
- } else if (aCurFeature->getKind() == "Partition") {
- //std::cout<<"ToDo PARTITION"<<std::endl;
- std::string anObjectName = aCurFeature->firstResult()->data()->name();
- aListNamesOfFeatures.push_back(anObjectName);
- aListNamesOfFeatures.push_back(aCurFeature->data()->name());
}
}
aListMedium.push_back(anIt->first);
}
+ std::cout<<"ETRANGE"<<std::endl;
itExport = theExport.begin();
for (; itExport != theExport.end(); ++itExport)
{
+ std::cout<<"ETRANGE une fois"<<std::endl;
FeaturePtr aCurFeature = *itExport;
if (aCurFeature->getKind() == "Group") {
+ std::cout<<"ETRANGE deux fois"<<std::endl;
std::vector<std::string> aListNames;
std::string anObjectName = aCurFeature->firstResult()->data()->name();
ExchangePlugin_ExportRoot::computeGroup(aCurFeature, aListNames);
//for (std::vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it)
for (std::vector<std::string>::iterator it = aListNames.begin(); it != aListNames.end(); it++) {
std::string aName = anObjectName + "_" + *it;
- anAlgo->BuildVolume(aName, *it, anObjectName, aListMedium);
+ anAlgo->buildVolume(aName, *it, anObjectName, aListMedium);
}
}
}
+
+ itExport = theExport.begin();
+ for (; itExport != theExport.end(); ++itExport)
+ {
+ FeaturePtr aCurFeature = *itExport;
+ 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());
+ // ToDo dans computeTranslation
+ AttributeSelectionListPtr anObjectsSelList = aCurFeature->data()->
+ selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
+ for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
+ anObjectsSelList->value(anObjectsIndex);
+ ObjectPtr anObject = anObjectAttr->contextObject();
+ std::string aName = anObject->data()->name();
+ std::cout<<anObjectName<<" et "<<aName<<std::endl;
+ aMapFeatureObject[anObjectName]=aName;
+ }
+ } else if (aCurFeature->getKind() == "Partition") {
+ std::string anObjectName = aCurFeature->firstResult()->data()->name();
+ // ToDo dans computePartition
+ int index = 0;
+ std::string aMainName = "";
+ AttributeSelectionListPtr anObjectsSelList = aCurFeature->data()->
+ selectionList(FeaturesPlugin_Partition::BASE_OBJECTS_ID());
+ for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
+ anObjectsSelList->value(anObjectsIndex);
+ ObjectPtr anObject = anObjectAttr->contextObject();
+ std::string aName = anObject->data()->name();
+ if (index == 0) {
+ aMainName = aName;
+ } else {
+ std::cout<<aMainName<<"AA AA "<<aMapFeatureObject[aName]<<" BB BB "<<aName<<std::endl;
+ anAlgo->buildPartition(aMainName, aMapFeatureObject[aName], aName, index);
+ }
+ index++;
+ }
+ aListNamesOfFeatures.push_back(anObjectName);
+ aListNamesOfFeatures.push_back(aCurFeature->data()->name());
+ }
+ }
std::string aExportFileName = string(ExchangePlugin_ExportFeature::EXP_NAME_FILE_ID())->value();
AttributeSelectionPtr anObjectAttr = selection(MAIN_OBJECT_ID());
myContent += tmp;
tmp = "TGeoManager *geom = new TGeoManager(\"" + theName + "\",\"" + theTitle +"\");\n";
myContent += tmp;
+ myContent += "\n";
}
//=================================================================================================
myContent += "TGeoBBox *" + theObjectName + "_tmp = new TGeoBBox(\"" +theObjectName + "_tmp\",";
myContent += doubleToString(theDX)+","+doubleToString(theDY)+","+doubleToString(theDZ)+",point_";
myContent += theObjectName + ");\n";
+ myContent += "\n";
}
//=================================================================================================
const double theDZ)
{
myContent += "TGeoTranslation *" + theObjectName;
- myContent += "_tmp = new TGeoTranslation(\"" + theObjectName + "_tmp\",";
+ myContent += " = new TGeoTranslation(\"" + theObjectName + "\",";
myContent += doubleToString(theDX) + "," + doubleToString(theDY) + ",";
myContent += doubleToString(theDZ) + ");\n";
+ myContent += "\n";
+}
+
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::buildPartition(const std::string& theMainName,
+ const std::string theObjectName,
+ const std::string theOperationName,
+ const int theIndex)
+{
+ myContent += theMainName + "->AddNode(";
+ myContent += theObjectName + ", " + intToString(theIndex) + ", ";
+ myContent += theOperationName + ");\n";
+ myContent += "\n";
}
//=================================================================================================
myContent += "TGeoMedium *" + anIt2->first + " = new TGeoMedium(\"";
myContent += aValues[1] + "\"," + aValues[2] + "," + aValues[3] + ") ;\n";
}
+ myContent += "\n";
}
//=================================================================================================
-void GeomAlgoAPI_ROOTExport::BuildVolume(const std::string theName,
+void GeomAlgoAPI_ROOTExport::buildVolume(const std::string theName,
const std::string theGeometryName,
const std::string theMediumName,
std::vector<std::string> theListMedium)
if (aFound) {
myContent += "TGeoVolume *" + theGeometryName + " = new TGeoVolume(\"" + theName;
myContent += "\"," + theGeometryName + "_tmp," + theMediumName + ");\n";
+ myContent += "\n";
}
}
return true;
}
+//=================================================================================================
+const std::string GeomAlgoAPI_ROOTExport::intToString(const int& value)
+{
+ std::ostringstream str;
+ str << value;
+ return str.str();
+}
+
//=================================================================================================
const std::string GeomAlgoAPI_ROOTExport::doubleToString(const double& value)
{
GEOMALGOAPI_EXPORT void buildTranslation(const std::string& theObjectName,
const double theDX, const double theDY,
const double theDZ);
+
+ /// Build partition
+ GEOMALGOAPI_EXPORT void buildPartition(const std::string& theMainName,
+ const std::string theObjectName,
+ const std::string theOperationName,
+ const int theIndex);
/// Build mat and medium
GEOMALGOAPI_EXPORT void buildMatAndMedium(
const std::map<std::string, std::vector<std::string> > theMedium);
///
- GEOMALGOAPI_EXPORT void BuildVolume(const std::string theName,
+ GEOMALGOAPI_EXPORT void buildVolume(const std::string theName,
const std::string theGeometryName,
const std::string theMediumName,
std::vector<std::string> theListMedium);
/// Write the file
GEOMALGOAPI_EXPORT bool write();
+ ///
+ GEOMALGOAPI_EXPORT const std::string intToString(const int& value);
+
+ ///
GEOMALGOAPI_EXPORT const std::string doubleToString(const double& value);
private: