+//=======================================================================
+//function : Get1DBranches
+//purpose : Partition given 1D elements into groups of contiguous edges.
+// A node where number of meeting edges != 2 is a group end.
+// An optional startNode is used to orient groups it belongs to.
+//return : a list of edge groups and a list of corresponding node groups.
+// If a group is closed, the first and last nodes of the group are same.
+//=======================================================================
+
+SMESH::array_of_long_array*
+SMESH_MeshEditor_i::Get1DBranches( SMESH::SMESH_IDSource_ptr theEdges,
+ CORBA::Long theStartNode,
+ SMESH::array_of_long_array_out theNodeGroups )
+{
+ if ( CORBA::is_nil( theEdges ))
+ THROW_SALOME_CORBA_EXCEPTION("Get1DBranches(): NULL group given", SALOME::BAD_PARAM);
+
+ SMESH::array_of_long_array_var edgeGroupArray = new SMESH::array_of_long_array;
+ theNodeGroups = new SMESH::array_of_long_array;
+
+ SMESH_TRY;
+
+ prepareIdSource( theEdges );
+
+ SMESH_MeshAlgos::TElemGroupVector edgeBranches;
+ SMESH_MeshAlgos::TNodeGroupVector nodeBranches;
+ SMESH_MeshAlgos::Get1DBranches( SMESH_Mesh_i::GetElements( theEdges, SMESH::EDGE ),
+ edgeBranches,
+ nodeBranches,
+ getMeshDS()->FindNode( theStartNode ));
+
+ edgeGroupArray->length( edgeBranches.size() );
+ for ( size_t iG = 0; iG < edgeBranches.size(); ++iG )
+ {
+ edgeGroupArray[ iG ].length( edgeBranches[ iG ].size() );
+ for ( size_t i = 0; i < edgeBranches[ iG ].size(); ++i )
+ edgeGroupArray[ iG ][ i ] = edgeBranches[ iG ][ i ]->GetID();
+ }
+
+ theNodeGroups->length( nodeBranches.size() );
+ for ( size_t iG = 0; iG < nodeBranches.size(); ++iG )
+ {
+ theNodeGroups[ iG ].length( nodeBranches[ iG ].size() );
+ for ( size_t i = 0; i < nodeBranches[ iG ].size(); ++i )
+ theNodeGroups[ iG ][ i ] = nodeBranches[ iG ][ i ]->GetID();
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return edgeGroupArray._retn();
+}
+
+//=======================================================================
+//function : FindSharpEdges
+//purpose : Return sharp edges of faces and non-manifold ones. Optionally add existing edges.
+//=======================================================================
+
+SMESH::ListOfEdges* SMESH_MeshEditor_i::FindSharpEdges(CORBA::Double theAngle,
+ CORBA::Boolean theAddExisting)
+{
+ SMESH::ListOfEdges_var resultEdges = new SMESH::ListOfEdges;
+ SMESH_TRY;
+
+ initData();
+
+ std::vector< SMESH_MeshAlgos::Edge > edges =
+ SMESH_MeshAlgos::FindSharpEdges( getMeshDS(), theAngle, theAddExisting );
+
+ if ( myIsPreviewMode ) // fill a preview mesh with edges
+ {
+ TPreviewMesh* mesh = getPreviewMesh( SMDSAbs_Edge );
+ SMDS_Mesh* meshDS = mesh->GetMeshDS();
+ for ( size_t i = 0; i < edges.size(); ++i )
+ {
+ SMESH_NodeXYZ xyz1( edges[i]._node1), xyz2( edges[i]._node2);
+ SMDS_MeshNode* n1 = meshDS->AddNode( xyz1.X(), xyz1.Y(), xyz1.Z() );
+ SMDS_MeshNode* n2 = meshDS->AddNode( xyz2.X(), xyz2.Y(), xyz2.Z() );
+ if ( edges[i]._medium )
+ {
+ xyz1.Set( edges[i]._medium );
+ SMDS_MeshNode* nm = meshDS->AddNode( xyz1.X(), xyz1.Y(), xyz1.Z() );
+ mesh->GetMeshDS()->AddEdge( n1, n2, nm );
+ }
+ else
+ {
+ mesh->GetMeshDS()->AddEdge( n1, n2 );
+ }
+ }
+ }
+ else
+ {
+ resultEdges->length( edges.size() );
+ for ( size_t i = 0; i < edges.size(); ++i )
+ {
+ resultEdges[ i ].node1 = edges[i]._node1->GetID();
+ resultEdges[ i ].node2 = edges[i]._node2->GetID();
+ resultEdges[ i ].medium = edges[i]._medium ? edges[i]._medium->GetID() : 0;
+ }
+ }
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return resultEdges._retn();
+}
+