From: gdd Date: Sun, 6 Mar 2011 23:23:08 +0000 (+0000) Subject: - Separate SetEnforcedMesh and SetEnforcedElements X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6f82a35809f9c7dd1187c8e1e3312bcdb8c27677;p=plugins%2Fghs3dplugin.git - Separate SetEnforcedMesh and SetEnforcedElements - Quad face as input are transformed into pyramids (some bugs remain) --- diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index eec5841..2b222ac 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -24,6 +24,8 @@ //============================================================================= // #include "GHS3DPlugin_Hypothesis.hxx" +#include +#include #include @@ -337,6 +339,49 @@ void GHS3DPlugin_Hypothesis::SetEnforcedVertex(double x, double y, double z, dou NotifySubMeshesHypothesisModification(); } + +//======================================================================= +//function : SetEnforcedMesh +//======================================================================= +void GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size) +{ + TIDSortedElemSet theElemSet; + SMDS_ElemIteratorPtr eIt; + + if ((elementType == SMESH::FACE) && (theMesh.NbQuadrangles() > 0)) { + SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh )); + + StdMeshers_QuadToTriaAdaptor* aQuad2Trias = new StdMeshers_QuadToTriaAdaptor; + aQuad2Trias->Compute( theMesh ); + proxyMesh.reset(aQuad2Trias ); + +// std::cout << "proxyMesh->NbFaces(): " << proxyMesh->NbFaces() << std::endl; +// eIt = proxyMesh->GetFaces(); +// if (eIt) +// while ( eIt->more() ) +// theElemSet.insert( eIt->next() ); +// else { +// std::cout << "********************** eIt == 0 *****************" << std::endl; + eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType)); + while ( eIt->more() ) { + const SMDS_MeshElement* elem = eIt->next(); + theElemSet.insert( elem ); + } + } + + else + { + eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType)); + while ( eIt->more() ) + theElemSet.insert( eIt->next() ); + } + + MESSAGE("Add "< #include "Utils_CorbaException.hxx" #include "utilities.h" @@ -566,15 +569,31 @@ void GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSou if (theMesh_i) { - SMESH::long_array_var anIDs = theMesh_i->GetElementsByType(theType); - if ( anIDs->length() == 0 ){MESSAGE("The source mesh is empty");} - for (int i=0; ilength(); i++) { - CORBA::Long ind = anIDs[i]; - const SMDS_MeshElement * elem = theMeshDS->FindElement(ind); - if (elem) - theElemSet.insert( elem ); + try { + this->GetImpl()->SetEnforcedMesh(anImplPtr->GetImpl(), theType, theSize); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize)"; + ExDescription.lineNumber = 502; + throw SALOME::SALOME_Exception(ExDescription); } - MESSAGE("Add "<GetElementsByType(theType); +// if ( anIDs->length() == 0 ){MESSAGE("The source mesh is empty");} +// for (int i=0; ilength(); i++) { +// CORBA::Long ind = anIDs[i]; +// const SMDS_MeshElement * elem = theMeshDS->FindElement(ind); +// if (elem) +// theElemSet.insert( elem ); +// } +//// } +// MESSAGE("Add "<length() == 1 && types[0] == theType) { @@ -596,21 +615,21 @@ void GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSou } } MESSAGE("Add "<GetName()); - } - - try { - this->GetImpl()->SetEnforcedElements(theElemSet, theType, theSize); - } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize)"; - ExDescription.lineNumber = 502; - throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + + try { + this->GetImpl()->SetEnforcedElements(theElemSet, theType, theSize); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize)"; + ExDescription.lineNumber = 502; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } } } //=============================================================================