new OCC()
Contains lower-level methods than PD.CADfor generating and operating
on primitive shapes within OpenCascade.
This class is also exposed as just OCC within the built-in code editor
panel of each framework application that uses it.
The methods in this class do the actual low-level work of interfacing with
the OpenCascade module and the raw geometry it creates. They provide the engine
that sits behind the higher-level methods in PD.CAD, many of which
are simply wrappers that marshal arguments and cache calls to the corresponding
methods in this class, and manage the final CAD model.
You can use the lower-level methods in this class directly to create interim
geometry, but it will not be cached and will not become part of the final model
until you specifically use the PD.CAD.add method to add them. You can
also use the PD.CAD.remove method to remove shapes from the CAD model.
Unlike shape generation methods within PD.CAD, the methods in this
class take a single configuration object as their primary argument and return
a shape, which may be a transformed copy of a source shape or a compound assembly
of multiple shapes. The properties of the configuration object provide the inputs
and data required for each method. This allows these methods to be used directly
with parsed JSON data, where the "type" property of each encapsulated JSON
object is basically the method name. This greatly simplifies both the creation
and parsing of JSON representations of complex constructive geometry.
Methods
-
chamfer( [config]) <static>
-
Applies a flat 45deg chamfer to one or more edges in a shape.
For simple chamfers all at the same size, the
config.edgesarray should contain a flat list of edge indices and thedistancevalue should give the size size of the chamfer to use on those edges.If you want to chamfer different edges with different distances, calling this method more than once is a very inefficient way of doing it and makes keeping track of the edges to chamfer almost impossible. Instead, you can include multiple arrays within the
config.edgesproperty, ensuring that each array starts with the required chamfer distance and is followed by one or more edge indices to chamfer at that distance, as shown in the third example below.If you want to chamfer different edges with different sizes, calling this method more than once is a very inefficient way of doing it and makes keeping track of the edges indexes after each iteration almost impossible. Instead, you can include the
config.distanceproperty as an array of size/edges arrays, ensuring that each array starts with the required size and is followed by one or more edge indices to chamfer at that size, as shown in the third example below.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
The shape to chamfer edges within.
distancenumber | Array.<Array.<number>> <optional>
The distance of the chamfer, defaults to 0.
edgesArray.<number> <optional>
An array of edge indices to chamfer, defaults to all edges.
Returns:
Returns the chamfered solid, or the given shape if no matching edges were found.
- Type
- oc.TopoDS_Solid
Example
/// Chamfer all edges. const chamfer1 = PD.OCC.chamfer({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), distance: 200 }); /// Chamfer 4 vertical edges. const chamfer2 = PD.OCC.chamfer({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), edges: [ 0, 2, 4, 6 ], distance: 200 }); /// Chamfer with different sizes. const chamfer3 = PD.OCC.chamfer({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), distance: [ [ 200, 0, 2, 4, 6 ], [ 100, 1, 5, 9, 11 ] ] }); -
checkToConvertFromJSON(shapes [, ignoreSolids]) <static>
-
Checks for JSON data and converts to OpenCascade shapes.
Parameters:
Name Type Argument Description shapesArray.<object> | Array.<oc.TopoDS_Shape> A JSON or shape array.
ignoreSolidsboolean <optional>
When true, solids will not be converted, defaults to false.
Returns:
Returns TopoDS_Shape(s).
- Type
- oc.TopoDS_Shape | Array.<oc.TopoDS_Shape>
-
combine( [config]) <static>
-
Combines the given shape(s) into a single compound shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesArray.<oc.TopoDS_Shape> <optional>
An array of two or more shapes to combine.
Returns:
Returns the compound shape.
- Type
- oc.TopoDS_Shape
-
compoundShell( [config]) <static>
-
Construct a compound shell shape from a series of vertices and faces.
A compound shell is basically just a collection of faces without any connection information such as shared vertices or edges. Use this if you just want to visualise a shape as it is quick to assemble and does not require any processing. Obviously you will not be able to convert it to a solid for use in CSG.
There are several variants of point/face meshes, and this is one of the simplest. It consists of a flat list of point in its
verticesproperty, together with a list of arrays in itsfacesproperty, each storing the ordinal indices of each vertex in thepointslist that forms the outer boundary of a face. Each face only has a single boundary so cannot contain holes or separate contours. As a result, it is mainly used to efficiently store polyhedra and simple manifold shapes.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description verticesArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the corners and edges of the shape.
facesArray.<Array.<number>> | Array.<object> <optional>
An array of faces with boundaries containing ordinal indexes of the points that make up the face.
Returns:
Returns a shape sewn together from multiple faces.
- Type
- oc.TopoDS_Shape
-
cone( [config]) <static>
-
Construct a conical primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the shape center, defaults to the origin.
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
radiusBotnumber <optional>
The base radius of the shape, defaults to 1000mm (1m).
radiusTopnumber <optional>
The top radius of the shape, defaults to 0 (a point).
heightnumber <optional>
The height of the shape, defaults to 1000mm (1m).
filletnumber <optional>
An optional fillet radius for the base, defaults to 0 (no fillet).
anglenumber <optional>
An optional angle in radians (0 to 2PI), defaults to 2PI.
Returns:
Returns a conical shape.
- Type
- oc.TopoDS_Shape
-
cuboid( [config]) <static>
-
Construct a rectangular prism primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
An optional configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the start position of the shape.
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
sizeArray.<number> <optional>
An [x,y,z] vector array defining the size of the shape in each axis, defaults to [1000,1000,1000].
minArray.<number> <optional>
An [x,y,z] vector array defining the bottom-left corner.
maxArray.<number> <optional>
An [x,y,z] vector array defining the top-right corner.
centeredboolean <optional>
An optional flag indicating that the shape should be centered on its pos/min position rather than at its bottom-left, defaults to false.
centerXYboolean <optional>
An optional flag indicating that the shape should be centered on its X and Y pos/min position rather than at its bottom-left, defaults to false.
filletnumber | Array.<number> <optional>
An optional radius or [bot,sides,top] array for filleting edges and corners, defaults to 0 (no fillet).
Returns:
Returns a rectangular prism shape.
- Type
- oc.TopoDS_Shape
Example
/// Define just the size. PD.CAD.add(PD.OCC.cuboid({ size: [ 1500, 2000, 3000 ] })); /// Define by min/max. PD.CAD.add(PD.OCC.cuboid({ min: [ -750, -1000, 0 ], max: [ 750, 1000, 3000 ] })); /// Define fillet radii, etc. PD.CAD.add(PD.OCC.cuboid({ size: [ 1500, 2000, 3000 ], axis: [ 0.5773503, 0.5773503, 0.5773503 ], fillet: [ 50, 500, 50 ], centerXY: true })); -
cylinder( [config]) <static>
-
Construct a cylindrical primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the shape center, defaults to the origin.
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
heightnumber <optional>
The height of the shape, defaults to 1000mm (1m).
radiusnumber <optional>
The base radius of the shape, defaults to 1000mm (1m).
filletnumber | Array.<number> <optional>
An optional radius or [bot,top] array for filleting edges and corners, defaults to 0 (no fillet).
chamfernumber | Array.<number> <optional>
An optional radius or [bot,top] array for chamfering edges and corners, defaults to 0 (no chamfer).
anglenumber <optional>
An optional angle in radians (0 to 2PI), defaults to 2PI.
Returns:
Returns a cylindrical shape.
- Type
- oc.TopoDS_Shape
-
edge( [config]) <static>
-
Construct a straight linear edge between two points.
Edges are lines typically used to represent the connection or intersection between two faces. They may be straight lines or complex curves, and can be connected together to form wires.
If the
config.pointsarray contains more than two points, only the first two will actually be used in the edge.Parameters:
Name Type Argument Description configPD.OCC.ITwoPoints <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of two [x,y,z] vector arrays defining the vertices at each end.
Returns:
Returns a linear edge.
- Type
- oc.TopoDS_Edge
-
edgeArc( [config]) <static>
-
Construct an edge as a circular arc defined by three points.
Edges are lines typically used to represent the connection or intersection between two faces. They may be straight lines or complex curves, and can be connected together to form wires.
Parameters:
Name Type Argument Description configPD.OCC.IArcPath <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of three [x,y,z] vector arrays defining the start, ptOnArc and end points.
Returns:
Returns a edge arc.
- Type
- oc.TopoDS_Edge
-
edgeBSpline( [config]) <static>
-
Construct a BSpline curved edge from control points.
Edges are lines typically used to represent the connection or intersection between two faces. They may be straight lines or complex curves, and can be connected together to form wires.
Parameters:
Name Type Argument Description configPD.OCC.ICurvePoints <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the control points of the bspline.
closedboolean <optional>
Whether or not the edge forms a closed loop.
Returns:
Returns a curved edge.
- Type
- oc.TopoDS_Edge
-
edgeBezier( [config]) <static>
-
Construct a Bezier curved edge from control points.
Edges are lines typically used to represent the connection or intersection between two faces. They may be straight lines or complex curves, and can be connected together to form wires.
Parameters:
Name Type Argument Description configPD.OCC.ICurvePoints <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the control points of the bezier curve.
closedboolean <optional>
Whether or not the edge forms a closed loop.
Returns:
Returns a curved edge.
- Type
- oc.TopoDS_Edge
-
edgeCircle( [config]) <static>
-
Construct a closed circular edge.
Edges are lines typically used to represent the connection or intersection between two faces. They may be straight lines or complex curves, and can be connected together to form wires.
Parameters:
Name Type Argument Description configPD.OCC.ICentreRadius <optional>
A configuration object.
Properties of
config:Name Type Argument Description centerArray.<number> <optional>
An [x,y,z] vector array defining the center of the circle.
radiusnumber <optional>
The radius of the circle, defaults to 1000mm (1m).
Returns:
Returns a circular edge.
- Type
- oc.TopoDS_Edge
-
extrude( [config]) <static>
-
Extrudes a flat polygonal face into a shape.
To extrude the shape, you can provide either an extrusion vector with absolute distances for each axis in the
config.vectorproperty, or a direction and height in theconfig.axisandconfig.heightproperties. The extrusion vector will be used in preference to and axis and distance, so you should include only one of the options rather than both.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description faceoc.TopoDS_Face <optional>
An optional closed face to extrude.
axisArray.<number> | number <optional>
An [x,y,z] vector array defining the direction to extrude in, or a number (X:1, Y:2, Z:3), defaults to the +Z axis.
heightnumber <optional>
The distance to extrude in the local Z axis, defaults to 1000mm (1m).
vectorArray.<number> <optional>
An [x,y,z] vector array defining the absolute distances to extrude in each axis.
Returns:
Returns the extruded shape.
- Type
- oc.TopoDS_Shape
-
extrudeAndRotate( [config]) <static>
-
Extrude and rotate a wire into a 3D shape.
When using this method, you should include either a
degreesvalue or ananglevalue. If you include both, thedegreeswill be used in preference to theanglevalue.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description wireoc.TopoDS_Wire <optional>
A wire to rotate and extrude.
axisArray.<number> | number <optional>
An [x,y,z] vector array defining the direction of the shape axis, or a number (X:1, Y:2, Z:3), defaults to the +Z axis.
heightnumber <optional>
The height of the extrusion, defaults to 1000mm (1m).
degreesnumber <optional>
The angle of rotation in degrees, defaults to 0.
anglenumber <optional>
The angle of rotation in radians, defaults to 0.
stepsnumber <optional>
The number of steps in the twisted rotation, defaults to 20.
Returns:
Returns the rotated twisted shape(s).
- Type
- oc.TopoDS_Shape
-
face( [config]) <static>
-
Construct a face from points or wires.
Faces are used to represent the surfaces of a shape. They are formed by connecting one or more wires together to form a boundary on a surface that may be curved or flat.
To create a face, you must pass either an array of wires in the
config.wiresproperty, or an array of [x,y,z] vector array coordinates in theconfig.pointsproperty. The list of wires will be used in preference to points, so you should only include one or the other rather than both.Using
config.pointscreates a simple face with a single outer boundary. For more complex faces with holes and/or multiple boundaries, you can use thePD.CAD.Shape#polygonmethod withconfig.contoursor build the boundaries using aPD.CAD.Pathinstance.Using
config.wires, you can add internal holes to the face by including closed wires that are entirely within the outer boundary wire. You can also add additional boundaries (like multiple islands) by including closed wires entirely outside any other boundary wire(s).Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the face boundary.
wiresArray.<oc.TopoDS_Wire> <optional>
An array of wires to connect together to form the face boundary.
Returns:
Returns a new face.
- Type
- oc.TopoDS_Face
-
facetedShell( [config]) <static>
-
Construct a shell shape sewn together from a series of facets.
This method only deals with faceted data, which means that each face is defined by or contains an array of [x,y,z] vector arrays giving the positions of each corner of its boundaries.
Each entry in the
facetsarray is an object that has an optionalplaneproperty with the [a,b,c,d] plane equation of the face and a non-optionalboundariesproperty containing one or more contours of [x,y,z] vertex positions. If there are multiple contours, the first will be considered the outer boundary and any subsequent contours will be treated as holes within the face.To be valid, each boundary and hole array must contain at least three (3) or more planar vertex indices defining each of its corners.
If you have data in which vertices are given in a separate array and where each face is an ordinal index, you can use the
OCC.indexedShellmethod instead of this one.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description facetsArray.<object> <optional>
An array of facets with boundary contours defined by sequential [x,y,z] vector arrays.
Returns:
Returns a shape sewn together from multiple faces.
- Type
- oc.TopoDS_Shape
-
fillet( [config]) <static>
-
Applies a rounded fillet to one or more edges in a shape.
For simple fillets with the same radius, the
config.edgesarray should contain a flat list of edge indices and theradiusvalue should give the radius to use on those edges.If you want to fillet different edges with different radii, calling this method more than once is a very inefficient way of doing it and makes keeping track of the edges indexes after each iteration almost impossible. Instead, you can include the
config.radiusproperty as an array of radius/edges arrays, ensuring that each array starts with the required radius and is followed by one or more edge indices to fillet at that radius, as shown in the third example below.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
The shape to fillet edges within.
radiusnumber | Array.<Array.<number>> <optional>
The radius of the fillet, defaults to 0.
edgesArray.<number> <optional>
An array of edge indices to fillet, defaults to all edges.
Returns:
Returns the filleted solid, or the given shape if no matching edges were found.
- Type
- oc.TopoDS_Shape
Example
/// Fillet all edges. const fillet1 = PD.OCC.fillet({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), radius: 200 }); /// Fillet 4 vertical edges. const fillet2 = PD.OCC.fillet({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), edges: [ 0, 2, 4, 6 ], radius: 200 }); /// Fillet with different radii. const fillet3 = PD.OCC.fillet({ shape: PD.OCC.cuboid({ size: [ 2000, 2000, 1000 ] }), radius: [ [ 200, 0, 2, 4, 6 ], [ 100, 1, 5, 9, 11 ] ] }); -
getEdge(shape [, index]) <static>
-
Extracts a particular edge from within a shape.
Parameters:
Name Type Argument Description shapeoc.TopoDS_Shape The shape to extract the edge from.
indexnumber <optional>
The ordinal index of the edge within the shape, defaults to 0.
Returns:
Returns the edge at the given index, or the given shape if no matching edge was found.
- Type
- oc.TopoDS_Edge | oc.TopoDS_Shape
-
getEdgeCount(shape) <static>
-
Retrieve the number of edges within a shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to examine.
Returns:
Returns the number of edges found.
- Type
- number
-
getFace(shape [, index]) <static>
-
Extracts a particular face from within a shape.
Parameters:
Name Type Argument Description shapeoc.TopoDS_Shape The shape to extract the face from.
indexnumber <optional>
The ordinal index of the face within the shape, defaults to 0.
Returns:
Returns the solid at the given index, or the given shape if no matching solid was found.
- Type
- oc.TopoDS_Face | oc.TopoDS_Shape
-
getFaceCount(shape) <static>
-
Retrieve the number of faces within a shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to examine.
Returns:
Returns the number of faces found.
- Type
- number
-
getFaceTriangulation(shape, maxDeviation) <static>
-
Compute the triangular tesselation from a shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to convert.
maxDeviationnumber The tolerance for linear and angle deflection, defaults to 1.0.
Returns:
Returns the faces and edges that make up the shape.
- Type
- Array.<Array>
-
getOpenCascadeInstance() <static>
-
Retrieve the current OpenCascade WebAssembly instance being used.
Returns:
Returns the current OpenCascade instance.
- Type
- object
-
getSolid(shape [, index]) <static>
-
Extracts a particular solid from within a compound shape.
Parameters:
Name Type Argument Description shapeoc.TopoDS_Shape The shape to extract the solid from.
indexnumber <optional>
The ordinal index of the solid within the shape, defaults to 0.
Returns:
Returns the solid at the given index, or the given shape if no matching solid was found.
- Type
- oc.TopoDS_Shape | oc.TopoDS_Solid
-
getSolidCount(shape) <static>
-
Retrieve the number of solids within a compound shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to examine.
Returns:
Returns the number of solid found.
- Type
- number
-
getVertex(shape [, index]) <static>
-
Extracts a particular vertex from within a shape.
Parameters:
Name Type Argument Description shapeoc.TopoDS_Shape The shape to extract the vertices from.
indexnumber <optional>
The ordinal index of the vertex within the shape, defaults to 0.
Returns:
Returns the vertex at the given index, or the given shape if no matching vertex was found.
- Type
- oc.TopoDS_Vertex | null
-
getVertexCount(shape) <static>
-
Retrieve the number of edges within a shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to examine.
Returns:
Returns the number of edges found.
- Type
- number
-
getVertexPos(vertex) <static>
-
Extracts the vertex position as an [x,y,z] vector array.
Parameters:
Name Type Description vertexoc.TopoDS_Vertex The vertex to get the coordinates from.
Returns:
Returns the coordinates as an [x,y,z] vector array.
- Type
- Array.<number>
-
getWire(shape [, index]) <static>
-
Extracts a particular wire from within a shape.
Parameters:
Name Type Argument Description shapeoc.TopoDS_Shape The shape to extract the wire from.
indexnumber <optional>
The ordinal index of the wire within the shape, defaults to 0.
Returns:
Returns the wire at the given index, or the given shape if no matching wire was found.
- Type
- oc.TopoDS_Wire | oc.TopoDS_Shape
-
getWireCount(shape) <static>
-
Retrieve the number of wires within a shape.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to examine.
Returns:
Returns the number of wires found.
- Type
- number
-
hollow( [config]) <static>
-
Creates a hollowed out solid from a closed shell.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
The shape to hollow out.
facesArray.<oc.TopoDS_Face> <optional>
An array or one or more faces to hollow from.
thicknessnumber <optional>
The side wall thickness, defaults to 250mm (0.25m).
tolerancenumber <optional>
The tolerance to use when hollowing, defaults to 0.1.
Returns:
Returns the hollowed out shape.
- Type
- oc.TopoDS_Shape
-
hull( [config]) <static>
-
Construct a convex hull solid shape from a set of points or shapes.
This method will preference points over shapes when creating the hull, so you should provide only one or the other rather than both. To support some JSON variants, this method allows the use of
config.verticesas an alias forconfig.points.When using shapes, the method has to extract vertices and sample points over each curved face in the shape, so you should provide a
config.maxDeviationargument to control the granularity of this surface sampling.The
config.tolerancevalue applies to both and affects the sewing together of faces when generating the solid shell.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the vertices the shape.
shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to create the hull from.
tolerancenumber <optional>
The sewing tolerance when converting hull to a shape, defaults to 0.1.
Returns:
Returns a solid shape sewn from multiple faces.
- Type
- oc.TopoDS_Shape
-
hullChain( [config]) <static>
-
Construct a chain of convex hulls from a set of shapes.
The method has to extract vertices and sample points over each curved face in each shape, so you should provide a
config.maxDeviationargument to control the granularity of this surface sampling.The
config.tolerancevalue affects the sewing together of faces when generating the solid shell(s).Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to create the hull chain from.
maxDeviationnumber <optional>
The mesh resolution when point sampling shape surfaces, defaults to 5.
tolerancenumber <optional>
The sewing tolerance when converting hull to a shape, defaults to 0.1.
Returns:
Returns a solid shape sewn from multiple hulls.
- Type
- oc.TopoDS_Shape
-
indexedShell( [config]) <static>
-
Construct a shell shape sewn together from a series of indexed facets.
This method sews together a collection of indexed planar faces into a
TopoDS_Shape. It does this by making planarTopoDS_Wireobjects out of each facet boundary, then makingTopoDS_Faceobjects out of each wire, and then sewing the faces together into aTopoDS_Shell.This method only deals with indexed face data, which means that all the vertices in the shape are stored in one array (points) and all the faces in another (faces). The vertices must all be [x,y,z] vector arrays and each face is defined by or contains an array of ordinal indexes of each vertex that make up its boundaries.
Thus, each entry in the
facesarray may be either an array of vertex indices or an object containing aboundariesproperty that is array. If theboundariesarray contain one or more sub-arrays of vertex indices, then the first will be considered as the outer boundary and any subsequent boundaries treated as holes within the face. If the boundary is a flat array of vertex indices, it will be considered as an outer boundary with no holes.To be valid, each boundary and hole array must contain at least three (3) or more planar vertex indices defining each of its corners.
If you have data in which vertices are not given separately, but where each face is a list of [x,y,z] vector arrays, use the
OCC.facetedShellmethod instead of this one.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the corners and edges of the shape.
facesArray.<Array.<number>> | Array.<object> <optional>
An array of faces with boundaries containing ordinal indexes of the points that make up the face.
tolerancenumber <optional>
An optional face sewing tolerance, defaults to 1mm.
Returns:
Returns a shell shape sewn together from multiple faces.
- Type
- oc.TopoDS_Shape
-
intersect( [config]) <static>
-
Computes the intersection of a set of shapes.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesArray.<oc.TopoDS_Shape> <optional>
An array of shapes to intersect.
tolerancenumber <optional>
The tolerance to use when intersecting, defaults to 0.1.
keepEdgesboolean <optional>
Whether or not to keep the original edge(s) in the shape, defaults to false.
Returns:
Returns the intersection shape.
- Type
- oc.TopoDS_Shape
-
isFacePlanar(face [, tolerance]) <static>
-
Determines if the face is planar or not.
Parameters:
Name Type Argument Description faceoc.TopoDS_Face The face to check if planar.
tolerancenumber <optional>
The tolerance to use when checking, defaults to 0.1.
Returns:
Returns true if the face is planar, false if it is curved.
- Type
- boolean
-
isValidCompositeSolid(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_COMPSOLID.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidCompound(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_COMPOUND.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidEdge(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_EDGE.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidFace(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_FACE.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidShell(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_SHELL.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidSolid(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_SOLID.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidType(shape, type) <static>
-
Checks if a shape is a non-null instance of the given type.
This method first checks the shape is not null and then calls its
oc.TopoDS_Shape#ShapeTypemethod to see if it matches the given type.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check.
typeoc.TopAbs_ShapeEnum The shape type to check for.
Returns:
Returns true if the shape is of the given type, otherwise false.
- Type
- boolean
-
isValidVertex(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_VERTEX.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
isValidWire(shape) <static>
-
Checks if a shape is a non-null instance of
TopAbs_WIRE.Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to check the type of.
Returns:
Returns true if the shape is of the right type, otherwise false.
- Type
- boolean
-
iterateEdges(shape, callback) <static>
-
Invokes a callback function on all the edges in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
iterateFaces(shape, callback) <static>
-
Invokes a callback function on all the faces in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
iterateShells(shape, callback) <static>
-
Invokes a callback function on all the shells in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
iterateSolids(shape, callback) <static>
-
Invokes a callback function on all the solids in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
iterateVertices(shape, callback) <static>
-
Invokes a callback function on all the vertices in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
iterateWires(shape, callback) <static>
-
Invokes a callback function on all the wires in a shape.
The callback function will be invoked with two arguments, the first being the item found and the second being its ordinal index.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to iterate.
callbackfunction The callback function to invoke.
Returns:
Returns the number of items found.
- Type
- number
-
loft( [config]) <static>
-
Lofts between a set of two or more wires.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description wiresArray.<oc.TopoDS_Wire> <optional>
The set of two or more wires to loft between.
Returns:
Returns the lofted shape.
- Type
- oc.TopoDS_Shape
-
makeFacesFromWires(wires [, allowNonPlanar]) <static>
-
Generates one or more faces from a set of properly oriented wires.
If the face is non-planar and
allowNonPlanaris true, the face will be converted into a fan of triangular faces about its center.Parameters:
Name Type Argument Description wiresArray.<oc.TopoDS_Wire> An array of one or more wires defining face contours.
allowNonPlanarboolean <optional>
A flag to enable/disable converting non-planar faces to multiple triangular faces, defaults to true.
Returns:
Returns an array of one or mor faces made from the wires.
- Type
- Array.<oc.TopoDS_Face>
-
makeTriangleFanFaces(wire) <static>
-
Generates one or more triangular faces from the geometric center and edges in a wire.
Parameters:
Name Type Description wireoc.TopoDS_Wire A wire containing one or more edges.
Returns:
Returns one or more faces made from edges in the wire.
- Type
- Array.<oc.TopoDS_Face>
-
makeWiresFromContours(contours [, vertices]) <static>
-
Construct an array of wires from one or more boundary contours that store actual vertex positions.
If the face boundary array contains one or more arrays of [x,y,z] vertices then the first will be considered the outer boundary and any subsequent boundaries will be treated as holes within the face. If the face boundary is a flat array of [ x,y,z] vertices, it will be considered as an outer boundary with no holes.
To be valid, each boundary and hole array must containing at least three (3) or more planar [x,y,z] vertices defining each of its corners.
Parameters:
Name Type Argument Description contoursArray.<Array.<Array.<number>>> An array of boundary contours, each containing 3 or more [x,y,z] vector arrays defining the face outlines.
verticesArray.<Array.<number>> <optional>
An optional array of [x,y,z] vector arrays to use if contours use vertex indices not actual vertexes.
Returns:
Returns a face created from multiple wires.
- Type
- Array.<oc.TopoDS_Wire>
-
mirror( [config]) <static>
-
Mirrors the given shape(s) around a given axis.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to rotate.
axisArray.<number> | number <optional>
An [x,y,z] vector array defining the direction of the shape axis, or a number (X:1, Y:2, Z:3), defaults to XZ axis.
aboutArray.<number> <optional>
An [x,y,z] vector array defining the position of the axis, defaults to the origin.
Returns:
Returns the mirrored shape(s).
- Type
- oc.TopoDS_Shape
-
move( [config]) <static>
-
Translates the given shape(s) by a relative vector.
This method is simply an alias for the
OCC.translatemethod.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to translate.
offsetArray.<number> <optional>
An [x,y,z] vector array defining the translation offset in each axis.
Returns:
Returns the translated shape(s).
- Type
- oc.TopoDS_Shape
-
offset( [config]) <static>
-
Offsets the edges and faces of a shape by the given distance.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
The shape to offset, which can also be a wire.
distancenumber <optional>
The distance to offset the shape by, defaults to 250mm (0.25m).
tolerancenumber <optional>
The tolerance to use when offsetting, defaults to 0.1.
Returns:
Returns the offset shape.
- Type
- oc.TopoDS_Shape
-
path2D( [config]) <static>
-
Construct a wire as a series of 2D path segments.
This method basically wraps a
PD.CAD.Pathinstance and takes an array ofsegmentsthat encapsulate the various generation methods it offers. Each segment requires atypeproperty that corresponds to a method name in the path instance, as well as other properties that correspond to the arguments that method takes, as shown in the code example below.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description segmentsArray.<Array.<number>> <optional>
An array of segment definitions, as shown in the code example.
closedboolean <optional>
Whether or not the path forms a closed loop, defaults to false.
reverseboolean <optional>
Whether or not to reverse the path direction.
Returns:
Returns a flat closed polygonal face shape.
- Type
- oc.TopoDS_Wire
Example
const wire = PD.CAD.Shape.path2D({ closed: false, reverse: false, segments: [ { type: "moveTo", point: [ 0, -1000 ] }, { type: "lineTo", point: [ 0, 0 ] }, { type: "fillet", radius: 500 }, { type: "lineTo", point: [ 1000, 0 ] }, { type: "arcTo", through: [ 1500, 500 ] point: [ 1000, 1000 ], }, { type: "bezierTo", points: [ [ 0, 1000 ], [ 0, 2000 ] ] }, { type: "bsplineTo", points: [ [ 0, 3000 ], [ -500, 3500 ], [ -1000, 3000 ], [ -1500, 3500 ], [ -2000, 3000 ] ] }, ], }); -
polygon( [config]) <static>
-
Construct a flat closed polygonal face from one or more boundary contours.
To create a polygonal face, you must pass either an array of contours in the
config.contoursproperty, or an array of [x,y,z] vector array coordinates in theconfig.pointsproperty. The list of contours will be used in preference to points, so you should only include one or the other rather than both.Using
config.pointscreates a simple polygon with a single outer boundary. For more complex faces with holes and/or multiple boundaries, use theconfig.contoursproperty or build the boundaries using aPD.CAD.Pathinstance.Using
config.contours, you can add internal holes to the face by including closed boundaries that are entirely within the first contour, which ia always assumed to define the outer boundary of the polygon.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description contoursArray.<Array.<Array.<number>>> <optional>
An array of boundary contours, each containing 3 or more [x,y,z] vector arrays defining the polygon outlines.
pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the polygon boundary.
Returns:
Returns a flat closed polygonal face.
- Type
- oc.TopoDS_Face
-
prism( [config]) <static>
-
Construct an extruded prism shape from a face or connected points.
You can define the base of the prism by either:
- providing a single face to extrude in the
config.faceproperty, - providing an array of [x,y,z] coordinates in the
config.pointsproperty, - or providing a radius and number of sides in the
config.radiusandconfig.sidesproperties.
The single face will be used in preference to points or sides. If no face is provided, the array of points will be used in preference to the radius and sides. Thus, you should only include the properties for one of these ways.
Using
config.pointscreates a simple prism from a face with a single outer boundary. For more complex prisms with holes and/or multiple boundaries, you can use thePD.OCC#polygonmethod withconfig.contoursor build the face boundaries using aPD.CAD.Pathinstance. You can use this method or thePD.OCC#extrudemethod to make the prism from the face.Parameters:
Name Type Argument Description configobject <optional>
An optional configuration object.
Properties of
config:Name Type Argument Description axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
heightnumber <optional>
The height of the shape, defaults to 1000mm (1m).
faceoc.TopoDS_Face <optional>
An optional closed face to extrude into a prism.
pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the base shape of the prism.
sidesnumber <optional>
The number of sides of the prism (3 to 256) when no face or points are provided, defaults to 8.
radiusnumber <optional>
The radius of the prism when no face or points are provided, defaults to 1000mm (1m).
posArray.<number> <optional>
An [x,y,z] vector array defining the center when no face or points are provided, defaults to [0,0,0].
Returns:
Returns a rectangular prism shape.
- Type
- oc.TopoDS_Shape
Example
const polygon = OCC.polygon({ contours: [ [ // Outer boundary. [ -3000.0, -2000.0, 0.0 ], [ 3000.0, -2000.0, 0.0 ], [ 3000.0, 2000.0, 0.0 ], [ -3000.0, 2000.0, 0.0 ] ], [ // Internal hole. [ -1000.0, -1000.0, 0.0 ], [ 1000.0, -1000.0, 0.0 ], [ 1000.0, 1000.0, 0.0 ], [ -1000.0, 1000.0, 0.0 ] ] ] }); /// Define the face to use. CAD.add(OCC.prism({ axis: [ 0.5773503, 0.5773503, 0.5773503 ], face: polygon, height: 5000 }) ); /// Define some boundary points. CAD.add(OCC.prism({ height: 5000, points: [ [ -3000.0, -2000.0, 0.0 ], [ 3000.0, -2000.0, 0.0 ], [ 3000.0, 2000.0, 0.0 ], [ -3000.0, 2000.0, 0.0 ] ] }) ); /// Define radius and sides. CAD.add(OCC.prism({ axis: [ 0.5773503, 0.5773503, 0.5773503 ], height: 5000, radius: 2000, sides: 12 }) ); - providing a single face to extrude in the
-
processJSON(json) <static>
-
Parses a JSON geometry node.
Parameters:
Name Type Description jsonobject | Array A parsed JSON object or array of objects.
Returns:
Returns a shape or null if
jsonis invalid.- Type
- oc.TopoDS_Shape | Array.<oc.TopoDS_Shape> | null
-
progressOperation(level [, operation]) <static>
-
Check first if processing has been cancelled and, if not, format the operation and add it to the progress log.
The movement of the progress bar should not be affected by the current log level so, if the log level is less than the level of this operation, we still need to send
undefinedto the host application to increment it.Parameters:
Name Type Argument Description levellevel The log level of the operation.
operationstring <optional>
The name of the operation to log.
Throws:
-
Throws and error if process cancelled.
- Type
- Error
-
-
pyramid( [config]) <static>
-
Construct a pyramid primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
An optional configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the start position of the shape, defaults to [0,0,0].
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
sizeArray.<number> <optional>
An [x,y,z] vector array defining the size of the shape in each axis, defaults [1000,1000,1000].
minArray.<number> <optional>
An [x,y,z] vector array defining the bottom-left extents.
maxArray.<number> <optional>
An [x,y,z] vector array defining the top-right extents.
truncatenumber <optional>
A fractional top point truncation amount (0 to 1), defaults to 1.0.
centeredboolean <optional>
An optional flag indicating that the shape should be centered on its pos/min position rather than at its bottom-left, defaults to false.
centerXYboolean <optional>
An optional flag indicating that the shape should be centered on its X and Y pos/min position rather than at its bottom-left, defaults to false.
filletnumber | Array.<number> <optional>
An optional radius or [bot,sides,top] array for filleting edges and corners, defaults to 0 (no fillet).
Returns:
Returns a pyramidal shape.
- Type
- oc.TopoDS_Shape
Example
PD.CAD.add(PD.OCC.pyramid({ size: [ 2000, 10000, 3000 ], fillet: [ 100, 200, 300 ], centerXY: true, truncateX: 0.5 })); -
revolve( [config]) <static>
-
Revolves a shape by the given angle and direction.
When using this method, you should include either a
degreesvalue or ananglevalue. If you include both, thedegreeswill be used in preference to theanglevalue.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
A shape to rotate.
axisArray.<number> | number <optional>
An [x,y,z] vector array defining the direction of the shape axis, or a number (X:1, Y:2, Z:3), defaults to the +Z axis.
aboutArray.<number> <optional>
An [x,y,z] vector array defining the revolution origin, defaults to the origin.
degreesnumber <optional>
The angle of rotation about the given axis in degrees, defaults to 0.
anglenumber <optional>
The angle of rotation about the given axis in radians, defaults to 0.
copyboolean <optional>
When true revolves a copy of the given shape, defaults to false.
Returns:
Returns the revolved shape.
- Type
- oc.TopoDS_Shape
-
rotate( [config]) <static>
-
Rotates shape(s) around an axis.
When using this method, you should include either a
degreesvalue or ananglevalue. If you include both, thedegreeswill be used in preference to theanglevalue.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to rotate.
axisArray.<number> | number <optional>
An [x,y,z] vector array defining the direction of the shape axis, or a number (X:1, Y:2, Z:3), defaults to Z axis.
aboutArray.<number> <optional>
An [x,y,z] vector array defining the rotation origin.
degreesnumber <optional>
The angle of rotation about the given axis in degrees, defaults to 0.
anglenumber <optional>
The angle of rotation about the given axis in radians, defaults to 0.
Returns:
Returns the rotated shape(s).
- Type
- oc.TopoDS_Shape
-
scale( [config]) <static>
-
Scales the given shape(s) from the origin.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to scale.
scalenumber <optional>
A relative scale factor to apply in each axis.
Returns:
Returns the scaled shape(s).
- Type
- oc.TopoDS_Shape
-
shapeToMesh(shape, maxDeviation, fullShapeEdgeHashes, fullShapeFaceHashes) <static>
-
Converts a shape, or composite shape to a mesh.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to convert.
maxDeviationnumber The tolerance for linear and angle deflection, defaults to 0.5.
fullShapeEdgeHashesobject An object containing edge hashes.
fullShapeFaceHashesobject An object containing face hashes
Returns:
Returns the faces and edges that make up the shape.
- Type
- Array.<Array>
-
shell( [config]) <static>
-
Construct a shell shape sewn together from facets.
This method tries to determine what format the facet data is in and then passes it to either the
OCC.indexedShellorOCC.facetedShellmethods for actual processing.Both methods sew together a collection of planar faces into a
TopoDS_Shape. It does this by making planarTopoDS_Wireobjects out of each facet, then makingTopoDS_Faceobjects out of each wire, and then sewing the faces together into aTopoDS_Shell.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An optional array of [x,y,z] vector arrays defining the corners and edges of the shape.
verticesArray.<Array.<number>> <optional>
An optional array of [x,y,z] vector arrays defining the corners and edges of the shape.
facesArray.<Array.<number>> | Array.<object> <optional>
An array of faces with boundaries containing ordinal indexes of the points that make up the face.
facetsArray.<object> <optional>
An array of facets with boundary contours defined by sequential [x,y,z] vector arrays.
tolerancenumber <optional>
An optional face sewing tolerance, defaults to 1mm.
Returns:
Returns a shell shape sewn together from faces/facets.
- Type
- oc.TopoDS_Shape
-
shellToSolid(shape) <static>
-
Converts a shell shape to a solid shape.
When used with CSG, shells and solids produce different results. This method first checks if the given shape is a shell and, if so, returns a solid. If it is already a solid, it is just passed through.
If the shape is not a shell or solid, and cannot be converted to a solid, the method returns null.
Parameters:
Name Type Description shapeoc.TopoDS_Shape The shape to create a solid from.
Returns:
Returns the created solid, or null if the shape could not be converted into a solid.
- Type
- oc.TopoDS_Solid | null
-
solid( [config]) <static>
-
Construct a solid shape from an indexed face mesh.
This method first calls
PD.OCC.shellto generate a manifold shell of faces, and then converts that into solid for use with CSG. Not all shell topology can be converted to solid, so you may end up with a compound of shells instead of a solid if that is the case.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An optional array of [x,y,z] vector arrays defining the corners and edges of the shape.
verticesArray.<Array.<number>> <optional>
An optional array of [x,y,z] vector arrays defining the corners and edges of the shape.
facesArray.<Array.<number>> | Array.<object> <optional>
An array of faces with boundaries containing ordinal indexes of the points that make up the face.
facetsArray.<object> <optional>
An array of facets with boundary contours defined by sequential [x,y,z] vector arrays.
tolerancenumber <optional>
An optional face sewing tolerance, defaults to 1mm.
Returns:
Returns a solid shape sewn together from faces.
- Type
- oc.TopoDS_Shape
-
sphere( [config]) <static>
-
Construct a spherical primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the shape center, defaults to the origin.
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
radiusnumber <optional>
The distance of the spherical surface from the centre, defaults to 1000mm (1m).
longitudenumber <optional>
An optional longitudinal angle in radians to restrict the sphere to (0 to 2PI), defaults to 2PI.
latitudeArray.<number> <optional>
An optional array with the start and stop latitude angles in radians (-PI/2 to PI/2), defaults to [-PI/2, PI/2].
Returns:
Returns a spherical shape.
- Type
- oc.TopoDS_Shape
-
subtract( [config]) <static>
-
Subtracts a set of shapes from a main body shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description fromoc.TopoDS_Shape <optional>
The shape to subtract from.
subtractArray.<oc.TopoDS_Shape> | oc.TopoDS_Shape <optional>
An array of shapes to subtract.
tolerancenumber <optional>
The tolerance to use when differencing, defaults to 0.1.
keepEdgesboolean <optional>
Whether or not to keep the original edge(s) in the shape, defaults to false.
Returns:
Returns the subtracted shape.
- Type
- oc.TopoDS_Shape
-
sweep( [config]) <static>
-
Creates a shape by sweeping a shape along a wire path.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapeoc.TopoDS_Shape <optional>
A shape to sweep along the path.
pathoc.TopoDS_Wire <optional>
A wire defining the path to sweep along.
Returns:
Returns the swept shape(s).
- Type
- oc.TopoDS_Shape
-
text( [config]) <static>
-
Construct a set of primitive shapes representing 3D text.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description textstring <optional>
The characters to be generated.
sizenumber <optional>
The size of the text, defaults to 36.
heightnumber <optional>
The extrusion height of the text faces, defaults to 0.15 font size.
Returns:
Returns a complex shape representing the text.
- Type
- oc.TopoDS_Shape | oc.TopoDS_Solid
-
torus( [config]) <static>
-
Construct a toroidal primitive shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the shape center, defaults to the origin.
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
radiusRingnumber <optional>
The radius of the torus pipe line from the center, defaults to 400mm (0.4m).
radiusPipenumber <optional>
The radius of the rotated pipe, defaults to 100 (0.1m).
longitudenumber <optional>
An optional longitudinal angle in radians to restrict the torus to (0 to 2PI), defaults to 2PI.
latitudeArray.<number> <optional>
An optional array with the start and stop latitude angles in radians (0 to 2PI), defaults to [0, 2PI].
Returns:
Returns a toroidal shape.
- Type
- oc.TopoDS_Shape
-
translate( [config]) <static>
-
Translates the given shape(s) by a relative vector.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesoc.TopoDS_Shape | Array.<oc.TopoDS_Shape> <optional>
A shape or array of shapes to translate.
offsetArray.<number> <optional>
An [x,y,z] vector array defining the translation offset in each axis.
Returns:
Returns the translated shape(s).
- Type
- oc.TopoDS_Shape
-
union( [config]) <static>
-
Combines a set of shapes into a single unioned shape.
Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description shapesArray.<oc.TopoDS_Shape> <optional>
An array of two or more shapes to union.
tolerancenumber <optional>
The tolerance to use when unioning, defaults to 0.1.
keepEdgesboolean <optional>
Whether or not to keep the original edge(s) in the shape, defaults to false.
Returns:
Returns the combined shape.
- Type
- oc.TopoDS_Shape
-
wedge( [config]) <static>
-
Construct a rectangular wedge primitive shape.
Wedges are rectangular primitives that taper in the X and/or Z axis as the shape runs along the Y axis. In addition to setting the overall size in each axis, you can provide either the taper width/height value or the minimum and maximum X and Z coordinates at the +Y end of the wedge.
This method will cache the generated shape if caching is enabled.
Parameters:
Name Type Argument Description configobject <optional>
An optional configuration object.
Properties of
config:Name Type Argument Description posArray.<number> <optional>
An [x,y,z] vector array defining the start position of the shape, defaults to [0,0,0].
axisArray.<number> | number <optional>
An [x,y,z] axis array or a number (X:1, Y:2, Z:3), defaults to Z axis.
sizeArray.<number> <optional>
An [x,y,z] vector array defining the size of the shape in each axis, defaults to [1000,1000,1000].
minArray.<number> <optional>
An [x,y,z] vector array defining the bottom-left extents.
maxArray.<number> <optional>
An [x,y,z] vector array defining the top-right extents.
taperXArray.<number> <optional>
An array with the minimum and maximum X-axis values at the tapered end, defaults to
[0, size[0]].taperZArray.<number> <optional>
An array with the minimum and maximum Z-axis values at the tapered end, defaults to
[0, 0].taperWidthnumber <optional>
The width of the tapered end in the X-axis, defaults to
size[0].taperHeightnumber <optional>
The height of the tapered end in the Z-axis, defaults to
0.centeredboolean <optional>
An optional flag indicating that the shape should be centered on its pos/min position rather than at its bottom-left, defaults to false.
centerXYboolean <optional>
An optional flag indicating that the shape should be centered on its X and Y pos/min position rather than at its bottom-left, defaults to false.
filletnumber | Array.<number> <optional>
An optional radius or [bot,sides,top] array for filleting edges and corners, defaults to 0 (no fillet).
Returns:
Returns a rectangular wedge shape.
- Type
- oc.TopoDS_Shape
Example
/// Define just the size. PD.CAD.add(PD.OCC.wedge({ size: [ 1000, 2000, 3000 ] })); /// Define the height and width at end. PD.CAD.add(PD.OCC.wedge({ size: [ 1000, 2000, 3000 ], taperHeight: 50, taperWidth: 750, centerXY: true })); /// Define X and Z positions at end. PD.CAD.add(PD.OCC.wedge({ min: [ -500, -1000, 0 ], max: [ 500, 1000, 3000 ], taperX: [ 250, 750 ], taperZ: [ -100, 50 ] })); /// Define both dimensions. const x_min = 0.40 * width; const x_max = 0.75 * width; const z_min = -0.25 * height; const z_max = 0.25 * height; PD.CAD.add(PD.CAD.addWedge({ size: [ width, depth, height ], taperX: [ x_min, x_max ], taperZ[ z_min, z_max ] })); -
wire( [config]) <static>
-
Construct a wire from points or edges.
Wires are used to represent shape outlines or face boundaries. They are formed by connecting one or more edges together, which may be curved or linear segments.
To create a wire, you must pass either an array of edges in the
config.edgesproperty, or an array of [x,y,z] vector array coordinates in theconfig.pointsproperty. The list of edges will be used in preference to points, so you should only include one or the other rather than both.Parameters:
Name Type Argument Description configPD.OCC.IWirePath <optional>
A configuration object.
Properties of
config:Name Type Argument Description edgesArray.<oc.TopoDS_Edge> <optional>
An array of edges to connect together to form the wire path.
pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the wire path.
closedboolean <optional>
Whether or not to form a closed loop from the given points.
Returns:
Returns a new wire.
- Type
- oc.TopoDS_Wire
-
wireArc( [config]) <static>
-
Construct a wire from a circular arc.
Wires are used to represent shape outlines or face boundaries. They are formed by connecting one or more edges together, which may be curved or linear segments.
Parameters:
Name Type Argument Description configPD.OCC.IArcPath <optional>
A configuration object defining the arc.
Returns:
Returns a wire arc.
- Type
- oc.TopoDS_Wire
-
wireBSpline( [config]) <static>
-
Construct a BSpline wire from control points.
Wires are used to represent shape outlines or face boundaries. They are formed by connecting one or more edges together, which may be curved or linear segments.
Parameters:
Name Type Argument Description configPD.OCC.ICurvePoints <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the control points of the bspline.
closedboolean <optional>
Whether or not the wire forms a closed loop.
Returns:
Returns a curved wire.
- Type
- oc.TopoDS_Edge
-
wireBezier( [config]) <static>
-
Construct a Bezier curved wire from control points.
Wires are used to represent shape outlines or face boundaries. They are formed by connecting one or more edges together, which may be curved or linear segments.
Parameters:
Name Type Argument Description configPD.OCC.ICurvePoints <optional>
A configuration object.
Properties of
config:Name Type Argument Description pointsArray.<Array.<number>> <optional>
An array of [x,y,z] vector arrays defining the control points of the bezier curve.
closedboolean <optional>
Whether or not the wire forms a closed loop.
Returns:
Returns a curved wire.
- Type
- oc.TopoDS_Edge
-
wireCircle( [config]) <static>
-
Construct a closed circular wire.
Wires are used to represent shape outlines or face boundaries. They are formed by connecting one or more edges together, which may be curved or linear segments.
Parameters:
Name Type Argument Description configPD.OCC.ICentreRadius <optional>
A configuration object.
Properties of
config:Name Type Argument Description centerArray.<number> <optional>
An [x,y,z] vector array defining the center of the circle.
radiusnumber <optional>
The radius of the circle, defaults to 1000mm (1m).
Returns:
Returns a circular wire.
- Type
- oc.TopoDS_Wire
-
wires( [config]) <static>
-
Construct one or more wires from an array of point contours.
To create wires, you must pass an array of contours in the
config.contoursproperty, each containing two or more [x,y,z] vector array coordinates defining a connected sequence of line vertices.Parameters:
Name Type Argument Description configobject <optional>
A configuration object.
Properties of
config:Name Type Argument Description contoursArray.<Array.<Array.<number>>> <optional>
An array of contours, each containing [x,y,z] vector arrays defining a wire path.
Returns:
Returns an array of wires new wire.
- Type
- Array.<oc.TopoDS_Wire>