Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Tools.cpp
index 09aa35dffa579be29f0a8a01677b468772ebce49..a4e461ada6afe7a04c830f84d2eedcdf19a214eb 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SketchSolver_Builder.cpp
-// Created: 25 Mar 2015
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <PlaneGCSSolver_Tools.h>
 #include <PlaneGCSSolver_EdgeWrapper.h>
@@ -95,6 +109,12 @@ static ConstraintWrapperPtr
   createConstraintMiddlePoint(std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
                               std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 
+static GCS::SET_pD scalarParameters(const ScalarWrapperPtr& theScalar);
+static GCS::SET_pD pointParameters(const PointWrapperPtr& thePoint);
+static GCS::SET_pD lineParameters(const EdgeWrapperPtr& theLine);
+static GCS::SET_pD circleParameters(const EdgeWrapperPtr& theCircle);
+static GCS::SET_pD arcParameters(const EdgeWrapperPtr& theArc);
+
 
 
 
@@ -262,6 +282,27 @@ std::shared_ptr<GeomAPI_Lin2d> PlaneGCSSolver_Tools::line(FeaturePtr theFeature)
 }
 
 
+GCS::SET_pD PlaneGCSSolver_Tools::parameters(const EntityWrapperPtr& theEntity)
+{
+  switch (theEntity->type()) {
+  case ENTITY_SCALAR:
+  case ENTITY_ANGLE:
+    return scalarParameters(GCS_SCALAR_WRAPPER(theEntity));
+  case ENTITY_POINT:
+    return pointParameters(GCS_POINT_WRAPPER(theEntity));
+  case ENTITY_LINE:
+    return lineParameters(GCS_EDGE_WRAPPER(theEntity));
+  case ENTITY_CIRCLE:
+    return circleParameters(GCS_EDGE_WRAPPER(theEntity));
+  case ENTITY_ARC:
+    return arcParameters(GCS_EDGE_WRAPPER(theEntity));
+  default: break;
+  }
+  return GCS::SET_pD();
+}
+
+
+
 
 
 
@@ -500,3 +541,55 @@ ConstraintWrapperPtr createConstraintEqual(
     aResult->setValueParameter(theIntermed);
   return aResult;
 }
+
+GCS::SET_pD scalarParameters(const ScalarWrapperPtr& theScalar)
+{
+  GCS::SET_pD aParams;
+  aParams.insert(theScalar->scalar());
+  return aParams;
+}
+
+GCS::SET_pD pointParameters(const PointWrapperPtr& thePoint)
+{
+  GCS::SET_pD aParams;
+  aParams.insert(thePoint->point()->x);
+  aParams.insert(thePoint->point()->y);
+  return aParams;
+}
+
+GCS::SET_pD lineParameters(const EdgeWrapperPtr& theLine)
+{
+  GCS::SET_pD aParams;
+  std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theLine->entity());
+  aParams.insert(aLine->p1.x);
+  aParams.insert(aLine->p1.y);
+  aParams.insert(aLine->p2.x);
+  aParams.insert(aLine->p2.y);
+  return aParams;
+}
+
+GCS::SET_pD circleParameters(const EdgeWrapperPtr& theCircle)
+{
+  GCS::SET_pD aParams;
+  std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(theCircle->entity());
+  aParams.insert(aCirc->center.x);
+  aParams.insert(aCirc->center.y);
+  aParams.insert(aCirc->rad);
+  return aParams;
+}
+
+GCS::SET_pD arcParameters(const EdgeWrapperPtr& theArc)
+{
+  GCS::SET_pD aParams;
+  std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(theArc->entity());
+  aParams.insert(anArc->center.x);
+  aParams.insert(anArc->center.y);
+  aParams.insert(anArc->start.x);
+  aParams.insert(anArc->start.y);
+  aParams.insert(anArc->end.x);
+  aParams.insert(anArc->end.y);
+  aParams.insert(anArc->startAngle);
+  aParams.insert(anArc->endAngle);
+  aParams.insert(anArc->rad);
+  return aParams;
+}