Salome HOME
2.3.5 Point creation: by geometrical property
authordbv <dbv@opencascade.com>
Fri, 29 Jun 2018 11:39:56 +0000 (14:39 +0300)
committerdbv <dbv@opencascade.com>
Fri, 29 Jun 2018 11:39:56 +0000 (14:39 +0300)
14 files changed:
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/ConstructionAPI/ConstructionAPI_Point.h
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.h
src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py [new file with mode: 0644]
src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py [new file with mode: 0644]
src/ConstructionPlugin/icons/point_by_center_of_circle_24x24.png [new file with mode: 0644]
src/ConstructionPlugin/icons/point_by_center_of_gravity_24x24.png [new file with mode: 0644]
src/ConstructionPlugin/icons/point_by_geometrical_property_32x32.png [new file with mode: 0644]
src/ConstructionPlugin/icons/shapes.png [new file with mode: 0644]
src/ConstructionPlugin/point_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/ModelHighAPI/ModelHighAPI_Macro.h

index e5925482f7c5e32eb995969dab3dee13e608cb76..8f8a45342add6858992f4cf20ad8d0b20f0ca786 100644 (file)
@@ -104,6 +104,22 @@ ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feat
   }
 }
 
+//==================================================================================================
+ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& 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<ModelAPI_Document> & thePart,
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
   return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2, theObject3));
 }
+
+//==================================================================================================
+PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
+                  const ModelHighAPI_Selection& theObject,
+                  const bool theIsCircularEdge)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
+  return PointPtr(new ConstructionAPI_Point(aFeature, theObject, theIsCircularEdge));
+}
index 247a5c22bc6243291396ba6de1e6a2fcf1f9fc44..03eea708e17cbb689dbc6da8e711597e2012f391 100644 (file)
@@ -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<ModelAPI_Feature>& 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<ModelAPI_Document> & 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<ModelAPI_Document> & 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<ModelAPI_Document> & thePart,
+                  const ModelHighAPI_Selection& theObject,
+                  const bool theIsCircularEdge = false);
+
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_POINT_H_ */
index 919c7dcf23e8688368ac78ed06aad390f82b1cd2..7985e93372279036207c59ab89326de221aead64 100644 (file)
@@ -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)
index e6ee010c24e08c03c7eb08ae2809a6a1523a1a24..43b222fb4952eb2dd0b6ee8d37df31a5a1274845 100644 (file)
@@ -29,6 +29,7 @@
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
+#include <GeomAPI_Circ.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Vertex.h>
@@ -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<GeomAPI_Vertex> ConstructionPlugin_Point::createByPlanesIntersec
 
   return aVertex;
 }
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> 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<GeomAPI_Vertex> aVertex;
+  std::shared_ptr<GeomAPI_Pnt> aPnt = GeomAlgoAPI_ShapeTools::centreOfMass(aShape);
+  if (aPnt.get())
+  {
+    aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+  }
+
+  return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> 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<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aShape));
+  std::shared_ptr<GeomAPI_Circ> aCirc = anEdge->circle();
+
+  std::shared_ptr<GeomAPI_Vertex> aVertex;
+  std::shared_ptr<GeomAPI_Pnt> aPnt = aCirc->center();
+  if (aPnt.get()) {
+    aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+  }
+
+  return aVertex;
+}
index 49db67df9ab6e6a2db8f6707e59fcc6daf50ef51..be2892ac7e547c3b95fd8731b008720c2fe16db5 100644 (file)
@@ -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<GeomAPI_Vertex> createByLinesIntersection();
   std::list<std::shared_ptr<GeomAPI_Vertex> > createByLineAndPlaneIntersection();
   std::shared_ptr<GeomAPI_Vertex> createByPlanesIntersection();
+  std::shared_ptr<GeomAPI_Vertex> createByCenterOfGravity();
+  std::shared_ptr<GeomAPI_Vertex> createByCenterOfCircle();
 };
 
 #endif
diff --git a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py
new file mode 100644 (file)
index 0000000..e08fa11
--- /dev/null
@@ -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<mailto: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 (file)
index 0000000..9332523
--- /dev/null
@@ -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<mailto: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 (file)
index 0000000..d582a93
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 (file)
index 0000000..564fe3a
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 (file)
index 0000000..e0bfc92
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 (file)
index 0000000..ea5fb26
Binary files /dev/null and b/src/ConstructionPlugin/icons/shapes.png differ
index 00b4caf8ba18c22c91c81a7315c1a74c9fb997f5..498f49bc99c23ea60e709055685b3c791dc97c0c 100644 (file)
@@ -213,5 +213,36 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         </box>
         </toolbox>
     </box>
+    <box id="by_geometrical_property"
+         title="By geometrical property of object"
+         tooltip="Point by center of gravity or center of circle."
+         icon="icons/Construction/point_by_geometrical_property_32x32.png">
+      <toolbox id="geometrical_property_type">
+        <box id="geometrical_property_type_by_center_of_gravity"
+             title="By center of gravity"
+             tooltip="Point by center of gravity."
+             icon="icons/Construction/point_by_center_of_gravity_24x24.png">
+          <shape_selector id="object_for_center_of_gravity"
+                          label="Object"
+                          tooltip="Object for center of gravity."
+                          icon="icons/Construction/shapes.png"
+                          shape_types="vertices edges wires faces shells solids compsolids compounds">
+            <validator id="GeomValidators_Finite"/>
+          </shape_selector>
+        </box>
+        <box id="geometrical_property_type_by_center_of_circle"
+             title="By center of circle"
+             tooltip="Point by center of circle."
+             icon="icons/Construction/point_by_center_of_circle_24x24.png">
+          <shape_selector id="object_for_center_of_circle"
+                          label="Object"
+                          tooltip="Object for center of circle."
+                          icon="icons/Construction/edge.png"
+                          shape_types="edges">
+            <validator id="GeomValidators_ShapeType" parameters="circle"/>
+          </shape_selector>
+        </box>
+      </toolbox>
+    </box>
   </toolbox>
 </source>
index 32384bf25021c13c6191deb79e34a5ae931a021c..ac3bee2557ca5faee1c330a6731ebeef1bbbe7b7 100644 (file)
 #include <BRepBuilderAPI_MakeVertex.hxx>
 #include <TopoDS_Edge.hxx>
 
+//==================================================================================================
+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<GeomAPI_Shape> theShape)
 {
@@ -132,14 +161,11 @@ std::shared_ptr<GeomAPI_Pnt>
   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<GeomAPI_Pnt>(new GeomAPI_Pnt(aCentre.X(), aCentre.Y(), aCentre.Z()));
 }
 
index 13ced7b69638c5c1f0a6ee8de31d7d19f1cf6aeb..7ed4e9b35f35146afc4186585cd23b7e26e33b11 100644 (file)
     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_ */