From: cg246364 Date: Mon, 23 Nov 2020 14:20:23 +0000 (+0100) Subject: Adding export ROOT for partition and mult-translation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcgt%2Fopera;p=modules%2Fshaper.git Adding export ROOT for partition and mult-translation --- diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index ea7f8863d..a1c395d05 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -39,6 +39,7 @@ #include #include +//#include #include #include #include @@ -646,19 +647,15 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName) aListMedium.push_back(anIt->first); } - std::cout<<"ETRANGE"<getKind() == "Group") { - std::cout<<"ETRANGE deux fois"< aListNames; std::string anObjectName = aCurFeature->firstResult()->data()->name(); ExchangePlugin_ExportRoot::computeGroup(aCurFeature, aListNames); - - //for (std::vector::iterator it = myvector.begin() ; it != myvector.end(); ++it) + for (std::vector::iterator it = aListNames.begin(); it != aListNames.end(); it++) { std::string aName = anObjectName + "_" + *it; anAlgo->buildVolume(aName, *it, anObjectName, aListMedium); @@ -688,6 +685,19 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName) std::cout<getKind() == "LinearCopy") { + std::vector aObjNames; + double aStep; + int aNb; + std::string anObjectName = aCurFeature->firstResult()->data()->name(); + std::vector> aResulNames; + std::shared_ptr anAxis = ExchangePlugin_ExportRoot::computeMultiTranslation(aCurFeature, aObjNames, aResulNames, aStep, aNb); + anAlgo->buildMultiTranslation(aObjNames, aResulNames, aStep, aNb, anAxis); + for (int i=0; igetKind() == "Partition") { std::string anObjectName = aCurFeature->firstResult()->data()->name(); // ToDo dans computePartition @@ -703,7 +713,6 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName) if (index == 0) { aMainName = aName; } else { - std::cout<buildPartition(aMainName, aMapFeatureObject[aName], aName, index); } index++; diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp index 4e8c52029..aeac567a2 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp @@ -21,13 +21,21 @@ #include +#include +#include +#include + #include +#include #include #include #include #include + +#include #include + #include #include @@ -61,8 +69,6 @@ void ExchangePlugin_ExportRoot::readFileMat(const std::string theFileMat, aData.push_back(anElem); } } - //std::cout<<"aType :: "< +ExchangePlugin_ExportRoot::computeMultiTranslation(FeaturePtr theCurFeature, + std::vector& theObjNames, + std::vector>& theResulNames, + double& theStep, int& theNb) +{ + std::list aResList = theCurFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResList.cbegin(); aIt != aResList.cend(); aIt++) { + std::cout<<(*aIt)->data()->name()<((*aIt)); + std::cout<numberOfSubs()< aVector; + for (int i=0; i< aCompSolid->numberOfSubs();i++) { + std::cout<subResult(i)->data()->name()<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 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 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& theListNames) { - //std::cout<<"COMPUTE GROUP"<data()->selectionList(CollectionPlugin_Group::LIST_ID()); diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.h b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h index 66c3a76a9..b15905f15 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportRoot.h +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h @@ -21,9 +21,11 @@ #define EXCHANGEPLUGIN_EXPORTROOT_H_ #include +#include #include #include +#include /** * \class ExchangePlugin_Tools @@ -43,6 +45,12 @@ public: /// Compute .... static void computeTranslation(FeaturePtr theCurFeature, double& DX, double& DY, double& DZ); + /// Compute .... + static std::shared_ptr computeMultiTranslation(FeaturePtr theCurFeature, + std::vector& theObjNames, + std::vector>& theResulNames, + double& theStep, int& theNb); + /// Compute .... static void computeGroup(FeaturePtr theCurFeature, std::vector& theListNames); }; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp index a7868bd0c..d86132000 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp @@ -19,6 +19,8 @@ #include +#include + #include #include @@ -72,6 +74,29 @@ void GeomAlgoAPI_ROOTExport::buildTranslation(const std::string& theObjectName, myContent += "\n"; } +//================================================================================================= +void GeomAlgoAPI_ROOTExport::buildMultiTranslation(const std::vector& theObjNames, + const std::vector>& theResulNames, + const double theStep, + const int theNb, + std::shared_ptr theAxis) +{ + const gp_Ax1& anAxis = theAxis->impl(); + + for (int i=0; i< theResulNames.size(); i++) { + std::vector aVector = theResulNames[i]; + for (int j=0; j +#include + #include #include #include @@ -49,6 +51,13 @@ public: const double theDX, const double theDY, const double theDZ); + /// Build translation + GEOMALGOAPI_EXPORT void buildMultiTranslation(const std::vector& theObjNames, + const std::vector>& theResulNames, + const double theStep, + const int theNb, + std::shared_ptr theAxis); + /// Build partition GEOMALGOAPI_EXPORT void buildPartition(const std::string& theMainName, const std::string theObjectName,