mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 08:50:36 +05:00
0022667: EDF 7375 GEOM: Add angle argument to Create cylinder function.
Minor corrections to initial implementation.
This commit is contained in:
parent
69b2ec02a2
commit
ccf1c3dfbc
@ -1,12 +1,13 @@
|
|||||||
# Creation of a Cylinder
|
# Creation of a Cylinder
|
||||||
|
|
||||||
|
import math
|
||||||
|
|
||||||
import salome
|
import salome
|
||||||
salome.salome_init()
|
salome.salome_init()
|
||||||
import GEOM
|
import GEOM
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
geompy = geomBuilder.New(salome.myStudy)
|
geompy = geomBuilder.New(salome.myStudy)
|
||||||
|
|
||||||
import math
|
|
||||||
gg = salome.ImportComponentGUI("GEOM")
|
gg = salome.ImportComponentGUI("GEOM")
|
||||||
|
|
||||||
# create a vertex and a vector
|
# create a vertex and a vector
|
||||||
@ -16,31 +17,33 @@ v = geompy.MakeVector(p1, p2)
|
|||||||
|
|
||||||
# create cylinders
|
# create cylinders
|
||||||
height = 40
|
height = 40
|
||||||
|
|
||||||
radius1 = 15
|
radius1 = 15
|
||||||
cylinder1 = geompy.MakeCylinder(p1, v, radius1, height)
|
|
||||||
angle1 = 45.*math.pi / 180.
|
|
||||||
cylinder1a = geompy.MakeCylinderA(p1, v, radius1, height, angle1)
|
|
||||||
geompy.TranslateDXDYDZ(cylinder1a,80.,0.,0.)
|
|
||||||
|
|
||||||
radius2 = 30
|
radius2 = 30
|
||||||
cylinder2 = geompy.MakeCylinderRH(radius2, height)
|
angle1 = 45. * math.pi / 180.
|
||||||
angle2 = 210. * math.pi / 180.
|
angle2 = 210. * math.pi / 180.
|
||||||
cylinder2a = geompy.MakeCylinderRHA(radius2, height, angle2)
|
|
||||||
geompy.TranslateDXDYDZ(cylinder2a,80.,0.,0.)
|
cylinder1 = geompy.MakeCylinder(p1, v, radius1, height)
|
||||||
|
|
||||||
|
cylinder2 = geompy.MakeCylinderRH(radius2, height)
|
||||||
|
|
||||||
|
cylinder3 = geompy.MakeCylinderA(p1, v, radius1, height, angle1)
|
||||||
|
geompy.TranslateDXDYDZ(cylinder3, 80., 0., 0.)
|
||||||
|
|
||||||
|
cylinder4 = geompy.MakeCylinderRHA(radius2, height, angle2)
|
||||||
|
geompy.TranslateDXDYDZ(cylinder4, 80., 0., 0.)
|
||||||
|
|
||||||
# add objects in the study
|
# add objects in the study
|
||||||
id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1")
|
id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1")
|
||||||
id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2")
|
id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2")
|
||||||
id_cylinder1a = geompy.addToStudy(cylinder1a,"Cylinder1a")
|
id_cylinder3 = geompy.addToStudy(cylinder3,"Cylinder3")
|
||||||
id_cylinder2a = geompy.addToStudy(cylinder2a,"Cylinder2a")
|
id_cylinder4 = geompy.addToStudy(cylinder4,"Cylinder4")
|
||||||
|
|
||||||
# display the cylinders
|
# display the cylinders
|
||||||
gg.createAndDisplayGO(id_cylinder1)
|
gg.createAndDisplayGO(id_cylinder1)
|
||||||
gg.setDisplayMode(id_cylinder1,1)
|
gg.setDisplayMode(id_cylinder1,1)
|
||||||
gg.createAndDisplayGO(id_cylinder2)
|
gg.createAndDisplayGO(id_cylinder2)
|
||||||
gg.setDisplayMode(id_cylinder2,1)
|
gg.setDisplayMode(id_cylinder2,1)
|
||||||
gg.createAndDisplayGO(id_cylinder1a)
|
gg.createAndDisplayGO(id_cylinder3)
|
||||||
gg.setDisplayMode(id_cylinder1a,1)
|
gg.setDisplayMode(id_cylinder3,1)
|
||||||
gg.createAndDisplayGO(id_cylinder2a)
|
gg.createAndDisplayGO(id_cylinder4)
|
||||||
gg.setDisplayMode(id_cylinder2a,1)
|
gg.setDisplayMode(id_cylinder4,1)
|
||||||
|
@ -10,26 +10,29 @@ Entity - > Primitives - > Cylinder</b>
|
|||||||
|
|
||||||
\n Firstly, you can define a \b Cylinder by the <b>Base Point</b> (the central
|
\n Firstly, you can define a \b Cylinder by the <b>Base Point</b> (the central
|
||||||
point of the cylinder base), the \b Vector (the axis of the cylinder),
|
point of the cylinder base), the \b Vector (the axis of the cylinder),
|
||||||
and its dimensions: the Radius and the Height.
|
and its dimensions: the \b Radius and the \b Height. Also, you can optionally specify
|
||||||
|
the \b Angle in order to create a portion of cylinder.
|
||||||
|
|
||||||
\n <b>TUI Command:</b> <em>geompy.MakeCylinder(Point, Axis, Radius, Height)</em>
|
\n <b>TUI Command:</b> <em>geompy.MakeCylinder(Point, Axis, Radius, Height)</em>
|
||||||
\n <b>Arguments:</b> Name + 1 vertex + 1 vector + 2 values
|
\n <b>Arguments:</b> Name + 1 vertex + 1 vector + 2 values
|
||||||
(Dimensions: radius and height).
|
(Dimensions: radius and height).
|
||||||
|
|
||||||
\n \b Angle checkbox and field allow defining an angle to create a portion of cylinder.
|
|
||||||
\n <b>TUI Command:</b> <em>geompy.MakeCylinderA(Point, Axis, Radius, Height, Angle)</em>
|
\n <b>TUI Command:</b> <em>geompy.MakeCylinderA(Point, Axis, Radius, Height, Angle)</em>
|
||||||
\n <b>Arguments:</b> Name + 1 vertex + 1 vector + 3 values
|
\n <b>Arguments:</b> Name + 1 vertex + 1 vector + 3 values
|
||||||
(Dimensions: radius, height and angle).
|
(Dimensions: radius, height and angle).
|
||||||
|
|
||||||
\image html cylinder1.png
|
\image html cylinder1.png
|
||||||
|
|
||||||
\n Secondly, you can define a \b Cylinder by the given radius and the
|
\n Secondly, you can define a \b Cylinder by the given \b Radius and
|
||||||
height at the origin of coordinate system. The axis of the cylinder
|
\b Height at the origin of coordinate system. The axis of the cylinder
|
||||||
will be collinear to the OZ axis of the coordinate system.
|
will be collinear to the OZ axis of the coordinate system.
|
||||||
|
Similarly to first constructor, you can optionally specify the \b Angle
|
||||||
|
in order to create a portion of cylinder.
|
||||||
|
|
||||||
\n <b>TUI Command:</b> <em>geompy.MakeCylinderRH(Radius, Height)</em>
|
\n <b>TUI Command:</b> <em>geompy.MakeCylinderRH(Radius, Height)</em>
|
||||||
\n <b>Arguments:</b> Name + 2 values (Dimensions at origin: radius and
|
\n <b>Arguments:</b> Name + 2 values (Dimensions at origin: radius and
|
||||||
height).
|
height).
|
||||||
|
|
||||||
\n \b Angle checkbox and field allow defining an angle to create a portion of cylinder at the origin of coordinate system.
|
|
||||||
\n <b>TUI Command:</b> <em>geompy.MakeCylinderRHA(Radius, Height, Angle)</em>
|
\n <b>TUI Command:</b> <em>geompy.MakeCylinderRHA(Radius, Height, Angle)</em>
|
||||||
\n <b>Arguments:</b> Name + 3 values
|
\n <b>Arguments:</b> Name + 3 values
|
||||||
(Dimensions at origin: radius, height and angle).
|
(Dimensions at origin: radius, height and angle).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
//
|
//
|
||||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
@ -1494,7 +1494,7 @@ module GEOM
|
|||||||
GEOM_Object MakeCylinderRHA (in double theR, in double theH, in double theA);
|
GEOM_Object MakeCylinderRHA (in double theR, in double theH, in double theA);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a cylinder with given base point, axis, radius, height and angle.
|
* \brief Create a cylinder with given base point, axis, radius and height.
|
||||||
* \param thePnt Central point of cylinder base.
|
* \param thePnt Central point of cylinder base.
|
||||||
* \param theAxis Cylinder axis.
|
* \param theAxis Cylinder axis.
|
||||||
* \param theR Cylinder radius.
|
* \param theR Cylinder radius.
|
||||||
|
@ -180,6 +180,9 @@
|
|||||||
<tabstop>PushButton2</tabstop>
|
<tabstop>PushButton2</tabstop>
|
||||||
<tabstop>LineEdit2</tabstop>
|
<tabstop>LineEdit2</tabstop>
|
||||||
<tabstop>SpinBox_DX</tabstop>
|
<tabstop>SpinBox_DX</tabstop>
|
||||||
|
<tabstop>SpinBox_DY</tabstop>
|
||||||
|
<tabstop>SpinBox_DZ</tabstop>
|
||||||
|
<tabstop>checkBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
<tabstop>SpinBox_DX</tabstop>
|
<tabstop>SpinBox_DX</tabstop>
|
||||||
<tabstop>SpinBox_DY</tabstop>
|
<tabstop>SpinBox_DY</tabstop>
|
||||||
<tabstop>SpinBox_DZ</tabstop>
|
<tabstop>SpinBox_DZ</tabstop>
|
||||||
|
<tabstop>checkBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -109,14 +109,12 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
|
|||||||
|
|
||||||
if (aCI.GetH() < 0.0) aV.Reverse();
|
if (aCI.GetH() < 0.0) aV.Reverse();
|
||||||
gp_Ax2 anAxes (aP, aV);
|
gp_Ax2 anAxes (aP, aV);
|
||||||
bool switchAngleVar;
|
|
||||||
if(aType == CYLINDER_R_H || aType == CYLINDER_PNT_VEC_R_H) switchAngleVar = false;
|
|
||||||
else if(aType == CYLINDER_R_H_A || aType == CYLINDER_PNT_VEC_R_H_A) switchAngleVar = true;
|
|
||||||
else return 0;
|
|
||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
|
|
||||||
switch (switchAngleVar) {
|
switch (aType) {
|
||||||
case false:
|
case CYLINDER_R_H:
|
||||||
|
case CYLINDER_PNT_VEC_R_H:
|
||||||
{
|
{
|
||||||
BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()));
|
BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()));
|
||||||
MC.Build();
|
MC.Build();
|
||||||
@ -126,20 +124,21 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
|
|||||||
aShape = MC.Shape();
|
aShape = MC.Shape();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case true:
|
case CYLINDER_R_H_A:
|
||||||
|
case CYLINDER_PNT_VEC_R_H_A:
|
||||||
{
|
{
|
||||||
BRepPrimAPI_MakeCylinder MCA (anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA());
|
BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA());
|
||||||
MCA.Build();
|
MC.Build();
|
||||||
if (!MCA.IsDone()) {
|
if (!MC.IsDone()) {
|
||||||
StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters. Failure.");
|
StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters. Failure.");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
aShape = MCA.Shape();
|
aShape = MC.Shape();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aShape.IsNull()) return 0;
|
if (aShape.IsNull()) return 0;
|
||||||
aFunction->SetValue(aShape);
|
aFunction->SetValue(aShape);
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ def TestAll (geompy, math):
|
|||||||
Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 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
|
Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object
|
||||||
Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object
|
Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object
|
||||||
Cylinder1= geompy.MakeCylinderA(p0, vz, radius1, height,angle1) #(2 GEOM_Object, 2 Doubles)->GEOM_Object
|
Cylinder1= geompy.MakeCylinderA(p0, vz, radius1, height, angle1) #(2 GEOM_Object, 3 Doubles)->GEOM_Object
|
||||||
Cyl2 = geompy.MakeCylinderRHA(radius2, height,angle2) #(2 Doubles)->GEOM_Object
|
Cyl2 = geompy.MakeCylinderRHA(radius2, height, angle2) #(3 Doubles)->GEOM_Object
|
||||||
Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object
|
Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object
|
||||||
Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object
|
Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object
|
||||||
Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object
|
Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object
|
||||||
|
@ -399,9 +399,10 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
|
|||||||
{
|
{
|
||||||
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
|
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
|
||||||
GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
|
GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
|
||||||
GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
|
( !GroupPoints->checkBox->isChecked() || GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) ) &&
|
||||||
myPoint && myDir;
|
myPoint && myDir;
|
||||||
if(GroupPoints->SpinBox_DZ->value()<=0. || GroupPoints->SpinBox_DZ->value()>=360.) {
|
if ( GroupPoints->checkBox->isChecked() &&
|
||||||
|
( GroupPoints->SpinBox_DZ->value() <= 0. || GroupPoints->SpinBox_DZ->value() >= 360. ) ) {
|
||||||
msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
|
msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
@ -410,8 +411,9 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
|
|||||||
{
|
{
|
||||||
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
|
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
|
||||||
GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
|
GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
|
||||||
GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
|
( GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) );
|
||||||
if(GroupDimensions->SpinBox_DZ->value()<=0. || GroupDimensions->SpinBox_DZ->value()>=360.) {
|
if ( GroupDimensions->checkBox->isChecked() &&
|
||||||
|
( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) {
|
||||||
msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
|
msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
@ -428,7 +430,6 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
|
|||||||
bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
|
bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
bool BAngle = false;
|
|
||||||
|
|
||||||
GEOM::GEOM_Object_var anObj;
|
GEOM::GEOM_Object_var anObj;
|
||||||
|
|
||||||
@ -436,20 +437,8 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
|
|||||||
|
|
||||||
switch (getConstructorId()) {
|
switch (getConstructorId()) {
|
||||||
case 0:
|
case 0:
|
||||||
BAngle = GroupPoints->checkBox->isChecked();
|
|
||||||
if ( myPoint && myDir ) {
|
if ( myPoint && myDir ) {
|
||||||
if(!BAngle){
|
if ( GroupPoints->checkBox->isChecked() ) {
|
||||||
anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
|
|
||||||
if (!anObj->_is_nil() && !IsPreview())
|
|
||||||
{
|
|
||||||
QStringList aParameters;
|
|
||||||
aParameters << GroupPoints->SpinBox_DX->text();
|
|
||||||
aParameters << GroupPoints->SpinBox_DY->text();
|
|
||||||
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
|
||||||
}
|
|
||||||
res = true;
|
|
||||||
}
|
|
||||||
else if(BAngle){
|
|
||||||
anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
|
anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
|
||||||
if (!anObj->_is_nil() && !IsPreview())
|
if (!anObj->_is_nil() && !IsPreview())
|
||||||
{
|
{
|
||||||
@ -461,22 +450,21 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
|
|||||||
}
|
}
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
break;
|
anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
|
||||||
case 1:
|
|
||||||
BAngle = GroupDimensions->checkBox->isChecked();
|
|
||||||
if(!BAngle){
|
|
||||||
anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
|
|
||||||
if (!anObj->_is_nil() && !IsPreview())
|
if (!anObj->_is_nil() && !IsPreview())
|
||||||
{
|
{
|
||||||
QStringList aParameters;
|
QStringList aParameters;
|
||||||
aParameters << GroupDimensions->SpinBox_DX->text();
|
aParameters << GroupPoints->SpinBox_DX->text();
|
||||||
aParameters << GroupDimensions->SpinBox_DY->text();
|
aParameters << GroupPoints->SpinBox_DY->text();
|
||||||
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
||||||
}
|
}
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
else if(BAngle){
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if ( GroupDimensions->checkBox->isChecked() ) {
|
||||||
anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
|
anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
|
||||||
if (!anObj->_is_nil() && !IsPreview())
|
if (!anObj->_is_nil() && !IsPreview())
|
||||||
{
|
{
|
||||||
@ -488,6 +476,17 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
|
|||||||
}
|
}
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
|
||||||
|
if (!anObj->_is_nil() && !IsPreview())
|
||||||
|
{
|
||||||
|
QStringList aParameters;
|
||||||
|
aParameters << GroupDimensions->SpinBox_DX->text();
|
||||||
|
aParameters << GroupDimensions->SpinBox_DY->text();
|
||||||
|
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
||||||
|
}
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user