]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The problem with extrusion direction of the sketch was fixed
authorazv <azv@opencascade.com>
Mon, 9 Jun 2014 07:21:34 +0000 (11:21 +0400)
committerazv <azv@opencascade.com>
Mon, 9 Jun 2014 07:21:34 +0000 (11:21 +0400)
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index 1828a7193368b9cba8950f1a18bd005fa0954228..b910d17532b93fe170d948a762fd0fc9526dbc06 100644 (file)
@@ -7,6 +7,7 @@
 #include <set>
 
 #include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
 
 #include <BOPAlgo_Builder.hxx>
 #include <BOPAlgo_Operation.hxx>
@@ -20,6 +21,7 @@
 #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>
@@ -48,6 +50,7 @@ static void findNextVertex(
 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
@@ -74,6 +77,7 @@ static void removeWasteEdges(
 
 
 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,
@@ -106,6 +110,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
   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
@@ -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<GeomAPI_Shape> 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<TopoDS_Shape>::iterator& theStartEdge,
                 const std::list<TopoDS_Shape>::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();
 }
index eb1587a54df4bf335ae415c3a7311800be741ce0..c5817d9b002bb99359aac273409de99b85040520 100644 (file)
@@ -11,6 +11,7 @@
 #include <list>
 
 #include <GeomAPI_Dir.h>
+#include <GeomAPI_Pnt.h>
 #include <GeomAPI_Shape.h>
 
 /** \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<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,
index 850058e8c1d438da7edb4a59c41fcac9d05ded49..51e9bbff61adec8a42a4cf8eb6d9bd3a3097a489 100644 (file)
@@ -37,6 +37,8 @@ void SketchPlugin_Sketch::execute()
   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 = 
@@ -62,7 +64,7 @@ void SketchPlugin_Sketch::execute()
 
   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());