]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp
Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_STEPImportXCAF.cpp
index 69797279c79e18a9dd3172242b75d1266b13f727..6fa5b5b5b106a173f59998e5ba82cf454caef92d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  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,8 +145,8 @@ std::shared_ptr<GeomAPI_Shape> readAttributes(STEPCAFControl_Reader &theReader,
 }
 
 //=============================================================================
-std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
-                                       const TDF_Label &theLabel,
+std::shared_ptr<GeomAPI_Shape> setGeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
+                                       const TDF_Label& /*theLabel*/,
                                        std::string& theError)
 {
   BRep_Builder aB;
@@ -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()) );
               }
@@ -164,7 +190,6 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShape
     // Check if any BRep entity has been read, there must be at least a vertex
     if (!TopExp_Explorer( aShape, 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;
     }
@@ -302,7 +327,7 @@ 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,
+                    const TDF_Label                         &/*theShapeLabel*/,
                     std::map< std::wstring, std::list<std::wstring>> &theMaterialShape )
 {
   // Treat Product Definition Shape only.
@@ -387,4 +412,3 @@ void storeMaterial( std::shared_ptr<ModelAPI_ResultBody>    theResultBody,
     }
   }
 }
-