0020098: EDF 899 GEOM : Point on curve/surface with X,Y,Z coordinates.

This commit is contained in:
ptv 2009-08-27 12:47:34 +00:00
parent bee423e7b3
commit 3d7b37578a
12 changed files with 472 additions and 135 deletions

View File

@ -25,14 +25,22 @@ the position of this point regarding the reference one.
\image html point2.png \image html point2.png
\n Thirdly, we can define a point by an \b Edge and a \b Parameter \n Thirdly, we can define a point by an \b Edge and a \b
[list]
[*]Parameter
indicating its position on the Edge, ranging from 0.0 to 1.0. For example, 0.5 means that the 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. 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).</em>
\n <b>Arguments:</b> Name + 1 edge + 1 Parameter defining the \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.
\image html point3.png \image html point3.png
[*]3D co-ordinate of point to project on the given edge
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnCurveByCoord(Edge,X,Y,Z).</em>
\n <b>Arguments:</b> Name + 1 edge + 3 coordinate values
to project point on the given edge.
\image html point3_2.png
[/list]
\n Fourthly, we can define a point by intersection of two \b Lines. \n Fourthly, we can define a point by intersection of two \b Lines.
\n <b>TUI Command:</b> <em>geompy.MakePointOnLinesIntersection(myLine1,myLine2).</em> \n <b>TUI Command:</b> <em>geompy.MakePointOnLinesIntersection(myLine1,myLine2).</em>
@ -41,14 +49,21 @@ position of the point on the given edge.
\image html point4.png \image html point4.png
<b>Example:</b> <b>Example:</b>
\n Finally, we can define a point by a \b Face and two <b> Parameters: U </b> and \b V \n Finally, we can define a point by a \b Face and
[list]
[*]Two <b> Parameters: U </b> and \b V
indicating its position on the Face, ranging from 0.0 to 1.0. For example, (0.5; 0.5) means that the indicating its position on the Face, ranging from 0.0 to 1.0. For example, (0.5; 0.5) means that the
point is located in the middle of the face. point is located in the middle of the face.
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurface(myFace,myUParameter,myVParameter).</em> \n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurface(myFace,myUParameter,myVParameter).</em>
\n <b>Arguments:</b> Name + 1 face + 2 Parameters defining the \n <b>Arguments:</b> Name + 1 face + 2 Parameters defining the
position of the point on the given face. position of the point on the given face.
[*] 3D co-ordinate of point to project on the given face.
\image html point5.png \image html point5.png
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurface(myFace,X,Y,Z).</em>
\n <b>Arguments:</b> Name + 1 face + 3 coordinate values
to project point on the given face.
\image html point5_2.png
[/list]
<b>Example:</b> <b>Example:</b>

View File

@ -17,9 +17,19 @@ px = geompy.MakeVertex(100., 0., 0.)
py = geompy.MakeVertex(0., 100., 0.) py = geompy.MakeVertex(0., 100., 0.)
pz = geompy.MakeVertex(0., 0., 100.) pz = geompy.MakeVertex(0., 0., 100.)
# create a curve and a vertex on it # create a curve and a vertices on it
Arc = geompy.MakeArc(py, pz, px) Arc = geompy.MakeArc(py, pz, px)
# create vertex by parameter
p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)
#create vertex by point projection
p_on_arc2 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10)
# create a face and vertices on it
Add_line = geompy.MakeLineTwoPnt(px, py)
arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face_1, 35, 35, 35)
# add objects in the study # add objects in the study
id_p0 = geompy.addToStudy(p0, "Vertex 0") id_p0 = geompy.addToStudy(p0, "Vertex 0")
@ -28,7 +38,10 @@ id_px = geompy.addToStudy(px, "Vertex X")
id_py = geompy.addToStudy(py, "Vertex Y") id_py = geompy.addToStudy(py, "Vertex Y")
id_pz = geompy.addToStudy(pz, "Vertex Z") id_pz = geompy.addToStudy(pz, "Vertex Z")
id_Arc = geompy.addToStudy(Arc, "Arc") id_Arc = geompy.addToStudy(Arc, "Arc")
id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc") id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter")
id_p_on_arc2 = geompy.addToStudy(p_on_arc, "Vertex on Arc by point projection")
id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
# display vertices # display vertices
gg.createAndDisplayGO(id_p0) gg.createAndDisplayGO(id_p0)

View File

@ -23,6 +23,12 @@
\until MakeVertexOnCurve \until MakeVertexOnCurve
\until MakeVertexOnCurveByCoord
\until MakeVertexOnSurface
\until MakeVertexOnSurfaceByCoord
\anchor swig_MakeVertexOnLinesIntersection \anchor swig_MakeVertexOnLinesIntersection
\until p_on_l1l2 \until p_on_l1l2

View File

@ -327,6 +327,19 @@ module GEOM
GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve, GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve,
in double theParameter); in double theParameter);
/*!
* Create a point on the given curve, projecting given point
* \param theRefCurve The referenced curve.
* \param theXParameter X co-ordinate of point to project on curve
* \param theYParameter Y co-ordinate of point to project on curve
* \param theZParameter Z co-ordinate of point to project on curve
* \return New GEOM_Object, containing the created point.
*/
GEOM_Object MakePointOnCurveByCoord (in GEOM_Object theRefCurve,
in double theXParameter,
in double theYarameter,
in double theZPameter);
/*! /*!
* Create a point, corresponding to the given parameters on the * Create a point, corresponding to the given parameters on the
* given surface. * given surface.
@ -339,6 +352,20 @@ module GEOM
in double theUParameter, in double theUParameter,
in double theVParameter); in double theVParameter);
/*!
* Create a point on the given surface, projecting given point
* \param theRefSurf The referenced surface.
* \param theXParameter X co-ordinate of point to project on curve
* \param theYParameter Y co-ordinate of point to project on curve
* \param theZParameter Z co-ordinate of point to project on curve
* \return New GEOM_Object, containing the created point.
*/
GEOM_Object MakePointOnSurfaceByCoord (in GEOM_Object theRefSurf,
in double theXParameter,
in double theYarameter,
in double theZPameter);
/*! /*!
* Create a point, on two lines intersection. * Create a point, on two lines intersection.
* \param theRefLine1, theRefLine2 The referenced lines. * \param theRefLine1, theRefLine2 The referenced lines.

View File

@ -38,7 +38,10 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <QApplication> #include <QApplication>
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QRadioButton>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
@ -49,6 +52,16 @@
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#define PARAM_VALUE 0
#define COORD_VALUE 1
#define POINT_XYZ 0
#define POINT_REF 1
#define POINT_EDGE 2
#define POINT_INTINT 3
#define POINT_SURF 4
//================================================================================= //=================================================================================
// class : BasicGUI_PointDlg() // class : BasicGUI_PointDlg()
// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
@ -79,6 +92,19 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
mainFrame()->RadioButton5->show(); mainFrame()->RadioButton5->show();
mainFrame()->RadioButton5->setIcon( image5 ); mainFrame()->RadioButton5->setIcon( image5 );
QGroupBox* paramGrp = new QGroupBox( centralWidget() );
myParamCoord = new QButtonGroup( paramGrp );
QHBoxLayout* boxLayout = new QHBoxLayout( paramGrp );
boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), paramGrp );
myParamCoord->addButton( btn, PARAM_VALUE );
boxLayout->addWidget( btn );
btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), paramGrp );
myParamCoord->addButton( btn, COORD_VALUE );
boxLayout->addWidget( btn );
myParamCoord->setExclusive( true );
myParamCoord->button( PARAM_VALUE )->setChecked( true );
GroupXYZ = new DlgRef_3Spin( centralWidget() ); GroupXYZ = new DlgRef_3Spin( centralWidget() );
GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) ); GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) ); GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
@ -86,13 +112,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) ); GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() ); GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) ); GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) ); GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) ); GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
GroupOnCurve->PushButton1->setIcon( image2 ); GroupOnCurve->PushButton1->setIcon( image2 );
GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() ); GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) ); GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) ); GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) ); GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) ); GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
@ -114,7 +140,7 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
GroupLineIntersection->PushButton2->setIcon( image2 ); GroupLineIntersection->PushButton2->setIcon( image2 );
GroupLineIntersection->LineEdit2->setEnabled(false); GroupLineIntersection->LineEdit2->setEnabled(false);
myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() ); myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp ); QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 ); myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
myX = new QLineEdit( myCoordGrp ); myX = new QLineEdit( myCoordGrp );
@ -128,6 +154,7 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( paramGrp );
layout->addWidget( GroupXYZ ); layout->addWidget( GroupXYZ );
layout->addWidget( GroupOnCurve ); layout->addWidget( GroupOnCurve );
layout->addWidget( GroupOnSurface ); layout->addWidget( GroupOnSurface );
@ -221,6 +248,9 @@ void BasicGUI_PointDlg::Init()
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( myParamCoord->button( PARAM_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
connect( myParamCoord->button( COORD_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
@ -280,7 +310,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
switch ( constructorId ) { switch ( constructorId ) {
case 0: case POINT_XYZ:
{ {
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
@ -291,10 +321,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
myCoordGrp->hide(); myCoordGrp->hide();
myParamCoord->button( PARAM_VALUE )->hide();
myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->show(); GroupXYZ->show();
break; break;
} }
case 1: case POINT_REF:
{ {
myEditCurrentArgument = GroupRefPoint->LineEdit1; myEditCurrentArgument = GroupRefPoint->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
@ -302,6 +334,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
GroupRefPoint->PushButton1->setDown(true); GroupRefPoint->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myParamCoord->button( PARAM_VALUE )->hide();
myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide(); GroupXYZ->hide();
GroupOnCurve->hide(); GroupOnCurve->hide();
GroupLineIntersection->hide(); GroupLineIntersection->hide();
@ -312,7 +346,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
myCoordGrp->show(); myCoordGrp->show();
break; break;
} }
case 2: case POINT_EDGE:
{ {
myEditCurrentArgument = GroupOnCurve->LineEdit1; myEditCurrentArgument = GroupOnCurve->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
@ -320,17 +354,19 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
GroupOnCurve->PushButton1->setDown(true); GroupOnCurve->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
GroupXYZ->hide();
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupLineIntersection->hide(); GroupLineIntersection->hide();
GroupOnSurface->hide(); GroupOnSurface->hide();
myParamCoord->button( PARAM_VALUE )->show();
myParamCoord->button( COORD_VALUE )->show();
GroupOnCurve->show(); GroupOnCurve->show();
myCoordGrp->show(); myCoordGrp->show();
updateParamCoord( false );
break; break;
} }
case 3: case POINT_INTINT:
{ {
myEditCurrentArgument = GroupLineIntersection->LineEdit1; myEditCurrentArgument = GroupLineIntersection->LineEdit1;
GroupLineIntersection->LineEdit1->setText( "" ); GroupLineIntersection->LineEdit1->setText( "" );
@ -344,6 +380,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
myParamCoord->button( PARAM_VALUE )->hide();
myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide(); GroupXYZ->hide();
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupOnCurve->hide(); GroupOnCurve->hide();
@ -354,7 +392,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
GroupLineIntersection->show(); GroupLineIntersection->show();
break; break;
} }
case 4: case POINT_SURF:
{ {
myEditCurrentArgument = GroupOnSurface->LineEdit1; myEditCurrentArgument = GroupOnSurface->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
@ -362,14 +400,16 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
GroupOnSurface->PushButton1->setDown(true); GroupOnSurface->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
GroupXYZ->hide();
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupOnCurve->hide(); GroupOnCurve->hide();
GroupLineIntersection->hide(); GroupLineIntersection->hide();
myParamCoord->button( PARAM_VALUE )->show();
myParamCoord->button( COORD_VALUE )->show();
GroupOnSurface->show(); GroupOnSurface->show();
myCoordGrp->show(); myCoordGrp->show();
updateParamCoord( false );
break; break;
} }
} }
@ -420,7 +460,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
{ {
const int id = getConstructorId(); const int id = getConstructorId();
if ( ( id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0 ) if ( ( id == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) && myEditCurrentArgument != 0 )
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
myX->setText( "" ); myX->setText( "" );
@ -442,9 +482,9 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
if ( id == 2 || id == 3 ) if ( id == POINT_EDGE || id == POINT_INTINT )
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
else if ( id == 4 ) else if ( id == POINT_SURF )
aNeedType = TopAbs_FACE; aNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
@ -473,7 +513,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
if ( aShape.ShapeType() != aNeedType ) { if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
if ( id == 0 ) return; if ( id == POINT_XYZ ) return;
} }
} }
} }
@ -481,21 +521,21 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
if ( aShape.IsNull() || aShape.ShapeType() != aNeedType) if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
return; return;
if ( id == 0 ) { if ( id == POINT_XYZ ) {
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
GroupXYZ->SpinBox_DX->setValue( aPnt.X() ); GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
GroupXYZ->SpinBox_DY->setValue( aPnt.Y() ); GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() ); GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
} }
else if ( id == 1 ) { else if ( id == POINT_REF ) {
myRefPoint = aSelectedObject; myRefPoint = aSelectedObject;
GroupRefPoint->LineEdit1->setText( aName ); GroupRefPoint->LineEdit1->setText( aName );
} }
else if ( id == 2 ) { else if ( id == POINT_EDGE ) {
myEdge = aSelectedObject; myEdge = aSelectedObject;
GroupOnCurve->LineEdit1->setText( aName ); GroupOnCurve->LineEdit1->setText( aName );
} }
else if ( id == 3 ) { else if ( id == POINT_INTINT ) {
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
globalSelection(); globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
@ -510,7 +550,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
GroupLineIntersection->PushButton1->click(); GroupLineIntersection->PushButton1->click();
} }
} }
else if ( id == 4 ) else if ( id == POINT_SURF )
{ {
myFace = aSelectedObject; myFace = aSelectedObject;
GroupOnSurface->LineEdit1->setText( aName ); GroupOnSurface->LineEdit1->setText( aName );
@ -667,7 +707,7 @@ double BasicGUI_PointDlg::getVParameter() const
//================================================================================= //=================================================================================
void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt ) void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
{ {
if ( getConstructorId() == 0 ) { if ( getConstructorId() == POINT_XYZ ) {
GroupXYZ->SpinBox_DX->setValue( thePnt.X() ); GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
GroupXYZ->SpinBox_DY->setValue( thePnt.Y() ); GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() ); GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
@ -692,14 +732,14 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
bool BasicGUI_PointDlg::isValid( QString& msg ) bool BasicGUI_PointDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); const int id = getConstructorId();
if ( id == 0 ) { if ( id == POINT_XYZ ) {
bool ok = true; bool ok = true;
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
return ok; return ok;
} }
else if ( id == 1 ) { else if ( id == POINT_REF ) {
bool ok = true; bool ok = true;
ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
@ -707,16 +747,30 @@ bool BasicGUI_PointDlg::isValid( QString& msg )
return !myRefPoint->_is_nil() && ok; return !myRefPoint->_is_nil() && ok;
} }
else if ( id == 2 ) { else if ( id == POINT_EDGE ) {
bool ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() ); bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE )
ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
else {
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
}
return !myEdge->_is_nil() && ok; return !myEdge->_is_nil() && ok;
} }
else if ( id == 3 ) else if ( id == POINT_INTINT )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() ); return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
else if ( id == 4 ) { else if ( id == POINT_SURF ) {
bool ok = true; bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
}
else {
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
}
return !myFace->_is_nil() && ok; return !myFace->_is_nil() && ok;
} }
@ -735,7 +789,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
QStringList aParameters; QStringList aParameters;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case POINT_XYZ :
{ {
double x = GroupXYZ->SpinBox_DX->value(); double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value(); double y = GroupXYZ->SpinBox_DY->value();
@ -749,7 +803,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
res = true; res = true;
break; break;
} }
case 1 : case POINT_REF :
{ {
double dx = GroupRefPoint->SpinBox_DX->value(); double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value(); double dy = GroupRefPoint->SpinBox_DY->value();
@ -764,36 +818,66 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
res = true; res = true;
break; break;
} }
case 2 : case POINT_EDGE :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> {
MakePointOnCurve( myEdge, getParameter() ); GEOM::GEOM_IBasicOperations_ptr anOp =
GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
anObj = anOp->MakePointOnCurve( myEdge, getParameter() );
aParameters<<GroupOnCurve->SpinBox_DX->text(); aParameters<<GroupOnCurve->SpinBox_DX->text();
} else {
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
double z = GroupXYZ->SpinBox_DZ->value();
aParameters << GroupXYZ->SpinBox_DX->text();
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
anObj = anOp->MakePointOnCurveByCoord( myEdge, x, y, z );
}
res = true; res = true;
break; break;
case 3 : }
case POINT_INTINT :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointOnLinesIntersection( myLine1, myLine2 ); MakePointOnLinesIntersection( myLine1, myLine2 );
res = true; res = true;
break; break;
case 4 : case POINT_SURF :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> {
MakePointOnSurface( myFace, getUParameter(), getVParameter() ); GEOM::GEOM_IBasicOperations_ptr anOp =
GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
anObj = anOp->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
aParameters<<GroupOnSurface->SpinBox_DX->text(); aParameters<<GroupOnSurface->SpinBox_DX->text();
aParameters<<GroupOnSurface->SpinBox_DY->text(); aParameters<<GroupOnSurface->SpinBox_DY->text();
} else {
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
double z = GroupXYZ->SpinBox_DZ->value();
aParameters << GroupXYZ->SpinBox_DX->text();
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
anObj = anOp->MakePointOnSurfaceByCoord( myFace, x, y, z );
}
res = true; res = true;
break; break;
} }
}
if(!anObj->_is_nil() && !IsPreview() && (getConstructorId()==0 || const int id = getConstructorId();
getConstructorId() == 1 || if(!anObj->_is_nil() && !IsPreview() && (id == POINT_XYZ ||
getConstructorId() == 2 || id == POINT_REF ||
getConstructorId() == 4) ) { id == POINT_EDGE ||
id == POINT_SURF) ) {
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
} }
if ( getConstructorId() == 1 || getConstructorId() == 2 || if ( id == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) {
getConstructorId() == 4 ) {
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
aShape.ShapeType() == TopAbs_VERTEX ) { aShape.ShapeType() == TopAbs_VERTEX ) {
@ -825,21 +909,57 @@ void BasicGUI_PointDlg::addSubshapesToStudy()
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case POINT_XYZ:
break; break;
case 1: case POINT_REF:
objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
break; break;
case 2: case POINT_EDGE:
objMap[GroupOnCurve->LineEdit1->text()] = myEdge; objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
break; break;
case 3: case POINT_INTINT:
objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
break; break;
case 4: case POINT_SURF:
objMap[GroupOnSurface->LineEdit1->text()] = myFace; objMap[GroupOnSurface->LineEdit1->text()] = myFace;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather( objMap );
} }
//=================================================================================
// function : ClickParamCoord()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::ClickParamCoord()
{
updateParamCoord( true );
}
//=================================================================================
// function : updateParamCoord
// purpose :
//=================================================================================
void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
{
bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
GroupXYZ->setShown( !isParam );
const int id = getConstructorId();
if ( id == POINT_EDGE ) {
GroupOnCurve->TextLabel2->setShown( isParam );
GroupOnCurve->SpinBox_DX->setShown( isParam );
}
else if ( id == POINT_SURF ) {
GroupOnSurface->TextLabel2->setShown( isParam );
GroupOnSurface->TextLabel3->setShown( isParam );
GroupOnSurface->SpinBox_DX->setShown( isParam );
GroupOnSurface->SpinBox_DY->setShown( isParam );
}
if ( theIsUpdate ) {
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
}
}

View File

@ -36,6 +36,7 @@ class DlgRef_1Sel2Spin;
class QLineEdit; class QLineEdit;
class QGroupBox; class QGroupBox;
class QButtonGroup;
class gp_Pnt; class gp_Pnt;
@ -68,6 +69,7 @@ private:
double getParameter() const; double getParameter() const;
double getUParameter() const; double getUParameter() const;
double getVParameter() const; double getVParameter() const;
void updateParamCoord(bool theIsUpdate);
private: private:
GEOM::GEOM_Object_var myEdge; GEOM::GEOM_Object_var myEdge;
@ -86,6 +88,7 @@ private:
QLineEdit* myX; QLineEdit* myX;
QLineEdit* myY; QLineEdit* myY;
QLineEdit* myZ; QLineEdit* myZ;
QButtonGroup* myParamCoord;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
@ -98,6 +101,7 @@ private slots:
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );
void ClickParamCoord();
}; };
#endif // BASICGUI_POINTDLG_H #endif // BASICGUI_POINTDLG_H

View File

@ -427,6 +427,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_COORDINATES</source> <source>GEOM_COORDINATES</source>
<translation>Coordinates</translation> <translation>Coordinates</translation>
</message> </message>
<message>
<source>GEOM_COORDINATES_RES</source>
<translation>Result coordinates</translation>
</message>
<message> <message>
<source>GEOM_CREATE_COPY</source> <source>GEOM_CREATE_COPY</source>
<translation>Create a copy</translation> <translation>Create a copy</translation>
@ -1076,8 +1080,20 @@ Please, select face, shell or solid and try again</translation>
<translation>Parameters</translation> <translation>Parameters</translation>
</message> </message>
<message> <message>
<source>GEOM_PARAM_POINT</source> <source>GEOM_POINT_ON_EDGE</source>
<translation>Parametric point</translation> <translation>Point on Edge</translation>
</message>
<message>
<source>GEOM_POINT_ON_FACE</source>
<translation>Point on Face</translation>
</message>
<message>
<source>GEOM_PARAM_VALUE</source>
<translation>By parameter</translation>
</message>
<message>
<source>GEOM_COORD_VALUE</source>
<translation>By coordinate</translation>
</message> </message>
<message> <message>
<source>GEOM_PARTITION</source> <source>GEOM_PARTITION</source>

View File

@ -269,6 +269,10 @@
<source>GEOM_COORDINATES</source> <source>GEOM_COORDINATES</source>
<translation>Coordonnes</translation> <translation>Coordonnes</translation>
</message> </message>
<message>
<source>GEOM_COORDINATES_RES</source>
<translation>Resultats coordonnes</translation>
</message>
<message> <message>
<source>GEOM_CREATE_COPY</source> <source>GEOM_CREATE_COPY</source>
<translation>Create a copy</translation> <translation>Create a copy</translation>
@ -726,8 +730,20 @@
<translation>Paramtre :</translation> <translation>Paramtre :</translation>
</message> </message>
<message> <message>
<source>GEOM_PARAM_POINT</source> <source>GEOM_POINT_ON_EDGE</source>
<translation>Point paramtrique</translation> <translation>Point sur la Edge</translation>
</message>
<message>
<source>GEOM_POINT_ON_FACE</source>
<translation>Point sur la Face</translation>
</message>
<message>
<source>GEOM_PARAM_VALUE</source>
<translation>By paramtrique</translation>
</message>
<message>
<source>GEOM_COORD_VALUE</source>
<translation>By Coordonnes</translation>
</message> </message>
<message> <message>
<source>GEOM_PARTITION</source> <source>GEOM_PARTITION</source>

View File

@ -182,32 +182,67 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
//============================================================================= //=============================================================================
/*! /*!
* MakePointOnCurve * makePointOnGeom
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
(Handle(GEOM_Object) theCurve, double theParameter) (Handle(GEOM_Object) theGeomObj,
double theParam1,
double theParam2,
double theParam3,
const PointLocation theLocation)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theCurve.IsNull()) return NULL; if (theGeomObj.IsNull()) return NULL;
//Add a new Point object //Add a new Point object
Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT); Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
//Add a new Point function for creation a point relativley another point //Add a new Point function for creation a point relativley another point
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_CURVE_PAR); int fType = POINT_CURVE_PAR;
switch( theLocation )
{
case PointOn_CurveByParam: fType = POINT_CURVE_PAR; 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;
default: break;
}
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
//Check if the function is set correctly //Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL; if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
GEOMImpl_IPoint aPI (aFunction); GEOMImpl_IPoint aPI (aFunction);
Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction(); Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
if (aRefFunction.IsNull()) return NULL; if (aRefFunction.IsNull()) return NULL;
switch( theLocation )
{
case PointOn_CurveByParam:
aPI.SetCurve(aRefFunction); aPI.SetCurve(aRefFunction);
aPI.SetParameter(theParameter); aPI.SetParameter(theParam1);
break;
case PointOn_CurveByCoord:
aPI.SetCurve(aRefFunction);
aPI.SetX(theParam1);
aPI.SetY(theParam2);
aPI.SetZ(theParam3);
break;
case PointOn_SurfaceByParam:
aPI.SetSurface(aRefFunction);
aPI.SetParameter(theParam1);
aPI.SetParameter2(theParam2);
break;
case PointOn_SurfaceByCoord:
aPI.SetSurface(aRefFunction);
aPI.SetX(theParam1);
aPI.SetY(theParam2);
aPI.SetZ(theParam3);
default: break;
}
//Compute the point value //Compute the point value
try { try {
@ -226,13 +261,57 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
} }
//Make a Python command //Make a Python command
switch( theLocation )
{
case PointOn_CurveByParam:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve(" GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
<< theCurve << ", " << theParameter << ")"; << theGeomObj << ", " << theParam1 << ")";
break;
case PointOn_CurveByCoord:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
break;
case PointOn_SurfaceByParam:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ")";
break;
case PointOn_SurfaceByCoord:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
default: break;
}
SetErrorCode(OK); SetErrorCode(OK);
return aPoint; return aPoint;
} }
//=============================================================================
/*!
* MakePointOnCurve
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
(Handle(GEOM_Object) theCurve, double theParameter)
{
return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
}
//=============================================================================
/*!
* MakePointOnCurveByCoord
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
(Handle(GEOM_Object) theCurve,
double theXParam,
double theYParam,
double theZParam)
{
return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
}
//============================================================================= //=============================================================================
/*! /*!
@ -240,54 +319,25 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
(Handle(GEOM_Object) theSurface, double theUParameter, double theVParameter) (Handle(GEOM_Object) theSurface,
double theUParameter,
double theVParameter)
{ {
SetErrorCode(KO); return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
if (theSurface.IsNull()) return NULL;
//Add a new Point object
Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
//Add a new Point function for creation a point relativley another point
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(),
POINT_SURFACE_PAR);
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
GEOMImpl_IPoint aPI (aFunction);
Handle(GEOM_Function) aRefFunction = theSurface->GetLastFunction();
if (aRefFunction.IsNull()) return NULL;
aPI.SetSurface(aRefFunction);
aPI.SetParameter(theUParameter);
aPI.SetParameter2(theVParameter);
//Compute the point value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Point driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
} }
//Make a Python command //=============================================================================
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface(" /*!
<< theSurface << ", " << theUParameter * MakePointOnSurfaceByCoord
<< ", " << theVParameter << ")"; */
//=============================================================================
SetErrorCode(OK); Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
return aPoint; (Handle(GEOM_Object) theSurface,
double theXParam,
double theYParam,
double theZParam)
{
return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
} }

View File

@ -42,6 +42,11 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve, Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve,
double theParameter); double theParameter);
Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve,
double theXParam,
double theYParam,
double theZParam);
Standard_EXPORT Handle(GEOM_Object) MakePointOnLinesIntersection Standard_EXPORT Handle(GEOM_Object) MakePointOnLinesIntersection
(Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2); (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2);
@ -49,6 +54,11 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
double theUParameter, double theUParameter,
double theVParameter); double theVParameter);
Standard_EXPORT Handle(GEOM_Object) MakePointOnSurfaceByCoord (Handle(GEOM_Object) theSurface,
double theXParam,
double theYParam,
double theZParam);
// Vector // Vector
Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ); Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ);
@ -96,6 +106,24 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
double theParamV, double theParamV,
double theSize); double theSize);
private:
// Private methods
//! Enumeration describes point position on geometric object (curve or surface)
//! Point location can be determined by parameter (or U, V parameters) or 3D coordinates
enum PointLocation
{
PointOn_CurveByParam,
PointOn_CurveByCoord,
PointOn_SurfaceByParam,
PointOn_SurfaceByCoord
};
Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj,
double theParam1,
double theParam2,
double theParam3,
const PointLocation theLocation);
}; };
#endif #endif

View File

@ -29,6 +29,8 @@
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepExtrema_DistShapeShape.hxx> #include <BRepExtrema_DistShapeShape.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -105,6 +107,23 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aP = aFP + (aLP - aFP) * aPI.GetParameter(); aP = aFP + (aLP - aFP) * aPI.GetParameter();
aPnt = aCurve->Value(aP); aPnt = aCurve->Value(aP);
} }
else if (aType == POINT_CURVE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
}
Standard_Real aFP, aLP;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFP, aLP);
gp_Pnt anInitPnt( aPI.GetX(), aPI.GetY(), aPI.GetZ() );
GeomAPI_ProjectPointOnCurve aProj(anInitPnt, aCurve/*, aFP, aLP*/);
if ( aProj.NbPoints() <= 0 ) {
Standard_ConstructionError::Raise
("Point On Curve creation aborted : cannot project point");
}
aPnt = aProj.NearestPoint();
}
else if (aType == POINT_SURFACE_PAR) { else if (aType == POINT_SURFACE_PAR) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface(); Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue(); TopoDS_Shape aRefShape = aRefCurve->GetValue();
@ -121,6 +140,28 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
Standard_Real V = V1 + (V2-V1) * aPI.GetParameter2(); Standard_Real V = V1 + (V2-V1) * aPI.GetParameter2();
aPnt = aSurf->Value(U,V); aPnt = aSurf->Value(U,V);
} }
else if (aType == POINT_SURFACE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face");
}
TopoDS_Face F = TopoDS::Face(aRefShape);
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
Standard_Real U1,U2,V1,V2;
//aSurf->Bounds(U1,U2,V1,V2);
ShapeAnalysis::GetFaceUVBounds(F,U1,U2,V1,V2);
gp_Pnt anInitPnt( aPI.GetX(), aPI.GetY(), aPI.GetZ() );
GeomAPI_ProjectPointOnSurf aProj( anInitPnt, aSurf/*,
U1,U2,V1,V2, Precision::Confusion()*/ );
if ( !aProj.IsDone() ) {
Standard_ConstructionError::Raise
("Point On Surface creation aborted : cannot project point");
}
aPnt = aProj.NearestPoint();
}
else if (aType == POINT_LINES_INTERSECTION) { else if (aType == POINT_LINES_INTERSECTION) {
Handle(GEOM_Function) aRef1 = aPI.GetLine1(); Handle(GEOM_Function) aRef1 = aPI.GetLine1();
Handle(GEOM_Function) aRef2 = aPI.GetLine2(); Handle(GEOM_Function) aRef2 = aPI.GetLine2();

View File

@ -106,7 +106,8 @@
#define POINT_CURVE_PAR 3 #define POINT_CURVE_PAR 3
#define POINT_LINES_INTERSECTION 4 #define POINT_LINES_INTERSECTION 4
#define POINT_SURFACE_PAR 5 #define POINT_SURFACE_PAR 5
//#define POINT_FACE_PAR 5 #define POINT_CURVE_COORD 6
#define POINT_SURFACE_COORD 7
#define VECTOR_TWO_PNT 1 #define VECTOR_TWO_PNT 1
#define VECTOR_DX_DY_DZ 2 #define VECTOR_DX_DY_DZ 2