| 176 | } |
| 177 | |
| 178 | Expected<void> fillContours2D( Mesh& mesh, const std::vector<EdgeId>& holeRepresentativeEdges ) |
| 179 | { |
| 180 | MR_TIMER; |
| 181 | |
| 182 | auto projInput = projectHoles( mesh, holeRepresentativeEdges ); |
| 183 | if ( !projInput.has_value() ) |
| 184 | return unexpected( std::move( projInput.error() ) ); |
| 185 | |
| 186 | auto fillRes = fillProjected( mesh.topology, *projInput ); |
| 187 | if ( !fillRes.has_value() ) |
| 188 | return unexpected( std::move( fillRes.error() ) ); |
| 189 | |
| 190 | // move patch surface border points to original position (according original mesh) |
| 191 | auto& patchMeshPoints = fillRes->mesh.points; |
| 192 | auto& patchMeshTopology = fillRes->mesh.topology; |
| 193 | auto& meshPoints = mesh.points; |
| 194 | auto& meshTopology = mesh.topology; |
| 195 | for ( int i = 0; i < projInput->paths.size(); ++i ) |
| 196 | { |
| 197 | auto& path = projInput->paths[i]; |
| 198 | auto& newPath = fillRes->paths[i]; |
| 199 | for ( int j = 0; j < path.size(); ++j ) |
| 200 | patchMeshPoints[patchMeshTopology.org( newPath[j] )] = meshPoints[meshTopology.org( path[j] )]; |
| 201 | } |
| 202 | |
| 203 | // add patch surface to original mesh |
| 204 | mesh.addMeshPart( fillRes->mesh, false, projInput->paths, fillRes->paths ); |
| 205 | return {}; |
| 206 | } |
| 207 | |
| 208 | Expected<HoleFillPlan> fillContours2DPlan( const Mesh& mesh, EdgeId holeEdgeId ) |
| 209 | { |