]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20429 Fix issues
authorJérôme <jerome.lucas@cesgenslab.fr>
Thu, 3 Dec 2020 13:24:42 +0000 (14:24 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Thu, 3 Dec 2020 13:24:42 +0000 (14:24 +0100)
14 files changed:
src/FeaturesAPI/FeaturesAPI_GeometryCalculation.cpp
src/FeaturesAPI/FeaturesAPI_GeometryCalculation.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.cpp
src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h
src/FeaturesPlugin/GeometryCalculation_widget.xml [deleted file]
src/FeaturesPlugin/doc/TUI_basic_properties.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/basic_properties.py [new file with mode: 0644]
src/FeaturesPlugin/doc/geometryCalculationFeature.rst
src/FeaturesPlugin/geometry_calculation_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp
src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h
src/ModelAPI/CMakeLists.txt

index 9bf0ae406efa5f14ee05b58801207124588bbbf3..a0067e55d5f1eeb32d150ea39aeadcf166147f30 100644 (file)
@@ -24,8 +24,9 @@
 #include <ModelHighAPI_Services.h>
 #include <ModelHighAPI_Tools.h>
 
-std::list<double>  getBasicProperties(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                      const ModelHighAPI_Selection& theObject)
+//=================================================================================================
+std::list<double> getBasicProperties(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                     const ModelHighAPI_Selection& theObject)
 {
   FeaturePtr aPointCoodFeat = thePart->addFeature(FeaturesPlugin_GeometryCalculation::ID());
 
@@ -37,7 +38,7 @@ std::list<double>  getBasicProperties(const std::shared_ptr<ModelAPI_Document>&
   AttributeDoubleArrayPtr aResult = std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(
       aPointCoodFeat->attribute(FeaturesPlugin_GeometryCalculation::RESULT_VALUES_ID()));
 
-  for ( int i : {0, 1, 2})
+  for (int i : {0, 1, 2})
     res.push_back( aResult->value(i));
 
   return res;
index abed69276ba35c7bd31eccccf2b6201b7b541410..8b912eaa73cc90313cc3bc0c77637095e6ee4a32 100644 (file)
@@ -31,7 +31,7 @@ class ModelHighAPI_Selection;
 /// \ingroup CPPHighAPI
 /// \brief get the basic properties (lenght, Surface area, volume)
 FEATURESAPI_EXPORT
-std::list<double>  getBasicProperties(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                      const ModelHighAPI_Selection& theObject);
+std::list<double> getBasicProperties(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                     const ModelHighAPI_Selection& theObject);
 
 #endif // FeaturesAPI_GeometryCalculation_H_
\ No newline at end of file
index ab56bb2569ddb5b5ab2902b90470e52878c1f7eb..83df4b4930c798a206636851135bdc0fc5596352 100644 (file)
@@ -24,7 +24,6 @@ INCLUDE(UseQtExt)
 # additional include directories
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
                      ${PROJECT_SOURCE_DIR}/src/Locale
-                     ${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin
                      ${QT_INCLUDES})
 
 # additional preprocessor / compiler flags
@@ -157,7 +156,7 @@ SET(XML_RESOURCES
   fillet_widget.xml
   fillet1d_widget.xml
   measurement_widget.xml
-  GeometryCalculation_widget.xml
+  geometry_calculation_widget.xml
   fusion_faces_widget.xml
   chamfer_widget.xml
   copy_widget.xml
index c16bc78a3285cbfff38de03c90c611e86d5a4d49..fb74e5f8a635f27a9101731ff5a4564aa23ee007 100644 (file)
 #include <Config_PropManager.h>
 
 #include <GeomAPI_Shape.h>
-#include <GeomAPI_Pnt.h>
-#include <GeomAPI_Vertex.h>
 #include <GeomAlgoAPI_BasicProperties.h>
 
 
 #include <iomanip>
 #include <sstream>
 
+//=================================================================================================
 FeaturesPlugin_GeometryCalculation::FeaturesPlugin_GeometryCalculation()
 {
 }
 
+//=================================================================================================
 void FeaturesPlugin_GeometryCalculation::initAttributes()
 {
   // attribute for point selected
@@ -51,15 +51,16 @@ void FeaturesPlugin_GeometryCalculation::initAttributes()
   data()->addAttribute(VOLUME_ID(), ModelAPI_AttributeString::typeId());
 
   data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId());
-
   data()->realArray(RESULT_VALUES_ID())->setSize(3);
 
 }
 
+//=================================================================================================
 void FeaturesPlugin_GeometryCalculation::execute()
 {
 }
 
+//=================================================================================================
 void FeaturesPlugin_GeometryCalculation::attributeChanged(const std::string& theID)
 {
   if (theID == OBJECT_SELECTED_ID()) {
@@ -77,18 +78,18 @@ void FeaturesPlugin_GeometryCalculation::attributeChanged(const std::string& the
       if (!aShape && aSelection->context())
         aShape = aSelection->context()->shape();
     }
-    if (aShape){
+    if (aShape) {
       double aTolerance = 0.0001;
       double aLength;
       double aSurfArea;
       double aVolume;
       std::string aError;
-      if( !GetBasicProperties( aShape,
+      if (!GetBasicProperties(aShape,
                               aTolerance,
                               aLength,
                               aSurfArea,
                               aVolume,
-                              aError) )
+                              aError))
          setError("Error in Geometry calculation :" +  aError);
 
       streamL << std::setprecision(14) << aLength;
@@ -99,9 +100,9 @@ void FeaturesPlugin_GeometryCalculation::attributeChanged(const std::string& the
       aValues->setValue(2, aVolume);
     }
 
-    string(LENGHT_ID() )->setValue( "Lenght = " +  streamL.str() );
-    string(AREA_ID() )->setValue( "Area = " +  streamA.str() );
-    string(VOLUME_ID() )->setValue( "Volume = " +  streamV.str() );
+    string(LENGHT_ID())->setValue("Lenght = " +  streamL.str());
+    string(AREA_ID())->setValue("Area = " +  streamA.str());
+    string(VOLUME_ID())->setValue("Volume = " +  streamV.str());
   }
 }
 
index a41e853652340a390d8cf21e2245db3e3acae634..0eaeaa13410535b48f24eb2131c1808e2601e23f 100644 (file)
@@ -33,7 +33,7 @@
 class FeaturesPlugin_GeometryCalculation : public ModelAPI_Feature
 {
 public:
-   inline static const std::string& ID()
+  inline static const std::string& ID()
   {
     static const std::string MY_ID("GeometryCalculation");
     return MY_ID;
@@ -73,7 +73,7 @@ public:
     return MY_VOLUME_ID;
   }
 
-   /// Attribute name for values of result.
+  /// Attribute name for values of result.
   inline static const std::string& RESULT_VALUES_ID()
   {
     static const std::string MY_RESULT_VALUES_ID("result_values");
diff --git a/src/FeaturesPlugin/GeometryCalculation_widget.xml b/src/FeaturesPlugin/GeometryCalculation_widget.xml
deleted file mode 100644 (file)
index 4b5913d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<source>
-  <shape_selector id="main_object"
-                  label="Object"
-                  tooltip="Select a object"
-                  shape_types="edges faces solids compsolids objects"
-                  default=""
-                  geometrical_selection="true">
-    <validator id="GeomValidators_ShapeType" parameters="line,edge,wire,face,shell,solid,compsolid,compound"/>
-  </shape_selector>
-  <label id="lenght" isSelectable = "true"/>
-  <label id="area" isSelectable = "true"/>
-  <label id="volume" isSelectable = "true"/>
-</source>
diff --git a/src/FeaturesPlugin/doc/TUI_basic_properties.rst b/src/FeaturesPlugin/doc/TUI_basic_properties.rst
new file mode 100644 (file)
index 0000000..8e6eeaf
--- /dev/null
@@ -0,0 +1,12 @@
+
+  .. _tui_basic_properties:
+
+Get basic properties
+====================
+
+.. literalinclude:: examples/basic_properties.py 
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/basic_properties.py>`
+   
diff --git a/src/FeaturesPlugin/doc/examples/basic_properties.py b/src/FeaturesPlugin/doc/examples/basic_properties.py
new file mode 100644 (file)
index 0000000..68a1949
--- /dev/null
@@ -0,0 +1,13 @@
+import os
+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)
+properties = model.getBasicProperties(Part_1_doc,model.selection("SOLID", "Box_1_1"))
+print(" lenght: ", properties[0])
+print(" area: ", properties[1])
+print(" volume: ", properties[2]) 
+model.end()
\ No newline at end of file
index a90d5bc8b18bf8a5928409b8f86d19ea377820f8..4018f219de6c5368ae96de9974be6c6b4179875a 100644 (file)
@@ -26,3 +26,13 @@ Input fields:
 - **Object** contains an object selected in 3D OCC viewer or object browser. 
 
 The basic properties displayed can be selected.
+
+**TUI Command**:
+
+.. py:function:: model.GetBasicProperties(Part_doc, shape)
+
+    :param part: The current part object.
+    :param object: A shape in format *model.selection("type", shape)*.
+    :return: list containing lenght, area and volume.
+
+**See Also** a sample TUI Script of :ref:`tui_basic_properties` operation.
\ No newline at end of file
diff --git a/src/FeaturesPlugin/geometry_calculation_widget.xml b/src/FeaturesPlugin/geometry_calculation_widget.xml
new file mode 100644 (file)
index 0000000..da30ff1
--- /dev/null
@@ -0,0 +1,13 @@
+<source>
+  <shape_selector id="main_object"
+                  label="Object"
+                  tooltip="Select a object"
+                  shape_types="edges faces solids compsolids"
+                  default=""
+                  geometrical_selection="true">
+    <validator id="GeomValidators_ShapeType" parameters="line,edge,wire,face,shell,solid,compsolid,compound"/>
+  </shape_selector>
+  <label id="lenght" isSelectable = "true"/>
+  <label id="area" isSelectable = "true"/>
+  <label id="volume" isSelectable = "true"/>
+</source>
index 00dddaf5f98e9d4b6f866eda53d1a1907aa2e1fc..343c77567b99c013ce1543acc8b7add3f4e1b8e2 100644 (file)
     </group>
   </workbench>
   <workbench id="Inspection">
-
     <group id="Calculation">
       <feature id="GeometryCalculation" title="Geometry Calculation" tooltip="Calculate properties of objects"
                icon="icons/Features/basicproperties.png" helpfile="geometryCalculationFeature.html" abort_confirmation="false">
-        <source path="GeometryCalculation_widget.xml"/>
+        <source path="geometry_calculation_widget.xml"/>
       </feature>
       <feature id="Measurement" title="Measurement" tooltip="Calculate properties of objects"
                icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false">
index 2a75303834ce00be3e0b5551927a831af3ebbd72..10a540b8a0c86e7cb98c4206ce014e9d0c95ff68 100644 (file)
 #include <Standard_ErrorHandler.hxx>
 
 //=================================================================================================
-bool GetBasicProperties(  const std::shared_ptr<GeomAPI_Shape>& theShape,
-                          const double theTolerance,
-                          Standard_Real& theLength,
-                          Standard_Real& theSurfArea,
-                          Standard_Real& theVolume,
-                          std::string& theError)
+bool GetBasicProperties(const std::shared_ptr<GeomAPI_Shape>& theShape,
+                        const double theTolerance,
+                        Standard_Real& theLength,
+                        Standard_Real& theSurfArea,
+                        Standard_Real& theVolume,
+                        std::string& theError)
 {
 
   #ifdef _DEBUG
index 5450ea7267130176f2062a810b086ca6abaf5b5e..4db5dc4f22799f79dab1e22bea9334f7056c6912 100644 (file)
   /// \param theVolume     Volume calculated
   /// \param theError      error
 GEOMALGOAPI_EXPORT
-bool GetBasicProperties(  const std::shared_ptr<GeomAPI_Shape>& theShape,
-                          const Standard_Real theTolerance,
-                          Standard_Real& theLength,
-                          Standard_Real& theSurfArea,
-                          Standard_Real& theVolume,
-                          std::string& theError);
+bool GetBasicProperties(const std::shared_ptr<GeomAPI_Shape>& theShape,
+                        const Standard_Real theTolerance,
+                        Standard_Real& theLength,
+                        Standard_Real& theSurfArea,
+                        Standard_Real& theVolume,
+                        std::string& theError);
 
 #endif
index 7b7876165946fb970b92faf8a221c3f33b3e7693..0a49da69553130978aa63bbfcbe5e6a4f4eff73d 100644 (file)
@@ -117,7 +117,6 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     Config
     GeomAPI
-    ${OpenCASCADE_ApplicationFramework_LIBRARIES}
 )
 SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
@@ -131,10 +130,6 @@ 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}
 )