// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
+#include <OSD.hxx>
#include "Utils_CorbaException.hxx"
#include "Utils_ExceptHandlers.hxx"
#include <map>
-#include <boost/filesystem/path.hpp>
using namespace std;
using SMESH::TPythonDump;
_thisObj = this ;
_id = myPoa->activate_object( _thisObj );
+ myIsEmbeddedMode = false;
myShapeReader = NULL; // shape reader
mySMESHGen = this;
+
+ // set it in standalone mode only
+ //OSD::SetSignal( true );
}
//=============================================================================
aPlatformLibName[0] = '\0';
aPlatformLibName = strcat( aPlatformLibName, "lib" );
aPlatformLibName = strcat( aPlatformLibName, theLibName );
- aPlatformLibName = strcat( aPlatformLibName, ".dll" );
+ aPlatformLibName = strcat( aPlatformLibName, ".so" );
#endif
}
if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName);
myHypothesis_i =
myHypCreatorMap[string(theHypName)]->Create (myPoa, GetCurrentStudyID(), &myGen);
- // _CS_gbo Explicit activation (no longer made in the constructor).
- myHypothesis_i->Activate();
myHypothesis_i->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance
}
catch (SALOME_Exception& S_ex)
// create a new mesh object servant, store it in a map in study context
SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
// create a new mesh object
- meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID() ));
+ meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
// activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
return myShapeReader;
}
+//=============================================================================
+/*!
+ * SMESH_Gen_i::SetEmbeddedMode
+ *
+ * Set current mode
+ */
+//=============================================================================
+
+void SMESH_Gen_i::SetEmbeddedMode( CORBA::Boolean theMode )
+{
+ myIsEmbeddedMode = theMode;
+
+ if ( !myIsEmbeddedMode ) {
+ bool raiseFPE;
+#ifdef _DEBUG_
+ raiseFPE = true;
+ char* envDisableFPE = getenv("DISABLE_FPE");
+ if (envDisableFPE && atoi(envDisableFPE))
+ raiseFPE = false;
+#else
+ raiseFPE = false;
+#endif
+ OSD::SetSignal( raiseFPE );
+ }
+ // else OSD::SetSignal() is called in GUI
+}
+
+//=============================================================================
+/*!
+ * SMESH_Gen_i::IsEmbeddedMode
+ *
+ * Get current mode
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::IsEmbeddedMode()
+{
+ return myIsEmbeddedMode;
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::SetCurrentStudy
myStudyContextMap[ studyId ] = new StudyContext;
}
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
- if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
- aStudyBuilder->LoadWith( myCurrentStudy->FindComponent( "GEOM" ), GetGeomEngine() );
+ // myCurrentStudy may be nil
+ if ( !CORBA::is_nil( myCurrentStudy ) ) {
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
+ aStudyBuilder->LoadWith( myCurrentStudy->FindComponent( "GEOM" ), GetGeomEngine() );
// set current study for geom engine
//if ( !CORBA::is_nil( GetGeomEngine() ) )
// GetGeomEngine()->GetCurrentStudy( myCurrentStudy->StudyId() );
+ }
}
//=============================================================================
return mesh._retn();
}
+//=============================================================================
+/*!
+ * SMESH_Gen_i::CreateEmptyMesh
+ *
+ * Create empty mesh
+ */
+//=============================================================================
+
+SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh()
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" );
+ // create mesh
+ SMESH::SMESH_Mesh_var mesh = this->createMesh();
+
+ // publish mesh in the study
+ if ( CanPublishInStudy( mesh ) ) {
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+ SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, mesh.in() );
+ aStudyBuilder->CommitCommand();
+ if ( !aSO->_is_nil() ) {
+ // Update Python script
+ TPythonDump() << aSO << " = " << this << ".CreateEmptyMesh()";
+ }
+ }
+
+ return mesh._retn();
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::CreateMeshFromUNV
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromUNV" );
SMESH::SMESH_Mesh_var aMesh = createMesh();
- string aFileName; // = boost::filesystem::path(theFileName).leaf();
+ string aFileName;
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
ASSERT( aServant );
aServant->ImportUNVFile( theFileName );
+
+ // Dump creation of groups
+ aServant->GetGroups();
+
return aMesh._retn();
}
Unexpect aCatch(SALOME_SalomeException);
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
- // Python Dump
- TPythonDump aPythonDump;
- aPythonDump << "([";
- //TCollection_AsciiString aStr ("([");
-
// Retrieve mesh names from the file
DriverMED_R_SMESHDS_Mesh myReader;
myReader.SetFile( theFileName );
list<string> aNames = myReader.GetMeshNames(aStatus);
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
+
+ { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
+
+ // Python Dump
+ TPythonDump aPythonDump;
+ aPythonDump << "([";
+ //TCollection_AsciiString aStr ("([");
+
if (theStatus == SMESH::DRS_OK) {
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
// Update Python script
aPythonDump << "], status) = " << this << ".CreateMeshesFromMED('" << theFileName << "')";
+ }
+ // Dump creation of groups
+ for ( int i = 0; i < aResult->length(); ++i )
+ aResult[ i ]->GetGroups();
return aResult._retn();
}
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromSTL" );
SMESH::SMESH_Mesh_var aMesh = createMesh();
- string aFileName; // = boost::filesystem::path(theFileName).leaf();
+ string aFileName;
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
if ( myImpl ) {
string hypname = string( myHyp->GetName() );
- string libname = string( myHyp->GetLibName() );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ string libname = string( myHyp->GetLibName() );
+// BUG SWP13062
+// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
+// WNT and ".so" for X-system) must be deleted
+ int libname_len = libname.length();
+#ifdef WNT
+ if( libname_len > 4 )
+ libname.resize( libname_len - 4 );
+#else
+ if( libname_len > 3 )
+ libname.resize( libname_len - 3 );
+#endif
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
string hypdata = string( myImpl->SaveTo() );
// for each hypothesis create HDF group basing on its id
if ( myImpl ) {
string hypname = string( myHyp->GetName() );
string libname = string( myHyp->GetLibName() );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+// BUG SWP13062
+// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
+// WNT and ".so" for X-system) must be deleted
+ int libname_len = libname.length();
+#ifdef WNT
+ if( libname_len > 4 )
+ libname.resize( libname_len - 4 );
+#else
+ if( libname_len > 3 )
+ libname.resize( libname_len - 3 );
+#endif
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
string hypdata = string( myImpl->SaveTo() );
// for each algorithm create HDF group basing on its id
if ( !myMesh->_is_nil() ) {
SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myMesh ).in() );
if ( myImpl ) {
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
::SMESH_Mesh& myLocMesh = myImpl->GetImpl();
SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
//string myRefOnObject = myRefOnHyp->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1;
char hypName[ 30 ], hypId[ 30 ];
//string myRefOnObject = myRefOnAlgo->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1;
char algoName[ 30 ], algoId[ 30 ];
if ( !CORBA::is_nil( anSubObject ))
{
SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow( anSubObject ) ;
- int subid = myStudyContext->findId( string( GetORB()->object_to_string( anSubObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anSubObject );
+ int subid = myStudyContext->findId( string( objStr.in() ) );
// for each mesh open the HDF group basing on its id
char submeshGrpName[ 30 ];
if ( ok ) {
//string myRefOnObject = myRefOnHyp->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1;
char hypName[ 30 ], hypId[ 30 ];
if ( ok ) {
//string myRefOnObject = myRefOnAlgo->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
- int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( anObject );
+ int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1;
char algoName[ 30 ], algoId[ 30 ];
if ( !myGroupImpl )
continue;
- int anId = myStudyContext->findId( string( GetORB()->object_to_string( aSubObject ) ) );
+ CORBA::String_var objStr = GetORB()->object_to_string( aSubObject );
+ int anId = myStudyContext->findId( string( objStr.in() ) );
// For each group, create a dataset named "Group <group_persistent_id>"
// and store the group's user name into it
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
if ( myImpl ) {
myImpl->LoadFrom( hypdata.c_str() );
- string iorString = GetORB()->object_to_string( myHyp );
- int newId = myStudyContext->findId( iorString );
+ CORBA::String_var iorString = GetORB()->object_to_string( myHyp );
+ int newId = myStudyContext->findId( string( iorString.in() ) );
myStudyContext->mapOldToNew( id, newId );
}
else
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
if ( myImpl ) {
myImpl->LoadFrom( hypdata.c_str() );
- string iorString = GetORB()->object_to_string( myHyp );
- int newId = myStudyContext->findId( iorString );
+ CORBA::String_var iorString = GetORB()->object_to_string( myHyp );
+ int newId = myStudyContext->findId( string( iorString.in() ) );
myStudyContext->mapOldToNew( id, newId );
}
else
SMESH_Mesh_i* myNewMeshImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myNewMesh ).in() );
if ( !myNewMeshImpl )
continue;
- string iorString = GetORB()->object_to_string( myNewMesh );
- int newId = myStudyContext->findId( iorString );
+ CORBA::String_var iorString = GetORB()->object_to_string( myNewMesh );
+ int newId = myStudyContext->findId( string( iorString.in() ) );
myStudyContext->mapOldToNew( id, newId );
::SMESH_Mesh& myLocMesh = myNewMeshImpl->GetImpl();
( myNewMeshImpl->createSubMesh( aSubShapeObject ) );
if ( aSubMesh->_is_nil() )
continue;
- string iorSubString = GetORB()->object_to_string( aSubMesh );
- int newSubId = myStudyContext->findId( iorSubString );
+ CORBA::String_var iorSubString = GetORB()->object_to_string( aSubMesh );
+ int newSubId = myStudyContext->findId( string( iorSubString.in() ) );
myStudyContext->mapOldToNew( subid, newSubId );
}
}
if ( aNewGroup->_is_nil() )
continue;
- string iorSubString = GetORB()->object_to_string( aNewGroup );
- int newSubId = myStudyContext->findId( iorSubString );
+ CORBA::String_var iorSubString = GetORB()->object_to_string( aNewGroup );
+ int newSubId = myStudyContext->findId( string( iorSubString.in() ) );
myStudyContext->mapOldToNew( subid, newSubId );
SMESH_GroupBase_i* aGroupImpl =
{
StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) {
- string iorString = GetORB()->object_to_string( theObject );
- return myStudyContext->addObject( iorString );
+ CORBA::String_var iorString = GetORB()->object_to_string( theObject );
+ return myStudyContext->addObject( string( iorString.in() ) );
}
return 0;
}