]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'V9_3_BR'
authorvsr <vsr@opencascade.com>
Mon, 6 May 2019 11:13:51 +0000 (14:13 +0300)
committervsr <vsr@opencascade.com>
Mon, 6 May 2019 11:13:51 +0000 (14:13 +0300)
34 files changed:
CMakeLists.txt
doc/gui/tutorial.py
make.sh
src/BuildPlugin/BuildPlugin_Validators.cpp
src/BuildPlugin/doc/images/Face.png
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/ConstructionAPI/ConstructionAPI_Point.h
src/ConstructionPlugin/Test/TestPoint_VertexSelection.py
src/ExchangePlugin/Test/TestExport.py
src/ExchangePlugin/Test/TestImport.py
src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace2.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/Model/Model_Data.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/PythonAPI/model/construction/__init__.py
src/XGUI/XGUI_DataModel.cpp
test.hdfs/CMakeLists.txt [new file with mode: 0644]
test.hdfs/delta_p.py [new file with mode: 0644]
test.hdfs/roselend.py [new file with mode: 0644]
test.hdfs/te_fluide.py [new file with mode: 0644]
test.hdfs/te_solide.py [new file with mode: 0644]
test.hdfs/test.py [new file with mode: 0644]
test.hdfs/test_hdf.py [new file with mode: 0644]
test.hdfs/usine.py [new file with mode: 0644]
test.sh

index 03dd2579fc6e4b7ec4c2bbabc4ab9a39194a75d1..cab33dbc4ec6bd7fb949dd3a27de6fa058d29f16 100644 (file)
@@ -183,6 +183,10 @@ IF(ADD_COMPATIBILITY_TESTS)
   ADD_CUSTOM_TARGET(run_compatibility_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -LE "tests_compatibility")
 ENDIF(ADD_COMPATIBILITY_TESTS)
 
+IF(ADD_HDF_TESTS)
+  ADD_SUBDIRECTORY (test.hdfs)
+ENDIF(ADD_HDF_TESTS)
+
 IF(SHAPER_BUILD_DOC)
     INCLUDE(FindSphinx)
     ADD_SUBDIRECTORY (doc)
index 08e75f0edb584c9deb302b2b33b84925040d5be6..ade5fc561e98e5fdddd5e7ba37be9997395af4bf 100644 (file)
@@ -63,8 +63,8 @@ Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Face_1_
 
 # Step5. Extrusion.
 Wire = model.selection("WIRE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_1r_wire")
-To = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_2")
-From = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_7")
+To = model.selection("FACE", "Revolution_1_1/Generated_Face&Point_4/Point_4")
+From = model.selection("FACE", "Revolution_1_1/Generated_Face&Point_1/Point_1")
 
 Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "PartSet/OZ"), To, 0, From, 0)
 
@@ -72,7 +72,7 @@ Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "Pa
 Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Extrusion_1_1")])
 
 # Step7. Fillet.
-Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_3][Common_1_1/Modified_Face&Face_1_1/Edge_4]")], 10)
+Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Point_6/Point_6][Common_1_1/Modified_Face&Point_7/Point_7]")], 10)
 
 # Step8. Box.
 Box_1 = model.addBox(Part_1_doc, 20, 120, 20)
@@ -87,5 +87,4 @@ AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Tr
 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fillet_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")])
 Cut_1.result().setColor(255, 214, 0)
 
-model.do()
 model.end()
diff --git a/make.sh b/make.sh
index dcb39447e4cc93b21d7d3e1116bc23ff60d7a8c8..49d78c1f49a41d9d2aec9bc930821cf47f23b364 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -21,6 +21,10 @@ while [[ $# > 0 ]]; do
       ADD_COMPATIBILITY_TESTS=TRUE
       shift
       ;;
+    hdf|test-hdf-models)
+      ADD_HDF_TESTS=TRUE
+      shift
+      ;;
     *)
       shift
       ;;
@@ -41,6 +45,7 @@ CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release}"
 CMAKE_ARGS="${CMAKE_ARGS} -DUSE_TEST_COVERAGE=${USE_TEST_COVERAGE:-OFF}"
 CMAKE_ARGS="${CMAKE_ARGS} -DADD_MODELS_TESTS=${ADD_MODELS_TESTS:-FALSE}"
 CMAKE_ARGS="${CMAKE_ARGS} -DADD_COMPATIBILITY_TESTS=${ADD_COMPATIBILITY_TESTS:-FALSE}"
+CMAKE_ARGS="${CMAKE_ARGS} -DADD_HDF_TESTS=${ADD_HDF_TESTS:-FALSE}"
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${SHAPER_ROOT_DIR}"
 CMAKE_ARGS="${CMAKE_ARGS} ${SOURCES_DIR}"
 
index 4c7c8a4fc8afbbceb1fb1f1b6a1820c95730cc1f..45d859844be13e4e08a845d0aec964426cbdbd38 100644 (file)
@@ -343,20 +343,24 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt
                                                       Events_InfoMessage& theError) const
 {
   if(theArguments.size() != 1) {
+    // LCOV_EXCL_START
     std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
       "1 parameter(Sketch feature id).";
     Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
+    // LCOV_EXCL_STOP
   }
 
   // Get base objects list.
   if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+    // LCOV_EXCL_START
     std::string aMsg =
       "Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
       "%1\"\n Only \"%2\" supported.";
     Events_InfoMessage("BuildPlugin_Validators", aMsg).
       arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
+    // LCOV_EXCL_STOP
   }
   AttributeSelectionListPtr aSelectionList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
@@ -444,12 +448,14 @@ bool BuildPlugin_ValidatorFillingSelection::isValid(const AttributePtr& theAttri
 {
   // Get base objects list.
   if (theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+    // LCOV_EXCL_START
     std::string aMsg =
       "Error: BuildPlugin_ValidatorFillingSelection does not support attribute type \""
       "%1\"\n Only \"%2\" supported.";
     Events_InfoMessage("BuildPlugin_Validators", aMsg).
       arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
+    // LCOV_EXCL_STOP
   }
   AttributeSelectionListPtr aSelectionList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
index 947440c834448a49396755052b7ef8bf07c6313e..b4e1c2a27cd440c02d393d79ddc6786dee79354d 100644 (file)
Binary files a/src/BuildPlugin/doc/images/Face.png and b/src/BuildPlugin/doc/images/Face.png differ
index c650cf48272ac933bacaf73a741fece63dd7f44f..fdc684cc3b849dda2f57b1585bb35cd664e98e70 100644 (file)
@@ -38,6 +38,7 @@ Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void*
   myUseInput = false;
   myNestedFeatures = "";
   myModal = false;
+  myIsTitleInToolbar = true;
   myIsApplyContinue = false;
 }
 
@@ -161,6 +162,11 @@ bool Config_FeatureMessage::isAutoPreview() const
   return myIsAutoPreview;
 }
 
+bool Config_FeatureMessage::isTitleInToolbar() const
+{
+  return myIsTitleInToolbar;
+}
+
 bool Config_FeatureMessage::isModal() const
 {
   return myModal;
@@ -225,4 +231,9 @@ const std::string& Config_FeatureMessage::helpFileName() const
 void Config_FeatureMessage::setHelpFileName(const std::string& aName)
 {
   myHelpFile = aName;
-}
\ No newline at end of file
+}
+
+void Config_FeatureMessage::setTitleInToolbar(bool theValue)
+{
+  myIsTitleInToolbar = theValue;
+}
index f4936056dbfe26986da43ca9bc2b4480a35e7acc..a027bec60b1df6e551dfa516bfba51af2f57ac00 100644 (file)
@@ -54,6 +54,7 @@ class Config_FeatureMessage : public Events_Message
   bool myInternal;  ///<Internal feature without GUI representation
   bool myModal;     ///<True if the feature has to be represented by modal dialog box
   bool myIsAutoPreview; ///< Preview computation is performed automatically
+  bool myIsTitleInToolbar; ///< False if title should not be displayed in the toolbar
 
   /// True if the feature can have Apply/Continue button in its property panel
   bool myIsApplyContinue;
@@ -115,11 +116,10 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT bool isModal() const;
   /// If true - the feature can have Apply/Continue button in its property panel
   CONFIG_EXPORT bool isApplyContinue() const;
-
-
-
   /// If true - preview of the feature is done by any modification of the feature attributes
   CONFIG_EXPORT bool isAutoPreview() const;
+  /// If true - title should normally be displayed in the toolbar
+  CONFIG_EXPORT bool isTitleInToolbar() const;
 
   ///Set feature's Id
   CONFIG_EXPORT void setId(const std::string& id);
@@ -155,6 +155,8 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT void setAutoPreview(bool isAutoPreview);
   ///Set modality state; If true - the feature will be represented by modal dialog box GUI
   CONFIG_EXPORT void setModal(bool isModal);
+  ///Set flag to display title in toolbar
+  CONFIG_EXPORT void setTitleInToolbar(bool theValue);
   ///Set Apply/Continue state;
   ///If true - the feature can have Apply/Continue button in its property panel
   CONFIG_EXPORT void setApplyContinue(bool isModal);
index 719dd5eb136c5affbf1b8c74fb20d4dab2ab7649..16da267c6fa950021871982cf609f2fc017bb287 100644 (file)
@@ -181,8 +181,11 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
 
   std::string aText = Config_Translator::translate(anId, getProperty(theFeatureNode, FEATURE_TEXT));
   outFeatureMessage->setText(aText);
-  std::string aToolTip = Config_Translator::translate(anId,
-                                                      getProperty(theFeatureNode, FEATURE_TOOLTIP));
+  bool isTitleInToolbar = getBooleanAttribute(theFeatureNode, FEATURE_TITLE_IN_TOOLBAR, true);
+  outFeatureMessage->setTitleInToolbar(isTitleInToolbar);
+  //std::string aToolTip = Config_Translator::translate(
+  //  anId, getProperty(theFeatureNode, FEATURE_TOOLTIP));
+  //outFeatureMessage->setTooltip(aToolTip);
   outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON));
   outFeatureMessage->setKeysequence(getProperty(theFeatureNode, FEATURE_KEYSEQUENCE));
   std::string aHelpFile = getProperty(theFeatureNode, HELP_FILE);
index 2d30633da83096feaa3f39cf5454d761f6e57cd0..ca31903ec3246de1d593ebaa9c0f8fb85faa2b62 100644 (file)
@@ -83,6 +83,7 @@ const static char* FEATURE_DOC = WORKBENCH_DOC;
 const static char* FEATURE_MODAL = "modal";
 const static char* FEATURE_APPLY_CONTINUE = "apply_continue";
 const static char* FEATURE_AUTO_PREVIEW = "auto_preview";
+const static char* FEATURE_TITLE_IN_TOOLBAR = "titleInToolbar";
 // NODE_VALIDATOR properties
 const static char* _PARAMETERS = "parameters";
 
index 5fa78bf6727063e672a58ec4fd0be1e56181bebc..d4f073f1b2ceb5671d29e9c7f980bf963ec8a568 100644 (file)
@@ -109,14 +109,15 @@ ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feat
 //==================================================================================================
 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                              const ModelHighAPI_Selection& theObject,
-                                             const bool theIsCircularEdge)
+                                             const bool theIsCircularEdge,
+                                             const bool theIsXYZSelection)
 : ModelHighAPI_Interface(theFeature)
 {
   if (initialize())
   {
     if (theIsCircularEdge) {
       setByCenterOfCircle(theObject);
-    } else if (theObject.shapeType() == "VERTEX") {
+    } else if (theObject.shapeType() == "VERTEX" && theIsXYZSelection) {
       // This is tricky way to get vertex shape.
       fillAttribute(theObject, mypointToProject);
       GeomShapePtr aShape = mypointToProject->value();
@@ -165,13 +166,6 @@ void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX,
                                      const ModelHighAPI_Double& theY,
                                      const ModelHighAPI_Double& theZ)
 {
-  //fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
-
-  // TODO: Fill point attribute
-  //fillAttribute(theX, myx);
-  //fillAttribute(theY, myy);
-  //fillAttribute(theZ, myz);
-
   fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
   fillAttribute(theX, theY, theZ, mypoint);
 
@@ -276,6 +270,8 @@ void ConstructionAPI_Point::setByCenterOfGravity(const ModelHighAPI_Selection& t
   fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY(),
                 mygeometricalPropertyType);
   fillAttribute(theObject, myobjectForCenterOfGravity);
+
+  execute();
 }
 
 //==================================================================================================
@@ -286,6 +282,8 @@ void ConstructionAPI_Point::setByCenterOfCircle(const ModelHighAPI_Selection& th
   fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE(),
                 mygeometricalPropertyType);
   fillAttribute(theObject, myobjectForCenterOfCircle);
+
+  execute();
 }
 
 //==================================================================================================
@@ -416,3 +414,11 @@ PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
   return PointPtr(new ConstructionAPI_Point(aFeature, theObject, theIsCircularEdge));
 }
+
+//==================================================================================================
+PointPtr addPointXYZ(const std::shared_ptr<ModelAPI_Document> & thePart,
+                     const ModelHighAPI_Selection& theObject)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
+  return PointPtr(new ConstructionAPI_Point(aFeature, theObject, false, true));
+}
index 96376b481efe66626ffcda3b1ca5de5e8796f50b..ce20c53990f1018f27ba8f3d52680ecb673e5cee 100644 (file)
@@ -70,10 +70,12 @@ public:
                         const ModelHighAPI_Selection& theObject3);
 
   /// Constructor with values: object and circular edge flag.
+  /// May be used for creation of point by coordinates using selection-vertex.
   CONSTRUCTIONAPI_EXPORT
   ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                         const ModelHighAPI_Selection& theObject,
-                        const bool theIsCircularEdge = false);
+                        const bool theIsCircularEdge = false,
+                        const bool theIsXYZSelection = false);
 
   /// Destructor.
   CONSTRUCTIONAPI_EXPORT
@@ -235,4 +237,10 @@ PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
                   const ModelHighAPI_Selection& theObject,
                   const bool theIsCircularEdge = false);
 
+/// \ingroup CPPHighAPI
+/// \brief Create Point feature by coordinates using the selected vertex.
+CONSTRUCTIONAPI_EXPORT
+PointPtr addPointXYZ(const std::shared_ptr<ModelAPI_Document> & thePart,
+                     const ModelHighAPI_Selection& theObject);
+
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_POINT_H_ */
index d3cad72ef4d2622a46cd26716dbbff4b925ec79a..269630bd014fff1758ef55d5ad7818da62677293 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+from SketchAPI import *
 from salome.shaper import model
 
 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)
-Point_2 = model.addPoint(Part_1_doc, 10, 0, 10)
+
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_1 = Sketch_1.addLine(10, 10, 0, 10)
+SketchLine_2 = Sketch_1.addLine(0, 10, 0, 0)
+SketchLine_3 = Sketch_1.addLine(0, 0, 10, 0)
+SketchLine_4 = Sketch_1.addLine(10, 0, 10, 10)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 10)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 10)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
 model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0)
+Point_2 = model.addPointXYZ(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"))
 model.end()
 
 from GeomAPI import GeomAPI_Vertex
index 353e7ea2cceb2066a797cdf54cf47acd57e45b84..2d87156987ffbe39653f56a59cd5f65014876a45 100644 (file)
@@ -172,15 +172,15 @@ if __name__ == '__main__':
         #=========================================================================
         # Export a shape into STEP
         #=========================================================================
-        testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17)
-        testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.78825807533e-06, 10 ** -17)
-        testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17)
+        testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17)
+        testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.788258075329978e-06, 10 ** -17)
+        testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17)
         #=========================================================================
         # Export a shape into IGES
         #=========================================================================
-        testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
-        testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 3.78829613776e-06, 10 ** -17)
-        testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
+        testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17)
+        testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 0.0019293313766693052, 10 ** -17)
+        testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17)
         testExport("IGES-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17)
         testExport("IGS-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17)
         #=========================================================================
index 587fa615a8faf37151267aa0060ddea69b4e869b..66ebe0dca8f8a44d9b8feceeaf4ed74661bad41f 100644 (file)
@@ -147,9 +147,9 @@ if __name__ == '__main__':
         # Create a shape imported from IGES
         #=========================================================================
         shape_path = getShapePath("Iges/bearing.igs")
-        testImport("IGES", shape_path, 6.86970803067e-14, 10 ** -25)
+        testImport("IGES", shape_path, 1.3407098545036494e-08, 10 ** -25)
         shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "bearing.iges"))
-        testImport("IGS", shape_path, 6.86970803067e-14, 10 ** -25)
+        testImport("IGS", shape_path, 1.3407098545036494e-08, 10 ** -25)
 
         #=========================================================================
         # Create a shape imported from XAO
index 24a0de7e7b1cbddbb950deafdfbdd43c4fe8ffd3..370efa3a6d76bb3ab73850afd123e344f8f327a7 100644 (file)
@@ -86,65 +86,71 @@ void FeaturesPlugin_RemoveSubShapes::attributeChanged(const std::string& theID)
   }
 
   myChangedInCode = true;
+  if (theID == BASE_SHAPE_ID() || theID == SUBSHAPES_TO_KEEP_ID() ||
+    theID == SUBSHAPES_TO_REMOVE_ID()) {
+    std::list<ResultPtr> anAllSubs;
+    ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
 
-  if(theID == BASE_SHAPE_ID()) {
-    aSubShapesToKeepAttrList->clear();
-    aSubShapesToRemoveAttrList->clear();
+    if(theID == BASE_SHAPE_ID()) {
+      aSubShapesToKeepAttrList->clear();
+      aSubShapesToRemoveAttrList->clear();
 
-    if (!aBaseShape.get()) {
-      return;
-    }
+      if (!aBaseShape.get()) {
+        return;
+      }
 
-    std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
-    for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
-    {
-      GeomShapePtr aSubShape = *anIt;
-      if(!isHasSubs) {
-        aSubShapesToKeepAttrList->append(aContext, aSubShape);
-      } else {
-        std::list<ResultPtr> anAllSubs;
-        ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
-        std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
-        for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
-          ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
-          if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
-            aSubShapesToKeepAttrList->append(aSub, aSubShape);
-            break;
+      std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+      ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+      for (; anIt != aSubShapes.cend(); ++anIt)
+      {
+        GeomShapePtr aSubShape = *anIt;
+        if(!isHasSubs) {
+          aSubShapesToKeepAttrList->append(aContext, aSubShape);
+        } else {
+          std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
+          for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+            ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
+            if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
+              aSubShapesToKeepAttrList->append(aSub, aSubShape);
+              break;
+            }
           }
         }
       }
     }
-  }
-  else if (theID == SUBSHAPES_TO_KEEP_ID())
-  {
-    aSubShapesToRemoveAttrList->clear();
+    else if (theID == SUBSHAPES_TO_KEEP_ID())
+    {
+      aSubShapesToRemoveAttrList->clear();
 
-    if (!aBaseShape.get()) {
-      return;
-    }
+      if (!aBaseShape.get()) {
+        return;
+      }
 
-    int anIndex;
-    const int aSubsToKeepNb = aSubShapesToKeepAttrList->size();
-    std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
-    for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
-    {
-      GeomShapePtr aSubShape = *anIt;
+      int anIndex;
+      // optimization: collect selection attribute values into a map
+      const int aSubsToKeepNb = aSubShapesToKeepAttrList->size();
+      GeomAPI_DataMapOfShapeShape aSubShapesToKeep;
       for(anIndex = 0; anIndex < aSubsToKeepNb; ++anIndex) {
         AttributeSelectionPtr anAttrSelectionInList = aSubShapesToKeepAttrList->value(anIndex);
         GeomShapePtr aSubShapeToKeep = anAttrSelectionInList->value();
-        if (aSubShapeToKeep.get() && aSubShapeToKeep->isEqual(aSubShape)) {
-          break;
-        }
+        if (aSubShapeToKeep.get())
+          aSubShapesToKeep.bind(aSubShapeToKeep, aSubShapeToKeep);
       }
 
-      if (anIndex == aSubsToKeepNb) {
+      std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+      ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+      for (; anIt != aSubShapes.cend(); ++anIt)
+      {
+        GeomShapePtr aSubShape = *anIt;
+        if (aSubShapesToKeep.isBound(aSubShape))
+          continue;
+
         if(!isHasSubs) {
           aSubShapesToRemoveAttrList->append(aContext, aSubShape);
-        } else {
-          std::list<ResultPtr> anAllSubs;
-          ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
+        }
+        else {
           std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
-          for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+          for (; aSubsIt != anAllSubs.end(); aSubsIt++) {
             ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
             if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
               aSubShapesToRemoveAttrList->append(aSub, aSubShape);
@@ -154,37 +160,39 @@ void FeaturesPlugin_RemoveSubShapes::attributeChanged(const std::string& theID)
         }
       }
     }
-  }
-  else if (theID == SUBSHAPES_TO_REMOVE_ID())
-  {
-    aSubShapesToKeepAttrList->clear();
+    else if (theID == SUBSHAPES_TO_REMOVE_ID())
+    {
+      aSubShapesToKeepAttrList->clear();
 
-    if (!aBaseShape.get()) {
-      return;
-    }
+      if (!aBaseShape.get()) {
+        return;
+      }
 
-    int anIndex;
-    const int aSubsToRemoveNb = aSubShapesToRemoveAttrList->size();
-    std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
-    for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
-    {
-      GeomShapePtr aSubShape = *anIt;
+      int anIndex;
+      const int aSubsToRemoveNb = aSubShapesToRemoveAttrList->size();
+      GeomAPI_DataMapOfShapeShape aSubShapesToRemove;
       for(anIndex = 0; anIndex < aSubsToRemoveNb; ++anIndex) {
         AttributeSelectionPtr anAttrSelectionInList = aSubShapesToRemoveAttrList->value(anIndex);
         GeomShapePtr aSubShapeToRemove = anAttrSelectionInList->value();
-        if (aSubShapeToRemove.get() && aSubShapeToRemove->isEqual(aSubShape)) {
-          break;
-        }
+        if (aSubShapeToRemove.get())
+          aSubShapesToRemove.bind(aSubShapeToRemove, aSubShapeToRemove);
       }
 
-      if (anIndex == aSubsToRemoveNb) {
-        if(!isHasSubs) {
+
+      std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+      ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+      for (; anIt != aSubShapes.cend(); ++anIt)
+      {
+        GeomShapePtr aSubShape = *anIt;
+        if (aSubShapesToRemove.isBound(aSubShape))
+          continue;
+
+        if (!isHasSubs) {
           aSubShapesToKeepAttrList->append(aContext, aSubShape);
-        } else {
-          std::list<ResultPtr> anAllSubs;
-          ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
+        }
+        else {
           std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
-          for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+          for (; aSubsIt != anAllSubs.end(); aSubsIt++) {
             ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
             if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
               aSubShapesToKeepAttrList->append(aSub, aSubShape);
index 1b3d191184dcdc46c055646107bcfe9dca807a70..89e30e116c0e0c31c2d0524439d6ce5a3d30d573 100644 (file)
@@ -49,7 +49,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [26])
-model.testResultsVolumes(Partition_1, [61838.592736754246288910508155823])
+model.testResultsVolumes(Partition_1, [58449.978430461182142607867717743])
 
 # update extrusion and check partition
 Param_ExtrusionMin.setValue(-5)
@@ -60,7 +60,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [23])
-model.testResultsVolumes(Partition_1, [60961.060159030253998935222625732])
+model.testResultsVolumes(Partition_1, [58449.978432491210696753114461899])
 
 # change radius of a circle and check partition
 Param_Radius.setValue(50)
@@ -70,7 +70,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [23])
-model.testResultsVolumes(Partition_1, [83608.865629965730477124452590942])
+model.testResultsVolumes(Partition_1, [81554.943249323987402021884918213])
 
 # check naming
 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
index a4b56d3c83f603d101289f1bd4717bf1672d8161..2f910a3c3648968d968ffde34f88f4e687945afc 100644 (file)
@@ -49,7 +49,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [22])
-model.testResultsVolumes(Partition_1, [61945.742345225989993195980787277])
+model.testResultsVolumes(Partition_1, [58449.978430083079729229211807251])
 
 # update extrusion and check partition
 Param_ExtrusionMin.setValue(-5)
@@ -60,7 +60,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
-model.testResultsVolumes(Partition_1, [60999.340090954778133891522884369])
+model.testResultsVolumes(Partition_1, [58449.978432399570010602474212646])
 
 # change radius of a circle and check partition
 Param_Radius.setValue(50)
@@ -70,7 +70,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
-model.testResultsVolumes(Partition_1, [83593.613567417080048471689224243])
+model.testResultsVolumes(Partition_1, [81554.943249112344346940517425537])
 
 # check naming
 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
index 523cd6af62de7a149c2936f0d3050832dcf00400..a1f82012b0539d11e76cd8e3d5362fe4d2ce305f 100644 (file)
@@ -49,7 +49,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [61517.614401630766224116086959839])
+model.testResultsVolumes(Partition_1, [58449.978431462892331182956695557])
 
 # update extrusion and check partition
 Param_ExtrusionMin.setValue(-5)
@@ -60,7 +60,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [60866.055096277588745579123497009])
+model.testResultsVolumes(Partition_1, [58449.978433344353106804192066193])
 
 # change radius of a circle and check partition
 Param_Radius.setValue(50)
@@ -70,7 +70,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [83526.053426235652295872569084167])
+model.testResultsVolumes(Partition_1, [81554.943249494404881261289119720])
 
 # check naming
 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
index 0884d51f4eeecdbf19c28d818dbba98bdd65fa60..6bec410de7ffc841a49e643f15fd9cf80c351984 100644 (file)
@@ -50,7 +50,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [27])
-model.testResultsVolumes(Partition_1, [61887.558125601033680140972137451])
+model.testResultsVolumes(Partition_1, [58449.978429485141532495617866516])
 
 # update extrusion and check partition
 Param_ExtrusionMin.setValue(-5)
@@ -61,7 +61,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [60989.714891709969379007816314697])
+model.testResultsVolumes(Partition_1, [58449.978433180862339213490486145])
 
 # change radius of a circle and check partition
 Param_Radius.setValue(50)
@@ -71,7 +71,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [83670.313521821837639436125755310])
+model.testResultsVolumes(Partition_1, [81554.943249094052589498460292816])
 
 # check naming
 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
index ce525b98bdddcccc65112c4f11877906de818280..29a2dcb1ad6301adf900ae2ece8bf01d7843285a 100644 (file)
@@ -50,7 +50,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [29])
-model.testResultsVolumes(Partition_1, [61804.7209520386313670314848423])
+model.testResultsVolumes(Partition_1, [58449.978429877664893865585327148])
 
 # update extrusion and check partition
 Param_ExtrusionMin.setValue(-5)
@@ -61,7 +61,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [60965.634801387262996286153793335])
+model.testResultsVolumes(Partition_1, [58449.978433183350716717541217804])
 
 # change radius of a circle and check partition
 Param_Radius.setValue(50)
@@ -71,7 +71,7 @@ model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [2])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [83661.21013607898203190416097641])
+model.testResultsVolumes(Partition_1, [81554.943249191215727478265762329])
 
 # check naming
 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
index 301717b15313218b7474810b88ee4005bc837452..357f79216cd959866d0fee694d5753b04ffcdaa7 100644 (file)
@@ -113,7 +113,6 @@ static GProp_GProps props(const TopoDS_Shape& theShape)
 //==================================================================================================
 double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theShape)
 {
-  GProp_GProps aGProps;
   if(!theShape.get()) {
     return 0.0;
   }
@@ -122,10 +121,19 @@ double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theSh
     return 0.0;
   }
   const Standard_Real anEps = 1.e-6;
-  if (aShape.ShapeType() <= TopAbs_SOLID)
-    BRepGProp::VolumeProperties(aShape, aGProps, anEps);
-  else
-    BRepGProp::SurfaceProperties(aShape, aGProps, anEps);
+  TopExp_Explorer anExp(aShape, TopAbs_SOLID);
+  if (anExp.More()) { // return volume if there is at least one solid
+    double aVolume = 0.0;
+    for (; anExp.More(); anExp.Next()) {
+      GProp_GProps aGProps;
+      BRepGProp::VolumeProperties(anExp.Current(), aGProps, anEps);
+      aVolume += aGProps.Mass();
+    }
+    return aVolume;
+  }
+  // return surfaces area
+  GProp_GProps aGProps;
+  BRepGProp::SurfaceProperties(aShape, aGProps, anEps);
   return aGProps.Mass();
 }
 
index 6c2f34378d67bb1c628076d1149ed058fd3d9f0d..252aac89cca4c109c994ba5bb0245983f487e899 100644 (file)
@@ -335,8 +335,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
         myWasChangedButBlocked.push_back(theAttr);
     }
   } else {
-    // trim: need to redisplay
-    if (myObject && theAttr->attributeType() == "Point2D") {
+    // trim: need to redisplay or set color in the python script
+    if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color")) {
       static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
       ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
     }
index 4a85e1c0c999c490931c85b0df8b4f7fb4e56018..cdbd9202bdaa57fa9ac16ad4c33833e8a906fde6 100644 (file)
@@ -800,7 +800,7 @@ QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
   int n = aWords.count();
   QString aLine;
   for (int i = 0; i < n; i++) {
-    QString aLineExt = aLine + " " + aWords[i];
+    QString aLineExt =  i == 0 ? aWords[i] : aLine + " " + aWords[i];
     qreal anWidthNonExt = tfm.boundingRect(aLine).width();
     qreal anWidthExt = tfm.boundingRect(aLineExt).width();
     qreal aDeltaNonExt = fabs(anWidthNonExt-aGoldWidth);
index 18f4616ca38c15305e47cc4c810b6a256e4c7ddf..6ecb09e7ee40c62c57d108d291bd094938cf2ce4 100644 (file)
@@ -19,4 +19,4 @@
 """Package for Construction plugin for the Parametric Geometry API of the Modeler.
 """
 
-from ConstructionAPI import addAxis, addPlane, addPoint
+from ConstructionAPI import addAxis, addPlane, addPoint, addPointXYZ
index 7da65684d112a024bfa6b9f37ade0a19edb5a5ea..a6aa8cba1b20515955ada266dc8707b785285836 100644 (file)
@@ -68,6 +68,8 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
       if ((*aIt)->isInHistory())
         aCreated.append(*aIt);
     }
+    if (aCreated.length() == 0)
+      return;
     QTreeNodesList aNodes = myRoot->objectCreated(aCreated);
     ModuleBase_ITreeNode* aParent;
     int aRow = 0;
diff --git a/test.hdfs/CMakeLists.txt b/test.hdfs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..58c6c48
--- /dev/null
@@ -0,0 +1,70 @@
+# Copyright (C) 2014-2019  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
+#
+
+ENABLE_TESTING()
+
+SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
+
+if (EXISTS ${RESTRICTED_ROOT_DIR})
+  file(GLOB hdfFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
+
+  if (WIN32) # different separators and path to libraries variable name
+    SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};$ENV{PATH}")
+    STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
+    STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
+    SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
+    STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
+    STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
+  else()
+    SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:$ENV{LD_LIBRARY_PATH}")
+    SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
+  endif()
+
+  foreach(eachFilePath ${hdfFilesRestr})
+    # Strip the ".hdf" suffix
+    GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE)
+    # Check corresponding ".py" file with reference data exists
+    IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
+      MESSGAGE(WARNING "File ${aTestName}.py containing reference data does not exist")
+    ENDIF()
+
+    # Add "SubprojectName_" prefix
+    GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+    SET(aTestName "${aSubprojectName}_${aTestName}")
+
+    # Full path to the python test file being executed
+    SET(aTestFilePath "${eachFilePath}")
+    IF(EXISTS ${aTestFilePath})
+      ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${aTestFilePath}")
+      if (WIN32) # different path to libraries variable name
+        SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}"
+          LABELS "models_hdf")
+      else()
+        SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}"
+          LABELS "models_hdf")
+      endif()
+      # Debug output...
+      # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}")
+    ELSE(EXISTS ${aTestFilePath})
+      MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}")
+    ENDIF(EXISTS ${aTestFilePath})
+  endforeach(eachFilePath ${ARGN})
+
+  ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf")
+endif()
diff --git a/test.hdfs/delta_p.py b/test.hdfs/delta_p.py
new file mode 100644 (file)
index 0000000..24452f8
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2014-2019  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
+#
+
+if __name__ == "__main__":
+  model.testNbResults(aPartFeature, 1)
+  model.testNbSubResults(aPartFeature, [0])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [319])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [2138])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [9022])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [18044])
+  model.testResultsVolumes(aPartFeature, [0.0837941287])
diff --git a/test.hdfs/roselend.py b/test.hdfs/roselend.py
new file mode 100644 (file)
index 0000000..e0533c3
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2014-2019  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
+#
+
+if __name__ == "__main__":
+  model.testNbResults(aPartFeature, 1)
+  model.testNbSubResults(aPartFeature, [0])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [32])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [875])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [4665])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [9330])
+  model.testResultsVolumes(aPartFeature, [145241798.705457538])
diff --git a/test.hdfs/te_fluide.py b/test.hdfs/te_fluide.py
new file mode 100644 (file)
index 0000000..25ea15a
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2014-2019  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
+#
+
+if __name__ == "__main__":
+  model.testNbResults(aPartFeature, 1)
+  model.testNbSubResults(aPartFeature, [0])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [30])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [231])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [968])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [1936])
+  model.testResultsVolumes(aPartFeature, [1429610.103267467])
diff --git a/test.hdfs/te_solide.py b/test.hdfs/te_solide.py
new file mode 100644 (file)
index 0000000..5d44704
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2014-2019  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
+#
+
+if __name__ == "__main__":
+  model.testNbResults(aPartFeature, 1)
+  model.testNbSubResults(aPartFeature, [0])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [48])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [292])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [1176])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [2352])
+  model.testResultsVolumes(aPartFeature, [6468345.48144548386])
diff --git a/test.hdfs/test.py b/test.hdfs/test.py
new file mode 100644 (file)
index 0000000..69b88b6
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+if __name__ == '__main__':
+
+  from subprocess import Popen
+  from time import sleep
+  import sys, os
+
+  salomeKernelDir = sys.argv[1]
+  sourceDir = sys.argv[2]
+  testfile = sys.argv[3]
+
+  portlogfile = os.getcwd() + "/.salome_port"
+  testlogfile = os.getcwd() + "/test.log"
+  # remove port file if any
+  try:
+    os.remove(portlogfile)
+  except:
+    pass
+
+  proc = Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir])
+
+  iter = 0
+  while not os.path.exists(portlogfile) and iter < 100:
+    sleep(0.1)
+    iter += 1
+
+  while os.path.exists(portlogfile):
+    sleep(0.1)
+
+  isOk = True
+  with open(testlogfile, 'r') as inputFile:
+    s = inputFile.read()
+    print(s)
+    for line in s:
+      isOk = isOk and s.find("FAIL") < 0
+  try:
+    os.remove(testlogfile)
+  except:
+    pass
+
+  assert isOk, "Test failed"
diff --git a/test.hdfs/test_hdf.py b/test.hdfs/test_hdf.py
new file mode 100644 (file)
index 0000000..b1d3991
--- /dev/null
@@ -0,0 +1,92 @@
+# Copyright (C) 2014-2019  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
+#
+
+import salome, os, sys
+import SalomePyQt
+
+import unittest
+import subprocess
+
+import ModelHighAPI, ModelAPI, PartSetAPI
+from GeomAPI import GeomAPI_Shape
+from salome.shaper import model
+
+class TestHDF(unittest.TestCase):
+  testfile = ""
+  reffile = ""
+
+  def setUp(self):
+    salome.salome_close()
+
+    # leave file name only (trim path and extension)
+    fileName = os.path.basename(self.testfile)
+    self.reffile = self.reffile + "/" + os.path.splitext(fileName)[0] + ".py"
+
+    salome.salome_init(self.testfile, embedded=1)
+    myStudyName = salome.myStudy._get_Name()
+    self.session = salome.naming_service.Resolve('/Kernel/Session')
+    self.session.emitMessage("connect_to_study")
+
+    self.sg = SalomePyQt.SalomePyQt()
+    self.sg.activateModule("Shaper")
+    self.session = ModelAPI.ModelAPI_Session.get()
+    self.partSet = self.session.moduleDocument()
+
+  def tearDown(self):
+    salome.sg.UpdateView()
+    self.sg.processEvents()
+    salome.sg.FitAll()
+
+  def test_hdf_file(self):
+    self.assertTrue(self.partSet.size("Parts") > 0)
+    aPartsList = []
+    for aPartIndex in range(self.partSet.size("Parts")):
+      self.session.startOperation()
+      aPart = ModelAPI.modelAPI_ResultPart(ModelAPI.objectToResult(self.partSet.object("Parts", aPartIndex)))
+      aPart.activate()
+      self.session.finishOperation()
+
+      aPartFeature = PartSetAPI.PartSetAPI_Part(self.partSet.currentFeature(True))
+      # check reference data
+      exec(open(self.reffile, "rb").read())
+
+
+if __name__ == "__main__":
+  if len(sys.argv) > 1:
+    TestHDF.testfile = sys.argv[1]
+  if len(sys.argv) > 2:
+    salomePortFile = sys.argv[2]
+  if len(sys.argv) > 3:
+    errFile = open(sys.argv[3], 'w')
+  if len(sys.argv) > 4:
+    salomeKernelDir = sys.argv[4]
+  if len(sys.argv) > 5:
+    TestHDF.reffile = sys.argv[5]
+
+  aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF)
+  unittest.TextTestRunner(stream=errFile).run(aTest)
+  errFile.close()
+
+  # close Salome GUI
+  proc = subprocess.Popen(salomeKernelDir + "/bin/salome/killSalome.py")
+
+  try:
+    os.remove(salomePortFile)
+  except:
+    print("Cannot remove file", file=f)
diff --git a/test.hdfs/usine.py b/test.hdfs/usine.py
new file mode 100644 (file)
index 0000000..278c08a
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2014-2019  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
+#
+
+if __name__ == "__main__":
+  model.testNbResults(aPartFeature, 1)
+  model.testNbSubResults(aPartFeature, [0])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [186])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [4573])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [25474])
+  model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [50980])
+  model.testResultsVolumes(aPartFeature, [2688153.285910513252])
diff --git a/test.sh b/test.sh
index 79ab28f2505e6cf0111ae486b188930b02d57f34..92c0b48e9651a0b4d16e12a6f178499fbe08164a 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -5,4 +5,10 @@ source env.sh
 mkdir -p ${BUILD_DIR}
 cd ${BUILD_DIR}
 
-ctest --no-compress-output -T Test "$@"
+export DISPLAY="localhost:0.0"
+
+if [[ $# > 0 ]]; then
+  ctest --no-compress-output -T Test "$@" -R $1
+else
+  ctest --no-compress-output -T Test "$@"
+fi