]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix issues for first level and tests
authorJérôme <jerome.lucas@cesgenslab.fr>
Mon, 12 Oct 2020 09:32:20 +0000 (11:32 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Mon, 12 Oct 2020 09:32:20 +0000 (11:32 +0200)
14 files changed:
src/ExchangeAPI/ExchangeAPI_Import.cpp
src/ExchangeAPI/ExchangeAPI_Import.h
src/ExchangePlugin/ExchangePlugin_Import.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/CMakeLists.txt

index d5d7ea2a98206757dbdcfb2793f0e2ede05d1c05..059467a250f371e4d797123bdd60410523e1da38 100644 (file)
@@ -67,16 +67,19 @@ ExchangeAPI_Import::~ExchangeAPI_Import()
 }
 
 //--------------------------------------------------------------------------------------
-void ExchangeAPI_Import::setParameters(const std::string & theFilePath, 
+void ExchangeAPI_Import::setParameters(const std::string & theFilePath,
                                        const bool  anScalInterUnits,
                                        const bool  anMaterials,
                                        const bool  anColor)
 {
   fillAttribute(theFilePath, mystepfilePath);
   fillAttribute("STEP", feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()));
-  fillAttribute(anScalInterUnits, feature()->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()));
-  fillAttribute(anMaterials, feature()->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()));
-  fillAttribute(anColor, feature()->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()));
+  fillAttribute(anScalInterUnits,
+                feature()->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()));
+  fillAttribute(anMaterials,
+                feature()->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()));
+  fillAttribute(anColor,
+                feature()->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()));
   execute();
 }
 
@@ -84,7 +87,16 @@ void ExchangeAPI_Import::setParameters(const std::string & theFilePath,
 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
 {
   fillAttribute(theFilePath, myfilePath);
-  std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath);
+  std::string aFrom = "\\";
+  std::string aTo = "\\\\";
+  std::string aFilePath = theFilePath;
+  for(std::size_t aPos = aFilePath.find(aFrom);
+      aPos != std::string::npos;
+      aPos = aFilePath.find(aFrom, aPos)) {
+    aFilePath.replace(aPos, aFrom.size(), aTo);
+    aPos += aTo.size();
+  }
+  std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
   fillAttribute(anExtension, feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()));
   execute();
 }
@@ -95,7 +107,8 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
   FeaturePtr aBase = feature();
   std::string aPartName = theDumper.name(aBase->document());
 
-  AttributeStringPtr aImportTypeAttr = aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+  AttributeStringPtr aImportTypeAttr =
+                    aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
   std::string aFormat = aImportTypeAttr->value();
   std::string aFilePath;
   if (aFormat == "STEP" || aFormat == "STP")
@@ -118,7 +131,7 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
       theDumper << aBase << " = model.addImportStep(" << aPartName << ", \""
                 << aFilePath << "\"" ;
 
-      theDumper << ", " << scalinterunits()->value() 
+      theDumper << ", " << scalinterunits()->value()
                 << ", " << materials()->value()
                 << ", " << colors()->value() << ")"<< std::endl;
   }else{
index d95a453895a69fab6d627c18f79e17493085cbc6..90562443a35f4251ebb25fdf680182ff1b712aef 100644 (file)
@@ -51,10 +51,10 @@ public:
   EXCHANGEAPI_EXPORT
   ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
                      const std::string & theFilePath,
-                     const bool  anScalInterUnits,
-                     const bool  anMaterials,
-                     const bool  anColor);
-                     
+                     const bool  theScalInterUnits,
+                     const bool  theMaterials,
+                     const bool  theColor);
+
   /// Destructor
   EXCHANGEAPI_EXPORT
   virtual ~ExchangeAPI_Import();
@@ -77,9 +77,9 @@ public:
   /// Set point values
   EXCHANGEAPI_EXPORT
   void setFilePath(const std::string & theFilePath);
-  
+
   EXCHANGEAPI_EXPORT
-  void setParameters(const std::string & theFilePath, 
+  void setParameters(const std::string & theFilePath,
                      const bool  anScalInterUnits,
                      const bool  anMaterials,
                      const bool  anColor);
@@ -108,7 +108,7 @@ ImportPtr addImportStep(const std::shared_ptr<ModelAPI_Document> & thePart,
                         const bool  anScalInterUnits,
                         const bool  anMaterials,
                         const bool  anColor);
-                    
+
 /** \ingroup CPPHighAPI
  *  \brief Import features from the file to the document after the current feature (or to the end).
  */
index 304d456d56f2e717157ad259f4e10e4c3b9e214a..22cbb89f879e93be3e1923757887786820c0ed12 100644 (file)
@@ -109,7 +109,7 @@ void ExchangePlugin_Import::execute()
   if (aFormat == "STEP" || aFormat == "STP")
   {
     aFilePathAttr = string(ExchangePlugin_Import::STEP_FILE_PATH_ID());
-    aFilePath = aFilePathAttr->value();    
+    aFilePath = aFilePathAttr->value();
     // get the document where to import
     aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
     aTargetAttr = integer(STEP_TARGET_PART_ID());
@@ -140,8 +140,9 @@ void ExchangePlugin_Import::execute()
     {
       aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
     }
-    
-    AttributeStringPtr aImportTypeAttr = aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+
+    AttributeStringPtr aImportTypeAttr =
+                        aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
 
     aData->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())
          ->setValue(boolean(ExchangePlugin_Import::STEP_MATERIALS_ID())->value());
@@ -180,10 +181,11 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID)
     aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
     aTargetAttr = integer(STEP_TARGET_PART_ID());
     updatePart(aPartsAttr, aTargetAttr);
-   } 
+   }
 }
 
-void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr)
+void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr,
+                                       AttributeIntegerPtr &aTargetAttr)
 {
     // update the list of target parts
     SessionPtr aSession = ModelAPI_Session::get();
index 402b660e9721b7aa56b5d7e36938a24b0b4b7805..2049662d1356638df169d9b991c643d331ef31f4 100644 (file)
@@ -93,9 +93,20 @@ void ExchangePlugin_ImportFeature::initAttributes()
   data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId());
 
   aFeaturesAttribute->setIsArgument(false);
-  
+
   ModelAPI_Session::get()->validators()->registerNotObligatory(
       getKind(), ExchangePlugin_ImportFeature::FEATURES_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+      getKind(), ExchangePlugin_ImportFeature::STEP_COLORS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+      getKind(), ExchangePlugin_ImportFeature::STEP_MATERIALS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+      getKind(), ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+      getKind(), ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+      getKind(), ExchangePlugin_ImportFeature::FILE_PATH_ID());
+      
 }
 
 /*
@@ -152,13 +163,14 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   ResultBodyPtr result = document()->createBody(data());
 
   bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())->value();
-  bool anMaterialsGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value();
+  bool anMaterialsGroupSelected =
+                        boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value();
 
   if (anExtension == "BREP" || anExtension == "BRP") {
     aGeomShape = BREPImport(theFileName, anExtension, anError);
   } else if (anExtension == "STEP" || anExtension == "STP") {
-    bool anScalInterUnits = boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
-    
+    bool anScalInterUnits =
+            boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
 
     try{
 
@@ -175,10 +187,11 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
         if (aFeature)
         document()->removeFeature(aFeature);
       }
-      
+
       aGeomShape = STEPImportAttributs(theFileName, result, anScalInterUnits,
-                                       anMaterialsGroupSelected, anColorGroupSelected,theMaterialShape,anError);
-      
+                                       anMaterialsGroupSelected, anColorGroupSelected,
+                                       theMaterialShape,anError);
+
     }
     catch (OSD_Exception& e) {
         //Try to load STEP file without colors...
@@ -201,7 +214,7 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   loadNamingDS(aGeomShape, result);
 
   // create color group
-  if (anColorGroupSelected) 
+  if (anColorGroupSelected)
   {
     setColorGroups(result);
   }
@@ -211,15 +224,16 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
     setMaterielGroup(result,theMaterialShape);
   }
 
-  setResult(result); 
+  setResult(result);
 
 }
 
-void ExchangePlugin_ImportFeature::setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody)
+void ExchangePlugin_ImportFeature::setColorGroups(
+                                    std::shared_ptr<ModelAPI_ResultBody> theResultBody)
 {
   std::vector<int> aColor;
-  int indice = 1; 
-  std::list< std::vector<int> > aColorsRead; 
+  int indice = 1;
+  std::list< std::vector<int> > aColorsRead;
 
 
   ModelAPI_Tools::getColor(theResultBody, aColor);
@@ -240,7 +254,7 @@ void ExchangePlugin_ImportFeature::setColorGroups(std::shared_ptr<ModelAPI_Resul
         if ( it == aColorsRead.end() ){
              std::wstringstream colorName;
             colorName<<L"Color_"<<indice;
-            setColorGroup( theResultBody, aColor, colorName.str() ); 
+            setColorGroup(theResultBody, aColor, colorName.str());
             indice++;
             aColorsRead.push_back(aColor);
         }
@@ -267,12 +281,12 @@ void ExchangePlugin_ImportFeature::setColorGroup(std::shared_ptr<ModelAPI_Result
       GeomShapePtr aShape = theResultBody->shape();
       aSelectionList->setSelectionType(aShape->shapeTypeStr() );
       aSelectionList->append(theResultBody,aShape);
-    }  
+    }
   }
-  // add element with the same color 
+  // add element with the same color
   std::list<ResultPtr> allRes;
   ModelAPI_Tools::allSubs(theResultBody, allRes);
-  for(std::list<ResultPtr>::iterator aRes = allRes.begin(); 
+  for(std::list<ResultPtr>::iterator aRes = allRes.begin();
       aRes != allRes.end(); ++aRes) {
     ModelAPI_Tools::getColor(*aRes, aColor);
     GeomShapePtr aShape = (*aRes)->shape();
@@ -285,38 +299,41 @@ void ExchangePlugin_ImportFeature::setColorGroup(std::shared_ptr<ModelAPI_Result
     }
   }
 
+  ModelAPI_Tools::setColor(aGroupFeature->lastResult(),theColor);
+
   if (aSelectionList->size() == 0 ){
     document()->removeFeature(aGroupFeature);
   }
 }
 
-void ExchangePlugin_ImportFeature::setMaterielGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                    std::map< std::wstring, std::list<std::wstring>> &theMaterialShape)
+void ExchangePlugin_ImportFeature::setMaterielGroup(
+                                      std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                      std::map< std::wstring,
+                                      std::list<std::wstring>> &theMaterialShape)
 {
-  int indice = 1; 
-  std::map< std::wstring, std::list<std::wstring>>::iterator it; 
+  int indice = 1;
+  std::map< std::wstring, std::list<std::wstring>>::iterator it;
   for( it = theMaterialShape.begin(); it != theMaterialShape.end(); ++it) {
-      
+
     std::shared_ptr<ModelAPI_Feature> aGroupFeature = addFeature("Group");
     // group name
     aGroupFeature->data()->setName((*it).first);
 
     // fill selection
     AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
-    std::string aSelectionType =  "solid" ;
-    aSelectionList->setSelectionType(aSelectionType);
     GeomShapePtr aShape = theResultBody->shape();
-    
+
     std::list<ResultPtr> allRes;
     ModelAPI_Tools::allSubs(theResultBody, allRes);
     for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) {
-      
+
       GeomShapePtr aShape = (*aRes)->shape();
       for(std::list<std::wstring>::iterator aResMat = it->second.begin();
                                  aResMat != it->second.end(); ++aResMat) {
         if( aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
-        {  
+        {
           aSelectionList->append(theResultBody,aShape);
+          aSelectionList->setSelectionType(aShape->shapeTypeStr() );
           break;
         }
       }
@@ -325,9 +342,7 @@ void ExchangePlugin_ImportFeature::setMaterielGroup(std::shared_ptr<ModelAPI_Res
       document()->removeFeature(aGroupFeature);
     }
   }
-} 
-
-
+}
 
 void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
 {
index 2875d83abf4cc007cc4c9da019320e378682699c..e37ef83ec74b5e47cd0da0ad03b285fb52b6492f 100644 (file)
@@ -139,8 +139,7 @@ private:
   /// Loads Naming data structure to the document
   void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody);
-  // Set groups of color 
+  // Set groups of color
   void setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody);
 
   // set a group of color
index 281f689e3dd54702d85614f6d88d0c6b4e63cbbc..38a1929a5d8503242a525fabe1e8a6a31977bd96 100644 (file)
@@ -55,7 +55,7 @@
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
 
-
+//JL_CGLB
 #include <XCAFApp_Application.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
 #include <OSD_Exception.hxx>
@@ -84,7 +84,7 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
 
   // Set "C" numeric locale to save numbers correctly
   // Kernel_Utils::Localizer loc;
+
   STEPControl_Reader aReader;
 
   //VSR: 16/09/09: Convert to METERS
@@ -212,14 +212,15 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
 
 
 std::shared_ptr<GeomAPI_Shape>  STEPImportAttributs(const std::string& theFileName,
-                                                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                                    const bool  anScalInterUnits,
-                                                    const bool  anMaterials,
-                                                    const bool  anColor,
-                                                    std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
-                                                    std::string& theError)
+                                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                              const bool  anScalInterUnits,
+                                              const bool  anMaterials,
+                                              const bool  anColor,
+                                              std::map< std::wstring,
+                                              std::list<std::wstring>> &theMaterialShape,
+                                              std::string& theError)
 {
-  
+
   STEPControl_Reader aReader;
   std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
   //VSR: 16/09/09: Convert to METERS
@@ -286,6 +287,11 @@ std::shared_ptr<GeomAPI_Shape>  STEPImportAttributs(const std::string& theFileNa
     return aGeomShape;
   }
 
-  return readAttributes(cafreader,theResultBody,anMaterials, theMaterialShape, "STEP-XCAF");
+  return readAttributes(cafreader,
+                        theResultBody,
+                        anMaterials,
+                        theMaterialShape,
+                        "STEP-XCAF",
+                        theError);
   }
 
index 9433a0a70bb88c07fe23b1d78e53c92349a0062e..fd886993b456167fe8eca67c77736881dbe699de 100644 (file)
@@ -38,11 +38,12 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
 /// Implementation of the import STEP files algorithms with Attributs (Name, Color, Materials)
 GEOMALGOAPI_EXPORT
 std::shared_ptr<GeomAPI_Shape>  STEPImportAttributs(const std::string& theFileName,
-                                                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                                    const bool  anScalInterUnits,
-                                                    const bool  anMaterials,
-                                                    const bool  anColor, 
-                                                    std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
-                                                    std::string& theError);
+                                                std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                                const bool  anScalInterUnits,
+                                                const bool  anMaterials,
+                                                const bool  anColor,
+                                                std::map< std::wstring,
+                                                std::list<std::wstring>> &theMaterialShape,
+                                                std::string& theError);
 
 #endif /* GEOMALGOAPI_STEPIMPORT_H_ */
index 3e2a700cf9c8ad23eafcb9f8455fc84496e0552f..5f7f95680583355d086cbe4a6818f232bfe8ab10 100644 (file)
@@ -63,7 +63,7 @@
 #include <TDocStd_Document.hxx>
 #include <XCAFDoc_ColorTool.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_MaterialTool.hxx> 
+#include <XCAFDoc_MaterialTool.hxx>
 #include <Quantity_Color.hxx>
 #include <TopoDS.hxx>
 #include <STEPConstruct.hxx>
@@ -104,8 +104,10 @@ TopoDS_Shape GetShape(const Handle(Standard_Transient)        &theEnti,
 std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
                                                std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                                const bool  anMaterials,
-                                               std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
-                                               const std::string &format)
+                                               std::map< std::wstring,
+                                               std::list<std::wstring>> &theMaterialShape,
+                                               const std::string &format,
+                                               std::string& theError)
 {
   // dummy XCAF Application to handle the STEP XCAF Document
   Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
@@ -129,11 +131,10 @@ std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
   setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel,
                      TopLoc_Location(),theResultBody,theMaterialShape,false);
 
-     
-  std::shared_ptr<GeomAPI_Shape> ageom =  setgeom(shapeTool,mainLabel);
-  STEPControl_Reader aReader = reader.ChangeReader();   
-  
+  std::shared_ptr<GeomAPI_Shape> ageom =  setgeom(shapeTool,mainLabel,theError);
+
+  STEPControl_Reader aReader = reader.ChangeReader();
+
   // BEGIN: reading materials of sub-shapes from file
   if ( anMaterials )
   {
@@ -156,11 +157,12 @@ std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
     }
   }
 
-  return ageom;                                  
+  return ageom;
 }
 
 std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
-                                       const TDF_Label &label)
+                                       const TDF_Label &label,
+                                       std::string& theError)
 {
   BRep_Builder B;
   TopoDS_Compound compound;
@@ -181,7 +183,6 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeToo
   } else {
     for (Standard_Integer i=1; i<frshapes.Length(); i++) {
       TopoDS_Shape S = shapeTool->GetShape(frshapes.Value(i));
-
       TDF_Label aLabel = shapeTool->FindShape(S, Standard_False);
       if ( (!aLabel.IsNull()) && (shapeTool->IsShape(aLabel)) ) {
         if (shapeTool->IsFree(aLabel) ) {
@@ -189,12 +190,28 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeToo
             continue;
           }
           else {
-            B.Add(compound, S);
+            if (!shapeTool->IsReference(aLabel) ){
+              for(TDF_ChildIterator it(aLabel); it.More(); it.Next()) {
+                B.Add(compound, shapeTool->GetShape(it.Value()) );
+              }
+            }else{
+              B.Add(compound, S);
+            }
           }
         }
       }
     }
+
     TopoDS_Shape shape = compound;
+    // Check if any BRep entity has been read, there must be at least a vertex
+    if ( !TopExp_Explorer( shape, TopAbs_VERTEX ).More() )
+    {
+      theError = "No geometrical data in the imported file.";
+      std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+      aGeomShape->setImpl(new TopoDS_Shape());
+      return aGeomShape;
+    }
+
     aGeomShape->setImpl(new TopoDS_Shape(shape));
     return aGeomShape;
   }
@@ -206,7 +223,8 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
                                     const TDF_Label &label,
                                     const TopLoc_Location &loc,
                                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                    std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
+                                    std::map< std::wstring,
+                                    std::list<std::wstring>> &theMaterialShape,
                                     bool isRef)
 {
   std::wstring shapeName;
@@ -217,7 +235,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
 
     shapeName =  Locale::Convert::toWString(TCollection_AsciiString(name).ToCString()) ;
   }
+
   TopLoc_Location partLoc = loc;
   Handle(XCAFDoc_Location) l;
   if(label.FindAttribute(XCAFDoc_Location::GetID(), l)) {
@@ -233,7 +251,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
     setShapeAttributes( shapeTool, colorTool, materialTool, ref,
                         partLoc,theResultBody,theMaterialShape,true);
   }
+
   if( shapeTool->IsSimpleShape(label) && (isRef || shapeTool->IsFree(label))) {
 
     TopoDS_Shape shape = shapeTool->GetShape(label);
@@ -263,12 +281,11 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
 
     if(materialTool->GetMaterial(label, matName, matDescription, matDensity,
                                  matDensName, matDensValType)) {
-      std::wstring nameMaterial = Locale::Convert::toWString(matName->ToCString()); 
-  
+      std::wstring nameMaterial = Locale::Convert::toWString(matName->ToCString());
+
       theMaterialShape[nameMaterial].push_back(shapeName);
     }
 
-
     Quantity_Color col;
     if(colorTool->GetColor(label, XCAFDoc_ColorGen, col)) {
       double r = col.Red(), g = col.Green(), b = col.Blue();
@@ -295,7 +312,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
           double r = col.Red(), g = col.Green(), b = col.Blue();
           TopoDS_Face face = TopoDS::Face(xp2.Current());
           std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
-          std::wstringstream aNameFace; 
+          std::wstringstream aNameFace;
           TopoDS_Shape shapeface = xp2.Current();
           if (!loc.IsIdentity()){
                   shapeface.Move(loc);
@@ -315,7 +332,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
            colorTool->GetColor(xp1.Current(), XCAFDoc_ColorCurv, col)) {
            double r = col.Red(), g = col.Green(), b = col.Blue();
            std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
-           std::wstringstream aNameEdge; 
+           std::wstringstream aNameEdge;
            aNameEdge << L"Edge_"<< shapeName;
            aShapeGeom->setImpl(new TopoDS_Shape(xp1.Current() ));
            theResultBody->addShapeColor(
@@ -326,9 +343,9 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
     }
   }
   else {
-    int indiceChild = 1;  
+    int indiceChild = 1;
 
-    if (!shapeTool->IsReference(label)){
+    if (!shapeTool->IsReference(label) ){
       TopoDS_Shape shape = shapeTool->GetShape(label);
 
       std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
@@ -338,7 +355,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
       aShapeGeom->setImpl(new TopoDS_Shape(shape));
       shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
     }
-    for(TDF_ChildIterator it(label); it.More(); it.Next()) { 
+    for(TDF_ChildIterator it(label); it.More(); it.Next()) {
 
       setShapeAttributes( shapeTool, colorTool, materialTool,
                          it.Value(), partLoc,theResultBody,theMaterialShape, isRef);
@@ -428,7 +445,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
                           std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
                           aShapeGeom->setImpl(new TopoDS_Shape(aSub));
                           std::wstring nom = theResultBody->findShapeName(aShapeGeom);
-                          std::wstring matName= Locale::Convert::toWString(aMatName->ToCString()); 
+                          std::wstring matName= Locale::Convert::toWString(aMatName->ToCString());
                           theMaterialShape[matName].push_back(nom);
 
                         }
index 2955a530801300cc2a8f5a326c4cdd3c4189bd4e..4e2720c40750724b7abaa1cf47715955b9a3b8cd 100644 (file)
@@ -21,7 +21,7 @@
 #define GEOMALGOAPI_STEPIMPORTXCAF_H_
 
 #include <GeomAlgoAPI.h>
-#include <TopoDS_Shape.hxx> 
+#include <TopoDS_Shape.hxx>
 
 #include <string>
 #include <vector>
 #include <ModelAPI_ResultBody.h>
 #include <TopTools_IndexedMapOfShape.hxx>
 
- // read Attributs of step file 
+ // read Attributs of step file
  GEOMALGOAPI_EXPORT
  std::shared_ptr<GeomAPI_Shape>  readAttributes( STEPCAFControl_Reader &reader,
-                                                 std::shared_ptr<ModelAPI_ResultBody> theResultBody, 
+                                                 std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                                  const bool  anMaterials,
-                                                 std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,          
-                                                 const std::string &format);
- // read attributs for  label                                          
- GEOMALGOAPI_EXPORT                            
+                                                 std::map< std::wstring,
+                                                 std::list<std::wstring>> &theMaterialShape,
+                                                 const std::string &format,
+                                                 std::string& theError);
+ // read attributs for  label
+ GEOMALGOAPI_EXPORT
  void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
                                const Handle(XCAFDoc_ColorTool) &colorTool,
                                const Handle(XCAFDoc_MaterialTool) &materialTool,
                                std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
                                bool isRef);
 
-// read geometry                              
-GEOMALGOAPI_EXPORT                              
+// read geometry
+GEOMALGOAPI_EXPORT
 std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
-                                    const TDF_Label &label);
+                                    const TDF_Label &label,
+                                    std::string& theError);
 
 // store Materiel for theShapeLabel in the map theMaterialShape
-GEOMALGOAPI_EXPORT 
+GEOMALGOAPI_EXPORT
 void StoreMaterial(  std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                      const Handle(Standard_Transient)        &theEnti,
                       const TopTools_IndexedMapOfShape        &theIndices,
index 63380e3e2cf3a95178608b0fa9bb9eff14abd6ef..a5b5134ae7ddc8f6b573a2125b49feb962847840 100644 (file)
@@ -1274,7 +1274,9 @@ std::shared_ptr<ModelAPI_ResultConstruction> Model_Objects::createConstruction(
 }
 
 std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
-    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex,const std::wstring& theNameShape )
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData,
+    const int theIndex,
+    const std::wstring& theNameShape )
 {
   TDF_Label aLab = resultLabel(theFeatureData, theIndex);
   TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
index fe38115434b4c9ea78abfae516709ffc6df12a89..49ba223b0ff5a3257efcb2aced6413041ce4222b 100644 (file)
@@ -220,7 +220,7 @@ class Model_Objects
 
   //! Initializes the data fields of the feature
   void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag);
-  
+
  //! Allows to store the result in the data tree of the document
   //! (attaches 'data' of result to tree)
   void storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
index 74b932c81d0abd7e2074a2a70e39fef8010adf87..f83c96fed1e8ef2c3e1dff29a5624d7ecb1baec6 100644 (file)
@@ -238,17 +238,18 @@ void Model_ResultBody::updateConcealment()
 void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector<int>& color) {
 
   if( myColorsShape.find(theName) == myColorsShape.end())
-    myColorsShape[ theName ] =  color; 
+    myColorsShape[ theName ] =  color;
 }
 
-std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,const std::wstring& theName ){
+std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,
+                                            const std::wstring& theName ){
 
-    int indice = 1; 
-    std::wstringstream aName; 
+    int indice = 1;
+    std::wstringstream aName;
     aName << theName;
     while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
         aName.str(L"");
-        aName << theName << L"__" << indice; 
+        aName << theName << L"__" << indice;
         indice++;
     }
     myNamesShape[ aName.str() ] =  theshape;
@@ -259,26 +260,28 @@ std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> thesh
 std::wstring Model_ResultBody::findShapeName(std::shared_ptr<GeomAPI_Shape> theshape){
 
     TopoDS_Shape  aShape =  theshape->impl<TopoDS_Shape>();
-    for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it = myNamesShape.begin();
+    for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+                                                                  myNamesShape.begin();
            it != myNamesShape.end();
            ++it)
-        {   
+        {
             TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
             if( (aShape.IsSame(curSelectedShape)))  {
                 return (*it).first;
             }
-              
         }
        return  L"material not found" ;
 }
 
 
-void Model_ResultBody::setShapeName(std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
-                                    std::map< std::wstring, std::vector<int>> & theColorsShape) 
+void Model_ResultBody::setShapeName(
+                std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
+                std::map< std::wstring, std::vector<int>> & theColorsShape)
 {
     myNamesShape = theshapename;
     myColorsShape = theColorsShape;
 }
+
 void Model_ResultBody::clearShapeNameAndColor(){
   myNamesShape.clear();
   myColorsShape.clear();
@@ -314,10 +317,11 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
       if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
         std::wstring thenameshape = L"";
         // find shape name read
-        for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it = myNamesShape.begin();
+        for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+                                                                            myNamesShape.begin();
            it != myNamesShape.end();
            ++it)
-        {   
+        {
             TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
             if( !(aShapesIter.Value().IsSame(curSelectedShape))) continue;
             thenameshape = (*it).first;
@@ -325,10 +329,11 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
         }
         aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape);
         //finf color read
-        std::map< std::wstring, std::vector<int>>::iterator itColor = myColorsShape.find(thenameshape);
+        std::map< std::wstring, std::vector<int>>::iterator itColor =
+                                                          myColorsShape.find(thenameshape);
         if(itColor != myColorsShape.end()){
             ModelAPI_Tools::setColor(aSub,(*itColor).second);
-        }   
+        }
         aSub->setShapeName(myNamesShape,myColorsShape);
         mySubs.push_back(aSub);
         mySubsMap[aSub] = int(mySubs.size() - 1);
@@ -336,7 +341,7 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
           aSub->ModelAPI_ResultBody::setIsConcealed(true);
           std::dynamic_pointer_cast<Model_ResultBody>(aSub)->updateConcealment();
         }
-        
+
       } else { // just update shape of this result
         aSub = mySubs[aSubIndex];
       }
index fe39876429da461c9918f5f632d01160a65caf04..b23aa1ac40f2b8ca7bf463da21b0686eff13abf5 100644 (file)
@@ -135,21 +135,24 @@ protected:
 
   friend class Model_Objects;
 
-  // Add shape Name for read shape in step file 
+  // Add shape Name for read shape in step file
   std::wstring addShapeName(std::shared_ptr<GeomAPI_Shape>,const std::wstring& theName) override;
-  // Add color for shape Name read shape in step file 
+  // Add color for shape Name read shape in step file
   void addShapeColor( const std::wstring& theName,std::vector<int>& color) override;
-  // Set the map of name and color read shape in step file 
-  void setShapeName(std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,std::map< std::wstring, std::vector<int>> & theColorsShape) override;
+  // Set the map of name and color read shape in step file
+  void setShapeName(std::map< std::wstring,
+                              std::shared_ptr<GeomAPI_Shape> > &theshapename,
+                              std::map< std::wstring,
+                              std::vector<int>> & theColorsShape) override;
   // find the name of shapp read in step file
   std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theshape) override;
   // Clear the map of name and color read shape in step file
   void clearShapeNameAndColor() override;
-  
-  // map with the name read in step file and shape 
+
+  // map with the name read in step file and shape
   std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > myNamesShape;
-  // map with the name contruct and color read 
-  std::map< std::wstring, std::vector<int>> myColorsShape; 
+  // map with the name contruct and color read
+  std::map< std::wstring, std::vector<int>> myColorsShape;
 
 };
 
index deefff6c19a6f2e0fa140bd3ff66795698298cf2..7b7876165946fb970b92faf8a221c3f33b3e7693 100644 (file)
@@ -117,7 +117,6 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     Config
     GeomAPI
-    Locale
     ${OpenCASCADE_ApplicationFramework_LIBRARIES}
 )
 SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
@@ -270,6 +269,4 @@ ADD_UNIT_TESTS(TestConstants.py
                Test19707.py
                Test19726.py
                Test19912.py
-               Test19932.py
-               Test19989.py
 )