#include <set>
#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_Operation.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <Geom_Curve.hxx>
+#include <Geom_Plane.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
static void createFace(const TopoDS_Shape& theStartVertex,
const std::list<TopoDS_Shape>::iterator& theStartEdge,
const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
+ const gp_Pln& thePlane,
TopoDS_Face& theResFace);
/// \bief Create planar wire
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,
gp_Dir aDirY = theDirY->impl<gp_Dir>();
gp_Dir aNorm = theNorm->impl<gp_Dir>();
+ gp_Pln aPlane(theOrigin->impl<gp_Pnt>(), aNorm);
+
// Set of edges used in loops
std::set<Handle(TopoDS_TShape)> anEdgesInLoops;
// Lists for processed vertexes and edges
// When the orientation is correct or the edges looped through
// the first element, create new face and remove unnecessary edges.
TopoDS_Face aPatch;
- createFace(*aVertIter, anEdgeIter, aProcEdges.end(), aPatch);
+ createFace(*aVertIter, anEdgeIter, aProcEdges.end(), aPlane, aPatch);
if (!aPatch.IsNull())
{
boost::shared_ptr<GeomAPI_Shape> aFace(new GeomAPI_Shape);
TopoDS_Shape& theSpliceVertex,
TopoDS_Wire& theWire)
{
+ TopoDS_Edge anEdge = theEdge;
bool isCurVertChanged = false;
TopoDS_Shape aCurVertChanged;
if (aVertex.TShape() == theSpliceVertex.TShape() &&
aVertex.Orientation() != theEdge.Orientation())
{ // Current vertex is the last for the edge, so its orientation is wrong, need to revert the edge
- const Handle(BRep_TEdge)& aTEdge = (const Handle(BRep_TEdge)&)theEdge.TShape();
- Handle(BRep_Curve3D) aEdgeCurve =
- Handle(BRep_Curve3D)::DownCast(aTEdge->Curves().First());
- Handle(Geom_Curve) aCurve = aEdgeCurve->Curve3D();
- aCurve->Reverse();
-
- theBuilder.UpdateEdge(theEdge, aCurve, aTEdge->Tolerance());
+ anEdge.Reverse();
break;
}
if (aVertex.TShape() != theSpliceVertex.TShape())
}
theSpliceVertex = isCurVertChanged ? aCurVertChanged : aVertExp.Current();
- theBuilder.Add(theWire, theEdge);
+ theBuilder.Add(theWire, anEdge);
}
void createFace(const TopoDS_Shape& theStartVertex,
const std::list<TopoDS_Shape>::iterator& theStartEdge,
const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
+ const gp_Pln& thePlane,
TopoDS_Face& theResFace)
{
TopoDS_Wire aResWire;
addEdgeToWire(anEdge, aBuilder, aCurVertex, aResWire);
}
- BRepBuilderAPI_MakeFace aFaceBuilder(aResWire, Standard_True/*planar face*/);
+ BRepBuilderAPI_MakeFace aFaceBuilder(thePlane, aResWire);
if (aFaceBuilder.Error() == BRepBuilderAPI_FaceDone)
theResFace = aFaceBuilder.Face();
}
#include <list>
#include <GeomAPI_Dir.h>
+#include <GeomAPI_Pnt.h>
#include <GeomAPI_Shape.h>
/** \class GeomAlgoAPI_SketchBuilder
{
public:
/** \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
* 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_Dir>& theDirX,
+ 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 std::list< boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SKETCH_ATTR_FEATURES));
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
boost::shared_ptr<GeomDataAPI_Dir> aDirX =
boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
boost::shared_ptr<GeomDataAPI_Dir> aDirY =
std::list< boost::shared_ptr<GeomAPI_Shape> > aLoops;
std::list< boost::shared_ptr<GeomAPI_Shape> > aWires;
- GeomAlgoAPI_SketchBuilder::createFaces(aDirX->dir(), aDirY->dir(), aNorm->dir(),
+ GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
aFeaturesPreview, aLoops, aWires);
aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());