1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesPlugin_PointCloudOnFace.h"
22 #include <ModelAPI_AttributeSelection.h>
23 #include <ModelAPI_AttributeString.h>
24 #include <ModelAPI_AttributeInteger.h>
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Session.h>
27 #include <ModelAPI_Validator.h>
28 #include <Config_PropManager.h>
29 #include <GeomAlgoAPI_PointCloudOnFace.h>
30 #include <ModelAPI_ResultConstruction.h>
35 //=================================================================================================
36 FeaturesPlugin_PointCloudOnFace::FeaturesPlugin_PointCloudOnFace()
40 //=================================================================================================
41 void FeaturesPlugin_PointCloudOnFace::initAttributes()
43 // attribute for object selected
44 data()->addAttribute(FACE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
45 data()->addAttribute(NUMBER_ID(), ModelAPI_AttributeInteger::typeId());
48 //=================================================================================================
49 void FeaturesPlugin_PointCloudOnFace::attributeChanged(const std::string& /*theID*/)
53 //=================================================================================================
54 void FeaturesPlugin_PointCloudOnFace::execute()
57 AttributeSelectionPtr aSelectionFace = selection(FACE_SELECTED_ID());
61 if (aSelectionFace && aSelectionFace->isInitialized()) {
62 aShape = aSelectionFace->value();
63 if (!aShape && aSelectionFace->context())
64 aShape = aSelectionFace->context()->shape();
67 // Getting number of points
68 int aNbPnts = integer(FeaturesPlugin_PointCloudOnFace::NUMBER_ID())->value();
70 if (aShape && aNbPnts >= 2) {
72 std::shared_ptr<GeomAPI_Shape> aPoints(new GeomAPI_Shape);
73 if (!GeomAlgoAPI_PointCloudOnFace::PointCloud(aShape,
77 setError("Error in points calculation :" + aError);
79 ResultConstructionPtr aConstr = document()->createConstruction(data());
80 aConstr->setInfinite(true);
81 aConstr->setShape(aPoints);