Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Projection.cpp
index c8b0022487dac21a68d912b17b1c00421330aa5c..9d0ff96e91e26dac6aa41a5c52d8b23711c1c87f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -395,7 +395,7 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE
   if (aProjectedCurve->isCircle()) {
     if (aProjectedCurve->isTrimmed()) {
       // ARC is a projection
-      isOk = fillArc(theProjection, aProjectedCurve, aSketchPlane);
+      isOk = fillArc(theProjection, aProjectedCurve, aSketchPlane, theEdge);
     }
     else {
       // CIRCLE is a projection
@@ -405,7 +405,7 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE
   else if (aProjectedCurve->isEllipse()) {
     if (aProjectedCurve->isTrimmed()) {
       // ELLIPTIC ARC is a projection
-      isOk = fillEllipticArc(theProjection, aProjectedCurve, aSketchPlane);
+      isOk = fillEllipticArc(theProjection, aProjectedCurve, aSketchPlane, theEdge);
     }
     else {
       // ELLIPSE is a projection
@@ -420,7 +420,8 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE
 
 bool SketchPlugin_Projection::fillArc(FeaturePtr& theProjection,
                                       const GeomCurvePtr& theArc,
-                                      const GeomPlanePtr& thePlane)
+                                      const GeomPlanePtr& thePlane,
+                                      const GeomEdgePtr& theOriginalEdge)
 {
   rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_Arc::ID());
 
@@ -432,6 +433,13 @@ bool SketchPlugin_Projection::fillArc(FeaturePtr& theProjection,
 
   bool isInversed = aNormalsDot < 0.;
 
+  GeomCirclePtr anOriginalCircle = theOriginalEdge->circle();
+  if (anOriginalCircle) {
+    double aCirclesDot = anOriginalCircle->normal()->dot(aCircle.normal());
+    if (aCirclesDot < 0.)
+      isInversed = !isInversed;
+  }
+
   GeomPointPtr aCenter = thePlane->project(aCircle.center());
   GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
 
@@ -508,7 +516,8 @@ bool SketchPlugin_Projection::fillEllipse(FeaturePtr& theProjection,
 
 bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection,
                                               const GeomCurvePtr& theEllipticArc,
-                                              const GeomPlanePtr& thePlane)
+                                              const GeomPlanePtr& thePlane,
+                                              const GeomEdgePtr& theOriginalEdge)
 {
   rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_EllipticArc::ID());
 
@@ -520,6 +529,13 @@ bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection,
 
   bool isInversed = aNormalsDot < 0.;
 
+  GeomEllipsePtr anOriginalEllipse = theOriginalEdge->ellipse();
+  if (anOriginalEllipse) {
+    double anEllipsesDot = anOriginalEllipse->normal()->dot(anEllipse.normal());
+    if (anEllipsesDot < 0.)
+      isInversed = !isInversed;
+  }
+
   GeomPointPtr aCenter = thePlane->project(anEllipse.center());
   GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
   GeomPointPtr aFocus = thePlane->project(anEllipse.firstFocus());
@@ -557,7 +573,7 @@ bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection,
 
 bool SketchPlugin_Projection::fillBSpline(FeaturePtr& theProjection,
                                           const GeomCurvePtr& theCurve,
-                                          const GeomPlanePtr& thePlane)
+                                          const GeomPlanePtr& /*thePlane*/)
 {
   GeomAPI_BSpline aBSpline(theCurve);
 
@@ -587,9 +603,9 @@ bool SketchPlugin_Projection::fillBSpline(FeaturePtr& theProjection,
   }
   else { // non-rational B-spline
     aWeightsAttr->setSize((int)aWeights.size());
-    std::list<double>::iterator anIt = aWeights.begin();
-    for (int anIndex = 0; anIt != aWeights.end(); ++anIt, ++anIndex)
-      aWeightsAttr->setValue(anIndex, *anIt);
+    std::list<double>::iterator aWIt = aWeights.begin();
+    for (int anIndex = 0; aWIt != aWeights.end(); ++aWIt, ++anIndex)
+      aWeightsAttr->setValue(anIndex, *aWIt);
   }
 
   AttributeDoubleArrayPtr aKnotsAttr =