| 40 | } |
| 41 | |
| 42 | Expected<Mesh> RegularMapMesher::createMesh() const |
| 43 | { |
| 44 | auto refSize = width_ * height_; |
| 45 | if ( !surfacePC_ ) |
| 46 | return unexpected( "Surface Point Cloud is not loaded" ); |
| 47 | if ( surfacePC_->points.size() != refSize ) |
| 48 | return unexpected( "Surface Point Cloud size is not equal width*height" ); |
| 49 | |
| 50 | if ( !directionsPC_ ) |
| 51 | return unexpected( "Directions Point Cloud is not loaded" ); |
| 52 | if ( directionsPC_->points.size() != width_ ) |
| 53 | return unexpected( "Directions Point Cloud size is not equal width" ); |
| 54 | |
| 55 | if ( distances_.empty() ) |
| 56 | return unexpected( "Distances file is not loaded" ); |
| 57 | if ( distances_.size() != refSize ) |
| 58 | return unexpected( "Distances size is not equal width*height" ); |
| 59 | |
| 60 | auto mesh = makeRegularGridMesh( width_, height_, [&] ( size_t x, size_t y ) |
| 61 | { |
| 62 | return distances_[x + y * width_] != 0.0; |
| 63 | }, |
| 64 | [&] ( size_t x, size_t y ) |
| 65 | { |
| 66 | VertId idx = VertId( x + y * width_ ); |
| 67 | Vector3f org = surfacePC_->points[idx]; |
| 68 | Vector3f dest = directionsPC_->points[VertId( x )]; |
| 69 | return org + ( dest - org ).normalized() * ( 1.0f / distances_[idx] ); |
| 70 | } ); |
| 71 | |
| 72 | if( mesh ) |
| 73 | mesh.value().topology.flipOrientation(); |
| 74 | |
| 75 | return mesh; |
| 76 | } |
| 77 | |
| 78 | } |
nothing calls this directly
no test coverage detected