X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i.cxx;h=63f4fe46dab4b70e7f879284153fc8543ed6f572;hb=1949fa0f3ec6dac7a1af935b60527903f314f2b7;hp=a387b1c65ef83239583f48af56125bff0db1d1c3;hpb=06221800dab96ac364d3c834548f185a2e449416;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index a387b1c65..63f4fe46d 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -126,7 +126,7 @@ static int MYDEBUG = 0; #endif // Static variables definition -GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen=GEOM::GEOM_Gen::_nil(); +GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen = GEOM::GEOM_Gen::_nil(); CORBA::ORB_var SMESH_Gen_i::myOrb; PortableServer::POA_var SMESH_Gen_i::myPoa; SALOME_NamingService* SMESH_Gen_i::myNS = NULL; @@ -223,12 +223,14 @@ SALOME_LifeCycleCORBA* SMESH_Gen_i::GetLCC() { * Get GEOM::GEOM_Gen reference */ //============================================================================= -GEOM::GEOM_Gen_ptr SMESH_Gen_i::GetGeomEngine() -{ - if (CORBA::is_nil(myGeomGen)) +GEOM::GEOM_Gen_ptr SMESH_Gen_i::GetGeomEngine() { + //CCRT GEOM::GEOM_Gen_var aGeomEngine = + //CCRT GEOM::GEOM_Gen::_narrow( GetLCC()->FindOrLoad_Component("FactoryServer","GEOM") ); + //CCRT return aGeomEngine._retn(); + if(CORBA::is_nil(myGeomGen)) { Engines::Component_ptr temp=GetLCC()->FindOrLoad_Component("FactoryServer","GEOM"); - myGeomGen = GEOM::GEOM_Gen::_narrow(temp); + myGeomGen=GEOM::GEOM_Gen::_narrow(temp); } return myGeomGen; } @@ -1028,7 +1030,7 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetComputeErrors()" ); - if ( CORBA::is_nil( theSubObject ) ) + if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -1038,7 +1040,12 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr try { if ( SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh )) { - TopoDS_Shape shape = GeomObjectToShape( theSubObject ); + TopoDS_Shape shape; + if(theMesh->HasShapeToMesh()) + shape = GeomObjectToShape( theSubObject ); + else + shape = SMESH_Mesh::PseudoShape(); + ::SMESH_Mesh& mesh = meshServant->GetImpl(); error_array->length( mesh.GetMeshDS()->MaxShapeIndex() ); @@ -1093,7 +1100,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetAlgoState()" ); - if ( CORBA::is_nil( theSubObject ) ) + if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -1104,7 +1111,12 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh ); ASSERT( meshServant ); if ( meshServant ) { - TopoDS_Shape myLocShape = GeomObjectToShape( theSubObject ); + TopoDS_Shape myLocShape; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theSubObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); + ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); list< ::SMESH_Gen::TAlgoStateError > error_list; list< ::SMESH_Gen::TAlgoStateError >::iterator error; @@ -1222,7 +1234,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" ); - if ( CORBA::is_nil( theShapeObject ) ) + if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); @@ -1233,23 +1245,27 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, // Update Python script TPythonDump() << "isDone = " << this << ".Compute( " << theMesh << ", " << theShapeObject << ")"; - TPythonDump() << "if not isDone: print 'Mesh', " << theMesh << ", ': computation failed'"; try { // get mesh servant SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( theMesh ).in() ); ASSERT( meshServant ); if ( meshServant ) { + // NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation" + meshServant->CheckGeomGroupModif(); // get local TopoDS_Shape - TopoDS_Shape myLocShape = GeomObjectToShape( theShapeObject ); + TopoDS_Shape myLocShape; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theShapeObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); // call implementation compute ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); return myGen.Compute( myLocMesh, myLocShape); } } - catch ( std::bad_alloc& exc ) { - THROW_SALOME_CORBA_EXCEPTION( "Memory allocation problem", - SALOME::INTERNAL_ERROR ); + catch ( std::bad_alloc ) { + INFOS( "Compute(): lack of memory" ); } catch ( SALOME_Exception& S_ex ) { INFOS( "Compute(): catch exception "<< S_ex.what() ); @@ -1783,6 +1799,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, int id = myStudyContext->findId( string( objStr.in() ) ); ::SMESH_Mesh& myLocMesh = myImpl->GetImpl(); SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS(); + bool hasShape = myLocMesh.HasShapeToMesh(); // for each mesh open the HDF group basing on its id char meshGrpName[ 30 ]; @@ -1805,6 +1822,18 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, aDataset->WriteOnDisk( ( char* )( strHasData.c_str() ) ); aDataset->CloseOnDisk(); + // ouv : NPAL12872 + // for each mesh open the HDF group basing on its auto color parameter + char meshAutoColorName[ 30 ]; + sprintf( meshAutoColorName, "AutoColorMesh %d", id ); + int anAutoColor[1]; + anAutoColor[0] = myImpl->GetAutoColor(); + aSize[ 0 ] = 1; + aDataset = new HDFdataset( meshAutoColorName, aTopGroup, HDF_INT32, aSize, 1 ); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( anAutoColor ); + aDataset->CloseOnDisk(); + // write reference on a shape if exists SALOMEDS::SObject_var myRef; bool shapeRefFound = false; @@ -1828,10 +1857,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write applied hypotheses if exist SALOMEDS::SObject_var myHypBranch; found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch ); - if ( found && !shapeRefFound ) { // remove applied hyps + if ( found && !shapeRefFound && hasShape) { // remove applied hyps myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch ); } - if ( found && shapeRefFound ) { + if ( found && (shapeRefFound || !hasShape) ) { aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup ); aGroup->CreateOnDisk(); @@ -1871,10 +1900,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write applied algorithms if exist SALOMEDS::SObject_var myAlgoBranch; found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch ); - if ( found && !shapeRefFound ) { // remove applied algos + if ( found && !shapeRefFound && hasShape) { // remove applied algos myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch ); } - if ( found && shapeRefFound ) { + if ( found && (shapeRefFound || !hasShape)) { aGroup = new HDFgroup( "Applied Algorithms", aTopGroup ); aGroup->CreateOnDisk(); @@ -2130,6 +2159,22 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, aDataset->WriteOnDisk( aUserName ); aDataset->CloseOnDisk(); + // ouv : NPAL12872 + // For each group, create a dataset named "Group Color" + // and store the group's color into it + char grpColorName[ 30 ]; + sprintf( grpColorName, "ColorGroup %d", anId ); + SALOMEDS::Color aColor = myGroupImpl->GetColor(); + double anRGB[3]; + anRGB[ 0 ] = aColor.R; + anRGB[ 1 ] = aColor.G; + anRGB[ 2 ] = aColor.B; + aSize[ 0 ] = 3; + aDataset = new HDFdataset( grpColorName, aGroup, HDF_FLOAT64, aSize, 1 ); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( anRGB ); + aDataset->CloseOnDisk(); + // Store the group contents into MED file if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) { @@ -2183,7 +2228,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, myWriter.Perform(); // maybe a shape was deleted in the study - if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) { + if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() && hasShape) { TopoDS_Shape nullShape; myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data } @@ -2670,6 +2715,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } // close hypotheses root HDF group aTopGroup->CloseOnDisk(); + aTopGroup = 0; } // --> then we should read&create algorithms @@ -2769,6 +2815,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } // close algorithms root HDF group aTopGroup->CloseOnDisk(); + aTopGroup = 0; } // --> the rest groups should be meshes @@ -2802,6 +2849,21 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, int newId = myStudyContext->findId( iorString ); myStudyContext->mapOldToNew( id, newId ); + // ouv : NPAL12872 + // try to read and set auto color flag + char aMeshAutoColorName[ 30 ]; + sprintf( aMeshAutoColorName, "AutoColorMesh %d", id); + if( aTopGroup->ExistInternalObject( aMeshAutoColorName ) ) + { + aDataset = new HDFdataset( aMeshAutoColorName, aTopGroup ); + aDataset->OpenOnDisk(); + size = aDataset->GetSize(); + int* anAutoColor = new int[ size ]; + aDataset->ReadFromDisk( anAutoColor ); + aDataset->CloseOnDisk(); + myNewMeshImpl->SetAutoColor( (bool)anAutoColor[0] ); + } + // try to read and set reference to shape GEOM::GEOM_Object_var aShapeObject; if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) { @@ -2907,7 +2969,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil() + || !myNewMeshImpl->HasShapeToMesh()) ) myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } @@ -2944,7 +3007,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil() + || !myNewMeshImpl->HasShapeToMesh()) ) myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } @@ -3310,9 +3374,14 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } // if ( hasData ) // Recompute State (as computed sub-meshes are restored from MED) - if ( !aShapeObject->_is_nil() ) { + if ( !aShapeObject->_is_nil() || !myNewMeshImpl->HasShapeToMesh()) { MESSAGE("Compute State Engine ..."); - TopoDS_Shape myLocShape = GeomObjectToShape( aShapeObject ); + TopoDS_Shape myLocShape; + if(myNewMeshImpl->HasShapeToMesh()) + myLocShape = GeomObjectToShape( aShapeObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); + myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine (SMESH_subMesh::SUBMESH_RESTORED); MESSAGE("Compute State Engine finished"); @@ -3399,6 +3468,25 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, SMESHDS_GroupBase* aGroupBaseDS = aLocalGroup->GetGroupDS(); aGroupBaseDS->SetStoreName( name_dataset ); + // ouv : NPAL12872 + // Read color of the group + char aGroupColorName[ 30 ]; + sprintf( aGroupColorName, "ColorGroup %d", subid); + if ( aGroup->ExistInternalObject( aGroupColorName ) ) + { + aDataset = new HDFdataset( aGroupColorName, aGroup ); + aDataset->OpenOnDisk(); + size = aDataset->GetSize(); + double* anRGB = new double[ size ]; + aDataset->ReadFromDisk( anRGB ); + aDataset->CloseOnDisk(); + SALOMEDS::Color aColor; + aColor.R = anRGB[0]; + aColor.G = anRGB[1]; + aColor.B = anRGB[2]; + aGroupBaseDS->SetColor( aColor ); + } + // Fill group with contents from MED file SMESHDS_Group* aGrp = dynamic_cast( aGroupBaseDS ); if ( aGrp ) @@ -3410,7 +3498,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } } // close mesh group - aTopGroup->CloseOnDisk(); + if(aTopGroup) + aTopGroup->CloseOnDisk(); } // close HDF file aFile->CloseOnDisk();