Mantis issue 0021394: EDF 1637 GEOM: Function 'MinDistance' with creation of vertices

This commit is contained in:
jfa 2013-01-18 11:52:16 +00:00
parent b0deb14544
commit 7d2fc6b422
21 changed files with 446 additions and 1098 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -5,7 +5,13 @@
Returns the minimum distance between two geometrical objects and Returns the minimum distance between two geometrical objects and
the coordinates of the vector of distance and shows the vector in the viewer. the coordinates of the vector of distance and shows the vector in the viewer.
<b>TUI Command:</b> <em>geompy.MinDistance(Shape1, Shape2),</em> \n On \b Apply or <b>Apply and Close</b> it creates a set of closest
points of the shapes.
<b>TUI Commands:</b>
\n<em>aDist = geompy.MinDistance(Shape1, Shape2),</em>
\n<em>[aDist, DX, DY, DZ] = geompy.MinDistanceComponents(Shape1, Shape2),</em>
\n<em>[nbSols, (x11, y11, z11, x21, y21, z21, ...)] = geompy.ClosestPoints(Shape1, Shape2),</em>
where \em Shape1 and \em Shape2 are shapes between which the minimal where \em Shape1 and \em Shape2 are shapes between which the minimal
distance is computed. distance is computed.

View File

@ -5,11 +5,51 @@
\code \code
import geompy import geompy
# create boxes # Create two curves with three closest points
box1 = geompy.MakeBoxDXDYDZ(100,30,100) Vertex_1 = geompy.MakeVertex(0, 0, 0)
box2 = geompy.MakeBox(105,0,0,200,30,100) Vertex_2 = geompy.MakeVertex(0, 70, 0)
min_dist = geompy.MinDistance(box1,box2) Vertex_3 = geompy.MakeVertex(30, 100, 0)
print "\nMinimal distance between box1 and box2 = ", min_dist Vertex_4 = geompy.MakeVertex(60, 70, 0)
Vertex_5 = geompy.MakeVertex(90, 100, 0)
Vertex_6 = geompy.MakeVertex(120, 70, 0)
Vertex_7 = geompy.MakeVertex(120, 0, 0)
Vertex_8 = geompy.MakeVertex(90, -30, 0)
Vertex_9 = geompy.MakeVertex(60, 0, 0)
Vertex_10 = geompy.MakeVertex(30, -30, 0)
geompy.addToStudy( Vertex_1, 'Vertex_1' )
geompy.addToStudy( Vertex_2, 'Vertex_2' )
geompy.addToStudy( Vertex_3, 'Vertex_3' )
geompy.addToStudy( Vertex_4, 'Vertex_4' )
geompy.addToStudy( Vertex_5, 'Vertex_5' )
geompy.addToStudy( Vertex_6, 'Vertex_6' )
geompy.addToStudy( Vertex_7, 'Vertex_7' )
geompy.addToStudy( Vertex_8, 'Vertex_8' )
geompy.addToStudy( Vertex_9, 'Vertex_9' )
geompy.addToStudy( Vertex_10, 'Vertex_10' )
Curve_a = geompy.MakeInterpol([Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6], False, True)
Curve_b = geompy.MakeInterpol([Vertex_1, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, True)
geompy.addToStudy( Curve_a, 'Curve_a' )
geompy.addToStudy( Curve_b, 'Curve_b' )
# Get all closest points
[nbSols, listCoords] = geompy.ClosestPoints(Curve_a, Curve_b)
for i in range(nbSols):
v1 = geompy.MakeVertex(listCoords[i*6 + 0], listCoords[i*6 + 1], listCoords[i*6 + 2])
v2 = geompy.MakeVertex(listCoords[i*6 + 3], listCoords[i*6 + 4], listCoords[i*6 + 5])
geompy.addToStudy(v1, 'MinDist_%d_Curve_a'%(i+1))
geompy.addToStudy(v2, 'MinDist_%d_Curve_b'%(i+1))
# Get minimum distance
print "Minimal distance between Curve_a and Curve_b is", geompy.MinDistance(Curve_a, Curve_b)
# Get minimum distance with components along axes
[aDist, DX, DY, DZ] = geompy.MinDistanceComponents(Curve_a, Curve_b)
print "Minimal distance between Curve_a and Curve_b is (", DX, ",", DY, ",", DZ, ")"
\endcode \endcode
*/ */

View File

@ -217,34 +217,6 @@ DlgRef_1Sel3Spin1Check::~DlgRef_1Sel3Spin1Check()
{ {
} }
//////////////////////////////////////////
// DlgRef_1Sel4Spin2Check
//////////////////////////////////////////
DlgRef_1Sel4Spin2Check::DlgRef_1Sel4Spin2Check( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
DlgRef_1Sel4Spin2Check::~DlgRef_1Sel4Spin2Check()
{
}
//////////////////////////////////////////
// DlgRef_1Sel4Spin
//////////////////////////////////////////
DlgRef_1Sel4Spin::DlgRef_1Sel4Spin( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
DlgRef_1Sel4Spin::~DlgRef_1Sel4Spin()
{
}
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_1Sel5Spin1Check // DlgRef_1Sel5Spin1Check
////////////////////////////////////////// //////////////////////////////////////////
@ -259,20 +231,6 @@ DlgRef_1Sel5Spin1Check::~DlgRef_1Sel5Spin1Check()
{ {
} }
//////////////////////////////////////////
// DlgRef_1Sel5Spin
//////////////////////////////////////////
DlgRef_1Sel5Spin::DlgRef_1Sel5Spin( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
DlgRef_1Sel5Spin::~DlgRef_1Sel5Spin()
{
}
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_1Spin // DlgRef_1Spin
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -258,38 +258,6 @@ public:
~DlgRef_1Sel3Spin1Check(); ~DlgRef_1Sel3Spin1Check();
}; };
//////////////////////////////////////////
// DlgRef_1Sel4Spin2Check
//////////////////////////////////////////
#include "ui_DlgRef_1Sel4Spin2Check_QTD.h"
class DLGREF_EXPORT DlgRef_1Sel4Spin2Check : public QWidget,
public Ui::DlgRef_1Sel4Spin2Check_QTD
{
Q_OBJECT
public:
DlgRef_1Sel4Spin2Check( QWidget* = 0, Qt::WindowFlags = 0 );
~DlgRef_1Sel4Spin2Check();
};
//////////////////////////////////////////
// DlgRef_1Sel4Spin
//////////////////////////////////////////
#include "ui_DlgRef_1Sel4Spin_QTD.h"
class DLGREF_EXPORT DlgRef_1Sel4Spin : public QWidget,
public Ui::DlgRef_1Sel4Spin_QTD
{
Q_OBJECT
public:
DlgRef_1Sel4Spin( QWidget* = 0, Qt::WindowFlags = 0 );
~DlgRef_1Sel4Spin();
};
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_1Sel5Spin1Check // DlgRef_1Sel5Spin1Check
////////////////////////////////////////// //////////////////////////////////////////
@ -306,22 +274,6 @@ public:
~DlgRef_1Sel5Spin1Check(); ~DlgRef_1Sel5Spin1Check();
}; };
//////////////////////////////////////////
// DlgRef_1Sel5Spin
//////////////////////////////////////////
#include "ui_DlgRef_1Sel5Spin_QTD.h"
class DLGREF_EXPORT DlgRef_1Sel5Spin : public QWidget,
public Ui::DlgRef_1Sel5Spin_QTD
{
Q_OBJECT
public:
DlgRef_1Sel5Spin( QWidget* = 0, Qt::WindowFlags = 0 );
~DlgRef_1Sel5Spin();
};
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_1Spin // DlgRef_1Spin
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -1,211 +0,0 @@
<ui version="4.0" >
<class>DlgRef_1Sel4Spin2Check_QTD</class>
<widget class="QWidget" name="DlgRef_1Sel4Spin2Check_QTD" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>156</width>
<height>120</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="GroupBox1" >
<property name="title" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL1</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="PushButton1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="LineEdit1" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="TextLabel2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL2</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="TextLabel3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL3</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="TextLabel4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL4</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DZ" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="TextLabel5" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL5</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_SC" />
</item>
<item row="5" column="0" colspan="3" >
<widget class="QCheckBox" name="CheckBox1" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3" >
<widget class="QCheckBox" name="CheckBox2" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>PushButton1</tabstop>
<tabstop>LineEdit1</tabstop>
<tabstop>SpinBox_DX</tabstop>
<tabstop>SpinBox_DY</tabstop>
<tabstop>SpinBox_DZ</tabstop>
<tabstop>SpinBox_SC</tabstop>
<tabstop>CheckBox1</tabstop>
<tabstop>CheckBox2</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,214 +0,0 @@
<ui version="4.0" >
<class>DlgRef_1Sel4Spin_QTD</class>
<widget class="QWidget" name="DlgRef_1Sel4Spin_QTD" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>271</width>
<height>117</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="GroupBox1" >
<property name="title" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<widget class="QLabel" name="TextLabel6" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL6</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_S" />
</item>
<item row="1" column="0" colspan="3" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string/>
</property>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QLabel" name="TextLabel3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL3</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
</item>
<item>
<widget class="QLabel" name="TextLabel4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL4</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
</item>
<item>
<widget class="QLabel" name="TextLabel5" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL5</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DZ" />
</item>
</layout>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="LineEdit1" />
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="PushButton1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL1</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>PushButton1</tabstop>
<tabstop>LineEdit1</tabstop>
<tabstop>SpinBox_DX</tabstop>
<tabstop>SpinBox_DY</tabstop>
<tabstop>SpinBox_DZ</tabstop>
<tabstop>SpinBox_S</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,232 +0,0 @@
<ui version="4.0" >
<class>DlgRef_1Sel5Spin_QTD</class>
<widget class="QWidget" name="DlgRef_1Sel5Spin_QTD" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<height>123</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="GroupBox1" >
<property name="title" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="1" column="0" colspan="3" >
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<widget class="QLabel" name="TextLabel4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL4</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="TextLabel3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL3</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox5" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL2</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox1" />
</item>
<item row="1" column="2" >
<widget class="QLabel" name="TextLabel6" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL6</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox2" />
</item>
<item row="2" column="1" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox3" />
</item>
<item row="1" column="1" >
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox4" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="TextLabel5" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL5</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="PushButton1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL1</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="LineEdit1" />
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>PushButton1</tabstop>
<tabstop>LineEdit1</tabstop>
<tabstop>SpinBox1</tabstop>
<tabstop>SpinBox2</tabstop>
<tabstop>SpinBox4</tabstop>
<tabstop>SpinBox5</tabstop>
<tabstop>SpinBox3</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -48,10 +48,7 @@ UIC_FILES = \
ui_DlgRef_1Sel3Spin_QTD.h \ ui_DlgRef_1Sel3Spin_QTD.h \
ui_DlgRef_1Sel3Spin1Check_QTD.h \ ui_DlgRef_1Sel3Spin1Check_QTD.h \
ui_DlgRef_1Sel3Spin2Check1Spin_QTD.h \ ui_DlgRef_1Sel3Spin2Check1Spin_QTD.h \
ui_DlgRef_1Sel4Spin2Check_QTD.h \
ui_DlgRef_1Sel4Spin_QTD.h \
ui_DlgRef_1Sel5Spin1Check_QTD.h \ ui_DlgRef_1Sel5Spin1Check_QTD.h \
ui_DlgRef_1Sel5Spin_QTD.h \
ui_DlgRef_1Sel_QTD.h \ ui_DlgRef_1Sel_QTD.h \
ui_DlgRef_1SelExt_QTD.h \ ui_DlgRef_1SelExt_QTD.h \
ui_DlgRef_1Spin_QTD.h \ ui_DlgRef_1Spin_QTD.h \

View File

@ -1082,6 +1082,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_MINDIST_TITLE</source> <source>GEOM_MINDIST_TITLE</source>
<translation>Minimun Distance Between Two Objects</translation> <translation>Minimun Distance Between Two Objects</translation>
</message> </message>
<message>
<source>GEOM_MINDIST_NAME</source>
<translation>MinDist</translation>
</message>
<message> <message>
<source>GEOM_MIRROR</source> <source>GEOM_MIRROR</source>
<translation>Mirror</translation> <translation>Mirror</translation>
@ -1202,6 +1206,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SOURCE_OBJECT</source> <source>GEOM_SOURCE_OBJECT</source>
<translation>Source vertex, edge or wire</translation> <translation>Source vertex, edge or wire</translation>
</message> </message>
<message>
<source>GEOM_SOLUTION</source>
<translation>Solution :</translation>
</message>
<message> <message>
<source>GEOM_TARGET_OBJECT</source> <source>GEOM_TARGET_OBJECT</source>
<translation>Target face</translation> <translation>Target face</translation>

View File

@ -1542,6 +1542,36 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object)
return Astr; return Astr;
} }
//=============================================================================
/*!
* AreCoordsInside
*/
//=============================================================================
std::vector<bool> GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape,
const std::vector<double>& coords,
double tolerance)
{
std::vector<bool> res;
if (!theShape.IsNull()) {
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
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 ) );
}
}
}
}
return res;
}
//======================================================================= //=======================================================================
//function : CheckSingularCase //function : CheckSingularCase
@ -1845,38 +1875,6 @@ static bool CheckSingularCase(const TopoDS_Shape& aSh1,
} }
*/ */
//=============================================================================
/*!
* AreCoordsInside
*/
//=============================================================================
std::vector<bool> GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape,
const std::vector<double>& coords,
double tolerance)
{
std::vector<bool> res;
if (!theShape.IsNull()) {
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
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 ) );
}
}
}
}
return res;
}
//============================================================================= //=============================================================================
/*! /*!
* GetMinDistance * GetMinDistance
@ -1941,7 +1939,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance
// additional workaround for bugs 19899, 19908 and 19910 from Mantis // additional workaround for bugs 19899, 19908 and 19910 from Mantis
gp_Pnt Ptmp1, Ptmp2; gp_Pnt Ptmp1, Ptmp2;
double dist = CheckSingularCase(aShape1, aShape2, Ptmp1, Ptmp2); double dist = CheckSingularCase(aShape1, aShape2, Ptmp1, Ptmp2);
if(dist>-1.0) { if (dist > -1.0) {
Ptmp1.Coord(X1, Y1, Z1); Ptmp1.Coord(X1, Y1, Z1);
Ptmp2.Coord(X2, Y2, Z2); Ptmp2.Coord(X2, Y2, Z2);
SetErrorCode(OK); SetErrorCode(OK);
@ -1978,6 +1976,84 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance
return MinDist; return MinDist;
} }
//=======================================================================
/*!
* Get coordinates of closest points of two shapes
*/
//=======================================================================
Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object) theShape1,
Handle(GEOM_Object) theShape2,
Handle(TColStd_HSequenceOfReal)& theDoubles)
{
SetErrorCode(KO);
Standard_Integer nbSolutions = 0;
if (theShape1.IsNull() || theShape2.IsNull()) return nbSolutions;
Handle(GEOM_Function) aRefShape1 = theShape1->GetLastFunction();
Handle(GEOM_Function) aRefShape2 = theShape2->GetLastFunction();
if (aRefShape1.IsNull() || aRefShape2.IsNull()) return nbSolutions;
TopoDS_Shape aShape1 = aRefShape1->GetValue();
TopoDS_Shape aShape2 = aRefShape2->GetValue();
if (aShape1.IsNull() || aShape2.IsNull()) {
SetErrorCode("One of Objects has NULL Shape");
return nbSolutions;
}
// Compute the extremities
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
// skl 30.06.2008
// additional workaround for bugs 19899, 19908 and 19910 from Mantis
gp_Pnt P1, P2;
double dist = CheckSingularCase(aShape1, aShape2, P1, P2);
if (dist > -1.0) {
nbSolutions = 1;
theDoubles->Append(P1.X());
theDoubles->Append(P1.Y());
theDoubles->Append(P1.Z());
theDoubles->Append(P2.X());
theDoubles->Append(P2.Y());
theDoubles->Append(P2.Z());
SetErrorCode(OK);
return nbSolutions;
}
BRepExtrema_DistShapeShape dst (aShape1, aShape2);
if (dst.IsDone()) {
nbSolutions = dst.NbSolution();
if (theDoubles.IsNull()) theDoubles = new TColStd_HSequenceOfReal;
gp_Pnt P1, P2;
for (int i = 1; i <= nbSolutions; i++) {
P1 = dst.PointOnShape1(i);
P2 = dst.PointOnShape2(i);
theDoubles->Append(P1.X());
theDoubles->Append(P1.Y());
theDoubles->Append(P1.Z());
theDoubles->Append(P2.X());
theDoubles->Append(P2.Y());
theDoubles->Append(P2.Z());
}
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return nbSolutions;
}
SetErrorCode(OK);
return nbSolutions;
}
//======================================================================= //=======================================================================
/*! /*!
* Get coordinates of point * Get coordinates of point

View File

@ -144,6 +144,10 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2); Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2);
Standard_EXPORT Standard_Integer ClosestPoints (Handle(GEOM_Object) theShape1,
Handle(GEOM_Object) theShape2,
Handle(TColStd_HSequenceOfReal)& theDoubles);
Standard_EXPORT void PointCoordinates (Handle(GEOM_Object) theShape, Standard_EXPORT void PointCoordinates (Handle(GEOM_Object) theShape,
Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ); Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ);

View File

@ -531,7 +531,7 @@ CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
// allocate the CORBA array // allocate the CORBA array
int nbSols = -1; int nbSols = 0;
GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble(); GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
//Get the reference shape //Get the reference shape
@ -541,23 +541,12 @@ CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints
if (!aShape1.IsNull() && !aShape2.IsNull()) { if (!aShape1.IsNull() && !aShape2.IsNull()) {
Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal; Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal;
// Get shape parameters // Get shape parameters
//nbSols = GetOperations()->ClosestPoints(aShape1, aShape2, aDoubles); nbSols = GetOperations()->ClosestPoints(aShape1, aShape2, aDoubles);
//int nbDbls = aDoubles->Length(); int nbDbls = aDoubles->Length();
//aDoublesArray->length(nbDbls); aDoublesArray->length(nbDbls);
//for (int id = 0; id < nbDbls; id++) { for (int id = 0; id < nbDbls; id++) {
// aDoublesArray[id] = aDoubles->Value(id + 1); aDoublesArray[id] = aDoubles->Value(id + 1);
//} }
// tmp
double X1, Y1, Z1, X2, Y2, Z2;
GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2);
aDoublesArray->length(6);
aDoublesArray[0] = X1;
aDoublesArray[1] = Y1;
aDoublesArray[2] = Z1;
aDoublesArray[3] = X2;
aDoublesArray[4] = Y2;
aDoublesArray[5] = Z2;
nbSols = 1;
} }
theCoords = aDoublesArray._retn(); theCoords = aDoublesArray._retn();

View File

@ -164,6 +164,16 @@ def TestMeasureOperations (geompy, math):
print "\nMinimal distance between Box and Cube = ", MinDistComps[0] print "\nMinimal distance between Box and Cube = ", MinDistComps[0]
print "Its components are (", MinDistComps[1], ", ", MinDistComps[2], ", ", MinDistComps[3], ")" print "Its components are (", MinDistComps[1], ", ", MinDistComps[2], ", ", MinDistComps[3], ")"
# Get all closest points
[nbSols, listCoords] = geompy.ClosestPoints(box, cube)
for i in range(nbSols):
v1 = geompy.MakeVertex(listCoords[i*6 + 0], listCoords[i*6 + 1], listCoords[i*6 + 2])
v2 = geompy.MakeVertex(listCoords[i*6 + 3], listCoords[i*6 + 4], listCoords[i*6 + 5])
geompy.addToStudy(v1, 'MinDist_%d_on_Box'%(i+1))
geompy.addToStudy(v2, 'MinDist_%d_on_Cube'%(i+1))
pass
####### Angle ####### ####### Angle #######
OX = geompy.MakeVectorDXDYDZ(10, 0,0) OX = geompy.MakeVectorDXDYDZ(10, 0,0)

View File

@ -8878,6 +8878,28 @@ class geompyDC(GEOM._objref_GEOM_Gen):
aRes = [aTuple[0], aTuple[4] - aTuple[1], aTuple[5] - aTuple[2], aTuple[6] - aTuple[3]] aRes = [aTuple[0], aTuple[4] - aTuple[1], aTuple[5] - aTuple[2], aTuple[6] - aTuple[3]]
return aRes return aRes
## Get closest points of the given shapes.
# @param theShape1,theShape2 Shapes to find closest points of.
# @return The number of found solutions (-1 in case of infinite number of
# solutions) and a list of (X, Y, Z) coordinates for all couples of points.
#
# @ref tui_measurement_tools_page "Example"
def ClosestPoints (self, theShape1, theShape2):
"""
Get closest points of the given shapes.
Parameters:
theShape1,theShape2 Shapes to find closest points of.
Returns:
The number of found solutions (-1 in case of infinite number of
solutions) and a list of (X, Y, Z) coordinates for all couples of points.
"""
# Example: see GEOM_TestMeasures.py
aTuple = self.MeasuOp.ClosestPoints(theShape1, theShape2)
RaiseIfFailed("ClosestPoints", self.MeasuOp)
return aTuple
## Get angle between the given shapes in degrees. ## Get angle between the given shapes in degrees.
# @param theShape1,theShape2 Lines or linear edges to find angle between. # @param theShape1,theShape2 Lines or linear edges to find angle between.
# @note If both arguments are vectors, the angle is computed in accordance # @note If both arguments are vectors, the angle is computed in accordance

View File

@ -15,7 +15,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# GEOM MEASUREGUI : # GEOM MEASUREGUI :
# File : Makefile.am # File : Makefile.am
@ -95,7 +94,6 @@ UIC_FILES = \
ui_MeasureGUI_1Sel3LineEdit_QTD.h \ ui_MeasureGUI_1Sel3LineEdit_QTD.h \
ui_MeasureGUI_1Sel6LineEdit_QTD.h \ ui_MeasureGUI_1Sel6LineEdit_QTD.h \
ui_MeasureGUI_2Sel1LineEdit_QTD.h \ ui_MeasureGUI_2Sel1LineEdit_QTD.h \
ui_MeasureGUI_2Sel4LineEdit_QTD.h \
ui_MeasureGUI_SkeletonBox_QTD.h ui_MeasureGUI_SkeletonBox_QTD.h
BUILT_SOURCES = $(UIC_FILES) BUILT_SOURCES = $(UIC_FILES)

View File

@ -1,189 +0,0 @@
<ui version="4.0" >
<class>MeasureGUI_2Sel4LineEdit_QTD</class>
<widget class="QWidget" name="MeasureGUI_2Sel4LineEdit_QTD" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>198</width>
<height>197</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="GroupBox1" >
<property name="title" >
<string/>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL1</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="PushButton1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="LineEdit1" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="TextLabel2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL2</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="PushButton2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="LineEdit2" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="TextLabel3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL3</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="LineEdit3" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="TextLabel4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL4</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<widget class="QLineEdit" name="LineEdit4" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="TextLabel5" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL5</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2" >
<widget class="QLineEdit" name="LineEdit5" />
</item>
<item row="5" column="0" >
<widget class="QLabel" name="TextLabel6" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>TL6</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2" >
<widget class="QLineEdit" name="LineEdit6" />
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -77,19 +77,28 @@ MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg (GeometryGUI* GUI, QWidget* paren
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
myGrp = new MeasureGUI_2Sel4LineEdit (centralWidget()); mainFrame()->GroupBoxName->hide();
myGrp = new MeasureGUI_DistanceGroup (centralWidget());
myGrp->GroupBox1->setTitle(tr("GEOM_MINDIST_OBJ")); myGrp->GroupBox1->setTitle(tr("GEOM_MINDIST_OBJ"));
// Arguments
myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
myGrp->PushButton1->setIcon(image1);
myGrp->PushButton2->setIcon(image1);
myGrp->LineEdit1->setReadOnly(true);
myGrp->LineEdit2->setReadOnly(true);
// Solutions combobox
myGrp->TextLabel7->setText(tr("GEOM_SOLUTION"));
// Distance, dx, dy and dz
myGrp->TextLabel3->setText(tr("GEOM_LENGTH")); myGrp->TextLabel3->setText(tr("GEOM_LENGTH"));
myGrp->TextLabel4->setText(tr("GEOM_DX")); myGrp->TextLabel4->setText(tr("GEOM_DX"));
myGrp->TextLabel5->setText(tr("GEOM_DY")); myGrp->TextLabel5->setText(tr("GEOM_DY"));
myGrp->TextLabel6->setText(tr("GEOM_DZ")); myGrp->TextLabel6->setText(tr("GEOM_DZ"));
myGrp->LineEdit3->setReadOnly(true); myGrp->LineEdit3->setReadOnly(true);
myGrp->PushButton1->setIcon(image1);
myGrp->PushButton2->setIcon(image1);
myGrp->LineEdit1->setReadOnly(true);
myGrp->LineEdit2->setReadOnly(true);
myGrp->LineEdit4->setReadOnly(true); myGrp->LineEdit4->setReadOnly(true);
myGrp->LineEdit5->setReadOnly(true); myGrp->LineEdit5->setReadOnly(true);
myGrp->LineEdit6->setReadOnly(true); myGrp->LineEdit6->setReadOnly(true);
@ -128,10 +137,11 @@ void MeasureGUI_DistanceDlg::Init()
connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(myGrp->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGrp->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(myGrp->ComboBox1, SIGNAL(currentIndexChanged(int)), this, SLOT(SolutionSelected(int)));
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()));
initName(tr("GEOM_DISTANCE"));
globalSelection(); globalSelection();
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -184,6 +194,38 @@ void MeasureGUI_DistanceDlg::enterEvent(QEvent*)
ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : SolutionSelected()
// purpose : Called when ComboBox selection has changed
//=================================================================================
void MeasureGUI_DistanceDlg::SolutionSelected (int i)
{
if (i < 0 || myDbls->length() <= i*6) {
myGrp->LineEdit3->setText("");
myGrp->LineEdit4->setText("");
myGrp->LineEdit5->setText("");
myGrp->LineEdit6->setText("");
erasePreview();
return;
}
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
gp_Pnt p1 (myDbls[i*6 + 0], myDbls[i*6 + 1], myDbls[i*6 + 2]);
gp_Pnt p2 (myDbls[i*6 + 3], myDbls[i*6 + 4], myDbls[i*6 + 5]);
double aDist = p1.Distance(p2);
myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(aDist, aPrecision));
gp_XYZ aVec = p2.XYZ() - p1.XYZ();
myGrp->LineEdit4->setText(DlgRef::PrintDoubleValue(aVec.X(), aPrecision));
myGrp->LineEdit5->setText(DlgRef::PrintDoubleValue(aVec.Y(), aPrecision));
myGrp->LineEdit6->setText(DlgRef::PrintDoubleValue(aVec.Z(), aPrecision));
redisplayPreview();
}
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection has changed
@ -260,56 +302,29 @@ void MeasureGUI_DistanceDlg::processObject()
myGrp->LineEdit1->setText(!myObj1->_is_nil() ? GEOMBase::GetName(myObj1) : ""); myGrp->LineEdit1->setText(!myObj1->_is_nil() ? GEOMBase::GetName(myObj1) : "");
myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : ""); myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : "");
gp_Pnt aPnt1, aPnt2; myGrp->ComboBox1->clear();
double aDist = 0.;
if (getParameters(aDist, aPnt1, aPnt2)) {
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(aDist, aPrecision));
gp_XYZ aVec = aPnt2.XYZ() - aPnt1.XYZ();
myGrp->LineEdit4->setText(DlgRef::PrintDoubleValue(aVec.X(), aPrecision));
myGrp->LineEdit5->setText(DlgRef::PrintDoubleValue(aVec.Y(), aPrecision));
myGrp->LineEdit6->setText(DlgRef::PrintDoubleValue(aVec.Z(), aPrecision));
redisplayPreview();
}
else {
myGrp->LineEdit3->setText("");
myGrp->LineEdit4->setText("");
myGrp->LineEdit5->setText("");
myGrp->LineEdit6->setText("");
erasePreview(); erasePreview();
}
}
//================================================================================= int nbSols = 0;
// function : getParameters()
// purpose : Get distance between objects
//=================================================================================
bool MeasureGUI_DistanceDlg::getParameters (double& theDistance, gp_Pnt& thePnt1, gp_Pnt& thePnt2)
{
QString msg; QString msg;
if (isValid(msg)) { if (!isValid(msg)) return;
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
try { try {
double x1, y1, z1, x2, y2, z2; nbSols = anOper->ClosestPoints(myObj1, myObj2, myDbls);
theDistance = anOper->GetMinDistance(myObj1, myObj2, x1, y1, z1, x2, y2, z2);
thePnt1.SetCoord(x1, y1, z1);
thePnt2.SetCoord(x2, y2, z2);
} }
catch (const SALOME::SALOME_Exception& e) { catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e); SalomeApp_Tools::QtCatchCorbaException(e);
return false; return;
} }
return anOper->IsDone(); if (anOper->IsDone() && nbSols > 0) {
for (int i = 0; i < nbSols; i++) {
myGrp->ComboBox1->addItem(QString("Solution %1").arg(i + 1));
}
myGrp->ComboBox1->setCurrentIndex(0);
} }
return false;
} }
//================================================================================= //=================================================================================
@ -318,16 +333,19 @@ bool MeasureGUI_DistanceDlg::getParameters (double& theDistance, gp_Pnt& thePnt1
//================================================================================= //=================================================================================
SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs()
{ {
double aDist = 0.;
gp_Pnt aPnt1 (0, 0, 0), aPnt2 (0, 0, 0);
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
if (myObj1->_is_nil() || myObj2->_is_nil() || int currSol = myGrp->ComboBox1->currentIndex();
!getParameters(aDist, aPnt1, aPnt2) ||
if (myObj1->_is_nil() || myObj2->_is_nil() || currSol == -1 ||
vw->getViewManager()->getType() != OCCViewer_Viewer::Type()) vw->getViewManager()->getType() != OCCViewer_Viewer::Type())
return 0; return 0;
gp_Pnt aPnt1 (myDbls[currSol*6 + 0], myDbls[currSol*6 + 1], myDbls[currSol*6 + 2]);
gp_Pnt aPnt2 (myDbls[currSol*6 + 3], myDbls[currSol*6 + 4], myDbls[currSol*6 + 5]);
double aDist = aPnt1.Distance(aPnt2);
try try
{ {
if (aDist <= 1.e-9) { if (aDist <= 1.e-9) {
@ -408,16 +426,20 @@ bool MeasureGUI_DistanceDlg::execute (ObjectList& objects)
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
GEOM::GEOM_IBasicOperations_var aBasicOper = getGeomEngine()->GetIBasicOperations(getStudyId()); GEOM::GEOM_IBasicOperations_var aBasicOper = getGeomEngine()->GetIBasicOperations(getStudyId());
double x1, y1, z1, x2, y2, z2; GEOM::ListOfDouble_var aDbls;
double aDist = anOper->GetMinDistance(myObj1, myObj2, x1, y1, z1, x2, y2, z2); int nbSols = anOper->ClosestPoints(myObj1, myObj2, aDbls);
GEOM::GEOM_Object_var anObj1 = aBasicOper->MakePointXYZ(x1, y1, z1); if (anOper->IsDone()) {
GEOM::GEOM_Object_var anObj2 = aBasicOper->MakePointXYZ(x2, y2, z2); for (int i = 0; i < nbSols; i++) {
GEOM::GEOM_Object_var anObj1 = aBasicOper->MakePointXYZ(aDbls[i*6 + 0], aDbls[i*6 + 1], aDbls[i*6 + 2]);
GEOM::GEOM_Object_var anObj2 = aBasicOper->MakePointXYZ(aDbls[i*6 + 3], aDbls[i*6 + 4], aDbls[i*6 + 5]);
if (!anObj1->_is_nil() && !anObj2->_is_nil()) { if (!anObj1->_is_nil() && !anObj2->_is_nil()) {
objects.push_back(anObj1._retn()); objects.push_back(anObj1._retn());
objects.push_back(anObj2._retn()); objects.push_back(anObj2._retn());
} }
}
}
return true; return true;
} }
@ -449,3 +471,95 @@ void MeasureGUI_DistanceDlg::redisplayPreview()
SalomeApp_Tools::QtCatchCorbaException(e); SalomeApp_Tools::QtCatchCorbaException(e);
} }
} }
//================================================================
// Function : getNewObjectName
// Purpose : Redefine this method to return proper name for a new object
//================================================================
QString MeasureGUI_DistanceDlg::getNewObjectName (int currObj) const
{
QString aName = tr("GEOM_MINDIST_NAME") + QString("_%1_").arg((currObj+1)/2);
aName += GEOMBase::GetName(currObj%2 ? myObj1 : myObj2);
return aName;
}
//=================================================================================
// function : MeasureGUI_DistanceGroup
// purpose :
//=================================================================================
MeasureGUI_DistanceGroup::MeasureGUI_DistanceGroup (QWidget *parent)
{
gridLayout = new QGridLayout (parent);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
gridLayout->setHorizontalSpacing(0);
gridLayout->setVerticalSpacing(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
GroupBox1 = new QGroupBox (parent);
gridLayout1 = new QGridLayout (GroupBox1);
gridLayout1->setSpacing(6);
gridLayout1->setContentsMargins(11, 11, 11, 11);
gridLayout1->setHorizontalSpacing(6);
gridLayout1->setVerticalSpacing(6);
gridLayout1->setContentsMargins(9, 9, 9, 9);
// 2Sel
TextLabel1 = new QLabel(GroupBox1);
TextLabel2 = new QLabel(GroupBox1);
PushButton1 = new QPushButton (GroupBox1);
PushButton2 = new QPushButton (GroupBox1);
LineEdit1 = new QLineEdit(GroupBox1);
LineEdit2 = new QLineEdit(GroupBox1);
gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
gridLayout1->addWidget(PushButton1, 0, 1, 1, 1);
gridLayout1->addWidget(PushButton2, 1, 1, 1, 1);
gridLayout1->addWidget(LineEdit1, 0, 2, 1, 1);
gridLayout1->addWidget(LineEdit2, 1, 2, 1, 1);
// 1Combo
TextLabel7 = new QLabel (GroupBox1);
ComboBox1 = new QComboBox (GroupBox1);
gridLayout1->addWidget(TextLabel7, 2, 0, 1, 1);
gridLayout1->addWidget(ComboBox1, 2, 1, 1, 2);
// 4Text
TextLabel3 = new QLabel (GroupBox1);
TextLabel4 = new QLabel (GroupBox1);
TextLabel5 = new QLabel (GroupBox1);
TextLabel6 = new QLabel (GroupBox1);
LineEdit3 = new QLineEdit(GroupBox1);
LineEdit4 = new QLineEdit(GroupBox1);
LineEdit5 = new QLineEdit(GroupBox1);
LineEdit6 = new QLineEdit(GroupBox1);
gridLayout1->addWidget(TextLabel3, 3, 0, 1, 1);
gridLayout1->addWidget(TextLabel4, 4, 0, 1, 1);
gridLayout1->addWidget(TextLabel5, 5, 0, 1, 1);
gridLayout1->addWidget(TextLabel6, 6, 0, 1, 1);
gridLayout1->addWidget(LineEdit3, 3, 1, 1, 2);
gridLayout1->addWidget(LineEdit4, 4, 1, 1, 2);
gridLayout1->addWidget(LineEdit5, 5, 1, 1, 2);
gridLayout1->addWidget(LineEdit6, 6, 1, 1, 2);
gridLayout->addWidget(GroupBox1, 0, 0, 1, 1);
}
//=================================================================================
// function : ~MeasureGUI_DistanceGroup()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
MeasureGUI_DistanceGroup::~MeasureGUI_DistanceGroup()
{
// no need to delete child widgets, Qt does it all for us
}

View File

@ -28,9 +28,59 @@
#include <GEOMBase_Skeleton.h> #include <GEOMBase_Skeleton.h>
class MeasureGUI_2Sel4LineEdit; // IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
class gp_Pnt; class gp_Pnt;
//=================================================================================
// class : MeasureGUI_DistanceGroup
// purpose :
//=================================================================================
class MeasureGUI_DistanceGroup : public QWidget
{
Q_OBJECT
public:
MeasureGUI_DistanceGroup (QWidget *parent);
~MeasureGUI_DistanceGroup();
public:
QGridLayout *gridLayout;
QGroupBox *GroupBox1;
QGridLayout *gridLayout1;
// 2Sel
QLabel *TextLabel1;
QLabel *TextLabel2;
QPushButton *PushButton1;
QPushButton *PushButton2;
QLineEdit *LineEdit1;
QLineEdit *LineEdit2;
// 1Combo
QLabel *TextLabel7;
QComboBox *ComboBox1;
// 4Text
QLabel *TextLabel3;
QLabel *TextLabel4;
QLabel *TextLabel5;
QLabel *TextLabel6;
QLineEdit *LineEdit3;
QLineEdit *LineEdit4;
QLineEdit *LineEdit5;
QLineEdit *LineEdit6;
};
//================================================================================= //=================================================================================
// class : MeasureGUI_DistanceDlg // class : MeasureGUI_DistanceDlg
// purpose : // purpose :
@ -48,6 +98,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid (QString&); virtual bool isValid (QString&);
virtual bool execute (ObjectList&); virtual bool execute (ObjectList&);
virtual QString getNewObjectName (int CurrObj = -1) const;
void redisplayPreview(); void redisplayPreview();
virtual void processObject(); virtual void processObject();
@ -56,13 +107,13 @@ protected:
private: private:
void Init(); void Init();
void enterEvent (QEvent*); void enterEvent (QEvent*);
bool getParameters (double&, gp_Pnt&, gp_Pnt&);
private: private:
GEOM::GEOM_Object_var myObj1; GEOM::GEOM_Object_var myObj1;
GEOM::GEOM_Object_var myObj2; GEOM::GEOM_Object_var myObj2;
MeasureGUI_2Sel4LineEdit* myGrp; MeasureGUI_DistanceGroup* myGrp;
GEOM::ListOfDouble_var myDbls;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
@ -70,6 +121,7 @@ private slots:
void ActivateThisDialog(); void ActivateThisDialog();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SolutionSelected (int i);
}; };
#endif // MEASUREGUI_DISTANCEDLG_H #endif // MEASUREGUI_DISTANCEDLG_H

View File

@ -15,11 +15,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : MeasureGUI_Widgets.cxx // File : MeasureGUI_Widgets.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#include "MeasureGUI_Widgets.h" #include "MeasureGUI_Widgets.h"
////////////////////////////////////////// //////////////////////////////////////////
@ -121,20 +120,6 @@ MeasureGUI_2Sel1LineEdit::~MeasureGUI_2Sel1LineEdit()
{ {
} }
//////////////////////////////////////////
// MeasureGUI_2Sel4LineEdit
//////////////////////////////////////////
MeasureGUI_2Sel4LineEdit::MeasureGUI_2Sel4LineEdit( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
MeasureGUI_2Sel4LineEdit::~MeasureGUI_2Sel4LineEdit()
{
}
////////////////////////////////////////// //////////////////////////////////////////
// MeasureGUI_SkeletonBox // MeasureGUI_SkeletonBox
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -15,11 +15,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : MeasureGUI_Widgets.h // File : MeasureGUI_Widgets.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#ifndef MEASUREGUI_WIDGETS_H #ifndef MEASUREGUI_WIDGETS_H
#define MEASUREGUI_WIDGETS_H #define MEASUREGUI_WIDGETS_H
@ -135,22 +134,6 @@ public:
~MeasureGUI_2Sel1LineEdit(); ~MeasureGUI_2Sel1LineEdit();
}; };
//////////////////////////////////////////
// MeasureGUI_2Sel4LineEdit
//////////////////////////////////////////
#include "ui_MeasureGUI_2Sel4LineEdit_QTD.h"
class MeasureGUI_2Sel4LineEdit : public QWidget,
public Ui::MeasureGUI_2Sel4LineEdit_QTD
{
Q_OBJECT
public:
MeasureGUI_2Sel4LineEdit( QWidget* = 0, Qt::WindowFlags = 0 );
~MeasureGUI_2Sel4LineEdit();
};
////////////////////////////////////////// //////////////////////////////////////////
// MeasureGUI_SkeletonBox // MeasureGUI_SkeletonBox
////////////////////////////////////////// //////////////////////////////////////////