\ref MEDCoupling::MEDCouplingUMesh::orientCorrectly2DCells "orientCorrectly2DCells()" and
re-check the orientation of cells.
\snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2
-
+Alternatively you can orient all 2D cells equally using the first cell as a reference:
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3
+Also it is possible to orient some selected 2D cells by using another group of cells as the reference:
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4
\subsubsection cpp_mcumesh_renumberNodesInConn Renumbering nodes in the connectivity array
//MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
//MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly);
+MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces = nullptr);
MEDCouplingUMesh::orientCorrectlyPolyhedrons();
//MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
//MEDCouplingUMesh::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
A mesh before applying orientCorrectly2DCells (to the left) and after (to the right)
+Alternatively you can orient all 2D cells equally using the first cell as a reference:
+
+.. literalinclude:: ../../../src/MEDCoupling_Swig/UsersGuideExamplesTest.py
+ :start-after: UG_CommonHandlingMesh_11_1
+ :end-before: UG_CommonHandlingMesh_11_1
+
+Also it is possible to orient some selected 2D cells by using another group of cells as the reference:
+
+.. literalinclude:: ../../../src/MEDCoupling_Swig/UsersGuideExamplesTest.py
+ :start-after: UG_CommonHandlingMesh_11_2
+ :end-before: UG_CommonHandlingMesh_11_2
+
If your mesh includes incorrectly oriented polyhedra, the following method can help to fix your mesh:
.. literalinclude:: ../../../src/MEDCoupling_Swig/UsersGuideExamplesTest.py
* \throw If \a this mesh and \refFaces do not share nodes.
* \throw If \a refFaces are not equally oriented.
* \throw If \a this mesh plus \a refFaces together form a non-manifold mesh.
+ *
+ * \if ENABLE_EXAMPLES
+ * \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
+ * \ref py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
+ * \endif
*/
//================================================================================
mesh[_OBJ]->getReverseNodalConnectivity( revNodal[_OBJ], revNodalIndx[_OBJ] );
mesh[_REF]->getReverseNodalConnectivity( revNodal[_REF], revNodalIndx[_REF] );
- std::vector< mcIdType > faceQueue; // starting faces with IDs counted from 1; negative ID mean a face in ref mesh
- if ( refFaces )
- faceQueue.push_back( MEDCouplingImpl::encodeID( 0, _REF ));
- else
- faceQueue.push_back( MEDCouplingImpl::encodeID( 0, _OBJ ));
-
std::vector< mcIdType > faceNodes(4);
std::vector< mcIdType > facesByEdge(4), equalFaces;
+ std::vector< mcIdType > faceQueue; // starting faces with IDs counted from 1; negative ID mean a face in ref mesh
while ( nbFacesToCheck[_OBJ] + nbFacesToCheck[_REF] > 0 ) // until all faces checked
{
if ( !isFaceQueued[iMesh][f] )
{
faceQueue.push_back( MEDCouplingImpl::encodeID( f, iMesh ));
+ isFaceQueued[ iMesh ][ f ] = true;
iMesh = 0;
break;
}
mesh->are2DCellsNotCorrectlyOriented( vec, false, badCellIds );
CPPUNIT_ASSERT( badCellIds.size() == 0 ); // the orientation is OK
//! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2]
+ //! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+ mesh->orientCorrectly2DCells();
+ //! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+ //! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
+ const mcIdType refCells[] = { 0,2 };
+ const mcIdType objCells[] = { 1,3 };
+ MCAuto<MEDCouplingUMesh> refGroup = mesh->buildPartOfMySelf( refCells, refCells + 2 );
+ MCAuto<MEDCouplingUMesh> objGroup = mesh->buildPartOfMySelf( objCells, objCells + 2 );
+ objGroup->orientCorrectly2DCells( refGroup );
+ mesh->setPartOfMySelf( objCells, objCells + 2, *objGroup );
+ //! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
}
void CppExample_MEDCouplingUMesh_getCellsContainingPoints()
badCellIds=mesh.are2DCellsNotCorrectlyOriented( vec, False )
assert len( badCellIds ) == 0 # the orientation is OK
#! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2]
+ #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+ mesh.orientCorrectly2DCells( None )
+ #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+ #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
+ refCells = [ 0,2 ]
+ objCells = [ 1,3 ]
+ refGroup = mesh.buildPartOfMySelf( refCells )
+ objGroup = mesh.buildPartOfMySelf( objCells )
+ objGroup.orientCorrectly2DCells( refGroup )
+ mesh.setPartOfMySelf( objCells, objGroup )
+ #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
return
def testExample_MEDCouplingUMesh_getCellsContainingPoints(self):
skin.orientCorrectly2DCells(vec,False)
#! [UG_CommonHandlingMesh_11]
+#! [UG_CommonHandlingMesh_11_1]
+skin.orientCorrectly2DCells( None )
+#! [UG_CommonHandlingMesh_11_1]
+
+#! [UG_CommonHandlingMesh_11_2]
+refCells = [ 0,2,4 ]
+objCells = [ 1,3,5,6,7,8, 20 ]
+refGroup = skin.buildPartOfMySelf( refCells )
+objGroup = skin.buildPartOfMySelf( objCells )
+objGroup.orientCorrectly2DCells( refGroup )
+skin.setPartOfMySelf( objCells, objGroup )
+#! [UG_CommonHandlingMesh_11_2]
+
#! [UG_CommonHandlingMesh_12]
m3.orientCorrectlyPolyhedrons()
#! [UG_CommonHandlingMesh_12]