Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_STEPImportXCAF.cpp
index 2d6f6ac602c1f36f1375549c0ef4726278ca1009..6fa5b5b5b106a173f59998e5ba82cf454caef92d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -40,6 +40,7 @@
 #include <TopoDS.hxx>
 #include <Transfer_TransientProcess.hxx>
 #include <TransferBRep.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 #include <XCAFApp_Application.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
 #include <XSControl_TransferReader.hxx>
 #include <XSControl_WorkSession.hxx>
+#include <XCAFDoc_ColorTool.hxx>
+#include <XCAFDoc_MaterialTool.hxx>
 
 #include <Locale_Convert.h>
 
+// read geometry
+std::shared_ptr<GeomAPI_Shape> setGeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
+  const TDF_Label &theLabel,
+  std::string& theError);
+
+/// read attributs for  label
+void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
+  const Handle(XCAFDoc_ColorTool) &theColorTool,
+  const Handle(XCAFDoc_MaterialTool) &TheMaterialTool,
+  const TDF_Label &theLabel,
+  const TopLoc_Location &theLoc,
+  std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
+  bool theIsRef);
+
+// store Materiel for theShapeLabel in the map theMaterialShape
+void storeMaterial(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  const Handle(Standard_Transient) &theEnti,
+  const TopTools_IndexedMapOfShape &theIndices,
+  const Handle(Transfer_TransientProcess) &theTP,
+  const TDF_Label &theShapeLabel,
+  std::map< std::wstring, std::list<std::wstring>> &theMaterialShape);
+
 //=============================================================================
 TopoDS_Shape getShape(const Handle(Standard_Transient) &theEnti,
                       const Handle(Transfer_TransientProcess) &theTP)
@@ -89,7 +115,7 @@ std::shared_ptr<GeomAPI_Shape> readAttributes(STEPCAFControl_Reader &theReader,
   setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel,
                      TopLoc_Location(),theResultBody,theMaterialShape,false);
 
-  std::shared_ptr<GeomAPI_Shape> ageom =  setgeom(shapeTool,mainLabel,theError);
+  std::shared_ptr<GeomAPI_Shape> ageom =  setGeom(shapeTool,mainLabel,theError);
 
   STEPControl_Reader aReader = theReader.ChangeReader();
 
@@ -119,7 +145,7 @@ std::shared_ptr<GeomAPI_Shape> readAttributes(STEPCAFControl_Reader &theReader,
 }
 
 //=============================================================================
-std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
+std::shared_ptr<GeomAPI_Shape> setGeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
                                        const TDF_Label& /*theLabel*/,
                                        std::string& theError)
 {
@@ -140,7 +166,7 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShape
     aGeomShape->setImpl(new TopoDS_Shape(shape));
     return aGeomShape;
   } else {
-    for (Standard_Integer i=1; i<aFrshapes.Length(); i++) {
+    for (Standard_Integer i=1; i<=aFrshapes.Length(); i++) {
       TopoDS_Shape aS = theShapeTool->GetShape(aFrshapes.Value(i));
       TDF_Label aLabel = theShapeTool->FindShape(aS, Standard_False);
       if ( (!aLabel.IsNull()) && (theShapeTool->IsShape(aLabel)) ) {
@@ -148,7 +174,7 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShape
           if (aS.IsNull()) {
             continue;
           } else {
-            if (!theShapeTool->IsReference(aLabel) ){
+            if (aS.ShapeType() != TopAbs_SOLID && !theShapeTool->IsReference(aLabel)){
               for(TDF_ChildIterator anIt(aLabel); anIt.More(); anIt.Next()) {
                 aB.Add(aCompound, theShapeTool->GetShape(anIt.Value()) );
               }
@@ -386,4 +412,3 @@ void storeMaterial( std::shared_ptr<ModelAPI_ResultBody>    theResultBody,
     }
   }
 }
-