+
+ // Clear python line, created by ExtrusionSweep()
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
+
+ // Update Python script
+ TCollection_AsciiString str ("mesh_editor.ExtrusionSweepObject(");
+ SMESH_Gen_i::AddObject( str, theObject ) += ", stepVector, ";
+ str += TCollection_AsciiString((int)theNbOfSteps) + " )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+}
+//=======================================================================
+//function : ExtrusionSweepObject1D
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::DirStruct & theStepVector,
+ CORBA::Long theNbOfSteps)
+{
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ SMESH::long_array_var allElementsId = theObject->GetIDs();
+
+ set<const SMDS_MeshElement*> elements;
+ for (int i = 0; i < allElementsId->length(); i++)
+ {
+ CORBA::Long index = allElementsId[i];
+ const SMDS_MeshElement * elem = aMesh->FindElement(index);
+ if ( elem && elem->GetType() == SMDSAbs_Edge )
+ elements.insert( elem );
+ }
+ const SMESH::PointStruct * P = &theStepVector.PS;
+ gp_Vec stepVec( P->x, P->y, P->z );
+
+ ::SMESH_MeshEditor anEditor( _myMesh );
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+}
+
+//=======================================================================
+//function : ExtrusionSweepObject2D
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::DirStruct & theStepVector,
+ CORBA::Long theNbOfSteps)
+{
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ SMESH::long_array_var allElementsId = theObject->GetIDs();
+
+ set<const SMDS_MeshElement*> elements;
+ for (int i = 0; i < allElementsId->length(); i++)
+ {
+ CORBA::Long index = allElementsId[i];
+ const SMDS_MeshElement * elem = aMesh->FindElement(index);
+ if ( elem && elem->GetType() == SMDSAbs_Face )
+ elements.insert( elem );
+ }
+ const SMESH::PointStruct * P = &theStepVector.PS;
+ gp_Vec stepVec( P->x, P->y, P->z );
+
+ ::SMESH_MeshEditor anEditor( _myMesh );
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+}
+
+#define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
+
+static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
+{
+ switch ( e ) {
+ RETCASE( EXTR_OK );
+ RETCASE( EXTR_NO_ELEMENTS );
+ RETCASE( EXTR_PATH_NOT_EDGE );
+ RETCASE( EXTR_BAD_PATH_SHAPE );
+ RETCASE( EXTR_BAD_STARTING_NODE );
+ RETCASE( EXTR_BAD_ANGLES_NUMBER );
+ RETCASE( EXTR_CANT_GET_TANGENT );
+ }
+ return SMESH::SMESH_MeshEditor::EXTR_OK;
+}
+
+//=======================================================================
+//function : ExtrusionAlongPath
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Extrusion_Error
+ SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
+ return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
+
+ SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
+ TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
+ SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
+
+ if ( !aSubMesh )
+ return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
+
+ SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
+ if ( !nodeStart )
+ return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
+
+ set<const SMDS_MeshElement*> elements;
+ for (int i = 0; i < theIDsOfElements.length(); i++)
+ {
+ CORBA::Long index = theIDsOfElements[i];
+ const SMDS_MeshElement * elem = aMesh->FindElement(index);
+ if ( elem )
+ elements.insert( elem );
+ }
+
+ list<double> angles;
+ for (int i = 0; i < theAngles.length(); i++)
+ {
+ angles.push_back( theAngles[i] );
+ }
+
+ gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
+
+ // Update Python script
+ TCollection_AsciiString str = "refPoint = SMESH.PointStruct( ";
+ str += (TCollection_AsciiString) refPnt.X() + ", ";
+ str += (TCollection_AsciiString) refPnt.Y() + ", ";
+ str += (TCollection_AsciiString) refPnt.Z() + " )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+ str = ("error = mesh_editor.ExtrusionAlongPath(");
+ SMESH_Gen_i::AddArray ( str, theIDsOfElements ) += ", ";
+ SMESH_Gen_i::AddObject( str, thePathMesh ) += ", ";
+ SMESH_Gen_i::AddObject( str, thePathShape ) += ", ";
+ str += TCollection_AsciiString( (int)theNodeStart ) + ", ";
+ str += TCollection_AsciiString( (int)theHasAngles ) + ", ";
+ SMESH_Gen_i::AddArray ( str, theAngles ) += ", ";
+ str += (TCollection_AsciiString) theHasRefPoint + ", refPoint )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+
+ ::SMESH_MeshEditor anEditor( _myMesh );
+ return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt ) );
+}
+
+//=======================================================================
+//function : ExtrusionAlongPathObject
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Extrusion_Error
+ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath
+ (anElementsId, thePathMesh, thePathShape, theNodeStart,
+ theHasAngles, theAngles, theHasRefPoint, theRefPoint);
+
+ // Clear python line, created by ExtrusionAlongPath()
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
+
+ // Update Python script
+ TCollection_AsciiString str ("error = mesh_editor.ExtrusionAlongPathObject(");
+ SMESH_Gen_i::AddObject( str, theObject ) += ", ";
+ SMESH_Gen_i::AddObject( str, thePathMesh ) += ", ";
+ SMESH_Gen_i::AddObject( str, thePathShape ) += ", ";
+ str += TCollection_AsciiString( (int)theNodeStart ) + ", ";
+ str += TCollection_AsciiString( theHasAngles ) + ", ";
+ SMESH_Gen_i::AddArray ( str, theAngles ) += ", ";
+ str += TCollection_AsciiString( theHasRefPoint ) + ", refPoint )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+
+ return error;