Visualize three planes for sketch.
SET(PROJECT_HEADERS
GeomAlgoAPI.h
+ GeomAlgoAPI_CompoundBuilder.h
GeomAlgoAPI_FaceBuilder.h
)
SET(PROJECT_SOURCES
+ GeomAlgoAPI_CompoundBuilder.cpp
GeomAlgoAPI_FaceBuilder.cpp
)
--- /dev/null
+// File: GeomAlgoAPI_CompoundBuilder.cpp
+// Created: 24 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+//#include <gp_Pln.hxx>
+//#include <BRepBuilderAPI_MakeFace.hxx>
+//#include <TopoDS_Face.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_CompoundBuilder::compound
+ (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes)
+{
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound(aComp);
+
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theShapes.begin(),
+ aLast = theShapes.end();
+ for (; anIt != aLast; anIt++) {
+ aBuilder.Add(aComp, (*anIt)->impl<TopoDS_Shape>());
+ }
+
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aComp));
+ return aRes;
+}
--- /dev/null
+// File: GeomAlgoAPI_CompoundBuilder.h
+// Created: 24 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef GeomAlgoAPI_CompoundBuilder_HeaderFile
+#define GeomAlgoAPI_CompoundBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+#include <boost/shared_ptr.hpp>
+
+#include <list>
+
+/**\class GeomAlgoAPI_CompoundBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_CompoundBuilder
+{
+public:
+ /// Creates compund of the given shapes
+ /// \param theShapes a list of shapes
+ static boost::shared_ptr<GeomAPI_Shape> compound
+ (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes);
+};
+
+#endif
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
using namespace std;
}
const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
+{
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+ addPlane(1, 0, 0, aFaces); // YZ plane
+ addPlane(0, 1, 0, aFaces); // XZ plane
+ addPlane(0, 0, 1, aFaces); // XY plane
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+ setPreview(aCompound);
+
+ return getPreview();
+}
+
+void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const
{
boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
- boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
+ boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
boost::shared_ptr<GeomAPI_Shape> aFace =
GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
- setPreview(aFace);
-
- return getPreview();
+ theShapes.push_back(aFace);
}
#include "SketchPlugin.h"
#include <SketchPlugin_Feature.h>
+#include <list>
+
/// part reference attribute
const std::string PART_ATTR_DOC_REF = "SketchDocument";
/// Use plugin manager for features creation
SketchPlugin_Sketch();
+protected:
+ /// Creates a plane and append it to the list
+ /// \param theX the X normal value
+ /// \param theY the Y normal value
+ /// \param theZ the Z normal value
+ /// \param theShapes the list of result shapes
+ void addPlane(double theX, double theY, double theZ,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
+
};
#endif