From: jfa Date: Wed, 13 Jul 2022 10:07:55 +0000 (+0300) Subject: Add test and debug X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a8104ff25e4268cd6af1c0bf4a21b5b69230c763;p=modules%2Fshaper.git Add test and debug --- diff --git a/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.cpp b/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.cpp index e84c88ab7..da7ae7ce1 100644 --- a/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.cpp +++ b/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.cpp @@ -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& thePart, - const ModelHighAPI_Selection& theFace, - const ModelHighAPI_Integer& theNumber) +PointCloudPtr makeVertexInsideFace(const std::shared_ptr& 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)); diff --git a/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.h b/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.h index 3969a7a61..323a7512a 100644 --- a/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.h +++ b/src/FeaturesAPI/FeaturesAPI_PointCloudOnFace.h @@ -76,8 +76,8 @@ typedef std::shared_ptr PointCloudPtr; /// \param theFace the selected face /// \param theNumberOfPoints the selected point FEATURESAPI_EXPORT -PointCloudPtr getPointCloud(const std::shared_ptr& thePart, - const ModelHighAPI_Selection& theFace, - const ModelHighAPI_Integer& theNumber); +PointCloudPtr makeVertexInsideFace(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theFace, + const ModelHighAPI_Integer& theNumber); #endif // FeaturesAPI_PointCloudOnFace_H_ diff --git a/src/FeaturesPlugin/FeaturesPlugin_PointCloudOnFace.cpp b/src/FeaturesPlugin/FeaturesPlugin_PointCloudOnFace.cpp index b02203778..e9a6c64c1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_PointCloudOnFace.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_PointCloudOnFace.cpp @@ -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 index 000000000..74ed5073d --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPointCloud.py @@ -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()) diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 87e47c378..0292c038c 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -195,6 +195,16 @@ icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false"> + + + + #include #include -//#include + +#include Standard_Boolean comp(const std::pair& theA, const std::pair& theB) diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index e31635882..c0faaacf6 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -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