Salome HOME
Support of the newer version of OCCT 7.2.0 with patches
[modules/shaper.git] / src / GeomAPI / GeomAPI_Wire.cpp
index 6932444bf75af2be55d57c4d5afe616e47caa31b..e750f3ac59270b32f64ac6c65de31e72a9ec8bfa 100644 (file)
@@ -1,48 +1,43 @@
-// File:        GeomAPI_Wire.cpp
-// Created:     06 Oct 2014
-// Author:      Sergey BELASH
+// 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>
+//
 
-#include <GeomAPI_Interface.h>
-#include <GeomAPI_Wire.h>
+#include "GeomAPI_Wire.h"
 
-#include <Standard_TypeDef.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Wire.hxx>
 #include <BRep_Builder.hxx>
-#include <BRepTools_WireExplorer.hxx>
-
-#include <list>
+#include <TopoDS_Wire.hxx>
 
-GeomAPI_Wire::GeomAPI_Wire() : GeomAPI_Shape()
+//==================================================================================================
+GeomAPI_Wire::GeomAPI_Wire()
 {
-  TopoDS_Compound aBigWireImpl;
-  BRep_Builder aBuilder;
-  aBuilder.MakeCompound(aBigWireImpl);
-  this->setImpl(new TopoDS_Shape(aBigWireImpl));
-}
+  TopoDS_Wire* aWire = new TopoDS_Wire();
 
-void GeomAPI_Wire::addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge)
-{
-  const TopoDS_Edge& anEdge = theEdge->impl<TopoDS_Edge>();
-  if (anEdge.ShapeType() != TopAbs_EDGE)
-    return;
-  TopoDS_Shape& aWire = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
   BRep_Builder aBuilder;
-  aBuilder.Add(aWire, anEdge);
+  aBuilder.MakeWire(*aWire);
+
+  this->setImpl(aWire);
 }
 
-std::list<boost::shared_ptr<GeomAPI_Shape> > GeomAPI_Wire::getEdges()
+//==================================================================================================
+GeomAPI_Wire::GeomAPI_Wire(const std::shared_ptr<GeomAPI_Shape>& theShape)
 {
-  TopoDS_Shape& aShape = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
-  BRepTools_WireExplorer aWireExp(TopoDS::Wire(aShape));
-  std::list<boost::shared_ptr<GeomAPI_Shape> > aResult;
-  for (; aWireExp.More(); aWireExp.Next()) {
-    boost::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
-    anEdge->setImpl(new TopoDS_Shape(aWireExp.Current()));
-    aResult.push_back(anEdge);
+  if (!theShape->isNull() && theShape->isWire()) {
+    setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
   }
-  return aResult;
 }