diff --git a/doc/salome/gui/GEOM/images/edge1.png b/doc/salome/gui/GEOM/images/edge1.png index 03840b25e..1ef12aecb 100644 Binary files a/doc/salome/gui/GEOM/images/edge1.png and b/doc/salome/gui/GEOM/images/edge1.png differ diff --git a/doc/salome/gui/GEOM/images/edge2.png b/doc/salome/gui/GEOM/images/edge2.png index b17336e06..273ce86bc 100644 Binary files a/doc/salome/gui/GEOM/images/edge2.png and b/doc/salome/gui/GEOM/images/edge2.png differ diff --git a/doc/salome/gui/GEOM/images/edge3.png b/doc/salome/gui/GEOM/images/edge3.png new file mode 100644 index 000000000..d234053ed Binary files /dev/null and b/doc/salome/gui/GEOM/images/edge3.png differ diff --git a/doc/salome/gui/GEOM/images/point3.png b/doc/salome/gui/GEOM/images/point3.png index 8972d735f..8b4daecc1 100755 Binary files a/doc/salome/gui/GEOM/images/point3.png and b/doc/salome/gui/GEOM/images/point3.png differ diff --git a/doc/salome/gui/GEOM/images/point3_2.png b/doc/salome/gui/GEOM/images/point3_2.png index 82ec677fe..8e7f3a127 100644 Binary files a/doc/salome/gui/GEOM/images/point3_2.png and b/doc/salome/gui/GEOM/images/point3_2.png differ diff --git a/doc/salome/gui/GEOM/images/point3_3.png b/doc/salome/gui/GEOM/images/point3_3.png index 823d34ca5..d4f2c9adb 100644 Binary files a/doc/salome/gui/GEOM/images/point3_3.png and b/doc/salome/gui/GEOM/images/point3_3.png differ diff --git a/doc/salome/gui/GEOM/input/creating_edge.doc b/doc/salome/gui/GEOM/input/creating_edge.doc index ffbfa69de..ce4f7b8b0 100644 --- a/doc/salome/gui/GEOM/input/creating_edge.doc +++ b/doc/salome/gui/GEOM/input/creating_edge.doc @@ -5,10 +5,10 @@ To create an \b Edge, in the Main Menu select New Entity > Build > Edge -There are two ways to create an edge. In both cases the \b Result +There are three ways to create an edge. In all cases the \b Result will be a \b GEOM_Object (EDGE). -Firstly, you can create an \b Edge by specifying two points (\b Point1 and +Firstly, you can create a linear \b Edge by specifying two points (\b Point1 and \b Point2), which are the first and the last vertices of the edge. TUI Command: geompy.MakeEdge(Vertex1, Vertex2)
@@ -41,6 +41,20 @@ the connection points (sharp bend) is not processed. \image html edge2.png "Create edge from wire" +The third case allows building edges of desired length on any existing +curve (selected existing edge). Start Point parameter is optional. +Any point can be selected for it, the new edge will begin at the end +of initial edge, close to the selected point. Length can exceed +the initial edge's length or be negative to extrapolate existing edge +along its curve (except bezier and b-spline curves). + +TUI Command: geompy.MakeEdgeOnCurveByLength(Edge, Length, StartPoint = None)
+Arguments: Name + 1 edge + Length + 1 Vertex +(StartPoint parameter is optional, it allows switching from one end of +initial edge to another. Length can exceed the initial edge's length or be negative). + +\image html edge3.png "Create edge on curve" + Example: \image html edgesn.png "Edge" diff --git a/doc/salome/gui/GEOM/input/creating_point.doc b/doc/salome/gui/GEOM/input/creating_point.doc index 295e3ede1..7b3e4cba9 100644 --- a/doc/salome/gui/GEOM/input/creating_point.doc +++ b/doc/salome/gui/GEOM/input/creating_point.doc @@ -34,11 +34,14 @@ position of the point on the given edge. \image html point3.png Alternatively, it is possible to define the point by \b Edge and \b Length, -the given length must not exceed the length of the edge. The orientation of the edge can be reversed. -\n TUI Command: geompy.MakeVertexOnCurveByLength(Edge,Length,Reverse). -\n Arguments: Name + 1 edge + 1 Length defining the -position of the point on the given edge + 1 Reverse flag defining the direction for the -calculation of the length (False = forward, True = reversed). +the given length can exceed the length of the edge or be negative +(except bezier and b-spline curves). The orientation of the edge can +be reversed by the \b StartPoint selection. +\n TUI Command: geompy.MakeVertexOnCurveByLength(Edge,Length,StartPoint=None). +\n Arguments: Name + 1 edge + 1 Length defining the position +of the point on the given edge + 1 Point defining the direction for +the calculation of the length (if not defined, the first vertex of +Edge is used, else the vertex of Edge closest to StartPoint is used). \image html point3_3.png It is also possible to define 3D coordinates of the point diff --git a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc index 0e8861511..1be354d79 100644 --- a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc @@ -46,6 +46,22 @@ id_edge = geompy.addToStudy(edge,"Edge_2") # display an edge gg.createAndDisplayGO(id_edge) +# +# create edge from existing curve and a length +# + +# create a circle +c = geompy.MakeCircle(None, None, 100) + +# create an edge of length 25.0 from the circle +edge = geompy.MakeEdgeOnCurveByLength(c, 25.0) + +# add object in the study +id_edge = geompy.addToStudy(edge,"Edge_3") + +# display an edge +gg.createAndDisplayGO(id_edge) + \endcode \anchor tui_creation_wire diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 4e8d98733..006cf9b45 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -428,13 +428,15 @@ module GEOM /*! * Create a point, corresponding to the given length on the given curve. * \param theRefCurve The referenced curve. - * \param theLength Length on the referenced curve. - * \param theReverse Direction for the calculation of the length (false = forward or true = reversed). + * \param theLength Length on the referenced curve. It can be negative. + * \param theStartPoint Any vertex close to one of edge's + * ends to select start point among them. + * If NULL, fist vertex is used. * \return New GEOM_Object, containing the created point. */ GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve, - in double theLength, - in boolean theReverse); + in double theLength, + in GEOM_Object theStartPoint); /*! * Create a point on the given curve, projecting given point @@ -1379,6 +1381,20 @@ module GEOM */ GEOM_Object MakeEdge (in GEOM_Object thePnt1, in GEOM_Object thePnt2); + /*! + * Create an edge on another edge, corresponding to the given length on the given edge. + * \param theRefCurve The referenced edge. + * \param theLength Length on the referenced edge. It can be + * negative for extrapolation on base curve. + * \param theStartPoint Any vertex close to one of edge's + * ends to select start point among them. + * If NULL, fist vertex is used. + * \return New GEOM_Object, containing the created edge. + */ + GEOM_Object MakeEdgeOnCurveByLength (in GEOM_Object theRefCurve, + in double theLength, + in GEOM_Object theStartPoint); + /*! * Create an edge from specified wire. * \param theWire source Wire. @@ -3158,6 +3174,13 @@ module GEOM boolean CheckShapeWithGeometry (in GEOM_Object theShape, out string theDescription); + /*! + * Check if the given shape can be an argument for MakeSolid operation + * \param theShape Shape to be described. + * \return Empty string if a solid can be made on this shape, error code otherwise. + */ + string IsGoodForSolid (in GEOM_Object theShape); + /*! * Obtain description of the given shape * \param theShape Shape to be described. @@ -3193,6 +3216,13 @@ module GEOM */ double GetAngle (in GEOM_Object theShape1, in GEOM_Object theShape2); + /*! + * Get angle between the given vectors. + * \param theShape1,theShape2 Vectors to find angle between. + * \return Value of the angle between the given vectors. + */ + double GetAngleBtwVectors (in GEOM_Object theShape1, in GEOM_Object theShape2); + /*! * Get point coordinates */ diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 3db909adf..bef0ecdf4 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -65,13 +65,16 @@ module GEOM //-----------------------------------------------------------// GEOM_Object MakePointXYZ (in double theX, in double theY, - in double theZ) ; + in double theZ); GEOM_Object MakePointWithReference (in GEOM_Object theReference, in double theX, in double theY, - in double theZ) ; + in double theZ); GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve, - in double theParameter) ; + in double theParameter); + GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve, + in double theLength, + in GEOM_Object theStartPoint); GEOM_Object MakeTangentOnCurve (in GEOM_Object theRefCurve, in double theParameter); @@ -368,6 +371,9 @@ module GEOM //-----------------------------------------------------------// GEOM_Object MakeEdge (in GEOM_Object thePnt1, in GEOM_Object thePnt2) ; + GEOM_Object MakeEdgeOnCurveByLength (in GEOM_Object theRefCurve, + in double theLength, + in GEOM_Object theStartPoint); GEOM_Object MakeWire (in GEOM_List theEdgesAndWires, in double theTolerance) ; GEOM_Object MakeFace (in GEOM_Object theWire, diff --git a/resources/Makefile.am b/resources/Makefile.am index 02d6e15bb..57529e357 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -47,7 +47,8 @@ box2points.png \ boxdxyz.png \ build_compound.png \ build_edge.png \ -build_edge_wire.png \ +build_edge_wire.png \ +build_edge_curve.png \ build_face.png \ build_shell.png \ build_solid.png \ diff --git a/resources/build_edge_curve.png b/resources/build_edge_curve.png new file mode 100644 index 000000000..e87abea5c Binary files /dev/null and b/resources/build_edge_curve.png differ diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 2b364705c..78fdec2b7 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_PointDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #include "BasicGUI_PointDlg.h" #include @@ -77,131 +76,132 @@ enum { SelectEdge, SelectWire }; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent, - bool modal, Qt::WindowFlags fl ) - : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ), - myBusy ( false ) +BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), + myBusy (false) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) ); - QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) ); - QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) ); - QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) ); - QPixmap image6( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_LINE" ) ) ); - QPixmap image7( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_WIRE" ) ) ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT"))); + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_EDGE"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_REF"))); + QPixmap image4 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_LINES"))); + QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_FACE"))); + QPixmap image6 (aResMgr->loadPixmap("GEOM", tr("ICO_LINE"))); + QPixmap image7 (aResMgr->loadPixmap("GEOM", tr("ICO_WIRE"))); - setWindowTitle( tr( "GEOM_POINT_TITLE" ) ); + setWindowTitle(tr("GEOM_POINT_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image3 ); - mainFrame()->RadioButton3->setIcon( image1 ); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_POINTS")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setIcon(image3); + mainFrame()->RadioButton3->setIcon(image1); mainFrame()->RadioButton4->show(); - mainFrame()->RadioButton4->setIcon( image4 ); + mainFrame()->RadioButton4->setIcon(image4); mainFrame()->RadioButton5->show(); - mainFrame()->RadioButton5->setIcon( image5 ); + mainFrame()->RadioButton5->setIcon(image5); - myParamGroup = new QGroupBox( centralWidget() ); - myParamCoord = new QButtonGroup( myParamGroup ); - QHBoxLayout* boxLayout = new QHBoxLayout( myParamGroup ); - boxLayout->setMargin( MARGIN ); boxLayout->setSpacing( SPACING ); - QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), myParamGroup ); - myParamCoord->addButton( btn, PARAM_VALUE ); - boxLayout->addWidget( btn ); - btn = new QRadioButton( tr( "GEOM_LENGTH_VALUE" ), myParamGroup ); - myParamCoord->addButton( btn, LENGTH_VALUE ); - boxLayout->addWidget( btn ); - btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup ); - myParamCoord->addButton( btn, COORD_VALUE ); - boxLayout->addWidget( btn ); - myParamCoord->setExclusive( true ); - myParamCoord->button( PARAM_VALUE )->setChecked( true ); + myParamGroup = new QGroupBox(centralWidget()); + myParamCoord = new QButtonGroup(myParamGroup); + QHBoxLayout* boxLayout = new QHBoxLayout(myParamGroup); + boxLayout->setMargin(MARGIN); boxLayout->setSpacing(SPACING); + QRadioButton* btn = new QRadioButton(tr("GEOM_PARAM_VALUE"), myParamGroup); + myParamCoord->addButton(btn, PARAM_VALUE); + boxLayout->addWidget(btn); + btn = new QRadioButton(tr("GEOM_LENGTH_VALUE"), myParamGroup); + myParamCoord->addButton(btn, LENGTH_VALUE); + boxLayout->addWidget(btn); + btn = new QRadioButton(tr("GEOM_COORD_VALUE"), myParamGroup); + myParamCoord->addButton(btn, COORD_VALUE); + boxLayout->addWidget(btn); + 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->TextLabel2->setText( tr( "GEOM_Y" ) ); - GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) ); + GroupXYZ = new DlgRef_3Spin(centralWidget()); + GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES")); + GroupXYZ->TextLabel1->setText(tr("GEOM_X")); + GroupXYZ->TextLabel2->setText(tr("GEOM_Y")); + GroupXYZ->TextLabel3->setText(tr("GEOM_Z")); - GroupOnCurve = new DlgRef_1Sel1Spin1Check( centralWidget() ); - GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) ); - GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) ); - GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) ); - GroupOnCurve->CheckButton1->setText( tr( "GEOM_REVERSE" ) ); - GroupOnCurve->PushButton1->setIcon( image2 ); - + GroupOnCurve = new DlgRef_2Sel1Spin(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); - GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() ); - 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" ) ); - GroupOnSurface->PushButton1->setIcon( image2 ); + GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget()); + 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")); + GroupOnSurface->PushButton1->setIcon(image2); - GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() ); - GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) ); - GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) ); - GroupRefPoint->PushButton1->setIcon( image2 ); - GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) ); - GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) ); - GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) ); + GroupRefPoint = new DlgRef_1Sel3Spin(centralWidget()); + GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT")); + GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT")); + GroupRefPoint->PushButton1->setIcon(image2); + GroupRefPoint->TextLabel2->setText(tr("GEOM_DX")); + GroupRefPoint->TextLabel3->setText(tr("GEOM_DY")); + GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ")); /* popup menu for line intersect buttons */ myBtnPopup = new QMenu(this); - QIcon ico_line = QIcon( image6 ); - QIcon ico_wire = QIcon( image7 ); - myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = SelectEdge; - myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = SelectWire; + QIcon ico_line = QIcon(image6); + QIcon ico_wire = QIcon(image7); + myActions[myBtnPopup->addAction(ico_line, tr("GEOM_EDGE"))] = SelectEdge; + myActions[myBtnPopup->addAction(ico_wire, tr("GEOM_WIRE"))] = SelectWire; - GroupLineIntersection = new DlgRef_2Sel( centralWidget() ); - GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) ); - GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) ); - GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) ); - GroupLineIntersection->PushButton1->setIcon( image2 ); - GroupLineIntersection->PushButton1->setMenu( myBtnPopup ); - GroupLineIntersection->PushButton2->setIcon( image2 ); - GroupLineIntersection->PushButton2->setMenu( myBtnPopup ); + GroupLineIntersection = new DlgRef_2Sel(centralWidget()); + GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION")); + GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1")); + GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2")); + GroupLineIntersection->PushButton1->setIcon(image2); + GroupLineIntersection->PushButton1->setMenu(myBtnPopup); + GroupLineIntersection->PushButton2->setIcon(image2); + GroupLineIntersection->PushButton2->setMenu(myBtnPopup); GroupLineIntersection->LineEdit2->setEnabled(false); - 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 ); - myCoordGrpLayout->addWidget( myX, 0, 1 ); - myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 ); - myY = new QLineEdit( myCoordGrp ); - myCoordGrpLayout->addWidget( myY, 1, 1 ); - myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 ); - myZ = new QLineEdit( myCoordGrp ); - myCoordGrpLayout->addWidget( myZ, 2, 1 ); + 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); + myCoordGrpLayout->addWidget(myX, 0, 1); + myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Y"), myCoordGrp), 1, 0); + myY = new QLineEdit(myCoordGrp); + myCoordGrpLayout->addWidget(myY, 1, 1); + myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Z"), myCoordGrp), 2, 0); + myZ = new QLineEdit(myCoordGrp); + myCoordGrpLayout->addWidget(myZ, 2, 1); - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( myParamGroup ); - layout->addWidget( GroupXYZ ); - layout->addWidget( GroupOnCurve ); - layout->addWidget( GroupOnSurface ); - layout->addWidget( GroupRefPoint ); - layout->addWidget( GroupLineIntersection ); - layout->addWidget( myCoordGrp ); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(myParamGroup); + layout->addWidget(GroupXYZ); + layout->addWidget(GroupOnCurve); + layout->addWidget(GroupOnSurface); + layout->addWidget(GroupRefPoint); + layout->addWidget(GroupLineIntersection); + layout->addWidget(myCoordGrp); - myX->setReadOnly( true ); - myY->setReadOnly( true ); - myZ->setReadOnly( true ); + myX->setReadOnly(true); + myY->setReadOnly(true); + myZ->setReadOnly(true); - myX->setEnabled( false ); - myY->setEnabled( false ); - myZ->setEnabled( false ); + myX->setEnabled(false); + myY->setEnabled(false); + myZ->setEnabled(false); QPalette aPal = myX->palette(); - aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ); - myX->setPalette( aPal ); - myY->setPalette( aPal ); - myZ->setPalette( aPal ); + aPal.setColor(QPalette::Disabled, QPalette::Text, QColor(0, 0, 0)); + myX->setPalette(aPal); + myY->setPalette(aPal); + myZ->setPalette(aPal); - setHelpFileName( "create_point_page.html" ); + setHelpFileName("create_point_page.html"); Init(); } @@ -222,13 +222,14 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() //================================================================================= void BasicGUI_PointDlg::Init() { - GroupOnCurve->LineEdit1->setReadOnly( true ); - GroupOnSurface->LineEdit1->setReadOnly( true ); - GroupRefPoint->LineEdit1->setReadOnly( true ); - GroupLineIntersection->LineEdit1->setReadOnly( true ); - GroupLineIntersection->LineEdit2->setReadOnly( true ); - GroupLineIntersection->LineEdit1->setEnabled( true ); - GroupLineIntersection->LineEdit2->setEnabled( false ); + GroupOnCurve->LineEdit1->setReadOnly(true); + GroupOnCurve->LineEdit2->setReadOnly(true); + GroupOnSurface->LineEdit1->setReadOnly(true); + GroupRefPoint->LineEdit1->setReadOnly(true); + GroupLineIntersection->LineEdit1->setReadOnly(true); + GroupLineIntersection->LineEdit2->setReadOnly(true); + GroupLineIntersection->LineEdit1->setEnabled(true); + GroupLineIntersection->LineEdit2->setEnabled(false); myEdge.nullify(); myFace.nullify(); @@ -241,78 +242,77 @@ void BasicGUI_PointDlg::Init() /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); + double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes */ - initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); - GroupXYZ->SpinBox_DX->setValue( 0.0 ); - GroupXYZ->SpinBox_DY->setValue( 0.0 ); - GroupXYZ->SpinBox_DZ->setValue( 0.0 ); + initSpinBox(GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision"); + GroupXYZ->SpinBox_DX->setValue(0.0); + GroupXYZ->SpinBox_DY->setValue(0.0); + GroupXYZ->SpinBox_DZ->setValue(0.0); - initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); - GroupRefPoint->SpinBox_DX->setValue( 0.0 ); - GroupRefPoint->SpinBox_DY->setValue( 0.0 ); - GroupRefPoint->SpinBox_DZ->setValue( 0.0 ); + initSpinBox(GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision"); + GroupRefPoint->SpinBox_DX->setValue(0.0); + GroupRefPoint->SpinBox_DY->setValue(0.0); + GroupRefPoint->SpinBox_DZ->setValue(0.0); step = 0.1; - initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision" ); - GroupOnCurve->SpinBox_DX->setValue( 0.5 ); + initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision"); + GroupOnCurve->SpinBox_DX->setValue(0.5); - initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision" ); - GroupOnSurface->SpinBox_DX->setValue( 0.5 ); - initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision" ); - GroupOnSurface->SpinBox_DY->setValue( 0.5 ); + initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision"); + GroupOnSurface->SpinBox_DX->setValue(0.5); + initSpinBox(GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision"); + GroupOnSurface->SpinBox_DY->setValue(0.5); /* signals and slots connections */ - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) ); + connect(myParamCoord, SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int))); - connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); + connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->PushButton1, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->PushButton2, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument())); - connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), this, SLOT( onBtnPopup( QAction* ) ) ); + connect(myBtnPopup, SIGNAL(triggered(QAction*)), this, SLOT(onBtnPopup(QAction*))); - connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect( GroupOnCurve->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), - this, SLOT(SelectionIntoArgument() ) ); + initName(tr("GEOM_VERTEX")); - initName( tr( "GEOM_VERTEX" ) ); - - ConstructorsClicked( 0 ); + ConstructorsClicked(0); } //================================================================================= // function : SetDoubleSpinBoxStep() // purpose : Double spin box management //================================================================================= -void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step ) +void BasicGUI_PointDlg::SetDoubleSpinBoxStep(double step) { GroupOnCurve->SpinBox_DX->setSingleStep(step); GroupXYZ->SpinBox_DX->setSingleStep(step); @@ -330,12 +330,12 @@ void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step ) //================================================================================= void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) { - switch ( constructorId ) { + switch (constructorId) { case GEOM_POINT_XYZ: { globalSelection(); // close local contexts, if any myNeedType = TopAbs_VERTEX; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); GroupRefPoint->hide(); GroupOnCurve->hide(); @@ -350,10 +350,10 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) { globalSelection(); // close local contexts, if any myNeedType = TopAbs_VERTEX; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); myEditCurrentArgument = GroupRefPoint->LineEdit1; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myRefPoint.nullify(); GroupRefPoint->PushButton1->setDown(true); myParamGroup->hide(); @@ -369,34 +369,35 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) { globalSelection(); // close local contexts, if any myNeedType = TopAbs_EDGE; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); myEditCurrentArgument = GroupOnCurve->LineEdit1; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myEdge.nullify(); + myRefPoint.nullify(); GroupOnCurve->PushButton1->setDown(true); GroupRefPoint->hide(); GroupLineIntersection->hide(); GroupOnSurface->hide(); myParamGroup->show(); - myParamCoord->button( LENGTH_VALUE )->show(); - myParamCoord->button( PARAM_VALUE )->setChecked( true ); + myParamCoord->button(LENGTH_VALUE)->show(); + myParamCoord->button(PARAM_VALUE)->setChecked(true); GroupOnCurve->show(); myCoordGrp->show(); - updateParamCoord( false ); + updateParamCoord(false); break; } case GEOM_POINT_INTINT: { globalSelection(); // close local contexts, if any myNeedType = TopAbs_EDGE; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); myEditCurrentArgument = GroupLineIntersection->LineEdit1; - GroupLineIntersection->LineEdit1->setText( "" ); - GroupLineIntersection->LineEdit2->setText( "" ); - GroupLineIntersection->LineEdit1->setEnabled( true ); - GroupLineIntersection->LineEdit2->setEnabled( false ); + GroupLineIntersection->LineEdit1->setText(""); + GroupLineIntersection->LineEdit2->setText(""); + GroupLineIntersection->LineEdit1->setEnabled(true); + GroupLineIntersection->LineEdit2->setEnabled(false); myLine1.nullify(); myLine2.nullify(); GroupLineIntersection->PushButton1->setDown(true); @@ -414,58 +415,56 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) { globalSelection(); // close local contexts, if any myNeedType = TopAbs_FACE; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); myEditCurrentArgument = GroupOnSurface->LineEdit1; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myFace.nullify(); GroupOnSurface->PushButton1->setDown(true); GroupRefPoint->hide(); GroupOnCurve->hide(); GroupLineIntersection->hide(); myParamGroup->show(); - myParamCoord->button( LENGTH_VALUE )->hide(); - myParamCoord->button( PARAM_VALUE )->setChecked(true); + myParamCoord->button(LENGTH_VALUE)->hide(); + myParamCoord->button(PARAM_VALUE)->setChecked(true); GroupOnSurface->show(); myCoordGrp->show(); - updateParamCoord( false ); + updateParamCoord(false); break; } } - myX->setText( "" ); - myY->setText( "" ); - myZ->setText( "" ); + myX->setText(""); + myY->setText(""); + myZ->setText(""); QTimer::singleShot(50, this, SLOT(updateSize())); SelectionIntoArgument(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void BasicGUI_PointDlg::ClickOnOk() { - setIsApplyAndClose( true ); - if ( onAccept() ) + setIsApplyAndClose(true); + if (onAccept()) ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool BasicGUI_PointDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); return true; } @@ -479,70 +478,85 @@ void BasicGUI_PointDlg::SelectionIntoArgument() erasePreview(); const int id = getConstructorId(); - if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 ) + if ((id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF) + && myEditCurrentArgument != 0) { - myEditCurrentArgument->setText( "" ); - myX->setText( "" ); - myY->setText( "" ); - myZ->setText( "" ); - myRefPoint.nullify(); - myEdge.nullify(); + myEditCurrentArgument->setText(""); + myX->setText(""); + myY->setText(""); + myZ->setText(""); myFace.nullify(); - } else if ( id == GEOM_POINT_INTINT ) { - myEditCurrentArgument->setText( "" ); - if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) + if (myEditCurrentArgument == GroupOnCurve->LineEdit1) + myEdge.nullify(); + else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) + myRefPoint.nullify(); + } + else if (id == GEOM_POINT_INTINT) { + myEditCurrentArgument->setText(""); + if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) myLine1.nullify(); - else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) + else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) myLine2.nullify(); } - GEOM::GeomObjPtr aSelectedObject = getSelected( myNeedType ); + GEOM::GeomObjPtr aSelectedObject = getSelected(myNeedType); TopoDS_Shape aShape; - if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { - QString aName = GEOMBase::GetName( aSelectedObject.get() ); + if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) { + QString aName = GEOMBase::GetName(aSelectedObject.get()); myBusy = true; - if ( id == GEOM_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() ); + if (id == GEOM_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 == GEOM_POINT_REF ) { + else if (id == GEOM_POINT_REF) { myRefPoint = aSelectedObject; - GroupRefPoint->LineEdit1->setText( aName ); + GroupRefPoint->LineEdit1->setText(aName); } - else if ( id == GEOM_POINT_EDGE ) { - myEdge = aSelectedObject; - GroupOnCurve->LineEdit1->setText( aName ); - } - else if ( id == GEOM_POINT_INTINT ) { - myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) { - myLine1 = aSelectedObject; - if ( myLine1 && !myLine2 ) { - GroupLineIntersection->PushButton2->setMenu( 0 ); - GroupLineIntersection->PushButton2->click(); - GroupLineIntersection->PushButton2->setDown(true); - GroupLineIntersection->PushButton2->setMenu( myBtnPopup ); - } + else if (id == GEOM_POINT_EDGE) { + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument == GroupOnCurve->LineEdit1) { + myEdge = aSelectedObject; + if (myEdge && !myRefPoint) { + GroupOnCurve->PushButton2->click(); + } } - else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) { - myLine2 = aSelectedObject; - if ( myLine2 && !myLine1 ) { - GroupLineIntersection->PushButton1->setMenu( 0 ); - GroupLineIntersection->PushButton1->click(); - GroupLineIntersection->PushButton1->setDown(true); - GroupLineIntersection->PushButton1->setMenu( myBtnPopup ); - } + else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) { + myRefPoint = aSelectedObject; + if (myRefPoint && !myEdge) { + GroupOnCurve->PushButton1->click(); + } } } - else if ( id == GEOM_POINT_SURF ) { + else if (id == GEOM_POINT_INTINT) { + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) { + myLine1 = aSelectedObject; + if (myLine1 && !myLine2) { + GroupLineIntersection->PushButton2->setMenu(0); + GroupLineIntersection->PushButton2->click(); + GroupLineIntersection->PushButton2->setDown(true); + GroupLineIntersection->PushButton2->setMenu(myBtnPopup); + } + } + else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) { + myLine2 = aSelectedObject; + if (myLine2 && !myLine1) { + GroupLineIntersection->PushButton1->setMenu(0); + GroupLineIntersection->PushButton1->click(); + GroupLineIntersection->PushButton1->setDown(true); + GroupLineIntersection->PushButton1->setMenu(myBtnPopup); + } + } + } + else if (id == GEOM_POINT_SURF) { myFace = aSelectedObject; - GroupOnSurface->LineEdit1->setText( aName ); + GroupOnSurface->LineEdit1->setText(aName); } myBusy = false; } - + displayPreview(true); } @@ -555,43 +569,57 @@ void BasicGUI_PointDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if ( send == GroupRefPoint->PushButton1 ) { + if (send == GroupRefPoint->PushButton1) { GroupRefPoint->LineEdit1->setFocus(); myEditCurrentArgument = GroupRefPoint->LineEdit1; globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); } - else if ( send == GroupOnCurve->PushButton1 ) { + else if (send == GroupOnCurve->PushButton1) { GroupOnCurve->LineEdit1->setFocus(); myEditCurrentArgument = GroupOnCurve->LineEdit1; globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + myNeedType = TopAbs_EDGE; + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); + GroupOnCurve->PushButton2->setDown(false); + GroupOnCurve->LineEdit1->setEnabled(true); + GroupOnCurve->LineEdit2->setEnabled(false); } - else if ( send == GroupOnSurface->PushButton1 ) + else if (send == GroupOnCurve->PushButton2) { + GroupOnCurve->LineEdit2->setFocus(); + myEditCurrentArgument = GroupOnCurve->LineEdit2; + globalSelection(); // close local contexts, if any + myNeedType = TopAbs_VERTEX; + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); + GroupOnCurve->PushButton1->setDown(false); + GroupOnCurve->LineEdit2->setEnabled(true); + GroupOnCurve->LineEdit1->setEnabled(false); + } + else if (send == GroupOnSurface->PushButton1) { GroupOnSurface->LineEdit1->setFocus(); myEditCurrentArgument = GroupOnSurface->LineEdit1; globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); } - else if ( send == GroupLineIntersection->PushButton1 ) { + else if (send == GroupLineIntersection->PushButton1) { GroupLineIntersection->LineEdit1->setFocus(); myEditCurrentArgument = GroupLineIntersection->LineEdit1; - GroupLineIntersection->PushButton2->setDown( false ); + GroupLineIntersection->PushButton2->setDown(false); GroupLineIntersection->LineEdit1->setEnabled(true); GroupLineIntersection->LineEdit2->setEnabled(false); } - else if ( send == GroupLineIntersection->PushButton2 ) { + else if (send == GroupLineIntersection->PushButton2) { GroupLineIntersection->LineEdit2->setFocus(); myEditCurrentArgument = GroupLineIntersection->LineEdit2; - GroupLineIntersection->PushButton1->setDown( false ); + GroupLineIntersection->PushButton1->setDown(false); GroupLineIntersection->LineEdit1->setEnabled(false); GroupLineIntersection->LineEdit2->setEnabled(true); } send->setDown(true); - if ( ( send == GroupLineIntersection->PushButton1 || - send == GroupLineIntersection->PushButton2 ) && !myBusy ) + if ((send == GroupLineIntersection->PushButton1 || + send == GroupLineIntersection->PushButton2) && !myBusy) SelectionIntoArgument(); } @@ -600,9 +628,9 @@ void BasicGUI_PointDlg::SetEditCurrentArgument() // function : enterEvent() // purpose : to reactivate this dialog box when mouse enter onto the window //================================================================================= -void BasicGUI_PointDlg::enterEvent( QEvent* ) +void BasicGUI_PointDlg::enterEvent(QEvent*) { - if ( !mainFrame()->GroupConstructors->isEnabled() ) + if (!mainFrame()->GroupConstructors->isEnabled()) ActivateThisDialog(); } @@ -611,14 +639,14 @@ void BasicGUI_PointDlg::enterEvent( QEvent* ) // function : ActivateThisDialog() // purpose : //================================================================================= -void BasicGUI_PointDlg::ActivateThisDialog( ) +void BasicGUI_PointDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } @@ -628,7 +656,7 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) //================================================================================= void BasicGUI_PointDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); + // myGeomGUI->SetState(-1); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -646,7 +674,7 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue) // function : CheckBoxClicked() // purpose : Check Boxes Management //================================================================================= -void BasicGUI_PointDlg::CheckBoxClicked( int State ) +void BasicGUI_PointDlg::CheckBoxClicked(int State) { displayPreview(true); } @@ -686,12 +714,12 @@ double BasicGUI_PointDlg::getVParameter() const // function : OnPointSelected // purpose : //================================================================================= -void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt ) +void BasicGUI_PointDlg::OnPointSelected(const gp_Pnt& thePnt) { - if ( getConstructorId() == GEOM_POINT_XYZ ) { - GroupXYZ->SpinBox_DX->setValue( thePnt.X() ); - GroupXYZ->SpinBox_DY->setValue( thePnt.Y() ); - GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() ); + if (getConstructorId() == GEOM_POINT_XYZ) { + GroupXYZ->SpinBox_DX->setValue(thePnt.X()); + GroupXYZ->SpinBox_DY->setValue(thePnt.Y()); + GroupXYZ->SpinBox_DZ->setValue(thePnt.Z()); displayPreview(true); } @@ -703,48 +731,48 @@ void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt ) //================================================================================= GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation() { - return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); + return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool BasicGUI_PointDlg::isValid( QString& msg ) +bool BasicGUI_PointDlg::isValid(QString& msg) { bool ok = false; - switch ( getConstructorId() ) { + switch (getConstructorId()) { case GEOM_POINT_XYZ : - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview()); break; case GEOM_POINT_REF: - ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && - GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && + ok = GroupRefPoint->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupRefPoint->SpinBox_DY->isValid(msg, !IsPreview()) && + GroupRefPoint->SpinBox_DZ->isValid(msg, !IsPreview()) && myRefPoint; break; case GEOM_POINT_EDGE: - if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE ) - ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() ); + if (myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE) + ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview()); else - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview()); ok = myEdge && ok; break; case GEOM_POINT_INTINT: ok = myLine1 && myLine2; break; case GEOM_POINT_SURF: - if ( myParamCoord->checkedId() == PARAM_VALUE ) - ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ); + if (myParamCoord->checkedId() == PARAM_VALUE) + ok = GroupOnSurface->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupOnSurface->SpinBox_DY->isValid(msg, !IsPreview()); else - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && - GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) && + GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview()); ok = myFace && ok; break; default: @@ -757,16 +785,16 @@ bool BasicGUI_PointDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool BasicGUI_PointDlg::execute( ObjectList& objects ) +bool BasicGUI_PointDlg::execute(ObjectList& objects) { bool res = false; GEOM::GEOM_Object_var anObj; QStringList aParameters; - GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() ); + GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow(getOperation()); - switch ( getConstructorId() ) { + switch (getConstructorId()) { case GEOM_POINT_XYZ : { double x = GroupXYZ->SpinBox_DX->value(); @@ -777,7 +805,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DZ->text(); - anObj = anOper->MakePointXYZ( x, y, z ); + anObj = anOper->MakePointXYZ(x, y, z); res = true; break; } @@ -791,24 +819,21 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupRefPoint->SpinBox_DY->text(); aParameters << GroupRefPoint->SpinBox_DZ->text(); - anObj = anOper->MakePointWithReference( myRefPoint.get(), dx, dy, dz ); + anObj = anOper->MakePointWithReference(myRefPoint.get(), dx, dy, dz); res = true; break; } case GEOM_POINT_EDGE : { - if ( myParamCoord->checkedId() == PARAM_VALUE ) { - anObj = anOper->MakePointOnCurve( myEdge.get(), getParameter() ); + if (myParamCoord->checkedId() == PARAM_VALUE) { + anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter()); aParameters<SpinBox_DX->text(); - } - else if ( myParamCoord->checkedId() == LENGTH_VALUE ) { - bool reversed = GroupOnCurve->CheckButton1->isChecked(); - anObj = anOper->MakePointOnCurveByLength( myEdge.get(), getParameter(), reversed ); - - aParameters<SpinBox_DX->text(); - aParameters<checkedId() == COORD_VALUE ) { + else if (myParamCoord->checkedId() == LENGTH_VALUE) { + anObj = anOper->MakePointOnCurveByLength(myEdge.get(), getParameter(), myRefPoint.get()); + aParameters<SpinBox_DX->text(); + } + else if (myParamCoord->checkedId() == COORD_VALUE) { double x = GroupXYZ->SpinBox_DX->value(); double y = GroupXYZ->SpinBox_DY->value(); double z = GroupXYZ->SpinBox_DZ->value(); @@ -817,26 +842,26 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DZ->text(); - anObj = anOper->MakePointOnCurveByCoord( myEdge.get(), x, y, z ); + anObj = anOper->MakePointOnCurveByCoord(myEdge.get(), x, y, z); } res = true; break; } case GEOM_POINT_INTINT : - anObj = anOper->MakePointOnLinesIntersection( myLine1.get(), myLine2.get() ); - if ( !anObj->_is_nil() ) { + anObj = anOper->MakePointOnLinesIntersection(myLine1.get(), myLine2.get()); + if (!anObj->_is_nil()) { QString aName = getNewObjectName(); - if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") ) - initName( tr( "GEOM_COMPOUND" ) ); - else if ( anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound")) - initName( tr( "GEOM_VERTEX" ) ); + if (anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex")) + initName(tr("GEOM_COMPOUND")); + else if (anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound")) + initName(tr("GEOM_VERTEX")); } res = true; break; case GEOM_POINT_SURF : { - if ( myParamCoord->checkedId() == PARAM_VALUE ) { - anObj = anOper->MakePointOnSurface( myFace.get(), getUParameter(), getVParameter() ); + if (myParamCoord->checkedId() == PARAM_VALUE) { + anObj = anOper->MakePointOnSurface(myFace.get(), getUParameter(), getVParameter()); aParameters<SpinBox_DX->text(); aParameters<SpinBox_DY->text(); } else { @@ -848,7 +873,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DZ->text(); - anObj = anOper->MakePointOnSurfaceByCoord( myFace.get(), x, y, z ); + anObj = anOper->MakePointOnSurfaceByCoord(myFace.get(), x, y, z); } res = true; break; @@ -859,30 +884,30 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ || id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || - id == GEOM_POINT_SURF) ) { + id == GEOM_POINT_SURF)) { anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } - if ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) { + if (id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF) { TopoDS_Shape aShape; - if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && - aShape.ShapeType() == TopAbs_VERTEX ) { - gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + if (GEOMBase::GetShape(anObj, aShape) && !aShape.IsNull() && + aShape.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 ); - myX->setText( DlgRef::PrintDoubleValue( aPnt.X(), aPrecision ) ); - myY->setText( DlgRef::PrintDoubleValue( aPnt.Y(), aPrecision ) ); - myZ->setText( DlgRef::PrintDoubleValue( aPnt.Z(), aPrecision ) ); + int aPrecision = resMgr->integerValue("Geometry", "length_precision", 6); + myX->setText(DlgRef::PrintDoubleValue(aPnt.X(), aPrecision)); + myY->setText(DlgRef::PrintDoubleValue(aPnt.Y(), aPrecision)); + myZ->setText(DlgRef::PrintDoubleValue(aPnt.Z(), aPrecision)); } else { - myX->setText( "" ); - myY->setText( "" ); - myZ->setText( "" ); + myX->setText(""); + myY->setText(""); + myZ->setText(""); } } - if ( !anObj->_is_nil() ) { - objects.push_back( anObj._retn() ); + if (!anObj->_is_nil()) { + objects.push_back(anObj._retn()); } return res; @@ -894,19 +919,19 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_PointDlg::addSubshapesToStudy() { - switch ( getConstructorId() ) { + switch (getConstructorId()) { case GEOM_POINT_REF: - GEOMBase::PublishSubObject( myRefPoint.get() ); + GEOMBase::PublishSubObject(myRefPoint.get()); break; case GEOM_POINT_EDGE: - GEOMBase::PublishSubObject( myEdge.get() ); + GEOMBase::PublishSubObject(myEdge.get()); break; case GEOM_POINT_INTINT: - GEOMBase::PublishSubObject( myLine1.get() ); - GEOMBase::PublishSubObject( myLine2.get() ); + GEOMBase::PublishSubObject(myLine1.get()); + GEOMBase::PublishSubObject(myLine2.get()); break; case GEOM_POINT_SURF: - GEOMBase::PublishSubObject( myFace.get() ); + GEOMBase::PublishSubObject(myFace.get()); break; default: break; @@ -917,9 +942,9 @@ void BasicGUI_PointDlg::addSubshapesToStudy() // function : ClickParamCoord() // purpose : //================================================================================= -void BasicGUI_PointDlg::ClickParamCoord( int id ) +void BasicGUI_PointDlg::ClickParamCoord(int id) { - updateParamCoord( true ); + updateParamCoord(true); displayPreview(true); } @@ -933,35 +958,36 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate) bool isLength = myParamCoord->checkedId() == LENGTH_VALUE; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); + double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); const int id = getConstructorId(); - if ( id == GEOM_POINT_EDGE ) { - GroupOnCurve->TextLabel2->setVisible( isParam || isLength ); - GroupOnCurve->SpinBox_DX->setVisible( isParam || isLength ); - if ( isParam ){ - initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision" ); - GroupOnCurve->SpinBox_DX->setValue( 0.5 ); - GroupOnCurve->TextLabel2->setText(tr( "GEOM_PARAMETER" )); - GroupOnCurve->CheckButton1->setVisible(false); + if (id == GEOM_POINT_EDGE) { + GroupOnCurve->TextLabel2->setVisible(isLength); + GroupOnCurve->PushButton2->setVisible(isLength); + GroupOnCurve->LineEdit2->setVisible(isLength); + GroupOnCurve->TextLabel3->setVisible(isParam || isLength); + GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength); + if (isParam){ + initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision"); + GroupOnCurve->SpinBox_DX->setValue(0.5); + GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER")); } - else if ( isLength ){ - initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, step, "length_precision" ); - GroupOnCurve->SpinBox_DX->setValue( 0.0 ); - GroupOnCurve->TextLabel2->setText(tr( "GEOM_LENGTH" )); - GroupOnCurve->CheckButton1->setVisible(true); + else if (isLength){ + initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); + GroupOnCurve->SpinBox_DX->setValue(0.0); + GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH")); } - } - else if ( id == GEOM_POINT_SURF ) { - GroupOnSurface->TextLabel2->setShown( isParam ); - GroupOnSurface->TextLabel3->setShown( isParam ); - GroupOnSurface->SpinBox_DX->setShown( isParam ); - GroupOnSurface->SpinBox_DY->setShown( isParam ); } - - GroupXYZ->setShown( !isParam && !isLength ); + else if (id == GEOM_POINT_SURF) { + GroupOnSurface->TextLabel2->setShown(isParam); + GroupOnSurface->TextLabel3->setShown(isParam); + GroupOnSurface->SpinBox_DX->setShown(isParam); + GroupOnSurface->SpinBox_DY->setShown(isParam); + } - if ( theIsUpdate ) + GroupXYZ->setShown(!isParam && !isLength); + + if (theIsUpdate) QTimer::singleShot(50, this, SLOT(updateSize())); } @@ -969,20 +995,20 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate) // function : onBtnPopup() // purpose : //================================================================================= -void BasicGUI_PointDlg::onBtnPopup( QAction* a ) +void BasicGUI_PointDlg::onBtnPopup(QAction* a) { globalSelection(); // close local contexts, if any myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE; - localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); } //================================================================================= // function : updateSize // purpose : adjust dialog size to minimum //================================================================================= -void BasicGUI_PointDlg::updateSize() +void BasicGUI_PointDlg::updateSize() { qApp->processEvents(); updateGeometry(); - resize( minimumSizeHint() ); + resize(minimumSizeHint()); } diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index 67bfae79b..a9813c160 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_PointDlg.h // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #ifndef BASICGUI_POINTDLG_H #define BASICGUI_POINTDLG_H @@ -31,7 +30,7 @@ #include "GEOM_GenericObjPtr.h" #include -class DlgRef_1Sel1Spin1Check; +class DlgRef_2Sel1Spin; class DlgRef_3Spin; class DlgRef_2Sel; class DlgRef_1Sel3Spin; @@ -87,7 +86,7 @@ private: DlgRef_3Spin* GroupXYZ; DlgRef_1Sel3Spin* GroupRefPoint; - DlgRef_1Sel1Spin1Check* GroupOnCurve; + DlgRef_2Sel1Spin* GroupOnCurve; DlgRef_2Sel* GroupLineIntersection; DlgRef_1Sel2Spin* GroupOnSurface; diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.cxx b/src/BuildGUI/BuildGUI_EdgeDlg.cxx index 5e332f957..fa268ffae 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.cxx +++ b/src/BuildGUI/BuildGUI_EdgeDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BuildGUI_EdgeDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #include "BuildGUI_EdgeDlg.h" #include @@ -48,9 +47,11 @@ BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent) : GEOMBase_Skeleton(theGeometryGUI, parent) { - QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); - QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE"))); - QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE_WIRE"))); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE_WIRE"))); + QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE_CURVE"))); setWindowTitle(tr("GEOM_EDGE_TITLE")); @@ -58,8 +59,7 @@ BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent mainFrame()->GroupConstructors->setTitle(tr("GEOM_EDGE")); mainFrame()->RadioButton1->setIcon(image1); mainFrame()->RadioButton2->setIcon(image2); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton3->setIcon(image3); // two points @@ -79,22 +79,38 @@ BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent GroupWire->TextLabel1->setText(tr("GEOM_WIRE")); GroupWire->PushButton1->setIcon(image0); GroupWire->LineEdit1->setReadOnly(true); - GroupWire->TextLabel2->setText( tr( "GEOM_LINEAR_TOLERANCE" ) ); - GroupWire->TextLabel3->setText( tr( "GEOM_ANGULAR_TOLERANCE" ) ); + GroupWire->TextLabel2->setText(tr("GEOM_LINEAR_TOLERANCE")); + GroupWire->TextLabel3->setText(tr("GEOM_ANGULAR_TOLERANCE")); double SpecificStep = 0.0001; double prec1 = Precision::Confusion(); double prec2 = Precision::Angular(); - initSpinBox(GroupWire->SpinBox_DX, prec1, MAX_NUMBER, SpecificStep, "len_tol_precision" ); - initSpinBox(GroupWire->SpinBox_DY, prec2, MAX_NUMBER, SpecificStep, "ang_tol_precision" ); + initSpinBox(GroupWire->SpinBox_DX, prec1, MAX_NUMBER, SpecificStep, "len_tol_precision"); + initSpinBox(GroupWire->SpinBox_DY, prec2, MAX_NUMBER, SpecificStep, "ang_tol_precision"); GroupWire->SpinBox_DX->setValue(prec1); GroupWire->SpinBox_DY->setValue(prec2); + // on curve + + GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget()); + GroupOnCurve->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE")); + GroupOnCurve->PushButton1->setIcon(image0); + GroupOnCurve->LineEdit1->setReadOnly(true); + GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT")); + GroupOnCurve->PushButton2->setIcon(image0); + GroupOnCurve->LineEdit2->setReadOnly(true); + GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH")); + double step = aResMgr->doubleValue("Geometry", "SettingsGeomStep", 100.0); + initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); + GroupOnCurve->SpinBox_DX->setValue(step); + // layout QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); layout->addWidget(GroupPoints); layout->addWidget(GroupWire); + layout->addWidget(GroupOnCurve); /***************************************************************/ setHelpFileName("create_edge_page.html"); @@ -122,30 +138,37 @@ void BuildGUI_EdgeDlg::Init() myPoint1.nullify(); myPoint2.nullify(); myWire.nullify(); + myCurve.nullify(); + myStartPoint.nullify(); + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->setDown(true); globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); // signals and slots connections - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); + connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName(tr("GEOM_EDGE")); - ConstructorsClicked( 0 ); + ConstructorsClicked(0); } //================================================================================= @@ -170,8 +193,8 @@ bool BuildGUI_EdgeDlg::ClickOnApply() initName(); - myEditCurrentArgument->setText( "" ); - ConstructorsClicked( getConstructorId() ); + myEditCurrentArgument->setText(""); + ConstructorsClicked(getConstructorId()); return true; } @@ -180,17 +203,17 @@ bool BuildGUI_EdgeDlg::ClickOnApply() // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId ) +void BuildGUI_EdgeDlg::ConstructorsClicked(int constructorId) { - switch ( constructorId ) { + switch (constructorId) { case 0: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->LineEdit1->setText( "" ); - GroupPoints->LineEdit2->setText( "" ); + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); myPoint1.nullify(); myPoint2.nullify(); GroupPoints->PushButton1->setDown(true); @@ -199,12 +222,13 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId ) GroupPoints->LineEdit2->setEnabled(false); GroupPoints->show(); GroupWire->hide(); + GroupOnCurve->hide(); break; } case 1: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_WIRE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_WIRE); myEditCurrentArgument = GroupWire->LineEdit1; GroupWire->LineEdit1->setText(""); @@ -212,14 +236,34 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId ) GroupWire->PushButton1->setDown(true); GroupWire->LineEdit1->setEnabled(true); GroupPoints->hide(); + GroupOnCurve->hide(); GroupWire->show(); break; } + case 2: + { + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + + myEditCurrentArgument = GroupOnCurve->LineEdit1; + GroupOnCurve->LineEdit1->setText(""); + GroupOnCurve->LineEdit2->setText(""); + myCurve.nullify(); + myStartPoint.nullify(); + GroupOnCurve->PushButton1->setDown(true); + GroupOnCurve->PushButton2->setDown(false); + GroupOnCurve->LineEdit1->setEnabled(true); + GroupOnCurve->LineEdit2->setEnabled(false); + GroupPoints->hide(); + GroupWire->hide(); + GroupOnCurve->show(); + break; + } } qApp->processEvents(); updateGeometry(); - resize( minimumSizeHint() ); + resize(minimumSizeHint()); SelectionIntoArgument(); } @@ -237,36 +281,51 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); - else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire.nullify(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); + else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire.nullify(); + else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) myCurve.nullify(); + else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) myStartPoint.nullify(); displayPreview(true); return; } - TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX; - GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupWire->LineEdit1) aNeedType = TopAbs_WIRE; + else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) aNeedType = TopAbs_EDGE; + GEOM::GeomObjPtr aSelectedObject = getSelected(aNeedType); + TopoDS_Shape aShape; - if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { - QString aName = GEOMBase::GetName( aSelectedObject.get() ); - myEditCurrentArgument->setText( aName ); + if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) { + QString aName = GEOMBase::GetName(aSelectedObject.get()); + myEditCurrentArgument->setText(aName); globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); + localSelection(GEOM::GEOM_Object::_nil(), aNeedType); - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) { myPoint1 = aSelectedObject; - if ( myPoint1 && !myPoint2 ) + if (myPoint1 && !myPoint2) GroupPoints->PushButton2->click(); } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { myPoint2 = aSelectedObject; - if ( myPoint2 && !myPoint1 ) + if (myPoint2 && !myPoint1) GroupPoints->PushButton1->click(); } - else if ( myEditCurrentArgument == GroupWire->LineEdit1 ) { + else if (myEditCurrentArgument == GroupWire->LineEdit1) { myWire = aSelectedObject; } + else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) { + myCurve = aSelectedObject; + if (myCurve && !myStartPoint) + GroupOnCurve->PushButton2->click(); + } + else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) { + myStartPoint = aSelectedObject; + if (myStartPoint && !myCurve) + GroupOnCurve->PushButton1->click(); + } } displayPreview(true); @@ -293,6 +352,22 @@ void BuildGUI_EdgeDlg::SetEditCurrentArgument() else if (send == GroupWire->PushButton1) { myEditCurrentArgument = GroupWire->LineEdit1; } + else if (send == GroupOnCurve->PushButton1) { + myEditCurrentArgument = GroupOnCurve->LineEdit1; + GroupOnCurve->PushButton2->setDown(false); + GroupOnCurve->LineEdit2->setEnabled(false); + + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else if (send == GroupOnCurve->PushButton2) { + myEditCurrentArgument = GroupOnCurve->LineEdit2; + GroupOnCurve->PushButton1->setDown(false); + GroupOnCurve->LineEdit1->setEnabled(false); + + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + } // enable line edit myEditCurrentArgument->setEnabled(true); @@ -309,10 +384,10 @@ void BuildGUI_EdgeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -325,6 +400,15 @@ void BuildGUI_EdgeDlg::enterEvent (QEvent*) ActivateThisDialog(); } +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::ValueChangedInSpinBox(double newValue) +{ + displayPreview(true); +} + //================================================================================= // function : createOperation // purpose : @@ -341,15 +425,19 @@ GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation() bool BuildGUI_EdgeDlg::isValid (QString& msg) { bool ok = false; - switch ( getConstructorId() ) { + switch (getConstructorId()) { case 0: ok = myPoint1 && myPoint2; break; case 1: - ok = GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ) && + ok = GroupWire->SpinBox_DX->isValid(msg, !IsPreview()) && + GroupWire->SpinBox_DY->isValid(msg, !IsPreview()) && myWire; break; + case 2: + ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview()) && + myCurve; + break; default: break; } @@ -365,12 +453,12 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) bool res = false; GEOM::GEOM_Object_var anObj; - GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); + GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation()); - switch ( getConstructorId() ) { - case 0 : + switch (getConstructorId()) { + case 0: { - anObj = anOper->MakeEdge( myPoint1.get(), myPoint2.get() ); + anObj = anOper->MakeEdge(myPoint1.get(), myPoint2.get()); res = true; break; } @@ -378,22 +466,34 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) { double aLinearTolerance = GroupWire->SpinBox_DX->value(); double anAngularTolerance = GroupWire->SpinBox_DY->value(); - + QStringList aParameters; aParameters << GroupWire->SpinBox_DX->text(); aParameters << GroupWire->SpinBox_DY->text(); - - anObj = anOper->MakeEdgeWire( myWire.get(), aLinearTolerance, anAngularTolerance ); - - if ( !anObj->_is_nil() && !IsPreview() ) - anObj->SetParameters( aParameters.join(":").toLatin1().constData() ); - + + anObj = anOper->MakeEdgeWire(myWire.get(), aLinearTolerance, anAngularTolerance); + + if (!anObj->_is_nil() && !IsPreview()) + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + + res = true; + break; + } + case 2: + { + double aLength = GroupOnCurve->SpinBox_DX->value(); + + anObj = anOper->MakeEdgeOnCurveByLength(myCurve.get(), aLength, myStartPoint.get()); + + if (!anObj->_is_nil() && !IsPreview()) + anObj->SetParameters(GroupOnCurve->SpinBox_DX->text().toLatin1().constData()); + res = true; break; } } - if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); + if (!anObj->_is_nil()) objects.push_back(anObj._retn()); return res; } @@ -404,13 +504,17 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) //================================================================================= void BuildGUI_EdgeDlg::addSubshapesToStudy() { - switch ( getConstructorId() ) { - case 0 : - GEOMBase::PublishSubObject( myPoint1.get() ); - GEOMBase::PublishSubObject( myPoint2.get() ); + switch (getConstructorId()) { + case 0: + GEOMBase::PublishSubObject(myPoint1.get()); + GEOMBase::PublishSubObject(myPoint2.get()); break; - case 1 : - GEOMBase::PublishSubObject( myWire.get() ); + case 1: + GEOMBase::PublishSubObject(myWire.get()); + break; + case 2: + GEOMBase::PublishSubObject(myCurve.get()); + GEOMBase::PublishSubObject(myStartPoint.get()); break; default: break; diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.h b/src/BuildGUI/BuildGUI_EdgeDlg.h index 9ead7e356..115574ee0 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.h +++ b/src/BuildGUI/BuildGUI_EdgeDlg.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BuildGUI_EdgeDlg.h // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #ifndef BUILDGUI_EDGEDLG_H #define BUILDGUI_EDGEDLG_H @@ -32,6 +31,7 @@ class DlgRef_1Sel2Spin; class DlgRef_2Sel; +class DlgRef_2Sel1Spin; //================================================================================= // class : BuildGUI_EdgeDlg @@ -42,34 +42,38 @@ class BuildGUI_EdgeDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_EdgeDlg( GeometryGUI*, QWidget* = 0 ); + BuildGUI_EdgeDlg (GeometryGUI*, QWidget* = 0); ~BuildGUI_EdgeDlg(); protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); virtual void addSubshapesToStudy(); private: void Init(); - void enterEvent( QEvent* ); + void enterEvent (QEvent*); private: - GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the edge */ + GEOM::GeomObjPtr myPoint1, myPoint2; /* Points */ GEOM::GeomObjPtr myWire; /* Wire */ + GEOM::GeomObjPtr myCurve; /* Edge */ + GEOM::GeomObjPtr myStartPoint; /* Point */ DlgRef_2Sel* GroupPoints; DlgRef_1Sel2Spin* GroupWire; + DlgRef_2Sel1Spin* GroupOnCurve; private slots: - void ConstructorsClicked( int ); + void ConstructorsClicked (int); void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + void ValueChangedInSpinBox (double); }; #endif // BUILDGUI_EDGEDLG_H diff --git a/src/BuildGUI/BuildGUI_SolidDlg.cxx b/src/BuildGUI/BuildGUI_SolidDlg.cxx index c619ee15b..8f9ab2761 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.cxx +++ b/src/BuildGUI/BuildGUI_SolidDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BuildGUI_SolidDlg.cxx // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #include "BuildGUI_SolidDlg.h" #include @@ -38,9 +37,11 @@ #include #include +#include + //================================================================================= // class : BuildGUI_SolidDlg() -// purpose : Constructs a BuildGUI_SolidDlg which is a child of 'parent', with the +// purpose : Constructs a BuildGUI_SolidDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -52,7 +53,7 @@ BuildGUI_SolidDlg::BuildGUI_SolidDlg( GeometryGUI* theGeometryGUI, QWidget* pare QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); setWindowTitle( tr( "GEOM_SOLID_TITLE" ) ); - + /***************************************************************/ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SOLID" ) ); mainFrame()->RadioButton1->setIcon( image0 ); @@ -68,7 +69,7 @@ BuildGUI_SolidDlg::BuildGUI_SolidDlg( GeometryGUI* theGeometryGUI, QWidget* pare GroupSolid->CheckButton1->setText( tr( "GEOM_CREATE_SINGLE_SOLID" ) ); GroupSolid->PushButton1->setIcon( image1 ); GroupSolid->LineEdit1->setReadOnly( true ); - + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupSolid ); @@ -103,8 +104,14 @@ void BuildGUI_SolidDlg::Init() GroupSolid->CheckButton1->setChecked( true ); myShells.clear(); - - globalSelection( GEOM_SHELL ); + + //globalSelection( GEOM_SHELL ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_COMPOUNDFILTER ); + QList aSubShapes; + aSubShapes.append( GEOM_SHELL ); + globalSelection( aMap, aSubShapes ); /* signals and slots connections */ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); @@ -154,7 +161,10 @@ void BuildGUI_SolidDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - myShells = getSelected( TopAbs_SHELL, -1 ); + //myShells = getSelected( TopAbs_SHELL, -1 ); + QList types; + types << TopAbs_SHELL << TopAbs_COMPOUND; + myShells = getSelected( types, -1 ); if ( !myShells.isEmpty() ) { QString aName = myShells.count() > 1 ? QString( "%1_objects").arg( myShells.count() ) : GEOMBase::GetName( myShells[0].get() ); @@ -171,8 +181,15 @@ void BuildGUI_SolidDlg::SetEditCurrentArgument() QPushButton* send = (QPushButton*)sender(); if ( send != GroupSolid->PushButton1 ) return; - - globalSelection( GEOM_SHELL ); + + //globalSelection( GEOM_SHELL ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_COMPOUNDFILTER ); + QList aSubShapes; + aSubShapes.append( GEOM_SHELL ); + globalSelection( aMap, aSubShapes ); + myEditCurrentArgument = GroupSolid->LineEdit1; myEditCurrentArgument->setFocus(); @@ -189,7 +206,14 @@ void BuildGUI_SolidDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - globalSelection( GEOM_SHELL ); + + //globalSelection( GEOM_SHELL ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_COMPOUNDFILTER ); + QList aSubShapes; + aSubShapes.append( GEOM_SHELL ); + globalSelection( aMap, aSubShapes ); } @@ -210,7 +234,7 @@ void BuildGUI_SolidDlg::enterEvent( QEvent* ) //================================================================================= void BuildGUI_SolidDlg::EnableNameField( bool toEnable ) { - mainFrame()->GroupBoxName->setEnabled( toEnable ); + mainFrame()->GroupBoxName->setEnabled( toEnable ); } //================================================================================= @@ -226,17 +250,24 @@ GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool BuildGUI_SolidDlg::isValid( QString& msg ) +bool BuildGUI_SolidDlg::isValid (QString& msg) { bool ok = !myShells.isEmpty(); + + GEOM::MeasureOpPtr anOp; + anOp.take(myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId())); + for ( int i = 0, n = myShells.count(); i < n && ok; i++ ) { - ok = isClosed( myShells[i].get() ); - if ( !ok ) - msg = QObject::tr("WRN_SHAPE_UNCLOSED").arg( GEOMBase::GetName( myShells[i].get() ) ); + CORBA::String_var aRes = anOp->IsGoodForSolid(myShells[i].get()); + if (strlen(aRes.in())) { + msg = QObject::tr(aRes.in()).arg(GEOMBase::GetName(myShells[i].get())); + ok = false; + } } return ok; } +/* //================================================================================= // function : isClosed // purpose : Check the object 'i' in myShells list is closed or unclosed @@ -252,15 +283,15 @@ bool BuildGUI_SolidDlg::isClosed( GEOM::GEOM_Object_ptr shell ) if ( !CORBA::is_nil( shell ) ) { GEOM::MeasureOpPtr anOp; anOp.take( myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ) ); - + // Detect kind of shape and parameters aKind = anOp->KindOfShape(shell, anInts, aDbls); - + if ( anOp->IsDone() ) { if ( anInts[0] == 1 ) - ok = true; + ok = true; else if ( anInts[0] == 2 ) - ok = false; + ok = false; } else { MESSAGE ("KindOfShape Operation is NOT DONE!!!"); @@ -272,6 +303,7 @@ bool BuildGUI_SolidDlg::isClosed( GEOM::GEOM_Object_ptr shell ) return ok; } +*/ //================================================================================= // function : execute @@ -280,7 +312,7 @@ bool BuildGUI_SolidDlg::isClosed( GEOM::GEOM_Object_ptr shell ) bool BuildGUI_SolidDlg::execute( ObjectList& objects ) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - + if ( GroupSolid->CheckButton1->isChecked() ) { GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); objlist->length( myShells.count() ); @@ -303,4 +335,3 @@ bool BuildGUI_SolidDlg::execute( ObjectList& objects ) return true; } - diff --git a/src/BuildGUI/BuildGUI_SolidDlg.h b/src/BuildGUI/BuildGUI_SolidDlg.h index 2ce9bcb96..8c0238efd 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.h +++ b/src/BuildGUI/BuildGUI_SolidDlg.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BuildGUI_SolidDlg.h // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #ifndef BUILDGUI_SOLIDDLG_H #define BUILDGUI_SOLIDDLG_H @@ -52,7 +51,7 @@ protected: private: void Init(); - bool isClosed( GEOM::GEOM_Object_ptr shell ); + //bool isClosed( GEOM::GEOM_Object_ptr shell ); void enterEvent( QEvent* ); private: diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index c8fe70499..9650843b4 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// + // GEOM GEOMGUI : GUI for Geometry component // File : EntityGUI_SubShapeDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. @@ -125,7 +125,7 @@ void EntityGUI_SubShapeDlg::Init() GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" ); GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" ); - if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() + if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ) GroupPoints->CheckButton1->setEnabled( false ); @@ -169,7 +169,7 @@ void EntityGUI_SubShapeDlg::ClickOnOk() bool EntityGUI_SubShapeDlg::ClickOnApply() { SUIT_Session::session()->activeApplication()->putInfo( "" ); - + /* Explode all sub shapes */ if ( isAllSubShapes() ) { /* More than 30 subshapes : ask confirmation */ @@ -301,7 +301,7 @@ void EntityGUI_SubShapeDlg::SetEditCurrentArgument() { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - + GroupPoints->CheckButton1->setChecked( false ); SubShapeToggled(); SelectionIntoArgument(); @@ -313,7 +313,7 @@ void EntityGUI_SubShapeDlg::SetEditCurrentArgument() // purpose : //================================================================================= void EntityGUI_SubShapeDlg::LineEditReturnPressed() -{ +{ QLineEdit* send = (QLineEdit*)sender(); if ( send == GroupPoints->LineEdit1 ) SetEditCurrentArgument(); @@ -386,9 +386,9 @@ void EntityGUI_SubShapeDlg::ResetStateOfDialog() GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Edge" ); GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" ); GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" ); - + myWithShape = true; - + GroupPoints->ComboBox1->setCurrentIndex( 8 - count + SelectedShapeType ); ComboTextChanged(); @@ -412,13 +412,13 @@ void EntityGUI_SubShapeDlg::SubShapeToggled() //================================================================================= // function : ComboTextChanged() -// purpose : +// purpose : //================================================================================= void EntityGUI_SubShapeDlg::ComboTextChanged() { /* Select sub shapes mode not checked */ updateButtonState(); - SubShapeToggled(); + SubShapeToggled(); } @@ -448,7 +448,7 @@ unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, } } } - } + } else { TopExp_Explorer Exp ( S, TopAbs_ShapeEnum( shapeType ) ); for ( ; Exp.More(); Exp.Next() ) { @@ -563,7 +563,7 @@ bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) if (!aList->length()) return false; - // Throw away sub-shapes not selected by user if not in preview mode + // Throw away sub-shapes not selected by user if not in preview mode // and manual selection is active if (!isAllSubShapes()) { LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -578,7 +578,7 @@ bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) TColStd_IndexedMapOfInteger aMapIndex; aSelMgr->GetIndexes(aSelList.First(), aMapIndex); - GEOM::GEOM_ILocalOperations_var aLocOp = + GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId()); for (int i = 0, n = aList->length(); i < n; i++) @@ -590,7 +590,7 @@ bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) else for (int i = 0, n = aList->length(); i < n; i++) objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); - + return objects.size(); } diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index a99fc90cd..3051bf90c 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -113,6 +113,10 @@ ICON_DLG_BUILD_EDGE_WIRE build_edge_wire.png + + ICON_DLG_BUILD_EDGE_CURVE + build_edge_curve.png + ICON_DLG_BUILD_FACE build_face.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 4215459aa..667d6a26b 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1205,6 +1205,10 @@ Please, select face, shell or solid and try again GEOM_POINT_TITLE Point Construction + + GEOM_START_POINT + Start Point + GEOM_POLYLINE Polyline @@ -2085,6 +2089,14 @@ Please, select face, shell or solid and try again WRN_SHAPE_UNCLOSED Unable to create solid from unclosed shape %1 + + WRN_SHAPE_NOT_SHELL + Unable to create solid from shape %1 as it is not a shell + + + WRN_NULL_OBJECT_OR_SHAPE + Shape %1 for solid creation is null + GEOM_X X : diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 07b40dc68..3cac51381 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -192,7 +191,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom double theParam2, double theParam3, const PointLocation theLocation, - bool theReverse) + Handle(GEOM_Object) theRefPoint) { SetErrorCode(KO); @@ -231,7 +230,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom case PointOn_CurveByLength: aPI.SetCurve(aRefFunction); aPI.SetLength(theParam1); - aPI.SetReversed(theReverse); + if (!theRefPoint.IsNull()) { + Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction(); + aPI.SetRef(aRefPoint); + } break; case PointOn_CurveByCoord: aPI.SetCurve(aRefFunction); @@ -277,7 +279,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom break; case PointOn_CurveByLength: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength(" - << theGeomObj << ", " << theParam1 << ", " << theReverse << ")"; + << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")"; break; case PointOn_CurveByCoord: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord(" @@ -332,10 +334,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord //============================================================================= Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength (Handle(GEOM_Object) theCurve, - double theLength, - bool theReverse) + double theLength, + Handle(GEOM_Object) theStartPoint) { - return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theReverse); + return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint); } //============================================================================= diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 64d65f552..bd0e3abb4 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_IBasicOperations_HXX_ #define _GEOMImpl_IBasicOperations_HXX_ @@ -44,8 +43,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theParameter); Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve, - double theLength, - bool theReverse); + double theLength, + Handle(GEOM_Object) theStartPoint); Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve, double theXParam, @@ -136,7 +135,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theParam2, double theParam3, const PointLocation theLocation, - bool theReverse = false); + Handle(GEOM_Object) theRefPoint = 0); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index 374aa589f..5aa0feb07 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifdef WNT #pragma warning( disable:4786 ) @@ -35,6 +34,7 @@ #include #include #include +#include #include #include @@ -3283,6 +3283,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate TopTools_MapOfShape mapAcceptedEdges; TCollection_AsciiString aListRes, anEntry; + // Sort shapes in current chain (Mantis issue 21053) + TopTools_DataMapOfShapeListOfShape aMapChains; + TopTools_ListOfShape aFirstInChains; + for (ie = 1; ie <= nbEdges; ie++) { TopoDS_Shape curE = MEW.FindKey(ie); @@ -3343,6 +3347,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate listPrevEdges = listCurEdges; } // while (listPrevEdges.Extent() > 0) + // Sort shapes in current chain (Mantis issue 21053) + GEOMImpl_IShapesOperations::SortShapes(currentChain, Standard_False); + aFirstInChains.Append(currentChain.First()); + aMapChains.Bind(currentChain.First(), currentChain); + } + + // Sort chains (Mantis issue 21053) + GEOMImpl_IShapesOperations::SortShapes(aFirstInChains, Standard_False); + + // Store sorted chains in the document + TopTools_ListIteratorOfListOfShape aChainsIt (aFirstInChains); + for (; aChainsIt.More(); aChainsIt.Next()) { + TopoDS_Shape aFirstInChain = aChainsIt.Value(); + const TopTools_ListOfShape& currentChain = aMapChains.Find(aFirstInChain); + // Store the chain in the document Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, currentChain.Extent()); diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index d6a259787..46ce5f9c5 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -60,6 +59,7 @@ #include #include +#include #include #include #include @@ -157,13 +157,13 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape if (aShape.IsNull()) return aKind; int geom_type = theShape->GetType(); - + // check if it's advanced shape if ( geom_type > ADVANCED_BASE ) { SetErrorCode(OK); return SK_ADVANCED; } - + // Call algorithm GEOMAlgo_ShapeInfoFiller aSF; aSF.SetShape(aShape); @@ -1299,6 +1299,53 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, return isValid; } +//============================================================================= +/*! + * IsGoodForSolid + */ +//============================================================================= +TCollection_AsciiString GEOMImpl_IMeasureOperations::IsGoodForSolid (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + TCollection_AsciiString aRes = ""; + + if (theShape.IsNull()) { + aRes = "WRN_NULL_OBJECT_OR_SHAPE"; + } + else { + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) { + aRes = "WRN_NULL_OBJECT_OR_SHAPE"; + } + else { + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + aRes = "WRN_NULL_OBJECT_OR_SHAPE"; + } + else { + if (aShape.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator It (aShape, Standard_True, Standard_True); + if (It.More()) aShape = It.Value(); + } + if (aShape.ShapeType() == TopAbs_SHELL) { + if (!aShape.Closed()) { + aRes = "WRN_SHAPE_UNCLOSED"; + } + } + else { + aRes = "WRN_SHAPE_NOT_SHELL"; + } + } + } + } + + if (aRes.IsEmpty()) + SetErrorCode(OK); + + return aRes; +} + //============================================================================= /*! * WhatIs @@ -1411,9 +1458,9 @@ static double CheckSingularCase(const TopoDS_Shape& aSh1, //S->Bounds(U1,U2,V1,V2); changed by ShapeAnalysis::GetFaceUVBounds(TopoDS::Face(tmpSh1),U1,U2,V1,V2); // end of changes for 020677 (dmv) - Handle(Geom_RectangularTrimmedSurface) TrS1 = + Handle(Geom_RectangularTrimmedSurface) TrS1 = new Geom_RectangularTrimmedSurface(S,U1,(U1+U2)/2.,V1,V2); - Handle(Geom_RectangularTrimmedSurface) TrS2 = + Handle(Geom_RectangularTrimmedSurface) TrS2 = new Geom_RectangularTrimmedSurface(S,(U1+U2)/2.,U2,V1,V2); BRep_Builder B; TopoDS_Face F1,F2; @@ -1481,9 +1528,9 @@ static double CheckSingularCase(const TopoDS_Shape& aSh1, double U1,U2,V1,V2; //S->Bounds(U1,U2,V1,V2); ShapeAnalysis::GetFaceUVBounds(TopoDS::Face(tmpSh2),U1,U2,V1,V2); - Handle(Geom_RectangularTrimmedSurface) TrS1 = + Handle(Geom_RectangularTrimmedSurface) TrS1 = new Geom_RectangularTrimmedSurface(S,U1,(U1+U2)/2.,V1,V2); - Handle(Geom_RectangularTrimmedSurface) TrS2 = + Handle(Geom_RectangularTrimmedSurface) TrS2 = new Geom_RectangularTrimmedSurface(S,(U1+U2)/2.,U2,V1,V2); BRep_Builder B; TopoDS_Face F1,F2; @@ -1686,8 +1733,8 @@ static bool CheckSingularCase(const TopoDS_Shape& aSh1, */ //============================================================================= std::vector GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape, - const std::vector& coords, - double tolerance) + const std::vector& coords, + double tolerance) { std::vector res; if (!theShape.IsNull()) { @@ -1695,16 +1742,16 @@ std::vector GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Objec if (!aRefShape.IsNull()) { TopoDS_Shape aShape = aRefShape->GetValue(); if (!aShape.IsNull()) { - BRepClass3d_SolidClassifier SC(aShape); - unsigned int nb_points = coords.size()/3; - for (int i = 0; i < nb_points; i++) { - double x = coords[3*i]; - double y = coords[3*i+1]; - double z = coords[3*i+2]; - gp_Pnt aPnt(x, y, z); - SC.Perform(aPnt, tolerance); - res.push_back( ( SC.State() == TopAbs_IN ) || ( SC.State() == TopAbs_ON ) ); - } + BRepClass3d_SolidClassifier SC(aShape); + unsigned int nb_points = coords.size()/3; + for (int i = 0; i < nb_points; i++) { + double x = coords[3*i]; + double y = coords[3*i+1]; + double z = coords[3*i+2]; + gp_Pnt aPnt(x, y, z); + SC.Perform(aPnt, tolerance); + res.push_back( ( SC.State() == TopAbs_IN ) || ( SC.State() == TopAbs_ON ) ); + } } } } @@ -1912,6 +1959,72 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine anAngle = aLin1.Angle(aLin2); anAngle /= PI180; // convert radians into degrees + if (anAngle > 90.0) { + anAngle = 180.0 - anAngle; + } + + SetErrorCode(OK); + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + } + + return anAngle; +} + +//======================================================================= +/*! + * Compute angle (in degrees) between two vectors + */ +//======================================================================= +Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Object) theVec1, + Handle(GEOM_Object) theVec2) +{ + SetErrorCode(KO); + + Standard_Real anAngle = -1.0; + + if (theVec1.IsNull() || theVec2.IsNull()) + return anAngle; + + Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction(); + Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction(); + if (aRefVec1.IsNull() || aRefVec2.IsNull()) + return anAngle; + + TopoDS_Shape aVec1 = aRefVec1->GetValue(); + TopoDS_Shape aVec2 = aRefVec2->GetValue(); + if (aVec1.IsNull() || aVec2.IsNull() || + aVec1.ShapeType() != TopAbs_EDGE || + aVec2.ShapeType() != TopAbs_EDGE) + { + SetErrorCode("Two edges must be given"); + return anAngle; + } + + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + TopoDS_Edge aE1 = TopoDS::Edge(aVec1); + TopoDS_Edge aE2 = TopoDS::Edge(aVec2); + + TopoDS_Vertex aP11, aP12, aP21, aP22; + TopExp::Vertices(aE1, aP11, aP12, Standard_True); + TopExp::Vertices(aE2, aP21, aP22, Standard_True); + if (aP11.IsNull() || aP12.IsNull() || aP21.IsNull() || aP22.IsNull()) { + SetErrorCode("Bad edge given"); + return anAngle; + } + + gp_Vec aV1 (BRep_Tool::Pnt(aP11), BRep_Tool::Pnt(aP12)); + gp_Vec aV2 (BRep_Tool::Pnt(aP21), BRep_Tool::Pnt(aP22)) ; + + anAngle = aV1.Angle(aV2); + anAngle /= PI180; // convert radians into degrees + SetErrorCode(OK); } catch (Standard_Failure) @@ -1957,7 +2070,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - GeomLProp_CLProps Prop = GeomLProp_CLProps + GeomLProp_CLProps Prop = GeomLProp_CLProps (aCurve, aP, 2, Precision::Confusion()); aRes = fabs(Prop.Curvature()); SetErrorCode(OK); @@ -1972,7 +2085,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam aRes = 1/aRes; else aRes = RealLast(); - + return aRes; } @@ -2013,7 +2126,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint #endif GeomAPI_ProjectPointOnCurve PPCurve(aPoint, aCurve, aFP, aLP); if(PPCurve.NbPoints()>0) { - GeomLProp_CLProps Prop = GeomLProp_CLProps + GeomLProp_CLProps Prop = GeomLProp_CLProps (aCurve, PPCurve.LowerDistanceParameter(), 2, Precision::Confusion()); aRes = fabs(Prop.Curvature()); SetErrorCode(OK); @@ -2029,7 +2142,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint aRes = 1/aRes; else aRes = RealLast(); - + return aRes; } @@ -2054,7 +2167,7 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - GeomLProp_SLProps Prop = GeomLProp_SLProps + GeomLProp_SLProps Prop = GeomLProp_SLProps (aSurf, theUParam, theVParam, 2, Precision::Confusion()); if(Prop.IsCurvatureDefined()) { if(Prop.IsUmbilic()) { @@ -2083,7 +2196,7 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures aRes = 1/aRes; else aRes = RealLast(); - + return aRes; } @@ -2120,7 +2233,7 @@ Standard_Real GEOMImpl_IMeasureOperations::MaxSurfaceCurvatureByParam ShapeAnalysis::GetFaceUVBounds(F,U1,U2,V1,V2); Standard_Real U = U1 + (U2-U1)*theUParam; Standard_Real V = V1 + (V2-V1)*theVParam; - + return getSurfaceCurvatures(aSurf, U, V, true); } @@ -2193,7 +2306,7 @@ Standard_Real GEOMImpl_IMeasureOperations::MinSurfaceCurvatureByParam ShapeAnalysis::GetFaceUVBounds(F,U1,U2,V1,V2); Standard_Real U = U1 + (U2-U1)*theUParam; Standard_Real V = V1 + (V2-V1)*theVParam; - + return getSurfaceCurvatures(aSurf, U, V, false); } diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index 5696d48cc..471bfb851 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_IMeasureOperations_HXX_ #define _GEOMImpl_IMeasureOperations_HXX_ @@ -127,11 +126,13 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { const Standard_Boolean theIsCheckGeom, TCollection_AsciiString& theDump); + Standard_EXPORT TCollection_AsciiString IsGoodForSolid (Handle(GEOM_Object) theShape); + Standard_EXPORT TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape); Standard_EXPORT std::vector AreCoordsInside (Handle(GEOM_Object) theShape, - const std::vector& coords, - double tolerance = Precision::Confusion()); + const std::vector& coords, + double tolerance = Precision::Confusion()); Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, @@ -143,6 +144,8 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_EXPORT Standard_Real GetAngle (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2); + Standard_EXPORT Standard_Real GetAngleBtwVectors (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2); + // Methods for recieving radiuses of curvature of curves and surfaces // in the given point diff --git a/src/GEOMImpl/GEOMImpl_IPoint.hxx b/src/GEOMImpl/GEOMImpl_IPoint.hxx index c11569533..94d156e35 100755 --- a/src/GEOMImpl/GEOMImpl_IPoint.hxx +++ b/src/GEOMImpl/GEOMImpl_IPoint.hxx @@ -18,10 +18,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//NOTE: This is an intreface to a function for the point creation. -// +//NOTE: This is an interface to a function for the point creation. + #include "GEOM_Function.hxx" #define ARG_X 1 @@ -40,7 +39,7 @@ #define ARG_LENGTH 11 -#define ARG_FLAG 12 +//#define ARG_FLAG 12 class GEOMImpl_IPoint { @@ -73,12 +72,12 @@ 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 SetReversed(bool theReversed) { _func->SetInteger(ARG_FLAG, theReversed); } 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 GetReversed() { return _func->GetInteger(ARG_FLAG); } private: diff --git a/src/GEOMImpl/GEOMImpl_IShapes.hxx b/src/GEOMImpl/GEOMImpl_IShapes.hxx index dcdb59265..214ed6a7c 100644 --- a/src/GEOMImpl/GEOMImpl_IShapes.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapes.hxx @@ -18,11 +18,10 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// NOTE: This is an intreface to a function for the Shapes -// (Wire, Face, Shell, Solid and Compound) creation. -// +// NOTE: This is an interface to a function for the Shapes +// (Edge, Wire, Face, Shell, Solid and Compound) creation. + #include "GEOM_Function.hxx" #include "TColStd_HSequenceOfTransient.hxx" diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 920d2c943..9b4f0e9b8 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// + // File : GEOMImpl_IShapesOperations.cxx // Created : // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007 @@ -209,6 +209,67 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge return anEdge; } +//============================================================================= +/*! + * MakeEdgeOnCurveByLength + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeOnCurveByLength + (Handle(GEOM_Object) theRefCurve, + const Standard_Real theLength, + Handle(GEOM_Object) theStartPoint) +{ + SetErrorCode(KO); + + if (theRefCurve.IsNull()) return NULL; + + //Add a new Edge object + Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE); + + //Add a new Vector function + Handle(GEOM_Function) aFunction = + anEdge->AddFunction(GEOMImpl_ShapeDriver::GetID(), EDGE_CURVE_LENGTH); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IVector aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theRefCurve->GetLastFunction(); + if (aRef1.IsNull()) return NULL; + aPI.SetPoint1(aRef1); + + if (!theStartPoint.IsNull()) { + Handle(GEOM_Function) aRef2 = theStartPoint->GetLastFunction(); + aPI.SetPoint2(aRef2); + } + + aPI.SetParameter(theLength); + + //Compute the Edge value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector 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) << anEdge << " = geompy.MakeEdgeOnCurveByLength(" + << theRefCurve << ", " << theLength << ", " << theStartPoint << ")"; + + SetErrorCode(OK); + return anEdge; +} + //============================================================================= /*! * MakeEdgeWire @@ -4089,7 +4150,17 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSame(const Handle(GEOM_Object TopoDS_Shape aSubShape; TopTools_MapOfShape aMap; - switch(aWhat.ShapeType()) { + if (aWhat.ShapeType() == TopAbs_COMPOUND || aWhat.ShapeType() == TopAbs_COMPSOLID) { + TopoDS_Iterator It (aWhat, Standard_True, Standard_True); + if (It.More()) aWhat = It.Value(); + It.Next(); + if (It.More()) { + SetErrorCode("Compounds of two or more shapes are not allowed for aWhat argument"); + return NULL; + } + } + + switch (aWhat.ShapeType()) { case TopAbs_VERTEX: { gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aWhat)); TopExp_Explorer E(aWhere, TopAbs_VERTEX); @@ -4104,12 +4175,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSame(const Handle(GEOM_Object } break; } - case TopAbs_FACE: { - TopoDS_Face aFace = TopoDS::Face(aWhat); - TopExp_Explorer E(aWhere, TopAbs_FACE); + case TopAbs_EDGE: { + TopoDS_Edge anEdge = TopoDS::Edge(aWhat); + TopExp_Explorer E(aWhere, TopAbs_EDGE); for(; E.More(); E.Next()) { if(!aMap.Add(E.Current())) continue; - if(isSameFace(aFace, TopoDS::Face(E.Current()))) { + if(isSameEdge(anEdge, TopoDS::Edge(E.Current()))) { aSubShape = E.Current(); isFound = true; break; @@ -4117,12 +4188,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSame(const Handle(GEOM_Object } break; } - case TopAbs_EDGE: { - TopoDS_Edge anEdge = TopoDS::Edge(aWhat); - TopExp_Explorer E(aWhere, TopAbs_EDGE); + case TopAbs_FACE: { + TopoDS_Face aFace = TopoDS::Face(aWhat); + TopExp_Explorer E(aWhere, TopAbs_FACE); for(; E.More(); E.Next()) { if(!aMap.Add(E.Current())) continue; - if(isSameEdge(anEdge, TopoDS::Edge(E.Current()))) { + if(isSameFace(aFace, TopoDS::Face(E.Current()))) { aSubShape = E.Current(); isFound = true; break; @@ -4147,14 +4218,14 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSame(const Handle(GEOM_Object return NULL; } - if(isFound) { + if (isFound) { TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aWhere, anIndices); if (anIndices.Contains(aSubShape)) anIndex = anIndices.FindIndex(aSubShape); } - if(anIndex < 0) return NULL; + if (anIndex < 0) return NULL; Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 607a1283f..53583e14c 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -54,6 +54,11 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2); + + Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve, + const Standard_Real theLength, + Handle(GEOM_Object) theStartPoint); + Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire, const Standard_Real theLinearTolerance, const Standard_Real theAngularTolerance); diff --git a/src/GEOMImpl/GEOMImpl_IVector.hxx b/src/GEOMImpl/GEOMImpl_IVector.hxx index 6e07703ee..7aedebf0e 100644 --- a/src/GEOMImpl/GEOMImpl_IVector.hxx +++ b/src/GEOMImpl/GEOMImpl_IVector.hxx @@ -18,10 +18,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//NOTE: This is an intreface to a function for the vector creation. -// +//NOTE: This is an interface to a function for the vector creation. + #include "GEOM_Function.hxx" #define VEC_ARG_DX 1 diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 4d08102d7..f39665e6c 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -27,28 +26,35 @@ #include #include +#include + +#include #include +#include #include #include -#include -#include -#include + #include +#include #include #include +#include #include #include #include -#include -#include -#include -#include -#include - #include #include +#include +#include + +#include + +#include + +#include + //======================================================================= //function : GetID //purpose : @@ -73,23 +79,22 @@ GEOMImpl_PointDriver::GEOMImpl_PointDriver() //purpose : local function //======================================================================= static Standard_Boolean getExtremaSolution -(GEOMImpl_IPoint& thePI, - TopoDS_Shape& theRefShape, +(const gp_Pnt& theInitPnt, + const TopoDS_Shape& theRefShape, gp_Pnt& thePnt) { - gp_Pnt anInitPnt( thePI.GetX(), thePI.GetY(), thePI.GetZ() ); - BRepBuilderAPI_MakeVertex mkVertex (anInitPnt); + BRepBuilderAPI_MakeVertex mkVertex (theInitPnt); TopoDS_Vertex anInitV = TopoDS::Vertex(mkVertex.Shape()); - BRepExtrema_DistShapeShape anExt( anInitV, theRefShape ); + BRepExtrema_DistShapeShape anExt (anInitV, theRefShape); if ( !anExt.IsDone() || anExt.NbSolution() < 1 ) return Standard_False; thePnt = anExt.PointOnShape2(1); - Standard_Real aMinDist2 = anInitPnt.SquareDistance( thePnt ); + Standard_Real aMinDist2 = theInitPnt.SquareDistance( thePnt ); for ( Standard_Integer j = 2, jn = anExt.NbSolution(); j <= jn; j++ ) { gp_Pnt aPnt = anExt.PointOnShape2(j); - Standard_Real aDist2 = anInitPnt.SquareDistance( aPnt ); + Standard_Real aDist2 = theInitPnt.SquareDistance( aPnt ); if ( aDist2 > aMinDist2) continue; aMinDist2 = aDist2; @@ -116,10 +121,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const if (aType == POINT_XYZ) { aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ()); - } else if (aType == POINT_XYZ_REF) { - Handle(GEOM_Function) aRefPoint = aPI.GetRef(); TopoDS_Shape aRefShape = aRefPoint->GetValue(); if (aRefShape.ShapeType() != TopAbs_VERTEX) { @@ -148,35 +151,72 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise ("Point On Curve creation aborted : curve shape is not an edge"); } - if (!getExtremaSolution( aPI, aRefShape, aPnt ) ) { + gp_Pnt anInitPnt (aPI.GetX(), aPI.GetY(), aPI.GetZ()); + if (!getExtremaSolution(anInitPnt, aRefShape, aPnt)) { Standard_ConstructionError::Raise ("Point On Curve creation aborted : cannot project point"); } } else if (aType == POINT_CURVE_LENGTH) { + // RefCurve Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); - Standard_Real theLength = aPI.GetLength(); - Standard_Integer theReversed = aPI.GetReversed(); - TopoDS_Shape aRefShape = aRefCurve->GetValue(); - Standard_Real UFirst = 0; - Standard_Real ULast = 0; - if (aRefShape.ShapeType() != TopAbs_EDGE) { + if (aRefCurve.IsNull()) { + Standard_NullObject::Raise + ("Point On Curve creation aborted : curve object is null"); + } + TopoDS_Shape aRefShape1 = aRefCurve->GetValue(); + if (aRefShape1.ShapeType() != TopAbs_EDGE) { Standard_TypeMismatch::Raise ("Point On Curve creation aborted : curve shape is not an edge"); - } - Standard_Real theCurveLength = IntTools::Length(TopoDS::Edge(aRefShape)); - if (theLength > theCurveLength) { - Standard_ConstructionError::Raise - ("Point On Curve creation aborted : given length is greater than edges length"); } - Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), UFirst, ULast); + TopoDS_Edge aRefEdge = TopoDS::Edge(aRefShape1); + TopoDS_Vertex V1, V2; + TopExp::Vertices(aRefEdge, V1, V2, Standard_True); + + // RefPoint + TopoDS_Vertex aRefVertex; + Handle(GEOM_Function) aRefPoint = aPI.GetRef(); + if (aRefPoint.IsNull()) { + aRefVertex = V1; + } + else { + TopoDS_Shape aRefShape2 = aRefPoint->GetValue(); + if (aRefShape2.ShapeType() != TopAbs_VERTEX) { + Standard_TypeMismatch::Raise + ("Point On Curve creation aborted : start point shape is not a vertex"); + } + aRefVertex = TopoDS::Vertex(aRefShape2); + } + gp_Pnt aRefPnt = BRep_Tool::Pnt(aRefVertex); + + // Length + Standard_Real aLength = aPI.GetLength(); + //Standard_Real theCurveLength = IntTools::Length(aRefEdge); + //if (aLength > theCurveLength) { + // Standard_ConstructionError::Raise + // ("Point On Curve creation aborted : given length is greater than edges length"); + //} + + // Check orientation + Standard_Real UFirst, ULast; + Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(aRefEdge, UFirst, ULast); Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; - if ( theReversed ) { - ReOrientedCurve = EdgeCurve -> Reversed(); - UFirst = EdgeCurve -> ReversedParameter(ULast); + + Standard_Real dU = ULast - UFirst; + Standard_Real par1 = UFirst + 0.1 * dU; + Standard_Real par2 = ULast - 0.1 * dU; + + gp_Pnt P1 = EdgeCurve->Value(par1); + gp_Pnt P2 = EdgeCurve->Value(par2); + + if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) { + ReOrientedCurve = EdgeCurve->Reversed(); + UFirst = EdgeCurve->ReversedParameter(ULast); } + + // Get the point by length GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); - GCPnts_AbscissaPoint anAbsPnt(AdapCurve, theLength, UFirst); + GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst); Standard_Real aParam = anAbsPnt.Parameter(); aPnt = AdapCurve.Value(aParam); } @@ -203,7 +243,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise ("Point On Surface creation aborted : surface shape is not a face"); } - if (!getExtremaSolution( aPI, aRefShape, aPnt ) ) { + gp_Pnt anInitPnt (aPI.GetX(), aPI.GetY(), aPI.GetZ()); + if (!getExtremaSolution(anInitPnt, aRefShape, aPnt)) { Standard_ConstructionError::Raise ("Point On Surface creation aborted : cannot project point"); } diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index 334bfbc09..f4e9fb3ec 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -18,11 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include +#include #include #include @@ -33,26 +33,27 @@ #include #include -#include #include +#include +#include #include -#include #include +#include +#include +#include #include #include #include #include -#include -#include #include #include #include -#include #include -#include #include +#include +#include #include #include #include @@ -61,12 +62,20 @@ #include #include #include -#include -#include #include #include +#include + +#include + +#include +#include +#include +#include +#include + #include #include #include @@ -74,13 +83,8 @@ #include #include -#include -#include -#include -#include -#include - #include + #include #include #include @@ -145,7 +149,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire; aFW->Load(aWire); aFW->FixReorder(); - + if (aFW->StatusReorder(ShapeExtend_FAIL1)) { Standard_ConstructionError::Raise("Wire construction failed: several loops detected"); } else if (aFW->StatusReorder(ShapeExtend_FAIL)) { @@ -157,7 +161,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Standard_Real aTolerance = aCI.GetTolerance(); if (aTolerance < Precision::Confusion()) aTolerance = Precision::Confusion(); - + aFW->ClosedWireMode() = Standard_False; aFW->FixConnected(aTolerance); if (aFW->StatusConnected(ShapeExtend_FAIL)) { @@ -204,7 +208,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (!MW.IsDone()) { Standard_ConstructionError::Raise("Wire construction failed"); } - W = MW; + W = MW; } else { Standard_NullObject::Raise @@ -370,12 +374,16 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const else if (aType == SOLID_SHELL) { Handle(GEOM_Function) aRefShell = aCI.GetBase(); TopoDS_Shape aShapeShell = aRefShell->GetValue(); + if (!aShapeShell.IsNull() && aShapeShell.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator It (aShapeShell, Standard_True, Standard_True); + if (It.More()) aShapeShell = It.Value(); + } if (aShapeShell.IsNull() || aShapeShell.ShapeType() != TopAbs_SHELL) { Standard_NullObject::Raise("Shape for solid construction is null or not a shell"); } BRepCheck_Shell chkShell(TopoDS::Shell(aShapeShell)); - if(chkShell.Closed() == BRepCheck_NotClosed) return 0; + if (chkShell.Closed() == BRepCheck_NotClosed) return 0; TopoDS_Solid Sol; B.MakeSolid(Sol); @@ -404,12 +412,16 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (aShapeShell.IsNull()) { Standard_NullObject::Raise("Shell for solid construction is null"); } + if (aShapeShell.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator It (aShapeShell, Standard_True, Standard_True); + if (It.More()) aShapeShell = It.Value(); + } if (aShapeShell.ShapeType() == TopAbs_SHELL) { B.Add(Sol, aShapeShell); ish++; } } - if ( ish == 0 ) return 0; + if (ish == 0) return 0; BRepClass3d_SolidClassifier SC (Sol); SC.PerformInfinitePoint(Precision::Confusion()); if (SC.State() == TopAbs_IN) @@ -550,7 +562,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const case GeomAbs_Line: { gp_Lin aLine = BAcurve.Line(); - gp_Lin PrevLine = GAprevcurve.Line(); + gp_Lin PrevLine = GAprevcurve.Line(); if (aLine.Contains(PrevLine.Location(), LinTol) && aLine.Direction().IsParallel(PrevLine.Direction(), AngTol)) { @@ -719,33 +731,33 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Standard_Integer nb_curve = CurveSeq.Length(); //number of curves TColGeom_Array1OfBSplineCurve tab(0,nb_curve-1); //array of the curves TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances - + Standard_Integer i; - + if (nb_curve > 1) { for (i = 1; i <= nb_curve; i++) { if (CurveSeq(i)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) CurveSeq(i) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve(); - + Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(CurveSeq(i), FparSeq(i), LparSeq(i)); tab(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve); tab(i-1)->Transform(LocSeq(i).Location().Transformation()); GeomConvert::C0BSplineToC1BSplineCurve(tab(i-1), Precision::Confusion()); if (LocSeq(i).Orientation() == TopAbs_REVERSED) tab(i-1)->Reverse(); - + //Temporary //char* name = new char[100]; //sprintf(name, "c%d", i); //DrawTrSurf::Set(name, tab(i-1)); - + if (i > 1) tabtolvertex(i-2) = TolSeq(i-1); } // end for (i = 1; i <= nb_curve; i++) tabtolvertex(nb_curve-1) = TolSeq(TolSeq.Length()); - + Standard_Boolean closed_flag = Standard_False; Standard_Real closed_tolerance = 0.; if (FirstVertex.IsSame(LastVertex) && @@ -757,7 +769,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const closed_flag = Standard_True ; closed_tolerance = BRep_Tool::Tolerance(FirstVertex); } - + Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex GeomConvert::ConcatC1(tab, @@ -766,17 +778,17 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const concatcurve, closed_flag, closed_tolerance); //C1 concatenation - + if (concatcurve->Length() > 1) { GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); - + for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++) Concat.Add( concatcurve->Value(i), LinTol, Standard_True ); - + concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); } - + ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()), FirstVertex, LastVertex); } @@ -784,16 +796,93 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const { if (CurveSeq(1)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) CurveSeq(1) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve(); - + CurveSeq(1)->Transform(LocSeq(1).Location().Transformation()); ResEdge = BRepLib_MakeEdge(CurveSeq(1), FirstVertex, LastVertex, FparSeq(1), LparSeq(1)); } } - + aShape = ResEdge; } + else if (aType == EDGE_CURVE_LENGTH) { + GEOMImpl_IVector aVI (aFunction); + + // RefCurve + Handle(GEOM_Function) aRefCurve = aVI.GetPoint1(); + if (aRefCurve.IsNull()) Standard_NullObject::Raise("Argument Curve is null"); + TopoDS_Shape aRefShape1 = aRefCurve->GetValue(); + if (aRefShape1.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise + ("Edge On Curve creation aborted : curve shape is not an edge"); + } + TopoDS_Edge aRefEdge = TopoDS::Edge(aRefShape1); + TopoDS_Vertex V1, V2; + TopExp::Vertices(aRefEdge, V1, V2, Standard_True); + + // RefPoint + TopoDS_Vertex aRefVertex; + Handle(GEOM_Function) aRefPoint = aVI.GetPoint2(); + if (aRefPoint.IsNull()) { + aRefVertex = V1; + } + else { + TopoDS_Shape aRefShape2 = aRefPoint->GetValue(); + if (aRefShape2.ShapeType() != TopAbs_VERTEX) { + Standard_TypeMismatch::Raise + ("Edge On Curve creation aborted : start point shape is not a vertex"); + } + aRefVertex = TopoDS::Vertex(aRefShape2); + } + gp_Pnt aRefPnt = BRep_Tool::Pnt(aRefVertex); + + // Length + Standard_Real aLength = aVI.GetParameter(); + //Standard_Real aCurveLength = IntTools::Length(aRefEdge); + //if (aLength > aCurveLength) { + // Standard_ConstructionError::Raise + // ("Edge On Curve creation aborted : given length is greater than edges length"); + //} + if (fabs(aLength) < Precision::Confusion()) { + Standard_ConstructionError::Raise + ("Edge On Curve creation aborted : given length is smaller than Precision::Confusion()"); + } + + // Check orientation + Standard_Real UFirst, ULast; + Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(aRefEdge, UFirst, ULast); + Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; + + Standard_Real dU = ULast - UFirst; + Standard_Real par1 = UFirst + 0.1 * dU; + Standard_Real par2 = ULast - 0.1 * dU; + + gp_Pnt P1 = EdgeCurve->Value(par1); + gp_Pnt P2 = EdgeCurve->Value(par2); + + if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) { + ReOrientedCurve = EdgeCurve->Reversed(); + UFirst = EdgeCurve->ReversedParameter(ULast); + } + + // Get the point by length + GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); + GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst); + Standard_Real aParam = anAbsPnt.Parameter(); + + if (AdapCurve.IsClosed() && aLength < 0.0) { + Standard_Real aTmp = aParam; + aParam = UFirst; + UFirst = aTmp; + } + + BRepBuilderAPI_MakeEdge aME (ReOrientedCurve, UFirst, aParam); + if (aME.IsDone()) + aShape = aME.Shape(); + } + else { + } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 6b98bf77b..b9c6f2bdf 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -18,10 +18,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// //GEOM_Object types -// + #define GEOM_COPY 0 #define GEOM_IMPORT 1 @@ -259,6 +258,7 @@ #define FACE_WIRES 9 #define REVERSE_ORIENTATION 10 #define EDGE_WIRE 11 +#define EDGE_CURVE_LENGTH 12 #define ARCHIMEDE_TYPE 1 diff --git a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx index c7a67168f..98a9a600e 100644 --- a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index d11abf3db..4bea49cc2 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -162,8 +161,8 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve //============================================================================= GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve, - CORBA::Double theLength, - CORBA::Boolean theReverse) + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint) { GEOM::GEOM_Object_var aGEOMObject; @@ -174,10 +173,15 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength Handle(GEOM_Object) aReference = GetObjectImpl(theCurve); if (aReference.IsNull()) return aGEOMObject._retn(); + //Get the reference point (can be NULL) + Handle(GEOM_Object) aRefPoint; + if (!CORBA::is_nil(theStartPoint)) { + aRefPoint = GetObjectImpl(theStartPoint); + } + //Create the point Handle(GEOM_Object) anObject = - GetOperations()->MakePointOnCurveByLength(aReference, theLength, - theReverse); + GetOperations()->MakePointOnCurveByLength(aReference, theLength, aRefPoint); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index 7fa357065..6b9a68cfe 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_IBasicOperations_i_HeaderFile #define _GEOM_IBasicOperations_i_HeaderFile @@ -56,8 +55,8 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve, - CORBA::Double theLength, - CORBA::Boolean theReverse); + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint); GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theXParameter, diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index dc6f9c0c6..94816c6ed 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -367,6 +366,25 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Obj return 0; } +//============================================================================= +/*! + * IsGoodForSolid + */ +//============================================================================= +char* GEOM_IMeasureOperations_i::IsGoodForSolid (GEOM::GEOM_Object_ptr theShape) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return CORBA::string_dup("WRN_NULL_OBJECT_OR_SHAPE"); + + // Get shape parameters + TCollection_AsciiString aDescription = GetOperations()->IsGoodForSolid(aShape); + return CORBA::string_dup(aDescription.ToCString()); +} + //============================================================================= /*! * WhatIs @@ -392,8 +410,8 @@ char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape) */ //============================================================================= GEOM::ListOfBool* GEOM_IMeasureOperations_i::AreCoordsInside (GEOM::GEOM_Object_ptr theShape, - const GEOM::ListOfDouble& theCoords, - CORBA::Double tolerance) + const GEOM::ListOfDouble& theCoords, + CORBA::Double tolerance) { //Set a not done flag GetOperations()->SetNotDone(); @@ -477,6 +495,26 @@ CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShap return GetOperations()->GetAngle(aShape1, aShape2); } +//============================================================================= +/*! + * GetAngle + */ +//============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::GetAngleBtwVectors (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shapes + Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + if (aShape1.IsNull() || aShape2.IsNull()) return -1.0; + + // Get the angle + return GetOperations()->GetAngleBtwVectors(aShape1, aShape2); +} + //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh index af88d448f..e869ecb10 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.hh +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_IMeasureOperations_i_HeaderFile #define _GEOM_IMeasureOperations_i_HeaderFile @@ -39,91 +38,96 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i : { public: GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IMeasureOperations* theImpl); + ::GEOMImpl_IMeasureOperations* theImpl); ~GEOM_IMeasureOperations_i(); GEOM::GEOM_IKindOfShape::shape_kind KindOfShape (GEOM::GEOM_Object_ptr theShape, - GEOM::ListOfLong_out theIntegers, - GEOM::ListOfDouble_out theDoubles); + GEOM::ListOfLong_out theIntegers, + GEOM::ListOfDouble_out theDoubles); void GetPosition (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz, - CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz, - CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz); + CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz, + CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz, + CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz); void GetBasicProperties (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& theLength, - CORBA::Double& theSurfArea, - CORBA::Double& theVolume); + CORBA::Double& theLength, + CORBA::Double& theSurfArea, + CORBA::Double& theVolume); GEOM::GEOM_Object_ptr GetCentreOfMass (GEOM::GEOM_Object_ptr theShape); GEOM::GEOM_Object_ptr GetNormal (GEOM::GEOM_Object_ptr theFace, - GEOM::GEOM_Object_ptr theOptionalPoint); + GEOM::GEOM_Object_ptr theOptionalPoint); - GEOM::GEOM_Object_ptr GetVertexByIndex (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr GetVertexByIndex (GEOM::GEOM_Object_ptr theObject, CORBA::Long theIndex); void GetInertia (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13, - CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23, - CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33, - CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz); + CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13, + CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23, + CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33, + CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz); void GetBoundingBox (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& Xmin, CORBA::Double& Xmax, - CORBA::Double& Ymin, CORBA::Double& Ymax, - CORBA::Double& Zmin, CORBA::Double& Zmax); + CORBA::Double& Xmin, CORBA::Double& Xmax, + CORBA::Double& Ymin, CORBA::Double& Ymax, + CORBA::Double& Zmin, CORBA::Double& Zmax); void GetTolerance (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& FaceMin, CORBA::Double& FaceMax, - CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, - CORBA::Double& VertMin, CORBA::Double& VertMax); + CORBA::Double& FaceMin, CORBA::Double& FaceMax, + CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, + CORBA::Double& VertMin, CORBA::Double& VertMax); CORBA::Boolean CheckShape (GEOM::GEOM_Object_ptr theShape, - CORBA::String_out theDescription); + CORBA::String_out theDescription); CORBA::Boolean CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape, - CORBA::String_out theDescription); + CORBA::String_out theDescription); + + char* IsGoodForSolid (GEOM::GEOM_Object_ptr theShape); char* WhatIs (GEOM::GEOM_Object_ptr theShape); GEOM::ListOfBool* AreCoordsInside (GEOM::GEOM_Object_ptr theShape, - const GEOM::ListOfDouble& theCoords, - CORBA::Double theTolerance); + const GEOM::ListOfDouble& theCoords, + CORBA::Double theTolerance); CORBA::Double GetMinDistance (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2, + GEOM::GEOM_Object_ptr theShape2, CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1, CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2); void PointCoordinates (GEOM::GEOM_Object_ptr theShape, - CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z); + CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z); CORBA::Double GetAngle (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2); + GEOM::GEOM_Object_ptr theShape2); + + CORBA::Double GetAngleBtwVectors (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2); // Methods for recieving radiuses of curvature of curves and surfaces // in the given point CORBA::Double CurveCurvatureByParam (GEOM::GEOM_Object_ptr theCurve, - CORBA::Double theParam); + CORBA::Double theParam); CORBA::Double CurveCurvatureByPoint (GEOM::GEOM_Object_ptr theCurve, - GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr thePoint); CORBA::Double MaxSurfaceCurvatureByParam (GEOM::GEOM_Object_ptr theSurf, - CORBA::Double theUParam, - CORBA::Double theVParam); + CORBA::Double theUParam, + CORBA::Double theVParam); CORBA::Double MaxSurfaceCurvatureByPoint (GEOM::GEOM_Object_ptr theSurf, - GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr thePoint); CORBA::Double MinSurfaceCurvatureByParam (GEOM::GEOM_Object_ptr theSurf, - CORBA::Double theUParam, - CORBA::Double theVParam); + CORBA::Double theUParam, + CORBA::Double theVParam); CORBA::Double MinSurfaceCurvatureByPoint (GEOM::GEOM_Object_ptr theSurf, - GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr thePoint); ::GEOMImpl_IMeasureOperations* GetOperations() { return (::GEOMImpl_IMeasureOperations*)GetImpl(); } diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index b6eb40db6..2b4e93e7a 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -85,6 +85,40 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge return GetObject(anObject); } +//============================================================================= +/*! + * MakeEdgeOnCurveByLength + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength + (GEOM::GEOM_Object_ptr theCurve, + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference curve + Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve); + if (aRefCurve.IsNull()) return aGEOMObject._retn(); + + //Get the reference point (can be NULL) + Handle(GEOM_Object) aRefPoint; + if (!CORBA::is_nil(theStartPoint)) { + aRefPoint = GetObjectImpl(theStartPoint); + } + + //Create the point + Handle(GEOM_Object) anObject = + GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeEdgeWire diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index 9cc86a989..3317c0417 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -44,6 +44,11 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2); + + GEOM::GEOM_Object_ptr MakeEdgeOnCurveByLength (GEOM::GEOM_Object_ptr theCurve, + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint); + GEOM::GEOM_Object_ptr MakeEdgeWire (GEOM::GEOM_Object_ptr theWire, const CORBA::Double theLinearTolerance, const CORBA::Double theAngularTolerance); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 6466983b1..e0ab44df4 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -591,12 +591,12 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theLength, - CORBA::Boolean theReverse) + GEOM::GEOM_Object_ptr theStartPoint) { beginService( " GEOM_Superv_i::MakePointOnCurveByLength" ); MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength"); getBasicOp(); - GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theReverse); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theStartPoint); endService( " GEOM_Superv_i::MakePointOnCurveByLength" ); return anObj; } @@ -2010,6 +2010,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEdge (GEOM::GEOM_Object_ptr thePnt1, return anObj; } +//============================================================================= +// MakeEdgeOnCurveByLength: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEdgeOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint) +{ + beginService( " GEOM_Superv_i::MakeEdgeOnCurveByLength" ); + MESSAGE("GEOM_Superv_i::MakeEdgeOnCurveByLength"); + getShapesOp(); + GEOM::GEOM_Object_ptr anObj = myShapesOp->MakeEdgeOnCurveByLength(theRefCurve, theLength, theStartPoint); + endService( " GEOM_Superv_i::MakeEdgeOnCurveByLength" ); + return anObj; +} + //============================================================================= // MakeWire: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 1dd848ad5..5f99b2465 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -151,7 +151,7 @@ public: CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theLength, - CORBA::Boolean theReverse); + GEOM::GEOM_Object_ptr theStartPoint); GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theXParameter, CORBA::Double theYParameter, @@ -465,6 +465,9 @@ public: //-----------------------------------------------------------// GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeEdgeOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theLength, + GEOM::GEOM_Object_ptr theStartPoint); GEOM::GEOM_Object_ptr MakeWire (GEOM::GEOM_List_ptr theEdgesAndWires, CORBA::Double theTolerance); GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index b681efa1b..5b89c34ff 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -62,63 +62,63 @@ def TestAll (geompy, math): precision = 0.00001 #Create base points - p0 = geompy.MakeVertex(0. , 0. , 0. ) #(3 Doubles)->GEOM_Object_ptr + p0 = geompy.MakeVertex(0. , 0. , 0. ) #(3 Doubles)->GEOM_Object px = geompy.MakeVertex(100., 0. , 0. ) py = geompy.MakeVertex(0. , 100., 0. ) pz = geompy.MakeVertex(0. , 0. , 100.) pxyz = geompy.MakeVertex(100., 100., 100.) - p200 = geompy.MakeVertexWithRef(pxyz, 100., 100., 100.) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr + p200 = geompy.MakeVertexWithRef(pxyz, 100., 100., 100.) #(GEOM_Object, 3 Doubles)->GEOM_Object #Create base directions - vx = geompy.MakeVector(p0, px) #(GEOM_Object_ptr, GEOM_Object_ptr)->GEOM_Object_ptr + vx = geompy.MakeVector(p0, px) #(GEOM_Object, GEOM_Object)->GEOM_Object vy = geompy.MakeVector(p0, py) vz = geompy.MakeVector(p0, pz) vxy = geompy.MakeVector(px, py) - vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) #(3 Doubles)->GEOM_Object_ptr + vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) #(3 Doubles)->GEOM_Object #Create local coordinate systems - cs1 = geompy.MakeMarker(50,50,50, 1,0,0, 0,1,0) #(9 Doubles)->GEOM_Object_ptr - cs2 = geompy.MakeMarker(70,80,10, 1,0,1, 1,1,0) #(9 Doubles)->GEOM_Object_ptr - cs3 = geompy.MakeMarkerPntTwoVec(pz, vxy, vz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + cs1 = geompy.MakeMarker(50,50,50, 1,0,0, 0,1,0) #(9 Doubles)->GEOM_Object + cs2 = geompy.MakeMarker(70,80,10, 1,0,1, 1,1,0) #(9 Doubles)->GEOM_Object + cs3 = geompy.MakeMarkerPntTwoVec(pz, vxy, vz) #(3 GEOM_Object)->GEOM_Object #Create base geometry 2D - Line = geompy.MakeLineTwoPnt(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Line1 = geompy.MakeLine(pz, vxy) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Line2 = geompy.MakeLineTwoPnt(pxyz, pz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object_ptr - Plane2 = geompy.MakePlane2Vec(vx, vz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - Plane3 = geompy.MakePlaneLCS(cs1, trimsize, 3) #(1 GEOM_Object_ptr, 2 Double)->GEOM_Object_ptr + Line = geompy.MakeLineTwoPnt(p0, pxyz) #(2 GEOM_Object)->GEOM_Object + Line1 = geompy.MakeLine(pz, vxy) #(2 GEOM_Object)->GEOM_Object + Line2 = geompy.MakeLineTwoPnt(pxyz, pz) #(2 GEOM_Object)->GEOM_Object + Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object, Double)->GEOM_Object + Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object + Plane2 = geompy.MakePlane2Vec(vx, vz, trimsize) #(2 GEOM_Object, Double)->GEOM_Object + Plane3 = geompy.MakePlaneLCS(cs1, trimsize, 3) #(1 GEOM_Object, 2 Double)->GEOM_Object - Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr - Arc3 = geompy.MakeArcOfEllipse(p0, px, pz) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr - Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - Circle2 = geompy.MakeCircleCenter2Pnt(p0, pxyz, py) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - Ellipse = geompy.MakeEllipse(p0, vy, radius2, radius1) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr - Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr - Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr - Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object_ptr,Boolean)->GEOM_Object_ptr + Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object)->GEOM_Object + Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object,Boolean)->GEOM_Object + Arc3 = geompy.MakeArcOfEllipse(p0, px, pz) #(3 GEOM_Object,Boolean)->GEOM_Object + Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object, Double)->GEOM_Object + Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object)->GEOM_Object + Circle2 = geompy.MakeCircleCenter2Pnt(p0, pxyz, py) #(3 GEOM_Object)->GEOM_Object + Ellipse = geompy.MakeEllipse(p0, vy, radius2, radius1) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object)->GEOM_Object + Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object)->GEOM_Object + Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->GEOM_Object Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW", - [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr + [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0]) #Create local coordinate system from shape cs4 = geompy.MakeMarkerFromShape(Plane) #Test point on curve creation - p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr - p_on_arc2 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10 ) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr - p_on_arc3 = geompy.MakeVertexOnCurveByLength(Arc, 50, True) #(GEOM_Object_ptr, Double, Boolean)->GEOM_Object_ptr + p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object, Double)->GEOM_Object + p_on_arc2 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10 ) #(GEOM_Object, Double)->GEOM_Object + p_on_arc3 = geompy.MakeVertexOnCurveByLength(Arc, 50, py) #(GEOM_Object, Double, GEOM_Object)->GEOM_Object #Test point on lines intersection - p_on_l1l2 = geompy.MakeVertexOnLinesIntersection(Line1, Line2) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + p_on_l1l2 = geompy.MakeVertexOnLinesIntersection(Line1, Line2) #(2 GEOM_Object)->GEOM_Object #Test tangent on curve creation - tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7) #(GEOM_Object, Double)->GEOM_Object #Test tangent on face creation tan_vertex_1 = geompy.MakeVertex(0, 0, 0) @@ -130,45 +130,46 @@ def TestAll (geompy, math): tan_on_face = geompy.MakeTangentPlaneOnFace(tan_extrusion, 0.7, 0.5, 150) #Create base geometry 3D - Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object_ptr - Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object_ptr - Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr - Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object_ptr - Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr - Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object_ptr - Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object_ptr - Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr - Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object_ptr - Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr - Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object_ptr + Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object)->GEOM_Object + Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object + Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object + Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object + Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object + Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object + Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object + Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object, 3 Doubles)->GEOM_Object + Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object + Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object #Boolean (Common, Cut, Fuse, Section) - Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object_ptr, Short)->GEOM_Object_ptr + Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object, Short)->GEOM_Object Cut = geompy.MakeBoolean(Box, Sphere, 2) Fuse = geompy.MakeBoolean(Box, Sphere, 3) Section = geompy.MakeBoolean(Box, Sphere, 4) #Create base objects - Edge = geompy.MakeEdge(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Wire = geompy.MakeWire([vxy, Arc]) #(List Of GEOM_Object_ptr)->GEOM_Object_ptr - Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Object_ptr, Boolean)->GEOM_Object_ptr + Edge = geompy.MakeEdge(p0, pxyz) #(2 GEOM_Object)->GEOM_Object + Edge1 = geompy.MakeEdgeOnCurveByLength(Arc, 50, px) #(GEOM_Object, Double, GEOM_Object)->GEOM_Object + Wire = geompy.MakeWire([vxy, Arc]) #(List Of GEOM_Object)->GEOM_Object + Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Object, Boolean)->GEOM_Object Face1 = geompy.MakeFaceWires([Wire, Sketcher], - WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr + WantPlanarFace) #(List of GEOM_Object, Boolean)->GEOM_Object Face2 = geompy.MakeFace(Sketcher, WantPlanarFace) - Face3 = geompy.MakeFaceHW (100., 200., 1) #(2 Doubles, 1 Int)->GEOM_Object_ptr - Face4 = geompy.MakeFaceObjHW (vz, 200., 100.) #(1 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr - Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object_ptr, 1 Double)->GEOM_Object_ptr - Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object_ptr - Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Face3 = geompy.MakeFaceHW (100., 200., 1) #(2 Doubles, 1 Int)->GEOM_Object + Face4 = geompy.MakeFaceObjHW (vz, 200., 100.) #(1 GEOM_Object, 2 Doubles)->GEOM_Object + Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object, 1 Double)->GEOM_Object + Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object)->GEOM_Object + Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object + Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object)->GEOM_Object - Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object)->GEOM_Object prism1_faces = geompy.SubShapeAllSortedCentres(Prism1, geompy.ShapeType["FACE"]) Shell1 = geompy.MakeShell([prism1_faces[0], prism1_faces[1], prism1_faces[3], prism1_faces[4], prism1_faces[5], prism1_faces[2]]) - Solid = geompy.MakeSolid([Shell1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Solid = geompy.MakeSolid([Shell1]) #(List of GEOM_Object)->GEOM_Object ShapeListCompound = [] i = 0 @@ -176,58 +177,58 @@ def TestAll (geompy, math): S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.) ShapeListCompound.append(S) i = i + 1 - Compound = geompy.MakeCompound(ShapeListCompound) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Compound = geompy.MakeCompound(ShapeListCompound) #(List of GEOM_Object)->GEOM_Object #Test point on surface creation - p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object_ptr, Double, Double)->GEOM_Object_ptr - p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object_ptr, Double, Double, Double)->GEOM_Object_ptr + p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object + p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object # Test plane from existing face creation - Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object, Double)->GEOM_Object #ShapeList for Sewing S = geompy.MakeRotation(Face, vxy, angle1) #Test Line on Faces Intersection - Line3 = geompy.MakeLineTwoFaces(prism1_faces[0], prism1_faces[1]) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Line3 = geompy.MakeLineTwoFaces(prism1_faces[0], prism1_faces[1]) #(2 GEOM_Object)->GEOM_Object #Create advanced objects - Copy = geompy.MakeCopy(Box) #(GEOM_Object_ptr)->GEOM_Object_ptr - Prism = geompy.MakePrismVecH(Face, vz, 100.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - Prism2Ways = geompy.MakePrismVecH2Ways(Face, vz, 10.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - PrismTwoPnt = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - PrismTwoPnt2Ways = geompy.MakePrism2Ways(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - PrismDXDYDZ = geompy.MakePrismDXDYDZ(Face2, 10, 20, 100)#(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - PrismDXDYDZ2Ways = geompy.MakePrismDXDYDZ2Ways(Face, 30, -20, 200)#(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Copy = geompy.MakeCopy(Box) #(GEOM_Object)->GEOM_Object + Prism = geompy.MakePrismVecH(Face, vz, 100.0) #(2 GEOM_Object, Double)->GEOM_Object + Prism2Ways = geompy.MakePrismVecH2Ways(Face, vz, 10.0) #(2 GEOM_Object, Double)->GEOM_Object + PrismTwoPnt = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object)->GEOM_Object + PrismTwoPnt2Ways = geompy.MakePrism2Ways(Face2, p0, pxyz) #(3 GEOM_Object)->GEOM_Object + PrismDXDYDZ = geompy.MakePrismDXDYDZ(Face2, 10, 20, 100)#(2 GEOM_Object, Double)->GEOM_Object + PrismDXDYDZ2Ways = geompy.MakePrismDXDYDZ2Ways(Face, 30, -20, 200)#(2 GEOM_Object, Double)->GEOM_Object Revolution = geompy.MakeRevolution(Face, vz, angle2) # Revolution2Ways = geompy.MakeRevolution(Face, vz, angle1) # Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, - tol2d, tol3d, nbiter) #(GEOM_Object_ptr, 4 Doubles, Short)->GEOM_Object_ptr - Pipe = geompy.MakePipe(Wire, Edge) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Sewing = geompy.MakeSewing([Face, S], precision) #(List Of GEOM_Object_ptr, Double)->GEOM_Object_ptr + tol2d, tol3d, nbiter) #(GEOM_Object, 4 Doubles, Short)->GEOM_Object + Pipe = geompy.MakePipe(Wire, Edge) #(2 GEOM_Object)->GEOM_Object + Sewing = geompy.MakeSewing([Face, S], precision) #(List Of GEOM_Object, Double)->GEOM_Object #Transform objects - Translation = geompy.MakeTranslationTwoPoints(Box, px, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - TranslVect = geompy.MakeTranslationVector(Box, vxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - TranslVectD = geompy.MakeTranslationVectorDistance(Box, vxyz, 50.0) #(2 GEOM_Object_ptr)->GEOM_Object_ptr - Rotation = geompy.MakeRotation(Box, vz, angle1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr - RotatPnt = geompy.MakeRotationThreePoints(Box, px, py, pz) #(4 GEOM_Object_ptr)->GEOM_Object_ptr + Translation = geompy.MakeTranslationTwoPoints(Box, px, pz) #(3 GEOM_Object)->GEOM_Object + TranslVect = geompy.MakeTranslationVector(Box, vxyz) #(2 GEOM_Object)->GEOM_Object + TranslVectD = geompy.MakeTranslationVectorDistance(Box, vxyz, 50.0) #(2 GEOM_Object)->GEOM_Object + Rotation = geompy.MakeRotation(Box, vz, angle1) #(2 GEOM_Object, Double)->GEOM_Object + RotatPnt = geompy.MakeRotationThreePoints(Box, px, py, pz) #(4 GEOM_Object)->GEOM_Object #Scale by factor relatively given point - Scale1 = geompy.MakeScaleTransform(Box, pxyz, factor) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Scale1 = geompy.MakeScaleTransform(Box, pxyz, factor) #(2 GEOM_Object, Double)->GEOM_Object #Scale by factor relatively the origin of global CS Scale2 = geompy.MakeScaleTransform(Box, None, factor) # #Scale along axes of global CS by different factors. Scale relatively given point - Scale3 = geompy.MakeScaleAlongAxes(Box, pxyz, 1.5, 0.5, 3) #(2 GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr + Scale3 = geompy.MakeScaleAlongAxes(Box, pxyz, 1.5, 0.5, 3) #(2 GEOM_Object, 3 Doubles)->GEOM_Object #Scale along axes of global CS by different factors. Scale relatively the origin of global CS Scale4 = geompy.MakeScaleAlongAxes(Box, None, 1.5, 0.5, 3) # - Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object)->GEOM_Object MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) # MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) # - Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - Position2 = geompy.PositionAlongPath(Box, Arc, 0.5, 1, 0) #(2 GEOM_Object_ptr, 1 Double, 2 Bool)->GEOM_Object_ptr - Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object)->GEOM_Object + Position2 = geompy.PositionAlongPath(Box, Arc, 0.5, 1, 0) #(2 GEOM_Object, 1 Double, 2 Bool)->GEOM_Object + Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object, Double)->GEOM_Object Orientation = geompy.ChangeOrientation(Box) #IDList for Fillet/Chamfer @@ -254,19 +255,19 @@ def TestAll (geompy, math): IDlist_f = [f_ind_1, f_ind_2] #Local operations - Fillet2d = geompy.MakeFillet2D(Face3, radius, [4, 7, 9]) #(GEOM_Object_ptr, Double, ListOfLong)->GEOM_Object_ptr + Fillet2d = geompy.MakeFillet2D(Face3, radius, [4, 7, 9]) #(GEOM_Object, Double, ListOfLong)->GEOM_Object Fillet = geompy.MakeFillet (Prism, radius, geompy.ShapeType["EDGE"], - IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr + IDlist_e) #(GEOM_Object, Double, Short, ListOfLong)->GEOM_Object Fillet2 = geompy.MakeFilletR1R2 (Prism, 7., 13., geompy.ShapeType["EDGE"], - IDlist_e) #(GEOM_Object_ptr, Double, Double, Short, ListOfLong)->GEOM_Object_ptr + IDlist_e) #(GEOM_Object, Double, Double, Short, ListOfLong)->GEOM_Object Chamfer = geompy.MakeChamferEdge(Prism, d1, d2, - f_ind_1, f_ind_2) #(GEOM_Object_ptr, 2 Doubles, 2 Long)->GEOM_Object_ptr + f_ind_1, f_ind_2) #(GEOM_Object, 2 Doubles, 2 Long)->GEOM_Object Chamfer2 = geompy.MakeChamferFaces(Prism, d1, d2, - IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr + IDlist_f) #(GEOM_Object, 2 Doubles, ListOfLong)->GEOM_Object Chamfer3 = geompy.MakeChamferEdges(Prism, d1, d2, - IDlist_e) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr + IDlist_e) #(GEOM_Object, 2 Doubles, ListOfLong)->GEOM_Object Chamfer4 = geompy.MakeChamferFacesAD(Prism, d1, 20. * math.pi / 180., - IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr + IDlist_f) #(GEOM_Object, 2 Doubles, ListOfLong)->GEOM_Object #End of Local operations #Create Patterns @@ -277,18 +278,18 @@ def TestAll (geompy, math): MultiRot2D = geompy.MultiRotate2D(Chamfer, vx, angle, nbtimes1, step1, nbtimes2) #Create Informations objects - CDG = geompy.MakeCDG(Prism) #(GEOM_Object_ptr)->GEOM_Object_ptr + CDG = geompy.MakeCDG(Prism) #(GEOM_Object)->GEOM_Object Archimede = geompy.Archimede(Box, weight, waterdensity, - meshingdeflection) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr - mindist = geompy.MinDistanceComponents(TranslVect, Mirror) #(2 GEOM_Object_ptr)->4 Doubles + meshingdeflection) #(GEOM_Object, 3 Doubles)->GEOM_Object + mindist = geompy.MinDistanceComponents(TranslVect, Mirror) #(2 GEOM_Object)->4 Doubles print "Minumal distance between TranslVect and Mirror is", mindist[0], print "by components:", mindist[1], ",", mindist[2], ",", mindist[3] - CheckShape = geompy.CheckShape(Prism) #(GEOM_Object_ptr)->Boolean + CheckShape = geompy.CheckShape(Prism) #(GEOM_Object)->Boolean print "CheckShape(Prism) = ", CheckShape #Partition objects - Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object_ptr)->GEOM_Object_ptr - Partition1 = geompy.MakeHalfPartition(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object)->GEOM_Object + Partition1 = geompy.MakeHalfPartition(Box, Plane) #(2 GEOM_Object)->GEOM_Object #Add In Study id_p0 = geompy.addToStudy(p0, "Vertex 0") @@ -331,7 +332,8 @@ def TestAll (geompy, math): id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D") id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)") - id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" ) + id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" ) + id_p_on_arc3 = geompy.addToStudy(p_on_arc3, "Vertex on Arc length 50 from Vertex X" ) id_p_on_l1l2 = geompy.addToStudy(p_on_l1l2, "Vertex on Lines Intersection") @@ -357,6 +359,7 @@ def TestAll (geompy, math): id_Section = geompy.addToStudy(Section, "Section") id_Edge = geompy.addToStudy(Edge, "Edge") + id_Edge1 = geompy.addToStudy(Edge1, "Edge on Arc length 50 from Vertex Y") id_Wire = geompy.addToStudy(Wire, "Wire") id_Face = geompy.addToStudy(Face, "Face") id_Face1 = geompy.addToStudy(Face1, "Face from two wires") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 695b9db3e..c3d4ddf77 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -514,15 +514,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a point, corresponding to the given length on the given curve. # @param theRefCurve The referenced curve. - # @param theLength Length on the referenced curve. - # @param theReverse Flag allowing to choose the direction for the calculation of the length (False = forward or True = reversed). + # @param theLength Length on the referenced curve. It can be negative. + # @param theStartPoint Point allowing to choose the direction for the calculation + # of the length. If None, start from the first point of theRefCurve. # @return New GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theReverse = False): + def MakeVertexOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None): # Example: see GEOM_TestAll.py theLength, Parameters = ParseParameters(theLength) - anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theReverse) + anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theStartPoint) RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp) anObj.SetParameters(Parameters) return anObj @@ -1636,6 +1637,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeEdge", self.ShapesOp) return anObj + ## Create a new edge, corresponding to the given length on the given curve. + # @param theRefCurve The referenced curve (edge). + # @param theLength Length on the referenced curve. It can be negative. + # @param theStartPoint Any point can be selected for it, the new edge will begin + # at the end of \a theRefCurve, close to the selected point. + # If None, start from the first point of \a theRefCurve. + # @return New GEOM_Object, containing the created edge. + # + # @ref tui_creation_edge "Example" + def MakeEdgeOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None): + # Example: see GEOM_TestAll.py + theLength, Parameters = ParseParameters(theLength) + anObj = self.ShapesOp.MakeEdgeOnCurveByLength(theRefCurve, theLength, theStartPoint) + RaiseIfFailed("MakeEdgeOnCurveByLength", self.BasicOp) + anObj.SetParameters(Parameters) + return anObj + ## Create an edge from specified wire. # @param theWire source Wire. # @param theLinearTolerance linear tolerance value.