Salome HOME
0022106: EDF 2464 SMESH : Split quadrangles in 4 triangles
authoreap <eap@opencascade.com>
Wed, 22 May 2013 15:33:27 +0000 (15:33 +0000)
committereap <eap@opencascade.com>
Wed, 22 May 2013 15:33:27 +0000 (15:33 +0000)
+  void           QuadTo4Tri      (SMESH::SMESH_IDSource_ptr   theObject)

src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx

index 4249f47433ad98591006097aad1478ea81a3e05e..6cb26a80ab6931f5803e96d2c9491228f2dfc9a2 100644 (file)
@@ -571,10 +571,9 @@ SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
 
     while ( itMeshElems->more() ) {
       const SMDS_MeshElement* aMeshElem = itMeshElems->next();
 
     while ( itMeshElems->more() ) {
       const SMDS_MeshElement* aMeshElem = itMeshElems->next();
-      SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
+      SMDS_NodeIteratorPtr itElemNodes = aMeshElem->nodeIterator();
       while ( itElemNodes->more() ) {
       while ( itElemNodes->more() ) {
-        const SMDS_MeshNode* aMeshNode =
-          static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
+        const SMDS_MeshNode* aMeshNode = itElemNodes->next();
         int aNodeID = aMeshNode->GetID();
         TNodesMap::iterator anIter = nodesMap.find(aNodeID);
         if ( anIter == nodesMap.end() ) {
         int aNodeID = aMeshNode->GetID();
         TNodesMap::iterator anIter = nodesMap.find(aNodeID);
         if ( anIter == nodesMap.end() ) {
@@ -591,12 +590,10 @@ SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
       // filling the elements types
       SMDSAbs_ElementType aType = aMeshElem->GetType();
       bool               isPoly = aMeshElem->IsPoly();
       // filling the elements types
       SMDSAbs_ElementType aType = aMeshElem->GetType();
       bool               isPoly = aMeshElem->IsPoly();
-
       myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
       myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
-      myPreviewData->elementTypes[i].isPoly = isPoly;
+      myPreviewData->elementTypes[i].isPoly           = isPoly;
       myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
       i++;
       myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
       i++;
-
     }
     myPreviewData->nodesXYZ.length( j );
 
     }
     myPreviewData->nodesXYZ.length( j );
 
@@ -606,8 +603,8 @@ SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
     for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
       myPreviewData->elementConnectivities[i] = *aConnIter;
   }
     for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
       myPreviewData->elementConnectivities[i] = *aConnIter;
   }
-
   return myPreviewData._retn();
   return myPreviewData._retn();
+
   SMESH_CATCH( SMESH::throwCorbaException );
   return 0;
 }
   SMESH_CATCH( SMESH::throwCorbaException );
   return 0;
 }
@@ -673,6 +670,7 @@ void SMESH_MeshEditor_i::ClearLastCreated() throw (SALOME::SALOME_Exception)
 //=======================================================================
 /*
  * Returns description of an error/warning occured during the last operation
 //=======================================================================
 /*
  * Returns description of an error/warning occured during the last operation
+ * WARNING: ComputeError.code >= 100 and no corresponding enum in IDL API
  */
 //=======================================================================
 
  */
 //=======================================================================
 
@@ -1663,7 +1661,7 @@ CORBA::Long SMESH_MeshEditor_i::Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup,
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *
+ * \brief Fuse neighbour triangles into quadrangles.
  */
 //=============================================================================
 
  */
 //=============================================================================
 
@@ -1703,7 +1701,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfE
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *
+ * \brief Fuse neighbour triangles into quadrangles.
  */
 //=============================================================================
 
  */
 //=============================================================================
 
@@ -1734,7 +1732,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *
+ * \brief Split quadrangles into triangles.
  */
 //=============================================================================
 
  */
 //=============================================================================
 
@@ -1770,12 +1768,12 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array &   IDsOfE
   return 0;
 }
 
   return 0;
 }
 
-
 //=============================================================================
 /*!
 //=============================================================================
 /*!
- *
+ * \brief Split quadrangles into triangles.
  */
 //=============================================================================
  */
 //=============================================================================
+
 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
                                                     SMESH::NumericalFunctor_ptr Criterion)
   throw (SALOME::SALOME_Exception)
 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
                                                     SMESH::NumericalFunctor_ptr Criterion)
   throw (SALOME::SALOME_Exception)
@@ -1801,12 +1799,36 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr
   return 0;
 }
 
   return 0;
 }
 
+//================================================================================
+/*!
+ * \brief Split each of quadrangles into 4 triangles.
+ *  \param [in] theObject - theQuads Container of quadrangles to split.
+ */
+//================================================================================
+
+void SMESH_MeshEditor_i::QuadTo4Tri (SMESH::SMESH_IDSource_ptr theObject)
+  throw (SALOME::SALOME_Exception)
+{
+  SMESH_TRY;
+  initData();
+
+  TIDSortedElemSet faces;
+  if ( !idSourceToSet( theObject, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/true ) &&
+       faces.empty() )
+    THROW_SALOME_CORBA_EXCEPTION("No faces given", SALOME::BAD_PARAM);
+
+  getEditor().QuadTo4Tri( faces );
+  TPythonDump() << this << ".QuadTo4Tri( " << theObject << " )";
+
+  SMESH_CATCH( SMESH::throwCorbaException );
+}
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *
+ * \brief Split quadrangles into triangles.
  */
 //=============================================================================
  */
 //=============================================================================
+
 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
                                               CORBA::Boolean            Diag13)
   throw (SALOME::SALOME_Exception)
 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
                                               CORBA::Boolean            Diag13)
   throw (SALOME::SALOME_Exception)
@@ -1831,12 +1853,12 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle
   return 0;
 }
 
   return 0;
 }
 
-
 //=============================================================================
 /*!
 //=============================================================================
 /*!
- *
+ * \brief Split quadrangles into triangles.
  */
 //=============================================================================
  */
 //=============================================================================
+
 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
                                                     CORBA::Boolean            Diag13)
   throw (SALOME::SALOME_Exception)
 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
                                                     CORBA::Boolean            Diag13)
   throw (SALOME::SALOME_Exception)
@@ -1863,7 +1885,11 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr th
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- *  BestSplit
+ * Find better splitting of the given quadrangle.
+ *  \param IDOfQuad  ID of the quadrangle to be splitted.
+ *  \param Criterion A criterion to choose a diagonal for splitting.
+ *  \return 1 if 1-3 diagonal is better, 2 if 2-4
+ *          diagonal is better, 0 if error occurs.
  */
 //=============================================================================
 
  */
 //=============================================================================
 
@@ -2045,7 +2071,6 @@ SMESH_MeshEditor_i::smooth(const SMESH::long_array &              IDsOfElements,
   return 0;
 }
 
   return 0;
 }
 
-
 //=============================================================================
 /*!
  *
 //=============================================================================
 /*!
  *
@@ -2085,7 +2110,6 @@ SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr              theObjec
   return 0;
 }
 
   return 0;
 }
 
-
 //=============================================================================
 /*!
  *
 //=============================================================================
 /*!
  *
index 399fe708eb831e238cbaf0d4c8ebead58063d4c8..07435e3a6fec2bd9f4243f68e7ea2455f72c92d0 100644 (file)
@@ -218,6 +218,8 @@ public:
   CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
                                   SMESH::NumericalFunctor_ptr Criterion)
     throw (SALOME::SALOME_Exception);
   CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
                                   SMESH::NumericalFunctor_ptr Criterion)
     throw (SALOME::SALOME_Exception);
+  void           QuadTo4Tri      (SMESH::SMESH_IDSource_ptr   theObject)
+    throw (SALOME::SALOME_Exception);
   CORBA::Boolean SplitQuad       (const SMESH::long_array &   IDsOfElements,
                                   CORBA::Boolean              Diag13)
     throw (SALOME::SALOME_Exception);
   CORBA::Boolean SplitQuad       (const SMESH::long_array &   IDsOfElements,
                                   CORBA::Boolean              Diag13)
     throw (SALOME::SALOME_Exception);