sdf-sampler 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sdf_sampler/__init__.py CHANGED
@@ -47,7 +47,7 @@ from sdf_sampler.models import (
47
47
  )
48
48
  from sdf_sampler.sampler import SDFSampler
49
49
 
50
- __version__ = "0.3.0"
50
+ __version__ = "0.4.0"
51
51
 
52
52
  __all__ = [
53
53
  # Main classes
sdf_sampler/analyzer.py CHANGED
@@ -14,6 +14,7 @@ from sdf_sampler.algorithms.voxel_regions import generate_voxel_region_constrain
14
14
  from sdf_sampler.config import AnalyzerConfig, AutoAnalysisOptions
15
15
  from sdf_sampler.models.analysis import (
16
16
  ALL_ALGORITHMS,
17
+ DEFAULT_ALGORITHMS,
17
18
  AlgorithmStats,
18
19
  AlgorithmType,
19
20
  AnalysisResult,
@@ -93,7 +94,7 @@ class SDFAnalyzer:
93
94
  raise ValueError(f"normals shape {normals.shape} doesn't match xyz {xyz.shape}")
94
95
 
95
96
  # Determine which algorithms to run
96
- algo_list = algorithms if algorithms else [a.value for a in ALL_ALGORITHMS]
97
+ algo_list = algorithms if algorithms else [a.value for a in DEFAULT_ALGORITHMS]
97
98
  algo_list = [a for a in algo_list if a in [alg.value for alg in ALL_ALGORITHMS]]
98
99
 
99
100
  # Run algorithms and collect constraints
sdf_sampler/cli.py CHANGED
@@ -169,10 +169,10 @@ def add_output_options(parser: argparse.ArgumentParser) -> None:
169
169
  help="Include original surface points (phi=0) in output",
170
170
  )
171
171
  group.add_argument(
172
- "--surface-point-ratio",
173
- type=float,
174
- default=0.1,
175
- help="Ratio of surface points to include (default: 0.1 = 10%%)",
172
+ "--surface-point-count",
173
+ type=int,
174
+ default=1000,
175
+ help="Number of surface points to include (default: 1000)",
176
176
  )
177
177
 
178
178
 
@@ -463,7 +463,7 @@ def cmd_sample(args: argparse.Namespace) -> int:
463
463
  # Include surface points if requested
464
464
  if args.include_surface_points:
465
465
  samples = _add_surface_points(
466
- samples, xyz, normals, args.surface_point_ratio, args.verbose
466
+ samples, xyz, normals, args.surface_point_count, args.verbose
467
467
  )
468
468
 
469
469
  if args.verbose:
@@ -541,7 +541,7 @@ def cmd_pipeline(args: argparse.Namespace) -> int:
541
541
  # Include surface points if requested
542
542
  if args.include_surface_points:
543
543
  samples = _add_surface_points(
544
- samples, xyz, normals, args.surface_point_ratio, args.verbose
544
+ samples, xyz, normals, args.surface_point_count, args.verbose
545
545
  )
546
546
 
547
547
  if args.verbose:
@@ -557,14 +557,14 @@ def _add_surface_points(
557
557
  samples: list,
558
558
  xyz: np.ndarray,
559
559
  normals: np.ndarray | None,
560
- ratio: float,
560
+ count: int,
561
561
  verbose: bool,
562
562
  ) -> list:
563
563
  """Add surface points to sample list."""
564
564
  from sdf_sampler.models import TrainingSample
565
565
 
566
- n_surface = int(len(xyz) * ratio)
567
- if n_surface == 0:
566
+ n_surface = min(count, len(xyz))
567
+ if n_surface <= 0:
568
568
  return samples
569
569
 
570
570
  # Subsample if needed
@@ -26,6 +26,13 @@ ALL_ALGORITHMS = [
26
26
  AlgorithmType.NORMAL_IDW,
27
27
  ]
28
28
 
29
+ # Default algorithms (excludes normal_idw which is opt-in)
30
+ DEFAULT_ALGORITHMS = [
31
+ AlgorithmType.FLOOD_FILL,
32
+ AlgorithmType.VOXEL_REGIONS,
33
+ AlgorithmType.NORMAL_OFFSET,
34
+ ]
35
+
29
36
 
30
37
  class GeneratedConstraint(BaseModel):
31
38
  """A constraint generated by auto-analysis.
sdf_sampler/sampler.py CHANGED
@@ -66,7 +66,7 @@ class SDFSampler:
66
66
  strategy: str | SamplingStrategy = SamplingStrategy.INVERSE_SQUARE,
67
67
  seed: int | None = None,
68
68
  include_surface_points: bool = False,
69
- surface_point_ratio: float = 0.1,
69
+ surface_point_count: int | None = None,
70
70
  ) -> list[TrainingSample]:
71
71
  """Generate training samples from constraints.
72
72
 
@@ -78,7 +78,7 @@ class SDFSampler:
78
78
  strategy: Sampling strategy (CONSTANT, DENSITY, or INVERSE_SQUARE)
79
79
  seed: Random seed for reproducibility
80
80
  include_surface_points: If True, include original surface points with phi=0
81
- surface_point_ratio: Fraction of surface points to include (default 0.1 = 10%)
81
+ surface_point_count: Number of surface points to include (default: 1000, or len(xyz) if smaller)
82
82
 
83
83
  Returns:
84
84
  List of TrainingSample objects
@@ -160,8 +160,10 @@ class SDFSampler:
160
160
 
161
161
  # Add surface points if requested
162
162
  if include_surface_points:
163
+ # Default to 1000 surface points, or all points if smaller
164
+ count = surface_point_count if surface_point_count is not None else min(1000, len(xyz))
163
165
  samples.extend(
164
- self._generate_surface_points(xyz, normals, surface_point_ratio, rng)
166
+ self._generate_surface_points(xyz, normals, count, rng)
165
167
  )
166
168
 
167
169
  return samples
@@ -170,7 +172,7 @@ class SDFSampler:
170
172
  self,
171
173
  xyz: np.ndarray,
172
174
  normals: np.ndarray | None,
173
- ratio: float,
175
+ count: int,
174
176
  rng: np.random.Generator,
175
177
  ) -> list[TrainingSample]:
176
178
  """Generate surface point samples (phi=0) from the input point cloud.
@@ -178,14 +180,14 @@ class SDFSampler:
178
180
  Args:
179
181
  xyz: Point cloud positions (N, 3)
180
182
  normals: Optional point normals (N, 3)
181
- ratio: Fraction of points to include (0.0 to 1.0)
183
+ count: Number of surface points to include
182
184
  rng: Random number generator
183
185
 
184
186
  Returns:
185
187
  List of TrainingSample objects with phi=0
186
188
  """
187
- n_surface = int(len(xyz) * ratio)
188
- if n_surface == 0:
189
+ n_surface = min(count, len(xyz))
190
+ if n_surface <= 0:
189
191
  return []
190
192
 
191
193
  # Subsample if needed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdf-sampler
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Auto-analysis and sampling of point clouds for SDF (Signed Distance Field) training data generation
5
5
  Project-URL: Repository, https://github.com/Chiark-Collective/sdf-sampler
6
6
  Author-email: Liam <liam@example.com>
@@ -1,10 +1,10 @@
1
- sdf_sampler/__init__.py,sha256=Kd5g1IROdKbRTR_gNSO4ff1ddNVP4WZJ30JFUbILa5k,1891
1
+ sdf_sampler/__init__.py,sha256=FHnKJRr5pvXppAkkkofZwF7BE4BZjq1xKeCprQHg_hU,1891
2
2
  sdf_sampler/__main__.py,sha256=6N7jJs2Efs1AmM7qXXXN9V-ErFTWpPqKzWTeiujtGhU,490
3
- sdf_sampler/analyzer.py,sha256=p5Pkoa01dBGFqqQs2wpWrr8ilPMsjkB4ODJEI2IWbdo,11674
4
- sdf_sampler/cli.py,sha256=ykW1_cPBV6G1ZtKmq0ZyjgUmVK-ESqk3Ey6SLMRIhSQ,20144
3
+ sdf_sampler/analyzer.py,sha256=bF0jiqJg0tc8H3c6O1f7Ac6tYxsHsT8Y0ShyoRcZnGg,11702
4
+ sdf_sampler/cli.py,sha256=DB6oAYCfH80hSGHt2IgUBa5tNock9HfeB_6Xsea2oDs,20135
5
5
  sdf_sampler/config.py,sha256=lrPM1ktFkv32RRtOz6R-ShUFlBZ2LvoAl1hRLThmgKw,5185
6
6
  sdf_sampler/io.py,sha256=DfdXJa_2KQhja_T_a-jlVADcAABeF-NR8e3_vnIJHnk,4968
7
- sdf_sampler/sampler.py,sha256=3yVT5LHB7-rIxdor-aSdkC6Qew5M-7UvZCKwtIZG0IQ,17744
7
+ sdf_sampler/sampler.py,sha256=G_t6o8HpXAP16s_V-dewYt9K_0Bq6Lx1vBPT7udmgMg,17915
8
8
  sdf_sampler/algorithms/__init__.py,sha256=pp7tSZ8q0zRXZ5S8D3tho7bJ62pmW8jceuuRXtiXIzU,777
9
9
  sdf_sampler/algorithms/flood_fill.py,sha256=iWGPPtOPSs0Cg7pxUlXUKGloFNCr8PuCHguRNy3c56c,7042
10
10
  sdf_sampler/algorithms/normal_idw.py,sha256=uX3MQDTDX0wVilwxDE9dFj9hm2xuBDHV-AZqspjz7sk,3270
@@ -13,7 +13,7 @@ sdf_sampler/algorithms/pocket.py,sha256=d6cvFz8C1ZFGgaOEySnFcKMPlHZ-kqOU_bBvOoXT
13
13
  sdf_sampler/algorithms/voxel_grid.py,sha256=LJz5V02AxSBRL0-kNEV3yEN_cMWFymGiepX0yysE6dw,11133
14
14
  sdf_sampler/algorithms/voxel_regions.py,sha256=YHr-apdq9wTo_po6v5L9HxQLkcZ1kP3KfJhoaQDZJOE,2422
15
15
  sdf_sampler/models/__init__.py,sha256=XWzMnPgvZyZF1ZUSfqlspIitLkzMn_0Yxj-hRF-ALEQ,1134
16
- sdf_sampler/models/analysis.py,sha256=h9CIxBeTQ89Z2-B3qdrlHM8qtOA0caijTYwzd9HsyUw,3251
16
+ sdf_sampler/models/analysis.py,sha256=xSzz1jmpV3mOSM4gIF3NR4dhPXPH6UlxIgxZSOke5yE,3432
17
17
  sdf_sampler/models/constraints.py,sha256=k0v6-JwXmUkFXGycDpPG44amjoRo13xz1ggqdr9NVtE,7316
18
18
  sdf_sampler/models/samples.py,sha256=0DD7Z8D70zJKRTq16pik9SgGiRDeXh56EqmBZfql_sk,1474
19
19
  sdf_sampler/sampling/__init__.py,sha256=mbeU9DTHxR4R1D4WqjEzaYHq7bV1nSv-wywc3YoD_Lg,492
@@ -21,8 +21,8 @@ sdf_sampler/sampling/box.py,sha256=qRAumR1z_7vU9rfNvk-B6xNu62UeHSyQNghYiTwVR_Y,3
21
21
  sdf_sampler/sampling/brush.py,sha256=CcAgOYLdYXMM3y_H4fIwyzRJ8PZivFxkUHP7d0ElpNM,1991
22
22
  sdf_sampler/sampling/ray_carve.py,sha256=EsfzEGk33q0iWVzOJKDAJi2iWEsY-JZXmEfEZ0dmNdg,4444
23
23
  sdf_sampler/sampling/sphere.py,sha256=Xqpwq-RcEnAD6HhoyIC-ErxRHDknDKMtYf6aWUJ43_U,1680
24
- sdf_sampler-0.3.0.dist-info/METADATA,sha256=MU48zB7pLEhlGEO5ZTDcfP0l7DBXH3u3_iZI0oZJ4FU,10481
25
- sdf_sampler-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
26
- sdf_sampler-0.3.0.dist-info/entry_points.txt,sha256=2IMWFbDYEqVUkpiRF1BlRMOhipeirPJSbv5PIOIZrvA,53
27
- sdf_sampler-0.3.0.dist-info/licenses/LICENSE,sha256=eeB8aLnEG-dgFYs2KqfMJaP52GFQT8sZPHwaYnHRW8E,1061
28
- sdf_sampler-0.3.0.dist-info/RECORD,,
24
+ sdf_sampler-0.4.0.dist-info/METADATA,sha256=o1peEETZNWtfdDyIvd4NIZFm30imYZbPvvbyUAeWH1Y,10481
25
+ sdf_sampler-0.4.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
26
+ sdf_sampler-0.4.0.dist-info/entry_points.txt,sha256=2IMWFbDYEqVUkpiRF1BlRMOhipeirPJSbv5PIOIZrvA,53
27
+ sdf_sampler-0.4.0.dist-info/licenses/LICENSE,sha256=eeB8aLnEG-dgFYs2KqfMJaP52GFQT8sZPHwaYnHRW8E,1061
28
+ sdf_sampler-0.4.0.dist-info/RECORD,,