]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
RNC: EDF 1542: Take into account orientation in newly created MakeVertexOnCurveByLeng...
authorgdd <gdd>
Wed, 5 Jan 2011 17:33:52 +0000 (17:33 +0000)
committergdd <gdd>
Wed, 5 Jan 2011 17:33:52 +0000 (17:33 +0000)
12 files changed:
idl/GEOM_Gen.idl
src/BasicGUI/BasicGUI_PointDlg.cxx
src/BasicGUI/BasicGUI_PointDlg.h
src/GEOMImpl/GEOMImpl_IBasicOperations.cxx
src/GEOMImpl/GEOMImpl_IBasicOperations.hxx
src/GEOMImpl/GEOMImpl_IPoint.hxx
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_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/geompyDC.py

index 18efa2a0cda928bfd6b79356b9b826e09a79f58d..2f8019d3fae294a4a77403f65b77a83b250711df 100644 (file)
@@ -422,11 +422,12 @@ module GEOM
      *  Create a point, corresponding to the given length on the given curve.
      *  \param theRefCurve The referenced curve.
      *  \param theLength Length on the referenced curve.
+     *  \param theDirection Direction for the calculation of the length (0 = forward or 2 = reversed).
      *  \return New GEOM_Object, containing the created point.
      */
     GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve,
-                                          in double theLength);
-
+                                          in double theLength,
+                                          in double theDirection);
 
     /*!
      *  Create a point on the given curve, projecting given point
index e5db36d90bed889a89c54d39a618ad9496ea8c77..9a039e9bacfa1aaba1d71421e9d2d43a654d645a 100644 (file)
@@ -123,11 +123,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
   GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
 
-  GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
+  GroupOnCurve = new DlgRef_1Sel1Spin1Check( centralWidget() );
   GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
   GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
   GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
+  GroupOnCurve->CheckButton1->setText( tr( "GEOM_REVERSE" ) );
   GroupOnCurve->PushButton1->setIcon( image2 );
+  
 
   GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
   GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
@@ -231,6 +233,7 @@ void BasicGUI_PointDlg::Init()
   myNeedType = TopAbs_VERTEX;
 
   myEditCurrentArgument = 0;
+  myCheckFlag = 0;
 
   /* Get setting of step value from file configuration */
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@@ -293,6 +296,8 @@ void BasicGUI_PointDlg::Init()
   connect( GroupRefPoint->SpinBox_DY,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
   connect( GroupRefPoint->SpinBox_DZ,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
 
+  connect( GroupOnCurve->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
+
   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this,  SLOT( SetDoubleSpinBoxStep( double ) ) );
 
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
@@ -701,6 +706,17 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
   displayPreview();
 }
 
+//=================================================================================
+// function : CheckBoxClicked()
+// purpose  : Check Boxes Management
+//=================================================================================
+void BasicGUI_PointDlg::CheckBoxClicked( int  State ) 
+{
+  myCheckFlag = State;
+  displayPreview();
+}
+
+
 //=================================================================================
 // funcion  : getParameter()
 // purpose  :
@@ -855,8 +871,13 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
         aParameters<<GroupOnCurve->SpinBox_DX->text();
       } 
       else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
-       anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter() ); 
+       anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), myCheckFlag );
+       
+       std::stringstream out;
+       out<<myCheckFlag;
+       std::string flag = out.str();
        aParameters<<GroupOnCurve->SpinBox_DX->text();
+       aParameters<<flag.c_str();
       }
       else if ( myParamCoord->checkedId() == COORD_VALUE ) {
         double x = GroupXYZ->SpinBox_DX->value();
@@ -990,17 +1011,19 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
 
   const int id = getConstructorId();
   if ( id == GEOM_POINT_EDGE ) {
-    GroupOnCurve->TextLabel2->setShown( isParam || isLength ); 
-    GroupOnCurve->SpinBox_DX->setShown( isParam || isLength );
+    GroupOnCurve->TextLabel2->setVisible( isParam || isLength ); 
+    GroupOnCurve->SpinBox_DX->setVisible( isParam || isLength );
     if ( isParam ){
       initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision" );
       GroupOnCurve->SpinBox_DX->setValue( 0.5 );
       GroupOnCurve->TextLabel2->setText(tr( "GEOM_PARAMETER" ));
+      GroupOnCurve->CheckButton1->setVisible(false);
     }
     else if ( isLength ){
-      initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, 0.1 * step, "length_precision" );
+      initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, step, "length_precision" );
       GroupOnCurve->SpinBox_DX->setValue( 0.0 );
       GroupOnCurve->TextLabel2->setText(tr( "GEOM_LENGTH" ));
+      GroupOnCurve->CheckButton1->setVisible(true);
     }
   }  
   else if ( id == GEOM_POINT_SURF ) {
index 0e6973fc41663597a6a0e7c2c634ced4410d5566..206111d8e3ae63fbe9b9b02932e9fbd0f46c93c1 100644 (file)
@@ -30,7 +30,7 @@
 #include <GEOMBase_Skeleton.h>
 #include <QMap>
 
-class DlgRef_1Sel1Spin;
+class DlgRef_1Sel1Spin1Check;
 class DlgRef_3Spin;
 class DlgRef_2Sel;
 class DlgRef_1Sel3Spin;
@@ -84,9 +84,11 @@ private:
 
   bool                               myBusy;
 
+  int                               myCheckFlag;
+
   DlgRef_3Spin*                      GroupXYZ;
   DlgRef_1Sel3Spin*                  GroupRefPoint;
-  DlgRef_1Sel1Spin*                  GroupOnCurve;
+  DlgRef_1Sel1Spin1Check*            GroupOnCurve;
   DlgRef_2Sel*                       GroupLineIntersection;
   DlgRef_1Sel2Spin*                  GroupOnSurface;
   
@@ -115,6 +117,7 @@ private slots:
   void                               ValueChangedInSpinBox( double );
   void                               SetDoubleSpinBoxStep( double );
   void                               ClickParamCoord( int );
+  void                               CheckBoxClicked( int );
   void                               onBtnPopup( QAction* );
   void                               updateSize();
 };
index ee4899f8e0d43f5c2cc16c7cfa0fe040075aeaf6..7e7d53bf9359ecbe1f304e10b8b324b4ec3a6767 100644 (file)
@@ -191,6 +191,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
                      double theParam1,
                      double theParam2,
                      double theParam3,
+                    int theFlag1,
                      const PointLocation theLocation)
 {
   SetErrorCode(KO);
@@ -229,7 +230,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
       break;
     case PointOn_CurveByLength:
       aPI.SetCurve(aRefFunction);
-      aPI.SetLength(theParam1); 
+      aPI.SetLength(theParam1);
+      aPI.SetFlag(theFlag1);
       break;
     case PointOn_CurveByCoord:
       aPI.SetCurve(aRefFunction);
@@ -275,7 +277,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
       break;
     case PointOn_CurveByLength:
       GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
-                                   << theGeomObj << ", " << theParam1 << ")";
+                                   << theGeomObj << ", " << theParam1 << ", " << theFlag1 <<  ")";
       break;
     case PointOn_CurveByCoord:
   GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
@@ -306,7 +308,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
                             (Handle(GEOM_Object) theCurve, double theParameter)
 {
-  return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
+  return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, 1, PointOn_CurveByParam);
 }
 
 //=============================================================================
@@ -320,7 +322,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
                      double theYParam,
                      double theZParam)
 {
-  return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
+  return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, 1, PointOn_CurveByCoord);
 }
 
 //=============================================================================
@@ -329,9 +331,11 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
-                    (Handle(GEOM_Object) theCurve, double theLength)
+                    (Handle(GEOM_Object) theCurve, 
+                    double theLength, 
+                    int theDirection)
 {
-  return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength);
+  return makePointOnGeom(theCurve, theLength, 0.0, 0.0, theDirection, PointOn_CurveByLength);
 }
 
 //=============================================================================
@@ -344,7 +348,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
                      double theUParameter,
                      double theVParameter)
 {
-  return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
+  return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., 1, PointOn_SurfaceByParam);
 }
 
 //=============================================================================
@@ -358,7 +362,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
                      double theYParam,
                      double theZParam)
 {
-  return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
+  return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, 1, PointOn_SurfaceByCoord);
 }
 
 
index 6a42fdf95ae128807f192614c41728d1eeac3ead..2066e14a03874f0f4ffda60a1cb0fde87994f417 100644 (file)
@@ -44,7 +44,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
                                                         double theParameter);
 
   Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve,
-                                                               double theLength);
+                                                               double theLength,
+                                                               int theDirection);
 
   Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve,
                                                                double theXParam,
@@ -134,6 +135,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
                                        double theParam1,
                                        double theParam2,
                                        double theParam3,
+                                      int theFlag1,
                                        const PointLocation theLocation);
 };
 
index 5c65005d0891d967a831ebbfeb30c891bce0691e..36ce68cac5b6fbb9a62e011cae05c6a070c98d39 100755 (executable)
@@ -40,6 +40,8 @@
 
 #define ARG_LENGTH 11
 
+#define ARG_FLAG 12
+
 class GEOMImpl_IPoint
 {
  public:
@@ -70,13 +72,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 SetFlag(int theFlag)  { _func->SetInteger(ARG_FLAG, theFlag); }
 
   double GetParameter() { return _func->GetReal(ARG_PARAM); }
   double GetParameter2() { return _func->GetReal(ARG_PARAM2); }
-
-  void SetLength(double theLength) { _func->SetReal(ARG_LENGTH, theLength); }
   double GetLength() { return _func->GetReal(ARG_LENGTH); }
+  int GetFlag() { return _func->GetInteger(ARG_FLAG); }
 
  private:
 
index 38411ee68be74cfb18c8e1efbfd47c9c8a24c376..49b709f5e94ecdf407311205d185456442becfce 100644 (file)
 #include <BRep_Builder.hxx>
 #include <Precision.hxx>
 #include <TopAbs.hxx>
+//#include <TopExp.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Compound.hxx>
+//#include <TopExp_Explorer.hxx>
 
 #include <Geom_Curve.hxx>
 #include <Geom_Surface.hxx>
@@ -48,6 +50,8 @@
 #include <GCPnts_AbscissaPoint.hxx>
 #include <BRepAdaptor_Curve.hxx>
 
+#include <BRep_Tool.hxx>
+
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -155,23 +159,28 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
   else if (aType == POINT_CURVE_LENGTH) {
     Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
     Standard_Real theLength = aPI.GetLength();
+    Standard_Integer theDirection = aPI.GetFlag(); 
     TopoDS_Shape aRefShape = aRefCurve->GetValue();
     if (aRefShape.ShapeType() != TopAbs_EDGE) {
       Standard_TypeMismatch::Raise
         ("Point On Curve creation aborted : curve shape is not an edge");
     }    
-    BRepAdaptor_Curve AdapCurve = BRepAdaptor_Curve(TopoDS::Edge(aRefShape));
+    Standard_Real UFirst = 0;
+    Standard_Real ULast = 0;
+    Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), UFirst, ULast);
+    Handle(Geom_Curve) ReOrientedCurve = EdgeCurve;
+    if ( theDirection == 2 )
+      ReOrientedCurve = EdgeCurve->Reversed();
+    else if ( theDirection == 0 )
+      ReOrientedCurve = EdgeCurve;
+    GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve);
     Standard_Real theCurveLength =  GCPnts_AbscissaPoint::Length(AdapCurve);
-    //std::cout<<"theCurveLength = "<<theCurveLength<<std::endl;
     if (theLength > theCurveLength) {
        Standard_ConstructionError::Raise
         ("Point On Curve creation aborted : given length is greater than edges length");
     }
-
-    GCPnts_AbscissaPoint anAbsPnt(AdapCurve, aPI.GetLength(), 0); 
+    GCPnts_AbscissaPoint anAbsPnt(AdapCurve, theLength, UFirst); 
     Standard_Real aParam = anAbsPnt.Parameter();
-    Standard_Real result_length = GCPnts_AbscissaPoint::Length(AdapCurve, 0, aParam); 
-    std::cout<<"calculated Length of the result = "<<result_length<<std::endl;  
     aPnt = AdapCurve.Value(aParam);
   }
   else if (aType == POINT_SURFACE_PAR) {
index 00399592cfda6754288454ccb026a5f4056a0209..fd462fa836fe9fa05a13ac390229ae0eadd3e6f3 100644 (file)
@@ -161,7 +161,9 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
  */
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
-                  (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theLength)
+                  (GEOM::GEOM_Object_ptr theCurve,  
+                  CORBA::Double theLength,
+                  CORBA::Double theDirection)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -174,7 +176,8 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
 
   //Create the point
   Handle(GEOM_Object) anObject =
-    GetOperations()->MakePointOnCurveByLength(aReference, theLength);
+    GetOperations()->MakePointOnCurveByLength(aReference, theLength,
+                                             theDirection);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index 6f26cee6c9b9d4f37e5878d3089a61e69003d7ad..a559062d6c0ab523953644ebdf0e90c3740c656b 100644 (file)
@@ -56,7 +56,8 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
                                           CORBA::Double theParameter);
 
    GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve,
-                                                  CORBA::Double theLength);
+                                                  CORBA::Double theLength,
+                                                  CORBA::Double theDirection);
 
    GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve,
                                                   CORBA::Double theXParameter,
index 3ca3c9e48ea7ebc364ec956ecd0c9601bb2fdc96..bcfb2485ac8f48cf4c780dd95431b416f72c325f 100644 (file)
@@ -591,12 +591,13 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the
 //  MakePointOnCurveByLength:
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve,
-                                                              CORBA::Double theLength)
+                                                              CORBA::Double theLength,
+                                                              CORBA::Double theDirection)
 {
   beginService( " GEOM_Superv_i::MakePointOnCurveByLength" );
   MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength");
   getBasicOp();
-  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength);
+  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theDirection);
   endService( " GEOM_Superv_i::MakePointOnCurveByLength" );
   return anObj;
 }
index c3608f0a1e3be27ee51065c2babc6911e23c3156..c97e931d319d05b046803d7644603241b559577e 100644 (file)
@@ -151,7 +151,8 @@ public:
   GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve,
                                          CORBA::Double theParameter);
   GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve,
-                                                 CORBA::Double theLength);
+                                                 CORBA::Double theLength,
+                                                 CORBA::Double theDirection);
   GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve,
                                                  CORBA::Double theXParameter,
                                                  CORBA::Double theYParameter,
index cb32ac012f57f3f7659945e3d8a635426a4e8631..bbb62b4633d1938890aed6d9ba7ac908640a8bce 100644 (file)
@@ -515,13 +515,14 @@ class geompyDC(GEOM._objref_GEOM_Gen):
        ## Create a point, corresponding to the given length on the given curve.
         #  @param theRefCurve The referenced curve.
         #  @param theLength length on the referenced curve.
+        #  @param theFirstParameter flag allowing to choose the direction for the calculation of the length (0 = forward or 2 = reversed).
         #  @return New GEOM_Object, containing the created point.
         #
         #  @ref tui_creation_point "Example"
-        def MakeVertexOnCurveByLength(self,theRefCurve, theLength):
+        def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theDirection):
             # Example: see GEOM_TestAll.py
             theLength, Parameters = ParseParameters(theLength)
-            anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength)
+            anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theDirection)
             RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp)
             anObj.SetParameters(Parameters)
             return anObj