Files
make-cad/docs/skill/references/docs/core/vertex.md
T
Ni Jingzhe c454a3af10 feat(skill): per-harness skillbuild toolchain replaces skill-pack (#18)
* feat(skill): replace skill-pack with per-harness conditional compiler

skillbuild compiles the skill tree into per-target harness builds:
- <!-- skill:if omp,!claude --> blocks include text only for matching
  targets; name-list conditions only, no else/nesting, fail-loud on
  unknown targets and unpaired/nested directives
- fence-aware: directive-looking lines inside code fences are literal
- layout is the filesystem; tree root configured in skillproj.toml
- post-build assertion: zero directive residue, SKILL.md frontmatter
  name check

Migration to the new model:
- docs/skill/ becomes the self-contained source root (SKILL.md,
  references/, generated api/stdlib/core/guides now under
  references/docs/; SDK_OVERVIEW/LICENSE/inspect are ordinary tree
  files)
- auto_docs_gen output redirected into the tree (docs/api ->
  docs/skill/references/docs/api, likewise stdlib)
- skills/simplecadapi/ is now the compiled omp target output;
  dist/generic/simplecadapi the generic target
- dropped skill-pack entry point (plus dangling evolve/make-export
  entries and their orphaned test), release workflow builds via
  skillbuild + tar; README updated

First real conditional block: harness reading paths in SKILL.md
(skill:// mount on omp vs disk-relative on generic).

Verified: 59 tests pass (skillbuild 31, auto_docs_gen 19, persistence
regression 9); both targets build; outputs residue-clean; full suite
collects (1376 tests).

* refactor(tools): auto_docs_gen moves out of the installed package

tools/ scripts are repo-checkout dev scripts, not packaged CLIs:
- auto_docs_gen.py now lives in tools/ beside the other generators;
  auto_tools/ package removed entirely
- path resolution simplifies: repo root = parent of tools/, fail-loud
  if pyproject.toml missing; site-packages/cwd fallback branches were
  dead code once the script stopped shipping in the wheel
- auto-docs-gen console script dropped from [project.scripts];
  release.yml and README invoke python tools/auto_docs_gen.py
- MANIFEST.in stale src/auto_tools include removed; CadQuery-free
  runtime scan no longer needs the auto_tools filter
- run_examples.py retired (user removal): README example-runner text
  updated to direct examples/ scripts; dangling runner-contract test
  (runpy.run_path into the deleted script) removed

Verified: 53 tests pass (auto_docs_gen + skill_build + ocp runtime
scan) and test_example_model_contract passes; regeneration from
tools/ is byte-identical (zero docs drift).

* refactor(skill): strip harness and build-tool content from the skill tree

The skill is plain harness-neutral content again:
- SKILL.md 'Reading skill files' section removed (the omp skill://
  mount block and its !omp complement were the only conditional
  blocks; the tree compiles identically for every target now)
- references/README.md: build-tool meta removed ('per-harness
  conditional compilation', skillbuild packaging/validation claims —
  link validation was never implemented, so the claim was false)
- live test now asserts the tree stays harness-neutral (zero blocks)
- skillproj.toml targets aligned with the user's output table
  (omp -> skills/simplecadapi-omp, opencode -> skills/simplecadapi-opencode;
  leftover 'generic' entry had no output and failed the build)
- compiled outputs are regenerable artifacts: skills/simplecadapi/
  untracked from git, skills/simplecadapi-*/ gitignored, release.yml
  and README build via skillbuild and tar the omp output directly
  (bsdtar has no --transform; inner dir keeps its suffixed name)

Verified: 49 tests pass; both targets build 372 files with zero
conditional blocks; no omp/conditional/directive residue in the tree
or outputs.

* chore(docs): drop stale architecture review and design notes
2026-08-22 20:20:49 +08:00

7.1 KiB

Vertex

Overview

Vertex is the vertex class in SimpleCAD API, representing a point in 3D space. It wraps OCP's Vertex object and adds tag functionality for identifying and managing specific vertices in geometries.

Class Definition

class Vertex(TaggedMixin):
    """Vertex class that wraps OCP's Vertex and adds tag functionality"""

Inheritance Relationships

  • Inherits from TaggedMixin, with tag and metadata functionality

Usage

  • Represent points in 3D space
  • Serve as building elements for edges, wires, faces, and other geometries
  • Provide vertex coordinate information
  • Support tag management and queries

Constructor

__init__(wrapped)

Initialize a vertex object.

Parameters:

  • wrapped (OCP TopoDS_Vertex): OCP vertex object

Exceptions:

  • ValueError: Raised when the input vertex object is invalid

Example:

from simplecadapi import make_point_rvertex

# Create a vertex through the SimpleCAD function
vertex = make_point_rvertex(1.0, 2.0, 3.0)

Main Properties

  • wrapped: Underlying OCP vertex object
  • _tags: Tag set (inherited from TaggedMixin)
  • _metadata: Metadata dictionary (inherited from TaggedMixin)

Common Methods

get_coordinates()

Get the coordinates of the vertex.

Returns:

  • Tuple[float, float, float]: Vertex coordinates (x, y, z)

Exceptions:

  • ValueError: Raised when coordinate retrieval fails

Example:

from simplecadapi import make_point_rvertex

vertex = make_point_rvertex(1.0, 2.0, 3.0)
coords = vertex.get_coordinates()
print(coords)  # (1.0, 2.0, 3.0)

Tagging and Metadata

Use the functional public API apply_tag(shape, tag) and list_tags(shape) for tags. Use set_metadata(key, value) and get_metadata(key, default=None) for structured metadata.

Example:

from simplecadapi import apply_tag, list_tags, make_point_rvertex

vertex = make_point_rvertex(0, 0, 0)
apply_tag(vertex, "role.origin")
apply_tag(vertex, "anchor.reference_point")

if "role.origin" in list_tags(vertex):
    print("This is the origin")

Metadata Management Methods

set_metadata(key, value)

Set metadata.

Example:

vertex = make_point_rvertex(0, 0, 0)
vertex.set_metadata("created_by", "user_input")
vertex.set_metadata("importance", "high")

get_metadata(key, default=None)

Get metadata.

Example:

vertex = make_point_rvertex(0, 0, 0)
vertex.set_metadata("created_by", "user_input")

creator = vertex.get_metadata("created_by")
print(creator)  # "user_input"

unknown = vertex.get_metadata("unknown_key", "default_value")
print(unknown)  # "default_value"

Usage Examples

Creating and Using Vertices

from simplecadapi import make_point_rvertex

# Create vertices
vertex1 = make_point_rvertex(0, 0, 0)
vertex2 = make_point_rvertex(1, 1, 1)

# Get coordinates
coords1 = vertex1.get_coordinates()
coords2 = vertex2.get_coordinates()

print(f"Vertex 1 coordinates: {coords1}")  # Vertex 1 coordinates: (0.0, 0.0, 0.0)
print(f"Vertex 2 coordinates: {coords2}")  # Vertex 2 coordinates: (1.0, 1.0, 1.0)

Vertex Tag Management

from simplecadapi import make_point_rvertex

# Create key points
origin = make_point_rvertex(0, 0, 0)
corner1 = make_point_rvertex(10, 0, 0)
corner2 = make_point_rvertex(10, 10, 0)
corner3 = make_point_rvertex(0, 10, 0)

# Add tags
apply_tag(origin, "origin")
apply_tag(origin, "reference")

apply_tag(corner1, "corner")
apply_tag(corner1, "x_axis")

apply_tag(corner2, "corner")
apply_tag(corner2, "diagonal")

apply_tag(corner3, "corner")
apply_tag(corner3, "y_axis")

# Find all corner points
vertices = [origin, corner1, corner2, corner3]
corners = [v for v in vertices if "corner" in list_tags(v)]

print(f"Found {len(corners)} corner points")

Vertex Classification and Management

from simplecadapi import make_point_rvertex

def create_grid_vertices(width, height, spacing):
    """Create grid vertices"""
    vertices = []
    
    for i in range(width + 1):
        for j in range(height + 1):
            x = i * spacing
            y = j * spacing
            z = 0
            
            vertex = make_point_rvertex(x, y, z)
            
            # Add position tags
            if i == 0 and j == 0:
                apply_tag(vertex, "origin")
            elif i == 0:
                apply_tag(vertex, "left_edge")
            elif i == width:
                apply_tag(vertex, "right_edge")
            
            if j == 0:
                apply_tag(vertex, "bottom_edge")
            elif j == height:
                apply_tag(vertex, "top_edge")
            
            # Add corner tags
            if (i == 0 or i == width) and (j == 0 or j == height):
                apply_tag(vertex, "corner")
            
            # Add metadata
            vertex.set_metadata("grid_position", (i, j))
            vertex.set_metadata("distance_from_origin", (x*x + y*y)**0.5)
            
            vertices.append(vertex)
    
    return vertices

# Create a 5x3 grid
vertices = create_grid_vertices(5, 3, 1.0)

# Find specific vertices
corners = [v for v in vertices if "corner" in list_tags(v)]
origin = [v for v in vertices if "origin" in list_tags(v)][0]

print(f"Total grid vertices: {len(vertices)}")
print(f"Corner count: {len(corners)}")
print(f"Origin coordinates: {origin.get_coordinates()}")

Vertex Distance Calculation

import math
from simplecadapi import make_point_rvertex

def calculate_distance(vertex1, vertex2):
    """Calculate the distance between two vertices"""
    coords1 = vertex1.get_coordinates()
    coords2 = vertex2.get_coordinates()
    
    dx = coords2[0] - coords1[0]
    dy = coords2[1] - coords1[1]
    dz = coords2[2] - coords1[2]
    
    return math.sqrt(dx*dx + dy*dy + dz*dz)

# Create vertices
v1 = make_point_rvertex(0, 0, 0)
v2 = make_point_rvertex(3, 4, 0)
v3 = make_point_rvertex(0, 0, 5)

# Calculate distances
dist12 = calculate_distance(v1, v2)
dist13 = calculate_distance(v1, v3)
dist23 = calculate_distance(v2, v3)

print(f"Distance from v1 to v2: {dist12}")  # 5.0
print(f"Distance from v1 to v3: {dist13}")  # 5.0
print(f"Distance from v2 to v3: {dist23}")  # approx 7.07

String Representation

from simplecadapi import make_point_rvertex

vertex = make_point_rvertex(1.234, 5.678, 9.012)
apply_tag(vertex, "test_point")
vertex.set_metadata("created_by", "example")

print(vertex)

Output:

Vertex:
  coordinates: [1.234, 5.678, 9.012]
  tags: [test_point]
  metadata:
    created_by: example

Relationships with Other Geometries

Vertices are the fundamental elements that compose more complex geometries:

  • Edge: Defined by two vertices
  • Wire: Composed of multiple connected edges, containing multiple vertices
  • Face: Boundary defined by vertices
  • Solid: Ultimately composed of vertices

Notes

  • Vertex objects wrap OCP's underlying vertices; do not modify coordinates directly
  • Tags are of string type and are case-sensitive
  • Metadata can store values of any type
  • Vertex coordinates are read-only; to modify positions, create new vertices
  • Floating-point coordinates may have precision issues; consider tolerance when comparing