]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implementation of fillet multi-Radius (Working progress)
authorJérôme <jerome.lucas@cesgenslab.fr>
Sun, 4 Oct 2020 15:07:30 +0000 (17:07 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Sun, 4 Oct 2020 15:07:30 +0000 (17:07 +0200)
68 files changed:
src/ConnectorAPI/Test/TestExportSTL.py [new file with mode: 0644]
src/ConnectorAPI/Test/TestImportSTEP.py [new file with mode: 0644]
src/ExchangeAPI/CMakeLists.txt
src/ExchangeAPI/ExchangeAPI_Export.cpp
src/ExchangeAPI/ExchangeAPI_Export.h
src/ExchangeAPI/ExchangeAPI_Import.cpp
src/ExchangeAPI/ExchangeAPI_Import.h
src/ExchangePlugin/CMakeLists.txt
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ExportFeature.h
src/ExchangePlugin/ExchangePlugin_Import.cpp
src/ExchangePlugin/ExchangePlugin_Import.h
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.h
src/ExchangePlugin/ExchangePlugin_msg_fr.ts
src/ExchangePlugin/export_widget.xml
src/ExchangePlugin/plugin-Exchange.xml
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Fillet.cpp
src/FeaturesAPI/FeaturesAPI_Fillet.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.h
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp
src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts
src/FeaturesPlugin/Test/TestSymmetry_Part.py
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/extrusionfuse_widget.xml
src/FeaturesPlugin/fillet_widget.xml
src/FeaturesPlugin/icons/fillet_multiradius_by_curv.png [new file with mode: 0644]
src/FeaturesPlugin/icons/fillet_multiradius_by_point.png [new file with mode: 0644]
src/FeaturesPlugin/icons/fillet_var_multiple_radiuses.png [new file with mode: 0644]
src/FeaturesPlugin/pipe_widget.xml
src/FeaturesPlugin/plugin-Features.xml
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h [new file with mode: 0644]
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_Update.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelHighAPI/CMakeLists.txt
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_Macro.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PythonAPI/model/exchange/__init__.py

diff --git a/src/ConnectorAPI/Test/TestExportSTL.py b/src/ConnectorAPI/Test/TestExportSTL.py
new file mode 100644 (file)
index 0000000..edc7eaf
--- /dev/null
@@ -0,0 +1,159 @@
+# Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+      TestExport.py
+      Unit test of ExchangePlugin_TestExport class
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+import salome
+
+import os
+import math
+from tempfile import TemporaryDirectory
+
+import GEOM
+
+from ModelAPI import *
+
+from salome.shaper import model
+
+from salome.geom import geomBuilder
+
+from GeomAlgoAPI import *
+
+__updated__ = "2015-05-22"
+
+salome.salome_init(1)
+geompy = geomBuilder.New()
+
+#=========================================================================
+# Help functions
+#=========================================================================
+def removeFile(theFileName):
+    try: os.remove(theFileName)
+    except OSError: pass
+    assert not os.path.exists(theFileName), \
+            "Can not remove file {0}".format(theFileName)
+
+#=========================================================================
+# test Export STL 
+#=========================================================================
+def testExportSTL(theFile, theDelta, theErrorExpected = False):
+
+    model.begin()
+    partSet = model.moduleDocument()
+    Part_1 = model.addPart(partSet)
+    Part_1_doc = Part_1.document()
+    Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+    Box_2 = model.addBox(Part_1_doc, 20, 20, 20)
+    model.do()
+
+    # First export to GEOM
+    model.exportToGEOM(Part_1_doc)
+    model.end()
+
+    theSurface = 600
+
+    print("theFile=",theFile)
+
+    # deflection relative 0.0001 et Ascii 
+    model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID","Box_1_1"),0.0001, 0.5, True,False)
+
+ #==   assert os.path.exists(theFile)
+        
+    # Check results
+    test_stl_1 = geompy.ImportSTL(theFile)
+    Props = geompy.BasicProperties(test_stl_1)
+    print("\nBasic Properties:")
+    print(" Wires length: ", Props[0])
+    print(" Surface area: ", Props[1])
+    print(" Volume      : ", Props[2])
+
+    aRefSurface = theSurface
+    aResSurface = Props[1]
+    assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+    
+    removeFile(theFile)
+
+    theSurface =  600
+    # deflection relative 0.0001 et binaire
+    model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, True,True)
+
+    # Check results
+    test_stl_1 = geompy.ImportSTL(theFile)
+    Props = geompy.BasicProperties(test_stl_1)
+    print("\nBasic Properties:")
+    print(" Wires length: ", Props[0])
+    print(" Surface area: ", Props[1])
+    print(" Volume      : ", Props[2])
+
+    aRefSurface = theSurface
+    aResSurface = Props[1]
+    assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+    
+    removeFile(theFile)
+
+    theSurface =  600
+    # deflection absolue et AScii
+    model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False, False)
+
+    # Check results
+    test_stl_1 = geompy.ImportSTL(theFile)
+    Props = geompy.BasicProperties(test_stl_1)
+    print("\nBasic Properties:")
+    print(" Wires length: ", Props[0])
+    print(" Surface area: ", Props[1])
+    print(" Volume      : ", Props[2])
+
+    aRefSurface = theSurface
+    aResSurface = Props[1]
+    assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+
+    theSurface =  600
+    # deflection absolue et binaire
+    model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False,True)
+
+    # Check results
+    test_stl_1 = geompy.ImportSTL(theFile)
+    Props = geompy.BasicProperties(test_stl_1)
+    print("\nBasic Properties:")
+    print(" Wires length: ", Props[0])
+    print(" Surface area: ", Props[1])
+    print(" Volume      : ", Props[2])
+
+    aRefSurface = theSurface
+    aResSurface = Props[1]
+    assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+
+    model.end()
+
+if __name__ == '__main__':
+    with TemporaryDirectory() as tmp_dir:
+        aRealSurface = 0.00192878
+        #=========================================================================
+        # Export a shape into STL
+        #=========================================================================
+        testExportSTL(os.path.join(tmp_dir, "export.stl"), 10 ** -5, True)
+        #=========================================================================
+        # End of test
+        #=========================================================================
diff --git a/src/ConnectorAPI/Test/TestImportSTEP.py b/src/ConnectorAPI/Test/TestImportSTEP.py
new file mode 100644 (file)
index 0000000..f6094c1
--- /dev/null
@@ -0,0 +1,124 @@
+# Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+      TestImportStep.py
+      Unit test of ExchangePlugin_ImportFeature class for STEP 
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+import salome
+
+import os
+import math
+from tempfile import TemporaryDirectory
+
+import GEOM
+
+from ModelAPI import *
+
+from salome.shaper import model
+
+from salome.geom import geomBuilder
+
+from GeomAPI import GeomAPI_Shape
+
+from GeomAlgoAPI import *
+
+__updated__ = "2015-05-22"
+
+salome.salome_init(1)
+geompy = geomBuilder.New()
+
+#=========================================================================
+# Help functions
+#=========================================================================
+def removeFile(theFileName):
+    try: os.remove(theFileName)
+    except OSError: pass
+    assert not os.path.exists(theFileName), \
+            "Can not remove file {0}".format(theFileName)
+
+#=========================================================================
+# test Import STEP 
+#=========================================================================
+def testImportSTEP():
+
+    model.begin()
+    partSet = model.moduleDocument()
+    Part_1 = model.addPart(partSet)
+    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)
+
+    model.do()
+
+    # Check results
+    Import_1_Feature = Import_1.feature()
+    assert Import_1_Feature.error() == ''
+    assert Import_1_Feature.name() == "black_and_white"
+    assert len(Import_1_Feature.results()) == 1
+    model.testNbSubShapes(Import_1, GeomAPI_Shape.SOLID, [2])
+
+    aCompositeFeature = featureToCompositeFeature(Import_1_Feature)
+    assert aCompositeFeature.numberOfSubs(False) == 2
+
+    aFeature1 = aCompositeFeature.subFeature(0, False)
+    assert aFeature1.getKind() == "Group"
+    assert aFeature1.name() == "Color_1"
+
+    aSelectionList = aFeature1.selectionList("group_list")
+    assert aSelectionList.size() == 1
+
+    aFeature1 = aCompositeFeature.subFeature(1, False)
+    assert aFeature1.getKind() == "Group"
+    assert aFeature1.name() == "Color_2"
+
+    aSelectionList = aFeature1.selectionList("group_list")
+    assert aSelectionList.size() == 1
+
+    aFeature1 = aCompositeFeature.subFeature(2, False)
+    assert aFeature1.getKind() == "Group"
+    assert aFeature1.name() == "Material_black"
+
+    aSelectionList = aFeature1.selectionList("group_list")
+    assert aSelectionList.size() == 1
+
+
+    aFeature1 = aCompositeFeature.subFeature(3, False)
+    assert aFeature1.getKind() == "Group"
+    assert aFeature1.name() == "Material_white"
+
+    aSelectionList = aFeature1.selectionList("group_list")
+    assert aSelectionList.size() == 1
+
+    model.end()
+
+if __name__ == '__main__':
+    with TemporaryDirectory() as tmp_dir:
+        #=========================================================================
+        # Export a shape into STL
+        #=========================================================================
+        testImportSTEP()
+        #=========================================================================
+        # End of test
+        #=========================================================================
index bdf5bcb345ffd454bd8bde502f7e3765f6bacb81..b61f22ce9a20a675cce9f89aa4cca82e82da9b13 100644 (file)
@@ -33,12 +33,14 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
   ModelAPI
   ModelHighAPI
+  GeomAlgoAPI
 )
 
 INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/Events
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+  ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
 )
 
 # Plugin headers dependency
index 000e178abdc874dff99814310bae3a905abbb4c6..4e9b4b9c3a179b7483b33ff121301d5f3690df0e 100644 (file)
@@ -53,6 +53,51 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>&
   apply(); // finish operation to make sure the export is done on the current state of the history
 }
 
+// Constructor with values for STL of selected result export.
+ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                       const std::string & theFilePath,
+                                       const ModelHighAPI_Selection& theSelectedShape,
+                                       double aDeflectionRelative,
+                                       double aDeflectionAbsolute,
+                                       const bool anIsRelative, 
+                                       const bool anIsASCII)
+  : ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+  fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID()));
+  fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID()));
+   
+  if (anIsRelative) {
+    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), 
+      theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
+    fillAttribute(aDeflectionRelative, 
+      theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) ); 
+  }
+  else {
+    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), 
+      theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
+    fillAttribute(aDeflectionAbsolute, 
+      theFeature->real(ExchangePlugin_ExportFeature::STL_ABSOLUTE()) );
+  }
+
+  if(anIsASCII){
+    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(), 
+      theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE()));
+  }
+  else
+  {
+    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY(), 
+      theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE()));
+  }
+  
+  fillAttribute(theSelectedShape,theFeature->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED()));
+  fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID()));
+  execute();
+  apply(); // finish operation to make sure the export is done on the current state of the history
+}
+
+
+
 ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::string & theFilePath, const ModelHighAPI_Selection& theResult,
   const std::string & theAuthor, const std::string & theGeometryName)
@@ -74,6 +119,7 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>&
 }
 
 
+
 /// Constructor with values for export in other formats than XAO.
 ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                               const std::string & theFilePath,
@@ -144,6 +190,33 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const
       theDumper << ", '" << theGeometryName << "'";
     theDumper << ")" << std::endl;
   }
+  else if (exportType == "STL") {
+    std::string aTmpSTLFile =
+                aBase->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value();
+    correctSeparators(aTmpSTLFile);
+    theDumper << "exportToSTL(" << aDocName << ", '" << aTmpSTLFile << "'" ;
+    AttributeSelectionPtr aShapeSelected =
+      aBase->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED());
+
+    theDumper<<","<< aShapeSelected;
+    
+    theDumper <<","<<  stlabsolute() <<","<< stlrelative();
+
+    if (stldeflectionType()->value() == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()) {
+      theDumper <<","<< "True";
+    }
+    else {
+      theDumper <<","<< "False";
+    }
+    
+    if (stlfileType()->value() == ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY()) {
+      theDumper << "False";
+    }
+    else {
+      theDumper <<  "True";
+    }
+    theDumper << ")" << std::endl;
+  }
   else {
     std::string aFilePath = aBase->string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->value();
     correctSeparators(aFilePath);
@@ -179,6 +252,27 @@ ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
   return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theAuthor, theGeometryName));
 }
 
+ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
+      const std::string & theFilePath,
+      const ModelHighAPI_Selection& theSelectedShape,
+      double  aDeflectionRelative,
+      double  aDeflectionAbsolute,
+      const bool anIsRelative, 
+      const bool anIsASCII)
+{
+  apply(); // finish previous operation to make sure all previous operations are done
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(ExchangePlugin_ExportFeature::ID());
+
+  return ExportPtr(new ExchangeAPI_Export(aFeature,
+                                          theFilePath,
+                                          theSelectedShape,
+                                          aDeflectionRelative,
+                                          aDeflectionAbsolute,
+                                          anIsRelative,
+                                          anIsASCII));                                    
+}
+
 ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
   const std::string & theFilePath, const ModelHighAPI_Selection& theSelectedShape,
   const std::string & /*theAuthor*/, const std::string & /*theGeometryName*/)
index 24211c9fa7d154b784ed2cc7fe2ca4541d8f1510..d867da1bff66feaacdbbcc285e2b00458078122d 100644 (file)
@@ -51,6 +51,16 @@ public:
                               const std::string & theFilePath,
                               const std::string & theAuthor = std::string(),
                               const std::string & theGeometryName = std::string());
+  
+  /// Constructor with values for STL of selected result export.
+  EXCHANGEAPI_EXPORT
+    explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                const std::string & theFilePath,
+                                const ModelHighAPI_Selection& theSelectedShape,
+                                double  aDeflectionRelative ,
+                                double  aDeflectionAbsolute,
+                                const bool anIsRelative, 
+                                const bool anIsASCII);
 
   /// Constructor with values for XAO of selected result export.
   EXCHANGEAPI_EXPORT
@@ -71,7 +81,7 @@ public:
   EXCHANGEAPI_EXPORT
   virtual ~ExchangeAPI_Export();
 
-  INTERFACE_7(ExchangePlugin_ExportFeature::ID(),
+  INTERFACE_15(ExchangePlugin_ExportFeature::ID(),
              exportType, ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(),
              ModelAPI_AttributeString, /** ExportType */,
              filePath, ExchangePlugin_ExportFeature::FILE_PATH_ID(),
@@ -85,7 +95,23 @@ public:
              xaoAuthor, ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(),
              ModelAPI_AttributeString, /** xao author */,
              xaoGeometryName, ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
-             ModelAPI_AttributeString, /** xao geometry name */)
+             ModelAPI_AttributeString, /** xao geometry name */,
+             stlFilePath, ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
+             ModelAPI_AttributeString, /** stl_file_path */,
+             stlobjectselected, ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(),
+             ModelAPI_AttributeSelection, /** Object selected to export in stl file*/,
+             stldeflectionType, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
+             ModelAPI_AttributeString, /** Type of the defelection */,
+             stlrelative, ExchangePlugin_ExportFeature::STL_RELATIVE(),
+             ModelAPI_AttributeDouble, /** Relative*/,
+             stlabsolute, ExchangePlugin_ExportFeature::STL_ABSOLUTE(),
+             ModelAPI_AttributeDouble, /** Absolute */,
+             stlfileType, ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
+             ModelAPI_AttributeString, /** Type of the stl file*/,
+             stldeflectionTypeabsolute, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(),
+             ModelAPI_AttributeString, /** Type of the defelection */,
+             stldeflectionTyperelative, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(),
+             ModelAPI_AttributeString, /** Type of the defelection */)
 
   /// Dump wrapped feature
   EXCHANGEAPI_EXPORT
@@ -113,6 +139,18 @@ ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
                  const std::string & theAuthor = std::string(),
                  const std::string & theGeometryName = std::string());
 
+/**\ingroup CPPHighAPI
+ * \brief Exports to STL file the result of the current document
+ */
+EXCHANGEAPI_EXPORT
+ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
+      const std::string & theFilePath,
+      const ModelHighAPI_Selection& theSelectedShape,
+      double  aDeflectionRelative,
+      double  aDeflectionAbsolute,
+      const bool anIsRelative, 
+      const bool anIsASCII);
+
 /**\ingroup CPPHighAPI
 * \brief Exports to XAO file the selected result with groups parts related to it only.
 */
index b1a6c832d0cee6027f99b2ae059de409be245b16..d5d7ea2a98206757dbdcfb2793f0e2ede05d1c05 100644 (file)
@@ -28,6 +28,8 @@
 #include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
+#include <GeomAlgoAPI_Tools.h>
+
 //--------------------------------------------------------------------------------------
 #include <algorithm>
 
@@ -47,16 +49,43 @@ ExchangeAPI_Import::ExchangeAPI_Import(
     setFilePath(theFilePath);
 }
 
+ExchangeAPI_Import::ExchangeAPI_Import(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::string & theFilePath,
+    const bool  anScalInterUnits,
+    const bool  anMaterials,
+    const bool  anColor)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize())
+    setParameters(theFilePath,anScalInterUnits,anMaterials,anColor);
+}
+
 ExchangeAPI_Import::~ExchangeAPI_Import()
 {
 
 }
 
+//--------------------------------------------------------------------------------------
+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()));
+  execute();
+}
+
 //--------------------------------------------------------------------------------------
 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
 {
   fillAttribute(theFilePath, myfilePath);
-
+  std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath);
+  fillAttribute(anExtension, feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()));
   execute();
 }
 
@@ -66,7 +95,16 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
   FeaturePtr aBase = feature();
   std::string aPartName = theDumper.name(aBase->document());
 
-  std::string aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value();
+  AttributeStringPtr aImportTypeAttr = aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+  std::string aFormat = aImportTypeAttr->value();
+  std::string aFilePath;
+  if (aFormat == "STEP" || aFormat == "STP")
+  {
+    aFilePath = aBase->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID())->value();
+  }else{
+    aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value();
+  }
+
   std::string aFrom = "\\";
   std::string aTo = "\\\\";
   for(std::size_t aPos = aFilePath.find(aFrom);
@@ -75,9 +113,19 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
     aFilePath.replace(aPos, aFrom.size(), aTo);
     aPos += aTo.size();
   }
-
-  theDumper << aBase << " = model.addImport(" << aPartName << ", \""
+  std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
+  if( anExtension == "STP" || anExtension == "STEP"){
+      theDumper << aBase << " = model.addImportStep(" << aPartName << ", \""
+                << aFilePath << "\"" ;
+
+      theDumper << ", " << scalinterunits()->value() 
+                << ", " << materials()->value()
+                << ", " << colors()->value() << ")"<< std::endl;
+  }else{
+      theDumper << aBase << " = model.addImport(" << aPartName << ", \""
             << aFilePath << "\")" << std::endl;
+  }
+
   // to make import have results
   theDumper << "model.do()" << std::endl;
 
@@ -102,6 +150,18 @@ ImportPtr addImport(
   return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath));
 }
 
+ImportPtr addImportStep(
+    const std::shared_ptr<ModelAPI_Document> & thePart,
+    const std::string & theFilePath,
+    const bool  anScalInterUnits,
+    const bool  anMaterials,
+    const bool  anColor )
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Import::ID());
+  return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath,
+                                          anScalInterUnits, anMaterials, anColor));
+}
+
 void importPart(const std::shared_ptr<ModelAPI_Document> & thePart,
                 const std::string & theFilePath,
                 const ModelHighAPI_Reference & theAfterThis)
index f38db9bbba537c85166dbb7494e83f8461e54094..d95a453895a69fab6d627c18f79e17493085cbc6 100644 (file)
@@ -46,18 +46,43 @@ public:
   EXCHANGEAPI_EXPORT
   ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
                      const std::string & theFilePath);
+
+  /// Constructor with values for Step file
+  EXCHANGEAPI_EXPORT
+  ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                     const std::string & theFilePath,
+                     const bool  anScalInterUnits,
+                     const bool  anMaterials,
+                     const bool  anColor);
+                     
   /// Destructor
   EXCHANGEAPI_EXPORT
   virtual ~ExchangeAPI_Import();
 
-  INTERFACE_1(ExchangePlugin_ImportFeature::ID(),
+  INTERFACE_6(ExchangePlugin_ImportFeature::ID(),
               filePath, ExchangePlugin_ImportFeature::FILE_PATH_ID(),
-              ModelAPI_AttributeString, /** File path */
+              ModelAPI_AttributeString, /** File path */,
+              stepimporttype, ExchangePlugin_ImportFeature::IMPORT_TYPE_ID(),
+              ModelAPI_AttributeString, /**import type */,
+              stepfilePath, ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID(),
+              ModelAPI_AttributeString, /**step File path */,
+              scalinterunits, ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID(),
+              ModelAPI_AttributeBoolean, /** Scale internationals units */,
+              materials, ExchangePlugin_ImportFeature::STEP_MATERIALS_ID(),
+              ModelAPI_AttributeBoolean, /** Materials */,
+              colors, ExchangePlugin_ImportFeature::STEP_COLORS_ID(),
+              ModelAPI_AttributeBoolean, /** Colors */
   )
 
   /// Set point values
   EXCHANGEAPI_EXPORT
   void setFilePath(const std::string & theFilePath);
+  
+  EXCHANGEAPI_EXPORT
+  void setParameters(const std::string & theFilePath, 
+                     const bool  anScalInterUnits,
+                     const bool  anMaterials,
+                     const bool  anColor);
 
   /// Dump wrapped feature
   EXCHANGEAPI_EXPORT
@@ -74,6 +99,16 @@ EXCHANGEAPI_EXPORT
 ImportPtr addImport(const std::shared_ptr<ModelAPI_Document> & thePart,
                     const std::string & theFilePath);
 
+/**\ingroup CPPHighAPI
+ * \brief Create Import Step feature
+ */
+EXCHANGEAPI_EXPORT
+ImportPtr addImportStep(const std::shared_ptr<ModelAPI_Document> & thePart,
+                        const std::string & theFilePath,
+                        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 67880c8e64ff524ad3394591e577cbc9ae9a4117..3df98beceac4beaa7da4148038a009671167d085 100644 (file)
@@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/XAO
                     ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin
                     ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+                    ${OpenCASCADE_INCLUDE_DIR}
 )
 
 SET(PROJECT_HEADERS
index d898a08e5dd8895c829986908eed8143629eae56..6a8f36cb1792a0fc7ee3e13bcf1bd6ae4a08d8dc 100644 (file)
@@ -27,6 +27,7 @@
 #include <ostream>
 #endif
 
+
 #include <Config_Common.h>
 #include <Config_PropManager.h>
 
@@ -34,6 +35,7 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_IGESExport.h>
 #include <GeomAlgoAPI_STEPExport.h>
+#include <GeomAlgoAPI_STLExport.h>
 #include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_XAOExport.h>
 
@@ -48,6 +50,7 @@
 #include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeTables.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
@@ -68,6 +71,8 @@
 
 #include <ExchangePlugin_Tools.h>
 
+#include <ModelAPI_ResultConstruction.h>
+
 ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature()
 {
 }
@@ -98,9 +103,27 @@ void ExchangePlugin_ExportFeature::initAttributes()
     ModelAPI_AttributeString::typeId());
   data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
     ModelAPI_AttributeSelectionList::typeId());
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
+    ModelAPI_AttributeString::typeId());
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), 
+    ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
+   ModelAPI_AttributeString::typeId());
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(), 
+    ModelAPI_AttributeDouble::typeId());
+   
+  double defelection = Config_PropManager::real("Visualization", "body_deflection");
+  real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
+
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(), 
+    ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
+   ModelAPI_AttributeString::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
     ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
+    ExchangePlugin_ExportFeature::STL_FILE_PATH_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
     ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
@@ -128,6 +151,11 @@ void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID)
     string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
       string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value());
   }
+  else if (theID == STL_FILE_PATH_ID()) {
+    string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
+      string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value());
+  }
+
 }
 
 /*
@@ -170,6 +198,9 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
   if (aFormatName == "XAO") {
     exportXAO(theFileName);
     return;
+  }else if (aFormatName == "STL") {
+    exportSTL(theFileName);
+    return;
   }
 
   // make shape for export from selected shapes
@@ -316,6 +347,49 @@ static bool isInResults(AttributeSelectionListPtr theSelection,
   return false;
 }
 
+void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName)
+{
+  // Get shape.
+  AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED());
+  GeomShapePtr aShape = aSelection->value();
+  if (!aShape.get()) {
+    aShape = aSelection->context()->shape();
+  }
+
+  // Get relative value and percent flag.
+  double aValue;
+  bool anIsRelative = false;
+  bool anIsASCII = false;
+
+  if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) {
+    aValue = real(STL_RELATIVE())->value();
+    anIsRelative = true;
+  } else {
+    aValue = real(STL_ABSOLUTE())->value();
+  }
+
+  if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) {
+    anIsASCII = true;
+  }            
+  // Perform the export
+  std::string anError;
+  bool aResult = false;
+
+  aResult = STLExport(theFileName,
+                      "STL",
+                      aShape,
+                      aValue,
+                      anIsRelative, 
+                      anIsASCII,
+                      anError);
+
+  if (!aResult || !anError.empty()) {
+    setError("An error occurred while exporting " + theFileName + ": " + anError);
+    return;
+  }
+}
+
+
 void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
 {
   try {
index 1067d99af198ae4e40eb110cb456af766e0fa68c..bc975ea5b7de9c76f8e22458a706fb66301e7bbc 100644 (file)
@@ -60,6 +60,66 @@ public:
     static const std::string MY_XAO_FILE_PATH_ID("xao_file_path");
     return MY_XAO_FILE_PATH_ID;
   }
+  /// attribute name of stl file path
+  inline static const std::string& STL_FILE_PATH_ID()
+  {
+    static const std::string MY_STL_FILE_PATH_ID("stl_file_path");
+    return MY_STL_FILE_PATH_ID;
+  }
+  /// Attribute name for selected object to export in stl file path.
+  inline static const std::string& STL_OBJECT_SELECTED()
+  {
+    static const std::string ATTR_ID("stl_object_selected");
+    return ATTR_ID;
+  }
+  /// Attribute name for deflection type.
+  inline static const std::string& STL_DEFLECTION_TYPE()
+  {
+    static const std::string ATTR_ID("stl_deflection_type");
+    return ATTR_ID;
+  }
+  /// Attribute name for deflection type relative.
+  inline static const std::string& STL_DEFLECTION_TYPE_RELATIVE()
+  {
+    static const std::string ATTR_ID("stl_deflection_type_relative");
+    return ATTR_ID;
+  }
+  /// Attribute name for deflection type absolute.
+  inline static const std::string& STL_DEFLECTION_TYPE_ABSOLUTE()
+  {
+    static const std::string ATTR_ID("stl_deflection_type_absolute");
+    return ATTR_ID;
+  }
+  /// Attribute name for relative.
+  inline static const std::string& STL_RELATIVE()
+  {
+    static const std::string ATTR_ID("stl_relative");
+    return ATTR_ID;
+  }
+  /// Attribute name for absolute.
+  inline static const std::string& STL_ABSOLUTE()
+  {
+    static const std::string ATTR_ID("stl_absolute");
+    return ATTR_ID;
+  }
+  /// Attribute name for stl file type.
+  inline static const std::string& STL_FILE_TYPE()
+  {
+    static const std::string ATTR_ID("stl_file_type");
+    return ATTR_ID;
+  }
+  /// Attribute name for stl file type ascii.
+  inline static const std::string& STL_FILE_TYPE_ASCII()
+  {
+    static const std::string ATTR_ID("stl_file_type_acii");
+    return ATTR_ID;
+  }
+  /// Attribute name for stl file type binary.
+  inline static const std::string& STL_FILE_TYPE_BINARY()
+  {
+    static const std::string ATTR_ID("stl_file_type_binary");
+    return ATTR_ID;
+  }
   /// attribute name of file format
   inline static const std::string& FILE_FORMAT_ID()
   {
@@ -129,6 +189,9 @@ protected:
 
   /// Performs export to XAO file
   EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName);
+
+  /// Performs export to STL file
+  EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName);
 };
 
 #endif /* EXPORT_EXPORTFEATURE_H_ */
index b5a51ff08fa248e1e6fec471595c98dd08c62bc1..304d456d56f2e717157ad259f4e10e4c3b9e214a 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeStringArray.h>
+#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Tools.h>
@@ -81,8 +82,15 @@ ExchangePlugin_Import::~ExchangePlugin_Import()
 void ExchangePlugin_Import::initAttributes()
 {
   data()->addAttribute(FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId());
   data()->addAttribute(TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId());
+  data()->addAttribute(STEP_TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId());
+  data()->addAttribute(STEP_TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId());
+  data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId());
+  data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId());
+  data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId());
 }
 
 /*
@@ -90,26 +98,61 @@ void ExchangePlugin_Import::initAttributes()
  */
 void ExchangePlugin_Import::execute()
 {
-  AttributeStringPtr aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID());
-  std::string aFilePath = aFilePathAttr->value();
-  if (aFilePath.empty()) {
-    setError("File path is empty.");
-    return;
+  AttributeStringPtr aFormatAttr =
+      this->string(ExchangePlugin_Import::IMPORT_TYPE_ID());
+  std::string aFormat = aFormatAttr->value();
+
+  AttributeStringPtr aFilePathAttr;
+  std::string aFilePath;
+  AttributeStringArrayPtr aPartsAttr;
+  AttributeIntegerPtr aTargetAttr;
+  if (aFormat == "STEP" || aFormat == "STP")
+  {
+    aFilePathAttr = string(ExchangePlugin_Import::STEP_FILE_PATH_ID());
+    aFilePath = aFilePathAttr->value();    
+    // get the document where to import
+    aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
+    aTargetAttr = integer(STEP_TARGET_PART_ID());
+  }else{
+    aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID());
+    aFilePath = aFilePathAttr->value();
+    // get the document where to import
+    aPartsAttr = stringArray(TARGET_PARTS_LIST_ID());
+    aTargetAttr = integer(TARGET_PART_ID());
   }
 
-  // get the document where to import
-  AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID());
-  AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID());
+  if (aFilePath.empty()) {
+      setError("File path is empty.");
+      return;
+  }
   SessionPtr aSession = ModelAPI_Session::get();
-  DocumentPtr aDoc =
-    findDocument(aSession->moduleDocument(),
+  DocumentPtr aDoc = findDocument(aSession->moduleDocument(),
       Locale::Convert::toWString(aPartsAttr->value(aTargetAttr->value())));
 
   if (aDoc.get()) {
     FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID());
     DataPtr aData = aImportFeature->data();
-    AttributeStringPtr aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
+    AttributeStringPtr aPathAttr;
+    if (aFormat == "STEP" || aFormat == "STP")
+    {
+      aPathAttr = aData->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID());
+    }else
+    {
+      aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_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());
+    aData->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())
+         ->setValue(boolean(ExchangePlugin_Import::STEP_COLORS_ID())->value());
+    aData->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())
+         ->setValue(boolean(ExchangePlugin_Import::STEP_SCALE_INTER_UNITS_ID())->value());
+
     aPathAttr->setValue(aFilePathAttr->value());
+    aImportTypeAttr->setValue(aFormat);
+
     aImportFeature->execute();
   }
 }
@@ -117,14 +160,31 @@ void ExchangePlugin_Import::execute()
 
 void ExchangePlugin_Import::attributeChanged(const std::string& theID)
 {
-  if (theID == FILE_PATH_ID()) {
-    AttributeStringPtr aFilePathAttr = string(FILE_PATH_ID());
-    if (aFilePathAttr->value().empty())
+  AttributeStringPtr aFilePathAttr;
+  AttributeStringArrayPtr aPartsAttr;
+  AttributeIntegerPtr aTargetAttr;
+
+  if (theID == FILE_PATH_ID() ||theID == STEP_FILE_PATH_ID() ) {
+    aFilePathAttr = string(FILE_PATH_ID());
+    if (theID == FILE_PATH_ID() && aFilePathAttr->value().empty())
       return;
+    aPartsAttr = stringArray(TARGET_PARTS_LIST_ID());
+    aTargetAttr = integer(TARGET_PART_ID());
+
+    updatePart(aPartsAttr, aTargetAttr);
 
-    AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID());
-    AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID());
+    aFilePathAttr = string(STEP_FILE_PATH_ID());
+    if (theID == STEP_FILE_PATH_ID() && aFilePathAttr->value().empty())
+      return;
 
+    aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
+    aTargetAttr = integer(STEP_TARGET_PART_ID());
+    updatePart(aPartsAttr, aTargetAttr);
+   } 
+}
+
+void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr)
+{
     // update the list of target parts
     SessionPtr aSession = ModelAPI_Session::get();
     DocumentPtr aDoc = document();
@@ -159,5 +219,4 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID)
         aTargetAttr->setValue(0);
       }
     }
-  }
 }
index c09b3ebab9b353b758199118d8768ace211621f9..38d3e05e7b2e2dc48a87b9047c58f44c4decacb1 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeStringArray.h>
 
 #include <map>
 
@@ -43,6 +45,12 @@ class ExchangePlugin_Import : public ModelAPI_Feature
     static const std::string MY_IMPORT_ID("ImportMacro");
     return MY_IMPORT_ID;
   }
+  /// Feature kind
+  inline static const std::string& IMPORT_TYPE_ID()
+  {
+    static const std::string MY_IMPORT_TYPE_ID("ImportType");
+    return MY_IMPORT_TYPE_ID;
+  }
   /// attribute name of file path
   inline static const std::string& FILE_PATH_ID()
   {
@@ -61,6 +69,42 @@ class ExchangePlugin_Import : public ModelAPI_Feature
     static const std::string MY_TARGET_PARTS_LIST_ID("target_parts_list");
     return MY_TARGET_PARTS_LIST_ID;
   }
+  /// attribute name of step file path
+  inline static const std::string& STEP_FILE_PATH_ID()
+  {
+    static const std::string MY_STEP_FILE_PATH_ID("step_file_path");
+    return MY_STEP_FILE_PATH_ID;
+  }
+  /// attribute name of step target part
+  inline static const std::string& STEP_TARGET_PART_ID()
+  {
+    static const std::string MY_STEP_TARGET_PART_ID("step_target_part");
+    return MY_STEP_TARGET_PART_ID;
+  }
+  /// attribute name of list ofstep target parts
+  inline static const std::string& STEP_TARGET_PARTS_LIST_ID()
+  {
+    static const std::string MY_STEP_TARGET_PARTS_LIST_ID("step_target_parts_list");
+    return MY_STEP_TARGET_PARTS_LIST_ID;
+  }
+  /// attribute name of step Scale to International System Units
+  inline static const std::string& STEP_SCALE_INTER_UNITS_ID()
+  {
+    static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units");
+    return MY_STEP_SCALE_INTER_UNITS_ID;
+  }
+  /// attribute name of step materiels
+  inline static const std::string& STEP_MATERIALS_ID()
+  {
+    static const std::string MY_STEP_MATERIALS_ID("step_materials");
+    return MY_STEP_MATERIALS_ID;
+  }
+  /// attribute name of step colors
+  inline static const std::string& STEP_COLORS_ID()
+  {
+    static const std::string MY_STEP_COLORS_ID("step_colours");
+    return MY_STEP_COLORS_ID;
+  }
   /// Default constructor
   EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import();
   /// Default destructor
@@ -79,6 +123,9 @@ class ExchangePlugin_Import : public ModelAPI_Feature
   /// \param theID identifier of changed attribute
   EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  EXCHANGEPLUGIN_EXPORT
+  void updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr);
+
   /// Computes or recomputes the results
   EXCHANGEPLUGIN_EXPORT virtual void execute();
 
index ade0a3115974fde390294daf839f71047207af17..402b660e9721b7aa56b5d7e36938a24b0b4b7805 100644 (file)
@@ -32,6 +32,7 @@
 #include <GeomAlgoAPI_XAOImport.h>
 
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_Face.h>
 #include <GeomAPI_ShapeExplorer.h>
 
 #include <Locale_Convert.h>
@@ -42,6 +43,8 @@
 #include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeTables.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 
 #include <ExchangePlugin_Tools.h>
 
+#include <TopExp_Explorer.hxx>
+#include <OSD_Exception.hxx>
+
+
 ExchangePlugin_ImportFeature::ExchangePlugin_ImportFeature()
 {
 }
@@ -77,10 +84,16 @@ void ExchangePlugin_ImportFeature::initAttributes()
   data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(),
                        ModelAPI_AttributeString::typeId());
   AttributePtr aFeaturesAttribute =
-    data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(),
+  data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(),
                          ModelAPI_AttributeRefList::typeId());
-  aFeaturesAttribute->setIsArgument(false);
+  data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId());
+  data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId());
+  data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId());
 
+  aFeaturesAttribute->setIsArgument(false);
+  
   ModelAPI_Session::get()->validators()->registerNotObligatory(
       getKind(), ExchangePlugin_ImportFeature::FEATURES_ID());
 }
@@ -90,7 +103,15 @@ void ExchangePlugin_ImportFeature::initAttributes()
  */
 void ExchangePlugin_ImportFeature::execute()
 {
-  AttributeStringPtr aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
+  AttributeStringPtr aImportTypeAttr = string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+  std::string aFormat = aImportTypeAttr->value();
+  AttributeStringPtr aFilePathAttr;
+  if (aFormat == "STEP" || aFormat == "STP")
+  {
+    aFilePathAttr = string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID());
+  }else{
+    aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
+  }
   std::string aFilePath = aFilePathAttr->value();
   if (aFilePath.empty()) {
     setError("File path is empty.");
@@ -101,7 +122,7 @@ void ExchangePlugin_ImportFeature::execute()
 }
 
 std::shared_ptr<ModelAPI_ResultBody> ExchangePlugin_ImportFeature::createResultBody(
-    std::shared_ptr<GeomAPI_Shape> aGeomShape)
+                        std::shared_ptr<GeomAPI_Shape> aGeomShape)
 {
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
   //LoadNamingDS of the imported shape
@@ -122,10 +143,47 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   // Perform the import
   std::string anError;
   std::shared_ptr<GeomAPI_Shape> aGeomShape;
+
+  std::map< std::wstring, std::list<std::wstring>> theMaterialShape;
+
+  std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
+  data()->setName(Locale::Convert::toWString(anObjectName));
+
+  ResultBodyPtr result = document()->createBody(data());
+
+  bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_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") {
-    aGeomShape = STEPImport(theFileName, anExtension, anError);
+    bool anScalInterUnits = boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
+    
+
+    try{
+
+      result->clearShapeNameAndColor();
+      // Process groups/fields
+      std::shared_ptr<ModelAPI_AttributeRefList> aRefListOfGroups =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(FEATURES_ID()));
+
+      // Remove previous groups/fields stored in RefList
+      std::list<ObjectPtr> anGroupList = aRefListOfGroups->list();
+      std::list<ObjectPtr>::iterator anGroupIt = anGroupList.begin();
+      for (; anGroupIt != anGroupList.end(); ++anGroupIt) {
+        std::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_Feature::feature(*anGroupIt);
+        if (aFeature)
+        document()->removeFeature(aFeature);
+      }
+      
+      aGeomShape = STEPImportAttributs(theFileName, result, anScalInterUnits,
+                                       anMaterialsGroupSelected, anColorGroupSelected,theMaterialShape,anError);
+      
+    }
+    catch (OSD_Exception& e) {
+        //Try to load STEP file without colors...
+        aGeomShape = STEPImport(theFileName, anExtension,anScalInterUnits,anError);
+    }
   } else if (anExtension == "IGES" || anExtension == "IGS") {
     aGeomShape = IGESImport(theFileName, anExtension, anError);
   } else {
@@ -139,12 +197,138 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   }
 
   // Pass the results into the model
-  std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
-  data()->setName(Locale::Convert::toWString(anObjectName));
 
-  setResult(createResultBody(aGeomShape));
+  loadNamingDS(aGeomShape, result);
+
+  // create color group
+  if (anColorGroupSelected) 
+  {
+    setColorGroups(result);
+  }
+
+  // create Materiel group
+  if (anMaterialsGroupSelected){
+    setMaterielGroup(result,theMaterialShape);
+  }
+
+  setResult(result); 
+
 }
 
+void ExchangePlugin_ImportFeature::setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody)
+{
+  std::vector<int> aColor;
+  int indice = 1; 
+  std::list< std::vector<int> > aColorsRead; 
+
+
+  ModelAPI_Tools::getColor(theResultBody, aColor);
+  if (!aColor.empty() ){
+    std::wstringstream colorName;
+    colorName<<L"Color_"<<indice;
+    setColorGroup( theResultBody, aColor, colorName.str());
+    indice++;
+    aColorsRead.push_back(aColor);
+  }
+
+  std::list<ResultPtr> allRes;
+  ModelAPI_Tools::allSubs(theResultBody, allRes);
+  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 colorName;
+            colorName<<L"Color_"<<indice;
+            setColorGroup( theResultBody, aColor, colorName.str() ); 
+            indice++;
+            aColorsRead.push_back(aColor);
+        }
+    }
+  }
+}
+
+void ExchangePlugin_ImportFeature::setColorGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                                 std::vector<int> &theColor,
+                                                 const std::wstring& theName )
+{
+  std::vector<int> aColor;
+  std::shared_ptr<ModelAPI_Feature> aGroupFeature = addFeature("Group");
+
+   // group name
+  aGroupFeature->data()->setName(theName);
+
+  // fill selection
+  AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+
+  ModelAPI_Tools::getColor(theResultBody, aColor);
+  if (!aColor.empty() ){
+    if( aColor == theColor ) {
+      GeomShapePtr aShape = theResultBody->shape();
+      aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+      aSelectionList->append(theResultBody,aShape);
+    }  
+  }
+  // add element with the same color 
+  std::list<ResultPtr> allRes;
+  ModelAPI_Tools::allSubs(theResultBody, allRes);
+  for(std::list<ResultPtr>::iterator aRes = allRes.begin(); 
+      aRes != allRes.end(); ++aRes) {
+    ModelAPI_Tools::getColor(*aRes, aColor);
+    GeomShapePtr aShape = (*aRes)->shape();
+
+    if (!aColor.empty() ){
+      if( aRes->get() &&  aColor == theColor ) {
+          aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+          aSelectionList->append(theResultBody,aShape);
+      }
+    }
+  }
+
+  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)
+{
+  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);
+          break;
+        }
+      }
+    }
+    if (aSelectionList->size() == 0){
+      document()->removeFeature(aGroupFeature);
+    }
+  }
+} 
+
+
+
 void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
 {
   try {
@@ -415,7 +599,6 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
 {
   //load result
   theResultBody->store(theGeomShape);
-
   std::string aNameMS = "Shape";
   theResultBody->loadFirstLevel(theGeomShape, aNameMS);
 }
index c087af2ab9e21284e96dad63ca8a4ff6da4bc5aa..2875d83abf4cc007cc4c9da019320e378682699c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
 
 #include <map>
 
@@ -43,18 +44,48 @@ class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
     static const std::string MY_IMPORT_ID("Import");
     return MY_IMPORT_ID;
   }
+  /// Feature kind
+  inline static const std::string& IMPORT_TYPE_ID()
+  {
+    static const std::string MY_IMPORT_TYPE_ID("ImportType");
+    return MY_IMPORT_TYPE_ID;
+  }
   /// attribute name of file path
   inline static const std::string& FILE_PATH_ID()
   {
     static const std::string MY_FILE_PATH_ID("file_path");
     return MY_FILE_PATH_ID;
   }
+  /// attribute name of file path
+  inline static const std::string& STEP_FILE_PATH_ID()
+  {
+    static const std::string MY_STEP_FILE_PATH_ID("step_file_path");
+    return MY_STEP_FILE_PATH_ID;
+  }
   /// All features (list of references)
   inline static const std::string& FEATURES_ID()
   {
     static const std::string MY_FEATURES_ID("Features");
     return MY_FEATURES_ID;
   }
+  /// attribute name of step Scale to International System Units
+  inline static const std::string& STEP_SCALE_INTER_UNITS_ID()
+  {
+    static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units");
+    return MY_STEP_SCALE_INTER_UNITS_ID;
+  }
+  /// attribute name of step materiels
+  inline static const std::string& STEP_MATERIALS_ID()
+  {
+    static const std::string MY_STEP_MATERIALS_ID("step_materials");
+    return MY_STEP_MATERIALS_ID;
+  }
+  /// attribute name of step colors
+  inline static const std::string& STEP_COLORS_ID()
+  {
+    static const std::string MY_STEP_COLORS_ID("step_colours");
+    return MY_STEP_COLORS_ID;
+  }
   /// Default constructor
   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
   /// Default destructor
@@ -108,6 +139,19 @@ 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 
+  void setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody);
+
+  // 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
+  void setMaterielGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                        std::map< std::wstring, std::list<std::wstring>> &theMaterialShape);
+
 };
 
 #endif /* IMPORT_IMPORTFEATURE_H_ */
index 3e4061b1efb7e0646c9def66f02abfd314d487a9..110053a1d346ca8ad671f596bbdff6134f0b117b 100644 (file)
       <source>XAO</source>
       <translation>XAO</translation>
     </message>
+    <message>
+      <source>STL</source>
+      <translation>STL</translation>
+    </message>
   </context>
   <context>
     <name>Export:file_path</name>
       <translation>Veuillez saisir le nom de la géométrie</translation>
     </message>
   </context>
+  <context>
+    <name>Export:stl_file_path</name>
+    <message>
+      <source>Export file</source>
+      <translation>Fichier d&apos;export</translation>
+    </message>
+  </context>
+  <context>
+    <name>Export:stl_file_path:ExchangePlugin_ExportFormat</name>
+    <message>
+      <source>%1 is not initialized.</source>
+      <translation>%1 n&apos;est pas initialisé.</translation>
+    </message>
+    <message>
+      <source>File name is empty.</source>
+      <translation>Le nom du fichier est vide.</translation>
+    </message>
+  </context>
+  <context>
+    <name>Export:stl_object_selected</name>
+    <message>
+      <source>Object</source>
+      <translation>Objet</translation>
+    </message>
+    <message>
+      <source>Object to export.</source>
+      <translation>Objet à exporter.</translation>
+    </message>
+  </context>
+  <context>
+    <name>Export:stl_file_type</name> 
+    <message>
+      <source>File type</source>
+      <translation>type du fichier</translation>
+    </message>
+    <message>
+      <source>Binary</source>
+      <translation>Binaire</translation>
+    </message>
+    <message>
+      <source>ASCII</source>
+      <translation>ASCII</translation>
+    </message>
+  </context>
+  <context>
+    <name>Export:Deflection</name>
+    <message>
+      <source>Deflection</source>
+      <translation>Déflection</translation>
+    </message>
+    <message>
+      <source>Relative</source>
+      <translation>Relative</translation>
+    </message>
+    <message>
+      <source>Relative value.</source>
+      <translation>Valeur relative</translation>
+    </message>
+    <message>
+      <source>Calculate by size of shape</source>
+      <translation>Calcul par rapport à la taille de la shape</translation>
+    </message>
+    <message>
+      <source>Absolute</source>
+      <translation>Absolue</translation>
+    </message>
+    <message>
+      <source>Value indicate by user</source>
+      <translation>Valeur indiquée par l&apos;utilisateur</translation>
+    </message>
+    <message>
+      <source>Absolute value.</source>
+      <translation>Valeur absolue.</translation>
+    </message>
+  </context>
 
   <!-- Import -->
   <context>
index 9e134b805c32601d268fc1ce6e73a25e165e2a50..d77786ee58dd10b5d03c32907c74c23260c0f9e0 100644 (file)
                    placeholder="Please input the geometry name">
       </stringvalue>
     </case>
+    <case id="STL" title="STL">
+      <export_file_selector id="stl_file_path"
+                            type="save"
+                            title="Export file"
+                            path="">
+        <validator id="ExchangePlugin_ExportFormat"
+                   parameters="stl:STL" />
+      </export_file_selector>
+      <shape_selector id="stl_object_selected"
+                          label="Object"
+                          tooltip="Object to export."
+                          shape_types="vertices edges wires faces shells solids compsolids compounds">
+            <validator id="GeomValidators_Finite"/>
+      </shape_selector>
+      <groupbox title="Deflection">
+        <radiobox id="stl_deflection_type">
+          <radio id="stl_deflection_type_relative"
+              title="Relative"
+              tooltip="Calculate by size of shape">
+            <doublevalue id="stl_relative"
+              tooltip="Relative value."
+              min="0.0"
+              step="0.001"
+              default="0.001">
+            </doublevalue>
+          </radio>
+          <radio id="stl_deflection_type_absolute"
+              title="Absolute"
+              tooltip="Value indicate by user">
+            <doublevalue id="stl_absolute"
+              tooltip="Absolute value."
+              min="0.0"
+              max="1.0"
+              step="0.1"
+              default="0.5">
+            </doublevalue>
+          </radio>
+        </radiobox>
+      </groupbox >
+      <groupbox title="File type">
+        <radiobox id="stl_file_type">
+          <radio id="stl_file_type_binary"
+              title="Binary">
+          </radio>
+          <radio id="stl_file_type_acii"
+              title="ASCII">
+          </radio>
+        </radiobox>
+      </groupbox >
+      <!--stringvalue id="xao_author"
+                   label="Author"
+                   placeholder="Please input the author">
+      </stringvalue>
+      <stringvalue id="xao_geometry_name"
+                   label="Geometry name"
+                   placeholder="Please input the geometry name">
+      </stringvalue-->
+    </case>
   </switch>
 </source>
index 7f240ba69c9701cf2dfd59fcbdaf181bda666b8e..275ceb69b6bd113c6fe5d631875189d48d51eadf 100644 (file)
@@ -4,19 +4,70 @@
       <feature id="ImportMacro" 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>
         <choice id="target_part"
                 string_list_attribute="target_parts_list"
                 label="Import to"
                 tooltip="Select the part to import the document" />
+        </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>
+            <choice id="step_target_part"
+                string_list_attribute="step_target_parts_list"
+                label="Import to"
+                tooltip="Select the part to import the document" /> 
+            <groupbox title="STEP options">
+              <boolvalue id="step_scale_inter_units"
+                        label="Scale to International System of Units"
+                        default="true"/>
+              <groupbox title="Create groups from">
+                <boolvalue id="step_materials"
+                          label="Materials"
+                          default="false"/>
+                <boolvalue id="step_colours"
+                          label="Colours"
+                          default="false"/>
+              </groupbox>
+            </groupbox>
+          </case>
+        </switch>
       </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="">
+        <!--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>
+        </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">
+            <file_selector id="step_file_path" title="Import file" path="">
+              <validator id="ExchangePlugin_ImportFormat" parameters="STEP|STP:STEP" />
+            </file_selector>
+            <groupbox title="STEP options">
+              <boolvalue id="step_scale_inter_units"
+                        label="Scale to International System of Units"
+                        default="true"/>
+              <groupbox title="Create groups from">
+                <boolvalue id="step_materials"
+                          label="Materials"
+                          default="false"/>
+                <boolvalue id="step_colours"
+                          label="Colours"
+                          default="false"/>
+              </groupbox>
+            </groupbox>
+          </case>
+        </switch>
       </feature>
       <feature id="Export" title="Export" tooltip="Export to file" icon="icons/Exchange/export.png"
                helpfile="exportFeature.html" internal="1">
index b76fd2dc433da48ec55917f838656249d29c963a..c5c0c28de3deb44d36ee70e0fb651764ee1e2b15 100644 (file)
@@ -42,6 +42,8 @@
 %feature("kwargs") addCommon;
 %feature("kwargs") addCut;
 %feature("kwargs") addFillet;
+%feature("kwargs") addFilletMultiRadiusBypoint;
+%feature("kwargs") addFilletMultiRadiusByCurv;
 %feature("kwargs") addFuse;
 %feature("kwargs") addIntersection;
 %feature("kwargs") addMultiRotation;
index 332b5820878c9eb63c6d4ae8dddb8db63edaf8e2..0f2f5041c5316b8b2c6d0e456422725d51484782 100644 (file)
@@ -152,6 +152,41 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Featur
   }
 }
 
+
+FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection & theedgeselected,
+                                           const std::list<ModelHighAPI_Selection>& thepoint,
+                                           const std::list<ModelHighAPI_Double>& theRadius)
+  : FeaturesAPI_Fillet(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES(), mycreationMethod);
+    fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS(), mycreationMethodmulti);
+    fillAttribute(theedgeselected, edgeselected());
+    fillAttribute(thepoint, myarraypointradiusbypoint);
+    // JL_CGLB fillAttribute(theRadius, myarrayradiusbypoint);
+
+    execIfBaseNotEmpty();
+  }
+}
+
+FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection & theedgeselected,
+                                           const std::list<ModelHighAPI_Double>& thepointCurvCood,
+                                           const std::list<ModelHighAPI_Double>& theRadius)
+  : FeaturesAPI_Fillet(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES(), mycreationMethod);
+    fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_BY_CURVILEAR_ABSCISSA(), mycreationMethodmulti);
+    fillAttribute(theedgeselected, edgeselected());
+    // JL_CGLB fillAttribute(thepointCurvCood, myarraypointradiusbycurv);
+    // JL_CGLB fillAttribute(theRadius, myarrayradiusbycurv);
+
+    execIfBaseNotEmpty();
+  }
+}
+
 FeaturesAPI_Fillet2D::~FeaturesAPI_Fillet2D()
 {
 }
@@ -189,18 +224,44 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const
 
   AttributeSelectionListPtr anAttrObjects =
     aBase->selectionList(FeaturesPlugin_Fillet::OBJECT_LIST_ID());
-
-  theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrObjects;
-
-  std::string aCreationMethod = aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value();
-
-  if(aCreationMethod == FeaturesPlugin_Fillet::CREATION_METHOD_SINGLE_RADIUS()) {
-    AttributeDoublePtr anAttrRadius = aBase->real(FeaturesPlugin_Fillet::RADIUS_ID());
-    theDumper << ", " << anAttrRadius;
-  } else if(aCreationMethod == FeaturesPlugin_Fillet::CREATION_METHOD_VARYING_RADIUS()) {
-    AttributeDoublePtr anAttrRadius1 = aBase->real(FeaturesPlugin_Fillet::START_RADIUS_ID());
-    AttributeDoublePtr anAttrRadius2 = aBase->real(FeaturesPlugin_Fillet::END_RADIUS_ID());
-    theDumper << ", " << anAttrRadius1 << ", " << anAttrRadius2;
+  
+
+  if ( aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value() 
+        == FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES() )
+  {
+    AttributeSelectionPtr anAttrEdgeSelec =
+    aBase->selection(FeaturesPlugin_Fillet::EDGE_SELECTED_ID());
+
+    if( aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())->value() 
+          == FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() )
+    {        
+      /*AttributeSelectionListPtr anAttrPoint =
+          aBase->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
+      AttributeDoubleArrayPtr anAttrRadius = 
+          aBase->realArray(FeaturesPlugin_Fillet::ARRAY_RADIUS_BY_POINTS());
+      theDumper << aBase << " = model.addFilletMultiRadiusBypoint(" << aDocName << ", " << anAttrEdgeSelec;
+      theDumper << ", " << anAttrPoint << ", " << anAttrRadius;
+    }else{
+      AttributeSelectionListPtr anAttrPoint =
+          aBase->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_CURV());
+      AttributeDoubleArrayPtr anAttrRadius = 
+          aBase->realArray(FeaturesPlugin_Fillet::ARRAY_RADIUS_BY_CURV());
+      theDumper << aBase << " = model.addFilletMultiRadiusByCurv(" << aDocName << ", " << anAttrEdgeSelec;
+      theDumper << ", " << anAttrPoint << ", " << anAttrRadius;*/
+    }
+  }else
+  {  theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrObjects;
+
+    std::string aCreationMethod = aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value();
+
+    if(aCreationMethod == FeaturesPlugin_Fillet::CREATION_METHOD_SINGLE_RADIUS()) {
+      AttributeDoublePtr anAttrRadius = aBase->real(FeaturesPlugin_Fillet::RADIUS_ID());
+      theDumper << ", " << anAttrRadius;
+    } else if(aCreationMethod == FeaturesPlugin_Fillet::CREATION_METHOD_VARYING_RADIUS()) {
+      AttributeDoublePtr anAttrRadius1 = aBase->real(FeaturesPlugin_Fillet::START_RADIUS_ID());
+      AttributeDoublePtr anAttrRadius2 = aBase->real(FeaturesPlugin_Fillet::END_RADIUS_ID());
+      theDumper << ", " << anAttrRadius1 << ", " << anAttrRadius2;
+    }
   }
 
   if (!aBase->data()->version().empty())
@@ -241,3 +302,39 @@ FilletPtr addFillet(const std::shared_ptr<ModelAPI_Document>& thePart,
     aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theBaseObjects, theRadius1, theRadius2));
   return aFillet;
 }
+
+FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const ModelHighAPI_Selection & theedgeselected,
+                    const std::list<ModelHighAPI_Selection>& thepoint,
+                    const std::list<ModelHighAPI_Double>& theRadius,
+                    const bool keepSubResults)
+{
+
+  FeaturePtr aFeature = thePart->addFeature(FeaturesAPI_Fillet2D::ID());
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  FilletPtr aFillet;
+
+  aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theedgeselected, thepoint, theRadius));
+
+  return aFillet;
+}
+
+FilletPtr addFilletMultiRadiusByCurv(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const ModelHighAPI_Selection & theedgeselected,
+                    const std::list<ModelHighAPI_Double>& thepointCurvCood,
+                    const std::list<ModelHighAPI_Double>& theRadius,
+                    const bool keepSubResults)
+{
+
+  FeaturePtr aFeature = thePart->addFeature(FeaturesAPI_Fillet2D::ID());
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  FilletPtr aFillet;
+
+  aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theedgeselected, thepointCurvCood, theRadius));
+
+  return aFillet;
+}
\ No newline at end of file
index 7eac5d6c882c3bfd2f71a69bea4e4e62f8a6b48c..2d66f7d6f8f1a4c5434278fe537adb5bdbe0ae9c 100644 (file)
@@ -28,6 +28,7 @@
 #include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelAPI_AttributeDoubleArray.h>
 
 class ModelHighAPI_Selection;
 
@@ -130,17 +131,39 @@ public:
                                 const ModelHighAPI_Double& theRadius1,
                                 const ModelHighAPI_Double& theRadius2);
 
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                const ModelHighAPI_Selection& theedgeselected,
+                                const std::list<ModelHighAPI_Selection>& thepoint,
+                                const std::list<ModelHighAPI_Double>& theRadius);
+  
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                const ModelHighAPI_Selection& theedgeselected,
+                                const std::list<ModelHighAPI_Double>& thepointCurvCood,
+                                const std::list<ModelHighAPI_Double>& theRadius);
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_Fillet2D();
 
-  INTERFACE_5(FeaturesPlugin_Fillet::ID(),
+  INTERFACE_8(FeaturesPlugin_Fillet::ID(),
               creationMethod, FeaturesPlugin_Fillet::CREATION_METHOD(),
                               ModelAPI_AttributeString,
                               /** Creation method */,
+              creationMethodmulti, FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES(),
+                              ModelAPI_AttributeString,
+                              /** Creation method */,
               baseObjects, FeaturesPlugin_Fillet::OBJECT_LIST_ID(),
                            ModelAPI_AttributeSelectionList,
                            /** Base objects */,
+              edgeselected, FeaturesPlugin_Fillet::EDGE_SELECTED_ID(),
+                           ModelAPI_AttributeSelection,
+                           /** Base objects */,
+              arraypointradiusbypoint, FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS(),
+                           ModelAPI_AttributeSelectionList,
+                           /** Base objects */, 
               radius, FeaturesPlugin_Fillet::RADIUS_ID(),
                       ModelAPI_AttributeDouble,
                       /** Value of the fixed radius fillet */,
@@ -181,4 +204,23 @@ FilletPtr addFillet(const std::shared_ptr<ModelAPI_Document>& thePart,
                     const ModelHighAPI_Double& theRadius2 = ModelHighAPI_Double(-1.0),
                     const bool keepSubResults = false);
 
+/// \ingroup CPPHighAPI
+/// \brief Create Fillet feature.
+FEATURESAPI_EXPORT
+FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const ModelHighAPI_Selection & theedgeselected,
+                    const std::list<ModelHighAPI_Selection>& thepoint,
+                    const std::list<ModelHighAPI_Double>& theRadius,
+                    const bool keepSubResults= false);
+
+
+/// \ingroup CPPHighAPI
+/// \brief Create Fillet feature.
+FEATURESAPI_EXPORT
+FilletPtr addFilletMultiRadiusByCurv(const std::shared_ptr<ModelAPI_Document>& thePart,
+                         const ModelHighAPI_Selection & theedgeselected,
+                         const std::list<ModelHighAPI_Double>& thepointCurvCood,
+                         const std::list<ModelHighAPI_Double>& theRadius,
+                         const bool keepSubResults= false);
+  
 #endif // FeaturesAPI_Fillet_H_
index 7523412b9fb240da8e23e7d4c203d862468000e4..5c3ecc45ca148cdd841b603375441f0876e01ec4 100644 (file)
 
 INCLUDE(Common)
 INCLUDE(UnitTest)
+INCLUDE(UseQtExt)
+
+# additional include directories
+INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+                     ${PROJECT_SOURCE_DIR}/src/Locale
+                     ${QT_INCLUDES})
+
+# additional preprocessor / compiler flags
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+
 
 SET(PROJECT_HEADERS
     FeaturesPlugin.h
@@ -66,6 +76,12 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_ImportResult.h
     FeaturesPlugin_Defeaturing.h
     FeaturesPlugin_VersionedChFi.h
+    FeaturesPlugin_WidgetCreator.h
+    FeaturesPlugin_WidgetFilletMultiRadiuses.h
+)
+
+SET(PROJECT_MOC_HEADERS
+    FeaturesPlugin_WidgetFilletMultiRadiuses.h
 )
 
 SET(PROJECT_SOURCES
@@ -113,6 +129,8 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_ImportResult.cpp
     FeaturesPlugin_Defeaturing.cpp
     FeaturesPlugin_VersionedChFi.cpp
+    FeaturesPlugin_WidgetCreator.cpp
+    FeaturesPlugin_WidgetFilletMultiRadiuses.cpp
 )
 
 SET(XML_RESOURCES
@@ -157,6 +175,12 @@ SET(TEXT_RESOURCES
     FeaturesPlugin_msg_ru.ts
 )
 
+# sources / moc wrappings
+QT_WRAP_MOC(PROJECT_AUTOMOC ${PROJECT_MOC_HEADERS})
+
+#QT5_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES})
+
+SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
 SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES})
 SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
 
@@ -166,6 +190,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomValidators
+  ../ModuleBase
   ../Events
   ../Config
   ${OpenCASCADE_INCLUDE_DIR}
@@ -182,7 +207,12 @@ SET(PROJECT_LIBRARIES
 )
 
 ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS)
-ADD_LIBRARY(FeaturesPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
+ADD_LIBRARY(FeaturesPlugin MODULE 
+            ${PROJECT_SOURCES} 
+            ${PROJECT_HEADERS} 
+            ${XML_RESOURCES} 
+            ${TEXT_RESOURCES}
+            ${PROJECT_AUTOMOC})
 TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES})
 
 INSTALL(TARGETS FeaturesPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
@@ -682,5 +712,4 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestFillet1D_Wire_3.py
                TestFillet1D_Wire_4.py
                TestFillet1D_Wire_5.py
-               Test19931.py
 )
index 3ab6d589c74eababd55b07e1fc95a50cc32cf734..4c43be8cc7e3840ac65d03260ea4e9f15657f070 100644 (file)
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
-static void explodeCompound(const GeomShapePtr& theShape, ListOfShape& theResult)
-{
-  if (theShape->shapeType() == GeomAPI_Shape::COMPOUND) {
-    GeomAPI_ShapeIterator it(theShape);
-    for (; it.more(); it.next())
-      theResult.push_back(it.current());
-  } else
-    theResult.push_back(theShape);
-}
-
-static void collectSolids(const ListOfShape& theShapes, ListOfShape& theResult)
-{
-  for (ListOfShape::const_iterator it = theShapes.begin(); it != theShapes.end(); ++it)
-    explodeCompound(*it, theResult);
-}
-
 //==================================================================================================
 FeaturesPlugin_BooleanFuse::FeaturesPlugin_BooleanFuse()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_FUSE)
@@ -121,13 +105,9 @@ void FeaturesPlugin_BooleanFuse::execute()
   const std::string aFuseVersion = data()->version();
 
   // Collecting all solids which will be fused.
-  // We explode the top-level compounds here because of issue #19931. It performs Fuse operation
-  // on a set of compounds, one of which is treated as self-intersected.
-  // But this problem is eliminated after the exploding, because in this case,
-  // the shapes are intersected, but not self-intersected.
   ListOfShape aSolidsToFuse;
-  collectSolids(anObjects, aSolidsToFuse);
-  collectSolids(aTools, aSolidsToFuse);
+  aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
+  aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
 
   // Collecting solids from compsolids which will not be modified
   // in boolean operation and will be added to result.
index 0bd58e26cf7755321e1b2c7158e6ea18642b2784..ab0d12b7dcf130baddc7216f2134834c446a3ef4 100644 (file)
@@ -32,8 +32,6 @@
 #include <GeomAPI_ShapeExplorer.h>
 
 
-static const std::string COMPOSITESKETCH_VERSION_1("v9.6");
-
 static void storeSubShape(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
                           ResultBodyPtr theResultBody,
                           const GeomShapePtr theShape,
@@ -51,15 +49,9 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the
 
   // Initialize selection list.
   if(theInitFlags & InitBaseObjectsList) {
-    AttributeSelectionListPtr anObjectsAttr =
-        std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(
-        data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()));
+    data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
     myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType();
-    anObjectsAttr->setWholeResultAllowed(true);
-    if (!anObjectsAttr->isInitialized()) {
-      // new feature, specify the version
-      data()->setVersion(COMPOSITESKETCH_VERSION_1);
-    }
+    selectionList(BASE_OBJECTS_ID())->setWholeResultAllowed(true);
   }
 }
 
index c8c5bf0d5a6f305054af06233eb66093ab32b329..aafdfacde94170494479abceb42b10e015458573 100644 (file)
@@ -22,6 +22,9 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeTables.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Edge.h>
+
+#include <GeomDataAPI_Point.h>
+#include <iostream>
+#include <Locale_Convert.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Vertex.h>
+#include <math.h>
+
 
 // Extract edges from the list
 static ListOfShape extractEdges(const ListOfShape& theShapes)
@@ -49,21 +62,56 @@ FeaturesPlugin_Fillet::FeaturesPlugin_Fillet()
 void FeaturesPlugin_Fillet::initAttributes()
 {
   data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(CREATION_METHOD_MULTIPLES_RADIUSES(), ModelAPI_AttributeString::typeId());
+  
   AttributePtr aSelectionList =
       data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(START_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(END_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
 
+  data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId());
+  data()->addAttribute(VALUES_CURV_ID(), ModelAPI_AttributeTables::typeId());
+  data()->addAttribute(EDGE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
+
+  data()->addAttribute(ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList::typeId());
+
+  data()->addAttribute(CREATION_METHOD_BY_POINTS(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(CREATION_METHOD_BY_CURVILEAR_ABSCISSA(), ModelAPI_AttributeString::typeId());
+
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END_RADIUS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ARRAY_POINT_RADIUS_BY_POINTS());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_CURV_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_MULTIPLES_RADIUSES());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_CURVILEAR_ABSCISSA());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_POINTS());
 
   initVersion(aSelectionList);
 }
 
 AttributePtr FeaturesPlugin_Fillet::objectsAttribute()
 {
+
   return attribute(OBJECT_LIST_ID());
 }
 
+void FeaturesPlugin_Fillet::attributeChanged(const std::string& theID)
+{
+  if (theID == EDGE_SELECTED_ID() 
+      && string(CREATION_METHOD())->value() == CREATION_METHOD_MULTIPLES_RADIUSES()) {
+    
+    AttributeSelectionPtr anEdges =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(attribute(EDGE_SELECTED_ID()));
+    AttributeSelectionListPtr array = selectionList(OBJECT_LIST_ID());
+    //if (array->isInitialized() )
+    //  array->clear(); 
+
+    array->append(anEdges->namingName() );
+
+
+  }
+}
+
 const std::string& FeaturesPlugin_Fillet::modifiedShapePrefix() const
 {
   static const std::string& THE_PREFIX("Fillet");
@@ -74,31 +122,63 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the
                                                          const ListOfShape& theEdges)
 {
   AttributeStringPtr aCreationMethod = string(CREATION_METHOD());
-  if (!aCreationMethod)
-    return GeomMakeShapePtr();
+  std::string anError;
 
-  bool isFixedRadius = aCreationMethod->value() == CREATION_METHOD_SINGLE_RADIUS();
-  double aRadius1 = 0.0, aRadius2 = 0.0;
-  if (isFixedRadius)
-    aRadius1 = real(RADIUS_ID())->value();
-  else {
-    aRadius1 = real(START_RADIUS_ID())->value();
-    aRadius2 = real(END_RADIUS_ID())->value();
+  if (!aCreationMethod){
+    setError(anError);
+    return GeomMakeShapePtr();
   }
-
-  // Perform fillet operation
+   
   std::shared_ptr<GeomAlgoAPI_Fillet> aFilletBuilder;
-  std::string anError;
-
+  
   ListOfShape aFilletEdges = extractEdges(theEdges);
-  if (isFixedRadius)
-    aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1));
-  else
-    aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1, aRadius2));
+
+  if ( aCreationMethod->value() == CREATION_METHOD_MULTIPLES_RADIUSES() )
+  {
+
+    std::list<double> coodCurv; 
+    std::list<double> radiuses;
+    AttributeTablesPtr aTablesAttr;
+
+    if( string(CREATION_METHOD_MULTIPLES_RADIUSES())->value() == CREATION_METHOD_BY_POINTS() )
+    {
+      aTablesAttr =  tables(VALUES_ID());
+  
+    }else{
+      aTablesAttr =  tables(VALUES_CURV_ID());
+    }
+
+    int aRows = aTablesAttr->rows();
+    ModelAPI_AttributeTables::Value aVal;
+    for (int k = 0; k < aRows; k++) { 
+        aVal = aTablesAttr->value(k, 0);
+        coodCurv.push_back(aVal.myDouble);
+        aVal = aTablesAttr->value(k, 1);
+        radiuses.push_back(aVal.myDouble);
+    }
+    aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, coodCurv,radiuses));
+
+  }else
+  {
+    bool isFixedRadius = aCreationMethod->value() == CREATION_METHOD_SINGLE_RADIUS();
+    double aRadius1 = 0.0, aRadius2 = 0.0;
+    if (isFixedRadius)
+      aRadius1 = real(RADIUS_ID())->value();
+    else {
+      aRadius1 = real(START_RADIUS_ID())->value();
+      aRadius2 = real(END_RADIUS_ID())->value();
+    }
+
+    if (isFixedRadius)
+      aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1));
+    else
+      aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1, aRadius2));
+  }
 
   if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) {
-    setError(anError);
-    return GeomMakeShapePtr();
+      setError(anError);
+      return GeomMakeShapePtr();
   }
   return aFilletBuilder;
 }
+
index 2c1460b957618bcae4c77d0adb07a73202933f11..ff7f2774d459b7a300072451692bc106e87520d1 100644 (file)
@@ -61,6 +61,30 @@ public:
     return MY_VARYING_RADIUS;
   }
 
+  inline static const std::string CREATION_METHOD_MULTIPLES_RADIUSES()
+  {
+    static std::string MY_METHOD_MULTIPLES_RADIUSES("multiple_radiuses");
+    return MY_METHOD_MULTIPLES_RADIUSES;
+  }
+
+  inline static const std::string CREATION_METHOD_BY_POINTS()
+  {
+    static std::string MY_CREATION_METHOD_BY_POINTS("by_point_method");
+    return MY_CREATION_METHOD_BY_POINTS;
+  }
+
+  inline static const std::string ARRAY_POINT_RADIUS_BY_POINTS()
+  {
+    static std::string MY_ARRAY_POINT_RADIUS_BY_POINTS("array_point_radius_by_point");
+    return MY_ARRAY_POINT_RADIUS_BY_POINTS;
+  }
+
+  inline static const std::string CREATION_METHOD_BY_CURVILEAR_ABSCISSA()
+  {
+    static std::string MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA("by_curvilinear_abscissa_methode");
+    return MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA;
+  }
+
   /// Attribute name of main objects.
   inline static const std::string& OBJECT_LIST_ID()
   {
@@ -75,6 +99,27 @@ public:
     return MY_START_RADIUS_ID;
   }
 
+  /// Attribute name of edge selected.
+  inline static const std::string& EDGE_SELECTED_ID()
+  {
+    static const std::string MY_EDGE_SELECTED_ID("edge_selected");
+    return MY_EDGE_SELECTED_ID;
+  }
+
+  /// attribute name of list of tables that contain deafult values (row 0) and the custom values
+  inline static const std::string& VALUES_ID()
+  {
+    static const std::string MY_VALUES_ID("values");
+    return MY_VALUES_ID;
+  }
+  
+  /// attribute name of list of tables that contain deafult values (row 0) and the custom values
+  inline static const std::string& VALUES_CURV_ID()
+  {
+    static const std::string MY_VALUES_ID("values_curv");
+    return MY_VALUES_ID;
+  }
+
   /// Attribute name of end radius.
   inline static const std::string& END_RADIUS_ID()
   {
@@ -91,6 +136,8 @@ public:
   /// Request for initialization of data model of the feature: adding all attributes.
   FEATURESPLUGIN_EXPORT virtual void initAttributes();
 
+  FEATURESPLUGIN_EXPORT void attributeChanged(const std::string& theID);
+
   /// Use plugin manager for features creation.
   FeaturesPlugin_Fillet();
 
index 0d49dfe08d1da9ca019628b9784e630e8b5331f9..e68b35d69835509a0fc3d73c1980fcfc0fb24181 100644 (file)
 #include <FeaturesPlugin_ValidatorTransform.h>
 #include <FeaturesPlugin_Validators.h>
 
+#include <ModuleBase_WidgetCreatorFactory.h>
+
+#include "FeaturesPlugin_WidgetCreator.h"
+
 #include <ModelAPI_Session.h>
 
 #include <string>
@@ -66,7 +70,13 @@ static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin()
 
 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
 {
+
+  WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get();
+  aWidgetCreatorFactory->registerCreator(
+   std::shared_ptr<FeaturesPlugin_WidgetCreator>(new FeaturesPlugin_WidgetCreator()));
+
   SessionPtr aMgr = ModelAPI_Session::get();
+
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
                               new FeaturesPlugin_ValidatorTransform);
index 55bad81ce443f6772c579ab99f0760d2f362ac78..9235d933e78d40e886dc4902e2f84649f016f7e3 100644 (file)
@@ -402,11 +402,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
     AttributeSelectionListPtr aListAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
 
-    const std::string& aVersion = theAttribute->owner()->data()->version();
-    std::string aSelType;
-    if (!aVersion.empty())
-      aSelType = aListAttr->selectionType();
-
+    const std::string& aSelType = aListAttr->selectionType();
     std::list<std::string> anApplicableTypes;
     switch (GeomValidators_ShapeType::shapeType(aSelType)) {
     case GeomValidators_ShapeType::Vertex:
index 7dfa2e3394ec18945277654e11746f4ce1cdaada..7738cf1fec9278fbdcdf461f660910aaec5f4cdb 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <GeomAPI_ShapeExplorer.h>
 
+#include <iostream>
 
 static const std::string CHAMFERFILLET_VERSION_1("v9.5");
 
@@ -81,6 +82,7 @@ void FeaturesPlugin_VersionedChFi::execute()
 
     anOriginalSolids.push_back(aSolid);
     anEdges.insert(anEdges.end(), aSubs.begin(), aSubs.end());
+
   }
 
   // Build results of the operaion.
@@ -125,14 +127,28 @@ bool FeaturesPlugin_VersionedChFi::processAttribute(const AttributePtr& theAttri
     if (aContext.get()) {
       ResultBodyPtr aCtxOwner = ModelAPI_Tools::bodyOwner(aContext);
       if (aCtxOwner && aCtxOwner->shape()->shapeType() == GeomAPI_Shape::COMPSOLID)
+      {
         aContext = aCtxOwner;
+      }
       aParent = aContext->shape();
       if (!aParent)
         return false;
 
       // store full shape hierarchy for the corresponding version only
-      theObjects.addObject(anObject);
-      theObjects.addParent(anObject, aParent);
+      if (anObject->shapeType() <= GeomAPI_Shape::SOLID)
+      {
+        ListOfShape anEdges;
+        collectSubs(aParent, anEdges, GeomAPI_Shape::EDGE);
+        for (ListOfShape::iterator anIt = anEdges.begin(); anIt != anEdges.end(); ++anIt) {
+          theObjects.addObject(*anIt);
+          theObjects.addParent(*anIt, aParent);
+        }
+      }else
+      {
+        theObjects.addObject(anObject);
+        theObjects.addParent(anObject, aParent);
+      }
+      
       if (isStoreFullHierarchy)
         ModelAPI_Tools::fillShapeHierarchy(aParent, aContext, theObjects);
     } else { // get it from a feature
diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp
new file mode 100644 (file)
index 0000000..05478d8
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "FeaturesPlugin_WidgetCreator.h"
+#include "FeaturesPlugin_WidgetFilletMultiRadiuses.h"
+
+
+FeaturesPlugin_WidgetCreator::FeaturesPlugin_WidgetCreator()
+: ModuleBase_IWidgetCreator()
+{
+  myPanelTypes.insert("multiradius-panel");
+  myPanelTypes.insert("multiradiuscurv-panel");
+}
+
+void FeaturesPlugin_WidgetCreator::widgetTypes(std::set<std::string>& theTypes)
+{
+  theTypes = myPanelTypes;
+}
+
+
+ModuleBase_ModelWidget* FeaturesPlugin_WidgetCreator::createWidgetByType(
+                                                     const std::string& theType,
+                                                     QWidget* theParent,
+                                                     Config_WidgetAPI* theWidgetApi,
+                                                     ModuleBase_IWorkshop* theWorkshop)
+{
+  ModuleBase_ModelWidget* aWidget = 0;
+  if (myPanelTypes.find(theType) == myPanelTypes.end())
+    return aWidget;
+
+  if (theType == "multiradius-panel") {
+    aWidget = new FeaturesPlugin_WidgetFilletMultiRadiuses(theParent, theWorkshop, theWidgetApi, true);
+  }else if (theType == "multiradiuscurv-panel")
+  {
+    aWidget = new FeaturesPlugin_WidgetFilletMultiRadiuses(theParent, theWorkshop, theWidgetApi, false);
+  }
+  
+
+  return aWidget;
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.h b/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.h
new file mode 100644 (file)
index 0000000..98ba3b6
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef FeaturesPlugin_WidgetCreator_H
+#define FeaturesPlugin_WidgetCreator_H
+
+
+#include "FeaturesPlugin.h"
+#include <ModuleBase_IWidgetCreator.h>
+
+#include <string>
+#include <set>
+
+class QWidget;
+
+/** 
+* \ingroup GUI
+* Interface to WidgetCreator which can create specific widgets by type
+*/
+class FeaturesPlugin_WidgetCreator : public ModuleBase_IWidgetCreator
+{
+public:
+  /// Default constructor
+  FeaturesPlugin_WidgetCreator();
+
+  /// Virtual destructor
+  ~FeaturesPlugin_WidgetCreator() {}
+
+  /// Returns a container of possible page types, which this creator can process
+  /// \param theTypes a list of type names
+  virtual void widgetTypes(std::set<std::string>& theTypes);
+
+  /// Create widget by its type
+  /// The default implementation is empty
+  /// \param theType a type
+  /// \param theParent a parent widget
+  /// \param theData a low-level API for reading xml definitions of widgets
+  /// \param theWorkshop a current workshop
+  /// \return a created model widget or null
+  virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
+                                                     QWidget* theParent,
+                                                     Config_WidgetAPI* theWidgetApi,
+                                                     ModuleBase_IWorkshop* /*theWorkshop*/);
+private:
+  std::set<std::string> myPanelTypes; ///< types of panels
+};
+
+#endif
\ No newline at end of file
diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp
new file mode 100644 (file)
index 0000000..3c9f3e3
--- /dev/null
@@ -0,0 +1,705 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "FeaturesPlugin_WidgetFilletMultiRadiuses.h"
+#include "FeaturesPlugin_Fillet.h"
+
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_ISelection.h>
+#include <ModuleBase_IPropertyPanel.h>
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_AttributeString.h>
+
+#include <QLayout>
+#include <QWidget>
+#include <QFormLayout>
+#include <QComboBox>
+#include <QSpinBox>
+#include <QLabel>
+#include <QSlider>
+#include <QTableWidget>
+#include <QPushButton>
+#include <QHeaderView>
+#include <QStackedWidget>
+#include <QValidator>
+#include <QLineEdit>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QScrollBar>
+#include <QApplication>
+#include <qabstractitemmodel.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Pnt.h>
+#include <Locale_Convert.h>
+#include <QStandardItem>
+#include <map>
+
+
+const char* MYFirstCol = "Shape";
+const char* MYTrue = "True";
+const char* MYFalse = "False";
+
+
+DataArrayItemDelegate::DataArrayItemDelegate(bool theTypeMethode)
+  : QStyledItemDelegate(), myTypeMethodePoint(theTypeMethode)
+{
+}
+
+
+QWidget* DataArrayItemDelegate::createEditor(QWidget* theParent,
+                                             const QStyleOptionViewItem & theOption,
+                                             const QModelIndex& theIndex ) const
+{
+  QWidget* aEditor = 0;
+  if ((theIndex.column() == 0) && (theIndex.row() > 0 )) {
+    QWidget* aWgt = QStyledItemDelegate::createEditor(theParent, theOption, theIndex);
+    QLineEdit* aEdt = static_cast<QLineEdit*>(aWgt);
+    aEdt->setReadOnly(true);
+    aEditor = aEdt;
+  } else {
+    QLineEdit* aLineEdt = 0;
+
+    aLineEdt = dynamic_cast<QLineEdit*>(QStyledItemDelegate::createEditor(theParent,
+                                                                          theOption,
+                                                                          theIndex));
+    if (aLineEdt) {
+      if( theIndex.column() == 2 )
+        aLineEdt->setValidator(new QDoubleValidator(0.0 , 10000.0, 6, aLineEdt));
+      else
+        aLineEdt->setValidator(new QDoubleValidator(0.00001 , 0.9999, 6, aLineEdt));
+      aEditor = aLineEdt;
+    }
+    
+  }
+
+  connect(aEditor, SIGNAL(textEdited(const QString&)),
+      SLOT(onEditItem(const QString&)));
+  return aEditor;
+}
+
+void DataArrayItemDelegate::onEditItem(const QString& theText)
+{
+  QWidget* aWgt = dynamic_cast<QWidget*>(sender());
+  commitData(aWgt);
+}
+
+
+//**********************************************************************************
+//**********************************************************************************
+//**********************************************************************************
+FeaturesPlugin_WidgetFilletMultiRadiuses::
+  FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent,
+                                           ModuleBase_IWorkshop* theWorkshop,
+                                           const Config_WidgetAPI* theData,
+                                           bool TypeMethodeBypoint):
+ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0),
+ myTypeMethodeBypoint(TypeMethodeBypoint),mySetSelection(true)
+{
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+
+  aMainLayout->addWidget(new QLabel("Raduises", this));
+  // Radiuses controls
+  QFrame* aRadiusesFrame = new QFrame(this);
+  aRadiusesFrame->setFrameShape(QFrame::Box);
+  aRadiusesFrame->setFrameStyle(QFrame::StyledPanel);
+  QVBoxLayout* aRadiusesLayout = new QVBoxLayout(aRadiusesFrame);
+  aMainLayout->addWidget(aRadiusesFrame);
+
+  myDataTbl = new QTableWidget(2, 3, aRadiusesFrame);
+
+  myDelegate = new DataArrayItemDelegate(myTypeMethodeBypoint);
+
+  myDataTbl->installEventFilter(this);
+  myDataTbl->setItemDelegate(myDelegate);
+
+  myDataTbl->verticalHeader()->hide();
+  myDataTbl->setRowHeight(0, 25);
+  myDataTbl->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+  
+  if(myTypeMethodeBypoint){
+    myfirstRowValue.push_back("Start extremity");
+    myfirstRowValue.push_back("0"); 
+    myfirstRowValue.push_back("0.5"); 
+    myLastRowValue.push_back("End extremity"); 
+    myLastRowValue.push_back("1"); 
+    myLastRowValue.push_back("0.5"); 
+  }else{
+    myfirstRowValue.push_back("0");
+    myfirstRowValue.push_back("0"); 
+    myfirstRowValue.push_back("1"); 
+    myLastRowValue.push_back("1"); 
+    myLastRowValue.push_back("1"); 
+    myLastRowValue.push_back("2"); 
+  }
+  
+
+  QStringList aHeaders;
+  aHeaders << "Point";
+  aHeaders << "Curvilinear /n Abscissa";
+  aHeaders << "Radius";
+
+  myDataTbl->setHorizontalHeaderLabels(aHeaders);
+  QTableWidgetItem* aItem;
+  for(int j =0; j<3;j++)
+  {
+    aItem = new QTableWidgetItem(myfirstRowValue[j]);
+    if(j==0 || j== 1)
+      aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
+    myDataTbl->setItem(0, j, aItem);
+    aItem = new QTableWidgetItem(myLastRowValue[j]);
+    if(j==0 || j== 1)
+      aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
+    myDataTbl->setItem(1, j, aItem);
+  }
+
+  connect(myDataTbl, SIGNAL(cellChanged(int, int)), SLOT(onTableEdited(int, int)));
+
+  myDataTbl->horizontalHeader()->viewport()->installEventFilter(this);
+  
+  aRadiusesLayout->addWidget(myDataTbl);
+  ///========================
+
+  // Buttons below
+  QWidget* aBtnWgt = new QWidget(this);
+  aRadiusesLayout->addWidget(aBtnWgt);
+  QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnWgt);
+  aBtnLayout->setAlignment(Qt::AlignLeft);
+  aBtnLayout->setContentsMargins(0, 0, 0, 0);
+
+  QPushButton* aAddBtn = new QPushButton(tr("+"), aBtnWgt);
+  QFont font = aAddBtn->font();
+  font.setPointSize(12);
+  aAddBtn->setFont(font);
+  aBtnLayout->addWidget(aAddBtn);
+  aBtnLayout->addStretch(1);
+
+  myRemoveBtn = new QPushButton(tr("-"), aBtnWgt);
+  font = myRemoveBtn->font();
+  font.setPointSize(12);
+  myRemoveBtn->setFont(font);
+  aBtnLayout->addWidget(myRemoveBtn);
+
+  connect(aAddBtn, SIGNAL(clicked(bool)), SLOT(onAddStep()));
+  connect(myRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemoveStep()));
+  connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(onFocusChanged(QWidget*, QWidget*)));
+}
+
+QList<QWidget*> FeaturesPlugin_WidgetFilletMultiRadiuses::getControls() const
+{
+  QList<QWidget*> aControls;
+  // this control will accept focus and will be highlighted in the Property Panel
+  aControls.append(myDataTbl);
+  return aControls;
+}
+
+//**********************************************************************************
+QIntList FeaturesPlugin_WidgetFilletMultiRadiuses::shapeTypes() const
+{
+  QIntList aRes;
+
+  aRes.append(ModuleBase_Tools::shapeType("vertex"));
+  return aRes;
+}
+
+//**********************************************************************************
+void FeaturesPlugin_WidgetFilletMultiRadiuses::deactivate()
+{
+
+  ModuleBase_WidgetSelector::deactivate();
+  storeValueCustom();
+}
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, QEvent* theEvent)
+{
+  QObject* aObject = 0;
+
+  if (myDataTbl->horizontalHeader()->viewport() == theObject) {
+      aObject = theObject;
+  }
+  if (aObject) {
+    if (theEvent->type() == QEvent::MouseButtonDblClick) {
+      if (myHeaderEditor) { //delete previous editor
+        myHeaderEditor->deleteLater();
+        myHeaderEditor = 0;
+      }
+      QMouseEvent* aMouseEvent = static_cast<QMouseEvent*>(theEvent);
+      QHeaderView* aHeader = static_cast<QHeaderView*>(aObject->parent());
+      QTableWidget* aTable = static_cast<QTableWidget*>(aHeader->parentWidget());
+
+      int aShift = aTable->horizontalScrollBar()->value();
+      int aPos = aMouseEvent->x();
+      int aIndex = aHeader->logicalIndex(aHeader->visualIndexAt(aPos));
+      if (aIndex > 0) {
+        QRect aRect;
+        aRect.setLeft(aHeader->sectionPosition(aIndex));
+        aRect.setWidth(aHeader->sectionSize(aIndex));
+        aRect.setTop(0);
+        aRect.setHeight(aHeader->height());
+        aRect.adjust(1, 1, -1, -1);
+        aRect.translate(-aShift, 0);
+
+        myHeaderEditor = new QLineEdit(aHeader->viewport());
+        myHeaderEditor->move(aRect.topLeft());
+        myHeaderEditor->resize(aRect.size());
+        myHeaderEditor->setFrame(false);
+        QString aText = aHeader->model()->
+          headerData(aIndex, aHeader->orientation()).toString();
+        myHeaderEditor->setText(aText);
+        myHeaderEditor->setFocus();
+        //myEditIndex = aIndex; //save for future use
+        myHeaderEditor->installEventFilter(this); //catch focus out event
+        //if user presses Enter it should close editor
+        connect(myHeaderEditor, SIGNAL(returnPressed()), aTable, SLOT(setFocus()));
+        myHeaderEditor->show();
+        return true;
+      }
+    }
+  } else if (theEvent->type() == QEvent::FocusIn) {
+    
+    QTableWidget* aTable = dynamic_cast<QTableWidget*>(theObject);
+    if (aTable) {
+      ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
+      if (aPanel->activeWidget() != this) {
+        aPanel->activateWidget(this, false);
+      }
+    }
+  }
+  else if (theEvent->type() == QEvent::Show ) {
+
+   /* ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
+    if (aPanel->activeWidget() != this) {
+      aPanel->activateWidget(this, false);
+    }*/
+    DataPtr aData = myFeature->data();
+    if( myTypeMethodeBypoint )
+      aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())
+            ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() );
+    else
+      aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())
+            ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_CURVILEAR_ABSCISSA() );
+  }
+  return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent);
+}
+
+
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom()
+{
+
+  DataPtr aData = myFeature->data();
+
+  AttributeTablesPtr aTablesAttr;
+
+  if(myTypeMethodeBypoint)
+    aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID());
+  else  
+    aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
+
+  // Store data-
+  int aRows = myDataTbl->rowCount();
+
+  aTablesAttr->setSize(aRows, 2);
+  aTablesAttr->setType(ModelAPI_AttributeTables::ValueType::DOUBLE);
+
+  for (int i = 0; i < aRows; i++) {
+    for (int j = 0; j < 2; j++) {
+      QString aTblVal = myDataTbl->item(i, j+1)->text();
+      aTablesAttr->setValue( getValue( aTblVal ), i, j);
+    }
+  } 
+
+  return true;
+}
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom()
+{
+
+  if ( !mySetSelection) {
+    mySetSelection = true;
+    return false;
+  }
+  DataPtr aData = myFeature->data();
+
+  AttributeTablesPtr aTablesAttr;
+
+  if(myTypeMethodeBypoint)
+    aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID());
+  else  
+    aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
+
+  AttributeSelectionPtr anEdges =
+    std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aData->attribute(FeaturesPlugin_Fillet::EDGE_SELECTED_ID()));
+
+  if( !anEdges->isInitialized() )
+      return;
+  
+  std::map<double,std::pair<QString,QString>> aValuesSort; 
+
+  double res;
+  int aRows = 0;
+  std::map<double,std::pair<QString,QString>>::iterator itValuesSort;
+  if(myTypeMethodeBypoint)
+  {
+    GeomEdgePtr anEdge = GeomEdgePtr(new GeomAPI_Edge( anEdges->value()));
+    GeomPointPtr first =  anEdge->firstPoint();
+    GeomPointPtr last  =  anEdge->lastPoint();
+    double taille = first->distance(last);
+    
+    // Load points 
+    AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
+    AttributeDoubleArrayPtr aArrayAttr; 
+    ListOfShape aPoints;
+
+    std::set<GeomShapePtr> aContexts;
+    for (int anIndex = 0; anIndex < aSelectionListAttr->size(); ++anIndex) {
+        AttributeSelectionPtr aSelection = aSelectionListAttr->value(anIndex);
+        GeomShapePtr aShape = aSelection->value();
+
+        ResultPtr aContext = aSelection->context();
+        aContexts.insert(aContext->shape());
+
+        if (!aShape.get()) {
+          aShape = aContext->shape();
+        } 
+
+        aPoints.push_back(aShape);
+    }
+    int i =0;
+
+    ListOfShape::const_iterator aPointsIt = aPoints.begin();
+    for (; aPointsIt != aPoints.end(); ++aPointsIt) {
+      AttributeSelectionPtr attsel = aSelectionListAttr->value(i);
+      std::shared_ptr<GeomAPI_Pnt> aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt);
+      res = (aPnt->distance(first) / taille);
+      QString aName = QString::fromStdWString(attsel->namingName());
+      QString aRad = findRadius( QString::number(res) );
+      if ( aValuesSort.find( res ) == aValuesSort.end() )
+        aValuesSort[ res ] = std::make_pair(aName, aRad ); 
+      i++;
+    } 
+    
+    res = 0.0; 
+    aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(res) )) ; 
+    res = 1.0;
+    aValuesSort[ res ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(res) )) ; 
+    aRows =  aValuesSort.size();
+  }else{
+
+    ModelAPI_AttributeTables::Value aVal;
+    if (aTablesAttr->isInitialized()){
+        
+        for (int anIndex = 0; anIndex < aTablesAttr->rows(); ++anIndex) {
+          aVal = aTablesAttr->value(anIndex,0);
+          double curv = getValueText(aVal).toDouble();
+          if ( aValuesSort.find( curv ) == aValuesSort.end() )
+            aValuesSort[ curv ] = std::make_pair(getValueText(aVal), findRadius(getValueText(aVal)));
+        }
+        aRows = aTablesAttr->rows();
+    }else{
+      res = 0.0; 
+      aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]) ; 
+      res = 1.0;
+      aValuesSort[ res ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]) ; 
+      aRows = 2;
+    }
+
+  }
+
+  QTableWidgetItem* aItem = 0;
+  myDataTbl->blockSignals(true);
+  aItem = myDataTbl->item( myDataTbl->rowCount() -1, 0 );
+  aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+  aItem = myDataTbl->item( myDataTbl->rowCount() -1, 1 );
+  aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+
+
+  myDataTbl->setRowCount(aRows);
+  
+  itValuesSort = aValuesSort.begin(); 
+
+  for (int k = 0; k < aRows; k++, ++itValuesSort ) {
+
+    std::pair<QString,QString> elem = itValuesSort->second;
+    QString aCurv = QString::number(itValuesSort->first); 
+
+    aItem = myDataTbl->item(k, 0);
+    if (aItem) {
+          aItem->setText( elem.first);
+    } else {
+          aItem = new QTableWidgetItem(elem.first);
+          myDataTbl->setItem(k, 0, aItem);
+    }
+    aItem = myDataTbl->item(k, 1);
+    if (aItem) {
+          aItem->setText( aCurv);
+    } else {
+          aItem = new QTableWidgetItem(aCurv);
+          myDataTbl->setItem(k, 1, aItem);
+    }
+    aItem = myDataTbl->item(k, 2);
+    if (aItem) {
+          aItem->setText( elem.second);
+    } else {
+          aItem = new QTableWidgetItem(elem.second);
+          myDataTbl->setItem(k, 2, aItem);
+    }
+  }
+  aItem = myDataTbl->item(myDataTbl->rowCount()-1, 0 );
+  aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled );
+  aItem = myDataTbl->item(myDataTbl->rowCount()-1, 1 );
+  aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled );
+  myDataTbl->blockSignals(false);
+  
+  return true;
+}
+
+
+//**********************************************************************************
+void FeaturesPlugin_WidgetFilletMultiRadiuses::onAddStep()
+{
+
+  QModelIndex index = myDataTbl->currentIndex();
+  int i  = index.row();
+  if( i == -1 )
+    return false; 
+
+  if( !myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2 ) 
+     return false;
+
+  myDataTbl->blockSignals(true);
+
+  if ( i == myDataTbl->rowCount() -1)
+    i = myDataTbl->rowCount() - 2;
+  
+  if ( i == 0)
+    i =1;
+
+  myDataTbl->model()->insertRow(i);
+  QTableWidgetItem* aItem =0;
+
+  aItem = myDataTbl->item( i, 0 );
+  aItem = new QTableWidgetItem( "New" );
+  myDataTbl->setItem(i, 0, aItem);
+  aItem = new QTableWidgetItem(myfirstRowValue[1]);
+  myDataTbl->setItem(i, 1, aItem);
+  aItem = new QTableWidgetItem("-1");
+  myDataTbl->setItem(i, 1, aItem);
+   aItem = new QTableWidgetItem(myfirstRowValue[2]);
+  myDataTbl->setItem(i, 2, aItem);
+  aItem = new QTableWidgetItem(myLastRowValue[2]);
+  myDataTbl->setItem(i, 2, aItem);
+
+  myDataTbl->blockSignals(false);
+
+  emit valuesChanged();
+}
+
+//**********************************************************************************
+void FeaturesPlugin_WidgetFilletMultiRadiuses::onRemoveStep()
+{
+  QModelIndex index = myDataTbl->currentIndex();
+
+  if( !myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2 ) 
+     return false;
+
+  myDataTbl->blockSignals(true);
+  if (index.row() == -1 
+   || index.row() == 0 
+   || index.row() == myDataTbl->rowCount() -1)
+    return;
+
+  if (myTypeMethodeBypoint)
+  {
+    QTableWidgetItem* aItem = 0;
+
+    QString aName = myDataTbl->item( index.row() , 0 )->text();
+    AttributeSelectionListPtr aSelList =
+            myFeature->data()->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
+
+    AttributeSelectionPtr aAttr;
+    for (int i = 0; i < aSelList->size(); i++) {
+        aAttr = aSelList->value(i);
+        if( aName == QString::fromStdWString( aAttr->namingName()) )
+        {
+          aSelList->remove({i});
+        }
+    }
+  }
+  myDataTbl->model()->removeRow(index.row());
+  myDataTbl->blockSignals(false);
+
+  emit valuesChanged();
+}
+
+//**********************************************************************************
+void FeaturesPlugin_WidgetFilletMultiRadiuses::onTableEdited(int theRow, int theCol)
+{
+  // Do not store here column of names
+  if (theCol == 0)
+    return;
+
+  if (!myFeature.get())
+    return;
+
+  ModelAPI_AttributeTables::Value aVal = getValue(myDataTbl->item(theRow, theCol)->text());
+
+  AttributeTablesPtr aTablesAttr;
+
+  if(myTypeMethodeBypoint)
+    aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID());
+  else  
+    aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
+
+  if (aTablesAttr->isInitialized())
+  {
+    aTablesAttr->setValue(aVal,theRow, theCol - 1);
+    emit valuesChanged();
+  }
+}   
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::
+  isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
+{
+  return true;
+}
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::processEnter()
+{
+
+  return true;
+}
+
+//**********************************************************************************
+bool FeaturesPlugin_WidgetFilletMultiRadiuses::
+  setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues, const bool theToValidate)
+{
+
+  if ( theValues.size() > 1 || !myTypeMethodeBypoint || theValues.size() == 0 )
+  {
+    mySetSelection = false;
+    return false; 
+  }
+  QModelIndex index = myDataTbl->currentIndex();
+  if(  index.row() == -1 )
+  {
+    mySetSelection = false;
+    return false; 
+  }
+
+  if( !myDataTbl->currentItem()->isSelected()){
+    mySetSelection = false;
+    return false; 
+  }
+
+
+  AttributeSelectionListPtr aSelList =
+    myFeature->data()->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
+
+  ResultPtr aResult;
+  GeomShapePtr aShape;
+  int aNbData = 0;
+  ModuleBase_ViewerPrsPtr aValue = theValues.first();
+  aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
+  aShape = aValue->shape();
+
+  if ( (aResult.get() || aShape.get() ) && !aSelList->isInList(aResult, aShape)) {
+    aSelList->append(aResult, aShape);
+    onRemoveStep();
+   }else{
+      mySetSelection = false;
+      return false; 
+  }
+
+  return true;
+}
+
+//**********************************************************************************
+QList<std::shared_ptr<ModuleBase_ViewerPrs>>
+  FeaturesPlugin_WidgetFilletMultiRadiuses::getAttributeSelection() const
+{
+  QList<std::shared_ptr<ModuleBase_ViewerPrs>> aList;
+  if(myFeature) {
+    DataPtr aData = myFeature->data();
+    AttributeSelectionListPtr aSelList =
+      aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
+    AttributeSelectionPtr aAttr;
+    ObjectPtr anObject;
+    for (int i = 0; i < aSelList->size(); i++) {
+      aAttr = aSelList->value(i);
+      ModuleBase_ViewerPrsPtr
+        aPrs(new ModuleBase_ViewerPrs(aAttr->context(), aAttr->value(), NULL));
+      aList.append(aPrs);
+    }
+  }
+  return aList;
+}
+
+//**********************************************************************************
+ModelAPI_AttributeTables::Value FeaturesPlugin_WidgetFilletMultiRadiuses::getValue(QString theStrVal) const
+{
+  ModelAPI_AttributeTables::Value aVal;
+  aVal.myDouble = theStrVal.toDouble();
+  return aVal;
+}
+
+//**********************************************************************************
+QString FeaturesPlugin_WidgetFilletMultiRadiuses::findRadius(QString thename) const
+{
+  AttributeTablesPtr aTablesAttr;
+
+  if(myTypeMethodeBypoint)
+    aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID());
+  else  
+    aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
+  for(int i = 0; i < aTablesAttr->rows(); ++i)
+  {
+    ModelAPI_AttributeTables::Value aVal = aTablesAttr->value( i, 0) ;
+    if( getValueText(aVal) == thename )
+    {
+        aVal = aTablesAttr->value( i, 1);
+        return getValueText(aVal);
+    }
+  }
+  return "0.5";
+}
+
+//**********************************************************************************
+QString FeaturesPlugin_WidgetFilletMultiRadiuses::getValueText(ModelAPI_AttributeTables::Value& theVal) const
+{
+
+    return QString::number(theVal.myDouble);
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h
new file mode 100644 (file)
index 0000000..b29b1e2
--- /dev/null
@@ -0,0 +1,167 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef FeaturesPlugin_WidgetFilletMultiRadiuses_H
+#define FeaturesPlugin_WidgetFilletMultiRadiuses_H
+
+#include "FeaturesPlugin.h"
+
+#include <ModuleBase_WidgetSelector.h>
+#include <ModuleBase_ViewerPrs.h>
+#include <ModelAPI_AttributeTables.h>
+
+#include <QList>
+#include <QStringList>
+#include <QStyledItemDelegate>
+
+class QWidget;
+class QLabel;
+class QTableWidget;
+class QPushButton;
+class QTableWidgetItem;
+class QLineEdit;
+
+class DataArrayItemDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+  DataArrayItemDelegate(bool theTypeMethode);
+
+  virtual QWidget* createEditor(QWidget* theParent,
+                                const QStyleOptionViewItem & theOption,
+                                const QModelIndex& theIndex) const;
+
+private slots:
+  void onEditItem(const QString& theText);
+
+private:
+  bool myTypeMethodePoint;
+};
+
+
+/*!
+ * \ingroup GUI
+ * Represent a content of the property panel to show/modify parameters of a Field feature.
+ */
+class FeaturesPlugin_WidgetFilletMultiRadiuses : public ModuleBase_WidgetSelector
+{
+ Q_OBJECT
+public:
+  FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent,
+                                           ModuleBase_IWorkshop* theWorkshop,
+                                           const Config_WidgetAPI* theData,
+                                           bool TypeMethodeBypoint);
+
+  virtual ~FeaturesPlugin_WidgetFilletMultiRadiuses() {}
+
+  /// Returns true if the event is processed.
+  virtual bool processEnter();
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
+  /// Checks the widget validity. By default, it returns true.
+  /// \param thePrs a selected presentation in the view
+  /// \return a boolean value
+  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
+
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom();
+
+  /// Restore value from attribute data to the widget's control
+  virtual bool restoreValueCustom();
+
+  /// Redefinition of virtual function
+  /// \param theObject an object for the event
+  /// \param theEvent an event
+  virtual bool eventFilter(QObject* theObject, QEvent* theEvent);
+
+  //virtual void showEvent(QShowEvent* theEvent);
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValues the wrapped selection values
+  /// \param theToValidate a validation of the values flag
+  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+                            const bool theToValidate);
+  
+    /// Return the attribute values wrapped in a list of viewer presentations
+  /// \return a list of viewer presentations, which contains an attribute result and
+  /// a shape. If the attribute do not uses the shape, it is empty
+  virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
+
+private slots:
+
+  /// Slot called on add a step
+  void onAddStep();
+
+  /// Slot called on remove a step
+  void onRemoveStep();
+
+  /// Retunrs a list of possible shape types
+  /// \return a list of shapes
+  virtual QIntList shapeTypes() const;
+
+  /// Slot called on editing of a table cell
+  /// \param theRow a row of the cell
+  /// \param theCol a column of the cell
+  void onTableEdited(int theRow, int theCol);
+
+
+private:
+
+  /// Return a value from the string
+  /// \param theStrVal a string
+  ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
+
+  /// Return a QString from the ModelAPI_AttributeTables
+  /// \param theStrVal a string
+  QString getValueText(ModelAPI_AttributeTables::Value& theVal) const;
+
+  /// Return a radii value from the name 
+  /// \param theStrVal a string
+  QString findRadius(QString thename) const;
+
+  /// tables
+  QTableWidget* myDataTbl;
+
+  /// Remove button
+  QPushButton* myRemoveBtn;
+
+  /// Editor for table header
+  QLineEdit* myHeaderEditor;
+
+  bool myTypeMethodeBypoint; 
+
+  bool mySetSelection; 
+
+  DataArrayItemDelegate* myDelegate;
+
+  std::vector<QString> myfirstRowValue; 
+  std::vector<QString> myLastRowValue; 
+
+};
+
+#endif
\ No newline at end of file
index 6f821a2e2fa1c59eadfbf68ab80c4f2e9fbd427a..aeebd768de1fc3ace1925dff286ffb73622d48a2 100644 (file)
   </context>
   <context>
     <name>Fillet:main_objects</name>
+    <message>
+      <source>Faces, edges or/and solids</source>
+      <translation>Faces, arêtes ou/et solides</translation>
+    </message>
     <message>
       <source>Faces or/and edges</source>
       <translation>Faces ou/et arêtes</translation>
index 478bf3770564a20a0f446e7a1799729d6298d42e..e1853ee74e9f481640bf5bd2d6d09d378b78b357 100644 (file)
@@ -38,4 +38,4 @@ model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.SOLID, [1, 1])
 model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.FACE, [6, 6])
 model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.EDGE, [24, 24])
 model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.VERTEX, [48, 48])
-model.testResultsVolumes(Symmetry_3, [1000, 1000])
+model.testResultsVolumes(Symmetry_3, [-1000, 1000])
index df1631146dd0b892b0c9a54f72a98eae1ea9d50a..94a9d4bc3a5d05302cc90b0974cf7a64fc4cb8df 100644 (file)
@@ -5,7 +5,7 @@
 1. Planar face of non-sketch object or a plane. Sketch creation will be started.&lt;br /&gt;
 2. An existing sketch face or contour. Extrusion will be filled by it.&lt;br /&gt;
 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
-                  shape_types="Vertices Edges Faces|Wires"
+                  shape_types="Vertices Edges Faces"
                   type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
                   default_type = "2"
                   use_choice="true">
@@ -14,7 +14,7 @@
   <multi_selector id="base"
                   label="Base objects:"
                   tooltip="Select a base objects"
-                  shape_types="Vertices Edges Faces|Wires"
+                  shape_types="Vertices Edges Faces"
                   type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
                   default_type = "2"
                   use_choice="true"
index a2caf45368e44ef0875944f8770d5412922b2dcb..78b9eb1313ff4d00cbe0099bf2c15035b1d7f9d8 100644 (file)
@@ -6,7 +6,7 @@
 1. Planar face of non-sketch object or a plane. Sketch creation will be started.&lt;br /&gt;
 2. An existing sketch face or contour. Extrusion will be filled by it.&lt;br /&gt;
 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
-      shape_types="Vertices Edges Faces|Wires"
+      shape_types="Vertices Edges Faces"
       type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
       default_type = "2"
       use_choice="true">
@@ -16,7 +16,7 @@
       label="Select a sketch face"
       icon="icons/Features/sketch.png"
       tooltip="Select a sketch face"
-      shape_types="Vertices Edges Faces|Wire"
+      shape_types="Vertices Edges Faces"
       type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
       default_type = "2"
       use_choice="true"
index 7abb4a5dfab0e5ebe2363695ad3f13707ddc9c36..d4c6fa6249ee1432ea762a7da3f2d8b10f45689a 100644 (file)
@@ -5,10 +5,10 @@
          tooltip="Fillet with fixed radius"
          icon="icons/Features/fillet_fixed_radius.png">
       <multi_selector id="main_objects"
-                      label="Faces or/and edges"
+                      label="Faces, edges or/and solids"
                       icon=""
                       tooltip="Select objects"
-                      shape_types="edges faces"
+                      shape_types="edges faces solids"
                       use_choice="false"
                       concealment="true">
         <validator id="PartSet_DifferentObjects"/>
         <validator id="GeomValidators_Positive"/>
       </doublevalue>
     </box>
+    <box id="multiple_radiuses"
+         title="Multiple radiuses"
+         tooltip="Fillet with multiple radiuses"
+         icon="icons/Features/fillet_var_multiple_radiuses.png">
+      <toolbox id="by_point_method">
+        <box id="by_points"
+         title="By points"
+         tooltip="Fillet with multiple radiuses by points"
+         icon="icons/Features/fillet_multiradius_by_point.png">
+          <shape_selector id="edge_selected"
+                        icon="icons/Features/edge.png"
+                        label="Start"
+                        tooltip="Select edge"
+                        shape_types="edge">
+           <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
+          </shape_selector>
+          <multiradius-panel id="array_point_radius_by_point"
+            filter_points="false">
+            <validator id="GeomValidators_ShapeType" parameters="empty,vertex"/>
+          </multiradius-panel>
+        </box>
+        <box id="by_curvilinear_abscissa_methode"
+         title="By curvilinear abscissa"
+         tooltip="Fillet with multiple radiuses by curvilinear abscissa"
+         icon="icons/Features/fillet_multiradius_by_curv.png">
+          <shape_selector id="edge_selected"
+                        icon="icons/Features/edge.png"
+                        label="Start"
+                        tooltip="Select edge"
+                        shape_types="edge">
+           <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
+          </shape_selector>
+          <multiradiuscurv-panel id="array_point_radius_by_point"
+            filter_points="false">
+            <validator id="GeomValidators_ShapeType" parameters="empty,vertex"/>
+          </multiradiuscurv-panel>
+        </box>
+      </toolbox>
+    </box>
   </toolbox>
 </source>
diff --git a/src/FeaturesPlugin/icons/fillet_multiradius_by_curv.png b/src/FeaturesPlugin/icons/fillet_multiradius_by_curv.png
new file mode 100644 (file)
index 0000000..015d270
Binary files /dev/null and b/src/FeaturesPlugin/icons/fillet_multiradius_by_curv.png differ
diff --git a/src/FeaturesPlugin/icons/fillet_multiradius_by_point.png b/src/FeaturesPlugin/icons/fillet_multiradius_by_point.png
new file mode 100644 (file)
index 0000000..53dbb08
Binary files /dev/null and b/src/FeaturesPlugin/icons/fillet_multiradius_by_point.png differ
diff --git a/src/FeaturesPlugin/icons/fillet_var_multiple_radiuses.png b/src/FeaturesPlugin/icons/fillet_var_multiple_radiuses.png
new file mode 100644 (file)
index 0000000..56e4a78
Binary files /dev/null and b/src/FeaturesPlugin/icons/fillet_var_multiple_radiuses.png differ
index ce17e7cd1aab1a4ecbdfa1914a1c1a844c49d7d1..f3ad505143de196cfb971dc4156479851dc9f153 100644 (file)
@@ -2,7 +2,6 @@
   <multi_selector id="base_objects"
                   label="Base objects:"
                   tooltip="Select a base objects"
-                  shape_types="vertices edges wires faces shells compsolids"
                   use_choice="false"
                   concealment="true">
     <validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
index ba80beedda3367cc8fef29f58ce5dc4bcafa7734..74b60d59ac38b980f940926da5dfef4154d66d56 100644 (file)
         <source path="fillet1d_widget.xml"/>
       </feature>
       <feature id="Fillet" title="Fillet" tooltip="Perform fillet on face or edge"
-               icon="icons/Features/fillet.png" auto_preview="true" helpfile="filletFeature.html">
+               icon="icons/Features/fillet.png" auto_preview="false" helpfile="filletFeature.html">
         <source path="fillet_widget.xml"/>
       </feature>
       <feature id="Chamfer" title="Chamfer" tooltip="Perform chamfer on face or edge"
index 95e749c10d2d5263ee845b513f73b2659f70365e..a03ae213f7537d4a1653bfbd2bf1183de71810a5 100644 (file)
@@ -45,9 +45,11 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Placement.h
     GeomAlgoAPI_BREPImport.h
     GeomAlgoAPI_STEPImport.h
+    GeomAlgoAPI_STEPImportXCAF.h
     GeomAlgoAPI_IGESImport.h
     GeomAlgoAPI_BREPExport.h
     GeomAlgoAPI_STEPExport.h
+    GeomAlgoAPI_STLExport.h
     GeomAlgoAPI_IGESExport.h
     GeomAlgoAPI_Transform.h
     GeomAlgoAPI_ShapeTools.h
@@ -110,9 +112,11 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Placement.cpp
     GeomAlgoAPI_BREPImport.cpp
     GeomAlgoAPI_STEPImport.cpp
+    GeomAlgoAPI_STEPImportXCAF.cpp
     GeomAlgoAPI_IGESImport.cpp
     GeomAlgoAPI_BREPExport.cpp
     GeomAlgoAPI_STEPExport.cpp
+    GeomAlgoAPI_STLExport.cpp
     GeomAlgoAPI_IGESExport.cpp
     GeomAlgoAPI_Transform.cpp
     GeomAlgoAPI_ShapeTools.cpp
@@ -176,6 +180,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAlgoImpl
   ../ModelAPI
   ../XAO
+  ${PROJECT_SOURCE_DIR}/src/Locale
   ${OpenCASCADE_INCLUDE_DIR}
 )
 
index 1fc2b871fc3dca89376e1318093caf0d87230f79..65f908deda7f1ab2d82e7647c3b661733f321c87 100644 (file)
@@ -21,6 +21,8 @@
 #include <GeomAlgoAPI_DFLoader.h>
 
 #include <BRepFilletAPI_MakeFillet.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <gp_Pnt2d.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid,
@@ -41,6 +43,17 @@ GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid,
   build(theBaseSolid, theFilletEdges, theStartRadius, theEndRadius);
 }
 
+//=================================================================================================
+GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid,
+                                       const ListOfShape&  theFilletEdges,
+                                       const std::list<double>& theCurvCoord,
+                                       const std::list<double>& theRadiuses)
+{
+  if (theRadiuses.size()== 0 )
+    return;
+  build(theBaseSolid, theFilletEdges,theCurvCoord, theRadiuses);
+}
+
 //=================================================================================================
 void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid,
                                const ListOfShape&  theFilletEdges,
@@ -84,3 +97,55 @@ void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid,
   setShape(aShape);
   setDone(true);
 }
+
+//=================================================================================================
+void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid,
+                               const ListOfShape&  theFilletEdges,
+                               const std::list<double>& theCurvCoord,
+                               const std::list<double>& theRadiuses)
+{
+  if (!theBaseSolid || theFilletEdges.empty() || theRadiuses.size() == 0)
+    return;
+
+  // create fillet builder
+  BRepFilletAPI_MakeFillet* aFilletBuilder =
+      new BRepFilletAPI_MakeFillet(theBaseSolid->impl<TopoDS_Shape>());
+  setImpl(aFilletBuilder);
+  setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
+
+  // assign filleting edges
+  for (ListOfShape::const_iterator anIt = theFilletEdges.begin();
+       anIt != theFilletEdges.end(); ++anIt) {
+    if ((*anIt)->isEdge())
+      aFilletBuilder->Add( (*anIt)->impl<TopoDS_Edge>() );
+  }
+
+  TColgp_Array1OfPnt2d array(1, theRadiuses.size());
+  int i = 1;
+  std::list<double>::const_iterator itCurv = theCurvCoord.begin();
+  std::list<double>::const_iterator itRadius = theRadiuses.begin();
+  
+  for( ; itCurv != theCurvCoord.end(); ++itCurv, ++itRadius )
+  {
+    array.SetValue(i, gp_Pnt2d( (*itCurv) , (*itRadius)));
+    std::cout << "Value lance " << (*itCurv) << " "<< (*itRadius) << std::endl;
+    i++;
+  }
+  // assign fillet radii for each contour of filleting edges
+  int aNbContours = aFilletBuilder->NbContours();
+  for (int ind = 1; ind <= aNbContours; ++ind) {
+    aFilletBuilder->SetRadius(array, ind, 1);
+  }
+
+  // build and get result
+  aFilletBuilder->Build();
+  if (!aFilletBuilder->IsDone())
+    return;
+  TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aFilletBuilder->Shape());
+
+  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  aShape->setImpl(new TopoDS_Shape(aResult));
+  setShape(aShape);
+  setDone(true);
+}
\ No newline at end of file
index f986933df0a956ad49c60ae0958bf969f8072424..175a88717dd699c3196108a5bbf2b6b731b1839e 100644 (file)
@@ -24,6 +24,7 @@
 #include <GeomAlgoAPI_MakeShape.h>
 
 #include <GeomAPI_Shape.h>
+#include <vector>
 
 /// \class GeomAlgoAPI_Fillet
 /// \ingroup DataAlgo
@@ -48,6 +49,16 @@ public:
                                         const ListOfShape&  theFilletEdges,
                                         const double        theStartRadius,
                                         const double        theEndRadius);
+  
+  /// Run fillet operation with variable radius.
+  /// \param theBaseSolid    a changing solid
+  /// \param theFilletEdges  list of edges the fillet is performed on
+  /// \param theRadiuses  theradius of the fillet
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid,
+                                        const ListOfShape&  theFilletEdges,
+                                        const std::list<double>& theCurvCoord,
+                                        const std::list<double>& theRadiuses);
+
 
 private:
   /// Perform fillet operation.
@@ -60,6 +71,18 @@ private:
              const ListOfShape&  theFilletEdges,
              const double        theStartRadius,
              const double        theEndRadius = -1.0);
+
+  /// Perform fillet operation.
+  /// If theEndRadius is less than 0., the fixed radius fillet will be built.
+  /// \param theBaseSolid    a changing solid
+  /// \param theFilletEdges  list of edges the fillet is performed on
+  /// \param theCurvCoord    the coordinate of a point defines a relative parameter on the edge
+  /// \param theRadiuses     the corresponding value of the radius, and the radius evolves 
+  //                         between the first and last vertices of the contour of index 
+  void build(const GeomShapePtr& theBaseSolid,
+             const ListOfShape&  theFilletEdges,
+             const std::list<double>& theCurvCoord,
+             const std::list<double>& theRadiuses);
 };
 
 #endif
index 3a824f106861e2731ee49ecd3b3fea9d4707fe9a..9e20ba201236d835795da1b1939f42c0b63aabee 100644 (file)
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
 
+#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  anScalInterUnits,
                                           std::string& theError)
 {
+
   TopoDS_Shape aResShape;
 
   // Set "C" numeric locale to save numbers correctly
   // Kernel_Utils::Localizer loc;
-
   STEPControl_Reader aReader;
 
   //VSR: 16/09/09: Convert to METERS
@@ -89,7 +103,7 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
     if (status == IFSelect_RetDone) {
 
       // Regard or not the model units
-      if (theFormatName == "STEP_SCALE") {
+      if (!anScalInterUnits) {
         // set UnitFlag to units from file
         TColStd_SequenceOfAsciiString anUnitLengthNames;
         TColStd_SequenceOfAsciiString anUnitAngleNames;
@@ -194,3 +208,83 @@ std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
   aGeomShape->setImpl(new TopoDS_Shape(aResShape));
   return aGeomShape;
 }
+
+
+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)
+{
+  
+  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);
+
+  try {
+    OCC_CATCH_SIGNALS;
+
+    IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.c_str());
+
+    if (status == IFSelect_RetDone) {
+
+      // Regard or not the model units
+      if (!anScalInterUnits) {
+        // set UnitFlag to units from file
+        TColStd_SequenceOfAsciiString anUnitLengthNames;
+        TColStd_SequenceOfAsciiString anUnitAngleNames;
+        TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
+        aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
+        if (anUnitLengthNames.Length() > 0) {
+          TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
+          if (aLenUnits == "millimetre")
+            Interface_Static::SetCVal("xstep.cascade.unit", "MM");
+          else if (aLenUnits == "centimetre")
+            Interface_Static::SetCVal("xstep.cascade.unit", "CM");
+          else if (aLenUnits == "metre" || aLenUnits.IsEmpty())
+            Interface_Static::SetCVal("xstep.cascade.unit", "M");
+          else if (aLenUnits == "INCH")
+            Interface_Static::SetCVal("xstep.cascade.unit", "INCH");
+          else {
+            theError = "The file contains not supported units.";
+            aGeomShape->setImpl(new TopoDS_Shape());
+            return aGeomShape;
+          }
+          // TODO (for other units than mm, cm, m or inch)
+          //else if (aLenUnits == "")
+          //  Interface_Static::SetCVal("xstep.cascade.unit", "???");
+        }
+      }
+      else {
+        //cout<<"need re-scale a model"<<endl;
+        // set UnitFlag to 'meter'
+        Interface_Static::SetCVal("xstep.cascade.unit","M");
+      }
+    }
+  }
+  catch (Standard_Failure const& anException) {
+    theError = anException.GetMessageString();
+    aGeomShape->setImpl(new TopoDS_Shape());
+    return aGeomShape;
+  }
+
+  STEPCAFControl_Reader cafreader;
+  cafreader.SetColorMode(true);
+  cafreader.SetNameMode(true);
+  cafreader.SetMatMode(true);
+
+  if(cafreader.ReadFile(theFileName.c_str()) != IFSelect_RetDone) {
+    theError = "Wrong format of the imported file. Can't import file.";
+    std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+    aGeomShape->setImpl(new TopoDS_Shape());
+    return aGeomShape;
+  }
+
+  return readAttributes(cafreader,theResultBody,anMaterials, theMaterialShape, "STEP-XCAF");
+  }
+
index 470791a3bca3f27c7ad8a859b3e29a4f06522df1..9433a0a70bb88c07fe23b1d78e53c92349a0062e 100644 (file)
 #include <GeomAlgoAPI.h>
 
 #include <string>
-
 #include <GeomAPI_Shape.h>
 
+#include <ModelAPI_ResultBody.h>
+
+
 /// Implementation of the import STEP files algorithms
 GEOMALGOAPI_EXPORT
 std::shared_ptr<GeomAPI_Shape> STEPImport(const std::string& theFileName,
                                           const std::string& theFormatName,
+                                          const bool  anScalInterUnits,
                                           std::string& theError);
 
+/// 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);
+
 #endif /* GEOMALGOAPI_STEPIMPORT_H_ */
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp
new file mode 100644 (file)
index 0000000..3e2a700
--- /dev/null
@@ -0,0 +1,446 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#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 <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 <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 <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Iterator.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 <TColStd_SequenceOfAsciiString.hxx>
+
+#include <Standard_Failure.hxx>
+#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
+
+
+//=============================================================================
+/*!
+ *  GetShape()
+ */
+//=============================================================================
+
+TopoDS_Shape GetShape(const Handle(Standard_Transient)        &theEnti,
+                        const Handle(Transfer_TransientProcess) &theTP)
+{
+  TopoDS_Shape            aResult;
+  Handle(Transfer_Binder) aBinder = theTP->Find(theEnti);
+
+  if (aBinder.IsNull()) {
+    return aResult;
+  }
+
+  aResult = TransferBRep::ShapeResult(aBinder);
+
+  return aResult;
+}
+
+// ----------------------------------------------------------------------------
+
+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)
+{
+  // dummy XCAF Application to handle the STEP XCAF Document
+  Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
+  // XCAF Document to contain the STEP/IGES file itself
+  Handle(TDocStd_Document) doc;
+   // check if a file is already open under this handle, if so, close it to
+  // prevent segfaults when trying to create a new document
+  if(dummy_app->NbDocuments() > 0) {
+    dummy_app->GetDocument(1, doc);
+    dummy_app->Close(doc);
+  }
+
+  dummy_app->NewDocument( TCollection_ExtendedString("MDTV-CAF"), doc);
+  // transfer STEP/IGES into the document, and get the main label
+  reader.Transfer(doc);
+  TDF_Label mainLabel = doc->Main();
+  Handle_XCAFDoc_ShapeTool shapeTool = XCAFDoc_DocumentTool::ShapeTool(mainLabel);
+  Handle_XCAFDoc_ColorTool colorTool = XCAFDoc_DocumentTool::ColorTool(mainLabel);
+  Handle(XCAFDoc_MaterialTool) materialTool = XCAFDoc_DocumentTool::MaterialTool(mainLabel);
+  // traverse the labels recursively to set attributes on shapes
+  setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel,
+                     TopLoc_Location(),theResultBody,theMaterialShape,false);
+
+     
+  std::shared_ptr<GeomAPI_Shape> ageom =  setgeom(shapeTool,mainLabel);
+  STEPControl_Reader aReader = reader.ChangeReader();   
+  
+  // BEGIN: reading materials of sub-shapes from file
+  if ( anMaterials )
+  {
+    TopTools_IndexedMapOfShape anIndices;
+    TopExp::MapShapes(ageom->impl<TopoDS_Shape>(), anIndices);
+
+    Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
+    Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
+    if (!TR.IsNull()) {
+      Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
+
+      Standard_Integer nb = Model->NbEntities();
+
+      for (Standard_Integer ie = 1; ie <= nb; ie++) {
+        Handle(Standard_Transient) enti = Model->Value(ie);
+
+        // Store materials.
+        StoreMaterial(theResultBody,enti, anIndices, TP, mainLabel,theMaterialShape);
+      }
+    }
+  }
+
+  return ageom;                                  
+}
+
+std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
+                                       const TDF_Label &label)
+{
+  BRep_Builder B;
+  TopoDS_Compound compound;
+  B.MakeCompound(compound);
+
+  TDF_LabelSequence frshapes;
+  shapeTool->GetShapes(frshapes);
+
+  std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+
+  if (frshapes.Length() == 0) {
+      aGeomShape->setImpl(new TopoDS_Shape());
+      return aGeomShape;
+  } else if (frshapes.Length() == 1) {
+    TopoDS_Shape shape = shapeTool->GetShape(frshapes.Value(1));
+    aGeomShape->setImpl(new TopoDS_Shape(shape));
+    return aGeomShape;
+  } 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) ) {
+          if (S.IsNull()) {
+            continue;
+          }
+          else {
+            B.Add(compound, S);
+          }
+        }
+      }
+    }
+    TopoDS_Shape shape = compound;
+    aGeomShape->setImpl(new TopoDS_Shape(shape));
+    return aGeomShape;
+  }
+}
+
+void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
+                                    const Handle(XCAFDoc_ColorTool) &colorTool,
+                                    const Handle(XCAFDoc_MaterialTool) &materialTool,
+                                    const TDF_Label &label,
+                                    const TopLoc_Location &loc,
+                                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                    std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
+                                    bool isRef)
+{
+  std::wstring shapeName;
+  Handle(TDataStd_Name) n;
+
+  if(label.FindAttribute(TDataStd_Name::GetID(), n)) {
+    TCollection_ExtendedString name = n->Get();
+
+    shapeName =  Locale::Convert::toWString(TCollection_AsciiString(name).ToCString()) ;
+  }
+  TopLoc_Location partLoc = loc;
+  Handle(XCAFDoc_Location) l;
+  if(label.FindAttribute(XCAFDoc_Location::GetID(), l)) {
+    if(isRef)
+      partLoc = partLoc * l->Get();
+    else
+      partLoc = l->Get();
+  }
+
+  TDF_Label ref;
+  if(shapeTool->IsReference(label) && shapeTool->GetReferredShape(label, ref)) {
+
+    setShapeAttributes( shapeTool, colorTool, materialTool, ref,
+                        partLoc,theResultBody,theMaterialShape,true);
+  }
+  if( shapeTool->IsSimpleShape(label) && (isRef || shapeTool->IsFree(label))) {
+
+    TopoDS_Shape shape = shapeTool->GetShape(label);
+
+    std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
+    if (!loc.IsIdentity()){
+        shape.Move(loc);
+    }
+    aShapeGeom->setImpl(new TopoDS_Shape(shape));
+    shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
+
+
+    shape.Location(isRef ? loc : partLoc);
+    int dim =
+      (shape.ShapeType() == TopAbs_VERTEX) ?
+        0 :
+        (shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_WIRE) ?
+        1 :
+        (shape.ShapeType() == TopAbs_FACE ||
+         shape.ShapeType() == TopAbs_SHELL) ? 2 :3;
+
+    Handle(TCollection_HAsciiString) matName;
+    Handle(TCollection_HAsciiString) matDescription;
+    Standard_Real matDensity;
+    Handle(TCollection_HAsciiString) matDensName;
+    Handle(TCollection_HAsciiString) matDensValType;
+
+    if(materialTool->GetMaterial(label, matName, matDescription, matDensity,
+                                 matDensName, matDensValType)) {
+      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();
+      std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
+      theResultBody->addShapeColor(shapeName, ColRGB);
+    }
+    else if(colorTool->GetColor(label, XCAFDoc_ColorSurf, col)) {
+      double r = col.Red(), g = col.Green(), b = col.Blue();
+      std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
+      theResultBody->addShapeColor(shapeName, ColRGB);
+    }
+    else if(colorTool->GetColor(label, 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)};
+      theResultBody->addShapeColor(shapeName, ColRGB);
+    }
+    // check explicit coloring of boundary entities
+    if(dim == 3) {
+      TopExp_Explorer xp2(shape, TopAbs_FACE);
+      while(xp2.More()) {
+        if(colorTool->GetColor(xp2.Current(), XCAFDoc_ColorGen, col) ||
+           colorTool->GetColor(xp2.Current(), XCAFDoc_ColorSurf, col) ||
+           colorTool->GetColor(xp2.Current(), XCAFDoc_ColorCurv, col)) {
+          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; 
+          TopoDS_Shape shapeface = xp2.Current();
+          if (!loc.IsIdentity()){
+                  shapeface.Move(loc);
+          }
+          aShapeGeom->setImpl(new TopoDS_Shape(shapeface));
+          theResultBody->addShapeColor(
+          theResultBody->addShapeName(aShapeGeom , aNameFace.str()), ColRGB);
+        }
+        xp2.Next();
+      }
+    }
+    if(dim == 2) {
+      TopExp_Explorer xp1(shape, TopAbs_EDGE);
+      while(xp1.More()) {
+        if(colorTool->GetColor(xp1.Current(), XCAFDoc_ColorGen, col) ||
+           colorTool->GetColor(xp1.Current(), XCAFDoc_ColorSurf, col) ||
+           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; 
+           aNameEdge << L"Edge_"<< shapeName;
+           aShapeGeom->setImpl(new TopoDS_Shape(xp1.Current() ));
+           theResultBody->addShapeColor(
+           theResultBody->addShapeName(aShapeGeom , aNameEdge.str()), ColRGB);
+        }
+        xp1.Next();
+      }
+    }
+  }
+  else {
+    int indiceChild = 1;  
+
+    if (!shapeTool->IsReference(label)){
+      TopoDS_Shape shape = shapeTool->GetShape(label);
+
+      std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
+      if (!loc.IsIdentity()){
+          shape.Move(loc);
+      }
+      aShapeGeom->setImpl(new TopoDS_Shape(shape));
+      shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
+    }
+    for(TDF_ChildIterator it(label); it.More(); it.Next()) { 
+
+      setShapeAttributes( shapeTool, colorTool, materialTool,
+                         it.Value(), partLoc,theResultBody,theMaterialShape, isRef);
+      indiceChild++;
+    }
+  }
+}
+
+
+//=============================================================================
+  /*!
+   *  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 ir;
+
+                for(ir = 1; ir <= aRepr->NbItems(); ir++) {
+                  Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(ir);
+                  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()) {
+                          return;
+                        }
+                      }
+
+                      // as PRODUCT can be included in the main shape
+                      // several times, we look here for all iclusions.
+                      Standard_Integer isub, nbSubs = theIndices.Extent();
+
+                      for (isub = 1; isub <= nbSubs; isub++) {
+                        TopoDS_Shape aSub = theIndices.FindKey(isub);
+
+                        if (aSub.IsPartner(aShape)) {
+                          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()); 
+                          theMaterialShape[matName].push_back(nom);
+
+                        }
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h
new file mode 100644 (file)
index 0000000..2955a53
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOMALGOAPI_STEPIMPORTXCAF_H_
+#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 
+ GEOMALGOAPI_EXPORT
+ 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);
+ // read attributs for  label                                          
+ GEOMALGOAPI_EXPORT                            
+ void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
+                               const Handle(XCAFDoc_ColorTool) &colorTool,
+                               const Handle(XCAFDoc_MaterialTool) &materialTool,
+                               const TDF_Label &label,
+                               const TopLoc_Location &loc,
+                               std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                               std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
+                               bool isRef);
+
+// read geometry                              
+GEOMALGOAPI_EXPORT                              
+std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
+                                    const TDF_Label &label);
+
+// 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 );
+
+#endif /* GEOMALGOAPI_STEPIMPORTXCAF_H_ */
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp
new file mode 100644 (file)
index 0000000..e7d82b6
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GeomAlgoAPI_STLExport.h"
+
+#include "GeomAlgoAPI_Tools.h"
+
+#include <TopoDS_Shape.hxx>
+
+// OOCT includes
+#include <BRepBuilderAPI_Copy.hxx>
+#include <StlAPI_Writer.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepTools.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+
+
+
+#define MAX2(X, Y)      ( Abs(X) > Abs(Y) ? Abs(X) : Abs(Y) )
+#define MAX3(X, Y, Z)   ( MAX2 ( MAX2(X, Y) , Z ) )
+
+bool STLExport(const std::string& theFileName,
+                const std::string& /*theFormatName*/,
+                const std::shared_ptr<GeomAPI_Shape>& theShape,
+                const double aDeflection,
+                const bool anIsRelative, 
+                const bool anIsASCII,
+                std::string& theError)
+{
+  #ifdef _DEBUG
+  std::cout << "Export STl into file " << theFileName << std::endl;
+  #endif
+
+  if (!theShape.get()) {
+    theError = "STl Export failed: An invalid argument";
+    return false;
+  }
+
+  try
+  {
+    // Set "C" numeric locale to save numbers correctly
+    GeomAlgoAPI_Tools::Localizer loc;
+
+    double lDeflection = aDeflection;
+    StlAPI_Writer aWriter;
+    // copy source shape
+    BRepBuilderAPI_Copy aCopy( theShape->impl<TopoDS_Shape>(), Standard_False );
+    TopoDS_Shape aCopyShape = aCopy.Shape();
+    // ASCII mode
+    aWriter.ASCIIMode() = anIsASCII;
+    if ( anIsRelative ) {
+      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+      Bnd_Box bndBox;
+      BRepBndLib::Add( theShape->impl<TopoDS_Shape>(), bndBox );
+      bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+      lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * aDeflection;
+    }
+    //Compute triangulation
+    BRepTools::Clean( aCopyShape );
+    BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection );
+    aWriter.Write( aCopyShape, theFileName.c_str() );
+
+    return true;
+  }
+  catch( Standard_Failure )
+  {
+    theError = "Exception catched in STlExport";
+  }
+  return false;
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h
new file mode 100644 (file)
index 0000000..327dce4
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOMALGOAPI_STLEXPORT_H_
+#define GEOMALGOAPI_STLEXPORT_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <string>
+
+#include <GeomAPI_Shape.h>
+
+/// Implementation of the export STL files algorithms
+GEOMALGOAPI_EXPORT
+bool STLExport(const std::string& theFileName,
+                const std::string& /*theFormatName*/,
+                const std::shared_ptr<GeomAPI_Shape>& theShape,
+                const double aDeflection,
+                const bool anIsRelative, 
+                const bool anIsASCII,
+                std::string& theError);
+
+#endif /* GEOMALGOAPI_STLEXPORT_H_ */
index 2c32988e2188e13577ee28df27f657110fbb5c6c..63380e3e2cf3a95178608b0fa9bb9eff14abd6ef 100644 (file)
@@ -1226,7 +1226,8 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData,
 
 void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
                                 std::shared_ptr<ModelAPI_Result> theResult,
-                                const int theResultIndex)
+                                const int theResultIndex,
+                                const std::wstring& theNameShape)
 {
   theResult->init();
   theResult->setDoc(myDoc);
@@ -1240,11 +1241,15 @@ void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
       theResult->data()->setName(L"");
     } else {
       std::wstringstream aName;
-      aName << aNewName;
-      // if there are several results (issue #899: any number of result),
-      // add unique prefix starting from second
-      if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
-        aName << "_" << theResultIndex + 1;
+      if( theNameShape != L"" ){
+        aName << theNameShape;
+      }else{
+        aName << aNewName;
+        // if there are several results (issue #899: any number of result),
+        // add unique prefix starting from second
+        if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
+          aName << "_" << theResultIndex + 1;
+      }
       aNewName = aName.str();
     }
     theResult->data()->setName(aNewName);
@@ -1269,7 +1274,7 @@ 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::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());
@@ -1280,7 +1285,7 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
   }
   if (!aResult.get()) {
     aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
-    storeResult(theFeatureData, aResult, theIndex);
+    storeResult(theFeatureData, aResult, theIndex,theNameShape);
   }
   return aResult;
 }
index c929be8ce86a19d26b9a51b3e039d573b5cdf422..fe38115434b4c9ea78abfae516709ffc6df12a89 100644 (file)
@@ -124,7 +124,8 @@ class Model_Objects
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a body result
   std::shared_ptr<ModelAPI_ResultBody> createBody(
-      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0,
+     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);
@@ -219,12 +220,13 @@ 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,
-                   const int theResultIndex = 0);
+                   const int theResultIndex = 0,
+                   const std::wstring& theNameShape = L"");
 
   //! returns the label of result by index; creates this label if it was not created before
   TDF_Label resultLabel(const std::shared_ptr<ModelAPI_Data>& theFeatureData,
index 7d6918c6af9a06246a04e25d8bb4241cce6481e3..74b932c81d0abd7e2074a2a70e39fef8010adf87 100644 (file)
@@ -30,6 +30,8 @@
 #include <Events_Loop.h>
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Pnt.h>
 
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
@@ -233,6 +235,54 @@ 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; 
+}
+
+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;
+
+    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" ;
+}
+
+
+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();
+}
 void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
                                   const bool theShapeChanged)
 {
@@ -262,13 +312,31 @@ void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisS
       aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
       ResultBodyPtr aSub;
       if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
-        aSub = anObjects->createBody(this->data(), aSubIndex);
+        std::wstring thenameshape = L"";
+        // find shape name read
+        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;
+            break;
+        }
+        aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape);
+        //finf color read
+        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);
         if (isConcealed()) { // for issue #2579 note7
           aSub->ModelAPI_ResultBody::setIsConcealed(true);
           std::dynamic_pointer_cast<Model_ResultBody>(aSub)->updateConcealment();
         }
+        
       } else { // just update shape of this result
         aSub = mySubs[aSubIndex];
       }
index 94e9d9b7c1276ef43b7f7381a8aefc843e0d9316..fe39876429da461c9918f5f632d01160a65caf04 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);
 
@@ -134,6 +134,23 @@ protected:
     const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub);
 
   friend class Model_Objects;
+
+  // 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 
+  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;
+  // 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 
+  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; 
+
 };
 
 #endif
index 9127a9915cab6da6e7d1306a10cfc62007505ade..a0dfe058af820cd8a7ddb1221d1bd5994bfbc962 100644 (file)
@@ -190,14 +190,13 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
 #endif
   }
   // clear processed and fill modified recursively
-  std::set<FeaturePtr> aRefSet;
   const std::set<std::shared_ptr<ModelAPI_Attribute> >& aRefs = theFeature->data()->refsToMe();
   std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRefIter = aRefs.cbegin();
   for(; aRefIter != aRefs.cend(); aRefIter++) {
     if ((*aRefIter)->isArgument()) {
       FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
       if (aReferenced.get()) {
-        aRefSet.insert(aReferenced);
+        addModified(aReferenced, theFeature);
       }
     }
   }
@@ -212,21 +211,19 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
       if ((*aRIter)->isArgument()) {
         FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRIter)->owner());
         if (aReferenced.get()) {
-          aRefSet.insert(aReferenced);
+          addModified(aReferenced, theFeature);
         }
       }
     }
   }
+
   // also add part feature that contains this feature to the modified
   if (theFeature->document()->kind() != "PartSet") {
     FeaturePtr aPart = ModelAPI_Tools::findPartFeature(
       ModelAPI_Session::get()->moduleDocument(), theFeature->document());
     if (aPart.get())
-      aRefSet.insert(aPart);
+      addModified(aPart, theFeature);
   }
-  for(std::set<FeaturePtr>::iterator aRef = aRefSet.begin(); aRef != aRefSet.end(); aRef++)
-    addModified(*aRef, theFeature);
-
   return true;
 }
 
index dd2f4acd920a972c11e1a6715dc2eca41ec5d271..7b7876165946fb970b92faf8a221c3f33b3e7693 100644 (file)
@@ -117,7 +117,7 @@ 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)
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
@@ -131,6 +131,10 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Config
                     ${PROJECT_SOURCE_DIR}/src/GeomAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
                     ${PROJECT_SOURCE_DIR}/src/Locale
+                    ${OpenCASCADE_INCLUDE_DIR}
+                    ${OpenCASCADE_DataExchange_LIBRARIES}
+                    ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
+                    ${OpenCASCADE_ApplicationFramework_LIBRARIES}
 )
 
 
@@ -265,6 +269,4 @@ ADD_UNIT_TESTS(TestConstants.py
                Test19707.py
                Test19726.py
                Test19912.py
-               Test19932.py
-               Test19989.py
 )
index a700139ec7ce53c41961fce4f5020b03222ed4d1..811845db21fb82826513ecf48354a279e08184e8 100644 (file)
@@ -193,6 +193,11 @@ class ModelAPI_Feature : public ModelAPI_Object
   {
     return data()->intArray(theID);
   }
+  /// Returns the double array attribute by the identifier
+  inline std::shared_ptr<ModelAPI_AttributeDoubleArray> realArray(const std::string& theID)
+  {
+    return data()->realArray(theID);
+  }
   /// Returns the reference attribute by the identifier
   inline std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID)
   {
index c88fb08fcd8500e37246bd36b82de371899ab499..11fdd242171c577527f8302c4f8266a614133cd2 100644 (file)
@@ -24,6 +24,8 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_DataMapOfShapeShape.h>
 #include <string>
+#include <map>
+#include <vector>
 
 class ModelAPI_BodyBuilder;
 class GeomAlgoAPI_MakeShape;
@@ -182,11 +184,26 @@ 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                                      
+  MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0;
+  // find the name of shapp read in step file
+  MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theshape) = 0;
+
 
 protected:
   /// Default constructor accessible only from Model_Objects
   MODELAPI_EXPORT ModelAPI_ResultBody();
 
+  
+
 };
 
 //! Pointer on feature object
index 9824505804f5b5b877c16ccb51fc97d9bbedd125..d94749f5c267c60eb8acc57259b838a20e7f7d92 100644 (file)
@@ -126,6 +126,4 @@ ADD_UNIT_TESTS(
   Test2488.py
   Test18451.py
   Test19031.py
-  Test19990_1.py
-  Test19990_2.py
 )
index 9d2c5e5f0f96ca5eede7510c24473e650a8c86db..6d8affba893069289e3e0b5ae1a3b8d62f4a3d9c 100644 (file)
@@ -1505,12 +1505,12 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
       }
 
       if(isAdded) {
+        *myDumpStorage << ", ";
         // print each attribute on separate line with the appropriate shift
         if (aNbSpaces > 0) {
           std::string aSpaces(aNbSpaces + 1, ' ');
-          *myDumpStorage << ",\n" << aSpaces;
-        } else
-          *myDumpStorage << ", ";
+          *myDumpStorage << "\n" << aSpaces;
+        }
       } else {
         isAdded = true;
       }
index 333de514e0347ea08358160a39ab93727b500db7..a372090fe334c4dcdc7f2008b240b7f196a98040 100644 (file)
       SET_ATTRIBUTE(N_13, T_13, AN_13) \
     END_INIT() \
   public:
+//--------------------------------------------------------------------------------------
+#define INTERFACE_15(KIND, \
+                     N_0, AN_0, T_0, C_0, \
+                     N_1, AN_1, T_1, C_1, \
+                     N_2, AN_2, T_2, C_2, \
+                     N_3, AN_3, T_3, C_3, \
+                     N_4, AN_4, T_4, C_4, \
+                     N_5, AN_5, T_5, C_5, \
+                     N_6, AN_6, T_6, C_6, \
+                     N_7, AN_7, T_7, C_7, \
+                     N_8, AN_8, T_8, C_8, \
+                     N_9, AN_9, T_9, C_9, \
+                     N_10, AN_10, T_10, C_10, \
+                     N_11, AN_11, T_11, C_11, \
+                     N_12, AN_12, T_12, C_12, \
+                     N_13, AN_13, T_13, C_13, \
+                     N_14, AN_14, T_14, C_14) \
+  public: \
+    INTERFACE_COMMON(KIND) \
+    DEFINE_ATTRIBUTE(N_0, T_0, C_0) \
+    DEFINE_ATTRIBUTE(N_1, T_1, C_1) \
+    DEFINE_ATTRIBUTE(N_2, T_2, C_2) \
+    DEFINE_ATTRIBUTE(N_3, T_3, C_3) \
+    DEFINE_ATTRIBUTE(N_4, T_4, C_4) \
+    DEFINE_ATTRIBUTE(N_5, T_5, C_5) \
+    DEFINE_ATTRIBUTE(N_6, T_6, C_6) \
+    DEFINE_ATTRIBUTE(N_7, T_7, C_7) \
+    DEFINE_ATTRIBUTE(N_8, T_8, C_8) \
+    DEFINE_ATTRIBUTE(N_9, T_9, C_9) \
+    DEFINE_ATTRIBUTE(N_10, T_10, C_10) \
+    DEFINE_ATTRIBUTE(N_11, T_11, C_11) \
+    DEFINE_ATTRIBUTE(N_12, T_12, C_12) \
+    DEFINE_ATTRIBUTE(N_13, T_13, C_13) \
+    DEFINE_ATTRIBUTE(N_14, T_14, C_14) \
+  protected: \
+    START_INIT() \
+      SET_ATTRIBUTE(N_0, T_0, AN_0) \
+      SET_ATTRIBUTE(N_1, T_1, AN_1) \
+      SET_ATTRIBUTE(N_2, T_2, AN_2) \
+      SET_ATTRIBUTE(N_3, T_3, AN_3) \
+      SET_ATTRIBUTE(N_4, T_4, AN_4) \
+      SET_ATTRIBUTE(N_5, T_5, AN_5) \
+      SET_ATTRIBUTE(N_6, T_6, AN_6) \
+      SET_ATTRIBUTE(N_7, T_7, AN_7) \
+      SET_ATTRIBUTE(N_8, T_8, AN_8) \
+      SET_ATTRIBUTE(N_9, T_9, AN_9) \
+      SET_ATTRIBUTE(N_10, T_10, AN_10) \
+      SET_ATTRIBUTE(N_11, T_11, AN_11) \
+      SET_ATTRIBUTE(N_12, T_12, AN_12) \
+      SET_ATTRIBUTE(N_13, T_13, AN_13) \
+      SET_ATTRIBUTE(N_14, T_14, AN_14) \
+    END_INIT() \
+  public:
 
 //--------------------------------------------------------------------------------------
 #define INTERFACE_16(KIND, \
index bb5c6e39d12f0685a8eb7ceb21111894a2adc773..21df54023958ca84d37343e5786b1b51688c5c2e 100644 (file)
@@ -352,7 +352,7 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
     if (aSelectionType.empty())
       aSelectionListAttr->setSelectionType(myDefMode);
     else {
-      setCurrentShapeType(aSelectionType.c_str());
+      setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionType.c_str()));
       myDefMode = aSelectionType;
       myIsFirst = false;
     }
@@ -752,28 +752,23 @@ QIntList ModuleBase_WidgetMultiSelector::shapeTypes() const
   QIntList aShapeTypes;
 
   if (myShapeTypes.length() > 1 && myIsUseChoice) {
-    QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts);
-    for(QString aType: aTypes) {
-      aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
-    }
+    aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
   }
   else {
     foreach (QString aType, myShapeTypes) {
-      QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts);
-      for(QString aSubType: aSubTypes) {
-        aShapeTypes.append(ModuleBase_Tools::shapeType(aSubType));
-      }
+      aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
     }
   }
   return aShapeTypes;
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const QString& theShapeType)
+void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const int theShapeType)
 {
   int idx = 0;
   foreach (QString aShapeTypeName, myShapeTypes) {
-    if(aShapeTypeName == theShapeType && idx != myTypeCtrl->value()) {
+    int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
+    if(aRefType == theShapeType && idx != myTypeCtrl->value()) {
       updateSelectionModesAndFilters(false);
       bool isBlocked = myTypeCtrl->blockSignals(true);
       myTypeCtrl->setValue(idx);
index 946b46d77f9c0392143b72978f69a17400192038..8e788d6552e40aab0e9f3f3a3f9ec7170c860b5d 100644 (file)
@@ -182,7 +182,7 @@ protected:
   virtual QIntList shapeTypes() const;
 
   /// Set current shape type for selection
-  void setCurrentShapeType(const QString& theShapeType);
+  void setCurrentShapeType(const int theShapeType);
 
   /// Return the attribute values wrapped in a list of viewer presentations
   /// \return a list of viewer presentations, which contains an attribute result and
index ab8f1791cbc4b4604acfc189621970fa94a3a2fe..c8068e18ca7b7a6d77f456c2b45c8ef7cdd8f7a1 100644 (file)
@@ -284,22 +284,19 @@ bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValu
       Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
       const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
       GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
-
       if (aPnt) {
-        //isDone = setPoint(aPnt->x(), aPnt->y());
-        //setConstraintToPoint(aPnt->x(), aPnt->y(), aValue);
-        processSelection(aValue, aPnt->x(), aPnt->y());
-        isDone = true;
+        isDone = setPoint(aPnt->x(), aPnt->y());
+        setConstraintToPoint(aPnt->x(), aPnt->y(), aValue);
       }
     }
   }
   return isDone;
 }
 
-//void PartSet_WidgetPoint2D::selectContent()
-//{
-// // myXSpin->selectAll();
-//}
+void PartSet_WidgetPoint2D::selectContent()
+{
+ // myXSpin->selectAll();
+}
 
 bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
 {
@@ -557,36 +554,12 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
     aFirstValue = myPreSelected;
   }
 
-  double aX=0, aY=0;
-  bool aHasPoint = false;
-  if (aFirstValue.get()) {
-    GeomShapePtr aShape = aFirstValue->shape();
-    if (aShape->shapeType() == TopAbs_VERTEX) {
-      const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
-      GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
-      aX = aPnt->x();
-      aY = aPnt->y();
-      aHasPoint = true;
-    }
-  }
-  if (!aHasPoint) {
-    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-    PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
-  }
-  processSelection(aFirstValue, aX, aY);
-}
-
-void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theValue,
-  double theX, double theY)
-{
-  if (!setPoint(theX, theY))
-    return;
   // if we have selection and use it
-  if (theValue.get() && isValidSelectionCustom(theValue) && theValue->shape().get()) {
-    /// Trihedron Axis may be selected, but shape is empty
-    GeomShapePtr aGeomShape = theValue->shape();
+  if (aFirstValue.get() && isValidSelectionCustom(aFirstValue) &&
+      aFirstValue->shape().get()) { /// Trihedron Axis may be selected, but shape is empty
+    GeomShapePtr aGeomShape = aFirstValue->shape();
     TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
-    ObjectPtr aObject = theValue->object();
+    ObjectPtr aObject = aFirstValue->object();
 
     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
     bool anExternal = false;
@@ -612,12 +585,34 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
       }
     }
     if (anExternal) {
-      if (!isFeatureContainsPoint(myFeature, theX, theY)) {
-        if (aShape.ShapeType() == TopAbs_EDGE) {
+      GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
+      double aX = 0, aY = 0;
+      if (aPnt) {
+        aX = aPnt->x();
+        aY = aPnt->y();
+      }
+      if (aPnt && isFeatureContainsPoint(myFeature, aX, aY)) {
+        // do not create a constraint to the point, which already used by the feature
+        // if the feature contains the point, focus is not switched
+        setPoint(aX, aY);
+      }
+      else {
+        if (aPnt)
+          setPoint(aX, aY);
+        else {
+          if (aShape.ShapeType() == TopAbs_EDGE) {
+            // point is taken from mouse event and set in attribute. It should be done before set
+            // coinident constraint to the external line. If a point is created, it should be in
+            // the mouse clicked point
+            gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(),
+                                                               theWindow->v3dView());
+            PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
+            setPoint(aX, aY);
+          }
           setValueState(Stored); // in case of edge selection, Apply state should also be updated
         }
         bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX ||
-                              isOrphanPoint(aSelectedFeature, mySketch, theX, theY);
+                              isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
         if (anExternal) {
           // we should not stop reentrant operation on external objects because
           anOrphanPoint = true;
@@ -625,7 +620,7 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
           if (aShape.ShapeType() == TopAbs_VERTEX) {
             FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
             if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
-              anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, theX, theY);
+              anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY);
             }
           }
         }
@@ -642,21 +637,33 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
         emit focusOutWidget(this);
       }
     }
-    else {
-      if (!isFeatureContainsPoint(myFeature, theX, theY)) {
+    if (!anExternal) {
+      GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
+      if (aPnt && isFeatureContainsPoint(myFeature, aPnt->x(), aPnt->y())) {
+        // when the point is selected, the coordinates of the point should be set into the attribute
+        // if the feature contains the point, focus is not switched
+        setPoint(aPnt->x(), aPnt->y());
+      }
+      else {
         double aX = 0, aY = 0;
         bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
         // do not set a coincidence constraint in the attribute if the feature contains a point
         // with the same coordinates. It is important for line creation in order to do not set
         // the same constraints for the same points, oterwise the result line has zero length.
         bool isAuxiliaryFeature = false;
-        if (aShape.ShapeType() == TopAbs_VERTEX) {
-          setConstraintToPoint(theX, theY, theValue);
+        if (aPnt) {
+          aX = aPnt->x();
+          aY = aPnt->y();
+          setPoint(aX, aY);
+          setConstraintToPoint(aX, aY, aFirstValue);
         }
         else if (aShape.ShapeType() == TopAbs_EDGE) {
           // point is taken from mouse event and set in attribute. It should be done before setting
           // coinident constraint to the external line. If a point is created, it should be in
           // the mouse clicked point
+          gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
+          PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
+          setPoint(aX, aY);
           setConstraintToObject(aObject);
           setValueState(Stored); // in case of edge selection, Apply state should also be updated
           isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject);
@@ -676,9 +683,9 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
     }
   }
   // The selection could be a center of an external circular object
-  else if (theValue.get() && (!theValue->interactive().IsNull())) {
+  else if (aFirstValue.get() && (!aFirstValue->interactive().IsNull())) {
     Handle(PartSet_CenterPrs) aAIS =
-        Handle(PartSet_CenterPrs)::DownCast(theValue->interactive());
+        Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive());
     if (!aAIS.IsNull()) {
       gp_Pnt aPntComp = aAIS->Component()->Pnt();
       GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z()));
@@ -698,6 +705,12 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
       // external objects e.g. selection of trihedron axis when input end arc point
       updateObject(feature());
 
+      GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
+      if (aPnt) {
+        // do not create a constraint to the point, which already used by the feature
+        // if the feature contains the point, focus is not switched
+        setPoint(aPnt->x(), aPnt->y());
+      }
       emit vertexSelected(); // it stops the reentrant operation
       myPreSelected.reset();
       emit focusOutWidget(this);
@@ -705,9 +718,12 @@ void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theV
   }
   else {
     // A case when point is taken from mouse event
+    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
+    double aX = 0, aY = 0;
+    PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
 
     // if the feature contains the point, focus is not switched
-    if (isFeatureContainsPoint(myFeature, theX, theY))
+    if (!setPoint(aX, aY) || isFeatureContainsPoint(myFeature, aX, aY))
       return;
 
     myPreSelected.reset();
index f0a06a8ecb0cb5a129b2cd84dcabebc7c7e10ea0..19846bfe7762cb83c3819fb1b8a3e5e8b4960945 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <ModelAPI_CompositeFeature.h>
 #include <ModuleBase_ModelWidget.h>
-#include <ModuleBase_ViewerPrs.h>
 
 #include <QObject>
 
@@ -99,7 +98,7 @@ Q_OBJECT
                             const bool theToValidate);
 
   /// Select the internal content if it can be selected. It is empty in the default realization
-  //virtual void selectContent();
+  virtual void selectContent();
 
   /// Returns list of widget controls
   /// \return a control list
@@ -223,13 +222,6 @@ protected:
    /// \return true if succed
    bool setConstraintToObject(const ObjectPtr& theObject);
 
-   /// Process selected value
-   /// \param theValue the selected object
-   /// \param theX X coordinate of clicked point
-   /// \param theY Y coordinate of clicked point
-   void processSelection(const ModuleBase_ViewerPrsPtr& theValue, double theX, double theY);
-
-
 public:
    /// Returns if the feature is an orphan point, circle or an arc. Returns true if it
    /// has no a coincident to other lines. It processes point, circle and arc features
index 6d570d985d62217ca4609c5b8e9745bb799b3fcc..3fe190981afe16bd41d069bc8916c01f82f57e5b 100644 (file)
@@ -307,17 +307,11 @@ QIntList PartSet_WidgetSketchCreator::shapeTypes() const
 {
   QIntList aShapeTypes;
   if (myShapeTypes.length() > 1 && myIsUseChoice) {
-    QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts);
-    foreach(QString aType, aTypes) {
-      aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
-    }
+    aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
   }
   else {
     foreach(QString aType, myShapeTypes) {
-      QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts);
-      foreach(QString asubType, aSubTypes) {
-        aShapeTypes.append(ModuleBase_Tools::shapeType(asubType));
-      }
+      aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
     }
   }
   return aShapeTypes;
index a37fdd6784b19b40d9b4e267ac4d8aef19eb874d..84b62bcc3e4ee37ca2144914a17b9f4452d931d5 100644 (file)
@@ -19,7 +19,7 @@
 """Package for Exchange plugin for the Parametric Geometry API of the Modeler.
 """
 
-from ExchangeAPI import addImport, exportToFile, exportToXAO
+from ExchangeAPI import addImport, addImportStep, exportToFile, exportToXAO, exportToSTL
 from ExchangeAPI import exportPart, importPart
 
 from .tools import *