X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i.cxx;h=e12ba1e52447c854422b6d57e14c08271bdbb517;hb=90c6367e0c7e55174459bc49cf9c5e82c8b29735;hp=e90e690f759e238dc86f9f8847267c5f93d74fbe;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index e90e690f7..e12ba1e52 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -559,12 +559,10 @@ CORBA::Boolean SMESH_Gen_i::IsEmbeddedMode() void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) { - //if(MYDEBUG) - //MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); + int curStudyId = GetCurrentStudyID(); myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy ); // create study context, if it doesn't exist and set current study int studyId = GetCurrentStudyID(); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SetCurrentStudy: study Id = " << studyId ); if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() ) { myStudyContextMap[ studyId ] = new StudyContext; } @@ -575,9 +573,23 @@ void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) 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() ); + // NPAL16168, issue 0020210 + // Let meshes update their data depending on GEOM groups that could change + if ( curStudyId != studyId ) + { + //SALOMEDS::SComponent_var me = PublishComponent( myCurrentStudy ); + SALOMEDS::SComponent_var me = SALOMEDS::SComponent::_narrow + ( myCurrentStudy->FindComponent( ComponentDataType() ) ); + if ( !me->_is_nil() ) { + SALOMEDS::ChildIterator_var anIter = myCurrentStudy->NewChildIterator( me ); + for ( ; anIter->More(); anIter->Next() ) { + SALOMEDS::SObject_var so = anIter->Value(); + CORBA::Object_var ior = SObjectToObject( so ); + if ( SMESH_Mesh_i* mesh = SMESH::DownCast( ior )) + mesh->CheckGeomGroupModif(); + } + } + } } } @@ -1498,10 +1510,10 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh if ( aNbNode > 4 ) aNbNode /= 2; // do not take into account additional middle nodes - SMDS_MeshNode* node1 = (SMDS_MeshNode*)face->GetNode( 1 ); - for ( int nIndx = 1; nIndx <= aNbNode; nIndx++ ) + SMDS_MeshNode* node1 = (SMDS_MeshNode*)face->GetNode( 0 ); + for ( int nIndx = 0; nIndx < aNbNode; nIndx++ ) { - SMDS_MeshNode* node2 = (SMDS_MeshNode*)face->GetNode( nIndx < aNbNode ? nIndx+1 : 1 ); + SMDS_MeshNode* node2 = (SMDS_MeshNode*)face->GetNode( nIndx+1 < aNbNode ? nIndx+1 : 0 ); if ( setOfEdge.insert( SMESH_TLink ( node1, node2 ) ).second ) { listOfElemType.push_back( SMDSAbs_Edge ); @@ -1595,6 +1607,93 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh return result._retn(); } + +//============================================================================= +/*! + * SMESH_Gen_i::Evaluate + * + * Evaluate mesh on a shape + */ +//============================================================================= + +//CORBA::Boolean +SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject) +// SMESH::long_array& theNbElems) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Evaluate" ); + + if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) + THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", + SALOME::BAD_PARAM ); + + if ( CORBA::is_nil( theMesh ) ) + THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", + SALOME::BAD_PARAM ); + + SMESH::long_array_var nbels = new SMESH::long_array; + + // Update Python script + TPythonDump() << "theNbElems = " << this << ".Evaluate( " + << theMesh << ", " << theShapeObject << ")"; + + 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; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theShapeObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); + // call implementation compute + ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); + MapShapeNbElems aResMap; + CORBA::Boolean ret = myGen.Evaluate( myLocMesh, myLocShape, aResMap); + MapShapeNbElemsItr anIt = aResMap.begin(); + vector aResVec(17); + int i = 0; + for(; i<17; i++) aResVec[i] = 0; + for(; anIt!=aResMap.end(); anIt++) { + // 0 - node, 1 - edge lin, 2 - edge quad, + // 3 - triangle lin, 4 - triangle quad + // 5 - quadrangle lin, 6 - quadrangle quad + // 7 - polygon, 8 - tetra lin, 9 - tetra quad + // 10 - pyramid lin, 11 - pyramid quad, + // 12 - penta lin, 13 - penta quad, 14 - hexa lin, + // 15 - hexa quad, 16 -polyhedra + vector aVec = (*anIt).second; + for(i=0; i<17; i++) { + aResVec[i] += aVec[i]; + } + } + nbels->length(17); + for(i=0; i<17; i++) { + nbels[i] = aResVec[i]; + } + cout<more() ) elemSet.insert( nIt->next() ); else while ( eIt->more() ) elemSet.insert( eIt->next() ); - ASSERT( elemSet.size() == nbElems ); - + //ASSERT( elemSet.size() == nbElems ); -- issue 20182 + // -- Most probably a bad study was saved when there were + // not fixed bugs in SMDS_MeshInfo + if ( elemSet.size() < nbElems ) { + cout << "SMESH_Gen_i::Load(), warning: Node position data is invalid" << endl; + nbElems = elemSet.size(); + } // add elements to submeshes TIDSortedElemSet::iterator iE = elemSet.begin(); for ( int i = 0; i < nbElems; ++i, ++iE ) { int smID = smIDs[ i ]; if ( smID == 0 ) continue; - ASSERT( smID <= maxID ); const SMDS_MeshElement* elem = *iE; + if( smID > maxID ) { + // corresponding subshape no longer exists: maybe geom group has been edited + if ( myNewMeshImpl->HasShapeToMesh() ) + mySMESHDSMesh->RemoveElement( elem ); + continue; + } // get or create submesh SMESHDS_SubMesh* & sm = subMeshes[ smID ]; if ( ! sm ) { @@ -3841,22 +3950,28 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, for ( int iNode = 0; iNode < nbNodes; iNode++ ) { const SMDS_MeshNode* node = mySMESHDSMesh->FindNode( aNodeIDs[ iNode ]); - ASSERT( node ); + if ( !node ) continue; // maybe removed while Loading() if geometry changed SMDS_PositionPtr aPos = node->GetPosition(); - ASSERT( aPos ) - if ( onFace ) { - ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ); + ASSERT( aPos ); + if ( onFace ) { + // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_FACE );-- issue 20182 + // -- Most probably a bad study was saved when there were + // not fixed bugs in SMDS_MeshInfo + if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) { SMDS_FacePosition* fPos = const_cast ( static_cast( aPos.get() )); fPos->SetUParameter( aUPos[ iNode ]); fPos->SetVParameter( aVPos[ iNode ]); } - else { - ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ); + } + else { + // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182 + if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) { SMDS_EdgePosition* fPos = const_cast ( static_cast( aPos.get() )); fPos->SetUParameter( aUPos[ iNode ]); } + } } } if ( aEids ) delete [] aEids;