- std::string aFullPath(Kernel_Utils::GetTmpFileName());
- aFullPath += ".med";
- StudyContext* myStudyContext = GetCurrentStudyContext();
-
- SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aComponent); // check only published meshes
- int aNumMeshes = 0; // number of meshes in result
- for(; anIter->More(); anIter->Next()) {
- SALOMEDS::SObject_var aSO = anIter->Value();
- CORBA::Object_var anObj = aSO->GetObject();
- if (!CORBA::is_nil(anObj)) {
- SMESH::SMESH_Mesh_var aCORBAMesh = SMESH::SMESH_Mesh::_narrow(anObj);
- if(!aCORBAMesh->_is_nil()) {
- SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>(GetServant(aCORBAMesh).in());
- if (myImpl) {
- myImpl->Load();
- SMESH_Mesh& aMesh = myImpl->GetImpl();
- CORBA::String_var objName = aSO->GetName();
- aMesh.ExportMED(aFullPath.c_str(), objName.in(), false, MED::eV2_2, 0);
- aNumMeshes++;
+ TopoDS_Shape aShape = GeomObjectToShape( theGeom );
+
+ std::vector<long> lst =_GetInside(meshPart, theElemType, aShape, &theTolerance);
+
+ if( lst.size() > 0 ) {
+ aResult->length( lst.size() );
+ for ( size_t i = 0; i < lst.size(); i++ ) {
+ aResult[i] = lst[i];
+ }
+ }
+ return aResult._retn();
+}
+
+
+
+std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
+ SMESH::ElementType theElemType,
+ TopoDS_Shape& aShape,
+ double* theTolerance) {
+
+ std::vector<long> res;
+ SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh();
+
+ if ( mesh->_is_nil() )
+ return res;
+
+ SMESH_Mesh_i* anImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
+ if ( !anImpl )
+ return res;
+
+ const SMDS_Mesh* meshDS = anImpl->GetImpl().GetMeshDS();
+
+ if ( !meshDS )
+ return res;
+
+ SMDSAbs_ElementType aType = SMDSAbs_ElementType(theElemType);
+ SMESH::Controls::ElementsOnShape* anElementsOnShape = new SMESH::Controls::ElementsOnShape();
+ anElementsOnShape->SetAllNodes( true );
+ anElementsOnShape->SetMesh( meshDS );
+ anElementsOnShape->SetShape( aShape, aType );
+
+ if(theTolerance)
+ anElementsOnShape->SetTolerance(*theTolerance);
+
+ SMESH::SMESH_Mesh_var msource = SMESH::SMESH_Mesh::_narrow(meshPart);
+ if ( !msource->_is_nil() ) { // Mesh case
+ SMDS_ElemIteratorPtr elemIt = meshDS->elementsIterator( aType );
+ if ( elemIt ) {
+ while ( elemIt->more() ) {
+ const SMDS_MeshElement* anElem = elemIt->next();
+ long anId = anElem->GetID();
+ if ( anElementsOnShape->IsSatisfy( anId ) )
+ res.push_back( anId );
+ }
+ }
+ }
+ SMESH::SMESH_Group_var gsource = SMESH::SMESH_Group::_narrow(meshPart);
+ if ( !gsource->_is_nil() ) {
+ if(theElemType == SMESH::NODE) {
+ SMESH::long_array_var nodes = gsource->GetNodeIDs();
+ for ( CORBA::ULong i = 0; i < nodes->length(); ++i ) {
+ if ( const SMDS_MeshNode* node = meshDS->FindNode( nodes[i] )) {
+ long anId = node->GetID();
+ if ( anElementsOnShape->IsSatisfy( anId ) )
+ res.push_back( anId );
+ }
+ }
+ } else if (gsource->GetType() == theElemType || theElemType == SMESH::ALL ) {
+ SMESH::long_array_var elems = gsource->GetListOfID();
+ for ( CORBA::ULong i = 0; i < elems->length(); ++i ) {
+ if ( const SMDS_MeshElement* elem = meshDS->FindElement( elems[i] )) {
+ long anId = elem->GetID();
+ if ( anElementsOnShape->IsSatisfy( anId ) )
+ res.push_back( anId );