### Parametric Gear Function Example Source: https://zoo.dev/research/introducing-kcl Illustrates a function definition for a gear, clearly declaring its parameters like module, number of teeth, and pressure angle. This demonstrates how code captures design intent and facilitates parametric adjustments. ```kcl def gear(module, nTeeth, aPressure): pass ``` -------------------------------- ### OBJ with Vertex Normals Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This OBJ format example includes vertex normal information ('vn') and face definitions that reference both vertex and normal indices. ```obj v -1.0 -1.0 0.0 v 1.0 -1.0 0.0 v 1.0 1.0 0.0 v -1.0 1.0 0.0 vn 0.0 0.0 1.0 f 1//1 2//1 3//1 f 1//1 3//1 4//1 ``` -------------------------------- ### OBJ with Texture Coordinates and Normals Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This OBJ format example showcases the inclusion of vertex texture coordinates ('vt') alongside vertex and normal information. ```obj v -1.0 -1.0 0.0 v 1.0 -1.0 0.0 v 1.0 1.0 0.0 v -1.0 1.0 0.0 vn 0.0 0.0 1.0 vt 0.0 0.0 vt 1.0 0.0 vt 0.0 0.0 vt 1.0 1.0 f 1/1/1 2/2/1 3/3/1 f 1/1/1 3/3/1 4/4/1 ``` -------------------------------- ### OBJ Format Example: Open Cylinder Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet demonstrates how to define an open cylinder using the OBJ file format, which includes defining vertices, curve types, and surface parameters. ```obj vp 0 0 vp 1 0 vp 1 1 vp 0 1 cstype bezier deg 1 curv2 1 2 3 4 1 parm u 0 0.25 0.5 0.75 1 end v 1 0 0 1 v 1 0 -1 0.70710678118654757 v 0 0 -1 1 v -1 0 -1 0.70710678118654757 v -1 0 0 1 v -1 0 1 0.70710678118654757 v 0 0 1 1 v 1 0 1 0.70710678118654757 v 1 0 0 1 v 1 1 0 1 v 1 1 -1 0.70710678118654757 v 0 1 -1 1 v -1 1 -1 0.70710678118654757 v -1 1 0 1 v -1 1 1 0.70710678118654757 v 0 1 1 1 v 1 1 1 0.70710678118654757 v 1 1 0 1 cstype rat bspline deg 2 1 surf 0 1 0 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 parm u 0 0 0 0.25 0.25 0.5 0.5 0.75 0.75 1 1 1 parm v 0 0 1 1 trim 0.0 1.0 1 end ``` -------------------------------- ### STEP Format Example: Cartesian Point and Vertex Point Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet shows how to define a Cartesian point and a vertex point in the STEP format. The vertex_point entity links a topological vertex to its geometric Cartesian point. ```step #10 = CARTESIAN_POINT(‘NAME’, 1.2, 3.4, 5.6); #11 = VERTEX_POINT(‘’, #10); ``` -------------------------------- ### STEP Format Example: Circle Definition Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet illustrates the definition of a circle in the STEP format, including its axis placement and radius. It references a Cartesian point for the center and direction entities for the axes. ```step #30 = CIRCLE(‘’, #31, 2.0); #31 = AXIS2_PLACEMENT_3D(‘’, #32, #33, #34, $); #32 = CARTESIAN_POINT(‘’, 0.0, 1.0, 2.,0); #33 = DIRECTION(‘’, 0.0, 0.0, 1.0); #34 = DIRECTION(‘’, 1.0, 0.0, 0.0); ``` -------------------------------- ### Plaintext PLY File Example Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet shows the structure of a 3D model represented in the ASCII (plaintext) version of the PLY file format. It includes header information defining elements like vertices and faces, followed by the actual data. ```ply ply format ascii 1.0 element vertex 4 property float x property float y property float z element face 6 property list uchar uint vertex_indices end_header -1 -1 0 1 -1 0 1 1 0 -1 1 0 3 1 2 3 3 1 3 4 ``` -------------------------------- ### STEP Format Example: Edge Curve Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet defines an edge_curve entity in STEP, which represents an edge linked to a geometric curve and its endpoints. The final boolean indicates if the curve direction matches the edge endpoints. ```step #20 = EDGE_CURVE(‘’, #11, #13, #30, .T.); ``` -------------------------------- ### Parametric Server Rack Calculation Source: https://zoo.dev/research/introducing-kcl Shows how constants for server rack height and number of sleds can be defined and used to calculate the height per sled. This highlights the traceability and recalculation benefits of parametric code. ```kcl const rackHeight = 100 const numSleds = 20 def server(height): pass sledHeight = rackHeight / numSleds server(sledHeight) ``` -------------------------------- ### Server Sled Design with Parameterized Height Source: https://zoo.dev/research/introducing-kcl Demonstrates a server sled function that accepts height as a parameter, showing how changes in overall rack dimensions or sled count automatically update the sled design. ```kcl def server_sled(height): pass ``` -------------------------------- ### Reusable Server Component Instancing Source: https://zoo.dev/research/introducing-kcl Explains the concept of instancing in software, where repeated components like memory controllers are stored once and referenced multiple times. This is crucial for performance in complex models. ```kcl def memory_controller(): pass def server(height): # ... other components memory_controller() # This instance is reused # ... other components ``` -------------------------------- ### glTF Asset and Scene Definition Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This JSON snippet illustrates the basic structure of a glTF file, defining the asset version, a default scene, and the nodes that constitute that scene. It's the entry point for understanding the glTF hierarchy. ```json { "asset": { "version": 2.0 }, "scene": 0, "scenes": [ { "nodes": [0] } ], "nodes": [ { "mesh": 0 } ], ... } ``` -------------------------------- ### glTF with KITTYCAD_boundary_representation Extension Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet shows the root of a glTF file incorporating the KITTYCAD_boundary_representation extension to define solids. It includes buffer information and the top-level structure for solids and shells. ```json "buffers": [ { "byteLength": 144, "uri": "binary-half.bin" } ], "extensions": { "KITTYCAD_boundary_representation": { "solids": [ { "shells": [[0, 1]], "mesh": 0 } ], ... } } } ``` -------------------------------- ### OBJ Vertex and Face Representation Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet demonstrates the OBJ file format's approach to defining vertices and faces using indices, which is more memory-efficient than STL. ```obj v -1.0 -1.0 0.0 v 1.0 -1.0 0.0 v 1.0 1.0 0.0 v -1.0 1.0 0.0 f 1 2 3 f 1 3 4 ``` -------------------------------- ### STEP B-rep Data Hierarchy Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet visualizes the typical hierarchical structure of a B-rep model within a STEP file, showing the relationships between entities like shape representations, shells, faces, edges, and points. ```text advanced_brep_shape_representation (1+) | manifold_solid_brep (1) | closed_shell (1+) | face (1+) | | | surface (1) | face_bound (1+) | edge_loop (1+) or vertex_loop (1) | oriented_edge (1+) | edge_curve (1) | | | curve (1) | vertex_point (2) | cartesian_point (1) ``` -------------------------------- ### Defining Shells and Faces in glTF B-Rep Extension Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This section details the structure for shells, faces, and surfaces within the glTF B-rep extension. It shows how shells are composed of faces, and faces are defined on parametric surfaces. ```json "shells": [ { "faces": [[0, 1], [1, 1], [2, -1]] } ], "faces": [ { "surface": [0, 1], "loops": [ [0, 1], [1, -1] ] }, ... ], "surfaces": [ { "type": "cylinder", "xAxis": [1.0, 0.0, 0.0], "yAxis": [0.0, 0.0, 1.0], "radius": 1.0 }, ... ], "loops": [ { "edges": [[0, 1]] }, ... ], ... ``` -------------------------------- ### glTF Buffer View and Buffer Definitions Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This JSON snippet defines 'bufferViews' and 'buffers' in a glTF file. Buffer views specify byte ranges within a buffer, and buffers define the actual binary data files, including their size and URI. ```json ... "bufferViews": [ { "buffer": 0, "byteLength": 72, "byteOffset": 0, "target": 34962 }, { "buffer": 0, "byteLength": 72, "byteOffset: 72, "target": 34962 } ], "buffers": [ { "byteLength": 144, "uri": "binary-half.bin" } ] } ``` -------------------------------- ### Readable KCL Model Representation Source: https://zoo.dev/research/introducing-kcl Illustrates how KCL represents models using human-friendly names for better understanding compared to binary data. ```kcl cube = extrude(square, 10) ``` ```kcl chessboard = gridPattern([8, 8], tile) ``` -------------------------------- ### glTF Mesh and Accessor Definitions Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This JSON snippet details the 'meshes' and 'accessors' sections within a glTF file. It shows how mesh primitives reference vertex attributes like POSITION and NORMAL, and how accessors define the properties and location of this attribute data. ```json ... "meshes": [ { "primitives": [ { "attributes": { "POSITION": 0 "NORMAL": 1 }, } ] } ] "accessors": [ { "bufferView": 0, "componentType": 5126, "count": 6, "max": [1.0, 1.0, 1.0], "min": [-1.0, -1.0, -1.0], "type": "VEC3" }, { "bufferView": 1, "componentType" 5126, "count": 6, "type": "VEC3" } ], ... ``` -------------------------------- ### Functional Programming Reusability Principle Source: https://zoo.dev/research/introducing-kcl Highlights the functional programming principle that functions with identical inputs yield identical outputs, enabling efficient caching and reuse of model parts within systems like Zoo. ```kcl def server(height): # ... logic return result # If 'height' is the same, the result of server(height) will be the same, # allowing for caching and reuse. ``` -------------------------------- ### Defining Edges, Vertices, and Curves in glTF B-Rep Extension Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet illustrates the definition of edges, vertices, and 3D curves within the glTF B-rep extension. Edges are defined by parametric curves and join at vertices, while B-rep vertices are defined by their 3D position. ```json "edges": [ { "curve": [0, 1], "start": 0, "end": 0, "closed": true, "t": [0, 6.28318530718], }, ... ], "vertices": [ [1.0, 0.0, 0.0], ... ], "curves3D": [ { "type": "circle", "xAxis": [1.0, 0.0, 0.0], "yAxis": [0.0, 0.0, 1.0], "radius": 1.0 }, ... ] }, ... ``` -------------------------------- ### Constructing a Semi-Circular Profile Curve Source: https://zoo.dev/research/zoo-cad-engine-overview Programmatically defines a semi-circular path for a sweep operation. This is useful for creating rounded profiles. ```cpp center = { 0, 0, 0 }; path->moveTo(center); path->addArc(center, sz / 3.0, 270, 450); path->close(); ``` -------------------------------- ### Defining a Trajectory Path with Lines and Arcs Source: https://zoo.dev/research/zoo-cad-engine-overview Programmatically defines a complex trajectory path using a combination of straight lines and tangential arcs. This is suitable for general sweep operations where the path is not a simple curve. ```cpp path->moveTo( { 0, 0, 0 } ); path->lineTo( { 0, 25, 0 } ); path->tangentialArcTo( { 25, 50, 0 } ); path->tangentialArcTo( { 50, 75, 0 } ); path->lineTo( { 50, 100, 0 } ); ``` -------------------------------- ### STL Facet Representation Source: https://zoo.dev/research/a-practical-overview-of-cad-file-formats This snippet shows the structure of a facet in the STL (Stereolithography) file format, defining vertices for two triangular faces. ```stl facet outer loop vertex -1.0 -1.0 0.0 vertex 1.0 -1.0 0.0 vertex 1.0 1.0 0.0 endloop endfacet facet outer loop vertex -1.0 -1.0 0.0 vertex 1.0 1.0 0.0 vertex -1.0 1.0 0.0 endloop endfacet ``` -------------------------------- ### Classify Points in Parameter Space Source: https://zoo.dev/research/zoo-cad-engine-overview This code snippet processes points derived from a medial axis transform to classify them as regular points, joints, ends, or boundary ends. It calculates distance and adjacency matrices to determine point connectivity. ```python # Create distance and adjacency matrix xx, yy = np.where(MAT) pnt_type = np.zeros(len(xx)-1) dist_mat = ((xx[:, None]-xx[None, :])**2 + (yy[:, None]-yy[None, :])**2) adj_mat = (dist_mat <= 2).astype(int) #print('adj_mat =', adj_mat) # Joints have more than 2 neighbors; endpoints have only one. joints = np.where(adj_mat.sum(1)>3)[0] #print('joints = ',joints) ends = np.where(adj_mat.sum(1)==2)[0] #print('ends = ',ends) # Determine point type pnt_type = np.zeros(len(xx)) #zero indicates regular point for j in range (len(joints)-1): pnt_type[joints[j]] = 1 #tag for joints for j in range (len(ends)): pnt_type[ends[j]] = 2 #tag for ends jj=ends[j] if xx[jj]==0 or yy[jj]==0 or xx[jj] >= 34 or yy[jj] >= 34: ## num patches-1 times res pnt_type[jj] = 3 #tag for ends on boundaries ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.