mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-15 23:41:27 +05:00
PAL13903 Extrusion along a path , linear variation of the angles
This commit is contained in:
parent
30313fedf6
commit
b78bf0bb14
@ -259,6 +259,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
|
|||||||
|
|
||||||
AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
|
AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
|
||||||
|
|
||||||
|
LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
|
||||||
|
|
||||||
// layouting
|
// layouting
|
||||||
QVBoxLayout* bLayout = new QVBoxLayout();
|
QVBoxLayout* bLayout = new QVBoxLayout();
|
||||||
bLayout->addWidget(AddAngleButton);
|
bLayout->addWidget(AddAngleButton);
|
||||||
@ -268,6 +270,7 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
|
|||||||
AnglesGrpLayout->addMultiCellWidget(AnglesList, 0, 1, 0, 0);
|
AnglesGrpLayout->addMultiCellWidget(AnglesList, 0, 1, 0, 0);
|
||||||
AnglesGrpLayout->addMultiCellLayout(bLayout, 0, 1, 1, 1);
|
AnglesGrpLayout->addMultiCellLayout(bLayout, 0, 1, 1, 1);
|
||||||
AnglesGrpLayout->addWidget( AngleSpin, 0, 2 );
|
AnglesGrpLayout->addWidget( AngleSpin, 0, 2 );
|
||||||
|
AnglesGrpLayout->addWidget( LinearAnglesCheck, 2, 0 );
|
||||||
AnglesGrpLayout->setRowStretch(1, 10);
|
AnglesGrpLayout->setRowStretch(1, 10);
|
||||||
|
|
||||||
// CheckBox for groups generation
|
// CheckBox for groups generation
|
||||||
@ -604,17 +607,20 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
|
|||||||
try {
|
try {
|
||||||
SUIT_OverrideCursor wc;
|
SUIT_OverrideCursor wc;
|
||||||
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
||||||
|
if ( LinearAnglesCheck->isChecked() )
|
||||||
|
anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
|
||||||
|
|
||||||
SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
|
SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
|
||||||
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
|
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
|
||||||
SMESH::ListOfGroups_var groups =
|
SMESH::ListOfGroups_var groups =
|
||||||
aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId.inout(), myPathMesh,
|
aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
|
||||||
myPathShape, aNodeStart,
|
myPathShape, aNodeStart,
|
||||||
AnglesCheck->isChecked(), anAngles.inout(),
|
AnglesCheck->isChecked(), anAngles,
|
||||||
BasePointCheck->isChecked(), aBasePoint, retVal);
|
BasePointCheck->isChecked(), aBasePoint, retVal);
|
||||||
else
|
else
|
||||||
retVal = aMeshEditor->ExtrusionAlongPath(anElementsId.inout(), myPathMesh,
|
retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
|
||||||
myPathShape, aNodeStart,
|
myPathShape, aNodeStart,
|
||||||
AnglesCheck->isChecked(), anAngles.inout(),
|
AnglesCheck->isChecked(), anAngles,
|
||||||
BasePointCheck->isChecked(), aBasePoint);
|
BasePointCheck->isChecked(), aBasePoint);
|
||||||
|
|
||||||
//wc.stop();
|
//wc.stop();
|
||||||
|
@ -2089,6 +2089,57 @@ SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMes
|
|||||||
const SMESH::double_array & theAngles)
|
const SMESH::double_array & theAngles)
|
||||||
{
|
{
|
||||||
SMESH::double_array_var aResult = new SMESH::double_array();
|
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();
|
return aResult._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +150,11 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
|
|||||||
print hypName, "was not assigned to",geomName,":", reason
|
print hypName, "was not assigned to",geomName,":", reason
|
||||||
pass
|
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.
|
## Methods of package smesh.py: general services of MESH component.
|
||||||
#
|
#
|
||||||
# This class has been designed to provide general services of the 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 NbOfSteps number of steps
|
||||||
# @param Tolerance tolerance
|
# @param Tolerance tolerance
|
||||||
# @param MakeGroups to generate new groups from existing ones
|
# @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
|
# @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 == []:
|
if IDsOfElements == []:
|
||||||
IDsOfElements = self.GetElementsId()
|
IDsOfElements = self.GetElementsId()
|
||||||
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
|
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
|
||||||
Axix = self.smeshpyD.GetAxisStruct(Axix)
|
Axix = self.smeshpyD.GetAxisStruct(Axix)
|
||||||
|
if TotalAngle and NbOfSteps:
|
||||||
|
AngleInRadians /= NbOfSteps
|
||||||
if MakeGroups:
|
if MakeGroups:
|
||||||
return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
|
return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
|
||||||
AngleInRadians, NbOfSteps, Tolerance)
|
AngleInRadians, NbOfSteps, Tolerance)
|
||||||
@ -1926,12 +1936,17 @@ class Mesh:
|
|||||||
# @param NbOfSteps number of steps
|
# @param NbOfSteps number of steps
|
||||||
# @param Tolerance tolerance
|
# @param Tolerance tolerance
|
||||||
# @param MakeGroups to generate new groups from existing ones
|
# @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
|
# @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 )):
|
if ( isinstance( theObject, Mesh )):
|
||||||
theObject = theObject.GetMesh()
|
theObject = theObject.GetMesh()
|
||||||
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
|
if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
|
||||||
Axix = self.smeshpyD.GetAxisStruct(Axix)
|
Axix = self.smeshpyD.GetAxisStruct(Axix)
|
||||||
|
if TotalAngle and NbOfSteps:
|
||||||
|
AngleInRadians /= NbOfSteps
|
||||||
if MakeGroups:
|
if MakeGroups:
|
||||||
return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
|
return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
|
||||||
NbOfSteps, Tolerance)
|
NbOfSteps, Tolerance)
|
||||||
@ -2044,11 +2059,16 @@ class Mesh:
|
|||||||
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
|
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
|
||||||
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
|
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
|
||||||
pass
|
pass
|
||||||
|
if ( isinstance( PathMesh, Mesh )):
|
||||||
|
PathMesh = PathMesh.GetMesh()
|
||||||
|
if HasAngles and Angles and LinearVariation:
|
||||||
|
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
|
||||||
|
pass
|
||||||
if MakeGroups:
|
if MakeGroups:
|
||||||
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(),
|
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
|
||||||
PathShape, NodeStart, HasAngles,
|
PathShape, NodeStart, HasAngles,
|
||||||
Angles, HasRefPoint, RefPoint)
|
Angles, HasRefPoint, RefPoint)
|
||||||
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape,
|
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
|
||||||
NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
|
NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
|
||||||
|
|
||||||
## Generate new elements by extrusion of the elements belong to object
|
## Generate new elements by extrusion of the elements belong to object
|
||||||
@ -2073,11 +2093,16 @@ class Mesh:
|
|||||||
theObject = theObject.GetMesh()
|
theObject = theObject.GetMesh()
|
||||||
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
|
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
|
||||||
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
|
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:
|
if MakeGroups:
|
||||||
return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(),
|
return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
|
||||||
PathShape, NodeStart, HasAngles,
|
PathShape, NodeStart, HasAngles,
|
||||||
Angles, HasRefPoint, RefPoint)
|
Angles, HasRefPoint, RefPoint)
|
||||||
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape,
|
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
|
||||||
NodeStart, HasAngles, Angles, HasRefPoint,
|
NodeStart, HasAngles, Angles, HasRefPoint,
|
||||||
RefPoint)
|
RefPoint)
|
||||||
|
|
||||||
@ -3228,7 +3253,6 @@ class Mesh_Netgen(Mesh_Algorithm):
|
|||||||
#
|
#
|
||||||
# More details.
|
# More details.
|
||||||
class Mesh_Projection1D(Mesh_Algorithm):
|
class Mesh_Projection1D(Mesh_Algorithm):
|
||||||
|
|
||||||
## Private constructor.
|
## Private constructor.
|
||||||
def __init__(self, mesh, geom=0):
|
def __init__(self, mesh, geom=0):
|
||||||
Mesh_Algorithm.__init__(self)
|
Mesh_Algorithm.__init__(self)
|
||||||
@ -3273,7 +3297,6 @@ class Mesh_Projection2D(Mesh_Algorithm):
|
|||||||
def __init__(self, mesh, geom=0):
|
def __init__(self, mesh, geom=0):
|
||||||
Mesh_Algorithm.__init__(self)
|
Mesh_Algorithm.__init__(self)
|
||||||
self.Create(mesh, geom, "Projection_2D")
|
self.Create(mesh, geom, "Projection_2D")
|
||||||
|
|
||||||
## Define "Source Face" hypothesis, specifying a meshed face to
|
## Define "Source Face" hypothesis, specifying a meshed face to
|
||||||
# take a mesh pattern from, and optionally association of vertices
|
# take a mesh pattern from, and optionally association of vertices
|
||||||
# between the source face and a target one (where a hipothesis is assigned to)
|
# between the source face and a target one (where a hipothesis is assigned to)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user