mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-18 23:50:36 +05:00
RNC: EDF 1618 Sketcher improvement for arc creation
This commit is contained in:
parent
7d9374db43
commit
fca838df4f
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@ -49,7 +49,7 @@ is predefined and is equal to 90 degrees);</li>
|
|||||||
<li>tangent to the previous segment;</li>
|
<li>tangent to the previous segment;</li>
|
||||||
<li>vector components DX, DY.</li>
|
<li>vector components DX, DY.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<li>Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius and angle).</li>
|
<li>Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius, angle or center coordinates).</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
\b Buttons:
|
\b Buttons:
|
||||||
|
@ -1514,6 +1514,10 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_ABS</source>
|
<source>GEOM_SKETCHER_ABS</source>
|
||||||
<translation>Absolute</translation>
|
<translation>Absolute</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_ADD_PARAMS</source>
|
||||||
|
<translation>Additionnal Parameters</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_ANGLE</source>
|
<source>GEOM_SKETCHER_ANGLE</source>
|
||||||
@ -1530,8 +1534,32 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_ARC</source>
|
<source>GEOM_SKETCHER_ARC</source>
|
||||||
<translation>Arc</translation>
|
<translation>Arc</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER</source>
|
||||||
|
<translation>Center</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER2</source>
|
||||||
|
<translation>Center :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER_X</source>
|
||||||
|
<translation>Center X coord. :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER_Y</source>
|
||||||
|
<translation>Center Y coord. :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER_DX</source>
|
||||||
|
<translation>Center DX coord. :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_CENTER_DY</source>
|
||||||
|
<translation>Center DY coord. :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
<source>GEOM_SKETCHER_DEST</source>
|
<source>GEOM_SKETCHER_DEST</source>
|
||||||
<translation>Destination</translation>
|
<translation>Destination</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1566,6 +1594,10 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_LENGTH2</source>
|
<source>GEOM_SKETCHER_LENGTH2</source>
|
||||||
<translation>Length :</translation>
|
<translation>Length :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_NONE</source>
|
||||||
|
<translation>None (Tangential)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_PER</source>
|
<source>GEOM_SKETCHER_PER</source>
|
||||||
@ -1578,7 +1610,15 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_POINT2</source>
|
<source>GEOM_SKETCHER_POINT2</source>
|
||||||
<translation>Point :</translation>
|
<translation>Point :</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_END_POINT2</source>
|
||||||
|
<translation>End Point :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_RADIUS</source>
|
||||||
|
<translation>Radius</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_RADIUS2</source>
|
<source>GEOM_SKETCHER_RADIUS2</source>
|
||||||
<translation>Radius :</translation>
|
<translation>Radius :</translation>
|
||||||
|
@ -1100,6 +1100,10 @@
|
|||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_POINT2</source>
|
<source>GEOM_SKETCHER_POINT2</source>
|
||||||
<translation>Point :</translation>
|
<translation>Point :</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_SKETCHER_END_POINT2</source>
|
||||||
|
<translation>End Point :</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>GEOM_SKETCHER_RADIUS2</source>
|
<source>GEOM_SKETCHER_RADIUS2</source>
|
||||||
|
@ -49,6 +49,19 @@ import geompy
|
|||||||
#"C radius length" : Create by direction, radius and length(in degree)
|
#"C radius length" : Create by direction, radius and length(in degree)
|
||||||
#"AA x y": Create by point at X & Y
|
#"AA x y": Create by point at X & Y
|
||||||
#"A dx dy" : Create by point with DX & DY
|
#"A dx dy" : Create by point with DX & DY
|
||||||
|
#"UU x y radius flag1": Create by point at X & Y with given radiUs
|
||||||
|
#"U dx dy radius flag1" : Create by point with DX & DY with given radiUs
|
||||||
|
#"EE x y xc yc flag1 flag2": Create by point at X & Y with given cEnter
|
||||||
|
#"E dx dy dxc dyc radius flag1 flag2" : Create by point with DX & DY with given cEnter
|
||||||
|
|
||||||
|
#Flag1 is 0 or 2 ...
|
||||||
|
# if 0 the drawn arc is the one of lower angle (< Pi)
|
||||||
|
# if 2 the drawn arc ius the one of greater angle (> Pi)
|
||||||
|
|
||||||
|
#Flag2 is 0 or 1 ...
|
||||||
|
# if 0 the specified end point can be at a distance of the arc greater than the tolerance (10^-7)
|
||||||
|
# if 1 the wire is built only if the end point is on the arc
|
||||||
|
# with a tolerance of 10^-7 on the distance else the creation fails
|
||||||
|
|
||||||
#To finish
|
#To finish
|
||||||
#"WW" : Close Wire
|
#"WW" : Close Wire
|
||||||
|
@ -913,11 +913,27 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
# - "C radius length" : Create arc by direction, radius and length(in degree)
|
# - "C radius length" : Create arc by direction, radius and length(in degree)
|
||||||
# - "AA x y": Create arc by point at X & Y
|
# - "AA x y": Create arc by point at X & Y
|
||||||
# - "A dx dy" : Create arc by point with DX & DY
|
# - "A dx dy" : Create arc by point with DX & DY
|
||||||
# .
|
# - "A dx dy" : Create arc by point with DX & DY
|
||||||
|
# - "UU x y radius flag1": Create arc by point at X & Y with given radiUs
|
||||||
|
# - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs
|
||||||
|
# - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
|
||||||
|
# - "E dx dy dxc dyc radius flag1 flag2" : Create arc by point with DX & DY with given cEnter coordinates
|
||||||
|
# .
|
||||||
# \n
|
# \n
|
||||||
# - "WW" : Close Wire (to finish)
|
# - "WW" : Close Wire (to finish)
|
||||||
# - "WF" : Close Wire and build face (to finish)
|
# - "WF" : Close Wire and build face (to finish)
|
||||||
#
|
# .
|
||||||
|
# \n
|
||||||
|
# - Flag1 (= reverse) is 0 or 2 ...
|
||||||
|
# - if 0 the drawn arc is the one of lower angle (< Pi)
|
||||||
|
# - if 2 the drawn arc ius the one of greater angle (> Pi)
|
||||||
|
# .
|
||||||
|
# \n
|
||||||
|
# - Flag2 (= control tolerance) is 0 or 1 ...
|
||||||
|
# - if 0 the specified end point can be at a distance of the arc greater than the tolerance (10^-7)
|
||||||
|
# - if 1 the wire is built only if the end point is on the arc
|
||||||
|
# with a tolerance of 10^-7 on the distance else the creation fails
|
||||||
|
#
|
||||||
# @param theCommand String, defining the sketcher in local
|
# @param theCommand String, defining the sketcher in local
|
||||||
# coordinates of the working plane.
|
# coordinates of the working plane.
|
||||||
# @param theWorkingPlane Nine double values, defining origin,
|
# @param theWorkingPlane Nine double values, defining origin,
|
||||||
|
@ -67,6 +67,7 @@ Sketcher_Profile::Sketcher_Profile()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
||||||
{
|
{
|
||||||
|
myErrMsg = "";
|
||||||
enum {line, circle, point, none} move;
|
enum {line, circle, point, none} move;
|
||||||
|
|
||||||
Standard_Integer i = 1;
|
Standard_Integer i = 1;
|
||||||
@ -78,6 +79,9 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
|||||||
first = Standard_True;
|
first = Standard_True;
|
||||||
stayfirst = face = close = Standard_False;
|
stayfirst = face = close = Standard_False;
|
||||||
|
|
||||||
|
Standard_Integer reversed = 0;
|
||||||
|
Standard_Integer control_Tolerance = 0;
|
||||||
|
|
||||||
TopoDS_Shape S;
|
TopoDS_Shape S;
|
||||||
TopoDS_Vertex MP;
|
TopoDS_Vertex MP;
|
||||||
BRepBuilderAPI_MakeWire MW;
|
BRepBuilderAPI_MakeWire MW;
|
||||||
@ -185,7 +189,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
|||||||
}
|
}
|
||||||
case 'T':
|
case 'T':
|
||||||
{
|
{
|
||||||
if (n1 != 3) goto badargs;
|
if (n1 != 3) goto badargs;
|
||||||
Standard_Real vx = a(1).RealValue();
|
Standard_Real vx = a(1).RealValue();
|
||||||
Standard_Real vy = a(2).RealValue();
|
Standard_Real vy = a(2).RealValue();
|
||||||
if (a(0) == "TT") {
|
if (a(0) == "TT") {
|
||||||
@ -245,7 +249,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
|||||||
move = none;
|
move = none;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'A':
|
case 'A': // TAngential arc by end point
|
||||||
{
|
{
|
||||||
if (n1 != 3) goto badargs;
|
if (n1 != 3) goto badargs;
|
||||||
Standard_Real vx = a(1).RealValue();
|
Standard_Real vx = a(1).RealValue();
|
||||||
@ -254,16 +258,14 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
|||||||
vx -= x;
|
vx -= x;
|
||||||
vy -= y;
|
vy -= y;
|
||||||
}
|
}
|
||||||
Standard_Real det = (dx * vy - dy * vx);
|
Standard_Real det = dx * vy - dy * vx;
|
||||||
if ( Abs(det) > Precision::Confusion()) {
|
if ( Abs(det) > Precision::Confusion()) {
|
||||||
Standard_Real c = (dx * vx + dy * vy) // Cosine of alpha = arc angle / 2
|
Standard_Real c = (dx * vx + dy * vy)
|
||||||
/ Sqrt((dx * dx + dy * dy)
|
/ Sqrt((dx * dx + dy * dy) * (vx * vx + vy * vy)); // Cosine of alpha = arc of angle / 2 , alpha in [0,Pi]
|
||||||
* (vx * vx + vy * vy));
|
radius = (vx * vx + vy * vy)* Sqrt(dx * dx + dy * dy) // radius = distance between start and end point / 2 * sin(alpha)
|
||||||
radius = (vx * vx + vy * vy) // radius = distance between start
|
/ (2.0 * det); // radius is > 0 or < 0
|
||||||
* Sqrt(dx * dx + dy * dy) // and end point / 2 * sin(alpha)
|
|
||||||
/ (2.0 * det); // radius is > 0 or < 0
|
|
||||||
if (Abs(radius) > Precision::Confusion()) {
|
if (Abs(radius) > Precision::Confusion()) {
|
||||||
angle = 2.0 * acos(c); // angle in [0,Pi]
|
angle = 2.0 * acos(c); // angle in [0,2Pi]
|
||||||
move = circle;
|
move = circle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -274,6 +276,83 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
|||||||
move = none;
|
move = none;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'U': // Arc by end point and radiUs
|
||||||
|
{
|
||||||
|
if (n1 != 5) goto badargs;
|
||||||
|
Standard_Real vx = a(1).RealValue();
|
||||||
|
Standard_Real vy = a(2).RealValue();
|
||||||
|
radius = a(3).RealValue();
|
||||||
|
reversed = a(4).IntegerValue();
|
||||||
|
if (a(0) == "UU") { // Absolute
|
||||||
|
vx -= x;
|
||||||
|
vy -= y;
|
||||||
|
}
|
||||||
|
Standard_Real length = Sqrt(vx * vx + vy * vy);
|
||||||
|
if ( (4.0 - (vx * vx + vy * vy) / (radius * radius) >= 0.0 ) && (length > Precision::Confusion()) ) {
|
||||||
|
Standard_Real c = 0.5 * Sqrt(4.0 - (vx * vx + vy * vy) / (radius * radius)); // Cosine of alpha = arc angle / 2 , alpha in [0,Pi/2]
|
||||||
|
angle = 2.0 * acos(c); // angle in [0,Pi]
|
||||||
|
if ( reversed == 2 )
|
||||||
|
angle = angle - 2 * PI;
|
||||||
|
dx = 0.5 * ( vy * 1.0/radius
|
||||||
|
+ vx * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius)));
|
||||||
|
dy = - 0.5 * ( vx * 1.0/radius
|
||||||
|
- vy * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius)));
|
||||||
|
move = circle;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
move = none;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'E': // Arc by end point and cEnter
|
||||||
|
{
|
||||||
|
myErrMsg = "";
|
||||||
|
if (n1 != 7) goto badargs;
|
||||||
|
Standard_Real vx = a(1).RealValue();
|
||||||
|
Standard_Real vy = a(2).RealValue();
|
||||||
|
Standard_Real vxc = a(3).RealValue();
|
||||||
|
Standard_Real vyc = a(4).RealValue();
|
||||||
|
reversed = a(5).IntegerValue();
|
||||||
|
control_Tolerance = a(6).IntegerValue();
|
||||||
|
|
||||||
|
if (a(0) == "EE") { // Absolute
|
||||||
|
vx -= x;
|
||||||
|
vy -= y;
|
||||||
|
vxc -= x;
|
||||||
|
vyc -= y;
|
||||||
|
}
|
||||||
|
radius = Sqrt( vxc * vxc + vyc * vyc );
|
||||||
|
Standard_Real det = vx * vyc - vy * vxc;
|
||||||
|
Standard_Real length = Sqrt(vx * vx + vy * vy);
|
||||||
|
Standard_Real length2 = Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc));
|
||||||
|
Standard_Real length3 = Sqrt(vxc * vxc + vyc * vyc);
|
||||||
|
Standard_Real error = Abs(length2 - radius);
|
||||||
|
if ( error > Precision::Confusion() ){
|
||||||
|
MESSAGE("Warning : The specified end point is not on the Arc, distance = "<<error);
|
||||||
|
myErrMsg = "Warning : The specified End Point is not on the Arc";
|
||||||
|
}
|
||||||
|
if ( error > Precision::Confusion() && // Don't create the arc if the end point
|
||||||
|
control_Tolerance == 1) // is too far from it
|
||||||
|
move = none;
|
||||||
|
else if ( (length > Precision::Confusion()) &&
|
||||||
|
(length2 > Precision::Confusion()) &&
|
||||||
|
(length3 > Precision::Confusion()) ) {
|
||||||
|
Standard_Real c = ( radius * radius - (vx * vxc + vy * vyc) )
|
||||||
|
/ ( radius * Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc)) ) ; // Cosine of arc angle
|
||||||
|
angle = acos(c); // angle in [0,Pi]
|
||||||
|
if ( reversed == 2 )
|
||||||
|
angle = angle - 2 * PI;
|
||||||
|
if (det < 0)
|
||||||
|
angle = -angle;
|
||||||
|
dx = vyc / radius;
|
||||||
|
dy = -vxc / radius;
|
||||||
|
move = circle;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
move = none;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
if (n1 != 2) goto badargs;
|
if (n1 != 2) goto badargs;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class Sketcher_Profile
|
class Sketcher_Profile
|
||||||
{
|
{
|
||||||
@ -43,6 +44,7 @@ private:
|
|||||||
|
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
bool myOK;
|
bool myOK;
|
||||||
|
std::string myErrMsg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Standard_EXPORT gp_Pnt GetLastPoint(){return myLastPoint;};
|
Standard_EXPORT gp_Pnt GetLastPoint(){return myLastPoint;};
|
||||||
@ -50,5 +52,6 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT const TopoDS_Shape& GetShape(){return myShape;};
|
Standard_EXPORT const TopoDS_Shape& GetShape(){return myShape;};
|
||||||
Standard_EXPORT bool IsDone(){return myOK;};
|
Standard_EXPORT bool IsDone(){return myOK;};
|
||||||
|
Standard_EXPORT std::string ErrMsg(){return myErrMsg;};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user