]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
RNC: IMP EDF 1542: Added the functionnality MakeVertexOnCurveByLength that allows...
authorgdd <gdd>
Fri, 17 Dec 2010 10:15:39 +0000 (10:15 +0000)
committergdd <gdd>
Fri, 17 Dec 2010 10:15:39 +0000 (10:15 +0000)
15 files changed:
idl/GEOM_Gen.idl
src/BasicGUI/BasicGUI_PointDlg.cxx
src/EntityGUI/EntityGUI_3Spin1Check_QTD.ui
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMImpl/GEOMImpl_IBasicOperations.cxx
src/GEOMImpl/GEOMImpl_IBasicOperations.hxx
src/GEOMImpl/GEOMImpl_IPoint.hxx
src/GEOMImpl/GEOMImpl_PointDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
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 179ecf35a9606bd7a7b86cc7fde017b46c298a12..868dc7f92c9e1fb273a94e9cc46556c8f05cea03 100644 (file)
@@ -404,6 +404,16 @@ module GEOM
     GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve,
                                   in double theParameter);
 
+    /*!
+     *  Create a point, corresponding to the given length on the given curve.
+     *  \param theRefCurve The referenced curve.
+     *  \param theLength Length on the referenced curve.
+     *  \return New GEOM_Object, containing the created point.
+     */
+    GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve,
+                                          in double theLength);
+
+
     /*!
      *  Create a point on the given curve, projecting given point
      *  \param theRefCurve The referenced curve.
index 90af070cd3c473f9527c92482eb8cd62245496bd..8042083ede787f88d382aaa23ed118f3bdbdf9a2 100644 (file)
@@ -57,6 +57,7 @@
 
 #define PARAM_VALUE 0
 #define COORD_VALUE 1
+#define LENGTH_VALUE 2
 
 #define GEOM_POINT_XYZ    0
 #define GEOM_POINT_REF    1
@@ -107,6 +108,9 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), myParamGroup );
   myParamCoord->addButton( btn, PARAM_VALUE );
   boxLayout->addWidget( btn );
+  btn = new QRadioButton( tr( "GEOM_LENGTH_VALUE" ), myParamGroup ); 
+  myParamCoord->addButton( btn, LENGTH_VALUE );
+  boxLayout->addWidget( btn );
   btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup );
   myParamCoord->addButton( btn, COORD_VALUE );
   boxLayout->addWidget( btn );
@@ -367,6 +371,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
       GroupLineIntersection->hide();
       GroupOnSurface->hide();
       myParamGroup->show();
+      myParamCoord->button( LENGTH_VALUE )->show();
+      myParamCoord->button( PARAM_VALUE )->setChecked( true );
       GroupOnCurve->show();
       myCoordGrp->show();
       updateParamCoord( false );
@@ -409,6 +415,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
       GroupOnCurve->hide();
       GroupLineIntersection->hide();
       myParamGroup->show();
+      myParamCoord->button( LENGTH_VALUE )->hide();
+      myParamCoord->button( PARAM_VALUE )->setChecked(true);
       GroupOnSurface->show();
       myCoordGrp->show();
       updateParamCoord( false );
@@ -772,7 +780,7 @@ bool BasicGUI_PointDlg::isValid( QString& msg )
   }
   else if ( id == GEOM_POINT_EDGE ) {
     bool ok = true;
-    if ( myParamCoord->checkedId() == PARAM_VALUE )
+    if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE )
       ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
     else {
       ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
@@ -846,7 +854,12 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
       if ( myParamCoord->checkedId() == PARAM_VALUE ) {
         anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
         aParameters<<GroupOnCurve->SpinBox_DX->text();
-      } else {
+      } 
+      else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
+       anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter() ); 
+       aParameters<<GroupOnCurve->SpinBox_DX->text();
+      }
+      else if ( myParamCoord->checkedId() == COORD_VALUE ) {
         double x = GroupXYZ->SpinBox_DX->value();
         double y = GroupXYZ->SpinBox_DY->value();
         double z = GroupXYZ->SpinBox_DZ->value();
@@ -971,20 +984,34 @@ void BasicGUI_PointDlg::ClickParamCoord( int id )
 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
 {
   bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
+  bool isLength = myParamCoord->checkedId() == LENGTH_VALUE;
+
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
 
   const int id = getConstructorId();
   if ( id == GEOM_POINT_EDGE ) {
-    GroupOnCurve->TextLabel2->setShown( isParam );
-    GroupOnCurve->SpinBox_DX->setShown( isParam );
-  }
+    GroupOnCurve->TextLabel2->setShown( isParam || isLength ); 
+    GroupOnCurve->SpinBox_DX->setShown( 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" ));
+    }
+    else if ( isLength ){
+      initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, 0.1 * step, "length_precision" );
+      GroupOnCurve->SpinBox_DX->setValue( 0.0 );
+      GroupOnCurve->TextLabel2->setText(tr( "GEOM_LENGTH" ));
+    }
+  }  
   else if ( id == GEOM_POINT_SURF ) {
     GroupOnSurface->TextLabel2->setShown( isParam );
     GroupOnSurface->TextLabel3->setShown( isParam );
     GroupOnSurface->SpinBox_DX->setShown( isParam );
     GroupOnSurface->SpinBox_DY->setShown( isParam );
   }
-
-  GroupXYZ->setShown( !isParam );
+    
+  GroupXYZ->setShown( !isParam && !isLength );
 
   if ( theIsUpdate )
     QTimer::singleShot(50, this, SLOT(updateSize()));
index f68dc1c1fe81761cd0ee875cdb9afde278f9442e..fa331f7859c0aa5e93e84898adb50566bb4c28b4 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>297</width>
+    <width>496</width>
     <height>148</height>
    </rect>
   </property>
index b0ea88ed136f538fe77173383abd1bd1589aa38d..5a4e70bdee19eeff12f3a700ad2599ca0b0c04d9 100644 (file)
@@ -1102,6 +1102,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_COORD_VALUE</source>
         <translation>By coordinate</translation>
     </message>
+    <message>
+        <source>GEOM_LENGTH_VALUE</source>
+        <translation>By length</translation>
+    </message>
     <message>
         <source>GEOM_PARTITION</source>
         <translation>Partition</translation>
index 3564fc070843bfa4174229f965fd9a400958beb8..42e44bc1fcb954dfbf7fc1c647b2bda911819a69 100644 (file)
@@ -1100,6 +1100,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
     <message>
         <source>GEOM_COORD_VALUE</source>
         <translation>Par coordonnée</translation>
+    </message>
+     <message>
+        <source>GEOM_LENGTH_VALUE</source>
+        <translation>Par longueur</translation>
     </message>
     <message>
         <source>GEOM_PARTITION</source>
index 9d8bbea1b68f8adbce8a49f1794e6cd0612c686f..ee4899f8e0d43f5c2cc16c7cfa0fe040075aeaf6 100644 (file)
@@ -205,6 +205,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
   switch( theLocation )
     {
     case PointOn_CurveByParam:   fType = POINT_CURVE_PAR; break;
+    case PointOn_CurveByLength:  fType = POINT_CURVE_LENGTH; break;                             
     case PointOn_CurveByCoord:   fType = POINT_CURVE_COORD; break;
     case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
     case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
@@ -226,6 +227,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
       aPI.SetCurve(aRefFunction);
       aPI.SetParameter(theParam1);
       break;
+    case PointOn_CurveByLength:
+      aPI.SetCurve(aRefFunction);
+      aPI.SetLength(theParam1); 
+      break;
     case PointOn_CurveByCoord:
       aPI.SetCurve(aRefFunction);
       aPI.SetX(theParam1);
@@ -268,6 +273,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
       GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
                                    << theGeomObj << ", " << theParam1 << ")";
       break;
+    case PointOn_CurveByLength:
+      GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
+                                   << theGeomObj << ", " << theParam1 << ")";
+      break;
     case PointOn_CurveByCoord:
   GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
                                << theGeomObj << ", " << theParam1 
@@ -314,6 +323,17 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
   return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
 }
 
+//=============================================================================
+/*!
+ *  MakePointOnCurveByLength 
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
+                    (Handle(GEOM_Object) theCurve, double theLength)
+{
+  return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength);
+}
+
 //=============================================================================
 /*!
  *  MakePointOnSurface
index c851656a11265dba0fd016586f84ecd3633640fb..6a42fdf95ae128807f192614c41728d1eeac3ead 100644 (file)
@@ -43,6 +43,9 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve,
                                                         double theParameter);
 
+  Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve,
+                                                               double theLength);
+
   Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve,
                                                                double theXParam,
                                                                double theYParam,
@@ -122,6 +125,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
   { 
     PointOn_CurveByParam,
     PointOn_CurveByCoord,
+    PointOn_CurveByLength,   
     PointOn_SurfaceByParam,
     PointOn_SurfaceByCoord
   };
index 7ee94ea6e8b823a3538870539aa37db82b5766b3..5c65005d0891d967a831ebbfeb30c891bce0691e 100755 (executable)
@@ -38,6 +38,8 @@
 #define ARG_SURFACE 9
 #define ARG_PARAM2 10
 
+#define ARG_LENGTH 11
+
 class GEOMImpl_IPoint
 {
  public:
@@ -72,6 +74,10 @@ class GEOMImpl_IPoint
   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); }
+
  private:
 
   Handle(GEOM_Function) _func;
index 8af5452e656926f7ee8b4e056f7339b0019e7109..38411ee68be74cfb18c8e1efbfd47c9c8a24c376 100644 (file)
@@ -45,6 +45,8 @@
 #include <TopoDS_Face.hxx>
 #include <ShapeAnalysis.hxx>
 
+#include <GCPnts_AbscissaPoint.hxx>
+#include <BRepAdaptor_Curve.hxx>
 
 //=======================================================================
 //function : GetID
@@ -150,6 +152,28 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
         ("Point On Curve creation aborted : cannot project point");
     }
   }
+  else if (aType == POINT_CURVE_LENGTH) {
+    Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
+    Standard_Real theLength = aPI.GetLength();
+    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 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); 
+    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) {
     Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
     TopoDS_Shape aRefShape = aRefCurve->GetValue();
index b954ec438f89401f360fa1f53536d49e4b253d1f..6b98bf77bcbc0008e23862ad60f64cb1a0cbe004 100755 (executable)
 #define POINT_SURFACE_PAR        5
 #define POINT_CURVE_COORD        6
 #define POINT_SURFACE_COORD      7
+#define POINT_CURVE_LENGTH       8 
 
 #define VECTOR_TWO_PNT  1
 #define VECTOR_DX_DY_DZ 2
index 1e7fbc247d9bbb14a9228e89e8dc100efc4b9fa1..00399592cfda6754288454ccb026a5f4056a0209 100644 (file)
@@ -155,6 +155,32 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  MakePointOnCurveByLength
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
+                  (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theLength)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference curve
+  Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
+  if (aReference.IsNull()) return aGEOMObject._retn();
+
+  //Create the point
+  Handle(GEOM_Object) anObject =
+    GetOperations()->MakePointOnCurveByLength(aReference, theLength);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  MakePointOnCurveByCoord
index a54cc4417a98cfca38064c7b7752677b43d8cc13..6f26cee6c9b9d4f37e5878d3089a61e69003d7ad 100644 (file)
@@ -55,6 +55,9 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
    GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve,
                                           CORBA::Double theParameter);
 
+   GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve,
+                                                  CORBA::Double theLength);
+
    GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve,
                                                   CORBA::Double theXParameter,
                                                   CORBA::Double theYParameter,
index aa842150ae7fc1c0e492bbc56b31357795c8ebec..3ca3c9e48ea7ebc364ec956ecd0c9601bb2fdc96 100644 (file)
@@ -587,6 +587,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the
   return anObj;
 }
 
+//=============================================================================
+//  MakePointOnCurveByLength:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve,
+                                                              CORBA::Double theLength)
+{
+  beginService( " GEOM_Superv_i::MakePointOnCurveByLength" );
+  MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength");
+  getBasicOp();
+  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength);
+  endService( " GEOM_Superv_i::MakePointOnCurveByLength" );
+  return anObj;
+}
+
 //=============================================================================
 //  MakePointOnCurveByCoord
 //=============================================================================
index c713705ed52a5571c2af52d2634f48ce96d6116f..c3608f0a1e3be27ee51065c2babc6911e23c3156 100644 (file)
@@ -150,6 +150,8 @@ public:
                                                CORBA::Double theZ);
   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);
   GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve,
                                                  CORBA::Double theXParameter,
                                                  CORBA::Double theYParameter,
index 4c7c7919a6caae6889bf08c8527a1f95e9c77bb7..e99f710aa288a1022a7d369aa1b487b6fd2c4080 100644 (file)
@@ -503,6 +503,20 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("MakeVertexOnCurveByCoord", self.BasicOp)
             anObj.SetParameters(Parameters)
             return anObj
+       
+       ## Create a point, corresponding to the given length on the given curve.
+        #  @param theRefCurve The referenced curve.
+        #  @param theLength length on the referenced curve.
+        #  @return New GEOM_Object, containing the created point.
+        #
+        #  @ref tui_creation_point "Example"
+        def MakeVertexOnCurveByLength(self,theRefCurve, theLength):
+            # Example: see GEOM_TestAll.py
+            theLength, Parameters = ParseParameters(theLength)
+            anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength)
+            RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp)
+            anObj.SetParameters(Parameters)
+            return anObj
 
         ## Create a point, corresponding to the given parameters on the
         #    given surface.