AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
+ LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
+
// layouting
QVBoxLayout* bLayout = new QVBoxLayout();
bLayout->addWidget(AddAngleButton);
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
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();
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();
}
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.
# @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)
# @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)
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
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)
#
# More details.
class Mesh_Projection1D(Mesh_Algorithm):
-
## Private constructor.
def __init__(self, mesh, geom=0):
Mesh_Algorithm.__init__(self)
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)