]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add the box by two points in root export
authorClarisse Genrault <cgenrault@is231796.intra.cea.fr>
Mon, 7 Sep 2020 14:44:13 +0000 (16:44 +0200)
committerClarisse Genrault <cgenrault@is231796.intra.cea.fr>
Mon, 7 Sep 2020 14:44:13 +0000 (16:44 +0200)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp

index c876948701a00974f11318ad53bb5641090c539c..0d2752db7737e2100e212fada5360316a42afdf1 100644 (file)
@@ -142,14 +142,10 @@ void ExchangePlugin_ExportFeature::execute()
   AttributeStringPtr aFormatAttr =
       this->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID());
   std::string aFormat = aFormatAttr->value();
-  std::cout<<"FORMAT"<<std::endl;
-  std::cout<<aFormat<<std::endl;
 
   AttributeStringPtr aFilePathAttr =
       this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID());
   std::string aFilePath = aFilePathAttr->value();
-  std::cout<<"FILE"<<std::endl;
-  std::cout<<aFilePath<<std::endl;
   if (aFilePath.empty())
     return;
 
@@ -177,15 +173,11 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
     }
   }
 
-  std::cout<<"PASSAGE1"<<std::endl;
-  std::cout<<aFormatName<<std::endl;
-
   if (aFormatName == "XAO") {
     exportXAO(theFileName);
     return;
   }
 
-  
   if (aFormatName == "ROOT") {
     exportROOT(theFileName);
     return;
@@ -599,7 +591,6 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
 
 void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName)
 {
-  std::cout<<"EXPORT ROOT ==> debut"<<std::endl;
   std::string aName = string(ExchangePlugin_ExportFeature::ROOT_MANAGER_NAME_ID())->value();
   std::string aTitle = string(ExchangePlugin_ExportFeature::ROOT_MANAGER_TITLE_ID())->value();
   std::string aFileMat = string(ExchangePlugin_ExportFeature::MAT_FILE_ID())->value();
@@ -616,8 +607,6 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName)
   std::map<std::string, std::vector<std::string> > aMat;
   std::map<std::string, std::vector<std::string> > aMedium;
   ExchangePlugin_ExportRoot::readFileMat(aFileMat, aMat, aMedium);
-  std::cout<<"Size  "<<aMat.size()<<std::endl;
-  std::cout<<"Size  "<<aMedium.size()<<std::endl;
   
   anAlgo->buildMatAndMedium(aMat, aMedium);
 
@@ -640,8 +629,6 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string& theFileName)
       }
   }
   
-  std::cout<<"Nb of elements :: " << aListNamesOfFeatures.size() << std::endl;
-  
   // Add all groups in the file
   itExport = theExport.begin();
   for (; itExport != theExport.end(); ++itExport)
index 61aabc2a6713c7d596744ecdd3d31ea34bf30aae..a4244a2dbd4de9c6ab541405a6e000428f27b684 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <ExchangePlugin_ExportRoot.h>
 
+#include <GeomAlgoAPI_PointBuilder.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -30,6 +32,8 @@
 #include <fstream>
 #include <iostream>
 
+#include "math.h"
+
 void ExchangePlugin_ExportRoot::readFileMat(const std::string theFileMat,
                                 std::map<std::string, std::vector<std::string> >& aMat,
                                 std::map<std::string, std::vector<std::string> >& aMedias)
@@ -56,8 +60,8 @@ void ExchangePlugin_ExportRoot::readFileMat(const std::string theFileMat,
           aData.push_back(anElem);
         }
       }
-      std::cout<<"aType :: "<<aName<<std::endl;
-      std::cout<<"aName :: "<<aData[0]<<std::endl;
+      //std::cout<<"aType :: "<<aName<<std::endl;
+      //std::cout<<"aName :: "<<aData[0]<<std::endl;
       if (aName == "mat") {
         aMat[aData[0]] = aData;
       } else if (aName == "medium") {
@@ -69,8 +73,8 @@ void ExchangePlugin_ExportRoot::readFileMat(const std::string theFileMat,
     
     aFile.close();
   }
-  std::cout<<"Size of aMat :: "<<aMat.size()<<std::endl;
-  std::cout<<"Size of aMedias :: "<<aMedias.size()<<std::endl;
+  //std::cout<<"Size of aMat :: "<<aMat.size()<<std::endl;
+  //std::cout<<"Size of aMedias :: "<<aMedias.size()<<std::endl;
 }
 
 void ExchangePlugin_ExportRoot::computeBox(FeaturePtr theCurFeature,
@@ -86,7 +90,28 @@ void ExchangePlugin_ExportRoot::computeBox(FeaturePtr theCurFeature,
     OY = DY;
     OZ = DZ;
   } else if (aMethodName == "BoxByTwoPoints") {
-    // A completer
+    AttributeSelectionPtr aRef1 = theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_FIRST_ID());
+    AttributeSelectionPtr aRef2 = theCurFeature->data()->selection(PrimitivesPlugin_Box::POINT_SECOND_ID());
+    GeomShapePtr aShape1 = aRef1->value();
+    if (!aShape1.get())
+      aShape1 = aRef1->context()->shape();
+    GeomShapePtr aShape2 = aRef2->value();
+    if (!aShape2.get())
+      aShape2 = aRef2->context()->shape();
+    std::shared_ptr<GeomAPI_Pnt> aFirstPoint = GeomAlgoAPI_PointBuilder::point(aShape1);
+    std::shared_ptr<GeomAPI_Pnt> aSecondPoint = GeomAlgoAPI_PointBuilder::point(aShape2);
+    double x1 = aFirstPoint->x();
+    double y1 = aFirstPoint->y();
+    double z1 = aFirstPoint->z();
+    double x2 = aSecondPoint->x();
+    double y2 = aSecondPoint->y();
+    double z2 = aSecondPoint->z();
+    DX = fabs(x2 -x1)/2;
+    DY = fabs(y2 -y1)/2;
+    DZ = fabs(z2 -z1)/2;
+    OX = fmin(x1,x2)+DX;
+    OY = fmin(y1,y2)+DY;
+    OZ = fmin(z1,z2)+DZ;
   } else if (aMethodName == "BoxByOnePointAndDims") {
     DX = theCurFeature->data()->real(PrimitivesPlugin_Box::HALF_DX_ID())->value();
     DY = theCurFeature->data()->real(PrimitivesPlugin_Box::HALF_DY_ID())->value();
@@ -100,7 +125,7 @@ void ExchangePlugin_ExportRoot::computeBox(FeaturePtr theCurFeature,
 void ExchangePlugin_ExportRoot::computeGroup(FeaturePtr theCurFeature,
                                              std::vector<std::string>& theListNames)
 {
-  std::cout<<"COMPUTE GROUP"<<std::endl;
+  //std::cout<<"COMPUTE GROUP"<<std::endl;
   AttributeSelectionListPtr anObjectsSelList =
       theCurFeature->data()->selectionList(CollectionPlugin_Group::LIST_ID());
       
@@ -109,7 +134,7 @@ void ExchangePlugin_ExportRoot::computeGroup(FeaturePtr theCurFeature,
       anObjectsSelList->value(anObjectsIndex);
     ObjectPtr anObject = anObjectAttr->contextObject();
     std::string aName = anObject->data()->name();
-    std::cout<<"NAME :: "<<aName<<std::endl;
+    //std::cout<<"NAME :: "<<aName<<std::endl;
     theListNames.push_back(aName);
   }
 }