]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add test and debug
authorjfa <jfa@opencascade.com>
Wed, 13 Jul 2022 10:07:55 +0000 (13:07 +0300)
committerjfa <jfa@opencascade.com>
Wed, 13 Jul 2022 10:07:55 +0000 (13:07 +0300)
src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.cpp
src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.h
src/FeaturesPlugin/FeaturesPlugin_PointCloudOnFace.cpp
src/FeaturesPlugin/Test/TestPointCloud.py [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/FeaturesPlugin/tests.set
src/GeomAlgoAPI/GeomAlgoAPI_PointCloudOnFace.cpp
src/PythonAPI/model/features/__init__.py

index e84c88ab7c1ab217b6ee2c8fc6a0696f9f36f26d..da7ae7ce13312c6cef5b098470be15afb80d22a4 100644 (file)
@@ -39,10 +39,7 @@ FeaturesAPI_PointCloudOnFace::FeaturesAPI_PointCloudOnFace(
 {
   if (initialize()) {
     fillAttribute(theFace, myfaceSelected);
-    //fillAttribute(theOptionalPoint, myvertexSelected);
-    //feature()->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->setValue("true");
     setNumberOfPoints(theNumber);
-    execute();
   }
 }
 
@@ -66,20 +63,19 @@ void FeaturesAPI_PointCloudOnFace::dump(ModelHighAPI_Dumper& theDumper) const
   FeaturePtr aBase = feature();
   const std::string& aDocName = theDumper.name(aBase->document());
 
-  AttributeSelectionPtr anAttrObject;
-    anAttrObject = aBase->selection(FeaturesPlugin_PointCloudOnFace::FACE_SELECTED_ID());
+  AttributeSelectionPtr anAttrObject =
+    aBase->selection(FeaturesPlugin_PointCloudOnFace::FACE_SELECTED_ID());
+  int aNbPnts = aBase->integer(FeaturesPlugin_PointCloudOnFace::NUMBER_ID())->value();
 
-  theDumper << aBase << " = model.getPointCloud(" << aDocName << ", " << anAttrObject;
-
-  theDumper << ")" << std::endl;
+  theDumper << aBase << " = model.makeVertexInsideFace(" << aDocName
+            << ", " << anAttrObject << ", " << aNbPnts << ")" << std::endl;
 }
 
 //==================================================================================================
-PointCloudPtr getPointCloud(const std::shared_ptr<ModelAPI_Document>& thePart,
-                            const ModelHighAPI_Selection& theFace,
-                            const ModelHighAPI_Integer& theNumber)
+PointCloudPtr makeVertexInsideFace(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                   const ModelHighAPI_Selection& theFace,
+                                   const ModelHighAPI_Integer& theNumber)
 {
-
   FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_PointCloudOnFace::ID());
   PointCloudPtr aPointCloud;
   aPointCloud.reset(new FeaturesAPI_PointCloudOnFace(aFeature, theFace, theNumber));
index 3969a7a619e435514afd94d7119ea581dc42c198..323a7512a167c7fcae02e8eeac2c74f9c571bf99 100644 (file)
@@ -76,8 +76,8 @@ typedef std::shared_ptr<FeaturesAPI_PointCloudOnFace> PointCloudPtr;
 /// \param theFace the selected face
 /// \param theNumberOfPoints the selected point
 FEATURESAPI_EXPORT
-PointCloudPtr getPointCloud(const std::shared_ptr<ModelAPI_Document>& thePart,
-                           const ModelHighAPI_Selection& theFace,
-                           const ModelHighAPI_Integer& theNumber);
+PointCloudPtr makeVertexInsideFace(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                   const ModelHighAPI_Selection& theFace,
+                                   const ModelHighAPI_Integer& theNumber);
 
 #endif // FeaturesAPI_PointCloudOnFace_H_
index b0220377882b4c5dc21eb2a06db6be2b8353d555..e9a6c64c192ee9b34ce4da507f54f5de65b72079 100644 (file)
@@ -42,6 +42,7 @@ void FeaturesPlugin_PointCloudOnFace::initAttributes()
 {
   // attribute for object selected
   data()->addAttribute(FACE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(NUMBER_ID(), ModelAPI_AttributeInteger::typeId());
 }
 
 //=================================================================================================
diff --git a/src/FeaturesPlugin/Test/TestPointCloud.py b/src/FeaturesPlugin/Test/TestPointCloud.py
new file mode 100644 (file)
index 0000000..74ed507
--- /dev/null
@@ -0,0 +1,50 @@
+# Copyright (C) 2014-2022  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
+#
+
+"""
+      Unit test of makeVertexInsideFace
+"""
+
+from salome.shaper import model
+from GeomAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sphere
+Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
+
+### Get Points Cloud
+PC_1 = model.makeVertexInsideFace(Part_1_doc, model.selection("FACE", "Sphere_1_1/Face_1"), 100)
+
+model.end()
+
+### Check result
+model.testNbResults(PC_1, 1)
+model.testNbSubResults(PC_1, [0])
+model.testNbSubShapes(PC_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(PC_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(PC_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(PC_1, GeomAPI_Shape.VERTEX, [100])
+
+assert(model.checkPythonDump())
index 87e47c378a6753e27f3297a13ee4f79bbe2fb6a8..0292c038ce228d2c71bdcf967359867000744ec9 100644 (file)
                icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false">
         <source path="measurement_widget.xml"/>
       </feature>
+      <feature id="Point_cloud" title="Cloud of points"
+               tooltip="Create points laying on the face"
+               icon="" internal="1">
+        <shape_selector id="face" label="Face"
+                        icon="" tooltip="Select objects"
+                        shape_types="face"/>
+        <integervalue id="number_of_points" label="Nb points"
+                      step="1" default="2"
+                      icon="" tooltip="Number of points"/>
+      </feature>
     </group>
     <group id="Face">
       <feature id="NormalMacro" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
index 393bc27e372859449568357273c7ea34f4f3fcc0..f239bdc761c6488c15316ed5d9ad2c809ec6fefe 100644 (file)
@@ -522,6 +522,7 @@ SET(TEST_NAMES
                Test20247.py
                Test22847.py
                TestPointCoordinates.py
+               TestPointCloud.py
                TestGeometryCalculation.py
                TestBoundingBox.py
                Test23885.py
index 5f75e3e9f3a13cfc46c50f5d9e0709928b18f895..ed135f46745e6a43051e74f6c2752a321e2ef735 100644 (file)
@@ -47,7 +47,8 @@
 #include <GeomLProp_SLProps.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <TopTools_DataMapOfShapeReal.hxx>
-//#include <GeomAPI_Edge.h>
+
+#include <algorithm>
 
 Standard_Boolean comp(const std::pair<TopoDS_Shape, Standard_Real>& theA,
                       const std::pair<TopoDS_Shape, Standard_Real>& theB)
index e316358829e21eb9c1d4283a7fe55d7da7a57941..c0faaacf68f1a13834a7cf23583d15200659ea3f 100644 (file)
@@ -32,6 +32,7 @@ from FeaturesAPI import addFusionFaces
 from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
 from FeaturesAPI import getPointCoordinates, getGeometryCalculation, getBoundingBox
 from FeaturesAPI import getNormal
+from FeaturesAPI import makeVertexInsideFace
 from FeaturesAPI import addRemoveResults
 from FeaturesAPI import addCopy, addImportResult
 from FeaturesAPI import addDefeaturing