#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_XAOExport.h>
+//#include <GeomAPI_Ax1.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Trsf.h>
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);
std::cout<<anObjectName<<" et "<<aName<<std::endl;
aMapFeatureObject[anObjectName]=aName;
}
+ } else if (aCurFeature->getKind() == "LinearCopy") {
+ std::vector<std::string> aObjNames;
+ double aStep;
+ int aNb;
+ std::string anObjectName = aCurFeature->firstResult()->data()->name();
+ std::vector<std::vector<std::string>> aResulNames;
+ std::shared_ptr<GeomAPI_Ax1> anAxis = ExchangePlugin_ExportRoot::computeMultiTranslation(aCurFeature, aObjNames, aResulNames, aStep, aNb);
+ anAlgo->buildMultiTranslation(aObjNames, aResulNames, aStep, aNb, anAxis);
+ for (int i=0; i<aObjNames.size(); i++) {
+ for (int j=0; j<aResulNames[i].size(); j++) {
+ aMapFeatureObject[aResulNames[i][j]]=aObjNames[i];
+ }
+ }
} else if (aCurFeature->getKind() == "Partition") {
std::string anObjectName = aCurFeature->firstResult()->data()->name();
// ToDo dans computePartition
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++;
#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
+
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <CollectionPlugin_Group.h>
#include <ExchangePlugin_Tools.h>
+
+#include <FeaturesPlugin_MultiTranslation.h>
#include <FeaturesPlugin_Translation.h>
+
#include <PrimitivesPlugin_Box.h>
#include <fstream>
aData.push_back(anElem);
}
}
- //std::cout<<"aType :: "<<aName<<std::endl;
- //std::cout<<"aName :: "<<aData[0]<<std::endl;
if (aName == "mat") {
aMat[aData[0]] = aData;
} else if (aName == "medium") {
aFile.close();
}
- //std::cout<<"Size of aMat :: "<<aMat.size()<<std::endl;
- //std::cout<<"Size of aMedias :: "<<aMedias.size()<<std::endl;
}
void ExchangePlugin_ExportRoot::computeBox(FeaturePtr theCurFeature,
}
}
+std::shared_ptr<GeomAPI_Ax1>
+ExchangePlugin_ExportRoot::computeMultiTranslation(FeaturePtr theCurFeature,
+ std::vector<std::string>& theObjNames,
+ std::vector<std::vector<std::string>>& theResulNames,
+ double& theStep, int& theNb)
+{
+ std::list<ResultPtr> aResList = theCurFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResList.cbegin(); aIt != aResList.cend(); aIt++) {
+ std::cout<<(*aIt)->data()->name()<<std::endl;
+ ResultBodyPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>((*aIt));
+ std::cout<<aCompSolid->numberOfSubs()<<std::endl;
+ std::vector<std::string> aVector;
+ for (int i=0; i< aCompSolid->numberOfSubs();i++) {
+ std::cout<<aCompSolid->subResult(i)->data()->name()<<std::endl;
+ aVector.push_back(aCompSolid->subResult(i)->data()->name());
+ }
+ theResulNames.push_back(aVector);
+ }
+
+ theStep = theCurFeature->data()->real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value();
+ theNb = theCurFeature->data()->integer(FeaturesPlugin_MultiTranslation::NB_COPIES_FIRST_DIR_ID())->value();
+
+ AttributeSelectionPtr anObjRef = theCurFeature->data()->
+ selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID());
+
+ GeomShapePtr aShape = anObjRef->value();
+ if (!aShape.get()) {
+ if (anObjRef->context().get()) {
+ aShape = anObjRef->context()->shape();
+ }
+ }
+ if (!aShape.get()) {
+ return;
+ }
+
+ GeomEdgePtr anEdge;
+ if (aShape->isEdge())
+ {
+ anEdge = aShape->edge();
+ }
+ else if (aShape->isCompound())
+ {
+ GeomAPI_ShapeIterator anIt(aShape);
+ anEdge = anIt.current()->edge();
+ }
+
+ if (!anEdge.get())
+ {
+ return;
+ }
+
+ std::shared_ptr<GeomAPI_Ax1> anAxis(new GeomAPI_Ax1(anEdge->line()->location(),
+ anEdge->line()->direction()));
+
+ AttributeSelectionListPtr anObjectsSelList = theCurFeature->data()->
+ selectionList(FeaturesPlugin_MultiTranslation::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();
+ theObjNames.push_back(aName);
+ }
+
+ return anAxis;
+}
+
void ExchangePlugin_ExportRoot::computeGroup(FeaturePtr theCurFeature,
std::vector<std::string>& theListNames)
{
- //std::cout<<"COMPUTE GROUP"<<std::endl;
AttributeSelectionListPtr anObjectsSelList =
theCurFeature->data()->selectionList(CollectionPlugin_Group::LIST_ID());
#define EXCHANGEPLUGIN_EXPORTROOT_H_
#include <ExchangePlugin.h>
+#include <GeomAPI_Ax1.h>
#include <ModelAPI_Feature.h>
#include <map>
+#include <vector>
/**
* \class ExchangePlugin_Tools
/// Compute ....
static void computeTranslation(FeaturePtr theCurFeature, double& DX, double& DY, double& DZ);
+ /// Compute ....
+ static std::shared_ptr<GeomAPI_Ax1> computeMultiTranslation(FeaturePtr theCurFeature,
+ std::vector<std::string>& theObjNames,
+ std::vector<std::vector<std::string>>& theResulNames,
+ double& theStep, int& theNb);
+
/// Compute ....
static void computeGroup(FeaturePtr theCurFeature, std::vector<std::string>& theListNames);
};
#include <GeomAlgoAPI_ROOTExport.h>
+#include <gp_Ax1.hxx>
+
#include <OSD_OpenFile.hxx>
#include <fstream>
myContent += "\n";
}
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::buildMultiTranslation(const std::vector<std::string>& theObjNames,
+ const std::vector<std::vector<std::string>>& theResulNames,
+ const double theStep,
+ const int theNb,
+ std::shared_ptr<GeomAPI_Ax1> theAxis)
+{
+ const gp_Ax1& anAxis = theAxis->impl<gp_Ax1>();
+
+ for (int i=0; i< theResulNames.size(); i++) {
+ std::vector<std::string> aVector = theResulNames[i];
+ for (int j=0; j<aVector.size();j++) {
+ double aDistance = j*theStep;
+ gp_Vec aVec = gp_Vec(anAxis.Direction()) * aDistance;
+ myContent += "TGeoTranslation *" + aVector[j];
+ myContent += " = new TGeoTranslation(\"" + aVector[j] + "\",";
+ myContent += doubleToString(aVec.X()) + "," + doubleToString(aVec.Y()) + ",";
+ myContent += doubleToString(aVec.Z()) + ");\n";
+ myContent += "\n";
+ }
+ }
+}
+
//=================================================================================================
void GeomAlgoAPI_ROOTExport::buildPartition(const std::string& theMainName,
const std::string theObjectName,
#include <GeomAlgoAPI.h>
+#include <GeomAPI_Ax1.h>
+
#include <map>
#include <string>
#include <vector>
const double theDX, const double theDY,
const double theDZ);
+ /// Build translation
+ GEOMALGOAPI_EXPORT void buildMultiTranslation(const std::vector<std::string>& theObjNames,
+ const std::vector<std::vector<std::string>>& theResulNames,
+ const double theStep,
+ const int theNb,
+ std::shared_ptr<GeomAPI_Ax1> theAxis);
+
/// Build partition
GEOMALGOAPI_EXPORT void buildPartition(const std::string& theMainName,
const std::string theObjectName,