@@ -343,11 +343,13 @@ def build_bounding_box(self, shape, tol=1e-6, triangulate=False, triangulate_tol
343343
344344 def _set_box_dimensions (self , min_xyz , max_xyz ):
345345 """
346- Dimensions of the cage are set as distance from the origin (minimum) of the cage to
347- the maximal point in each dimension.
346+ Dimensions of the cage are set as distance from the origin (minimum) of
347+ the cage to the maximal point in each dimension.
348348
349- :param iterable min_xyz: three values representing the minimal values of the bounding box in XYZ respectively
350- :param iterable max_xyz: three values representing the maximal values of the bounding box in XYZ respectively
349+ :param iterable min_xyz: three values representing the minimal values of
350+ the bounding box in XYZ respectively
351+ :param iterable max_xyz: three values representing the maximal values of
352+ the bounding box in XYZ respectively
351353 """
352354 dims = [max_xyz [i ] - min_xyz [i ] for i in range (3 )]
353355 self .lenght_box_x = dims [0 ]
@@ -357,8 +359,9 @@ def _set_box_dimensions(self, min_xyz, max_xyz):
357359 def _set_position_of_vertices (self ):
358360 """
359361 Vertices of the control box around the object are set in this method.
360- Four vertices (non coplanar) are sufficient to uniquely identify a parallelepiped -- the
361- second half of the box is created as a mirror reflection of the first four vertices.
362+ Four vertices (non coplanar) are sufficient to uniquely identify a
363+ parallelepiped -- the second half of the box is created as a mirror
364+ reflection of the first four vertices.
362365 """
363366 origin_array = np .array (self .origin_box )
364367 dim = [self .lenght_box_x , self .lenght_box_y , self .lenght_box_z ]
@@ -369,17 +372,18 @@ def _set_position_of_vertices(self):
369372
370373 def _set_mapping (self ):
371374 """
372- This method sets mapping from physcial domain to the reference domain (``psi_mapping``)
373- as well as inverse mapping (``inv_psi_mapping``).
375+ This method sets mapping from physcial domain to the reference domain
376+ (``psi_mapping``) as well as inverse mapping (``inv_psi_mapping``).
374377 """
375378 dim = [self .lenght_box_x , self .lenght_box_y , self .lenght_box_z ]
376379 self .psi_mapping = np .diag ([1. / dim [i ] for i in range (3 )])
377380 self .inv_psi_mapping = np .diag (dim )
378381
379382 def _set_transformation_params_to_zero (self ):
380383 """
381- Sets transfomration parameters (``array_mu_x, array_mu_y, array_mu_z``) to arrays of zeros
382- (``numpy.zeros``). The shape of arrays corresponds to the number of control points in each dimension.
384+ Sets transfomration parameters (``array_mu_x, array_mu_y, array_mu_z``)
385+ to arrays of zeros (``numpy.zeros``). The shape of arrays corresponds to
386+ the number of control points in each dimension.
383387 """
384388 ctrl_pnts = self .n_control_points
385389 self .array_mu_x = np .zeros (ctrl_pnts )
@@ -390,17 +394,20 @@ def _set_transformation_params_to_zero(self):
390394 def _calculate_bb_dimension (shape , tol = 1e-6 , triangulate = False , triangulate_tol = 1e-1 ):
391395 """ Calculate dimensions (minima and maxima) of a box bounding the
392396
393- :param TopoDS_Shape shape: or a subclass such as TopoDS_Face
394- the shape to compute the bounding box from
397+ :param TopoDS_Shape shape: or a subclass such as TopoDS_Face the shape
398+ to compute the bounding box from
395399 :param float tol: tolerance of the computed bounding box
396- :param bool triangulate: Should shape be triangulated before the boudning box is created.
400+ :param bool triangulate: Should shape be triangulated before the
401+ boudning box is created.
397402
398- If ``True`` only the dimensions of the bb will take into account every part of the shape (also not *visible*)
403+ If ``True`` only the dimensions of the bb will take into account
404+ every part of the shape (also not *visible*)
399405
400406 If ``False`` only the *visible* part is taken into account
401407
402408 \*See :meth:`~params.FFDParameters.build_bounding_box`
403- :param float triangulate_tol: tolerance of triangulation (size of created triangles)
409+ :param float triangulate_tol: tolerance of triangulation (size of
410+ created triangles)
404411 :return: coordinates of minima and maxima along XYZ
405412 :rtype: tuple
406413 """
@@ -417,27 +424,32 @@ def _calculate_bb_dimension(shape, tol=1e-6, triangulate=False, triangulate_tol=
417424
418425class RBFParameters (object ):
419426 """
420- Class that handles the Radial Basis Functions parameters in terms of RBF control points and
421- basis functions.
422-
423- :cvar string basis: name of the basis functions to use in the transformation. The functions
424- implemented so far are: gaussian spline, multi quadratic biharmonic spline,
425- inv multi quadratic biharmonic spline, thin plate spline, beckert wendland c2 basis.
426- For a comprehensive list with details see the class :class:`~pygem.radialbasis.RBF`.
427- The default value is None.
428- :cvar float radius: is the scaling parameter r that affects the shape of the basis functions.
429- For details see the class :class:`~pygem.radialbasis.RBF`. The default value is None.
427+ Class that handles the Radial Basis Functions parameters in terms of RBF
428+ control points and basis functions.
429+
430+ :cvar string basis: name of the basis functions to use in the
431+ transformation. The functions implemented so far are: gaussian spline,
432+ multi quadratic biharmonic spline, inv multi quadratic biharmonic
433+ spline, thin plate spline, beckert wendland c2 basis, polyharmonic
434+ splines. For a comprehensive list with details see the class
435+ :class:`~pygem.radialbasis.RBF`. The default value is None.
436+ :cvar float radius: is the scaling parameter r that affects the shape of the
437+ basis functions. For details see the class
438+ :class:`~pygem.radialbasis.RBF`. The default value is None.
430439 :cvar int n_control_points: total number of control points.
431- :cvar numpy.ndarray original_control_points: it is an `n_control_points`-by-3 array with the
432- coordinates of the original interpolation control points before the deformation. The
433- default value is None.
434- :cvar numpy.ndarray deformed_control_points: it is an `n_control_points`-by-3 array with the
435- coordinates of the interpolation control points after the deformation. The default value
440+ :cvar numpy.ndarray original_control_points: it is an
441+ `n_control_points`-by-3 array with the coordinates of the original
442+ interpolation control points before the deformation. The default value
436443 is None.
444+ :cvar numpy.ndarray deformed_control_points: it is an
445+ `n_control_points`-by-3 array with the coordinates of the
446+ interpolation control points after the deformation. The default value is
447+ None.
437448 """
438449 def __init__ (self ):
439450 self .basis = None
440451 self .radius = None
452+ self .power = 2
441453 self .n_control_points = None
442454 self .original_control_points = None
443455 self .deformed_control_points = None
@@ -447,14 +459,15 @@ def read_parameters(self, filename='parameters_rbf.prm'):
447459 """
448460 Reads in the parameters file and fill the self structure.
449461
450- :param string filename: parameters file to be read in. Default value is parameters_rbf.prm.
462+ :param string filename: parameters file to be read in. Default value is
463+ parameters_rbf.prm.
451464 """
452465 if not isinstance (filename , str ):
453466 raise TypeError ('filename must be a string' )
454467
455- # Checks if the parameters file exists. If not it writes the default class into filename.
456- # It consists in the vetices of a cube of side one with a vertex in (0, 0, 0) and opposite one
457- # in (1, 1, 1).
468+ # Checks if the parameters file exists. If not it writes the default
469+ # class into filename. It consists in the vetices of a cube of side one
470+ # with a vertex in (0, 0, 0) and opposite one in (1, 1, 1).
458471 if not os .path .isfile (filename ):
459472 self .basis = 'gaussian_spline'
460473 self .radius = 0.5
@@ -471,6 +484,7 @@ def read_parameters(self, filename='parameters_rbf.prm'):
471484
472485 self .basis = config .get ('Radial Basis Functions' , 'basis function' )
473486 self .radius = config .getfloat ('Radial Basis Functions' , 'radius' )
487+ self .power = config .getint ('Radial Basis Functions' , 'power' )
474488
475489 ctrl_points = config .get ('Control points' , 'original control points' )
476490 lines = ctrl_points .split ('\n ' )
@@ -511,14 +525,17 @@ def write_parameters(self, filename='parameters_rbf.prm'):
511525 output_file .write ('\n # basis funtion is the name of the basis functions to use in the transformation. ' + \
512526 'The functions\n ' )
513527 output_file .write ('# implemented so far are: gaussian_spline, multi_quadratic_biharmonic_spline,\n ' )
514- output_file .write ('# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis.\n ' )
528+ output_file .write ('# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis, polyharmonic_spline .\n ' )
515529 output_file .write ('# For a comprehensive list with details see the class RBF.\n ' )
516530 output_file .write ('basis function: ' + str (self .basis ) + '\n ' )
517531
518532 output_file .write ('\n # radius is the scaling parameter r that affects the shape of the basis functions. ' + \
519533 'See the documentation\n ' )
520534 output_file .write ('# of the class RBF for details.\n ' )
521535 output_file .write ('radius: ' + str (self .radius ) + '\n ' )
536+ output_file .write ('\n # The power parameter k for polyharmonic spline' )
537+ output_file .write ('\n # See the documentation for details\n ' )
538+ output_file .write ('power: ' + str (self .power ) + '\n ' )
522539
523540 output_file .write ('\n \n [Control points]\n ' )
524541 output_file .write ('# This section describes the RBF control points.\n ' )
@@ -552,6 +569,7 @@ def __str__(self):
552569 string = ''
553570 string += 'basis function = {}\n ' .format (self .basis )
554571 string += 'radius = {}\n ' .format (self .radius )
572+ string += 'power = {}\n ' .format (self .power )
555573 string += '\n original control points =\n '
556574 string += '{}\n ' .format (self .original_control_points )
557575 string += '\n deformed control points =\n '
0 commit comments