Salome HOME
Correct case when the weak-named attribute is dumped in Geom mode: geometrical repres...
[modules/shaper.git] / src / GeomAPI / GeomAPI_Wire.cpp
index 32df6d6bbc55e39207ade979d5e3e2810ec063e2..65729cbf7bed5f9d49b16703852d3c74f73a366e 100644 (file)
@@ -81,6 +81,8 @@ bool GeomAPI_Wire::isPolygon(std::list<GeomPointPtr>& thePoints) const
 //==================================================================================================
 bool GeomAPI_Wire::isRectangle(std::list<GeomPointPtr>& thePoints) const
 {
+  thePoints.clear();
+
   const TopoDS_Wire& aWire = TopoDS::Wire(impl<TopoDS_Shape>());
   const Handle(Standard_Type)& aLineType = STANDARD_TYPE(Geom_Line);
 
@@ -113,3 +115,20 @@ bool GeomAPI_Wire::isRectangle(std::list<GeomPointPtr>& thePoints) const
   }
   return true;
 }
+
+//==================================================================================================
+GeomPointPtr GeomAPI_Wire::middlePoint() const
+{
+  // find middle edge in the wire
+  std::list<GeomShapePtr> aSubs = subShapes(EDGE);
+  size_t aNbSubs = aSubs.size();
+  if (aNbSubs == 0)
+    return GeomPointPtr();
+
+  aNbSubs /= 2;
+  for (; aNbSubs > 0; --aNbSubs)
+    aSubs.pop_front();
+
+  // compute middle point on the middle edge
+  return aSubs.front()->middlePoint();
+}