From d10ed925d0a56a99162702dea8a00190248eef7c Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 29 Jun 2018 14:39:56 +0300 Subject: [PATCH] 2.3.5 Point creation: by geometrical property --- src/ConstructionAPI/ConstructionAPI_Point.cpp | 61 +++++++++++- src/ConstructionAPI/ConstructionAPI_Point.h | 36 ++++++- src/ConstructionPlugin/CMakeLists.txt | 2 + .../ConstructionPlugin_Point.cpp | 55 ++++++++++- .../ConstructionPlugin_Point.h | 44 +++++++++ ...Point_GeometricalPropertyCenterOfCircle.py | 55 +++++++++++ ...oint_GeometricalPropertyCenterOfGravity.py | 60 ++++++++++++ .../icons/point_by_center_of_circle_24x24.png | Bin 0 -> 1041 bytes .../point_by_center_of_gravity_24x24.png | Bin 0 -> 943 bytes .../point_by_geometrical_property_32x32.png | Bin 0 -> 846 bytes src/ConstructionPlugin/icons/shapes.png | Bin 0 -> 802 bytes src/ConstructionPlugin/point_widget.xml | 31 ++++++ src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp | 36 ++++++- src/ModelHighAPI/ModelHighAPI_Macro.h | 90 ++++++++++++++++++ 14 files changed, 456 insertions(+), 14 deletions(-) create mode 100644 src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py create mode 100644 src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py create mode 100644 src/ConstructionPlugin/icons/point_by_center_of_circle_24x24.png create mode 100644 src/ConstructionPlugin/icons/point_by_center_of_gravity_24x24.png create mode 100644 src/ConstructionPlugin/icons/point_by_geometrical_property_32x32.png create mode 100644 src/ConstructionPlugin/icons/shapes.png diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index e5925482f..8f8a45342 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -104,6 +104,22 @@ ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theObject, + const bool theIsCircularEdge) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + { + if (theIsCircularEdge) { + setByCenterOfCircle(theObject); + } else { + setByCenterOfGravity(theObject); + } + } +} + //================================================================================================== ConstructionAPI_Point::~ConstructionAPI_Point() { @@ -214,6 +230,26 @@ void ConstructionAPI_Point::setByPlanesIntersection(const ModelHighAPI_Selection execute(); } +//================================================================================================== +void ConstructionAPI_Point::setByCenterOfGravity(const ModelHighAPI_Selection& theObject) +{ + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY(), + mycreationMethod); + fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY(), + mygeometricalPropertyType); + fillAttribute(theObject, myobjectForCenterOfGravity); +} + +//================================================================================================== +void ConstructionAPI_Point::setByCenterOfCircle(const ModelHighAPI_Selection& theObject) +{ + fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY(), + mycreationMethod); + fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE(), + mygeometricalPropertyType); + fillAttribute(theObject, myobjectForCenterOfCircle); +} + //================================================================================================== void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const { @@ -256,11 +292,21 @@ void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const } theDumper << ", " << reverse()->value(); } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION()) { - theDumper << mypoinToProject << ", "; + theDumper << poinToProject() << ", "; if (projectionType()->value() == ConstructionPlugin_Point::PROJECTION_TYPE_ON_EDGE()) { - theDumper << myedgeForPointProjection; + theDumper << edgeForPointProjection(); } else { - theDumper << myfaceForPointProjection; + theDumper << faceForPointProjection(); + } + } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY()) { + if (geometricalPropertyType()->value() == + ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY()) + { + theDumper << objectForCenterOfGravity(); + } + else + { + theDumper << objectForCenterOfCircle() << ", " << true; } } @@ -323,3 +369,12 @@ PointPtr addPoint(const std::shared_ptr & thePart, std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2, theObject3)); } + +//================================================================================================== +PointPtr addPoint(const std::shared_ptr & thePart, + const ModelHighAPI_Selection& theObject, + const bool theIsCircularEdge) +{ + std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); + return PointPtr(new ConstructionAPI_Point(aFeature, theObject, theIsCircularEdge)); +} diff --git a/src/ConstructionAPI/ConstructionAPI_Point.h b/src/ConstructionAPI/ConstructionAPI_Point.h index 247a5c22b..03eea708e 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.h +++ b/src/ConstructionAPI/ConstructionAPI_Point.h @@ -70,11 +70,17 @@ public: const ModelHighAPI_Selection& theObject2, const ModelHighAPI_Selection& theObject3); + /// Constructor with values: object and circular edge flag. + CONSTRUCTIONAPI_EXPORT + ConstructionAPI_Point(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theObject, + const bool theIsCircularEdge = false); + /// Destructor. CONSTRUCTIONAPI_EXPORT virtual ~ConstructionAPI_Point(); - INTERFACE_24(ConstructionPlugin_Point::ID(), + INTERFACE_27(ConstructionPlugin_Point::ID(), x, ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble, /** X attribute */, y, ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble, /** Y attribute */, z, ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble, /** Z attribute */, @@ -117,10 +123,15 @@ public: projectionType, ConstructionPlugin_Point::PROJECTION_TYPE(), ModelAPI_AttributeString, /** Type of the point projection */, faceForPointProjection, ConstructionPlugin_Point::FACE_FOR_POINT_PROJECTION(), - ModelAPI_AttributeSelection, /** Point to project on edge */, + ModelAPI_AttributeSelection, /** Face for point projection */, edgeForPointProjection, ConstructionPlugin_Point::EDGE_FOR_POINT_PROJECTION(), - ModelAPI_AttributeSelection, /** Edge for point projection */) - + ModelAPI_AttributeSelection, /** Edge for point projection */, + geometricalPropertyType, ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE(), + ModelAPI_AttributeString, /** Type of the geometrical property */, + objectForCenterOfGravity, ConstructionPlugin_Point::OBJECT_FOR_CENTER_OF_GRAVITY(), + ModelAPI_AttributeSelection, /** Object for center of gravity */, + objectForCenterOfCircle, ConstructionPlugin_Point::OBJECT_FOR_CENTER_OF_CIRCLE(), + ModelAPI_AttributeSelection, /** Object for center of circle */) /// Set point values. CONSTRUCTIONAPI_EXPORT @@ -161,6 +172,14 @@ public: const ModelHighAPI_Selection& theFace2, const ModelHighAPI_Selection& theFace3); + /// Set object for center of gravity. + CONSTRUCTIONAPI_EXPORT + void setByCenterOfGravity(const ModelHighAPI_Selection& theObject); + + /// Set object for center of circular edge. + CONSTRUCTIONAPI_EXPORT + void setByCenterOfCircle(const ModelHighAPI_Selection& theObject); + /// Dump wrapped feature CONSTRUCTIONAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -204,11 +223,18 @@ PointPtr addPoint(const std::shared_ptr & thePart, const bool theReverse = false); /// \ingroup CPPHighAPI -/// \brief Create Point feature as an intersection of selected planes +/// \brief Create Point feature as an intersection of selected planes. CONSTRUCTIONAPI_EXPORT PointPtr addPoint(const std::shared_ptr & thePart, const ModelHighAPI_Selection& theObject1, const ModelHighAPI_Selection& theObject2, const ModelHighAPI_Selection& theObject3); +/// \ingroup CPPHighAPI +/// \brief Create Point feature as a geometrical property. +CONSTRUCTIONAPI_EXPORT +PointPtr addPoint(const std::shared_ptr & thePart, + const ModelHighAPI_Selection& theObject, + const bool theIsCircularEdge = false); + #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_POINT_H_ */ diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index 919c7dcf2..7985e9337 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -84,5 +84,7 @@ ADD_UNIT_TESTS(TestAxisCreation.py TestPoint_Edge.py TestPoint_ProjectOnEdge.py TestPoint_ProjectOnFace.py + TestPoint_GeometricalPropertyCenterOfGravity.py + TestPoint_GeometricalPropertyCenterOfCircle.py TestPointName.py TestPlane.py) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index e6ee010c2..43b222fb4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -76,10 +77,13 @@ void ConstructionPlugin_Point::initAttributes() data()->addAttribute(FACE_FOR_POINT_PROJECTION(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(INTERSECTION_TYPE(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(INTERSECTION_PLANE_1(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(INTERSECTION_PLANE_2(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(INTERSECTION_PLANE_3(), ModelAPI_AttributeSelection::typeId()); + + data()->addAttribute(GEOMETRICAL_PROPERTY_TYPE(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(OBJECT_FOR_CENTER_OF_GRAVITY(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(OBJECT_FOR_CENTER_OF_CIRCLE(), ModelAPI_AttributeSelection::typeId()); } //================================================================================================== @@ -123,6 +127,13 @@ void ConstructionPlugin_Point::execute() } else { aShape = createByPlanesIntersection(); } + } else if (aCreationMethod == CREATION_METHOD_BY_GEOMETRICAL_PROPERTY()) { + std::string aGeometricalPropertyType = string(GEOMETRICAL_PROPERTY_TYPE())->value(); + if (aGeometricalPropertyType == GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY()) { + aShape = createByCenterOfGravity(); + } else { + aShape = createByCenterOfCircle(); + } } if(!aShape.get()) { @@ -326,3 +337,45 @@ std::shared_ptr ConstructionPlugin_Point::createByPlanesIntersec return aVertex; } + +//================================================================================================== +std::shared_ptr ConstructionPlugin_Point::createByCenterOfGravity() +{ + // Get shape. + AttributeSelectionPtr aShapeSelection = selection(OBJECT_FOR_CENTER_OF_GRAVITY()); + GeomShapePtr aShape = aShapeSelection->value(); + if (!aShape.get()) + { + aShape = aShapeSelection->context()->shape(); + } + + std::shared_ptr aVertex; + std::shared_ptr aPnt = GeomAlgoAPI_ShapeTools::centreOfMass(aShape); + if (aPnt.get()) + { + aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z())); + } + + return aVertex; +} + +//================================================================================================== +std::shared_ptr ConstructionPlugin_Point::createByCenterOfCircle() +{ + // Get shape. + AttributeSelectionPtr aShapeSelection = selection(OBJECT_FOR_CENTER_OF_CIRCLE()); + GeomShapePtr aShape = aShapeSelection->value(); + if (!aShape.get()) { + aShape = aShapeSelection->context()->shape(); + } + std::shared_ptr anEdge(new GeomAPI_Edge(aShape)); + std::shared_ptr aCirc = anEdge->circle(); + + std::shared_ptr aVertex; + std::shared_ptr aPnt = aCirc->center(); + if (aPnt.get()) { + aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z())); + } + + return aVertex; +} diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.h b/src/ConstructionPlugin/ConstructionPlugin_Point.h index 49db67df9..be2892ac7 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.h @@ -82,6 +82,13 @@ public: return MY_CREATION_METHOD_ID; } + /// Attribute name for creation method. + inline static const std::string& CREATION_METHOD_BY_GEOMETRICAL_PROPERTY() + { + static const std::string MY_CREATION_METHOD_ID("by_geometrical_property"); + return MY_CREATION_METHOD_ID; + } + /// Attribute name for X coordinate. inline static const std::string& X() { @@ -292,6 +299,41 @@ public: return ATTR_ID; } + /// Attribute name for property type. + inline static const std::string& GEOMETRICAL_PROPERTY_TYPE() + { + static const std::string ATTR_ID("geometrical_property_type"); + return ATTR_ID; + } + + /// Attribute name for property type by center of gravity. + inline static const std::string& GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY() + { + static const std::string PROPERTY_TYPE("geometrical_property_type_by_center_of_gravity"); + return PROPERTY_TYPE; + } + + /// Attribute name for property type by center of circle. + inline static const std::string& GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE() + { + static const std::string PROPERTY_TYPE("geometrical_property_type_by_center_of_circle"); + return PROPERTY_TYPE; + } + + /// Attribute name for selected object for center of gravity. + inline static const std::string& OBJECT_FOR_CENTER_OF_GRAVITY() + { + static const std::string ATTR_ID("object_for_center_of_gravity"); + return ATTR_ID; + } + + /// Attribute name for selected object for center of cricle. + inline static const std::string& OBJECT_FOR_CENTER_OF_CIRCLE() + { + static const std::string ATTR_ID("object_for_center_of_circle"); + return ATTR_ID; + } + /// Creates a new part document if needed. CONSTRUCTIONPLUGIN_EXPORT virtual void execute(); @@ -316,6 +358,8 @@ private: std::shared_ptr createByLinesIntersection(); std::list > createByLineAndPlaneIntersection(); std::shared_ptr createByPlanesIntersection(); + std::shared_ptr createByCenterOfGravity(); + std::shared_ptr createByCenterOfCircle(); }; #endif diff --git a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py new file mode 100644 index 000000000..e08fa1158 --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py @@ -0,0 +1,55 @@ +## Copyright (C) 2014-2017 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 +## + +""" +Test case for Construction Point feature by center of gravity. +""" + +from salome.shaper import model +from GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-50, 25, 25) +SketchArc_1 = Sketch_1.addArc(50, 25, 25, 25, 75, 25, True) +model.do() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 100) +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2"), True) +Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), True) +Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), True) +model.do() +model.end() + +assert (len(Point_2.results()) > 0) +rightPosition = GeomAPI_Vertex(-50, 25, 0) +assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) + +assert (len(Point_3.results()) > 0) +rightPosition = GeomAPI_Vertex(50, 25, 0) +assert(rightPosition.isEqual(Point_3.results()[0].resultSubShapePair()[0].shape())) + +assert (len(Point_4.results()) > 0) +rightPosition = GeomAPI_Vertex(0, 0, 100) +assert(rightPosition.isEqual(Point_4.results()[0].resultSubShapePair()[0].shape())) + +assert(model.checkPythonDump()) diff --git a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py new file mode 100644 index 000000000..933252369 --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py @@ -0,0 +1,60 @@ +## Copyright (C) 2014-2017 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 +## + +""" +Test case for Construction Point feature by center of gravity. +""" + +from salome.shaper import model +from GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchCircle_1 = Sketch_1.addCircle(-50, 25, 25) +SketchCircle_2 = Sketch_1.addCircle(50, 25, 25) +model.do() +Box_1 = model.addBox(Part_1_doc, 50, 50, 50) +Point_2 = model.addPoint(Part_1_doc, model.selection("COMPOUND", "Sketch_1")) +Point_3 = model.addPoint(Part_1_doc, model.selection("SOLID", "Box_1_1")) +Point_4 = model.addPoint(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "Box_1_1/Left&Box_1_1/Top")) +model.do() +model.end() + +assert (len(Point_2.results()) > 0) +rightPosition = GeomAPI_Vertex(0, 0, 25) +assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) + +assert (len(Point_3.results()) > 0) +rightPosition = GeomAPI_Vertex(25, 25, 25) +assert(rightPosition.isEqual(Point_3.results()[0].resultSubShapePair()[0].shape())) + +assert (len(Point_4.results()) > 0) +rightPosition = GeomAPI_Vertex(25, 25, 50) +assert(rightPosition.isEqual(Point_4.results()[0].resultSubShapePair()[0].shape())) + +assert (len(Point_5.results()) > 0) +rightPosition = GeomAPI_Vertex(25, 0, 50) +assert(rightPosition.isEqual(Point_5.results()[0].resultSubShapePair()[0].shape())) + +assert(model.checkPythonDump()) diff --git a/src/ConstructionPlugin/icons/point_by_center_of_circle_24x24.png b/src/ConstructionPlugin/icons/point_by_center_of_circle_24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..d582a9383b32de8256a0c8d35e1681d3c0c87683 GIT binary patch literal 1041 zcmV+s1n&EZP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGh)&Kwv)&Y=jd7JN&o-=8FWQhbW?9;ba!ELWdLwtX>N2bZe?^JG%heMGBNQWX_Wu~18zw~K~zXf z?UmbW6G0S*lX|Ncyu`gEF}6)xwGCReMcUeAH#;-C-89*q-L!#`V&6&hE z9kE<)Zb;1tvTj8s;x>tdwu-uAh+29*8;ckn0bedRi^b-BKEF3^!AoW$dZG|NlD0dMcvLpvYU`> z7~Zc0?3|S`-3N)ci^Sdm$q&Q$r9u%p9M&>@;7{^wzX8c3N@`t=nz~V&Fu%s)#TOTw##7I-e{Dz*MIZQTL*B1({ZYYFk0t(!RoeVTS zp-g5$Z6b9wjIB}Fb{wO3^p65=-^e3o1nZ)5HQfmd9D=jC=5-jyzeJ@=1#G7)l(x&&O6q)F zLPxAH_s^7)Wgr)v#RVwxMIscl^W{DO60-BCHqCjH9X=mB3z&EWCS8XEy(S}S{pkM* z_`L?eZW>}ffZXT2Tz`V?PA2qF7(1(F?CcB@N0kif2!!r0SJhG;Rsa?z>m5;$=oUP8 zL^ZdFdx|3w`-FtEmCP0qy$UPq_H5m10ecIxe*y)Tk=zo2I2S>thoa_GaZhnTnk$lS zb%8vmVe4e~tLOne{BRy9CvCOd_s{S%*}MzZ&@;#T{?C63{QBGcOMJfXpicT_V?ROW00000 LNkvXXu0mjf)j`w_ literal 0 HcmV?d00001 diff --git a/src/ConstructionPlugin/icons/point_by_center_of_gravity_24x24.png b/src/ConstructionPlugin/icons/point_by_center_of_gravity_24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..564fe3a25aa3030a037abe7ed833f6f24b9358a0 GIT binary patch literal 943 zcmV;g15o^lP)N2bZe?^J zG%heMGBNQWX_Wu~11w2IK~zXfot6DdQ&AYl{SShENW8NQ#iAg>BGg6oLs`3X>TLIJ znmWxl(n@V<&NOtsYifzj_<|cCw ze7QW_bHAT+o^#G~y<7z&Qw1?H?vaG$<|Hf+o{1Z`+S!LhrVjB7*Gz_{9s^ZTEvQTC z-4dH?fBXBjd0$GauGQ9)J+C@_^_BdjKQXNYQ+ERv{Q~k2y7QrDif7 z%>(yq;i&NnwBDV7Z3nX!06wgGyHFN1AAJ4YsgX0GxinozXP!mOu~c1S({vRSz{pin ziHw`Vnx)mZLHF2O2Ti-oaWX<#v{gnhKcAscJAg#SzY{iPqb3DH({y%{E|G7J&wxNx zB4nF7;fB@R34oi!K@s{2P!?7%QdB_|MCvO=DNioEThAqd>eOj4Kl>z_F9I+u{}<0N z*3Nbi>g>QMC{C1vJhzleNnmYc1BLhdbj1*3I0H8wzI6+b(bxgWwI=$pp=%Ht39NVG z187PbK!4Fp$9N2=v)qI9hITQ>RV3H8h&f+e2km4f9s{r({Zn7X+!1i?$$Q{P?L7wI zW|npjLR?uR)uz~V2qqUt$m=cl$(Rby0C>rw3MwJDwTI3ewSiBDAaW#y9QVXy0E#_s zfB~D^>{z0{ryn7@sKzA#`_dNeVeFpNW1>! z9~B3|DcSVwE=PV5u~q=r?9?2C04|VK{KiYMY_a?-Bjfvg_i`((b`Ig?^&hN9b~tv< R<(B{e002ovPDHLkV1l4ZoofI9 literal 0 HcmV?d00001 diff --git a/src/ConstructionPlugin/icons/point_by_geometrical_property_32x32.png b/src/ConstructionPlugin/icons/point_by_geometrical_property_32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..e0bfc926a0e4ee8d383f37c036a8d778a27dee0b GIT binary patch literal 846 zcmV-U1F`&xP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmOaK59OaUR#CPM%K02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;2FkAZe8V00O>AL_t(oN4=N7Z__{&$IXv{jUtGh#z8_X z{8|}cKnk$~b_(%X^*KQK(FU;~mUO5Bfi@C?Qi+KPRYF3L76Ao`UlM-=D+>!Oohva_ zZOQRo@PU1~HZ-*x>66@h_wIea_SuP}Fvhx~7kyv1={&$FeDNaztj8x=|6KF z1~Nr&1cJoG$D1D^{ck>EAY=Ir7_|6;Lw<#kTMwiR*6w%B9lKVIh)>K!#XAhZ+cIAe zCwm9VY-09Phd3e{`0sDI{?mg@E4UFdmM5(()$V~-r#K=SSi}I6VqqA~bnBYwOzz7K z??{`(?>C$ieL2#n7Tm`v)2;BjpmBRUcur*920++UP14|T%5YwQp-CRArZb&BdG-j7 zgU0b10P#5`m)p)`(SUBayET(MX^#^!Fq1BnD2O~lApQoQUwEwL-8|%Gu@-y5k4$_9 z;I#!#aZ@#%>v-gdYLFiw{FTReO@s{~ai4)VN~5ur$Kn?3GU-mWK%U|_XdJTvgAibh z$D#q;hCPMSQ5*-2<28W55l*EHa#NvnTgoIi)V$;3EeXaR!d+73bwT6!4IrA~o>2|= zEgbPH*p@l?4tNdm@o-JhcufPRs^h&G;NXQR%OgSKRSk?zzvSY`_nr)_1#d1hAc(Kv z)Aptr5XG}adI9sBVn7s!M}YHuE^z~$;@-J%eWC`si6e;_IN*&$#cf)a)hA{k#4=v( zvRdS?fy3piZ4(@y=bU%W zy#xT}i&qZEMnyjq1u9`oFmVno0TSnYQ|0`Ne`Dj>a#!0ZB7m%A)p_O^Q|FDUtLE&i z95NaVdqXKCVPblcnp$1!%d5UeOYfUrgc~p}^BR@&_-#odgI<4NsL^V`NZ=twjutd@ zGg1PPLG{>=+i7HMMC$y|CCZA*6-9<92w;p+LVUcEo0%#04!AuL4FKRsVxm%AQKi|f z70z)Fex=_2{z!VTh_7K#6$O&2Bv_qQMG+GK0OuT>bFBUF!L#TgkJpPO?-H&0)&S0t z>Bw*fgTXT<)2;5{=GN`S4%hktgP#6AJa24ZdD&S=wjD#V?I?;*7s6_`>~_+DNZaRj zm%VIl8a{UE+Wq<#l$VZ~Z3ZfmkEXx=g{)Wk! zX))Fmn;>d+E!L8%2Lu4N^6Rw*jqY(?PHuX3MkY1CZlP28`P}ahV0pz0f8aMKVm!%W zRUGLKq^H<5BNO9NduPX85daq7G&fqDl?#l7wxWW3L`PN%xT%xJvB68M&(dUl0byh(PMU1Y8uR z28V`zeYSTS&lVMHBZ&fm0H$WAX>@$T?;afB4A?&KqphgMpieS3I8sxc>%O(Px;u61 z?EIWMJT~f|nwycOkn~gKQqP8e^Q|C?A6MSF)*?nuyIgzkkF;HXC_1J)u(jD9l0% + + + + + + + + + + + + + + diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 32384bf25..ac3bee255 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -81,6 +81,35 @@ #include #include +//================================================================================================== +static GProp_GProps props(const TopoDS_Shape& theShape) +{ + GProp_GProps aGProps; + + if (theShape.ShapeType() == TopAbs_EDGE || theShape.ShapeType() == TopAbs_WIRE) + { + BRepGProp::LinearProperties(theShape, aGProps); + } + else if (theShape.ShapeType() == TopAbs_FACE || theShape.ShapeType() == TopAbs_SHELL) + { + const Standard_Real anEps = 1.e-6; + BRepGProp::SurfaceProperties(theShape, aGProps, anEps); + } + else if (theShape.ShapeType() == TopAbs_SOLID || theShape.ShapeType() == TopAbs_COMPSOLID) + { + BRepGProp::VolumeProperties(theShape, aGProps); + } + else if (theShape.ShapeType() == TopAbs_COMPOUND) + { + for (TopoDS_Iterator anIt(theShape); anIt.More(); anIt.Next()) + { + aGProps.Add(props(anIt.Value())); + } + } + + return aGProps; +} + //================================================================================================== double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr theShape) { @@ -132,14 +161,11 @@ std::shared_ptr gp_Pnt aCentre; if(aShape.ShapeType() == TopAbs_VERTEX) { aCentre = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); - } else if(aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(aShape, aGProps); - aCentre = aGProps.CentreOfMass(); } else { - const Standard_Real anEps = 1.e-6; - BRepGProp::SurfaceProperties(aShape, aGProps, anEps); + aGProps = props(aShape); aCentre = aGProps.CentreOfMass(); } + return std::shared_ptr(new GeomAPI_Pnt(aCentre.X(), aCentre.Y(), aCentre.Z())); } diff --git a/src/ModelHighAPI/ModelHighAPI_Macro.h b/src/ModelHighAPI/ModelHighAPI_Macro.h index 13ced7b69..7ed4e9b35 100644 --- a/src/ModelHighAPI/ModelHighAPI_Macro.h +++ b/src/ModelHighAPI/ModelHighAPI_Macro.h @@ -831,5 +831,95 @@ END_INIT() \ public: +//-------------------------------------------------------------------------------------- +#define INTERFACE_27(KIND, \ + N_0, AN_0, T_0, C_0, \ + N_1, AN_1, T_1, C_1, \ + N_2, AN_2, T_2, C_2, \ + N_3, AN_3, T_3, C_3, \ + N_4, AN_4, T_4, C_4, \ + N_5, AN_5, T_5, C_5, \ + N_6, AN_6, T_6, C_6, \ + N_7, AN_7, T_7, C_7, \ + N_8, AN_8, T_8, C_8, \ + N_9, AN_9, T_9, C_9, \ + N_10, AN_10, T_10, C_10, \ + N_11, AN_11, T_11, C_11, \ + N_12, AN_12, T_12, C_12, \ + N_13, AN_13, T_13, C_13, \ + N_14, AN_14, T_14, C_14, \ + N_15, AN_15, T_15, C_15, \ + N_16, AN_16, T_16, C_16, \ + N_17, AN_17, T_17, C_17, \ + N_18, AN_18, T_18, C_18, \ + N_19, AN_19, T_19, C_19, \ + N_20, AN_20, T_20, C_20, \ + N_21, AN_21, T_21, C_21, \ + N_22, AN_22, T_22, C_22, \ + N_23, AN_23, T_23, C_23, \ + N_24, AN_24, T_24, C_24, \ + N_25, AN_25, T_25, C_25, \ + N_26, AN_26, T_26, C_26) \ + public: \ + INTERFACE_COMMON(KIND) \ + DEFINE_ATTRIBUTE(N_0, T_0, C_0) \ + DEFINE_ATTRIBUTE(N_1, T_1, C_1) \ + DEFINE_ATTRIBUTE(N_2, T_2, C_2) \ + DEFINE_ATTRIBUTE(N_3, T_3, C_3) \ + DEFINE_ATTRIBUTE(N_4, T_4, C_4) \ + DEFINE_ATTRIBUTE(N_5, T_5, C_5) \ + DEFINE_ATTRIBUTE(N_6, T_6, C_6) \ + DEFINE_ATTRIBUTE(N_7, T_7, C_7) \ + DEFINE_ATTRIBUTE(N_8, T_8, C_8) \ + DEFINE_ATTRIBUTE(N_9, T_9, C_9) \ + DEFINE_ATTRIBUTE(N_10, T_10, C_10) \ + DEFINE_ATTRIBUTE(N_11, T_11, C_11) \ + DEFINE_ATTRIBUTE(N_12, T_12, C_12) \ + DEFINE_ATTRIBUTE(N_13, T_13, C_13) \ + DEFINE_ATTRIBUTE(N_14, T_14, C_14) \ + DEFINE_ATTRIBUTE(N_15, T_15, C_15) \ + DEFINE_ATTRIBUTE(N_16, T_16, C_16) \ + DEFINE_ATTRIBUTE(N_17, T_17, C_17) \ + DEFINE_ATTRIBUTE(N_18, T_18, C_18) \ + DEFINE_ATTRIBUTE(N_19, T_19, C_19) \ + DEFINE_ATTRIBUTE(N_20, T_20, C_20) \ + DEFINE_ATTRIBUTE(N_21, T_21, C_21) \ + DEFINE_ATTRIBUTE(N_22, T_22, C_22) \ + DEFINE_ATTRIBUTE(N_23, T_23, C_23) \ + DEFINE_ATTRIBUTE(N_24, T_24, C_24) \ + DEFINE_ATTRIBUTE(N_25, T_25, C_25) \ + DEFINE_ATTRIBUTE(N_26, T_26, C_26) \ + protected: \ + START_INIT() \ + SET_ATTRIBUTE(N_0, T_0, AN_0) \ + SET_ATTRIBUTE(N_1, T_1, AN_1) \ + SET_ATTRIBUTE(N_2, T_2, AN_2) \ + SET_ATTRIBUTE(N_3, T_3, AN_3) \ + SET_ATTRIBUTE(N_4, T_4, AN_4) \ + SET_ATTRIBUTE(N_5, T_5, AN_5) \ + SET_ATTRIBUTE(N_6, T_6, AN_6) \ + SET_ATTRIBUTE(N_7, T_7, AN_7) \ + SET_ATTRIBUTE(N_8, T_8, AN_8) \ + SET_ATTRIBUTE(N_9, T_9, AN_9) \ + SET_ATTRIBUTE(N_10, T_10, AN_10) \ + SET_ATTRIBUTE(N_11, T_11, AN_11) \ + SET_ATTRIBUTE(N_12, T_12, AN_12) \ + SET_ATTRIBUTE(N_13, T_13, AN_13) \ + SET_ATTRIBUTE(N_14, T_14, AN_14) \ + SET_ATTRIBUTE(N_15, T_15, AN_15) \ + SET_ATTRIBUTE(N_16, T_16, AN_16) \ + SET_ATTRIBUTE(N_17, T_17, AN_17) \ + SET_ATTRIBUTE(N_18, T_18, AN_18) \ + SET_ATTRIBUTE(N_19, T_19, AN_19) \ + SET_ATTRIBUTE(N_20, T_20, AN_20) \ + SET_ATTRIBUTE(N_21, T_21, AN_21) \ + SET_ATTRIBUTE(N_22, T_22, AN_22) \ + SET_ATTRIBUTE(N_23, T_23, AN_23) \ + SET_ATTRIBUTE(N_24, T_24, AN_24) \ + SET_ATTRIBUTE(N_25, T_25, AN_25) \ + SET_ATTRIBUTE(N_26, T_26, AN_26) \ + END_INIT() \ + public: + //-------------------------------------------------------------------------------------- #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_MACRO_H_ */ -- 2.39.2