]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0022782: [CEA 1315] GetFirstVertex does not return the edge's starting point
authorskv <skv@opencascade.com>
Thu, 11 Jun 2015 08:53:02 +0000 (11:53 +0300)
committerskv <skv@opencascade.com>
Thu, 11 Jun 2015 08:53:02 +0000 (11:53 +0300)
14 files changed:
doc/salome/gui/GEOM/images/point3.png [changed mode: 0755->0644]
doc/salome/gui/GEOM/input/creating_point.doc
idl/GEOM_Gen.idl
src/BasicGUI/BasicGUI_PointDlg.cxx
src/BasicGUI/BasicGUI_PointDlg.h
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_IBasicOperations.cxx
src/GEOMImpl/GEOMImpl_IBasicOperations.hxx
src/GEOMImpl/GEOMImpl_IPoint.hxx [changed mode: 0755->0644]
src/GEOMImpl/GEOMImpl_PointDriver.cxx
src/GEOM_I/GEOM_IBasicOperations_i.cc
src/GEOM_I/GEOM_IBasicOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_SWIG/geomBuilder.py

old mode 100755 (executable)
new mode 100644 (file)
index 8b4daec..57cccab
Binary files a/doc/salome/gui/GEOM/images/point3.png and b/doc/salome/gui/GEOM/images/point3.png differ
index cc879062498c9530ddc4681c043aba4612a177f2..5929a8fd1a21888417a43f9c4342130c92123a51 100644 (file)
@@ -28,9 +28,10 @@ the position of this point regarding the reference one.
 \n Thirdly, we can define a point by an \b Edge and a \b Parameter
 indicating its position on the Edge, ranging from 0.0 to 1.0. For example, 0.5 means that the
 point is located in the middle of the edge.
-\n <b>TUI Command:</b> <em>geompy.MakeVertexOnCurve(Edge,Parameter).</em>
+\n <b>TUI Command:</b> <em>geompy.MakeVertexOnCurve(Edge,Parameter,takeOrientationIntoAccount).</em>
 \n <b>Arguments:</b> Name + 1 edge  + 1 Parameter defining the
-position of the point on the given edge.
+position of the point on the given edge + flag that tells if it is necessary
+to take the edge orientation into account.
 \image html point3.png
 
 Alternatively, it is possible to define a point by an \b Edge and a \b Length.
index c301b79ae6860bd55e6cf408e723d1643b7cee26..d7c6435627d13fbace57442ac53581c2f2d217d7 100644 (file)
@@ -732,10 +732,13 @@ module GEOM
      *  Create a point, corresponding to the given parameter on the given curve.
      *  \param theRefCurve The referenced curve.
      *  \param theParameter Value of parameter on the referenced curve.
+     *  \param takeOrientationIntoAccount flag that tells if it is necessary
+     *         to take the curve's orientation into account.
      *  \return New GEOM_Object, containing the created point.
      */
     GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve,
-                                  in double theParameter);
+                                  in double      theParameter,
+                                  in boolean     takeOrientationIntoAccount);
 
     /*!
      *  \brief Create a point, corresponding to the given length on the given curve.
index 983666d280b9af71eed29afc0963034ebb9635b5..0a374c4d7ee1beef0e774ebdc53777682aed308e 100644 (file)
@@ -125,13 +125,17 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren
   GroupXYZ->TextLabel2->setText(tr("GEOM_Y"));
   GroupXYZ->TextLabel3->setText(tr("GEOM_Z"));
 
-  GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
+  GroupOnCurve = new DlgRef_2Sel1Spin2Check(centralWidget());
   GroupOnCurve->GroupBox1->setTitle(tr("GEOM_POINT_ON_EDGE"));
   GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
   GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
   GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
   GroupOnCurve->PushButton1->setIcon(image2);
   GroupOnCurve->PushButton2->setIcon(image2);
+  GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
+  GroupOnCurve->CheckButton1->setText(tr("GEOM_TAKE_ORIENTATION_INTO_ACCOUNT"));
+  GroupOnCurve->CheckButton2->setAttribute( Qt::WA_DeleteOnClose );
+  GroupOnCurve->CheckButton2->close();
 
   GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
   GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
@@ -258,6 +262,7 @@ void BasicGUI_PointDlg::Init()
 
   initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision");
   GroupOnCurve->SpinBox_DX->setValue(0.5);
+  GroupOnCurve->CheckButton1->setChecked(true);
 
   initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision");
   GroupOnSurface->SpinBox_DX->setValue(0.5);
@@ -275,6 +280,8 @@ void BasicGUI_PointDlg::Init()
 
   connect(myParamCoord,   SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int)));
 
+  connect(GroupOnCurve->CheckButton1,         SIGNAL(toggled(bool)), this, SLOT(CheckBoxClicked()));
+
   connect(GroupOnCurve->PushButton1,          SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupOnCurve->PushButton2,          SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupOnSurface->PushButton1,        SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@@ -669,7 +676,7 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
 // function : CheckBoxClicked()
 // purpose  : Check Boxes Management
 //=================================================================================
-void BasicGUI_PointDlg::CheckBoxClicked(int  State)
+void BasicGUI_PointDlg::CheckBoxClicked()
 {
   displayPreview(true);
 }
@@ -821,7 +828,9 @@ bool BasicGUI_PointDlg::execute(ObjectList& objects)
   case GEOM_POINT_EDGE :
     {
       if (myParamCoord->checkedId() == PARAM_VALUE) {
-        anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter());
+        bool isUseOrientation = GroupOnCurve->CheckButton1->isChecked();
+
+        anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter(), isUseOrientation);
         aParameters<<GroupOnCurve->SpinBox_DX->text();
       }
       else if (myParamCoord->checkedId() == LENGTH_VALUE) {
@@ -973,6 +982,7 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
     GroupOnCurve->LineEdit2->setVisible(isLength);
     GroupOnCurve->TextLabel3->setVisible(isParam || isLength);
     GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength);
+    GroupOnCurve->CheckButton1->setVisible(isParam);
     if (isParam){
       initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
       GroupOnCurve->SpinBox_DX->setValue(0.5);
index 7002333dba7f439a4e507dd1a3d084b8419fc192..ffc01a165876512eca8d7c6dcebae73afd951e84 100644 (file)
@@ -31,7 +31,7 @@
 #include "GEOM_GenericObjPtr.h"
 #include <QMap>
 
-class DlgRef_2Sel1Spin;
+class DlgRef_2Sel1Spin2Check;
 class DlgRef_3Spin;
 class DlgRef_2Sel;
 class DlgRef_1Sel3Spin;
@@ -88,7 +88,7 @@ private:
 
   DlgRef_3Spin*                      GroupXYZ;
   DlgRef_1Sel3Spin*                  GroupRefPoint;
-  DlgRef_2Sel1Spin*                  GroupOnCurve;
+  DlgRef_2Sel1Spin2Check*            GroupOnCurve;
   DlgRef_2Sel*                       GroupLineIntersection;
   DlgRef_1Sel2Spin*                  GroupOnSurface;
   
@@ -115,7 +115,7 @@ private slots:
   void                               ValueChangedInSpinBox( double );
   void                               SetDoubleSpinBoxStep( double );
   void                               ClickParamCoord( int );
-  void                               CheckBoxClicked( int );
+  void                               CheckBoxClicked();
   void                               updateSize();
 };
 
index 9bed663c48cfb25e8fafb042a08dd4dea3c3672f..d9ce747c715870867503c5a8083b3748863571c2 100644 (file)
@@ -1352,6 +1352,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_LENGTH_VALUE</source>
         <translation>By length</translation>
     </message>
+    <message>
+        <source>GEOM_TAKE_ORIENTATION_INTO_ACCOUNT</source>
+        <translation>Take edge orientation into account</translation>
+    </message>
     <message>
         <source>GEOM_PARTITION</source>
         <translation>Partition</translation>
index 576ba74af0ceaad6a56e0430c53f0bf02d1e3e3b..8f282f2ae477fa3c06457de0f06a7af2483bcf0a 100644 (file)
@@ -186,10 +186,11 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
                     (Handle(GEOM_Object) theGeomObj,
-                     double theParam1,
-                     double theParam2,
-                     double theParam3,
+                     double              theParam1,
+                     double              theParam2,
+                     double              theParam3,
                      const PointLocation theLocation,
+                     const bool          takeOrientationIntoAccount,
                      Handle(GEOM_Object) theRefPoint)
 {
   SetErrorCode(KO);
@@ -226,6 +227,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
     case PointOn_CurveByParam:
       aPI.SetCurve(aRefFunction);
       aPI.SetParameter(theParam1);
+      aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
       break;
     case PointOn_CurveByLength:
       aPI.SetCurve(aRefFunction);
@@ -277,7 +279,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
     {
     case PointOn_CurveByParam:
       GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
-                                   << theGeomObj << ", " << theParam1 << ")";
+                                   << theGeomObj << ", " << theParam1 << ", "
+                                   << takeOrientationIntoAccount <<  ")";
       break;
     case PointOn_CurveByLength:
       GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
@@ -315,9 +318,12 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
-                            (Handle(GEOM_Object) theCurve, double theParameter)
+                            (Handle(GEOM_Object) theCurve,
+                             double              theParameter,
+                             bool                takeOrientationIntoAccount)
 {
-  return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
+  return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
+                         takeOrientationIntoAccount);
 }
 
 //=============================================================================
@@ -344,7 +350,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
                      double              theLength, 
                      Handle(GEOM_Object) theStartPoint)
 {
-  return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
+  return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
+                         false, theStartPoint);
 }
 
 //=============================================================================
index e3960f2f548ff0c9095be3c7ee4e75f561bb55d2..df8051ab683d187316d590fde79d6ac394e11497 100644 (file)
@@ -40,8 +40,10 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) MakePointWithReference (Handle(GEOM_Object) theReference,
                                               double theX, double theY, double theZ);
 
-  Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve,
-                                                        double theParameter);
+  Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve
+                              (Handle(GEOM_Object) theCurve,
+                               double              theParameter,
+                               bool                takeOrientationIntoAccount);
 
   Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve,
                                                                 double              theLength,
@@ -134,12 +136,14 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
     PointOn_Face
   };
 
-  Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj,
-                                       double theParam1,
-                                       double theParam2,
-                                       double theParam3,
-                                       const PointLocation theLocation,
-                                       Handle(GEOM_Object) theRefPoint = 0);
+  Handle(GEOM_Object) makePointOnGeom
+                     (Handle(GEOM_Object) theGeomObj,
+                      double              theParam1,
+                      double              theParam2,
+                      double              theParam3,
+                      const PointLocation theLocation,
+                      const bool          takeOrientationIntoAccount = false,
+                      Handle(GEOM_Object) theRefPoint = 0);
 };
 
 #endif
old mode 100755 (executable)
new mode 100644 (file)
index 6503302..07f81f0
@@ -40,7 +40,7 @@
 
 #define ARG_LENGTH 11
 
-//#define ARG_FLAG 12
+#define ARG_USE_ORIENTATION 12
 
 class GEOMImpl_IPoint
 {
@@ -73,12 +73,13 @@ class GEOMImpl_IPoint
   void SetParameter(double theParam) { _func->SetReal(ARG_PARAM, theParam); }
   void SetParameter2(double theParam) { _func->SetReal(ARG_PARAM2, theParam); }
   void SetLength(double theLength) { _func->SetReal(ARG_LENGTH, theLength); }
-  //void SetReversed(bool theReversed)  { _func->SetInteger(ARG_FLAG, theReversed); }
+  void SetTakeOrientationIntoAccount(bool takeOrientationIntoAccount)
+        { _func->SetInteger(ARG_USE_ORIENTATION, takeOrientationIntoAccount); }
 
   double GetParameter() { return _func->GetReal(ARG_PARAM); }
   double GetParameter2() { return _func->GetReal(ARG_PARAM2); }
   double GetLength() { return _func->GetReal(ARG_LENGTH); }
-  //bool   GetReversed() { return _func->GetInteger(ARG_FLAG); }
+  bool   GetTakeOrientationIntoAccount() { return _func->GetInteger(ARG_USE_ORIENTATION); }
 
  private:
 
index 03edfc4c1bef3c6f2a85dc1724d017b8cbc41a0e..f80ba42b986d9cf384d24c537f849386a3c4b76c 100644 (file)
@@ -145,7 +145,14 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
     Standard_Real aFP, aLP, aP;
     Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFP, aLP);
     if ( !aCurve.IsNull() ) {
-      aP = aFP + (aLP - aFP) * aPI.GetParameter();
+      if (aPI.GetTakeOrientationIntoAccount() &&
+          aRefShape.Orientation() == TopAbs_REVERSED) {
+        aP = 1. - aPI.GetParameter();
+      } else {
+        aP = aPI.GetParameter();
+      }
+
+      aP = aFP + (aLP - aFP) * aP;
       aPnt = aCurve->Value(aP);
     }
     else {
@@ -393,6 +400,7 @@ GetCreationInformation(std::string&             theOperationName,
   case POINT_CURVE_PAR:
     AddParam( theParams, "Edge", aCI.GetCurve() );
     AddParam( theParams, "Parameter", aCI.GetParameter() );
+    AddParam( theParams, "Use Orientation", aCI.GetTakeOrientationIntoAccount() );
     break;
   case POINT_CURVE_COORD:
     AddParam( theParams, "X", aCI.GetX() );
index 1dcf544f91f27d5f741e9745ab6372d57985a585..b48adfff4de063edbff06bc4f33d51e50d04c988 100644 (file)
@@ -135,7 +135,9 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
  */
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
-                  (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
+                  (GEOM::GEOM_Object_ptr theCurve,
+                   CORBA::Double         theParameter,
+                   CORBA::Boolean        takeOrientationIntoAccount)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -147,8 +149,8 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
   if (aReference.IsNull()) return aGEOMObject._retn();
 
   //Create the point
-  Handle(GEOM_Object) anObject =
-    GetOperations()->MakePointOnCurve(aReference, theParameter);
+  Handle(GEOM_Object) anObject = GetOperations()->MakePointOnCurve
+        (aReference, theParameter, takeOrientationIntoAccount);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index ec55aee27574ae85e57a47530b8896f62b42e701..c3e1fa3ffda4d67ae4c0bd6114d093b7a1cbc306 100644 (file)
@@ -52,8 +52,10 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
                                                 CORBA::Double theY,
                                                 CORBA::Double theZ);
 
-   GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve,
-                                          CORBA::Double theParameter);
+   GEOM::GEOM_Object_ptr MakePointOnCurve
+                      (GEOM::GEOM_Object_ptr theCurve,
+                                          CORBA::Double         theParameter,
+                       CORBA::Boolean        takeOrientationIntoAccount);
 
    GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve,
                                                   CORBA::Double         theLength,
index 8501474d80e79a0d858b3e47d9717ea648e2be75..bfd598ad5bff22a193d91391475952e50e3201f9 100644 (file)
@@ -722,7 +722,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the
   beginService( " GEOM_Superv_i::MakePointOnCurve" );
   MESSAGE("GEOM_Superv_i::MakePointOnCurve");
   getBasicOp();
-  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurve(theRefCurve, theParameter);
+  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurve(theRefCurve, theParameter, false);
   endService( " GEOM_Superv_i::MakePointOnCurve" );
   return anObj;
 }
index 0a3d2c83202c045591303ea864459b0850b622ed..0e8257dec7d0b19e64e5e0608f521142fe376d73 100644 (file)
@@ -1148,6 +1148,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         ## Create a point, corresponding to the given parameter on the given curve.
         #  @param theRefCurve The referenced curve.
         #  @param theParameter Value of parameter on the referenced curve.
+        #  @param takeOrientationIntoAccount flag that tells if it is necessary
+        #         to take the curve's orientation into account for the
+        #         operation. I.e. if this flag is set, the results for the same
+        #         parameters (except the value 0.5) is different for forward
+        #         and reversed curves. If it is not set the result is the same.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
         #         publication is switched on, default value is used for result name.
@@ -1156,13 +1161,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_creation_point "Example"
         @ManageTransactions("BasicOp")
-        def MakeVertexOnCurve(self, theRefCurve, theParameter, theName=None):
+        def MakeVertexOnCurve(self, theRefCurve, theParameter,
+                              takeOrientationIntoAccount=False, theName=None):
             """
             Create a point, corresponding to the given parameter on the given curve.
 
             Parameters:
                 theRefCurve The referenced curve.
                 theParameter Value of parameter on the referenced curve.
+                takeOrientationIntoAccount flag that tells if it is necessary
+                        to take the curve's orientation into account for the
+                        operation. I.e. if this flag is set, the results for
+                        the same parameters (except the value 0.5) is different
+                        for forward and reversed curves. If it is not set
+                        the result is the same.
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
@@ -1174,8 +1186,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)
             """
             # Example: see GEOM_TestAll.py
-            theParameter, Parameters = ParseParameters(theParameter)
-            anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter)
+            theParameter, takeOrientationIntoAccount, Parameters = ParseParameters(
+                theParameter, takeOrientationIntoAccount)
+            anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter,
+                                                  takeOrientationIntoAccount)
             RaiseIfFailed("MakePointOnCurve", self.BasicOp)
             anObj.SetParameters(Parameters)
             self._autoPublish(anObj, theName, "vertex")