File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,26 @@ def reset_weights(self):
235235 self .array_mu_x .fill (0.0 )
236236 self .array_mu_y .fill (0.0 )
237237 self .array_mu_z .fill (0.0 )
238+
239+ def fit_to_points (self , points , padding_factor = 0.05 ):
240+ """
241+ Automatically set the FFD box_origin and box_length based on the input points.
242+
243+ The method computes the axis-aligned bounding box of the input points, adds a small padding, and sets the FFD lattice to exactly
244+ enclose the points. This provides a convenient default for the morphing setup.
245+
246+ :param numpy.ndarray points: The original mesh points (N x 3).
247+ :param float padding_factor: Additional space around the object as a fraction of its size. Default is 0.05 (5%).
248+ """
249+ points = np .asarray (points )
250+ min_coords = np .min (points , axis = 0 )
251+ max_coords = np .max (points , axis = 0 )
252+
253+ side_lengths = max_coords - min_coords
254+ padding = side_lengths * padding_factor
255+ self .box_length = side_lengths + 2 * padding
256+ self .box_origin = min_coords - padding
257+
238258
239259 def read_parameters (self , filename = 'parameters.prm' ):
240260 """
You can’t perform that action at this time.
0 commit comments