0022782: [CEA 1315] GetFirstVertex does not return the edge's starting point

This commit is contained in:
skv 2015-06-11 11:53:02 +03:00
parent eba013acfe
commit 1839b501d4
14 changed files with 93 additions and 37 deletions

BIN
doc/salome/gui/GEOM/images/point3.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View 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.

View 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.

View 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);

View 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();
};

View 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>

View 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);
}
//=============================================================================

View 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

7
src/GEOMImpl/GEOMImpl_IPoint.hxx Executable file → Normal file
View File

@ -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:

View 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() );

View 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();

View 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,

View 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;
}

View 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")