-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
// 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
#include <unistd.h>
#endif
-
-IMPLEMENT_STANDARD_HANDLE (_pyObject ,Standard_Transient);
-IMPLEMENT_STANDARD_HANDLE (_pyCommand ,Standard_Transient);
-IMPLEMENT_STANDARD_HANDLE (_pyHypothesisReader,Standard_Transient);
-IMPLEMENT_STANDARD_HANDLE (_pyGen ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyMesh ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pySubMesh ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyMeshEditor ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyHypothesis ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pySelfEraser ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyGroup ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyFilter ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
-IMPLEMENT_STANDARD_HANDLE (_pyComplexParamHypo,_pyHypothesis);
-IMPLEMENT_STANDARD_HANDLE (_pyNumberOfSegmentsHyp,_pyHypothesis);
-
-IMPLEMENT_STANDARD_RTTIEXT(_pyObject ,Standard_Transient);
-IMPLEMENT_STANDARD_RTTIEXT(_pyCommand ,Standard_Transient);
-IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient);
-IMPLEMENT_STANDARD_RTTIEXT(_pyGen ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pySelfEraser ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyGroup ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyFilter ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
-IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
-IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
-IMPLEMENT_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis);
-IMPLEMENT_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyObject ,Standard_Transient);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyCommand ,Standard_Transient);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyGen ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySelfEraser ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyGroup ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyFilter ,_pyObject);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis);
+OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis);
using namespace std;
using SMESH::TPythonDump;
_AString comment;
_pyID obj = cmd->GetObject();
+ if ( obj.Search( "print " ) == 1 )
+ return; // print statement
+
if ( !obj.IsEmpty() && obj.Value( obj.Length() ) == ')' )
// remove an accessor method
obj = _pyCommand( obj ).GetObject();
// - FT_EntityType = 36
// v 7.3.0: FT_Undefined == 46, new items:
// - FT_ConnectedElements = 39
+ // v 7.6.0: FT_Undefined == 47, new items:
+ // - FT_BelongToMeshGroup = 22
+ // v 8.1.0: FT_Undefined == 48, new items:
+ // - FT_NodeConnectivityNumber= 22
//
// It's necessary to continue recording this history and to fill
// undef2newItems (see below) accordingly.
undef2newItems[ 44 ].push_back( 37 );
undef2newItems[ 45 ].push_back( 36 );
undef2newItems[ 46 ].push_back( 39 );
+ undef2newItems[ 47 ].push_back( 22 );
+ undef2newItems[ 48 ].push_back( 22 );
ASSERT( undef2newItems.rbegin()->first == SMESH::FT_Undefined );
}
*/
//================================================================================
- void StructToList( Handle( _pyCommand)& theCommand )
+ void StructToList( Handle( _pyCommand)& theCommand, const bool checkMethod=true )
{
static TStringSet methodsAcceptingList;
if ( methodsAcceptingList.empty() ) {
"ExtrusionSweepObjectMakeGroups","ExtrusionSweepObject0D",
"ExtrusionSweepObject1D","ExtrusionSweepObject1DMakeGroups",
"ExtrusionSweepObject2D","ExtrusionSweepObject2DMakeGroups",
+ "ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects",
"Translate","TranslateMakeGroups","TranslateMakeMesh",
"TranslateObject","TranslateObjectMakeGroups", "TranslateObjectMakeMesh",
- "ExtrusionAlongPathX","ExtrusionAlongPathObjX"
+ "ExtrusionAlongPathX","ExtrusionAlongPathObjX","SplitHexahedraIntoPrisms"
,"" }; // <- mark of the end
methodsAcceptingList.Insert( methodNames );
}
- if ( methodsAcceptingList.Contains( theCommand->GetMethod() ))
+ if ( !checkMethod || methodsAcceptingList.Contains( theCommand->GetMethod() ))
{
for ( int i = theCommand->GetNbArgs(); i > 0; --i )
{
"ExportCGNS","ExportGMF",
"Create0DElementsOnAllNodes","Reorient2D","QuadTo4Tri",
"ScaleMakeGroups","Scale","ScaleMakeMesh",
- "FindCoincidentNodesOnPartBut","DoubleElements"
+ "FindCoincidentNodesOnPartBut","DoubleElements",
+ "ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects"
,"" }; // <- mark of the end
methodsAcceptingList.Insert( methodNames );
}
* \param theRemovedObjIDs - entries of objects whose created commands were removed
* \param theHistoricalDump - true means to keep all commands, false means
* to exclude commands relating to objects removed from study
- * \retval TCollection_AsciiString - Convertion result
+ * \retval TCollection_AsciiString - Conversion result
*/
//================================================================================
{
//id_mesh->second->AddProcessedCmd( aCommand );
+ // Wrap Export*() into try-except
+ if ( aCommand->MethodStartsFrom("Export"))
+ {
+ _AString tab = "\t";
+ _AString indent = aCommand->GetIndentation();
+ _AString tryStr = indent + "try:";
+ _AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() );
+ _AString pasCmd = indent + tab + "pass"; // to keep valid if newCmd is erased
+ _AString excStr = indent + "except:";
+ _AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'";
+
+ myCommands.insert( --myCommands.end(), new _pyCommand( tryStr, myNbCommands ));
+ aCommand->Clear();
+ aCommand->GetString() = newCmd;
+ aCommand->SetOrderNb( ++myNbCommands );
+ myCommands.push_back( new _pyCommand( pasCmd, ++myNbCommands ));
+ myCommands.push_back( new _pyCommand( excStr, ++myNbCommands ));
+ myCommands.push_back( new _pyCommand( msgStr, ++myNbCommands ));
+ }
// check for mesh editor object
if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
_pyID editorID = aCommand->GetResultValue();
if ( Type == "SMESH.FT_ElemGeomType" )
{
// set SMESH.GeometryType instead of a numerical Threshold
- const int nbTypes = SMESH::Geom_BALL+1;
- const char* types[nbTypes] = {
+ const int nbTypes = SMESH::Geom_LAST;
+ const char* types[] = {
"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 _asrt[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 2 : -1 ]; _asrt[0]=_asrt[1];
+#endif
}
if (Type == "SMESH.FT_EntityType")
{
// set SMESH.EntityType instead of a numerical Threshold
- const int nbTypes = SMESH::Entity_Ball+1;
- const char* types[nbTypes] = {
+ const int nbTypes = SMESH::Entity_Last;
+ const char* types[] = {
"Entity_Node", "Entity_0D", "Entity_Edge", "Entity_Quad_Edge",
"Entity_Triangle", "Entity_Quad_Triangle", "Entity_BiQuad_Triangle",
"Entity_Quadrangle", "Entity_Quad_Quadrangle", "Entity_BiQuad_Quadrangle",
"Entity_Polygon", "Entity_Quad_Polygon", "Entity_Tetra", "Entity_Quad_Tetra",
"Entity_Pyramid", "Entity_Quad_Pyramid",
"Entity_Hexa", "Entity_Quad_Hexa", "Entity_TriQuad_Hexa",
- "Entity_Penta", "Entity_Quad_Penta", "Entity_Hexagonal_Prism",
+ "Entity_Penta", "Entity_Quad_Penta", "Entity_BiQuad_Penta", "Entity_Hexagonal_Prism",
"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 _asrt[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 2 : -1 ]; _asrt[0]=_asrt[1];
+#endif
}
}
if ( ThresholdID.Length() != 2 ) // neither '' nor ""
* \brief Find algorithm able to create a hypothesis
* \param theGeom - The shape ID the algorithm was created on
* \param theMesh - The mesh ID that created the algorithm
- * \param theHypothesis - The hypothesis the algorithm sould be able to create
+ * \param theHypothesis - The hypothesis the algorithm should be able to create
* \retval Handle(_pyHypothesis) - The found algo
*/
//================================================================================
}
while ( myObjectNames.IsBound( aNewID ) );
- myObjectNames.Bind( aNewID, myObjectNames.IsBound( theID )
- ? (myObjectNames.Find( theID ) + _pyID( "_" ) + _pyID( index-1 ))
- : _pyID( "A" ) + aNewID );
+ if ( myObjectNames.IsBound( theID ) )
+ myObjectNames.Bind( aNewID, ( myObjectNames.Find( theID ) + _pyID( "_" ) + _pyID( index-1 ) ) );
+ else
+ myObjectNames.Bind( aNewID, ( _pyID( "A" ) + aNewID ) );
return aNewID;
}
return;
const bool isHyp = theObj->IsKind( STANDARD_TYPE( _pyHypothesis ));
- Handle(_pyObject) existing =
- isHyp ? FindHyp( theObj->GetID() ) : FindObject( theObj->GetID() );
+ Handle(_pyObject) existing;
+ if( isHyp )
+ existing = FindHyp( theObj->GetID() );
+ else
+ existing = FindObject( theObj->GetID() );
if ( !existing.IsNull() && existing != theObj )
{
existing->SetRemovedFromStudy( true );
return id_obj->second;
}
{
- map< _pyID, Handle(_pyMesh) >::const_iterator id_obj = myMeshes.find( theObjID );
+ _pyGen* me = const_cast< _pyGen* >( this );
+ map< _pyID, Handle(_pyMesh) >::iterator id_obj = me->myMeshes.find( theObjID );
if ( id_obj != myMeshes.end() )
return id_obj->second;
}
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;
}
}
// ----------------------------------------------------------------------
- else if ( method == "GetSubMesh" ) { // collect submeshes of the mesh
+ else if ( method == "GetSubMesh" ) { // collect sub-meshes of the mesh
Handle(_pySubMesh) subMesh = theGen->FindSubMesh( theCommand->GetResultValue() );
if ( !subMesh.IsNull() ) {
subMesh->SetCreator( this );
}
}
// ----------------------------------------------------------------------
+ else if ( method == "GetSubMeshes" ) { // clear as the command does nothing (0023156)
+ theCommand->Clear();
+ }
+ // ----------------------------------------------------------------------
else if ( method == "AddHypothesis" ) { // mesh.AddHypothesis(geom, HYPO )
myAddHypCmds.push_back( theCommand );
// set mesh to hypo
// ----------------------------------------------------------------------
else if ( method == "CreateGroup" ||
method == "CreateGroupFromGEOM" ||
- method == "CreateGroupFromFilter" )
+ method == "CreateGroupFromFilter" ||
+ method == "CreateDimGroup" )
{
Handle(_pyGroup) group = new _pyGroup( theCommand );
myGroups.push_back( group );
TCollection_AsciiString grIDs = theCommand->GetResultValue();
list< _pyID > idList = theCommand->GetStudyEntries( grIDs );
list< _pyID >::iterator grID = idList.begin();
- const int nbGroupsBefore = myGroups.size();
+ const size_t nbGroupsBefore = myGroups.size();
Handle(_pyObject) obj;
for ( ; grID != idList.end(); ++grID )
{
//
// 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 );
{
addCmd = *cmd;
cmd = addHypCmds.erase( cmd );
- if ( !theGen->IsToKeepAllCommands() && CanClear() ) {
+ if ( !theGen->IsToKeepAllCommands() /*&& CanClear()*/ ) {
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
{
if ( sameMethods.empty() ) {
const char * names[] =
{ "ExportDAT","ExportUNV","ExportSTL","ExportSAUV", "RemoveGroup","RemoveGroupWithContents",
- "GetGroups","UnionGroups","IntersectGroups","CutGroups","GetLog","GetId","ClearLog",
- "GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
+ "GetGroups","UnionGroups","IntersectGroups","CutGroups","CreateDimGroup","GetLog","GetId",
+ "ClearLog","GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
"NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
"NbTrianglesOfOrder","NbQuadrangles","NbQuadranglesOfOrder","NbPolygons","NbVolumes",
"NbVolumesOfOrder","NbTetras","NbTetrasOfOrder","NbHexas","NbHexasOfOrder",
"GetSubMeshElementsId","GetSubMeshNodesId","GetSubMeshElementType","Dump","GetNodeXYZ",
"GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
"GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
+ "GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes",
"IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
"Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder"
,"" }; // <- mark of end
for ( ; m != fatherMeshes.end(); ++m )
addFatherMesh( *m );
// if ( removedGeom )
- // SetRemovedFromStudy(); // as reffered geometry not in study
+ // SetRemovedFromStudy(); // as referred geometry not in study
}
if ( myGeomNotInStudy )
return;
"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",
+ "FindCoincidentFreeBorders", "SewCoincidentFreeBorders",
"SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
"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",
hyp->SetConvMethodAndType( "SetGrid", "Cartesian_3D");
for ( int iArg = 0; iArg < 4; ++iArg )
hyp->setCreationArg( iArg+1, "[]");
+ hyp->AddAccumulativeMethod( "SetGrid" );
+ hyp->AddAccumulativeMethod( "SetGridSpacing" );
}
else
{
* \brief Convert the command adding a hypothesis to mesh into a smesh command
* \param theCmd - The command like mesh.AddHypothesis( geom, hypo )
* \param theAlgo - The algo that can create this hypo
- * \retval bool - false if the command cant be converted
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
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] );
}
}
//================================================================================
/*!
- * \brief clear creation, arg and unkown commands
+ * \brief clear creation, arg and unknown commands
*/
//================================================================================
{
if ( myCurCrMethod )
{
- while ( myCurCrMethod->myArgs.size() < argNb )
+ while ( (int) myCurCrMethod->myArgs.size() < argNb )
myCurCrMethod->myArgs.push_back( "None" );
if ( arg.IsEmpty() )
myCurCrMethod->myArgs[ argNb-1 ] = "None";
{
// 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;
}
myCurCrMethod->myArgs[ iArg ] += "]";
}
myArgCommands.push_back( theCommand );
- rememberCmdOfParameter( theCommand );
+ //rememberCmdOfParameter( theCommand ); -- these commands are marked as
+ // accumulative, else, if the creation
+ // is not converted, commands for axes 1 and 2 are lost
return;
}
}
for ( ; type2meth != myAlgoType2CreationMethod.end(); ++type2meth )
{
CreationMethod& crMethod = type2meth->second;
- while ( crMethod.myArgs.size() < i+1 )
+ while ( (int) crMethod.myArgs.size() < i+1 )
crMethod.myArgs.push_back( "[]" );
crMethod.myArgs[ i ] = theCommand->GetArg( 1 ); // arg value
}
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 )
+ // {
+ // if ( IsWrapped() )
+ // {
+ // StructToList( *cmd, /*checkMethod=*/false );
+ // const _AString & method = (*cmd)->GetMethod();
+ // if ( method == "SetFixedPoint" )
+ // (*cmd)->SetObject( algo );
+ // }
+ // }
+ // }
}
//================================================================================
/*!
* \brief Convert methods of 1D hypotheses to my own methods
- * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
*/
//================================================================================
* \brief additionally to Addition2Creation, clears SetDistrType() command
* \param theCmd - AddHypothesis() command
* \param theMesh - mesh to which a hypothesis is added
- * \retval bool - convertion result
+ * \retval bool - conversion result
*/
//================================================================================
* into regular1D.LengthNearVertex( length, vertex )
* \param theCmd - The command like mesh.AddHypothesis( vertex, SegmentLengthAroundVertex )
* \param theMesh - The mesh needing this hypo
- * \retval bool - false if the command cant be converted
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
_pyID vertex = theCmd->GetArg( 1 );
- // the problem here is that segment algo will not be found
+ // the problem here is that segment algo can be not found
// by pyHypothesis::Addition2Creation() for <vertex>, so we try to find
// geometry where segment algorithm is assigned
- Handle(_pyHypothesis) algo;
_pyID geom = vertex;
+ Handle(_pyHypothesis) algo = theGen->FindAlgo( geom, theMeshID, this );
while ( algo.IsNull() && !geom.IsEmpty()) {
// try to find geom as a father of <vertex>
geom = FatherID( geom );
algo = theGen->FindAlgo( geom, theMeshID, this );
}
- if ( algo.IsNull() )
+ if ( algo.IsNull() || geom.IsEmpty() )
return false; // also possible to find geom as brother of veretex...
+
// set geom instead of vertex
theCmd->SetArg( 1, geom );
- // set vertex as a second arg
- if ( myCurCrMethod->myArgs.size() < 1) setCreationArg( 1, "1" ); // :(
- setCreationArg( 2, vertex );
-
// mesh.AddHypothesis(vertex, SegmentLengthAroundVertex) -->
- // theMeshID.LengthNearVertex( length, vertex )
- return _pyHypothesis::Addition2Creation( theCmd, theMeshID );
+ // SegmentLengthAroundVertex = Regular_1D.LengthNearVertex( length )
+ if ( _pyHypothesis::Addition2Creation( theCmd, theMeshID ))
+ {
+ // set vertex as a second arg
+ theCmd->SetArg( 2, vertex );
+
+ return true;
+ }
}
return false;
}
* \brief Convert the command adding an algorithm to mesh
* \param theCmd - The command like mesh.AddHypothesis( geom, algo )
* \param theMesh - The mesh needing this algo
- * \retval bool - false if the command cant be converted
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
TCollection_AsciiString _pyCommand::GetIndentation()
{
int end = 1;
- if ( GetBegPos( RESULT_IND ) == UNKNOWN )
- GetWord( myString, end, true );
- else
- end = GetBegPos( RESULT_IND );
- return myString.SubString( 1, Max( end - 1, 1 ));
+ //while ( end <= Length() && isblank( myString.Value( end )))
+ //ANA: isblank() function isn't provided in VC2010 compiler
+ while ( end <= Length() && ( myString.Value( end ) == ' ' || myString.Value( end ) == '\t') )
+ ++end;
+ return ( end == 1 ) ? _AString("") : myString.SubString( 1, end - 1 );
}
//================================================================================
if ( GetBegPos( METHOD_IND ) == UNKNOWN )
{
// beginning
- int begPos = GetBegPos( OBJECT_IND ) + myObj.Length();
+ int begPos = GetBegPos( OBJECT_IND );
bool forward = true;
if ( begPos < 1 ) {
begPos = myString.Location( "(", 1, Length() ) - 1;
forward = false;
}
+ else {
+ begPos += myObj.Length();
+ }
// store
myMeth = GetWord( myString, begPos, forward );
SetBegPos( METHOD_IND, begPos );
{
int nbCalls = 0;
std::list< Handle(_pyCommand) >& cmds = GetProcessedCmds();
- std::list< Handle(_pyCommand) >::const_iterator cmd = cmds.begin();
- for ( ; cmd != cmds.end(); ++cmd )
+ std::list< Handle(_pyCommand) >::iterator cmd = cmds.begin();
+ for ( ; cmd != cmds.end(); )
// check of cmd emptiness is not enough as object can change
- nbCalls += ( ( *cmd )->GetString().Search( GetID() ) > 0 );
+ if (( *cmd )->GetString().Search( GetID() ) > 0 )
+ ++nbCalls, ++cmd;
+ else
+ cmd = cmds.erase( cmd ); // save the cmd from clearing
toErase = ( nbCalls < 1 );
}