@@ -7,6 +7,7 @@ import { IBox } from '../_interface/box';
7
7
import { ICylinder } from '../_interface/cylinder' ;
8
8
import { ISphere } from '../_interface/sphere' ;
9
9
import { ICone } from '../_interface/cone' ;
10
+ import { ITorus } from '../_interface/torus' ;
10
11
import { ICut } from '../_interface/cut' ;
11
12
12
13
const SHAPE_CACHE = new Map < string , TopoDS_Shape > ( ) ;
@@ -103,6 +104,20 @@ function _Cone(arg: ICone, _: IJCadContent): TopoDS_Shape | undefined {
103
104
return setShapePlacement ( shape , Placement ) ;
104
105
}
105
106
107
+ function _Torus ( arg : ITorus , _ : IJCadContent ) : TopoDS_Shape | undefined {
108
+ const { Radius1, Radius2, Angle1, Angle2, Angle3, Placement } = arg ;
109
+ const oc = getOcc ( ) ;
110
+ const torus = new oc . BRepPrimAPI_MakeTorus_4 (
111
+ Radius1 ,
112
+ Radius2 ,
113
+ toRad ( Angle1 ) ,
114
+ toRad ( Angle2 ) ,
115
+ toRad ( Angle3 )
116
+ ) ;
117
+ const shape = torus . Shape ( ) ;
118
+ return setShapePlacement ( shape , Placement ) ;
119
+ }
120
+
106
121
function _Cut ( arg : ICut , content : IJCadContent ) : TopoDS_Shape | undefined {
107
122
const { Placement, Base, Tool } = arg ;
108
123
const oc = getOcc ( ) ;
@@ -140,6 +155,7 @@ const Box = operatorCache<IBox>('Box', _Box);
140
155
const Cylinder = operatorCache < ICylinder > ( 'Cylinder' , _Cylinder ) ;
141
156
const Sphere = operatorCache < ISphere > ( 'Sphere' , _Sphere ) ;
142
157
const Cone = operatorCache < ICone > ( 'Cone' , _Cone ) ;
158
+ const Torus = operatorCache < ITorus > ( 'Torus' , _Torus ) ;
143
159
// const Cut = operatorCache<ICut>('Cut', _Cut);
144
160
145
161
export const ShapesFactory : {
@@ -149,5 +165,6 @@ export const ShapesFactory: {
149
165
'Part::Cylinder' : Cylinder ,
150
166
'Part::Sphere' : Sphere ,
151
167
'Part::Cone' : Cone ,
168
+ 'Part::Torus' : Torus ,
152
169
'Part::Cut' : _Cut
153
170
} ;
0 commit comments