]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implemention feature to view basic prpoperties
authorJérôme <jerome.lucas@cesgenslab.fr>
Wed, 21 Oct 2020 13:12:18 +0000 (15:12 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Wed, 21 Oct 2020 13:12:18 +0000 (15:12 +0200)
19 files changed:
src/Config/Config_Keywords.h
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_GeometryCalculation.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_GeometryCalculation.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/GeometryCalculation_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/icons/basicproperties.png [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/PythonAPI/model/features/__init__.py

index 5be23a997a8cb03ab9d4c04c8b75030c191fa77e..28783fd69c7ae2bd501418e968a6b6a36716c001 100644 (file)
@@ -100,6 +100,7 @@ MAYBE_UNUSED const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP;
 MAYBE_UNUSED const static char* ATTR_ICON = FEATURE_ICON;
 MAYBE_UNUSED const static char* ATTR_LABEL = "label";
 MAYBE_UNUSED const static char* ATTR_STYLE_SHEET = "styleSheet";
+MAYBE_UNUSED const static char* ATTR_IS_SELECTABLE = "isSelectable";
 MAYBE_UNUSED const static char* ATTR_HTML_STYLE = "isHTML";
 MAYBE_UNUSED const static char* ATTR_DEFAULT = "default";
 MAYBE_UNUSED const static char* ATTR_INTERNAL = "internal";
index 0b8e3055ceea2574236c565de5a95816d09e0a8c..093877f66ae861cef159442dfc772c5c715a9ddb 100644 (file)
@@ -32,6 +32,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Fillet.h
   FeaturesAPI_Intersection.h
   FeaturesAPI_Measurement.h
+  FeaturesAPI_GeometryCalculation.h
   FeaturesAPI_MultiRotation.h
   FeaturesAPI_MultiTranslation.h
   FeaturesAPI_Partition.h
@@ -65,6 +66,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Fillet.cpp
   FeaturesAPI_Intersection.cpp
   FeaturesAPI_Measurement.cpp
+  FeaturesAPI_GeometryCalculation.cpp
   FeaturesAPI_MultiRotation.cpp
   FeaturesAPI_MultiTranslation.cpp
   FeaturesAPI_Partition.cpp
index b76fd2dc433da48ec55917f838656249d29c963a..c2c0631d42eb6e77c772e42e7876831e99bc97ee 100644 (file)
 %include "FeaturesAPI_Fillet.h"
 %include "FeaturesAPI_Intersection.h"
 %include "FeaturesAPI_Measurement.h"
+%include "FeaturesAPI_GeometryCalculation.h"
 %include "FeaturesAPI_MultiRotation.h"
 %include "FeaturesAPI_MultiTranslation.h"
 %include "FeaturesAPI_Partition.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_GeometryCalculation.cpp b/src/FeaturesAPI/FeaturesAPI_GeometryCalculation.cpp
new file mode 100644 (file)
index 0000000..9bf0ae4
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2018-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 "FeaturesAPI_GeometryCalculation.h"
+
+#include <FeaturesPlugin_GeometryCalculation.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelHighAPI_Services.h>
+#include <ModelHighAPI_Tools.h>
+
+std::list<double>  getBasicProperties(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                      const ModelHighAPI_Selection& theObject)
+{
+  FeaturePtr aPointCoodFeat = thePart->addFeature(FeaturesPlugin_GeometryCalculation::ID());
+
+  fillAttribute(theObject, aPointCoodFeat
+                      ->selection(FeaturesPlugin_GeometryCalculation::OBJECT_SELECTED_ID()));
+  std::list<double> res;
+
+  // obtain result
+  AttributeDoubleArrayPtr aResult = std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(
+      aPointCoodFeat->attribute(FeaturesPlugin_GeometryCalculation::RESULT_VALUES_ID()));
+
+  for ( int i : {0, 1, 2})
+    res.push_back( aResult->value(i));
+
+  return res;
+}
+
diff --git a/src/FeaturesAPI/FeaturesAPI_GeometryCalculation.h b/src/FeaturesAPI/FeaturesAPI_GeometryCalculation.h
new file mode 100644 (file)
index 0000000..abed692
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2018-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 FeaturesAPI_GeometryCalculation_H_
+#define FeaturesAPI_GeometryCalculation_H_
+
+#include "FeaturesAPI.h"
+
+#include <list>
+#include <memory>
+
+class ModelAPI_Document;
+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);
+
+#endif // FeaturesAPI_GeometryCalculation_H_
\ No newline at end of file
index 17ada7187e7c42fda139cd4ebb47fea682fc0974..030fbaa261aad1b95e4ea3868893b23e3ff3bec4 100644 (file)
@@ -35,6 +35,7 @@
   #include "FeaturesAPI_Fillet.h"
   #include "FeaturesAPI_Intersection.h"
   #include "FeaturesAPI_Measurement.h"
+  #include "FeaturesAPI_GeometryCalculation.h"
   #include "FeaturesAPI_MultiRotation.h"
   #include "FeaturesAPI_MultiTranslation.h"
   #include "FeaturesAPI_Partition.h"
index c93c66a173f551dd39cd53f0ea742d80b19cb4ef..8d7002a615cd19ee5ed5774b77ba80430b77200f 100644 (file)
 
 INCLUDE(Common)
 INCLUDE(UnitTest)
+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
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+
 
 SET(PROJECT_HEADERS
     FeaturesPlugin.h
@@ -59,6 +70,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_Fillet.h
     FeaturesPlugin_Fillet1D.h
     FeaturesPlugin_Measurement.h
+    FeaturesPlugin_GeometryCalculation.h
     FeaturesPlugin_FusionFaces.h
     FeaturesPlugin_RemoveResults.h
     FeaturesPlugin_Chamfer.h
@@ -106,6 +118,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Fillet.cpp
     FeaturesPlugin_Fillet1D.cpp
     FeaturesPlugin_Measurement.cpp
+    FeaturesPlugin_GeometryCalculation.cpp
     FeaturesPlugin_FusionFaces.cpp
     FeaturesPlugin_RemoveResults.cpp
     FeaturesPlugin_Chamfer.cpp
@@ -144,6 +157,7 @@ SET(XML_RESOURCES
   fillet_widget.xml
   fillet1d_widget.xml
   measurement_widget.xml
+  GeometryCalculation_widget.xml
   fusion_faces_widget.xml
   chamfer_widget.xml
   copy_widget.xml
@@ -166,6 +180,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomValidators
+  ../ModuleBase
   ../Events
   ../Config
   ${OpenCASCADE_INCLUDE_DIR}
@@ -182,7 +197,11 @@ 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})
 TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES})
 
 INSTALL(TARGETS FeaturesPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
@@ -682,6 +701,4 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestFillet1D_Wire_3.py
                TestFillet1D_Wire_4.py
                TestFillet1D_Wire_5.py
-               Test19931.py
-               Test20027.py
 )
diff --git a/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.cpp b/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.cpp
new file mode 100644 (file)
index 0000000..c16bc78
--- /dev/null
@@ -0,0 +1,107 @@
+// Copyright (C) 2018-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_GeometryCalculation.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
+
+#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
+  data()->addAttribute(OBJECT_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
+  // attributes for result message and values
+  data()->addAttribute(LENGHT_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(AREA_ID(), ModelAPI_AttributeString::typeId());
+  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()) {
+
+    AttributeSelectionPtr aSelection = selection(OBJECT_SELECTED_ID());
+    AttributeDoubleArrayPtr aValues =
+      std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
+    std::stringstream streamL;
+    std::stringstream streamA;
+    std::stringstream streamV;
+    GeomShapePtr aShape;
+
+    if (aSelection && aSelection->isInitialized()) {
+      aShape = aSelection->value();
+      if (!aShape && aSelection->context())
+        aShape = aSelection->context()->shape();
+    }
+    if (aShape){
+      double aTolerance = 0.0001;
+      double aLength;
+      double aSurfArea;
+      double aVolume;
+      std::string aError;
+      if( !GetBasicProperties( aShape,
+                              aTolerance,
+                              aLength,
+                              aSurfArea,
+                              aVolume,
+                              aError) )
+         setError("Error in Geometry calculation :" +  aError);
+
+      streamL << std::setprecision(14) << aLength;
+      aValues->setValue(0, aLength);
+      streamA << std::setprecision(14) << aSurfArea;
+      aValues->setValue(1, aSurfArea);
+      streamV << std::setprecision(14) << aVolume;
+      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() );
+  }
+}
+
diff --git a/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h b/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h
new file mode 100644 (file)
index 0000000..df95636
--- /dev/null
@@ -0,0 +1,101 @@
+// Copyright (C) 2018-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_GeometryCalculation_H_
+#define FeaturesPlugin_GeometryCalculation_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+
+/// \class FeaturesPlugin_GeometryCalculation
+/// \ingroup Plugins
+/// \brief Feature for geometry calculation.
+
+class FeaturesPlugin_GeometryCalculation : public ModelAPI_Feature
+{
+public:
+   inline static const std::string& ID()
+  {
+    static const std::string MY_ID("GeometryCalculation");
+    return MY_ID;
+  }
+
+  /// \return the kind of a feature.
+  virtual const std::string& getKind()
+  {
+    return ID();
+  }
+
+  /// Attribute name for object selected.
+  inline static const std::string& OBJECT_SELECTED_ID()
+  {
+    static const std::string MY_OBJECT_SELECTED_ID("main_object");
+    return MY_OBJECT_SELECTED_ID;
+  }
+
+  /// Attribute name for lenght
+  inline static const std::string& LENGHT_ID()
+  {
+    static const std::string MY_LENGHT_ID("lenght");
+    return MY_LENGHT_ID;
+  }
+
+  /// Attribute name for area
+  inline static const std::string& AREA_ID()
+  {
+    static const std::string MY_AREA_ID("area");
+    return MY_AREA_ID;
+  }
+
+  /// Attribute name for volume.
+  inline static const std::string& VOLUME_ID()
+  {
+    static const std::string MY_VOLUME_ID("volume");
+    return MY_VOLUME_ID;
+  }
+
+   /// Attribute name for values of result.
+  inline static const std::string& RESULT_VALUES_ID()
+  {
+    static const std::string MY_RESULT_VALUES_ID("result_values");
+    return MY_RESULT_VALUES_ID;
+  }
+
+  /// Performs the algorithm and stores results it in the data structure.
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+  /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
+  virtual bool isMacro() const { return true; }
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_GeometryCalculation();
+
+};
+
+#endif
index 0d49dfe08d1da9ca019628b9784e630e8b5331f9..d4f2f77a3b315a724d6286b6ccaf77df8e1e410e 100644 (file)
@@ -33,6 +33,7 @@
 #include <FeaturesPlugin_Fillet1D.h>
 #include <FeaturesPlugin_Intersection.h>
 #include <FeaturesPlugin_Measurement.h>
+#include <FeaturesPlugin_GeometryCalculation.h>
 #include <FeaturesPlugin_MultiRotation.h>
 #include <FeaturesPlugin_MultiTranslation.h>
 #include <FeaturesPlugin_Partition.h>
@@ -187,6 +188,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_Fillet1D);
   } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) {
     return FeaturePtr(new FeaturesPlugin_Measurement);
+  } else if (theFeatureID == FeaturesPlugin_GeometryCalculation::ID()) {
+    return FeaturePtr(new FeaturesPlugin_GeometryCalculation);
   } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) {
     return FeaturePtr(new FeaturesPlugin_RemoveResults);
   } else if (theFeatureID == FeaturesPlugin_Chamfer::ID()) {
diff --git a/src/FeaturesPlugin/GeometryCalculation_widget.xml b/src/FeaturesPlugin/GeometryCalculation_widget.xml
new file mode 100644 (file)
index 0000000..4b5913d
--- /dev/null
@@ -0,0 +1,13 @@
+<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/icons/basicproperties.png b/src/FeaturesPlugin/icons/basicproperties.png
new file mode 100644 (file)
index 0000000..f46c0da
Binary files /dev/null and b/src/FeaturesPlugin/icons/basicproperties.png differ
index 08c08b775d79c7aaf9fa5ea31cc8103dbe6f65bf..88b649b334773244ac1081194bc0b22b1df15aa1 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"
         <source path="chamfer_widget.xml"/>
       </feature>
       <feature id="FusionFaces" title="Fuse Faces" tooltip="Performs fusion of connected faces"
-               icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="fuseFeatureFaces.html">
+               icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="FeaturesPlugin/fusionFacesFeature.html">
         <source path="fusion_faces_widget.xml"/>
       </feature>
       <feature id="Defeaturing" title="Defeaturing" tooltip="Perform removing faces from solid"
     </group>
   </workbench>
   <workbench id="Inspection">
-    <group id="Measurement">
+
+    <group id="Calculation">
+      <feature id="GeometryCalculation" title="Geometry Calculation" tooltip="Calculate properties of objects"
+               icon="icons/Features/basicproperties.png" helpfile="measurementFeature.html" abort_confirmation="false">
+        <source path="GeometryCalculation_widget.xml"/>
+      </feature>
       <feature id="Measurement" title="Measurement" tooltip="Calculate properties of objects"
                icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false">
         <source path="measurement_widget.xml"/>
index 95e749c10d2d5263ee845b513f73b2659f70365e..af8c0acf6476b86c3e54edf425d9fc1fb223f81d 100644 (file)
@@ -33,6 +33,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Prism.h
     GeomAlgoAPI_Revolution.h
     GeomAlgoAPI_Boolean.h
+    GeomAlgoAPI_BasicProperties.h
     GeomAlgoAPI_ThroughAll.h
     GeomAlgoAPI_Rotation.h
     GeomAlgoAPI_Translation.h
@@ -98,6 +99,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Prism.cpp
     GeomAlgoAPI_Revolution.cpp
     GeomAlgoAPI_Boolean.cpp
+    GeomAlgoAPI_BasicProperties.cpp
     GeomAlgoAPI_ThroughAll.cpp
     GeomAlgoAPI_Rotation.cpp
     GeomAlgoAPI_Translation.cpp
@@ -176,6 +178,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAlgoImpl
   ../ModelAPI
   ../XAO
+  ${PROJECT_SOURCE_DIR}/src/Locale
   ${OpenCASCADE_INCLUDE_DIR}
 )
 
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp
new file mode 100644 (file)
index 0000000..2a75303
--- /dev/null
@@ -0,0 +1,75 @@
+// 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_BasicProperties.h"
+
+#include <GProp_GProps.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRepGProp.hxx>
+#include <TopExp_Explorer.hxx>
+#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)
+{
+
+  #ifdef _DEBUG
+  std::cout << "GetBasicProperties " << std::endl;
+  #endif
+
+  if (!theShape.get()) {
+    theError = "GetBasicProperties : An invalid argument";
+    return false;
+  }
+
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+
+  //Compute the parameters
+  GProp_GProps LProps, SProps;
+  Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6;
+  try {
+    OCC_CATCH_SIGNALS;
+    BRepGProp::LinearProperties(aShape, LProps, Standard_True);
+    theLength = LProps.Mass();
+
+    BRepGProp::SurfaceProperties(aShape, SProps, anEps, Standard_True);
+    theSurfArea = SProps.Mass();
+
+    theVolume = 0.0;
+    if (aShape.ShapeType() < TopAbs_SHELL) {
+      for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) {
+        GProp_GProps VProps;
+        BRepGProp::VolumeProperties(Exp.Current(), VProps, anEps, Standard_True);
+        theVolume += VProps.Mass();
+      }
+    }
+  }
+  catch (Standard_Failure& aFail) {
+    theError = aFail.GetMessageString();
+    return false;
+  }
+
+  return true;
+
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h b/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h
new file mode 100644 (file)
index 0000000..5450ea7
--- /dev/null
@@ -0,0 +1,42 @@
+// 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_BasicProperties_H_
+#define GeomAlgoAPI_BasicProperties_H_
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <Standard_TypeDef.hxx>
+
+/// Run chamfer operation with two distances or with a distance and an angle .
+  /// \param theShape      the shape
+  /// \param theTolerance  tolerance desirated
+  /// \param theLength     lenght calculated
+  /// \param theSurfArea   Surface Area calculated
+  /// \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);
+
+#endif
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 7a47835c8a1b984de1fdc6aa9939ef5db144f1f2..7e3f86de0ab80bdf75d1b2397dfeb846dd64de43 100644 (file)
@@ -61,6 +61,10 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
   std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET);
   if (!aStyleSheet.empty())
     myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str()));
+
+  aStyleSheet = theData->getProperty(ATTR_IS_SELECTABLE);
+  if ( aStyleSheet == "true")
+    myLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
 }
 
 ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
index 772dc05c219e2fa9c563ea82796013ef67860cca..354362e09fc346b35888d0d83fc345ef33bc7ae3 100644 (file)
@@ -30,6 +30,7 @@ from FeaturesAPI import addRecover
 from FeaturesAPI import addFillet, addChamfer
 from FeaturesAPI import addFusionFaces
 from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
+from FeaturesAPI import getBasicProperties
 from FeaturesAPI import addRemoveResults
 from FeaturesAPI import addCopy, addImportResult
 from FeaturesAPI import addDefeaturing