X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_2smeshpy.cxx;h=572413800b1a6f6229fb30578f855c8162f0e9b6;hp=9c68a33be6d5c427d09f6be082a76501921d79bb;hb=09705577d153a1af07a5619503d3338b67951440;hpb=cc9e7d544292b687b0cc729bc455c147bd65ac54 diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 9c68a33be..572413800 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -384,6 +384,7 @@ namespace { "ExtrusionSweepObjectMakeGroups","ExtrusionSweepObject0D", "ExtrusionSweepObject1D","ExtrusionSweepObject1DMakeGroups", "ExtrusionSweepObject2D","ExtrusionSweepObject2DMakeGroups", + "ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects", "Translate","TranslateMakeGroups","TranslateMakeMesh", "TranslateObject","TranslateObjectMakeGroups", "TranslateObjectMakeMesh", "ExtrusionAlongPathX","ExtrusionAlongPathObjX","SplitHexahedraIntoPrisms" @@ -431,7 +432,8 @@ namespace { "ExportCGNS","ExportGMF", "Create0DElementsOnAllNodes","Reorient2D","QuadTo4Tri", "ScaleMakeGroups","Scale","ScaleMakeMesh", - "FindCoincidentNodesOnPartBut","DoubleElements" + "FindCoincidentNodesOnPartBut","DoubleElements", + "ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects" ,"" }; // <- mark of the end methodsAcceptingList.Insert( methodNames ); } @@ -888,18 +890,22 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand if ( Type == "SMESH.FT_ElemGeomType" ) { // set SMESH.GeometryType instead of a numerical Threshold - const int nbTypes = SMESH::Geom_BALL+1; + const int nbTypes = SMESH::Geom_LAST; const char* types[nbTypes] = { "Geom_POINT", "Geom_EDGE", "Geom_TRIANGLE", "Geom_QUADRANGLE", "Geom_POLYGON", "Geom_TETRA", "Geom_PYRAMID", "Geom_HEXA", "Geom_PENTA", "Geom_HEXAGONAL_PRISM", "Geom_POLYHEDRA", "Geom_BALL" }; if ( -1 < iGeom && iGeom < nbTypes ) Threshold = SMESH + types[ iGeom ]; +#ifdef _DEBUG_ + // is types complete? (compilation failure mains that enum GeometryType changed) + int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ]; +#endif } if (Type == "SMESH.FT_EntityType") { // set SMESH.EntityType instead of a numerical Threshold - const int nbTypes = SMESH::Entity_Ball+1; + const int nbTypes = SMESH::Entity_Last; const char* types[nbTypes] = { "Entity_Node", "Entity_0D", "Entity_Edge", "Entity_Quad_Edge", "Entity_Triangle", "Entity_Quad_Triangle", "Entity_BiQuad_Triangle", @@ -911,6 +917,10 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand "Entity_Polyhedra", "Entity_Quad_Polyhedra", "Entity_Ball" }; if ( -1 < iGeom && iGeom < nbTypes ) Threshold = SMESH + types[ iGeom ]; +#ifdef _DEBUG_ + // is types complete? (compilation failure mains that enum EntityType changed) + int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ]; +#endif } } if ( ThresholdID.Length() != 2 ) // neither '' nor "" @@ -1793,10 +1803,29 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) list< Handle(_pyHypothesis) >::iterator hyp; if ( !myLastComputeCmd.IsNull() ) { - for ( hyp = myHypos.begin(); hyp != myHypos.end(); ++hyp ) - (*hyp)->ComputeDiscarded( myLastComputeCmd ); + // check if the previously computed mesh has been edited, + // if so then we do not clear the previous Compute() + bool toClear = true; + if ( myLastComputeCmd->GetMethod() == "Compute" ) + { + list< Handle(_pyMeshEditor)>::iterator e = myEditors.begin(); + for ( ; e != myEditors.end() && toClear; ++e ) + { + list< Handle(_pyCommand)>& cmds = (*e)->GetProcessedCmds(); + list< Handle(_pyCommand) >::reverse_iterator cmd = cmds.rbegin(); + if ( cmd != cmds.rend() && + (*cmd)->GetOrderNb() > myLastComputeCmd->GetOrderNb() ) + toClear = false; + } + } + if ( toClear ) + { + // clear hyp commands called before myLastComputeCmd + for ( hyp = myHypos.begin(); hyp != myHypos.end(); ++hyp ) + (*hyp)->ComputeDiscarded( myLastComputeCmd ); - myLastComputeCmd->Clear(); + myLastComputeCmd->Clear(); + } } myLastComputeCmd = theCommand; @@ -1961,11 +1990,11 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) // // remove "PartTo" from the method TCollection_AsciiString newMethod = method; - newMethod.Remove( 7, 6 ); + newMethod.Remove( /*where=*/7, /*howmany=*/6 ); theCommand->SetMethod( newMethod ); - // make the 1st arg be the last one (or last but one for ExportMED()) + // make the 1st arg be the last one (or last but three for ExportMED()) _pyID partID = theCommand->GetArg( 1 ); - int nbArgs = theCommand->GetNbArgs() - (newMethod == "ExportMED"); + int nbArgs = theCommand->GetNbArgs() - 3 * (newMethod == "ExportMED"); for ( int i = 2; i <= nbArgs; ++i ) theCommand->SetArg( i-1, theCommand->GetArg( i )); theCommand->SetArg( nbArgs, partID ); @@ -2006,6 +2035,14 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) addCmd->Clear(); theCommand->Clear(); } + else + { + // mesh.AddHypothesis(geom, hyp) --> mesh.AddHypothesis(hyp, geom=0) + addCmd->RemoveArgs(); + addCmd->SetArg( 1, hypID ); + if ( isLocal ) + addCmd->SetArg( 2, geomID ); + } } else { @@ -2361,14 +2398,15 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) "AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace","AddBall", "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces", "MoveNode", "MoveClosestNodeToPoint", - "InverseDiag","DeleteDiag","Reorient","ReorientObject", + "InverseDiag","DeleteDiag","Reorient","ReorientObject","Reorient2DBy3D", "TriToQuad","TriToQuadObject", "QuadTo4Tri", "SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D", "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D", - "ExtrusionSweepObject2D","ExtrusionAlongPath","ExtrusionAlongPathObject", + "ExtrusionByNormal", "ExtrusionSweepObject2D","ExtrusionAlongPath","ExtrusionAlongPathObject", "ExtrusionAlongPathX","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", + "ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects", "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject", "FindCoincidentNodes","MergeNodes","FindEqualElements", "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", @@ -2750,7 +2788,7 @@ void _pyHypothesis::Process( const Handle(_pyCommand)& theCommand) myArgCommands.push_back( theCommand ); usedCommand = true; while ( crMethod.myArgs.size() < i+1 ) - crMethod.myArgs.push_back( "[]" ); + crMethod.myArgs.push_back( "None" ); crMethod.myArgs[ i ] = theCommand->GetArg( crMethod.myArgNb[i] ); } } @@ -3092,9 +3130,11 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand) { // CartesianParameters3D hyp - if ( theCommand->GetMethod() == "SetSizeThreshold" ) + if ( theCommand->GetMethod() == "SetSizeThreshold" || + theCommand->GetMethod() == "SetToAddEdges" ) { - setCreationArg( 4, theCommand->GetArg( 1 )); + int iEdges = ( theCommand->GetMethod().Value( 4 ) == 'T' ); + setCreationArg( 4+iEdges, theCommand->GetArg( 1 )); myArgCommands.push_back( theCommand ); return; } @@ -3153,23 +3193,28 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand) void _pyComplexParamHypo::Flush() { + list < Handle(_pyCommand) >::iterator cmd; if ( IsWrapped() ) { - list < Handle(_pyCommand) >::iterator cmd = myUnusedCommands.begin(); - for ( ; cmd != myUnusedCommands.end(); ++cmd ) + for ( cmd = myUnusedCommands.begin(); cmd != myUnusedCommands.end(); ++cmd ) if ((*cmd)->GetMethod() == "SetObjectEntry" ) (*cmd)->Clear(); - - if ( GetAlgoType() == "Cartesian_3D" ) - { - _pyID algo = myCreationCmd->GetObject(); - for ( cmd = myProcessedCmds.begin(); cmd != myProcessedCmds.end(); ++cmd ) - { - StructToList( *cmd, /*checkMethod=*/false ); - (*cmd)->SetObject( algo ); - } - } } + + // if ( GetAlgoType() == "Cartesian_3D" ) + // { + // _pyID algo = myCreationCmd->GetObject(); + // for ( cmd = myProcessedCmds.begin(); cmd != myProcessedCmds.end(); ++cmd ) + // { + // if ( IsWrapped() ) + // { + // StructToList( *cmd, /*checkMethod=*/false ); + // const _AString & method = (*cmd)->GetMethod(); + // if ( method == "SetFixedPoint" ) + // (*cmd)->SetObject( algo ); + // } + // } + // } } //================================================================================