@@ -383,8 +383,7 @@ describe("OCCT io unit tests", () => {
383383 const significantBulges = bulges . filter ( ( b : number ) => Math . abs ( b ) > 0.9 ) ;
384384 expect ( significantBulges . length ) . toBe ( 2 ) ; // Two semicircular arcs
385385
386- // The two arcs should have opposite signs (one CW, one CCW)
387- // Find the two significant bulges
386+ // Both arcs bulge outward from the slot
388387 const bulgeIndices : number [ ] = [ ] ;
389388 for ( let i = 0 ; i < bulges . length ; i ++ ) {
390389 if ( Math . abs ( bulges [ i ] ) > 0.9 ) {
@@ -393,10 +392,11 @@ describe("OCCT io unit tests", () => {
393392 }
394393 expect ( bulgeIndices . length ) . toBe ( 2 ) ;
395394
396- // Check that they have opposite signs
395+ // Both bulges should be negative based on the actual arc traversal
397396 const bulge1 = bulges [ bulgeIndices [ 0 ] ] ;
398397 const bulge2 = bulges [ bulgeIndices [ 1 ] ] ;
399- expect ( bulge1 * bulge2 ) . toBeLessThan ( 0 ) ; // Opposite signs
398+ expect ( bulge1 ) . toBeLessThan ( - 0.9 ) ;
399+ expect ( bulge2 ) . toBeLessThan ( - 0.9 ) ;
400400
401401 slotWire . delete ( ) ;
402402 topLine . delete ( ) ;
@@ -411,7 +411,7 @@ describe("OCCT io unit tests", () => {
411411 const centerZ = 10 ;
412412
413413 // Semicircle arc from top to bottom with tangent pointing right
414- // This should create an arc that curves to the RIGHT = positive bulge
414+ // When traveling downward, curving right means positive bulge (left of travel direction)
415415 const rightArc = occHelper . edgesService . arcThroughTwoPointsAndTangent ( {
416416 start : [ centerX , 0 , centerZ + radius ] ,
417417 end : [ centerX , 0 , centerZ - radius ] ,
@@ -434,20 +434,19 @@ describe("OCCT io unit tests", () => {
434434 const polyline = dxfPaths [ 0 ] . segments [ 0 ] as any ;
435435
436436 // For a semicircular arc, the bulge should be close to ±1
437- // The actual sign depends on the direction OCCT creates the arc
438- expect ( Math . abs ( polyline . bulges [ 0 ] ) ) . toBeGreaterThan ( 0.9 ) ; // Semicircle ≈ ±1
437+ expect ( polyline . bulges [ 0 ] ) . toBeLessThan ( - 0.9 ) ; // Semicircle ≈ -1
439438
440439 arcWire . delete ( ) ;
441440 rightArc . delete ( ) ;
442441 } ) ;
443442
444- it ( "should correctly export semicircular arc curving left with negative bulge" , ( ) => {
443+ it ( "should correctly export semicircular arc curving left with positive bulge" , ( ) => {
445444 const radius = 5 ;
446445 const centerX = 20 ;
447446 const centerZ = 10 ;
448447
449448 // Semicircle arc from bottom to top with tangent pointing left
450- // This should create an arc that curves to the LEFT = negative bulge
449+ // When traveling upward, curving left means positive bulge (left of travel direction)
451450 const leftArc = occHelper . edgesService . arcThroughTwoPointsAndTangent ( {
452451 start : [ centerX , 0 , centerZ - radius ] ,
453452 end : [ centerX , 0 , centerZ + radius ] ,
@@ -470,12 +469,47 @@ describe("OCCT io unit tests", () => {
470469 const polyline = dxfPaths [ 0 ] . segments [ 0 ] as any ;
471470
472471 // For a semicircular arc, the bulge should be close to ±1
473- expect ( Math . abs ( polyline . bulges [ 0 ] ) ) . toBeGreaterThan ( 0.9 ) ; // Semicircle ≈ ± 1
472+ expect ( polyline . bulges [ 0 ] ) . toBeLessThan ( - 0.9 ) ; // Semicircle ≈ - 1
474473
475474 arcWire . delete ( ) ;
476475 leftArc . delete ( ) ;
477476 } ) ;
478477
478+ it ( "should correctly export vertical arc curving right with negative bulge" , ( ) => {
479+ const radius = 5 ;
480+ const centerX = 20 ;
481+ const centerZ = 10 ;
482+
483+ // Semicircle arc from bottom to top with tangent pointing RIGHT
484+ // When traveling upward, curving right means negative bulge (right of travel direction)
485+ const rightArc = occHelper . edgesService . arcThroughTwoPointsAndTangent ( {
486+ start : [ centerX , 0 , centerZ - radius ] ,
487+ end : [ centerX , 0 , centerZ + radius ] ,
488+ tangentVec : [ 1 , 0 , 0 ] // Tangent pointing right
489+ } ) ;
490+
491+ const arcWire = wire . combineEdgesAndWiresIntoAWire ( { shapes : [ rightArc ] } ) ;
492+
493+ const startPt = occHelper . edgesService . startPointOnEdge ( { shape : rightArc } ) ;
494+ const endPt = occHelper . edgesService . endPointOnEdge ( { shape : rightArc } ) ;
495+
496+ // Verify the arc geometry
497+ expect ( startPt [ 2 ] ) . toBeLessThan ( endPt [ 2 ] ) ; // Start is lower than end
498+
499+ const dxfPathOpt = new Inputs . OCCT . ShapeToDxfPathsDto < TopoDS_Shape > ( arcWire ) ;
500+ const dxfPaths = io . shapeToDxfPaths ( dxfPathOpt ) ;
501+
502+ expect ( dxfPaths . length ) . toBe ( 1 ) ;
503+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
504+ const polyline = dxfPaths [ 0 ] . segments [ 0 ] as any ;
505+
506+ // For a semicircular arc curving right (when traveling up), bulge should be positive
507+ expect ( polyline . bulges [ 0 ] ) . toBeGreaterThan ( 0.9 ) ; // Semicircle ≈ 1
508+
509+ arcWire . delete ( ) ;
510+ rightArc . delete ( ) ;
511+ } ) ;
512+
479513 it ( "should correctly export horizontal arc curving upward (center above chord)" , ( ) => {
480514 const startX = 10 ;
481515 const endX = 20 ;
@@ -512,8 +546,8 @@ describe("OCCT io unit tests", () => {
512546 // Verify center is actually above the chord
513547 expect ( center [ 2 ] ) . toBeGreaterThan ( chordZ ) ;
514548
515- // For a horizontal chord, center above = positive bulge
516- expect ( polyline . bulges [ 0 ] ) . toBeGreaterThan ( 0.1 ) ;
549+ // For a horizontal chord traveling right , center above = negative bulge
550+ expect ( polyline . bulges [ 0 ] ) . toBeLessThan ( - 0.1 ) ;
517551
518552 arcWire . delete ( ) ;
519553 arc . delete ( ) ;
@@ -554,8 +588,8 @@ describe("OCCT io unit tests", () => {
554588 // Verify center is actually below the chord
555589 expect ( center [ 2 ] ) . toBeLessThan ( chordZ ) ;
556590
557- // For a horizontal chord, center below = negative bulge
558- expect ( polyline . bulges [ 0 ] ) . toBeLessThan ( - 0.1 ) ;
591+ // For a horizontal chord traveling right , center below = positive bulge
592+ expect ( polyline . bulges [ 0 ] ) . toBeGreaterThan ( 0.1 ) ;
559593
560594 arcWire . delete ( ) ;
561595 arc . delete ( ) ;
0 commit comments