Surface Generator¶
CPGen
module allows users to generate control points grids as an input to BSpline.Surface
and
NURBS.Surface
classes. This module is designed to enable more testing cases in a very simple way and
it doesn’t have the capabilities of a fully-featured grid generator, but it should be enough to be used side by side
with BSpline
and NURBS
modules.
CPGen.Grid
class provides an easy way to generate control point grids for use with
BSpline.Surface
class and CPGen.GridWeighted
does the same for NURBS.Surface
class.
Grid¶
-
class
geomdl.CPGen.
Grid
(size_x, size_y, **kwargs)¶ Bases:
object
Simple control points grid generator to use with non-rational surfaces.
This class stores grid points in [x, y, z] format and the grid (control) points can be retrieved from the
grid
attribute. The z-coordinate of the control points can be set via the keyword argumentz_value
while initializing the class.Parameters: - size_x (float) – width of the grid
- size_y (float) – height of the grid
-
bumps
(num_bumps, **kwargs)¶ Generates arbitrary bumps (i.e. hills) on the 2-dimensional grid.
This method generates hills on the grid defined by the num_bumps argument. It is possible to control the z-value using bump_height argument. bump_height can be a positive or negative numeric value or it can be a list of numeric values.
Please note that, not all grids can be modified to have num_bumps number of bumps. Therefore, this function uses a brute-force algorithm to determine whether the bumps can be generated or not. For instance:
test_grid = Grid(5, 10) # generates a 5x10 rectangle test_grid.generate(4, 4) # splits the rectangle into 2x2 pieces test_grid.bumps(100) # impossible, it will return an error message test_grid.bumps(1) # You will get a bump at the center of the generated grid
This method accepts the following keyword arguments:
bump_height
: z-value of the generated bumps on the grid. Default: 5.0base_extent
: extension of the hill base from its center in terms of grid points. Default: 2base_adjust
: padding between the bases of the hills. Default: 0
Parameters: num_bumps (int) – number of bumps (i.e. hills) to be generated on the 2D grid
-
generate
(num_u, num_v)¶ Generates grid using the input division parameters.
Parameters: - num_u (int) – number of divisions in x-direction
- num_v (int) – number of divisions in y-direction
-
grid
¶ Grid points.
Please refer to the wiki for details on using this class member.
Getter: Gets the 2-dimensional list of points in [u][v] format
-
reset
()¶ Resets the grid.
Weighted Grid¶
-
class
geomdl.CPGen.
GridWeighted
(size_x, size_y, **kwargs)¶ Bases:
geomdl.CPGen.Grid
Simple control points grid generator to use with rational surfaces.
This class stores grid points in [x*w, y*w, z*w, w] format and the grid (control) points can be retrieved from the
grid
attribute. The z-coordinate of the control points can be set via the keyword argumentz_value
while initializing the class.Parameters: - size_x (float) – width of the grid
- size_y (float) – height of the grid
-
bumps
(num_bumps, **kwargs)¶ Generates arbitrary bumps (i.e. hills) on the 2-dimensional grid.
This method generates hills on the grid defined by the num_bumps argument. It is possible to control the z-value using bump_height argument. bump_height can be a positive or negative numeric value or it can be a list of numeric values.
Please note that, not all grids can be modified to have num_bumps number of bumps. Therefore, this function uses a brute-force algorithm to determine whether the bumps can be generated or not. For instance:
test_grid = Grid(5, 10) # generates a 5x10 rectangle test_grid.generate(4, 4) # splits the rectangle into 2x2 pieces test_grid.bumps(100) # impossible, it will return an error message test_grid.bumps(1) # You will get a bump at the center of the generated grid
This method accepts the following keyword arguments:
bump_height
: z-value of the generated bumps on the grid. Default: 5.0base_extent
: extension of the hill base from its center in terms of grid points. Default: 2base_adjust
: padding between the bases of the hills. Default: 0
Parameters: num_bumps (int) – number of bumps (i.e. hills) to be generated on the 2D grid
-
generate
(num_u, num_v)¶ Generates grid using the input division parameters.
Parameters: - num_u (int) – number of divisions in x-direction
- num_v (int) – number of divisions in y-direction
-
grid
¶ Weighted grid points.
Please refer to the wiki for details on using this class member.
Getter: Gets the 2-dimensional list of weighted points in [u][v] format
-
reset
()¶ Resets the grid.