GeomAPI_Pln.h
GeomAPI_Shape.h
GeomAPI_Edge.h
+ GeomAPI_Wire.h
GeomAPI_AISObject.h
GeomAPI_IPresentable.h
GeomAPI_Curve.h
GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
GeomAPI_Edge.cpp
+ GeomAPI_Wire.cpp
GeomAPI_AISObject.cpp
GeomAPI_Curve.cpp
)
--- /dev/null
+// File: GeomAPI_Wire.cpp
+// Created: 06 Oct 2014
+// Author: Sergey BELASH
+
+#include <GeomAPI_Interface.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>
+
+GeomAPI_Wire::GeomAPI_Wire() : GeomAPI_Shape()
+{
+ TopoDS_Wire aBigWireImpl;
+ BRep_Builder aBuilder;
+ aBuilder.MakeWire(aBigWireImpl);
+ this->setImpl(new TopoDS_Shape(aBigWireImpl));
+}
+
+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);
+}
+
+std::list<boost::shared_ptr<GeomAPI_Shape> > GeomAPI_Wire::getEdges()
+{
+ 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);
+ }
+ return aResult;
+}
--- /dev/null
+// File: GeomAPI_Wire.hxx
+// Created: 24 Jul 2014
+// Author: Artem ZHIDKOV
+
+#ifndef GEOMAPI_WIRE_H_
+#define GEOMAPI_WIRE_H_
+
+#include <GeomAPI.h>
+#include <GeomAPI_Edge.h>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+
+#include <list>
+
+/**\class GeomAPI_Wire
+ * \ingroup DataModel
+ * \brief Interface to the edge object
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Wire : public GeomAPI_Shape
+{
+ public:
+ /// Creation of empty (null) shape
+ GeomAPI_Wire();
+
+ virtual bool isVertex() const
+ {
+ return false;
+ }
+
+ /// Returns whether the shape is an edge
+ virtual bool isEdge() const
+ {
+ return false;
+ }
+
+ void addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge);
+ std::list<boost::shared_ptr<GeomAPI_Shape> > getEdges();
+
+};
+
+#endif
+
// Author: Artem ZHIDKOV
#include <GeomAlgoAPI_SketchBuilder.h>
+#include <GeomAPI_Wire.h>
#include <set>
fixIntersections(theResultFaces);
}
+void GeomAlgoAPI_SketchBuilder::createFaces(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirX,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirY,
+ const boost::shared_ptr<GeomAPI_Dir>& theNorm,
+ const boost::shared_ptr<GeomAPI_Shape>& theWire,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces)
+{
+ boost::shared_ptr<GeomAPI_Wire> aWire = boost::dynamic_pointer_cast<GeomAPI_Wire>(theWire);
+ if(!aWire)
+ return;
+ // Filter wires, return only faces.
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFilteredWires;
+ createFaces(theOrigin, theDirX, theDirY, theNorm,
+ aWire->getEdges(), theResultFaces, aFilteredWires);
+}
+
+
void GeomAlgoAPI_SketchBuilder::fixIntersections(
std::list<boost::shared_ptr<GeomAPI_Shape> >& theFaces)
{
std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultWires);
+ /** \brief Creates list of faces and unclosed wires on basis of the features of the sketch
+ * \param[in] theOrigin origin point of the sketch
+ * \param[in] theDirX x-direction of the sketch
+ * \param[in] theDirY y-direction of the sketch
+ * \param[in] theNorm normal of the sketch
+ * \param[in] theWire a wire which contains all edges
+ * \param[out] theResultFaces faces based on closed wires
+ *
+ * The algorithm searches all loops of edges surrounding lesser squares.
+ * It finds the vertex with minimal coordinates along X axis (theDirX) and then
+ * goes through the edges passing the surrounding area on the left.
+ */
+ static void createFaces(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirX,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirY,
+ const boost::shared_ptr<GeomAPI_Dir>& theNorm,
+ const boost::shared_ptr<GeomAPI_Shape>& theWire,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces);
+
/** \brief Searches intersections between the faces in the list
* and make holes in the faces to avoid intersections
* \param[in,out] theFaces list of faces to proccess
// Created: 27 Mar 2014
// Author: Mikhail PONIKAROV
-#include "SketchPlugin_Sketch.h"
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeRefList.h>
+#include <Config_PropManager.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
+
#include <GeomAPI_AISObject.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Wire.h>
#include <GeomAPI_XYZ.h>
+
#include <GeomDataAPI_Dir.h>
#include <GeomDataAPI_Point.h>
-#include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomAlgoAPI_CompoundBuilder.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
+
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
#include <ModelAPI_ResultConstruction.h>
-#include <Config_PropManager.h>
+#include <SketchPlugin_Sketch.h>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+
+#include <vector>
using namespace std;
if (aFeaturesPreview.empty())
return;
- std::list<boost::shared_ptr<GeomAPI_Shape> > aLoops;
- std::list<boost::shared_ptr<GeomAPI_Shape> > aWires;
- GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
- aFeaturesPreview, aLoops, aWires);
- aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
- boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
+ // Collect all edges as one big wire
+ boost::shared_ptr<GeomAPI_Wire> aBigWire(new GeomAPI_Wire);
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator aShapeIt = aFeaturesPreview.begin();
+ for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
+ aBigWire->addEdge(*aShapeIt);
+ }
+// GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
+// aFeaturesPreview, aLoops, aWires);
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
- aConstr->setShape(aCompound);
+ aConstr->setShape(aBigWire);
setResult(aConstr);
}