@@ -568,10 +568,10 @@ var MakerJs;
568568 */
569569 var pathAreEqualMap = { } ;
570570 pathAreEqualMap [ MakerJs . pathType . Line ] = function ( line1 , line2 ) {
571- return MakerJs . point . areEqual ( line1 . end , line2 . end ) ;
571+ return ( MakerJs . point . areEqual ( line1 . origin , line2 . origin ) && MakerJs . point . areEqual ( line1 . end , line2 . end ) ) || ( MakerJs . point . areEqual ( line1 . origin , line2 . end ) && MakerJs . point . areEqual ( line1 . end , line2 . origin ) ) ;
572572 } ;
573573 pathAreEqualMap [ MakerJs . pathType . Circle ] = function ( circle1 , circle2 ) {
574- return circle1 . radius == circle2 . radius ;
574+ return MakerJs . point . areEqual ( circle1 . origin , circle2 . origin ) && circle1 . radius == circle2 . radius ;
575575 } ;
576576 pathAreEqualMap [ MakerJs . pathType . Arc ] = function ( arc1 , arc2 ) {
577577 return pathAreEqualMap [ MakerJs . pathType . Circle ] ( arc1 , arc2 ) && MakerJs . angle . areEqual ( arc1 . startAngle , arc2 . startAngle ) && MakerJs . angle . areEqual ( arc1 . endAngle , arc2 . endAngle ) ;
@@ -585,7 +585,7 @@ var MakerJs;
585585 */
586586 function areEqual ( path1 , path2 ) {
587587 var result = false ;
588- if ( path1 . type == path2 . type && MakerJs . point . areEqual ( path1 . origin , path2 . origin ) ) {
588+ if ( path1 . type == path2 . type ) {
589589 var fn = pathAreEqualMap [ path1 . type ] ;
590590 if ( fn ) {
591591 result = fn ( path1 , path2 ) ;
@@ -1139,7 +1139,7 @@ var MakerJs;
11391139 function breakAlongForeignPath ( segments , overlappedSegments , foreignPath ) {
11401140 if ( MakerJs . path . areEqual ( segments [ 0 ] . path , foreignPath ) ) {
11411141 segments [ 0 ] . overlapped = true ;
1142- segments [ 0 ] . overlappedEqual = true ;
1142+ segments [ 0 ] . duplicate = true ;
11431143 overlappedSegments . push ( segments [ 0 ] ) ;
11441144 return ;
11451145 }
@@ -1283,7 +1283,7 @@ var MakerJs;
12831283 function checkForEqualOverlaps ( crossedPathsA , crossedPathsB ) {
12841284 function compareSegments ( segment1 , segment2 ) {
12851285 if ( MakerJs . path . areEqual ( segment1 . path , segment2 . path ) ) {
1286- segment1 . overlappedEqual = segment2 . overlappedEqual = true ;
1286+ segment1 . duplicate = segment2 . duplicate = true ;
12871287 }
12881288 }
12891289 function compareAll ( segment ) {
@@ -1298,7 +1298,7 @@ var MakerJs;
12981298 /**
12991299 * @private
13001300 */
1301- function addOrDeleteSegments ( crossedPath , includeInside , includeOutside , firstPass ) {
1301+ function addOrDeleteSegments ( crossedPath , includeInside , includeOutside , keepDuplicates ) {
13021302 function addSegment ( model , pathIdBase , segment ) {
13031303 var id = model_1 . getSimilarPathId ( model , pathIdBase ) ;
13041304 model . paths [ id ] = segment . path ;
@@ -1311,8 +1311,8 @@ var MakerJs;
13111311 //delete the original, its segments will be added
13121312 delete crossedPath . modelContext . paths [ crossedPath . pathId ] ;
13131313 for ( var i = 0 ; i < crossedPath . segments . length ; i ++ ) {
1314- if ( crossedPath . segments [ i ] . overlappedEqual ) {
1315- if ( firstPass ) {
1314+ if ( crossedPath . segments [ i ] . duplicate ) {
1315+ if ( keepDuplicates ) {
13161316 addSegment ( crossedPath . modelContext , crossedPath . pathId , crossedPath . segments [ i ] ) ;
13171317 }
13181318 }
@@ -1330,14 +1330,16 @@ var MakerJs;
13301330 * @param includeAOutsideB Flag to include paths from modelA which are outside of modelB.
13311331 * @param includeBInsideA Flag to include paths from modelB which are inside of modelA.
13321332 * @param includeBOutsideA Flag to include paths from modelB which are outside of modelA.
1333+ * @param keepDuplicates Flag to include paths which are duplicate in both models.
13331334 * @param farPoint Optional point of reference which is outside the bounds of both models.
13341335 */
1335- function combine ( modelA , modelB , includeAInsideB , includeAOutsideB , includeBInsideA , includeBOutsideA , farPoint ) {
1336+ function combine ( modelA , modelB , includeAInsideB , includeAOutsideB , includeBInsideA , includeBOutsideA , keepDuplicates , farPoint ) {
1337+ if ( keepDuplicates === void 0 ) { keepDuplicates = true ; }
13361338 var pathsA = breakAllPathsAtIntersections ( modelA , modelB , farPoint ) ;
13371339 var pathsB = breakAllPathsAtIntersections ( modelB , modelA , farPoint ) ;
13381340 checkForEqualOverlaps ( pathsA . overlappedSegments , pathsB . overlappedSegments ) ;
13391341 for ( var i = 0 ; i < pathsA . crossedPaths . length ; i ++ ) {
1340- addOrDeleteSegments ( pathsA . crossedPaths [ i ] , includeAInsideB , includeAOutsideB , true ) ;
1342+ addOrDeleteSegments ( pathsA . crossedPaths [ i ] , includeAInsideB , includeAOutsideB , keepDuplicates ) ;
13411343 }
13421344 for ( var i = 0 ; i < pathsB . crossedPaths . length ; i ++ ) {
13431345 addOrDeleteSegments ( pathsB . crossedPaths [ i ] , includeBInsideA , includeBOutsideA ) ;
@@ -3383,6 +3385,35 @@ var MakerJs;
33833385 } ) ( models = MakerJs . models || ( MakerJs . models = { } ) ) ;
33843386} ) ( MakerJs || ( MakerJs = { } ) ) ;
33853387var MakerJs ;
3388+ ( function ( MakerJs ) {
3389+ var models ;
3390+ ( function ( models ) {
3391+ var Dome = ( function ( ) {
3392+ function Dome ( width , height , radius ) {
3393+ if ( radius === void 0 ) { radius = Math . min ( width / 2 , height ) ; }
3394+ this . paths = { } ;
3395+ var w2 = width / 2 ;
3396+ var wt = Math . max ( w2 - radius , 0 ) ;
3397+ var hr = Math . max ( height - radius , 0 ) ;
3398+ this . paths [ "Bottom" ] = new MakerJs . paths . Line ( [ - w2 , 0 ] , [ w2 , 0 ] ) ;
3399+ if ( hr ) {
3400+ this . paths [ "Left" ] = new MakerJs . paths . Line ( [ - w2 , 0 ] , [ - w2 , hr ] ) ;
3401+ this . paths [ "Right" ] = new MakerJs . paths . Line ( [ w2 , 0 ] , [ w2 , hr ] ) ;
3402+ }
3403+ if ( radius > 0 ) {
3404+ this . paths [ "TopLeft" ] = new MakerJs . paths . Arc ( [ - wt , hr ] , radius , 90 , 180 ) ;
3405+ this . paths [ "TopRight" ] = new MakerJs . paths . Arc ( [ wt , hr ] , radius , 0 , 90 ) ;
3406+ }
3407+ if ( wt ) {
3408+ this . paths [ "Top" ] = new MakerJs . paths . Line ( [ - wt , height ] , [ wt , height ] ) ;
3409+ }
3410+ }
3411+ return Dome ;
3412+ } ) ( ) ;
3413+ models . Dome = Dome ;
3414+ } ) ( models = MakerJs . models || ( MakerJs . models = { } ) ) ;
3415+ } ) ( MakerJs || ( MakerJs = { } ) ) ;
3416+ var MakerJs ;
33863417( function ( MakerJs ) {
33873418 var models ;
33883419 ( function ( models ) {
0 commit comments