From: dbv Date: Fri, 29 Jun 2018 11:39:56 +0000 (+0300) Subject: 2.3.5 Point creation: by geometrical property X-Git-Tag: SHAPER_V9_1_0RC1~148 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d10ed925d0a56a99162702dea8a00190248eef7c;p=modules%2Fshaper.git 2.3.5 Point creation: by geometrical property --- 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 000000000..d582a9383 Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_center_of_circle_24x24.png differ 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 000000000..564fe3a25 Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_center_of_gravity_24x24.png differ 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 000000000..e0bfc926a Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_geometrical_property_32x32.png differ diff --git a/src/ConstructionPlugin/icons/shapes.png b/src/ConstructionPlugin/icons/shapes.png new file mode 100644 index 000000000..ea5fb26d6 Binary files /dev/null and b/src/ConstructionPlugin/icons/shapes.png differ diff --git a/src/ConstructionPlugin/point_widget.xml b/src/ConstructionPlugin/point_widget.xml index 00b4caf8b..498f49bc9 100644 --- a/src/ConstructionPlugin/point_widget.xml +++ b/src/ConstructionPlugin/point_widget.xml @@ -213,5 +213,36 @@ email : webmaster.salome@opencascade.com + + + + + + + + + + + + + + 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_ */