]> SALOME platform Git repositories - plugins/ghs3dplugin.git/commitdiff
Salome HOME
- Separate SetEnforcedMesh and SetEnforcedElements
authorgdd <gdd>
Sun, 6 Mar 2011 23:23:08 +0000 (23:23 +0000)
committergdd <gdd>
Sun, 6 Mar 2011 23:23:08 +0000 (23:23 +0000)
- Quad face as input are transformed into pyramids (some bugs remain)

src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx

index eec584152fa3f2a381c7ab6a21989f5aedd36808..2b222ac95199e6b0c54f74cabdbba7b76f68034b 100644 (file)
@@ -24,6 +24,8 @@
 //=============================================================================
 //
 #include "GHS3DPlugin_Hypothesis.hxx"
+#include <SMESH_ProxyMesh.hxx>
+#include <StdMeshers_QuadToTriaAdaptor.hxx>
 
 #include <TCollection_AsciiString.hxx>
 
@@ -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 "<<theElemSet.size()<<" types["<<elementType<<"] from source mesh");
+
+  SetEnforcedElements( theElemSet, elementType, size);
+
+}
+
 //=======================================================================
 //function : SetEnforcedElements
 //=======================================================================
index fd51c7d1a3be467bd03f97cfa752f70df90270e5..ac546762dc406d49a560e7553529d7eee41ed733 100644 (file)
@@ -163,6 +163,7 @@ public:
   /*!
    * To set enforced elements
    */
+  void SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size);
   void SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size);
   void ClearEnforcedMeshes();
   const TIDSortedNodeSet _GetEnforcedNodes() const { return _enfNodes; }
index 1ccb8e90457a0413de6ad93db2e1269b989d1e56..3df541434c42ecba7101c4475827f65a112cbf37 100644 (file)
@@ -25,6 +25,9 @@
 
 #include "SMESH_Gen.hxx"
 #include "SMESH_PythonDump.hxx"
+//#include "SMESH_Mesh.hxx"
+//#include "SMESH_ProxyMesh.hxx"
+//#include <StdMeshers_QuadToTriaAdaptor.hxx>
 
 #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; i<anIDs->length(); 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 "<<theElemSet.size()<<" types["<<theType<<"] from source mesh");
+    catch (SALOME_Exception& ex) {
+      THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+    }
+//
+//      SMESH::long_array_var anIDs = theMesh_i->GetElementsByType(theType);
+//      if ( anIDs->length() == 0 ){MESSAGE("The source mesh is empty");}
+//      for (int i=0; i<anIDs->length(); i++) {
+//        CORBA::Long ind = anIDs[i];
+//        const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
+//        if (elem)
+//          theElemSet.insert( elem );
+//      }
+////    }
+//    MESSAGE("Add "<<theElemSet.size()<<" types["<<theType<<"] from source mesh");
   }
   else if (theGroup_i && types->length() == 1 && types[0] == theType)
   {
@@ -596,21 +615,21 @@ void GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSou
       }
     }
     MESSAGE("Add "<<theElemSet.size()<<" types["<<theType<<"] from source group "<< theGroup_i->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 );
+    }
   }
 }
 //=============================================================================