Class Make3D
- Namespace
- CADability.GeoObject
- Assembly
- CADability.dll
Static methods to create and combine Solids, Shells and Faces: primitives (MakeBox(GeoPoint, GeoVector, GeoVector, GeoVector), MakeCylinder(GeoPoint, GeoVector, GeoVector), MakeCone(GeoPoint, GeoVector, GeoVector, double, double), MakeSphere(GeoPoint, double), MakeTorus(GeoPoint, GeoVector, double, double)), extrusions and sweeps (MakePrism(IGeoObject, GeoVector, Project, bool), MakeRevolution(IGeoObject, GeoPoint, GeoVector, double, Project), MakePipe(IGeoObject, Path, Project), MakeRuledSolid(Path, Path, Project), MakeRuledShell(Path, Path, Project)), boolean operations (Union(Solid, Solid), Difference(Solid, Solid), Intersection(Solid, Solid)), fillets and chamfers (MakeFillet(Edge[], double, out Shell), MakeChamfer(Face, Edge[], double, double, out IGeoObject[])) and sewing faces to shells and solids (SewFaces(Face[], bool), SewFacesAndShells(GeoObjectList)).
Methods with a Project parameter give the result the project's current layer, colour and other default attributes (SetDefaults(IGeoObject)) when the project is not null. No method adds its result to a model, that is left to the caller (Add(IGeoObject)).
Some members are left over from an implementation on top of an external modelling kernel and throw NotImplementedException; they are marked obsolete, name the replacement where one exists, and will be removed in the next minor version.
public class Make3D
- Inheritance
-
Make3D
- Inherited Members
Constructors
Make3D()
public Make3D()
Methods
CloneFaceUserData(Solid[], Solid[])
Copies the UserData of the faces of the solids in copyFrom to the faces
of the solids in addTo that lie on the same surface and share a common part with them. Used
after a boolean operation to carry the user data of the operands over to the faces of the result.
public static void CloneFaceUserData(Solid[] copyFrom, Solid[] addTo)
Parameters
copyFromSolid[]solids whose faces carry the user data
addToSolid[]solids whose faces receive the user data
Curtail(Path, Shell)
Intended to cut a shell with a closed path: the path (made planar first, if necessary) is extruded through the extent of the shell and the part of the shell inside that prism is returned, or, if several parts result, the one closest to the path. Currently not functional: it relies on Intersection(Shell, Solid), which is not implemented and throws NotImplementedException.
[Obsolete("Not functional, throws NotImplementedException unless the path cannot be made planar. Will be removed in the next minor version.")]
public static Shell Curtail(Path path, Shell shell)
Parameters
Returns
- Shell
null when the path cannot be made planar or no prism can be made from it, otherwise throws
Exceptions
Difference(Face, Solid)
Not implemented, throws NotImplementedException. Intended to return the remains of a face when a solid is subtracted.
[Obsolete("Not implemented, throws NotImplementedException. Will be removed in the next minor version.")]
public static Face[] Difference(Face fce, Solid sld)
Parameters
Returns
- Face[]
One or more faces
Difference(Shell, Solid)
Not implemented, throws NotImplementedException. Intended to return the remains of a shell when a solid is subtracted.
[Obsolete("Not implemented, throws NotImplementedException. Will be removed in the next minor version.")]
public static Shell[] Difference(Shell shl, Solid sld)
Parameters
Returns
- Shell[]
One or more shells
Difference(Solid, Face)
Not implemented, throws NotImplementedException. Intended to split a solid by a face. Use SplitByPlane(Plane) to split a solid by a plane.
[Obsolete("Not implemented, throws NotImplementedException; use Solid.SplitByPlane to split a solid by a plane. Will be removed in the next minor version.")]
public static Solid[] Difference(Solid sld, Face fce)
Parameters
Returns
- Solid[]
The parts of the solid
Difference(Solid, Solid)
Returns the difference of the two given Solids, same as Subtract(Solid, Solid): s2
is subtracted from s1. The result may consist of several solids. If the solids are disjunct,
a copy of s1 is returned, if s2 contains s1 the array is empty.
public static Solid[] Difference(Solid s1, Solid s2)
Parameters
Returns
- Solid[]
difference of the two solids
Extrude(IGeoObject, GeoVector, Project)
Extrudes the provided object faceShellPathCurve along the extension.
public static IGeoObject Extrude(IGeoObject faceShellPathCurve, GeoVector extension, Project project)
Parameters
faceShellPathCurveIGeoObjectObject to extrude, may be a Face, Shell, Path or ICurve object
extensionGeoVectorDirection and length of extension
projectProjectA project which is used to set default attributes to the result, may be null
Returns
- IGeoObject
The extruded face, shell or solid, null if extrusion not possible
ExtrudeCurveToFace(ICurve, ICurve)
Extrude a curve along another curve. E.g. if you extrude a circle along a line (which is perpendicular to the cirle plane) you will get a cylindrical face.
If the curve along is planar, the curve toExtrude will be only rotated around the plane's normal (and moved of course),
If the curve along is not planar, there is no well defined way how to rotate the curve toExtrude.
Two lines give a planar face, a circle along a line perpendicular to its plane a cylindrical face, a line along a
circle a cylindrical, planar or conical face (depending on the direction of the line relative to the axis of the
circle), a circle along a circle around an axis in its plane a toroidal face; other combinations give a face on a
swept surface. Returns null when no surface can be built (e.g. a line extruded along itself).
public static Face ExtrudeCurveToFace(ICurve toExtrude, ICurve along)
Parameters
toExtrudeICurvethe curve to extrude, it becomes an edge of the face
alongICurvethe curve to extrude along, its start point should be on
toExtrude
Returns
- Face
the face or null
GetDtkFileType(string)
Was meant to return the type of a file readable by the external DTK import library, which is not part of this distribution. Always returns the string "error: dtk is not installed".
public static string GetDtkFileType(string filename)
Parameters
filenamestringignored
Returns
- string
"error: dtk is not installed"
GetShape(Project)
Not implemented, throws NotImplementedException (left over from an implementation on top of an external modelling kernel, there is no way to create a Make3D instance). Use the static methods.
[Obsolete("Not implemented, throws NotImplementedException; use the static methods of Make3D. Will be removed in the next minor version.")]
public IGeoObject GetShape(Project project)
Parameters
projectProjectthe project to set default styles
Returns
- IGeoObject
nothing, throws
GetShapes(Project)
Not implemented, throws NotImplementedException, see GetShape(Project).
[Obsolete("Not implemented, throws NotImplementedException; use the static methods of Make3D. Will be removed in the next minor version.")]
public IGeoObject[] GetShapes(Project project)
Parameters
projectProjectthe project to set default styles
Returns
- IGeoObject[]
nothing, throws
ImportDtk(string, Project, bool, bool)
Was meant to import a file via the external DTK import library, which is not part of this distribution. Always throws NotImplementedException.
[Obsolete("Not implemented, throws NotImplementedException; the DTK import library is not part of CADability. Will be removed in the next minor version.")]
public static IGeoObject[] ImportDtk(string filename, Project pr, bool useProgress = false, bool makeCompounds = false)
Parameters
filenamestringthe file to import
prProjectthe project to set default styles for the result
useProgressbooltrue: show the progress of the import
makeCompoundsbooltrue: combine the imported objects into blocks according to the structure of the file
Returns
- IGeoObject[]
nothing, throws
Exceptions
- NotImplementedException
always
ImportSTL(string)
Not functional: reads the header of the STL file and then throws NotImplementedException. Use the class ImportSTL to import STL files.
public static Solid[] ImportSTL(string fileName)
Parameters
fileNamestringthe file to read
Returns
- Solid[]
nothing, throws
Exceptions
- NotImplementedException
always
Intersection(Face, Face)
Not implemented, throws NotImplementedException. Use Intersect(Face) for the intersection curves of two faces.
[Obsolete("Not implemented, throws NotImplementedException; use Face.Intersect(Face). Will be removed in the next minor version.")]
public static IGeoObject[] Intersection(Face face1, Face face2)
Parameters
Returns
- IGeoObject[]
nothing, throws
Intersection(Shell, Solid)
Not implemented, throws NotImplementedException.
[Obsolete("Not implemented, throws NotImplementedException. Will be removed in the next minor version.")]
public static Shell[] Intersection(Shell shell1, Solid solid2)
Parameters
Returns
- Shell[]
nothing, throws
Intersection(Solid, Solid)
Returns the intersection of the two given Solids, same as Intersect(Solid, Solid): the parts common to both solids, as new solids. If the solids are disjunct or only touch, the array is empty.
public static Solid[] Intersection(Solid solid1, Solid solid2)
Parameters
Returns
- Solid[]
the common parts, empty when there are none
MakeBox(GeoPoint, GeoVector, GeoVector, GeoVector)
Creates a box (a parallelepiped): the corner location and the three edges that start there. The
vectors need not be perpendicular or of equal length. When they do not form a right handed system,
directionX and directionY are exchanged so that the faces are oriented outward.
public static Solid MakeBox(GeoPoint location, GeoVector directionX, GeoVector directionY, GeoVector directionZ)
Parameters
locationGeoPointa corner of the box
directionXGeoVectorfirst edge starting at the corner
directionYGeoVectorsecond edge starting at the corner
directionZGeoVectorthird edge starting at the corner
Returns
- Solid
the box
MakeChamfer(Face, Edge[], double, double, out IGeoObject[])
Chamfers (bevels) the given edges of a shell. The edges must belong to primaryFace, must be
connected (form a path) and only two edges may have a common vertex. The chamfer is primaryDist
wide on the primary face and secondaryDist wide on the other face of each edge; equal distances
give a 45° chamfer. The shell itself is not modified, the chamfered copy is returned. The caller replaces the shell,
or the solid it belongs to, by the result (the "chamfer" action does that with undo).
public static IGeoObject[] MakeChamfer(Face primaryFace, Edge[] edges, double primaryDist, double secondaryDist, out IGeoObject[] affectedShellsOrSolids)
Parameters
primaryFaceFacethe face all edges belong to
edgesEdge[]the edges to chamfer
primaryDistdoubledistance of the chamfer from the edge on
primaryFacesecondaryDistdoubledistance of the chamfer from the edge on the other face
affectedShellsOrSolidsIGeoObject[]receives the shell the face belongs to, or null when the face does not belong to a shell
Returns
- IGeoObject[]
an array with the new shell, or null when the chamfer failed
MakeCone(GeoPoint, GeoVector, GeoVector, double, double)
Creates a cone. The cone is defined by two parallel discs with two different radii. The first disc is centered at location, the second at location + directionZ. directionZ is also the normal vector of both discs. directionX must be perpendicular to directionZ and specifies the startpoint of the circular edge.
public static Solid MakeCone(GeoPoint location, GeoVector directionX, GeoVector directionZ, double radius1, double radius2)
Parameters
locationGeoPointlocation of the cone
directionXGeoVectorstartpoint of edge
directionZGeoVectoraxis of the cone
radius1doubleradius at location, 0 for a pointed cone
radius2doubleradius at location + directionZ, 0 for a pointed cone
Returns
- Solid
the cone, or null when both radii are equal (use MakeCylinder(GeoPoint, GeoVector, GeoVector)) or the faces cannot be sewed
MakeCylinder(GeoPoint, GeoVector, GeoVector)
Creates a cylinder with the centre of the bottom circle at location. The length of
directionX is the radius, its direction is where the seam of the lateral surface starts, and
directionZ is the axis, its length the height. directionX must be
perpendicular to directionZ. The lateral surface is split into two half faces.
public static Solid MakeCylinder(GeoPoint location, GeoVector directionX, GeoVector directionZ)
Parameters
locationGeoPointcentre of the bottom circle
directionXGeoVectorradius vector, perpendicular to the axis
directionZGeoVectoraxis, its length is the height
Returns
- Solid
the cylinder
MakeCylinderShell(GeoPoint, GeoVector, GeoVector)
Creates the lateral surface of a cylinder as an open shell of two half faces, without bottom and top. The parameters are those of MakeCylinder(GeoPoint, GeoVector, GeoVector).
public static Shell MakeCylinderShell(GeoPoint location, GeoVector directionX, GeoVector directionZ)
Parameters
locationGeoPointcentre of the bottom circle
directionXGeoVectorradius vector, perpendicular to the axis
directionZGeoVectoraxis, its length is the height
Returns
- Shell
the open shell
MakeFace(Path, Project)
Creates a planar Face bound by the closed planar path. A path that consists of a
single closed curve (a circle) is split into two halves first, so that the face has two edges. Returns null when
the path is not planar.
public static Face MakeFace(Path path, Project project)
Parameters
pathPaththe closed planar outline
projectProjectthe Project to set default styles for the result, may be null
Returns
- Face
the face or null
MakeFillet(Edge[], double, out Shell)
Rounds the given edges of a shell with a fillet of the given radius. The edges must belong to the same shell, must be connected (form a path) and no more than three edges may meet in a vertex. The shell itself is not modified, the rounded copy is returned. The caller replaces the shell, or the solid it belongs to, by the result (the "fillet" action does that with undo).
public static Shell MakeFillet(Edge[] edges, double radius, out Shell affectedShell)
Parameters
edgesEdge[]the edges to round, all of the same shell
radiusdoublethe radius of the fillet
affectedShellShellreceives the shell the edges belong to, or null when the first edge does not belong to a shell
Returns
- Shell
a new shell with the fillets, or null when the rounding failed
MakeOffset(Shell, double)
Not implemented, throws NotImplementedException. Intended to create the offset of a shell, see MakeOffset(Solid, double).
[Obsolete("Not implemented, throws NotImplementedException; use Shell.GetOffset. Will be removed in the next minor version.")]
public static IGeoObject MakeOffset(Shell shell, double offset)
Parameters
Returns
- IGeoObject
The resulting shell
MakeOffset(Solid, double)
Not implemented, throws NotImplementedException. Intended to create a solid as an offset to
solid: positive values of offset expand the solid, negative values contract it.
[Obsolete("Not implemented, throws NotImplementedException; use Shell.GetOffset. Will be removed in the next minor version.")]
public static Solid MakeOffset(Solid solid, double offset)
Parameters
Returns
- Solid
The resulting solid
MakePipe(IGeoObject, Path, Project)
Sweeps a profile along a path (extrusion along a curve). The profile is a closed planar curve, a Face
or a Shell; a closed planar curve is first turned into a planar face, so the result is a solid
whose cross section is the profile. The open edges of the profile are extruded along each segment of
along (see ExtrudeCurveToFace(ICurve, ICurve)), a planar profile that the path
crosses is first moved to the start of the path, and the profile and its moved copy close the ends unless the path
is closed and smooth. The path should be smooth; at sharp bends the segments overlap instead of being mitred.
Returns null for an open curve or when the faces of the result cannot be sewed to a single shell; throws
NotImplementedException for a profile of another type.
public static IGeoObject MakePipe(IGeoObject faceShellOrPath, Path along, Project project)
Parameters
faceShellOrPathIGeoObjectthe profile: a closed planar curve, a face or a shell
alongPaththe path to sweep along
projectProjectthe Project to set default styles for the result, may be null
Returns
- IGeoObject
the created solid or null
MakePrism(IGeoObject, GeoVector, Project, bool)
Creates a Solid or a Shell by moving a closed planar curve or a Face along a
vector (extrusion). A closed planar curve (a Path, a Polyline, a circle...) yields the shell
of the side faces when pathToShell is true, and a closed solid with bottom and top face when it is
false. A face yields the solid between the face and its moved copy; the face may be curved. An open or non-planar
curve, a shell, or any other IGeoObject returns null.
public static IGeoObject MakePrism(IGeoObject faceShellOrPath, GeoVector extrusion, Project project, bool pathToShell = true)
Parameters
faceShellOrPathIGeoObjectthe closed planar curve or the face to move
extrusionGeoVectordirection and length of the extrusion
projectProjectthe Project to set default styles for the result, may be null
pathToShellbooltrue: a curve yields the open shell of the side faces, false: a curve yields a closed solid
Returns
- IGeoObject
the created solid or shell, or null
MakePrismMiter(SimpleShape, GeoPoint, GeoVector, GeoVector, GeoVector, GeoVector)
Creates a prism or profile as an extrusion of the provided shape. The position of the prism is defined by location and mainDirection. The shape is a 2D object. The 2d origin is moved along the axis defined by location and main direction. The topDirection vector corresponds to the 2d y-axis of the shape. The beginning and ending of the extrusion is a miter cut that allows the same profile be connected to the starting or ending point where mainDirection and startMiter are exchanged and topDirection is kept.
public static Solid MakePrismMiter(SimpleShape shape, GeoPoint location, GeoVector topDirection, GeoVector mainDirection, GeoVector startMiter, GeoVector endMiter)
Parameters
shapeSimpleShape2d shape to be extruded, the 2d origin is moved along mainDirection
locationGeoPointStarting point of the resulting profile, corresponds to the 2d origin
topDirectionGeoVectorThe "up" direction for the resulting profile, corresponds to the y-axis of the 2d shape
mainDirectionGeoVectorDirection of the prism, the length of this vector defines the length of the prism
startMiterGeoVectorDirection of the connecting profile at the starting point, must not be parallel to mainDirection
endMiterGeoVectorDirection of the connecting profile at the ending point, must not be parallel to mainDirection
Returns
- Solid
The resulting solid
MakePrismMiter(SimpleShape, GeoPoint[], GeoVector, GeoVector, GeoVector, GeoVector)
Not implemented, always returns null. Use MakePrismMiter(SimpleShape, GeoPoint, GeoVector, GeoVector, GeoVector, GeoVector).
[Obsolete("Not implemented, always returns null; use MakePrismMiter(SimpleShape, GeoPoint, GeoVector, GeoVector, GeoVector, GeoVector). Will be removed in the next minor version.")]
public static Solid MakePrismMiter(SimpleShape outline, GeoPoint[] path, GeoVector topDirection, GeoVector mainDirection, GeoVector startMiter, GeoVector endMiter)
Parameters
outlineSimpleShape2d shape to be extruded
pathGeoPoint[]Points of the polygonal path along which the profile was to be extruded
topDirectionGeoVectorThe "up" direction of the profile
mainDirectionGeoVectorDirection of the prism
startMiterGeoVectorDirection of the connecting profile at the starting point
endMiterGeoVectorDirection of the connecting profile at the ending point
Returns
- Solid
null
MakeRevolution(IGeoObject, GeoPoint, GeoVector, double, Project)
Creates a Shell or a Solid by rotating a Path, a curve or a Face around a given axis. Rotating a path or a curve yields the shell of the rotated curves, also when the path is closed. Rotating a face yields a Solid. Rotating a different type of IGeoObject returns null, as does a rotation that fails.
public static IGeoObject MakeRevolution(IGeoObject faceShellOrPath, GeoPoint location, GeoVector direction, double sweep, Project project)
Parameters
faceShellOrPathIGeoObjectobject to rotate
locationGeoPointa point on the axis
directionGeoVectordirection of the axis
sweepdoubleamount to rotate in radians (2*Math.PI is a full rotation)
projectProjectthe Project to set default styles for the result, may be null
Returns
- IGeoObject
the created solid or shell, or null
MakeRuledShell(Path, Path, Project)
Connects the two paths with ruled surfaces and returns them as a Shell, without the faces of the paths. The segments are paired as in MakeRuledSolid(Path, Path, Project). The paths may be open or closed. Returns null when the paths cannot be connected (a failing surface).
public static IGeoObject MakeRuledShell(Path firstPath, Path secondPath, Project project)
Parameters
firstPathPaththe first path
secondPathPaththe second path
projectProjectthe Project to set default styles for the result, may be null
Returns
- IGeoObject
the generated shell, or null
MakeRuledSolid(Path, Path, Project)
Connects the two closed paths with ruled surfaces and returns the solid bound by the planar faces of the two paths and the ruled surfaces (a loft between two profiles). Splines are split at their corners first. Each segment of the first path is connected with the segment with the same index of the second path. When the numbers of segments differ, a path with a single segment is split into as many segments as the other path has, otherwise both paths are split where the other one has a vertex at the same relative length. Two lines are connected by a plane, two coaxial circles by a cylinder or a cone, other pairs by a RuledSurface, see MakeRuledSurface(ICurve, ICurve). Returns null when the paths cannot be connected to a solid (an open path, a path that does not bound a planar face, or a surface that cannot be built).
public static Solid MakeRuledSolid(Path firstPath, Path secondPath, Project project)
Parameters
firstPathPaththe first path, closed
secondPathPaththe second path, closed
projectProjectthe Project to set default styles for the result, may be null
Returns
- Solid
the generated solid, or null
MakeRuledSurface(ICurve, ICurve)
Returns the surface that connects the two curves with straight lines. Two lines in a common plane give a PlaneSurface, two circles or circular arcs on a common axis a CylindricalSurface (same radius) or a ConicalSurface (different radii, same start and end angle), two curves in a common plane a PlaneSurface, and every other pair a RuledSurface.
public static ISurface MakeRuledSurface(ICurve curve1, ICurve curve2)
Parameters
Returns
- ISurface
the surface
MakeSphere(GeoPoint, double)
Creates a sphere. The surface is split into two half faces at the seam in the plane x == 0 of the sphere.
public static Solid MakeSphere(GeoPoint location, double radius)
Parameters
Returns
- Solid
the sphere, or null when the faces cannot be sewed
MakeTorus(GeoPoint, GeoVector, double, double)
Creates a torus (a ring). The surface is split into four faces.
public static Solid MakeTorus(GeoPoint location, GeoVector normal, double radius1, double radius2)
Parameters
locationGeoPointcentre of the torus
normalGeoVectoraxis of the torus, the normal of the plane of the ring
radius1doublemajor radius, the distance from the centre to the centre line of the tube
radius2doubleminor radius, the radius of the tube; must be smaller than
radius1
Returns
- Solid
the torus, or null when the faces cannot be sewed
PlaneIntersection(Face[], Plane)
Not implemented, throws NotImplementedException. Use GetPlaneIntersection(PlaneSurface), GetPlaneIntersection(PlaneSurface) or GetPlaneIntersection(PlaneSurface) to intersect with a plane.
[Obsolete("Not implemented, throws NotImplementedException; use GetPlaneIntersection of Face, Shell or Solid. Will be removed in the next minor version.")]
public static Make3D PlaneIntersection(Face[] faces, Plane plane)
Parameters
Returns
- Make3D
nothing, throws
Rotate(IGeoObject, Axis, SweepAngle, SweepAngle, Project)
Rotates a Face, a Path or a curve around axis to make a solid or a
shell: a face, or a closed planar path or curve (which is made a face first), yields a Solid; an
open or not planar path or curve yields the Shell of the rotated curves. The rotation starts at
offset from the current position of the object and sweeps rotation; a full
rotation (2*Math.PI) gives a closed shape without start and end faces. Splines in a path are split at their
corners, so that each resulting face is smooth. Returns null for other kinds of objects and when the construction
fails. See also MakeRevolution(IGeoObject, GeoPoint, GeoVector, double, Project).
public static IGeoObject Rotate(IGeoObject faceShellPathCurve, Axis axis, SweepAngle rotation, SweepAngle offset, Project project)
Parameters
faceShellPathCurveIGeoObjectthe face, path or curve to rotate
axisAxisthe axis of rotation
rotationSweepAnglethe angle to sweep, 2*Math.PI for a full rotation
offsetSweepAnglethe angle, measured from the current position of the object, at which the rotation starts
projectProjectcurrently not used, may be null
Returns
- IGeoObject
the solid or shell, or null
SewFaces(Face[], bool)
Sews the faces together: edges of different faces with the same geometry become one edge shared by both faces, and each set of faces connected this way is returned as a Shell. The faces are modified (their edges and vertices are replaced), connections to faces not in the array are cut first. The shells are oriented outward. A shell without open edges (OpenEdges) bounds a volume and can be turned into a solid with MakeSolid(Shell). This is how the primitives of this class and the STL import build their solids.
public static Shell[] SewFaces(Face[] faces, bool edgesArUnambiguous = false)
Parameters
Returns
- Shell[]
the shells, one per connected set of faces
SewFacesAndShells(GeoObjectList)
Takes all faces and shells from the given list and sews them together with SewFaces(Face[], bool): faces with common edges are connected to shells. Other objects in the list are ignored. Returns null when the list contains less than two faces (counting the faces of the shells).
public static GeoObjectList SewFacesAndShells(GeoObjectList select)
Parameters
selectGeoObjectListfaces and shells to sew
Returns
- GeoObjectList
the resulting shells, or null
Union(Solid, Solid)
Returns the union of the two given Solids, same as Unite(Solid, Solid). If the solids are disjunct, null will be returned.
public static Solid Union(Solid s1, Solid s2)
Parameters
Returns
- Solid
union of the two solids or null