cuts one edge and connects all intersecting contours with pieces
| 794 | |
| 795 | // cuts one edge and connects all intersecting contours with pieces |
| 796 | void cutOneEdge( Mesh& mesh, |
| 797 | const EdgeData& edgeData, const OneMeshContours& contours, |
| 798 | FaceMap* new2OldMap, NewEdgesMap* new2OldEdgeMap ) |
| 799 | { |
| 800 | assert( !edgeData.empty() ); |
| 801 | |
| 802 | const auto& intInfo = std::find_if( edgeData.begin(), edgeData.end(), [] ( const auto& data ) |
| 803 | { |
| 804 | return data.beforeSortIndex == 0; |
| 805 | } )->interOnEdge; |
| 806 | EdgeId baseEdge = std::get<EdgeId>( contours[intInfo.contourId].intersections[intInfo.intersectionId].primitiveId ); |
| 807 | |
| 808 | // will need this to restore lost face on first or last intersection (only for open contours) |
| 809 | FaceId oldLeft = mesh.topology.left( baseEdge ); |
| 810 | FaceId oldRight = mesh.topology.left( baseEdge.sym() ); |
| 811 | |
| 812 | // remove incident faces |
| 813 | mesh.topology.setLeft( baseEdge, FaceId{} ); |
| 814 | mesh.topology.setLeft( baseEdge.sym(), FaceId{} ); |
| 815 | |
| 816 | EdgeId e = baseEdge; |
| 817 | // disconnect edge e from its origin |
| 818 | EdgeId e0; |
| 819 | { |
| 820 | EdgeId ePrev = mesh.topology.prev( e ); |
| 821 | if ( ePrev != e ) |
| 822 | mesh.topology.splice( ePrev, e ); |
| 823 | // e now becomes the second part of split edge, add first part to it |
| 824 | e0 = mesh.topology.makeEdge(); |
| 825 | if ( new2OldEdgeMap ) |
| 826 | { |
| 827 | new2OldEdgeMap->splitEdges.autoResizeSet( e0.undirected() ); |
| 828 | new2OldEdgeMap->map[e0.undirected()] = baseEdge; |
| 829 | } |
| 830 | if ( ePrev != e ) |
| 831 | mesh.topology.splice( ePrev, e0 ); |
| 832 | } |
| 833 | |
| 834 | bool isAllLeftOnly = true; |
| 835 | bool isAllRightOnly = true; |
| 836 | for ( int i = 0; i < edgeData.size(); ++i ) |
| 837 | { |
| 838 | const auto& vertEdge = edgeData[i].orgEdgeInLeftTri; |
| 839 | const auto& interIndex = edgeData[i].interOnEdge; |
| 840 | const auto& inter = contours[interIndex.contourId].intersections[interIndex.intersectionId]; |
| 841 | |
| 842 | bool isBaseSym = std::get<EdgeId>( inter.primitiveId ).sym() == baseEdge; |
| 843 | |
| 844 | EdgeId leftEdge, rightEdge; |
| 845 | EdgeId& baseleft = isBaseSym ? rightEdge : leftEdge; |
| 846 | EdgeId& baserigth = isBaseSym ? leftEdge : rightEdge; |
| 847 | |
| 848 | baseleft = vertEdge; |
| 849 | baserigth = baseleft.valid() ? mesh.topology.next( baseleft ) : mesh.topology.edgePerVertex()[edgeData[i].newVert]; |
| 850 | if ( baseleft == baserigth ) |
| 851 | baserigth = EdgeId{}; |
| 852 | |
| 853 | EdgeId lastEdge = e; |
no test coverage detected