From: azv Date: Mon, 9 Jun 2014 07:21:34 +0000 (+0400) Subject: The problem with extrusion direction of the sketch was fixed X-Git-Tag: V_0.4.4~301^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b77ff54992fb443be835deda82dede415799f17b;p=modules%2Fshaper.git The problem with extrusion direction of the sketch was fixed --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp index 1828a7193..b910d1753 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +50,7 @@ static void findNextVertex( static void createFace(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, const std::list::iterator& theEndOfEdges, + const gp_Pln& thePlane, TopoDS_Face& theResFace); /// \bief Create planar wire @@ -74,6 +77,7 @@ static void removeWasteEdges( void GeomAlgoAPI_SketchBuilder::createFaces( + const boost::shared_ptr& theOrigin, const boost::shared_ptr& theDirX, const boost::shared_ptr& theDirY, const boost::shared_ptr& theNorm, @@ -106,6 +110,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces( gp_Dir aDirY = theDirY->impl(); gp_Dir aNorm = theNorm->impl(); + gp_Pln aPlane(theOrigin->impl(), aNorm); + // Set of edges used in loops std::set anEdgesInLoops; // Lists for processed vertexes and edges @@ -177,7 +183,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces( // 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 aFace(new GeomAPI_Shape); @@ -420,6 +426,7 @@ static void addEdgeToWire(const TopoDS_Edge& theEdge, TopoDS_Shape& theSpliceVertex, TopoDS_Wire& theWire) { + TopoDS_Edge anEdge = theEdge; bool isCurVertChanged = false; TopoDS_Shape aCurVertChanged; @@ -430,13 +437,7 @@ static void addEdgeToWire(const TopoDS_Edge& theEdge, 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()) @@ -447,12 +448,13 @@ static void addEdgeToWire(const TopoDS_Edge& theEdge, } theSpliceVertex = isCurVertChanged ? aCurVertChanged : aVertExp.Current(); - theBuilder.Add(theWire, theEdge); + theBuilder.Add(theWire, anEdge); } void createFace(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, const std::list::iterator& theEndOfEdges, + const gp_Pln& thePlane, TopoDS_Face& theResFace) { TopoDS_Wire aResWire; @@ -467,7 +469,7 @@ void createFace(const TopoDS_Shape& theStartVertex, 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(); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h index eb1587a54..c5817d9b0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h @@ -11,6 +11,7 @@ #include #include +#include #include /** \class GeomAlgoAPI_SketchBuilder @@ -21,6 +22,7 @@ class GEOMALGOAPI_EXPORT 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 @@ -32,7 +34,8 @@ public: * 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& theDirX, + static void createFaces(const boost::shared_ptr& theOrigin, + const boost::shared_ptr& theDirX, const boost::shared_ptr& theDirY, const boost::shared_ptr& theNorm, const std::list< boost::shared_ptr >& theFeatures, diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 850058e8c..51e9bbff6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -37,6 +37,8 @@ void SketchPlugin_Sketch::execute() boost::shared_ptr aRefList = boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_FEATURES)); + boost::shared_ptr anOrigin = + boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_ORIGIN)); boost::shared_ptr aDirX = boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_DIRX)); boost::shared_ptr aDirY = @@ -62,7 +64,7 @@ void SketchPlugin_Sketch::execute() std::list< boost::shared_ptr > aLoops; std::list< boost::shared_ptr > 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());