From c94d606fe399faeb356151a1a9754e5f21754082 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 21 Jan 2014 16:37:16 +0000 Subject: [PATCH] 22316: EDF 2719 SMESH: Split hexas into prisms Make Python API be equal to IDL API --- idl/SMESH_MeshEditor.idl | 14 +++++++------ src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx | 22 +++++++++++--------- src/SMESH_I/SMESH_2smeshpy.cxx | 4 ++-- src/SMESH_I/SMESH_MeshEditor_i.cxx | 28 +++++++++++++++----------- src/SMESH_I/SMESH_MeshEditor_i.hxx | 9 +++++---- src/SMESH_SWIG/smeshBuilder.py | 20 +++++++++++------- 6 files changed, 56 insertions(+), 41 deletions(-) diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl index 13107425d..578a61eaa 100644 --- a/idl/SMESH_MeshEditor.idl +++ b/idl/SMESH_MeshEditor.idl @@ -326,9 +326,10 @@ module SMESH /*! * \brief Split hexahedra into triangular prisms * \param elems - elements to split + * \param startHexPoint - a point used to find a hexahedron for which \a facetToSplitNormal + * gives a normal vector defining facets to split into triangles. * \param facetToSplitNormal - normal used to find a facet of hexahedron - * to split into triangles. Location of this vector is used to - * find a hexahedron whose facets are tested using direction of this vector. + * to split into triangles. * \param methodFlags - flags passing splitting method: * 1 - split the hexahedron into 2 prisms * 2 - split the hexahedron into 4 prisms @@ -336,10 +337,11 @@ module SMESH * to \a facetToSplitNormal location are split, else \a facetToSplitNormal * is used to find the facet to split in all domains present in \a elems. */ - void SplitHexahedraIntoPrisms(in SMESH_IDSource elems, - in short methodFlags, - in SMESH::AxisStruct facetToSplitNormal, - in boolean allDomains) + void SplitHexahedraIntoPrisms(in SMESH_IDSource elems, + in SMESH::PointStruct startHexPoint, + in SMESH::DirStruct facetToSplitNormal, + in short methodFlags, + in boolean allDomains) raises (SALOME::SALOME_Exception); diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index a8682ee95..a9aa67d2e 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -1635,16 +1635,18 @@ bool SMESHGUI_SplitVolumesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, aParameters << myDirSpin[2]->text(); myMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); - SMESH::AxisStruct_var axis = new SMESH::AxisStruct; - axis->x = myPointSpin[0]->GetValue(); - axis->y = myPointSpin[1]->GetValue(); - axis->z = myPointSpin[2]->GetValue(); - axis->vx = myDirSpin[0]->GetValue(); - axis->vy = myDirSpin[1]->GetValue(); - axis->vz = myDirSpin[2]->GetValue(); - - theEditor->SplitHexahedraIntoPrisms( obj, myGroupChoice->checkedId()+1, - axis, myAllDomainsChk->isChecked() ); + SMESH::PointStruct_var point = new SMESH::PointStruct; + point->x = myPointSpin[0]->GetValue(); + point->y = myPointSpin[1]->GetValue(); + point->z = myPointSpin[2]->GetValue(); + SMESH::DirStruct_var norm = new SMESH::DirStruct; + norm->PS.x = myDirSpin[0]->GetValue(); + norm->PS.y = myDirSpin[1]->GetValue(); + norm->PS.z = myDirSpin[2]->GetValue(); + + theEditor->SplitHexahedraIntoPrisms( obj, point, norm, + myGroupChoice->checkedId()+1, + myAllDomainsChk->isChecked() ); } else { diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 7a59ad87f..15e2a183f 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -386,7 +386,7 @@ namespace { "ExtrusionSweepObject2D","ExtrusionSweepObject2DMakeGroups", "Translate","TranslateMakeGroups","TranslateMakeMesh", "TranslateObject","TranslateObjectMakeGroups", "TranslateObjectMakeMesh", - "ExtrusionAlongPathX","ExtrusionAlongPathObjX" + "ExtrusionAlongPathX","ExtrusionAlongPathObjX","SplitHexahedraIntoPrisms" ,"" }; // <- mark of the end methodsAcceptingList.Insert( methodNames ); } @@ -2376,7 +2376,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) "GetLastCreatedElems", "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh","TranslateObjectMakeMesh", "Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh", - "MakeBoundaryElements", "SplitVolumesIntoTetra", + "MakeBoundaryElements", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms", "DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups", "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup", "DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion", diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index b066d2492..a983a13c3 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -2028,22 +2028,23 @@ void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems, */ //================================================================================ -void SMESH_MeshEditor_i::SplitHexahedraIntoPrisms (SMESH::SMESH_IDSource_ptr elems, - CORBA::Short methodFlags, - const SMESH::AxisStruct & facetToSplitNormal, - CORBA::Boolean allDomains) +void SMESH_MeshEditor_i::SplitHexahedraIntoPrisms (SMESH::SMESH_IDSource_ptr elems, + const SMESH::PointStruct & startHexPoint, + const SMESH::DirStruct& facetToSplitNormal, + CORBA::Short methodFlags, + CORBA::Boolean allDomains) throw (SALOME::SALOME_Exception) { SMESH_TRY; initData(); prepareIdSource( elems ); - gp_Ax1 facetNorm( gp_Pnt( facetToSplitNormal.x, - facetToSplitNormal.y, - facetToSplitNormal.z ), - gp_Dir( facetToSplitNormal.vx, - facetToSplitNormal.vy, - facetToSplitNormal.vz )); + gp_Ax1 facetNorm( gp_Pnt( startHexPoint.x, + startHexPoint.y, + startHexPoint.z ), + gp_Dir( facetToSplitNormal.PS.x, + facetToSplitNormal.PS.y, + facetToSplitNormal.PS.z )); TIDSortedElemSet elemSet; SMESH::long_array_var anElementsId = elems->GetIDs(); SMDS_MeshElement::GeomFilter filter( SMDSGeom_HEXA ); @@ -2070,8 +2071,11 @@ void SMESH_MeshEditor_i::SplitHexahedraIntoPrisms (SMESH::SMESH_IDSource_ptr ele declareMeshModified( /*isReComputeSafe=*/true ); // it does not influence Compute() TPythonDump() << this << ".SplitHexahedraIntoPrisms( " - << elems << ", " << methodFlags<< ", " - << facetToSplitNormal<< ", " << allDomains << " )"; + << elems << ", " + << startHexPoint << ", " + << facetToSplitNormal<< ", " + << methodFlags<< ", " + << allDomains << " )"; SMESH_CATCH( SMESH::throwCorbaException ); } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index ed67dabef..350cefa46 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -233,10 +233,11 @@ public: void SplitVolumesIntoTetra(SMESH::SMESH_IDSource_ptr elems, CORBA::Short methodFlags) throw (SALOME::SALOME_Exception); - void SplitHexahedraIntoPrisms(SMESH::SMESH_IDSource_ptr elems, - CORBA::Short methodFlags, - const SMESH::AxisStruct & facetToSplitNormal, - CORBA::Boolean allDomains) + void SplitHexahedraIntoPrisms(SMESH::SMESH_IDSource_ptr elems, + const SMESH::PointStruct & startHexPoint, + const SMESH::DirStruct& facetToSplitNormal, + CORBA::Short methodFlags, + CORBA::Boolean allDomains) throw (SALOME::SALOME_Exception); CORBA::Boolean Smooth(const SMESH::long_array & IDsOfElements, diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 41791ff77..779aeb24e 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -3076,14 +3076,20 @@ class Mesh: pass # axis if isinstance( startHexPoint, geomBuilder.GEOM._objref_GEOM_Object): - startHexPoint = self.geompyD.PointCoordinates( startHexPoint ) + startHexPoint = self.smeshpyD.GetPointStruct( startHexPoint ) + elif isinstance( startHexPoint, list ): + startHexPoint = SMESH.PointStruct( startHexPoint[0], + startHexPoint[1], + startHexPoint[2]) if isinstance( facetNormal, geomBuilder.GEOM._objref_GEOM_Object): - facetNormal = self.geompyD.VectorCoordinates( facetNormal ) - axis = SMESH.AxisStruct( startHexPoint[0], startHexPoint[1], startHexPoint[2], - facetNormal[0], facetNormal[1], facetNormal[2]) - self.mesh.SetParameters( axis.parameters ) - - self.editor.SplitHexahedraIntoPrisms(elems, method, axis, allDomains) + facetNormal = self.smeshpyD.GetDirStruct( facetNormal ) + elif isinstance( facetNormal, list ): + facetNormal = self.smeshpyD.MakeDirStruct( facetNormal[0], + facetNormal[1], + facetNormal[2]) + self.mesh.SetParameters( startHexPoint.parameters + facetNormal.PS.parameters ) + + self.editor.SplitHexahedraIntoPrisms(elems, startHexPoint, facetNormal, method, allDomains) ## Splits quadrangle faces near triangular facets of volumes # -- 2.39.2