X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Pattern_i.cxx;h=887dfe51f89dd105e7506f9cc7450abb91c71417;hp=d0b8bd2161188c900139d0b9ce6a5fee5d7a2963;hb=a5e3cc49d703c008b20d1ba71858a4d5164210c5;hpb=e465982eeb48dded773c5e18053a8da7fcf15222 diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx index d0b8bd216..887dfe51f 100644 --- a/src/SMESH_I/SMESH_Pattern_i.cxx +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -42,10 +42,22 @@ #include #include -// ============================================================================= +//======================================================================= +//function : dumpErrorCode +//purpose : +//======================================================================= + +static void addErrorCode(const char* thePyCommand) +{ + SMESH_Gen_i::AddToCurrentPyScript("if (isDone != 1):"); + TCollection_AsciiString str ("\tprint \""); + str += (char*) thePyCommand; + str += ":\", pattern.GetErrorCode()"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +} + //============================================================================= /*! -// ============================================================================= * SMESH_Gen_i::GetPattern * * Create pattern mapper @@ -54,6 +66,9 @@ SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern() { + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( "pattern = smesh.GetPattern()" ); + SMESH_Pattern_i* i = new SMESH_Pattern_i( this ); SMESH::SMESH_Pattern_var anObj = i->_this(); return anObj._retn(); @@ -91,6 +106,12 @@ SMESH_Pattern_i::SMESH_Pattern_i( SMESH_Gen_i* theGen_i ): CORBA::Boolean SMESH_Pattern_i::LoadFromFile(const char* theFileContents) { + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFromFile(" ); + str += TCollection_AsciiString( (char*) theFileContents ) + ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFromFile" ); + return myPattern.Load( theFileContents ); } @@ -110,11 +131,19 @@ CORBA::Boolean SMESH_Pattern_i::LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh, if ( !aMesh ) return false; - TopoDS_Face aFace = TopoDS::Face( myGen->GeomObjectToShape( theFace )); - if ( aFace.IsNull() ) + TopoDS_Shape aFace = myGen->GeomObjectToShape( theFace ); + if ( aFace.IsNull() || aFace.ShapeType() != TopAbs_FACE ) return false; - return myPattern.Load( aMesh, aFace, theProject ); + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFromFace( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddObject( str, theFace ) += ", "; + str += TCollection_AsciiString( theProject ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFromFace" ); + + return myPattern.Load( aMesh, TopoDS::Face( aFace ), theProject ); } //======================================================================= @@ -140,6 +169,13 @@ CORBA::Boolean SMESH_Pattern_i::LoadFrom3DBlock(SMESH::SMESH_Mesh_ptr theMesh, if ( !exp.More() ) return false; + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFrom3DBlock( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddObject( str, theBlock ) += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFrom3DBlock" ); + return myPattern.Load( aMesh, TopoDS::Shell( exp.Current() )); } @@ -172,6 +208,13 @@ SMESH::point_array* SMESH_Pattern_i::ApplyToFace(GEOM::GEOM_Object_ptr theFace, } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToFace( " ); + SMESH_Gen_i::AddObject( str, theFace ) += ", "; + SMESH_Gen_i::AddObject( str, theVertexOnKeyPoint1 ) += ", "; + str += TCollection_AsciiString( theReverse ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -208,6 +251,13 @@ SMESH::point_array* SMESH_Pattern_i::ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlo } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyTo3DBlock( " ); + SMESH_Gen_i::AddObject( str, theBlock ) += ", "; + SMESH_Gen_i::AddObject( str, theVertex000 ) += ", "; + SMESH_Gen_i::AddObject( str, theVertex001 ) += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -248,6 +298,14 @@ SMESH::point_array* } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToMeshFaces( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddArray( str, theFacesIDs ) += ", "; + str += TCollection_AsciiString( (int)theNodeIndexOnKeyPoint1 ) + ", "; + str += TCollection_AsciiString( theReverse ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -288,6 +346,14 @@ SMESH::point_array* } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToHexahedrons( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddArray( str, theVolumesIDs ) += ", "; + str += TCollection_AsciiString( (int)theNode000Index ) + ", "; + str += TCollection_AsciiString( (int)theNode001Index ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -296,13 +362,23 @@ SMESH::point_array* //purpose : //======================================================================= -CORBA::Boolean SMESH_Pattern_i::MakeMesh(SMESH::SMESH_Mesh_ptr theMesh) +CORBA::Boolean SMESH_Pattern_i::MakeMesh (SMESH::SMESH_Mesh_ptr theMesh, + const CORBA::Boolean CreatePolygons, + const CORBA::Boolean CreatePolyedrs) { ::SMESH_Mesh* aMesh = getMesh( theMesh ); if ( !aMesh ) return false; - return myPattern.MakeMesh( aMesh ); + // Update Python script + TCollection_AsciiString str( "isDone = pattern.MakeMesh( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + str += TCollection_AsciiString( CreatePolygons ) + ", "; + str += TCollection_AsciiString( CreatePolyedrs ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "MakeMesh" ); + + return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs ); } //=======================================================================