\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
point is located in the middle of the edge.
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnCurve(Edge,Parameter).</em>
\n <b>Arguments:</b> Name + 1 edge + 1 Parameter defining the
position of the point on the given edge.
-
\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 <b>TUI Command:</b> <em>geompy.MakePointOnLinesIntersection(myLine1,myLine2).</em>
\image html point4.png
<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
point is located in the middle of the face.
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurface(myFace,myUParameter,myVParameter).</em>
\n <b>Arguments:</b> Name + 1 face + 2 Parameters defining the
position of the point on the given face.
-
+[*] 3D co-ordinate of point to project on the given face.
\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>
py = geompy.MakeVertex(0., 100., 0.)
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)
+# create vertex by parameter
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
id_p0 = geompy.addToStudy(p0, "Vertex 0")
id_py = geompy.addToStudy(py, "Vertex Y")
id_pz = geompy.addToStudy(pz, "Vertex Z")
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
gg.createAndDisplayGO(id_p0)
\until MakeVertexOnCurve
+\until MakeVertexOnCurveByCoord
+
+\until MakeVertexOnSurface
+
+\until MakeVertexOnSurfaceByCoord
+
\anchor swig_MakeVertexOnLinesIntersection
\until p_on_l1l2
GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve,
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
* given surface.
in double theUParameter,
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.
* \param theRefLine1, theRefLine2 The referenced lines.
#include <GEOMImpl_Types.hxx>
#include <QApplication>
+#include <QButtonGroup>
+#include <QHBoxLayout>
#include <QLabel>
+#include <QRadioButton>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#include <TColStd_IndexedMapOfInteger.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()
// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
mainFrame()->RadioButton5->show();
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->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
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->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
GroupOnCurve->PushButton1->setIcon( image2 );
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->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
GroupLineIntersection->PushButton2->setIcon( image2 );
GroupLineIntersection->LineEdit2->setEnabled(false);
- myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
+ myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
myX = new QLineEdit( myCoordGrp );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
+ layout->addWidget( paramGrp );
layout->addWidget( GroupXYZ );
layout->addWidget( GroupOnCurve );
layout->addWidget( GroupOnSurface );
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->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
globalSelection(); // close local contexts, if any
switch ( constructorId ) {
- case 0:
+ case POINT_XYZ:
{
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myCoordGrp->hide();
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->show();
break;
}
- case 1:
+ case POINT_REF:
{
myEditCurrentArgument = GroupRefPoint->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupRefPoint->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
myCoordGrp->show();
break;
}
- case 2:
+ case POINT_EDGE:
{
myEditCurrentArgument = GroupOnCurve->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupOnCurve->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
- GroupXYZ->hide();
GroupRefPoint->hide();
GroupLineIntersection->hide();
GroupOnSurface->hide();
+ myParamCoord->button( PARAM_VALUE )->show();
+ myParamCoord->button( COORD_VALUE )->show();
GroupOnCurve->show();
-
myCoordGrp->show();
+
+ updateParamCoord( false );
break;
}
- case 3:
+ case POINT_INTINT:
{
myEditCurrentArgument = GroupLineIntersection->LineEdit1;
GroupLineIntersection->LineEdit1->setText( "" );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->show();
break;
}
- case 4:
+ case POINT_SURF:
{
myEditCurrentArgument = GroupOnSurface->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupOnSurface->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
- GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
+ myParamCoord->button( PARAM_VALUE )->show();
+ myParamCoord->button( COORD_VALUE )->show();
GroupOnSurface->show();
-
myCoordGrp->show();
+
+ updateParamCoord( false );
break;
}
}
{
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( "" );
myX->setText( "" );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- if ( id == 2 || id == 3 )
+ if ( id == POINT_EDGE || id == POINT_INTINT )
aNeedType = TopAbs_EDGE;
- else if ( id == 4 )
+ else if ( id == POINT_SURF )
aNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap;
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
- if ( id == 0 ) return;
+ if ( id == POINT_XYZ ) return;
}
}
}
if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
return;
- if ( id == 0 ) {
+ if ( id == POINT_XYZ ) {
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
}
- else if ( id == 1 ) {
+ else if ( id == POINT_REF ) {
myRefPoint = aSelectedObject;
GroupRefPoint->LineEdit1->setText( aName );
}
- else if ( id == 2 ) {
+ else if ( id == POINT_EDGE ) {
myEdge = aSelectedObject;
GroupOnCurve->LineEdit1->setText( aName );
}
- else if ( id == 3 ) {
+ else if ( id == POINT_INTINT ) {
myEditCurrentArgument->setText( aName );
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
GroupLineIntersection->PushButton1->click();
}
}
- else if ( id == 4 )
+ else if ( id == POINT_SURF )
{
myFace = aSelectedObject;
GroupOnSurface->LineEdit1->setText( aName );
//=================================================================================
void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
{
- if ( getConstructorId() == 0 ) {
+ if ( getConstructorId() == POINT_XYZ ) {
GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
bool BasicGUI_PointDlg::isValid( QString& msg )
{
const int id = getConstructorId();
- if ( id == 0 ) {
+ if ( id == POINT_XYZ ) {
bool ok = true;
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 ok;
}
- else if ( id == 1 ) {
+ else if ( id == POINT_REF ) {
bool ok = true;
ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
return !myRefPoint->_is_nil() && ok;
}
- else if ( id == 2 ) {
- bool ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
+ else if ( id == POINT_EDGE ) {
+ 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;
}
- else if ( id == 3 )
+ else if ( id == POINT_INTINT )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
- else if ( id == 4 ) {
+ else if ( id == POINT_SURF ) {
bool ok = true;
- ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ ok = GroupOnSurface->SpinBox_DX->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;
}
QStringList aParameters;
switch ( getConstructorId() ) {
- case 0 :
+ case POINT_XYZ :
{
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
res = true;
break;
}
- case 1 :
+ case POINT_REF :
{
double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value();
res = true;
break;
}
- case 2 :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnCurve( myEdge, getParameter() );
- aParameters<<GroupOnCurve->SpinBox_DX->text();
- res = true;
- break;
- case 3 :
+ case POINT_EDGE :
+ {
+ 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();
+ } 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;
+ break;
+ }
+ case POINT_INTINT :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointOnLinesIntersection( myLine1, myLine2 );
res = true;
break;
- case 4 :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnSurface( myFace, getUParameter(), getVParameter() );
- aParameters<<GroupOnSurface->SpinBox_DX->text();
- aParameters<<GroupOnSurface->SpinBox_DY->text();
- res = true;
- break;
+ case POINT_SURF :
+ {
+ 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_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;
+ break;
+ }
}
- if(!anObj->_is_nil() && !IsPreview() && (getConstructorId()==0 ||
- getConstructorId() == 1 ||
- getConstructorId() == 2 ||
- getConstructorId() == 4) ) {
+ const int id = getConstructorId();
+ if(!anObj->_is_nil() && !IsPreview() && (id == POINT_XYZ ||
+ id == POINT_REF ||
+ id == POINT_EDGE ||
+ id == POINT_SURF) ) {
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
}
- if ( getConstructorId() == 1 || getConstructorId() == 2 ||
- getConstructorId() == 4 ) {
+ if ( id == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) {
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
aShape.ShapeType() == TopAbs_VERTEX ) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
- case 0:
+ case POINT_XYZ:
break;
- case 1:
+ case POINT_REF:
objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
break;
- case 2:
+ case POINT_EDGE:
objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
break;
- case 3:
+ case POINT_INTINT:
objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
break;
- case 4:
+ case POINT_SURF:
objMap[GroupOnSurface->LineEdit1->text()] = myFace;
break;
}
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() );
+ }
+}
class QLineEdit;
class QGroupBox;
+class QButtonGroup;
class gp_Pnt;
double getParameter() const;
double getUParameter() const;
double getVParameter() const;
+ void updateParamCoord(bool theIsUpdate);
private:
GEOM::GEOM_Object_var myEdge;
QLineEdit* myX;
QLineEdit* myY;
QLineEdit* myZ;
+ QButtonGroup* myParamCoord;
private slots:
void ClickOnOk();
void ConstructorsClicked( int );
void ValueChangedInSpinBox( double );
void SetDoubleSpinBoxStep( double );
+ void ClickParamCoord();
};
#endif // BASICGUI_POINTDLG_H
<source>GEOM_COORDINATES</source>
<translation>Coordinates</translation>
</message>
+ <message>
+ <source>GEOM_COORDINATES_RES</source>
+ <translation>Result coordinates</translation>
+ </message>
<message>
<source>GEOM_CREATE_COPY</source>
<translation>Create a copy</translation>
<translation>Parameters</translation>
</message>
<message>
- <source>GEOM_PARAM_POINT</source>
- <translation>Parametric point</translation>
+ <source>GEOM_POINT_ON_EDGE</source>
+ <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>
<source>GEOM_PARTITION</source>
<source>GEOM_COORDINATES</source>
<translation>Coordonnes</translation>
</message>
+ <message>
+ <source>GEOM_COORDINATES_RES</source>
+ <translation>Resultats coordonnes</translation>
+ </message>
<message>
<source>GEOM_CREATE_COPY</source>
<translation>Create a copy</translation>
<translation>Paramtre :</translation>
</message>
<message>
- <source>GEOM_PARAM_POINT</source>
- <translation>Point paramtrique</translation>
+ <source>GEOM_POINT_ON_EDGE</source>
+ <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>
<source>GEOM_PARTITION</source>
//=============================================================================
/*!
- * MakePointOnCurve
+ * makePointOnGeom
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
- (Handle(GEOM_Object) theCurve, double theParameter)
+Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
+ (Handle(GEOM_Object) theGeomObj,
+ double theParam1,
+ double theParam2,
+ double theParam3,
+ const PointLocation theLocation)
{
SetErrorCode(KO);
- if (theCurve.IsNull()) return NULL;
+ if (theGeomObj.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_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
if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
GEOMImpl_IPoint aPI (aFunction);
- Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
+ Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
if (aRefFunction.IsNull()) return NULL;
- aPI.SetCurve(aRefFunction);
- aPI.SetParameter(theParameter);
-
+ switch( theLocation )
+ {
+ case PointOn_CurveByParam:
+ aPI.SetCurve(aRefFunction);
+ 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
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
- << theCurve << ", " << theParameter << ")";
+ switch( theLocation )
+ {
+ case PointOn_CurveByParam:
+ GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
+ << 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);
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);
+}
//=============================================================================
/*!
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
- (Handle(GEOM_Object) theSurface, double theUParameter, double theVParameter)
+ (Handle(GEOM_Object) theSurface,
+ double theUParameter,
+ double theVParameter)
{
- SetErrorCode(KO);
-
- 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
- << ", " << theVParameter << ")";
+ return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
+}
- SetErrorCode(OK);
- return aPoint;
+//=============================================================================
+/*!
+ * MakePointOnSurfaceByCoord
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
+ (Handle(GEOM_Object) theSurface,
+ double theXParam,
+ double theYParam,
+ double theZParam)
+{
+ return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
}
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
- double theParamU,
- double theParamV,
- double theSize)
+ double theParamU,
+ double theParamV,
+ double theSize)
{
SetErrorCode(KO);
double theX, double theY, double theZ);
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
(Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2);
double theUParameter,
double theVParameter);
+ Standard_EXPORT Handle(GEOM_Object) MakePointOnSurfaceByCoord (Handle(GEOM_Object) theSurface,
+ double theXParam,
+ double theYParam,
+ double theZParam);
+
// Vector
Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ);
Handle(GEOM_Object) thePnt2);
Standard_EXPORT Handle(GEOM_Object) MakeTangentOnCurve(const Handle(GEOM_Object)& theCurve,
- double theParameter);
+ double theParameter);
// Line
Standard_EXPORT Handle(GEOM_Object) MakeLineTwoPnt (Handle(GEOM_Object) thePnt1,
Standard_EXPORT Handle(GEOM_Object) MakePlane2Vec (Handle(GEOM_Object) theVec1,
Handle(GEOM_Object) theVec2,
- double theSize);
-
+ double theSize);
+
Standard_EXPORT Handle(GEOM_Object) MakePlaneLCS (Handle(GEOM_Object) theFace, double theSize, int theOrientation);
// Marker
double theYDX, double theYDY, double theYDZ);
Standard_EXPORT Handle(GEOM_Object) MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
- double theParamU,
- double theParamV,
- double theSize);
-
+ double theParamU,
+ double theParamV,
+ 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
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Precision.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
aP = aFP + (aLP - aFP) * aPI.GetParameter();
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) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
Standard_Real V = V1 + (V2-V1) * aPI.GetParameter2();
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) {
Handle(GEOM_Function) aRef1 = aPI.GetLine1();
Handle(GEOM_Function) aRef2 = aPI.GetLine2();
#define POINT_CURVE_PAR 3
#define POINT_LINES_INTERSECTION 4
#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_DX_DY_DZ 2