Skip to content
ForCADDocumentation
Browse guide contents ↓

Extract a parameter range

Keep the middle half of a rectangular block along U. Use restrict when you want an independent patch with the same rank as the original. The inputs are parameter values. For the 8-unit block in this example, the U interval from 0.25 to 0.75 spans X from 2 to 6.

program extract_a_subpatch
    use forcad, only: rk, nurbs_volume
    implicit none
    type(nurbs_volume) :: stock, slab
    real(rk) :: volume, first(3), last(3)

    call stock%set_hexahedron(L=[8._rk,3._rk,2._rk], nc=[2,2,2])
    if (.not. stock%err%ok) error stop "Could not build the stock"
    slab = stock%restrict(dir=1, a=0.25_rk, b=0.75_rk)
    if (.not. slab%err%ok) error stop "Could not extract the interval"

    first = slab%cmp_Xg([0.25_rk,0._rk,0._rk])
    last = slab%cmp_Xg([0.75_rk,1._rk,1._rk])
    call slab%cmp_volume(volume)
    if (.not. slab%err%ok) error stop "Could not measure the slab"
    print '(3f8.3)', first, last
    print '(f8.3)', volume
end program

The corner coordinates are (2, 0, 0) and (6, 3, 2). The enclosed volume is 24 cubic units. The result retains U bounds 0.25 and 0.75, so use these values to probe its ends. To give the extracted patch a different interval, reparameterize it.

For surfaces and volumes, choose one parameter direction per call. A curve takes just a and b. Both bounds must lie inside the source interval, with a < b. To keep both pieces on either side of one cut, split the patch.

Studio equivalent. Extract a parameter range.