]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003)
authorazv <azv@opencascade.com>
Sun, 22 Sep 2019 13:10:23 +0000 (16:10 +0300)
committerazv <azv@opencascade.com>
Sun, 22 Sep 2019 13:54:37 +0000 (16:54 +0300)
* Projection of ellipse.
* Update tests according to new behavior of projection (circle can be projected to ellipse now).

src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Projection.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Projection.h [new file with mode: 0644]
src/SketchAPI/SketchAPI_Projection.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Projection.cpp
src/SketchPlugin/SketchPlugin_Projection.h
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/Test/TestProjectionEllipse.py [new file with mode: 0644]
src/SketchPlugin/Test/TestProjectionIntoResult.py

index 6e09db85a3fe8abd9ae5b4d26420949266df26be..460aebe7e4b16a1a9794b0e7b4361c752e4fc617 100644 (file)
@@ -81,6 +81,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Offset.h
     GeomAlgoAPI_SolidClassifier.h
     GeomAlgoAPI_MapShapesAndAncestors.h
+    GeomAlgoAPI_Projection.h
 )
 
 SET(PROJECT_SOURCES
@@ -141,6 +142,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Offset.cpp
     GeomAlgoAPI_SolidClassifier.cpp
     GeomAlgoAPI_MapShapesAndAncestors.cpp
+    GeomAlgoAPI_Projection.cpp
 )
 
 SET(PROJECT_LIBRARIES
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Projection.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Projection.cpp
new file mode 100644 (file)
index 0000000..21a66fa
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2019  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <GeomAlgoAPI_Projection.h>
+
+#include <GeomAPI_Curve.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Pln.h>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomProjLib.hxx>
+
+GeomAlgoAPI_Projection::GeomAlgoAPI_Projection(const GeomPlanePtr& thePlane)
+  : myPlane(thePlane)
+{
+}
+
+GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomCurvePtr& theCurve)
+{
+  Handle(Geom_Curve) aCurve = theCurve->impl<Handle_Geom_Curve>();
+  Handle(Geom_Plane) aPlane = new Geom_Plane(myPlane->impl<gp_Ax3>());
+
+  Handle(Geom_Curve) aProj = GeomProjLib::Project(aCurve, aPlane);
+
+  GeomCurvePtr aProjCurve(new GeomAPI_Curve);
+  aProjCurve->setImpl(new Handle_Geom_Curve(aProj));
+  return aProjCurve;
+}
+
+GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomEdgePtr& theEdge)
+{
+  GeomCurvePtr aCurve(new GeomAPI_Curve(theEdge));
+  return project(aCurve);
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Projection.h b/src/GeomAlgoAPI/GeomAlgoAPI_Projection.h
new file mode 100644 (file)
index 0000000..5ffde63
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2019  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GeomAlgoAPI_Projection_H_
+#define GeomAlgoAPI_Projection_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <GeomAPI_Pln.h>
+
+#include <memory>
+
+class GeomAPI_Curve;
+class GeomAPI_Edge;
+
+/**\class GeomAlgoAPI_Projection
+ * \ingroup DataAlgo
+ * \brief Project curve onto a plane
+ */
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_Projection
+{
+public:
+  GeomAlgoAPI_Projection(const std::shared_ptr<GeomAPI_Pln>& thePlane);
+
+  /// Project curve to the plane
+  std::shared_ptr<GeomAPI_Curve> project(const std::shared_ptr<GeomAPI_Curve>& theCurve);
+  /// Project edge to the plane
+  std::shared_ptr<GeomAPI_Curve> project(const std::shared_ptr<GeomAPI_Edge>& theEdge);
+
+private:
+  std::shared_ptr<GeomAPI_Pln> myPlane;
+};
+
+#endif
index 76fb2dc18b30bedfdea9e9e43fd45daf343a44a0..493991519f467748531f2181d9747fc1daef88a2 100644 (file)
 
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Ellipse.h>
 #include <SketchPlugin_Point.h>
 
-#include <SketchAPI_Line.h>
-#include <SketchAPI_Circle.h>
 #include <SketchAPI_Arc.h>
+#include <SketchAPI_Circle.h>
+#include <SketchAPI_Ellipse.h>
+#include <SketchAPI_Line.h>
 #include <SketchAPI_Point.h>
 
 #include <ModelHighAPI_Dumper.h>
@@ -100,6 +102,8 @@ std::shared_ptr<SketchAPI_SketchEntity> SketchAPI_Projection::createdFeature() c
     anEntity.reset(new SketchAPI_Circle(aProjectedFeature));
   else if (aProjectedFeature->getKind() == SketchPlugin_Arc::ID())
     anEntity.reset(new SketchAPI_Arc(aProjectedFeature));
+  else if (aProjectedFeature->getKind() == SketchPlugin_Ellipse::ID())
+    anEntity.reset(new SketchAPI_Ellipse(aProjectedFeature));
   else if (aProjectedFeature->getKind() == SketchPlugin_Point::ID())
     anEntity.reset(new SketchAPI_Point(aProjectedFeature));
 
index 24745e8a13713b5b1a12f22b11a3cfa6d914574b..d7274a96a900fc3e5378182c271abfe0eae1d16e 100644 (file)
@@ -267,6 +267,7 @@ ADD_UNIT_TESTS(
   TestMultiTranslation.py
   TestPresentation.py
   TestProjection.py
+  TestProjectionEllipse.py
   TestProjectionIntoResult.py
   TestProjectionUpdate.py
   TestRectangle.py
index 0a1a1b96f1a5d1fe4baab9a5263991b28bbbe717..c0d555059e4317001adbc9ea7f675d3bb983acc3 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Ellipse.h>
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Sketch.h>
 
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Edge.h>
+#include <GeomAPI_Ellipse.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
+#include <GeomAlgoAPI_Projection.h>
 #include <GeomDataAPI_Point2D.h>
 
 #include <cmath>
@@ -101,21 +104,23 @@ void SketchPlugin_Projection::attributeChanged(const std::string& theID)
   }
 }
 
-static bool isValidProjectionType(FeaturePtr theProjection,
-                                  GeomEdgePtr theEdge,
-                                  GeomVertexPtr theVertex)
+static const std::string& projectionType(GeomEdgePtr theEdge,
+                                         GeomVertexPtr theVertex)
 {
-  if (theVertex && theProjection->getKind() == SketchPlugin_Point::ID())
-    return true;
+  if (theVertex)
+    return SketchPlugin_Point::ID();
   if (theEdge) {
-    if (theEdge->isLine() && theProjection->getKind() == SketchPlugin_Line::ID())
-      return true;
-    else if (theEdge->isCircle() && theProjection->getKind() == SketchPlugin_Circle::ID())
-      return true;
-    else if (theEdge->isArc() && theProjection->getKind() == SketchPlugin_Arc::ID())
-      return true;
+    if (theEdge->isLine())
+      return SketchPlugin_Line::ID();
+    else if (theEdge->isCircle())
+      return SketchPlugin_Circle::ID();
+    else if (theEdge->isArc())
+      return SketchPlugin_Arc::ID();
+    else if (theEdge->isEllipse())
+      return SketchPlugin_Ellipse::ID();
   }
-  return false;
+  static const std::string DUMMY;
+  return DUMMY;
 }
 
 void SketchPlugin_Projection::computeProjection(const std::string& theID)
@@ -139,30 +144,21 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
   if (!anEdge && !aVertex)
     return;
 
+  const std::string& aProjType = projectionType(anEdge, aVertex);
+
   AttributeRefAttrPtr aRefAttr = data()->refattr(PROJECTED_FEATURE_ID());
   FeaturePtr aProjection;
   if (aRefAttr && aRefAttr->isInitialized())
     aProjection = ModelAPI_Feature::feature(aRefAttr->object());
 
   // if the type of feature differs with already selected, remove it and create once again
-  bool hasPrevProj = aProjection.get() != 0;
-  if (hasPrevProj && !isValidProjectionType(aProjection, anEdge, aVertex)) {
-    DocumentPtr aDoc = sketch()->document();
-
-    aRefAttr->setObject(data()->owner()); // to not remove of this remove reference to aProjection
-    std::set<FeaturePtr> aFeaturesToBeRemoved;
-    aFeaturesToBeRemoved.insert(aProjection);
-    ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
-    aProjection = FeaturePtr();
-    aRefAttr->setObject(aProjection);
-    hasPrevProj = false;
-  }
+  bool isRebuild = rebuildProjectedFeature(aProjection, aProjType, true);
 
   std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
 
   ResultConstructionPtr aResult =
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
-  if (aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
+  if (!isRebuild && aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
     aResult->setShape(std::shared_ptr<GeomAPI_Edge>());
     if (aProjection)
       aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
@@ -174,8 +170,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     std::shared_ptr<GeomAPI_Pnt> aPrjPnt = aSketchPlane->project(aVertex->point());
     std::shared_ptr<GeomAPI_Pnt2d> aPntInSketch = sketch()->to2D(aPrjPnt);
 
-    if (!hasPrevProj)
-      aProjection = sketch()->addFeature(SketchPlugin_Point::ID());
+    rebuildProjectedFeature(aProjection, SketchPlugin_Point::ID());
 
     // update coordinates of projection
     std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
@@ -190,8 +185,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     if (aFirstInSketch->distance(aLastInSketch) < tolerance)
       return; // line is semi-orthogonal to the sketch plane
 
-    if (!hasPrevProj)
-      aProjection = sketch()->addFeature(SketchPlugin_Line::ID());
+    rebuildProjectedFeature(aProjection, SketchPlugin_Line::ID());
 
     // update attributes of projection
     std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
@@ -201,26 +195,47 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     aStartPnt->setValue(aFirstInSketch);
     aEndPnt->setValue(aLastInSketch);
   }
-  else if (anEdge->isCircle()) {
-    std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
-    double aRadius = aCircle->radius();
-
-    double aNormalsDot = aCircle->normal()->dot(aSketchPlane->direction());
-    if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
-      return; // circle is not in the plane, parallel to the sketch plane
-
-    std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
-    std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
-
-    if (!hasPrevProj)
-      aProjection = sketch()->addFeature(SketchPlugin_Circle::ID());
-
-    // update attributes of projection
-    std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
-    aCenterPnt->setValue(aCenterInSketch);
-    aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius);
+  else if (anEdge->isCircle() || anEdge->isEllipse()) {
+    GeomAlgoAPI_Projection aProjAlgo(aSketchPlane);
+    GeomCurvePtr aProjectedCurve = aProjAlgo.project(anEdge);
+
+    if (aProjectedCurve->isCircle()) {
+      rebuildProjectedFeature(aProjection, SketchPlugin_Circle::ID());
+
+      GeomAPI_Circ aCircle(aProjectedCurve);
+      std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle.center());
+      std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
+
+      // update attributes of projection
+      std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
+      aCenterPnt->setValue(aCenterInSketch);
+      aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aCircle.radius());
+    }
+    else if (aProjectedCurve->isEllipse()) {
+      rebuildProjectedFeature(aProjection, SketchPlugin_Ellipse::ID());
+
+      GeomAPI_Ellipse anEllipse(aProjectedCurve);
+      std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(anEllipse.center());
+      std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
+      std::shared_ptr<GeomAPI_Pnt> aFocus = aSketchPlane->project(anEllipse.firstFocus());
+      std::shared_ptr<GeomAPI_Pnt2d> aFocusInSketch = sketch()->to2D(aFocus);
+
+      // update attributes of projection
+      std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aProjection->attribute(SketchPlugin_Ellipse::CENTER_ID()));
+      aCenterPnt->setValue(aCenterInSketch);
+      std::shared_ptr<GeomDataAPI_Point2D> aFocusPnt =
+          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aProjection->attribute(SketchPlugin_Ellipse::FIRST_FOCUS_ID()));
+      aFocusPnt->setValue(aFocusInSketch);
+      aProjection->real(SketchPlugin_Ellipse::MINOR_RADIUS_ID())->setValue(
+          anEllipse.minorRadius());
+    }
+    else
+      return;
   }
   else if (anEdge->isArc()) {
     std::shared_ptr<GeomAPI_Pnt> aFirst = aSketchPlane->project(anEdge->firstPoint());
@@ -238,8 +253,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
 
     bool isInversed = aNormalsDot < 0.;
 
-    if (!hasPrevProj)
-      aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
+    rebuildProjectedFeature(aProjection, SketchPlugin_Arc::ID());
 
     bool aWasBlocked = aProjection->data()->blockSendAttributeUpdated(true);
 
@@ -279,3 +293,26 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     }
   }
 }
+
+bool SketchPlugin_Projection::rebuildProjectedFeature(FeaturePtr& theProjection,
+                                                      const std::string& theResultType,
+                                                      bool theRemoveOnly)
+{
+  bool isRebuild = false;
+  if (theProjection && theProjection->getKind() != theResultType) {
+    DocumentPtr aDoc = sketch()->document();
+
+    AttributeRefAttrPtr aRefAttr = data()->refattr(PROJECTED_FEATURE_ID());
+    aRefAttr->setObject(data()->owner()); // to not remove of this remove reference to aProjection
+    std::set<FeaturePtr> aFeaturesToBeRemoved;
+    aFeaturesToBeRemoved.insert(theProjection);
+    ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
+    theProjection = FeaturePtr();
+    aRefAttr->setObject(theProjection);
+    isRebuild = true;
+  }
+
+  if (!theProjection && !theRemoveOnly)
+    theProjection = sketch()->addFeature(theResultType);
+  return isRebuild;
+}
index b928dfabdd5c577428685e3805da92641c5e0b56..f62237608c6143d79ec07fad05648c43a9429f3c 100644 (file)
@@ -88,6 +88,12 @@ private:
   /// \brief Find projection of a feature onto sketch plane
   void computeProjection(const std::string& theID);
 
+  /// \brief Delete already calculated projected feature
+  ///        if the selection of the projection is changed
+  bool rebuildProjectedFeature(FeaturePtr& theProjection,
+                               const std::string& theResultType,
+                               bool theRemoveOnly = false);
+
   bool myIsComputing;
 };
 
index 31f2178687e7d9e3d012574aa7a1304b42ce8062..1d62d8f2418824f22a9c718e5750de700f11d508 100644 (file)
@@ -60,6 +60,7 @@
 
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Dir2d.h>
+#include <GeomAPI_Ellipse.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Vertex.h>
@@ -1127,17 +1128,27 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
     double aDot = fabs(aNormal->dot(aLineDir));
     bool aValid = fabs(aDot - 1.0) >= tolerance * tolerance;
     if (!aValid)
-      theError = "Error: Edge is already in the sketch plane.";
+      theError = "Error: Line is orthogonal to the sketch plane.";
     return aValid;
   }
   else if (anEdge->isCircle() || anEdge->isArc()) {
     std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
     std::shared_ptr<GeomAPI_Dir> aCircNormal = aCircle->normal();
     double aDot = fabs(aNormal->dot(aCircNormal));
-    bool aValid = fabs(aDot - 1.0) < tolerance * tolerance;
+    bool aValid = aDot >= tolerance * tolerance;
     if (!aValid)
-      theError.arg(anEdge->isCircle() ? "Error: Cirlce is already in the sketch plane."
-                                      : "Error: Arc is already in the sketch plane.");
+      theError.arg(anEdge->isCircle() ? "Error: Circle is orthogonal to the sketch plane."
+                                      : "Error: Arc is orthogonal to the sketch plane.");
+    return aValid;
+  }
+  else if (anEdge->isEllipse()) {
+    std::shared_ptr<GeomAPI_Ellipse> anEllipse = anEdge->ellipse();
+    std::shared_ptr<GeomAPI_Dir> anEllipseNormal = anEllipse->normal();
+    double aDot = fabs(aNormal->dot(anEllipseNormal));
+    bool aValid = aDot >= tolerance * tolerance;
+    if (!aValid)
+      theError.arg(anEdge->isEllipse() ? "Error: Ellipse is orthogonal to the sketch plane."
+                                       : "Error: Elliptic Arc is orthogonal to the sketch plane.");
     return aValid;
   }
 
diff --git a/src/SketchPlugin/Test/TestProjectionEllipse.py b/src/SketchPlugin/Test/TestProjectionEllipse.py
new file mode 100644 (file)
index 0000000..9dbaabc
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (C) 2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(0, -100, 20)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchAPI_Line(SketchLine_1).startPoint(), 100, True)
+model.do()
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("EDGE", "PartSet/OX"), 30)
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), True)
+SketchCircle_2 = SketchProjection_2.createdFeature()
+model.do()
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), True)
+SketchEllipse_1 = SketchProjection_3.createdFeature()
+SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), True)
+SketchEllipse_2 = SketchProjection_4.createdFeature()
+model.do()
+model.end()
+
+from GeomAPI import *
+
+circle2 = SketchCircle_2.results()[-1].resultSubShapePair()[0].shape()
+assert(circle2.isEdge() and circle2.edge().isCircle())
+ellipse1 = SketchEllipse_1.results()[-1].resultSubShapePair()[0].shape()
+assert(ellipse1.isEdge() and ellipse1.edge().isEllipse())
+ellipse2 = SketchEllipse_2.results()[-1].resultSubShapePair()[0].shape()
+assert(ellipse2.isEdge() and ellipse2.edge().isEllipse())
+
+assert(model.checkPythonDump())
index 0ad4fb507f3d1e2f19c234431b54c544031a7fb6..016bbc6deead2ee3ba3fb9f7efc95a9bffa5ce71 100644 (file)
@@ -159,7 +159,7 @@ testProjections(Part_1_doc, Sketch_7, aProjectedList, aFailedIDs)
 
 # Test projection to slope side face of the prism
 Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2"))
-aFailedIDs = set([0, 1])
+aFailedIDs = set([1])
 testProjections(Part_1_doc, Sketch_8, aProjectedList, aFailedIDs)
 
 model.end()