]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix #20368 refactoring code
authorJérôme <jerome.lucas@cesgenslab.fr>
Fri, 20 Nov 2020 15:31:56 +0000 (16:31 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Fri, 20 Nov 2020 15:31:56 +0000 (16:31 +0100)
22 files changed:
src/ConnectorAPI/Test/TestImportSTEP.py
src/ExchangeAPI/ExchangeAPI_Import.cpp
src/ExchangeAPI/ExchangeAPI_Import.h
src/ExchangePlugin/ExchangePlugin_Dump.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.h
src/ExchangePlugin/Test/TestImportSTEP.py
src/ExchangePlugin/doc/examples/importStep.py
src/ExchangePlugin/doc/importFeature.rst
src/ExchangePlugin/plugin-Exchange.xml
src/FeaturesAPI/FeaturesAPI_ImportResult.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h
src/Model/Model_BodyBuilder.cpp
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/ModelAPI_ResultBody.h
src/PythonAPI/model/exchange/__init__.py

index f583934777d5bb808dbb2ac668ee1dd0889d190c..84b6d90ce96b8cab3f7426adcc290379fe05adc3 100644 (file)
@@ -68,7 +68,7 @@ def testImportSTEP():
     Part_1_doc = Part_1.document()
     aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "black_and_white.step")
     print("aShapePath=",aShapePath)
-    Import_1 = model.addImportStep(Part_1_doc,aShapePath, True, True, True)
+    Import_1 = model.addImportSTEP(Part_1_doc,aShapePath, True, True, True)
 
     model.do()
 
index 84a949a674f629a65cdde331f6e97466f781c159..20b0b4209d0ca9bce3fb2148b99eb87079727b36 100644 (file)
@@ -82,11 +82,11 @@ void ExchangeAPI_Import::setParameters(const std::string & theFilePath,
 //--------------------------------------------------------------------------------------
 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
 {
-  
+
   std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath);
   if (anExtension == "STEP" || anExtension == "STP") {
     setParameters(theFilePath,true,false,false);
-  }else{
+  } else {
     fillAttribute(theFilePath, myfilePath);
     fillAttribute(anExtension, myimportType);
     execute();
@@ -106,7 +106,7 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
   if (aFormat == "STEP" || aFormat == "STP")
   {
     aFilePath = aBase->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID())->value();
-  }else{
+  } else {
     aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value();
   }
 
@@ -119,14 +119,14 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
     aPos += aTo.size();
   }
   std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
-  ifanExtension == "STP" || anExtension == "STEP"){
-      theDumper << aBase << " = model.addImportStep(" << aPartName << ", \""
+  if (anExtension == "STP" || anExtension == "STEP"){
+      theDumper << aBase << " = model.addImportSTEP(" << aPartName << ", \""
                 << aFilePath << "\"" ;
 
       theDumper << ", " << scalInterUnits()->value()
                 << ", " << materials()->value()
                 << ", " << colors()->value() << ")"<< std::endl;
-  }else{
+  } else {
       theDumper << aBase << " = model.addImport(" << aPartName << ", \""
             << aFilePath << "\")" << std::endl;
   }
@@ -136,7 +136,7 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
 
   CompositeFeaturePtr aCompositeFeature =
     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aBase);
-  if(aCompositeFeature.get()) {
+  if (aCompositeFeature.get()) {
     int aNbOfSubs = aCompositeFeature->numberOfSubs();
     for(int anIndex = 0; anIndex < aNbOfSubs; ++anIndex) {
       std::string aSubFeatureGet =
@@ -155,7 +155,7 @@ ImportPtr addImport(
   return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath));
 }
 
-ImportPtr addImportStep(
+ImportPtr addImportSTEP(
     const std::shared_ptr<ModelAPI_Document> & thePart,
     const std::string & theFilePath,
     const bool  theScalInterUnits,
index 3024899189d4b7bc09b11527c936baa05623258b..b4439d2d3df1a74e25d68792ee359fdd326e5e57 100644 (file)
@@ -103,7 +103,7 @@ ImportPtr addImport(const std::shared_ptr<ModelAPI_Document> & thePart,
  * \brief Create Import Step feature
  */
 EXCHANGEAPI_EXPORT
-ImportPtr addImportStep(const std::shared_ptr<ModelAPI_Document> & thePart,
+ImportPtr addImportSTEP(const std::shared_ptr<ModelAPI_Document> & thePart,
                         const std::string & theFilePath,
                         const bool  anScalInterUnits,
                         const bool  anMaterials,
index 0f751808dd9520c7ba6498e867103ce5d1302f9e..3c86b8c3f5b7373b5c17ede53d9fc5a57b73cb3c 100644 (file)
@@ -93,10 +93,10 @@ void ExchangePlugin_Dump::dump(const std::string& theFileName)
   DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
 
   int aFeaturesNb = aDoc->size(ModelAPI_Feature::group());
-  if(aFeaturesNb > 1) {
+  if (aFeaturesNb > 1) {
     FeaturePtr aLastFeature =
         ModelAPI_Feature::feature(aDoc->object(ModelAPI_Feature::group(), aFeaturesNb - 1));
-    if(aDoc->currentFeature(true) != aLastFeature) {
+    if (aDoc->currentFeature(true) != aLastFeature) {
         setError("Dump cannot be done. Please move the history line to the end before dumping.");
         return;
     }
@@ -104,10 +104,10 @@ void ExchangePlugin_Dump::dump(const std::string& theFileName)
 
   DocumentPtr anActiveDoc = ModelAPI_Session::get()->activeDocument();
   aFeaturesNb = anActiveDoc->size(ModelAPI_Feature::group());
-  if(aFeaturesNb > 1) {
+  if (aFeaturesNb > 1) {
     FeaturePtr aLastFeature =
         ModelAPI_Feature::feature(anActiveDoc->object(ModelAPI_Feature::group(), aFeaturesNb - 1));
-    if(anActiveDoc->currentFeature(true) != aLastFeature) {
+    if (anActiveDoc->currentFeature(true) != aLastFeature) {
       setError("Dump cannot be done. Please move the history line to the end before dumping.");
       return;
     }
index 0535c3888e406650a87cfc0525b3fe6d4c71a03a..158a1cc675b557aeb172a0d6c42970e0af0f3612 100644 (file)
@@ -119,7 +119,7 @@ void ExchangePlugin_ImportFeature::execute()
   if (aFormat == "STEP" || aFormat == "STP")
   {
     aFilePathAttr = string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID());
-  }else{
+  } else {
     aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
   }
   std::string aFilePath = aFilePathAttr->value();
@@ -248,14 +248,14 @@ void ExchangePlugin_ImportFeature::setColorGroups(
   for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) {
     ModelAPI_Tools::getColor(*aRes, aColor);
     if (!aColor.empty() ){
-        auto it = std::find(aColorsRead.begin(), aColorsRead.end(), aColor);
-        if ( it == aColorsRead.end() ){
-             std::wstringstream aColorName;
-            aColorName<<L"Color_"<< anIndice;
-            setColorGroup(theResultBody, aColor, aColorName.str());
-            anIndice++;
-            aColorsRead.push_back(aColor);
-        }
+      auto it = std::find(aColorsRead.begin(), aColorsRead.end(), aColor);
+      if ( it == aColorsRead.end() ){
+        std::wstringstream aColorName;
+        aColorName<<L"Color_"<< anIndice;
+        setColorGroup(theResultBody, aColor, aColorName.str());
+        anIndice++;
+        aColorsRead.push_back(aColor);
+      }
     }
   }
 }
@@ -276,7 +276,7 @@ void ExchangePlugin_ImportFeature::setColorGroup(
 
   ModelAPI_Tools::getColor(theResultBody, aColor);
   if (!aColor.empty() ){
-    ifaColor == theColor ) {
+    if (aColor == theColor ) {
       GeomShapePtr aShape = theResultBody->shape();
       aSelectionList->setSelectionType(aShape->shapeTypeStr() );
       aSelectionList->append(theResultBody,aShape);
@@ -291,9 +291,9 @@ void ExchangePlugin_ImportFeature::setColorGroup(
     GeomShapePtr aShape = (*aRes)->shape();
 
     if (!aColor.empty() ){
-      ifaRes->get() &&  aColor == theColor ) {
-          aSelectionList->setSelectionType(aShape->shapeTypeStr() );
-          aSelectionList->append(theResultBody,aShape);
+      if (aRes->get() &&  aColor == theColor ) {
+        aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+        aSelectionList->append(theResultBody,aShape);
       }
     }
   }
@@ -331,7 +331,7 @@ void ExchangePlugin_ImportFeature::setMaterielGroup(
       GeomShapePtr aShape = (*aRes)->shape();
       for(std::list<std::wstring>::iterator aResMat = anIt->second.begin();
                                  aResMat != anIt->second.end(); ++aResMat) {
-        ifaRes->get() && ((*aRes)->data()->name() == (*aResMat)))
+        if (aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
         {
           aSelectionList->append(theResultBody,aShape);
           aSelectionList->setSelectionType(aShape->shapeTypeStr() );
index 93d551bf57aaf70705e81ac0f9dbf55132308d82..cd55564d315e33c21fd22e441e076b268ff654d8 100644 (file)
@@ -139,15 +139,15 @@ 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
+  /// set a group of color
   void setColorGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                      std::vector<int> &aColor,
                      const std::wstring& theName );
 
-  // set Materiel group of color
+  /// set Materiel group of color
   void setMaterielGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                         std::map< std::wstring, std::list<std::wstring>> &theMaterialShape);
 
index f583934777d5bb808dbb2ac668ee1dd0889d190c..84b6d90ce96b8cab3f7426adcc290379fe05adc3 100644 (file)
@@ -68,7 +68,7 @@ def testImportSTEP():
     Part_1_doc = Part_1.document()
     aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "black_and_white.step")
     print("aShapePath=",aShapePath)
-    Import_1 = model.addImportStep(Part_1_doc,aShapePath, True, True, True)
+    Import_1 = model.addImportSTEP(Part_1_doc,aShapePath, True, True, True)
 
     model.do()
 
index 54efab493d54bf1a9cbc5ecfc0646d3e32f4438f..0adc73a7ae6dcc83503f7e3d157ef5624458eee0 100644 (file)
@@ -6,6 +6,6 @@ file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","black_and_white.
 partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
-Import_1 = model.addImportStep(Part_1_doc,file_path, True, True, True)
+Import_1 = model.addImportSTEP(Part_1_doc,file_path, True, True, True)
 model.do()
 model.end()
index 33706fb4044df926c6e2814ef036d69f36f79db1..c68dcc778df52d13900491f6f6294fc5bda91944 100644 (file)
@@ -127,7 +127,7 @@ The **Import to** combobox provides the list of destinations (one of existing Pa
 
 **TUI Command**:
 
-.. py:function:: model.addImportStep(Part_doc, FileNameString,scalInterUnits,materials,colors)
+.. py:function:: model.addImportSTEP(Part_doc, FileNameString,scalInterUnits,materials,colors)
 
     :param part: The current part object
     :param string: A file name string.
index f015d806959fac09a76170fe9ae332ca1cd7da29..5fbe54f9f5d4ec6e886544505e0c8bb0ec869a2d 100644 (file)
       </feature>
       <feature id="Import" title="Import" tooltip="Import a file" icon="icons/Exchange/import.png"
                helpfile="importFeature.html" internal="1">
-        <!--file_selector id="file_path" title="Import file" path="">
-          <validator id="ExchangePlugin_ImportFormat" parameters="BREP|BRP:BREP,STEP|STP:STEP,IGES|IGS:IGES,XAO:XAO" />
-        </file_selector-->
         <switch id="ImportType">
-        <case id="Regular" title="BREP, XAO, IGES">
-          <file_selector id="file_path" title="Import file" path="">
-              <validator id="ExchangePlugin_ImportFormat" parameters="BREP|BRP:BREP,IGES|IGS:IGES,XAO:XAO" />
-          </file_selector>
-        </case>
-        <case id="STEP" title="STEP">
+          <case id="Regular" title="BREP, XAO, IGES">
+            <file_selector id="file_path" title="Import file" path="">
+                <validator id="ExchangePlugin_ImportFormat" parameters="BREP|BRP:BREP,IGES|IGS:IGES,XAO:XAO" />
+            </file_selector>
+          </case>
+          <case id="STEP" title="STEP">
             <file_selector id="step_file_path" title="Import file" path="">
               <validator id="ExchangePlugin_ImportFormat" parameters="STEP|STP:STEP" />
             </file_selector>
index 923b246ed1a92b328935e2309152bb9d8de24165..068730242bf19e3546ce235e62038b73cb350dc7 100644 (file)
@@ -34,7 +34,7 @@ FeaturesAPI_ImportResult::FeaturesAPI_ImportResult(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theObjects) : ModelHighAPI_Interface(theFeature)
 {
-  if(initialize()) {
+  if (initialize()) {
     setObjects(theObjects);
   }
 }
index 5fdb7f68799d5b0f20111ab2a8709d085ab87c4e..a10212ec379f953f76ed1f40c28058cce6794837 100644 (file)
@@ -18,6 +18,7 @@
 //
 
 #include <GeomAlgoAPI_STEPImport.h>
+#include <GeomAlgoAPI_STEPImportXCAF.h>
 
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_Label.hxx>
@@ -31,6 +32,8 @@
 #include <Interface_Graph.hxx>
 #include <Interface_InterfaceModel.hxx>
 #include <Interface_Static.hxx>
+
+#include <STEPCAFControl_Reader.hxx>
 #include <STEPControl_Reader.hxx>
 #include <StepBasic_Product.hxx>
 #include <StepBasic_ProductDefinition.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
 
-//JL_CGLB
-#include <XCAFApp_Application.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <OSD_Exception.hxx>
-#include <STEPCAFControl_Reader.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ColorTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <GeomAlgoAPI_STEPImportXCAF.h>
-#include <Quantity_Color.hxx>
-
-#include <TColStd_SequenceOfAsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-#include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
-// ----------------------------------------------------------------------------
 
+//==================================================================================================
 std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
                                           const std::string& theFormatName,
                                           const bool theScalInterUnits,
@@ -210,20 +198,20 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
   return aGeomShape;
 }
 
-
-std::shared_ptr<GeomAPI_Shape>  STEPImportAttributs(const std::string& theFileName,
-                                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                              const bool  theScalInterUnits,
-                                              const bool  theMaterials,
-                                              const bool  theColor,
-                                              std::map< std::wstring,
-                                              std::list<std::wstring>> &theMaterialShape,
-                                              std::string& theError)
+//==================================================================================================
+GeomShapePtr STEPImportAttributs(const std::string& theFileName,
+                                 std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                 const bool  theScalInterUnits,
+                                 const bool  theMaterials,
+                                 const bool  theColor,
+                                 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
+
   Interface_Static::SetCVal("xstep.cascade.unit","M");
   Interface_Static::SetIVal("read.step.ideas", 1);
   Interface_Static::SetIVal("read.step.nonmanifold", 1);
@@ -292,5 +280,4 @@ std::shared_ptr<GeomAPI_Shape>  STEPImportAttributs(const std::string& theFileNa
                         theMaterials,
                         theMaterialShape,
                         theError);
-}
-
+}
\ No newline at end of file
index fd886993b456167fe8eca67c77736881dbe699de..4d62ab6b6240e0df263aef3360a80204982f3f1b 100644 (file)
@@ -37,13 +37,13 @@ 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);
+GeomShapePtr  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);
 
 #endif /* GEOMALGOAPI_STEPIMPORT_H_ */
index 8a465911d5ab3a4742b78448f1087cc8560378b2..4710b2668bf9b884a921e9e902cde54ca9aa7c6c 100644 (file)
 
 #include <GeomAlgoAPI_STEPImportXCAF.h>
 
-#include <TDF_ChildIDIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
+#include <BRep_Builder.hxx>
 
-#include <IFSelect_ReturnStatus.hxx>
 #include <Interface_EntityIterator.hxx>
 #include <Interface_Graph.hxx>
 #include <Interface_InterfaceModel.hxx>
-#include <Interface_Static.hxx>
-#include <STEPControl_Reader.hxx>
-#include <StepBasic_Product.hxx>
-#include <StepBasic_ProductDefinition.hxx>
-#include <StepBasic_ProductDefinitionFormation.hxx>
-#include <StepGeom_GeometricRepresentationItem.hxx>
-#include <StepShape_TopologicalRepresentationItem.hxx>
+
+#include <Quantity_Color.hxx>
+
 #include <StepRepr_DescriptiveRepresentationItem.hxx>
 #include <StepRepr_ProductDefinitionShape.hxx>
 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
 #include <StepRepr_Representation.hxx>
-#include <TransferBRep.hxx>
-#include <Transfer_Binder.hxx>
-#include <Transfer_TransientProcess.hxx>
-#include <XSControl_TransferReader.hxx>
-#include <XSControl_WorkSession.hxx>
-
-#include <BRep_Builder.hxx>
 
+#include <TDataStd_Name.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TDocStd_Document.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Iterator.hxx>
+#include <TopoDS.hxx>
+#include <Transfer_TransientProcess.hxx>
+#include <TransferBRep.hxx>
 
 #include <XCAFApp_Application.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
-#include <OSD_Exception.hxx>
-#include <Locale_Convert.h>
-
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ColorTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_MaterialTool.hxx>
-#include <Quantity_Color.hxx>
-#include <TopoDS.hxx>
-#include <STEPConstruct.hxx>
-#include <STEPConstruct_Tool.hxx>
-#include <StepBasic_ProductDefinitionRelationship.hxx>
-#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
 #include <XCAFDoc_Location.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XSControl_TransferReader.hxx>
+#include <XSControl_WorkSession.hxx>
 
-#include <TColStd_SequenceOfAsciiString.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
-
+#include <Locale_Convert.h>
 
 //=============================================================================
-/*!
- *  GetShape()
- */
-//=============================================================================
-
 TopoDS_Shape getShape(const Handle(Standard_Transient) &theEnti,
                       const Handle(Transfer_TransientProcess) &theTP)
 {
@@ -99,14 +66,12 @@ TopoDS_Shape getShape(const Handle(Standard_Transient) &theEnti,
   return aResult;
 }
 
-// ----------------------------------------------------------------------------
-
-std::shared_ptr<GeomAPI_Shape> readAttributes(
-                              STEPCAFControl_Reader &theReader,
-                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                              const bool  theIsMaterials,
-                              std::map< std::wstring,std::list<std::wstring>> &theMaterialShape,
-                              std::string& theError)
+//=============================================================================
+std::shared_ptr<GeomAPI_Shape> readAttributes(STEPCAFControl_Reader &theReader,
+                               std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                               const bool  theIsMaterials,
+                               std::map< std::wstring,std::list<std::wstring>> &theMaterialShape,
+                               std::string& theError)
 {
   // dummy XCAF Application to handle the STEP XCAF Document
   Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
@@ -152,6 +117,7 @@ std::shared_ptr<GeomAPI_Shape> readAttributes(
   return ageom;
 }
 
+//=============================================================================
 std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
                                        const TDF_Label &theLabel,
                                        std::string& theError)
@@ -180,13 +146,12 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShape
         if (theShapeTool->IsFree(aLabel) ) {
           if (aS.IsNull()) {
             continue;
-          }
-          else {
+          } else {
             if (!theShapeTool->IsReference(aLabel) ){
               for(TDF_ChildIterator anIt(aLabel); anIt.More(); anIt.Next()) {
                 aB.Add(aCompound, theShapeTool->GetShape(anIt.Value()) );
               }
-            }else{
+            } else {
               aB.Add(aCompound, aS);
             }
           }
@@ -208,7 +173,7 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &theShape
     return aGeomShape;
   }
 }
-
+//=============================================================================
 void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
                         const Handle(XCAFDoc_ColorTool) &theColorTool,
                         const Handle(XCAFDoc_MaterialTool) &theMaterialTool,
@@ -221,7 +186,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
   std::wstring aShapeName;
   Handle(TDataStd_Name) aN;
 
-  if(theLabel.FindAttribute(TDataStd_Name::GetID(), aN)) {
+  if (theLabel.FindAttribute(TDataStd_Name::GetID(), aN)) {
     TCollection_ExtendedString aName = aN->Get();
 
     aShapeName =  Locale::Convert::toWString(TCollection_AsciiString(aName).ToCString()) ;
@@ -229,21 +194,21 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
 
   TopLoc_Location aPartLoc = theLoc;
   Handle(XCAFDoc_Location) al;
-  if(theLabel.FindAttribute(XCAFDoc_Location::GetID(), al)) {
-    if(theIsRef)
+  if (theLabel.FindAttribute(XCAFDoc_Location::GetID(), al)) {
+    if (theIsRef)
       aPartLoc = aPartLoc * al->Get();
     else
       aPartLoc = al->Get();
   }
 
   TDF_Label aRef;
-  if(theShapeTool->IsReference(theLabel) && theShapeTool->GetReferredShape(theLabel, aRef)) {
+  if (theShapeTool->IsReference(theLabel) && theShapeTool->GetReferredShape(theLabel, aRef)) {
 
     setShapeAttributes( theShapeTool, theColorTool, theMaterialTool, aRef,
                         aPartLoc,theResultBody,theMaterialShape,true);
   }
 
-  iftheShapeTool->IsSimpleShape(theLabel) && (theIsRef || theShapeTool->IsFree(theLabel))) {
+  if (theShapeTool->IsSimpleShape(theLabel) && (theIsRef || theShapeTool->IsFree(theLabel))) {
 
     TopoDS_Shape aShape = theShapeTool->GetShape(theLabel);
 
@@ -270,7 +235,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
     Handle(TCollection_HAsciiString) aMatDensName;
     Handle(TCollection_HAsciiString) aMatDensValType;
 
-    if(theMaterialTool->GetMaterial(theLabel, aMatName, aMatDescription, aMatDensity,
+    if (theMaterialTool->GetMaterial(theLabel, aMatName, aMatDescription, aMatDensity,
                                  aMatDensName, aMatDensValType)) {
       std::wstring aNameMaterial = Locale::Convert::toWString(aMatName->ToCString());
 
@@ -278,26 +243,24 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
     }
 
     Quantity_Color aCol;
-    if(theColorTool->GetColor(theLabel, XCAFDoc_ColorGen, aCol)) {
+    if (theColorTool->GetColor(theLabel, XCAFDoc_ColorGen, aCol)) {
       double r = aCol.Red(), g = aCol.Green(), b = aCol.Blue();
       std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
       theResultBody->addShapeColor(aShapeName, ColRGB);
-    }
-    else if(theColorTool->GetColor(theLabel, XCAFDoc_ColorSurf, aCol)) {
+    } else if (theColorTool->GetColor(theLabel, XCAFDoc_ColorSurf, aCol)) {
       double r = aCol.Red(), g = aCol.Green(), b = aCol.Blue();
       std::vector<int> aColRGB = {int(r*255),int(g*255),int(b*255)};
       theResultBody->addShapeColor(aShapeName, aColRGB);
-    }
-    else if(theColorTool->GetColor(theLabel, XCAFDoc_ColorCurv, aCol)) {
+    } else if (theColorTool->GetColor(theLabel, XCAFDoc_ColorCurv, aCol)) {
      double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue();
      std::vector<int> aColRGB = {int(aR*255),int(aG*255),int(aB*255)};
       theResultBody->addShapeColor(aShapeName, aColRGB);
     }
     // check explicit coloring of boundary entities
-    if(aDim == 3) {
+    if (aDim == 3) {
       TopExp_Explorer aXp2(aShape, TopAbs_FACE);
       while(aXp2.More()) {
-        if(theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorGen, aCol) ||
+        if (theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorGen, aCol) ||
            theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorSurf, aCol) ||
            theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorCurv, aCol)) {
           double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue();
@@ -315,10 +278,10 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
         aXp2.Next();
       }
     }
-    if(aDim == 2) {
+    if (aDim == 2) {
       TopExp_Explorer aXp1(aShape, TopAbs_EDGE);
       while(aXp1.More()) {
-        if(theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorGen, aCol) ||
+        if (theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorGen, aCol) ||
            theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorSurf, aCol) ||
            theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorCurv, aCol)) {
            double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue();
@@ -332,8 +295,7 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
         aXp1.Next();
       }
     }
-  }
-  else {
+  } else {
     if (!theShapeTool->IsReference(theLabel) ){
       TopoDS_Shape aShape = theShapeTool->GetShape(theLabel);
 
@@ -352,91 +314,84 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
   }
 }
 
-
 //=============================================================================
-  /*!
-   *  StoreMaterial()
-   */
-  //=============================================================================
-
-  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 )
-  {
-    // Treat Product Definition Shape only.
-    Handle(StepRepr_ProductDefinitionShape) aPDS =
-      Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti);
-    Handle(StepBasic_ProductDefinition)     aProdDef;
-
-    if(aPDS.IsNull() == Standard_False) {
-      // Product Definition Shape ==> Product Definition
-      aProdDef = aPDS->Definition().ProductDefinition();
-    }
-
-    if (aProdDef.IsNull() == Standard_False) {
-      // Product Definition ==> Property Definition
-      const Interface_Graph    &aGraph = theTP->Graph();
-      Interface_EntityIterator  aSubs  = aGraph.Sharings(aProdDef);
-      TopoDS_Shape              aShape;
-
-      for(aSubs.Start(); aSubs.More(); aSubs.Next()) {
-        Handle(StepRepr_PropertyDefinition) aPropD =
-          Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value());
-
-        if(aPropD.IsNull() == Standard_False) {
-          // Property Definition ==> Representation.
-          Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD);
-
-          for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) {
-            Handle(StepRepr_PropertyDefinitionRepresentation) aPDR =
-              Handle(StepRepr_PropertyDefinitionRepresentation)::
-              DownCast(aSubs1.Value());
-
-            if(aPDR.IsNull() == Standard_False) {
-              // Property Definition ==> Material Name.
-              Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation();
-
-              if(aRepr.IsNull() == Standard_False) {
-                Standard_Integer anIr;
-
-                for(anIr = 1; anIr <= aRepr->NbItems(); anIr++) {
-                  Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(anIr);
-                  Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
-                    Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI);
-
-                  if(aDRI.IsNull() == Standard_False) {
-                    // Get shape from Product Definition
-                    Handle(TCollection_HAsciiString) aMatName = aDRI->Name();
-                    if(aMatName.IsNull() == Standard_False) {
-                      TCollection_ExtendedString
-                        aMatNameExt (aMatName->ToCString());
+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 )
+{
+  // Treat Product Definition Shape only.
+  Handle(StepRepr_ProductDefinitionShape) aPDS =
+    Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti);
+  Handle(StepBasic_ProductDefinition)     aProdDef;
+
+  if (aPDS.IsNull() == Standard_False) {
+    // Product Definition Shape ==> Product Definition
+    aProdDef = aPDS->Definition().ProductDefinition();
+  }
 
+  if (aProdDef.IsNull() == Standard_False) {
+    // Product Definition ==> Property Definition
+    const Interface_Graph    &aGraph = theTP->Graph();
+    Interface_EntityIterator  aSubs  = aGraph.Sharings(aProdDef);
+    TopoDS_Shape              aShape;
+
+    for(aSubs.Start(); aSubs.More(); aSubs.Next()) {
+      Handle(StepRepr_PropertyDefinition) aPropD =
+        Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value());
+
+      if (aPropD.IsNull() == Standard_False) {
+        // Property Definition ==> Representation.
+        Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD);
+
+        for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) {
+          Handle(StepRepr_PropertyDefinitionRepresentation) aPDR =
+            Handle(StepRepr_PropertyDefinitionRepresentation)::
+            DownCast(aSubs1.Value());
+
+          if (aPDR.IsNull() == Standard_False) {
+            // Property Definition ==> Material Name.
+            Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation();
+
+            if (aRepr.IsNull() == Standard_False) {
+              Standard_Integer anIr;
+
+              for(anIr = 1; anIr <= aRepr->NbItems(); anIr++) {
+                Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(anIr);
+                Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
+                  Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI);
+
+                if (aDRI.IsNull() == Standard_False) {
+                  // Get shape from Product Definition
+                  Handle(TCollection_HAsciiString) aMatName = aDRI->Name();
+                  if (aMatName.IsNull() == Standard_False) {
+                    TCollection_ExtendedString
+                      aMatNameExt (aMatName->ToCString());
+
+                    if (aShape.IsNull()) {
+                      //Get the shape.
+                      aShape = getShape(aProdDef, theTP);
                       if (aShape.IsNull()) {
-                        //Get the shape.
-                        aShape = getShape(aProdDef, theTP);
-                        if (aShape.IsNull()) {
-                          return;
-                        }
+                        return;
                       }
+                    }
 
-                      // as PRODUCT can be included in the main shape
-                      // several times, we look here for all iclusions.
-                      Standard_Integer anISub, aNbSubs = theIndices.Extent();
+                    // as PRODUCT can be included in the main shape
+                    // several times, we look here for all iclusions.
+                    Standard_Integer anISub, aNbSubs = theIndices.Extent();
 
-                      for (anISub = 1; anISub <= aNbSubs; anISub++) {
-                        TopoDS_Shape aSub = theIndices.FindKey(anISub);
+                    for (anISub = 1; anISub <= aNbSubs; anISub++) {
+                      TopoDS_Shape aSub = theIndices.FindKey(anISub);
 
-                        if (aSub.IsPartner(aShape)) {
-                          std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
-                          aShapeGeom->setImpl(new TopoDS_Shape(aSub));
-                          std::wstring aNom = theResultBody->findShapeName(aShapeGeom);
-                          std::wstring aMName= Locale::Convert::toWString(aMatName->ToCString());
-                          theMaterialShape[aMName].push_back(aNom);
+                      if (aSub.IsPartner(aShape)) {
+                        std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
+                        aShapeGeom->setImpl(new TopoDS_Shape(aSub));
+                        std::wstring aNom = theResultBody->findShapeName(aShapeGeom);
+                        std::wstring aMName= Locale::Convert::toWString(aMatName->ToCString());
+                        theMaterialShape[aMName].push_back(aNom);
 
-                        }
                       }
                     }
                   }
@@ -448,4 +403,5 @@ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
       }
     }
   }
+}
 
index 04d4cb7219d8db0b33304eda4e91a06b47599394..d43019068a0b400d051afeb1a2faac3962a8321a 100644 (file)
 #define GEOMALGOAPI_STEPIMPORTXCAF_H_
 
 #include <GeomAlgoAPI.h>
-#include <TopoDS_Shape.hxx>
 
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <GeomAPI_Shape.h>
 #include <XCAFDoc_ColorTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
 #include <XCAFDoc_MaterialTool.hxx>
-#include <TDocStd_Document.hxx>
-#include <XSControl_WorkSession.hxx>
 
 #include <STEPCAFControl_Reader.hxx>
 
 #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 &theReader,
-                                std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                const bool  theMaterials,
-                                std::map< std::wstring,std::list<std::wstring>> &theMaterialShape,
-                                std::string& theError);
-// read attributs for  label
+ std::shared_ptr<GeomAPI_Shape>  readAttributes(STEPCAFControl_Reader &theReader,
+                                 std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                 const bool  theMaterials,
+                                 std::map< std::wstring,std::list<std::wstring>> &theMaterialShape,
+                                 std::string& theError);
+/// read attributs for  label
  GEOMALGOAPI_EXPORT
  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);
+                         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);
 
 // read geometry
 GEOMALGOAPI_EXPORT
@@ -66,11 +56,11 @@ std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeToo
 
 // store Materiel for theShapeLabel in the map theMaterialShape
 GEOMALGOAPI_EXPORT
-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 );
+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);
 
 #endif /* GEOMALGOAPI_STEPIMPORTXCAF_H_ */
index 6c3a491c5c22301e60d24268f70f4e0a0292a022..ca53ccf868ea82c700ed814cda376519199d2740 100644 (file)
@@ -186,12 +186,12 @@ void Model_BodyBuilder::store(const GeomShapePtr& theShape,
     if (aShape.IsNull())
       return;  // null shape inside
 
-    if(!theIsStoreSameShapes) {
+    if (!theIsStoreSameShapes) {
       Handle(TNaming_NamedShape) aNS;
       if (TNaming_Tool::HasLabel(aShapeLab, aShape))
         aNS = TNaming_Tool::NamedShape(aShape, aShapeLab);
       // the last condition is for the issue 2751 : existing shape may be found in compound-NS
-      if(!aNS.IsNull() && !aNS->IsEmpty() && aNS->Get().IsSame(aShape)) {
+      if (!aNS.IsNull() && !aNS->IsEmpty() && aNS->Get().IsSame(aShape)) {
         // This shape is already in document, store reference instead of shape;
         const TDF_Label aFoundLabel = aNS->Label();
         TDF_Reference::Set(aShapeLab, aFoundLabel);
@@ -203,11 +203,11 @@ void Model_BodyBuilder::store(const GeomShapePtr& theShape,
     aBuilder.Generated(aShape);
     // register name
     aShapeLab.ForgetAttribute(TDF_Reference::GetID());
-    if(!aBuilder.NamedShape()->IsEmpty()) {
+    if (!aBuilder.NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
-      if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+      if (aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
         std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
-        if(!aName.empty()) {
+        if (!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
           aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
@@ -255,11 +255,11 @@ void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape,
     }
 
     // register name
-    if(!aBuilder->NamedShape()->IsEmpty()) {
+    if (!aBuilder->NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
-      if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+      if (aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
         std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
-        if(!aName.empty()) {
+        if (!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
           aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
@@ -369,11 +369,11 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
       storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label());
     }
 
-    if(!aBuilder->NamedShape()->IsEmpty()) {
+    if (!aBuilder->NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
-      if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
+      if (aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
         std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
-        if(!aName.empty()) {
+        if (!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
           aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
@@ -504,8 +504,7 @@ bool Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
       if (anIndexTags.index == 2) {
         buildName(anIndexTags.tags.front(), theName + "_1");
       }
-    }
-    else {
+    } else {
       IndexTags anIndexTags;
       anIndexTags.index = 1;
       anIndexTags.tags.push_back(myFreePrimitiveTag);
@@ -806,7 +805,7 @@ void loadGeneratedDangleShapes(
 void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
                                        const std::string& theName)
 {
-  if(theShape->isNull()) return;
+  if (theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
   std::string aName;
   if (aShape.ShapeType() == TopAbs_SOLID) {
@@ -850,7 +849,7 @@ void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
         TopTools_ListIteratorOfListOfShape anIter(aLL);
         const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
         anIter.Next();
-        if(aFace.IsEqual(anIter.Value())) {
+        if (aFace.IsEqual(anIter.Value())) {
           builder(myFreePrimitiveTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
           TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
           aName = theName + "_" + aStr.ToCString();
@@ -994,7 +993,7 @@ void Model_BodyBuilder::loadFirstLevel(GeomShapePtr theShape, const std::string&
     loadNextLevels(itrShape, theName);
   }
   TopTools_ListOfShape   aList;
-  if(findAmbiguities(aShape, aList)) {
+  if (findAmbiguities(aShape, aList)) {
     TopTools_ListIteratorOfListOfShape it(aList);
     for (; it.More(); it.Next(), ++myFreePrimitiveTag) {
       builder(myFreePrimitiveTag)->Generated(it.Value());
index a5b5134ae7ddc8f6b573a2125b49feb962847840..e8fbf563b59a0c52be89aac1e50872d8e10db447 100644 (file)
@@ -1241,9 +1241,9 @@ void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
       theResult->data()->setName(L"");
     } else {
       std::wstringstream aName;
-      if( theNameShape != L"" ){
+      if ( theNameShape != L"" ){
         aName << theNameShape;
-      }else{
+      } else {
         aName << aNewName;
         // if there are several results (issue #899: any number of result),
         // add unique prefix starting from second
index 49ba223b0ff5a3257efcb2aced6413041ce4222b..3ae6c713a352aa6915b02e7aec17d01e860e5e9e 100644 (file)
@@ -125,7 +125,7 @@ class Model_Objects
   /// Creates a body result
   std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0,
-     const std::wstring& theNameShape = L"");
+      const std::wstring& theNameShape = L"");
   /// Creates a part result
   std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
@@ -221,7 +221,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
 //! 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,
                    std::shared_ptr<ModelAPI_Result> theResult,
index f83c96fed1e8ef2c3e1dff29a5624d7ecb1baec6..0595ba58edf0791bb12171ec105db5e277f93317 100644 (file)
@@ -237,49 +237,48 @@ void Model_ResultBody::updateConcealment()
 
 void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector<int>& color) {
 
-  ifmyColorsShape.find(theName) == myColorsShape.end())
+  if (myColorsShape.find(theName) == myColorsShape.end())
     myColorsShape[ theName ] =  color;
 }
 
 std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,
                                             const std::wstring& theName ){
 
-    int indice = 1;
-    std::wstringstream aName;
-    aName << theName;
-    while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
-        aName.str(L"");
-        aName << theName << L"__" << indice;
-        indice++;
-    }
-    myNamesShape[ aName.str() ] =  theshape;
+  int indice = 1;
+  std::wstringstream aName;
+  aName << theName;
+  while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
+    aName.str(L"");
+    aName << theName << L"__" << indice;
+    indice++;
+  }
+  myNamesShape[ aName.str() ] = theshape;
 
-    return aName.str();
+  return aName.str();
 }
 
 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();
-           it != myNamesShape.end();
-           ++it)
-        {
-            TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
-            if( (aShape.IsSame(curSelectedShape)))  {
-                return (*it).first;
-            }
-        }
-       return  L"material not found" ;
+  TopoDS_Shape  aShape =  theshape->impl<TopoDS_Shape>();
+  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)
 {
-    myNamesShape = theshapename;
-    myColorsShape = theColorsShape;
+  myNamesShape = theshapename;
+  myColorsShape = theColorsShape;
 }
 
 void Model_ResultBody::clearShapeNameAndColor(){
@@ -323,7 +322,7 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
            ++it)
         {
             TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
-            if!(aShapesIter.Value().IsSame(curSelectedShape))) continue;
+            if (!(aShapesIter.Value().IsSame(curSelectedShape))) continue;
             thenameshape = (*it).first;
             break;
         }
@@ -331,7 +330,7 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
         //finf color read
         std::map< std::wstring, std::vector<int>>::iterator itColor =
                                                           myColorsShape.find(thenameshape);
-        if(itColor != myColorsShape.end()){
+        if (itColor != myColorsShape.end()){
             ModelAPI_Tools::setColor(aSub,(*itColor).second);
         }
         aSub->setShapeName(myNamesShape,myColorsShape);
index b23aa1ac40f2b8ca7bf463da21b0686eff13abf5..35da37f9978b89cfb88a6d1d9af2a4c83f47179e 100644 (file)
@@ -117,7 +117,7 @@ protected:
   /// Makes a body on the given feature
   Model_ResultBody();
 
-/// Updates the sub-bodies if shape of this object is composite-solid
+  /// Updates the sub-bodies if shape of this object is composite-solid
   void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
                   const bool theShapeChanged = true);
 
@@ -126,7 +126,7 @@ protected:
     const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
     const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated);
 
-  // Checks the state of children and parents to send events of creation/erase when needed
+  /// Checks the state of children and parents to send events of creation/erase when needed
   void updateConcealment();
 
   /// Adds to theOldForSub only old shapes that where used for theSub creation
@@ -135,23 +135,23 @@ 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
+  /// 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
+  /// 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
+  /// 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
+  /// map with the name contruct and color read
   std::map< std::wstring, std::vector<int>> myColorsShape;
 
 };
index 11fdd242171c577527f8302c4f8266a614133cd2..9f33c13b43e1736dcaef22c15175decb46a482fa 100644 (file)
@@ -184,17 +184,20 @@ public:
 
   /// Cleans cash related to the already stored elements
   MODELAPI_EXPORT virtual void cleanCash() = 0;
-  
-  // Add shape Name for read shape in step file 
-  MODELAPI_EXPORT virtual std::wstring addShapeName(std::shared_ptr<GeomAPI_Shape>,const std::wstring& theName) = 0;
-  // Add color for shape Name read shape in step file 
-  MODELAPI_EXPORT virtual void addShapeColor(const std::wstring& theName,std::vector<int>& color) = 0;
-  // Set the map of name and color read shape in step file 
-  MODELAPI_EXPORT virtual void setShapeName(std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
-                                            std::map< std::wstring, std::vector<int>> & theColorsShape) = 0;
-  // Clear the map of name and color read shape in step file                                      
+
+  /// Add shape Name for read shape in step file
+  MODELAPI_EXPORT virtual std::wstring addShapeName
+                              (std::shared_ptr<GeomAPI_Shape>,const std::wstring& theName) = 0;
+  /// Add color for shape Name read shape in step file
+  MODELAPI_EXPORT virtual void addShapeColor
+                              (const std::wstring& theName,std::vector<int>& color) = 0;
+  /// Set the map of name and color read shape in step file
+  MODELAPI_EXPORT virtual void setShapeName
+                          (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
+                           std::map< std::wstring, std::vector<int>> & theColorsShape) = 0;
+  /// Clear the map of name and color read shape in step file
   MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0;
-  // find the name of shapp read in step file
+  /// find the name of shapp read in step file
   MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theshape) = 0;
 
 
@@ -202,8 +205,6 @@ protected:
   /// Default constructor accessible only from Model_Objects
   MODELAPI_EXPORT ModelAPI_ResultBody();
 
-  
-
 };
 
 //! Pointer on feature object
index 84b62bcc3e4ee37ca2144914a17b9f4452d931d5..800ab45f9e2f4366a234f0413a804a6c162d6755 100644 (file)
@@ -19,7 +19,7 @@
 """Package for Exchange plugin for the Parametric Geometry API of the Modeler.
 """
 
-from ExchangeAPI import addImport, addImportStep, exportToFile, exportToXAO, exportToSTL
+from ExchangeAPI import addImport, addImportSTEP, exportToFile, exportToXAO, exportToSTL
 from ExchangeAPI import exportPart, importPart
 
 from .tools import *