PAL13903 Extrusion along a path , linear variation of the angles

This commit is contained in:
eap 2008-03-05 12:27:13 +00:00
parent 30313fedf6
commit b78bf0bb14
3 changed files with 92 additions and 12 deletions

View File

@ -259,6 +259,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
// layouting
QVBoxLayout* bLayout = new QVBoxLayout();
bLayout->addWidget(AddAngleButton);
@ -268,6 +270,7 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
AnglesGrpLayout->addMultiCellWidget(AnglesList, 0, 1, 0, 0);
AnglesGrpLayout->addMultiCellLayout(bLayout, 0, 1, 1, 1);
AnglesGrpLayout->addWidget( AngleSpin, 0, 2 );
AnglesGrpLayout->addWidget( LinearAnglesCheck, 2, 0 );
AnglesGrpLayout->setRowStretch(1, 10);
// CheckBox for groups generation
@ -604,17 +607,20 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
try {
SUIT_OverrideCursor wc;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
if ( LinearAnglesCheck->isChecked() )
anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId.inout(), myPathMesh,
aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
myPathShape, aNodeStart,
AnglesCheck->isChecked(), anAngles.inout(),
AnglesCheck->isChecked(), anAngles,
BasePointCheck->isChecked(), aBasePoint, retVal);
else
retVal = aMeshEditor->ExtrusionAlongPath(anElementsId.inout(), myPathMesh,
retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
myPathShape, aNodeStart,
AnglesCheck->isChecked(), anAngles.inout(),
AnglesCheck->isChecked(), anAngles,
BasePointCheck->isChecked(), aBasePoint);
//wc.stop();

View File

@ -2089,6 +2089,57 @@ SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMes
const SMESH::double_array & theAngles)
{
SMESH::double_array_var aResult = new SMESH::double_array();
int nbAngles = theAngles.length();
if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
{
SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
return aResult._retn();
int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
if ( nbSteps == nbAngles )
{
aResult.inout() = theAngles;
}
else
{
aResult->length( nbSteps );
double rAn2St = double( nbAngles ) / double( nbSteps );
double angPrev = 0, angle;
for ( int iSt = 0; iSt < nbSteps; ++iSt )
{
double angCur = rAn2St * ( iSt+1 );
double angCurFloor = floor( angCur );
double angPrevFloor = floor( angPrev );
if ( angPrevFloor == angCurFloor )
angle = rAn2St * theAngles[ int( angCurFloor ) ];
else
{
int iP = int( angPrevFloor );
double angPrevCeil = ceil(angPrev);
angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
int iC = int( angCurFloor );
if ( iC < nbAngles )
angle += ( angCur - angCurFloor ) * theAngles[ iC ];
iP = int( angPrevCeil );
while ( iC-- > iP )
angle += theAngles[ iC ];
}
aResult[ iSt ] = angle;
angPrev = angCur;
}
}
}
// Update Python script
TPythonDump() << "rotAngles = " << theAngles;
TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
<< thePathMesh << ", "
<< thePathShape << ", "
<< "rotAngles )";
return aResult._retn();
}

View File

@ -150,6 +150,11 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
print hypName, "was not assigned to",geomName,":", reason
pass
## Convert angle in degrees to radians
def DegreesToRadians(AngleInDegrees):
from math import pi
return AngleInDegrees * pi / 180.0
## Methods of package smesh.py: general services of MESH component.
#
# This class has been designed to provide general services of the MESH component.
@ -1907,12 +1912,17 @@ class Mesh:
# @param NbOfSteps number of steps
# @param Tolerance tolerance
# @param MakeGroups to generate new groups from existing ones
# @param TotalAngle gives meaning of AngleInRadians: if True then it is an anglular size
# of all steps, else - size of each step
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance,
MakeGroups=False, TotalAngle=False):
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
Axix = self.smeshpyD.GetAxisStruct(Axix)
if TotalAngle and NbOfSteps:
AngleInRadians /= NbOfSteps
if MakeGroups:
return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
AngleInRadians, NbOfSteps, Tolerance)
@ -1926,12 +1936,17 @@ class Mesh:
# @param NbOfSteps number of steps
# @param Tolerance tolerance
# @param MakeGroups to generate new groups from existing ones
# @param TotalAngle gives meaning of AngleInRadians: if True then it is an anglular size
# of all steps, else - size of each step
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance,
MakeGroups=False, TotalAngle=False):
if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
Axix = self.smeshpyD.GetAxisStruct(Axix)
if TotalAngle and NbOfSteps:
AngleInRadians /= NbOfSteps
if MakeGroups:
return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
NbOfSteps, Tolerance)
@ -2044,11 +2059,16 @@ class Mesh:
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
pass
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
if HasAngles and Angles and LinearVariation:
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
pass
if MakeGroups:
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(),
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
PathShape, NodeStart, HasAngles,
Angles, HasRefPoint, RefPoint)
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape,
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
## Generate new elements by extrusion of the elements belong to object
@ -2073,11 +2093,16 @@ class Mesh:
theObject = theObject.GetMesh()
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
if HasAngles and Angles and LinearVariation:
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
pass
if MakeGroups:
return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(),
return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
PathShape, NodeStart, HasAngles,
Angles, HasRefPoint, RefPoint)
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape,
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
NodeStart, HasAngles, Angles, HasRefPoint,
RefPoint)
@ -3228,7 +3253,6 @@ class Mesh_Netgen(Mesh_Algorithm):
#
# More details.
class Mesh_Projection1D(Mesh_Algorithm):
## Private constructor.
def __init__(self, mesh, geom=0):
Mesh_Algorithm.__init__(self)
@ -3273,7 +3297,6 @@ class Mesh_Projection2D(Mesh_Algorithm):
def __init__(self, mesh, geom=0):
Mesh_Algorithm.__init__(self)
self.Create(mesh, geom, "Projection_2D")
## Define "Source Face" hypothesis, specifying a meshed face to
# take a mesh pattern from, and optionally association of vertices
# between the source face and a target one (where a hipothesis is assigned to)