maspack.geometry
Class MeshFactory

java.lang.Object
  extended by maspack.geometry.MeshFactory

public class MeshFactory
extends java.lang.Object

Creates specific instances of polygonal meshes.


Nested Class Summary
static class MeshFactory.VertexSet
           
 
Constructor Summary
MeshFactory()
           
 
Method Summary
static void addQuadAnnularSector(PolygonalMesh mesh, double r0, double r1, double ang, int nr, int nang, RigidTransform3d XLM, maspack.geometry.MeshFactory.VertexMap vtxMap)
          Adds an annular sector to an existing mesh.
static void addQuadCylindricalSection(PolygonalMesh mesh, double r, double h, double ang, int nh, int nang, boolean outward, RigidTransform3d XLM, maspack.geometry.MeshFactory.VertexMap vtxMap)
          Adds a cylindrical section to an existing mesh.
static void addQuadRectangle(PolygonalMesh mesh, double wx, double wy, int nx, int ny, RigidTransform3d XLM, maspack.geometry.MeshFactory.VertexMap vtxMap)
          Adds a quad rectangle to an existing mesh.
static void addQuadSphericalSection(PolygonalMesh mesh, double r, double maxthe, double maxphi, int nthe, int nphi, RigidTransform3d XLM, maspack.geometry.MeshFactory.VertexMap vtxMap)
          Adds a spherical section to an existing mesh.
static void addQuadToroidalSection(PolygonalMesh mesh, double rmajor, double rminor, double maxthe, int nmajor, int nminor, RigidTransform3d XLM, maspack.geometry.MeshFactory.VertexMap vtxMap)
          Adds a toroidal section to an existing mesh.
static void closeSeams(PolygonalMesh mesh)
           
static PolygonalMesh createBox(double wx, double wy, double wz)
          Creates a triangle-based box mesh, with two triangles per side, centered on the origin.
static PolygonalMesh createBox(double wx, double wy, double wz, double x, double y, double z)
          Creates a triangle-based box mesh, with two triangles per side, centered at a prescribed location.
static PolygonalMesh createCone(double rtop, double rbot, double h, int nsides)
           
static PolygonalMesh createCylinder(double r, double h, int nslices)
          Creates a triangular cylindrical mesh centered on the origin with the main axis aligned with the z axis.
static PolygonalMesh createCylinder(double r, double h, int nslices, int nr, int nh)
          Creates a triangular cylindrical mesh centered on the origin with the main axis aligned with the z axis.
static PolygonalMesh createExtendedTorus(double rmajor, double rminor, double xlen, int nmajor, int nminor)
          Creates a quad extended torus mesh in the x-y plane.
static PolygonalMesh createHollowedBox(double wx, double wy, double wz, double r, int nsegs)
          Creates a box with a cylindrical indentation in the top, parallel to the y axis, with a radius of r and approximated by nsegs segments.
static PolygonalMesh createIcosahedralSphere(double r, int divisions)
           
static PolygonalMesh createIcosahedralSphere(double r, Point3d c, int divisions)
           
static PolygonalMesh createIcosahedron(double r)
           
static PolygonalMesh createOctahedralSphere(double r, int divisions)
           
static PolygonalMesh createOctahedralSphere(double r, Point3d c, int divisions)
           
static PolygonalMesh createOctahedron(double r)
           
static PolygonalMesh createPlane(double wx, double wy)
          Create a open planar mesh, composed of two triangles, centered on the origin and with normals directed along the z axis.
static PolygonalMesh createPlane(double wx, double wy, int xdiv, int ydiv)
          Create a open planar mesh, composed of triangles, centered on the origin and with normals directed along the z axis.
static PolygonalMesh createPointedCylinder(double r, double h, double tiph, int nsides)
           
static PolygonalMesh createPrism(double[] xy, double h)
           
static PolygonalMesh createPrism(double[] xyTop, double[] xyBot, double h)
           
static PolygonalMesh createQuadAnnularSector(double r0, double r1, double ang, int nr, int nang)
          Creates an annular sector.
static PolygonalMesh createQuadBox(double wx, double wy, double wz)
          Creates a quad-based box mesh, with one quad per side, centered on the origin.
static PolygonalMesh createQuadBox(double wx, double wy, double wz, double x, double y, double z)
          Creates a quad-based box mesh, with one quad per side, centered at a prescribed location.
static PolygonalMesh createQuadBox(double wx, double wy, double wz, Point3d center, int nx, int ny, int nz)
          Creates a quad-based box mesh, with a specified mesh resolution in each direction, and centered at a defined center point.
static PolygonalMesh createQuadBoxNew(double wx, double wy, double wz, Point3d center, int nx, int ny, int nz)
           
static PolygonalMesh createQuadCone(double rtop, double rbot, double h, int nsides)
           
static PolygonalMesh createQuadCone(double rtop, double rbot, double h, int nsides, int nh)
           
static PolygonalMesh createQuadCylinder(double r, double h, int nslices, int nr, int nh)
          Creates a quad cylindrical mesh centered on the origin with the main axis aligned with the z axis.
static PolygonalMesh createQuadCylindricalSection(double r, double h, double ang, int nh, int nang)
          Creates a cylindrical section.
static PolygonalMesh createQuadExtendedTorus(double rmajor, double rminor, double xlen, int nmajor, int nminor)
          Creates a quad extended torus mesh in the x-y plane.
static PolygonalMesh createQuadPrism(double[] xy, double h)
           
static PolygonalMesh createQuadPrism(double[] xyTop, double[] xyBot, double h)
           
static PolygonalMesh createQuadPrism(double[] xyTop, double[] xyBot, double h, int nH)
           
static PolygonalMesh createQuadRectangle(double wx, double wy, int nx, int ny)
          Create a quad rectangle mesh.
static PolygonalMesh createQuadRoundedBox(double wx, double wy, double wz, int nslices)
          Creates a box with rounded ends on the x-axis ends.
static PolygonalMesh createQuadRoundedBox(double wx, double wy, double wz, int nx, int ny, int nz, int nslices)
          Creates a box with rounded ends on the x-axis ends, and with a specified mesh resolution in the x, y, and z directions.
static PolygonalMesh createQuadRoundedCylinder(double r, double h, int nslices, int nsegs, boolean flatBottom)
          Creates a cylinder with rounded (spherical) ends on the z-axis ends.
static PolygonalMesh createQuadSphere(double r, int nslices)
           
static PolygonalMesh createQuadSphere(double r, int nslices, double x, double y, double z)
           
static PolygonalMesh createQuadSphere(double r, int nslices, int nlevels, double x, double y, double z)
           
static PolygonalMesh createQuadSphericalSection(double r, double maxthe, double maxphi, int nthe, int nphi)
          Creates a spherical section.
static PolygonalMesh createQuadToroidalSection(double rmajor, double rminor, double maxthe, int nmajor, int nminor)
          Creates a toroidal section.
static PolygonalMesh createQuadTorus(double rmajor, double rminor, int nmajor, int nminor)
          Creates a quad torus mesh in the x-y plane.
static PolygonalMesh createQuadTube(double r0, double r1, double h, int nslices, int nr, int nh)
          Creates a quad tube mesh centered on the origin with the main axis aligned with the z axis.
static PointMesh createRandomPointMesh(int numv, double width)
          Creates a random point mesh, centered on the orgin, with a specified number of vertices and width.
static PolygonalMesh createRefinedMesh(PolygonalMesh orig, int res)
          Creates a refined version of a polygonal mesh, based on Nagata patches applied with a given resolution.
static PolygonalMesh createRoundedBox(double wx, double wy, double wz, int nslices)
          Creates a triangular box mesh with rounded ends on the z-axis ends.
static PolygonalMesh createRoundedBox(double wx, double wy, double wz, int nx, int ny, int nz, int nslices)
          Creates a triangule box mesh with rounded ends on the x-axis ends, and with a specified mesh resolution in the x, y, and z directions.
static PolygonalMesh createRoundedCylinder(double r, double h, int nslices, int nsegs, boolean flatBottom)
          Creates a triangular cylinder mesh with rounded (spherical) ends on the z-axis ends.
static PolygonalMesh createSphere(double r, int nslices)
           
static PolygonalMesh createSphere(double r, int nslices, double x, double y, double z)
           
static PolygonalMesh createSphere(double r, int nslices, int nlevels)
           
static PolylineMesh createSphericalPolyline(double r, int nslices, int nlevels)
           
static PolygonalMesh createTorus(double rmajor, double rminor, int nmajor, int nminor)
          Creates a triangular torus mesh in the x-y plane.
static PolygonalMesh createTube(double r0, double r1, double h, int nslices, int nr, int nh)
          Creates a triangular tube mesh centered on the origin with the main axis aligned with the z axis.
static boolean fillHoles(PolygonalMesh mesh)
           
static java.util.ArrayList<HalfEdge> findBorderEdges(PolygonalMesh mesh)
           
static PolygonalMesh getFlipped(PolygonalMesh mesh)
           
static PolygonalMesh getIntersection(PolygonalMesh mesh1, PolygonalMesh mesh2)
           
static PolygonalMesh getSubtraction(PolygonalMesh mesh1, PolygonalMesh mesh2)
           
static PolygonalMesh getUnion(PolygonalMesh mesh1, PolygonalMesh mesh2)
           
static void main(java.lang.String[] args)
           
static void mergeVertices(PolygonalMesh mesh, Vertex3d vtx1, Vertex3d vtx2)
           
static PolygonalMesh subdivide(PolygonalMesh orig)
           
static PolygonalMesh subdivide(PolygonalMesh orig, int numIters)
           
static void triangulateFaceCentroid(Face face)
           
static void triangulateFaceCentroid(PolygonalMesh mesh)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeshFactory

public MeshFactory()
Method Detail

addQuadRectangle

public static void addQuadRectangle(PolygonalMesh mesh,
                                    double wx,
                                    double wy,
                                    int nx,
                                    int ny,
                                    RigidTransform3d XLM,
                                    maspack.geometry.MeshFactory.VertexMap vtxMap)
Adds a quad rectangle to an existing mesh. The rectangle is centered on the x-y plane of a local coordinate frame L, with face normals directed along the z axis. A transform XLM is supplied to map L into the mesh coordinate frame M.

Parameters:
mesh - existing mesh to add the rectangle to
wx - width of the rectangle along the local x axis
wy - width of the rectangle along the local y axis
nx - number of subdivisions along the local x axis
ny - number of subdivisions along the local y axis
XLM - transform from the local coordinate frame L to mesh coordinates M.
vtxMap - spatial hash map storing all existing vertices in the mesh. New vertices will be created as needed and added to both this map and to the mesh.

createQuadRectangle

public static PolygonalMesh createQuadRectangle(double wx,
                                                double wy,
                                                int nx,
                                                int ny)
Create a quad rectangle mesh. The rectangle is centered on the x-y plane of a local coordinate frame L, with face normals directed along the z axis.

Parameters:
wx - width of the rectangle along the local x axis
wy - width of the rectangle along the local y axis
nx - number of subdivisions along the local x axis
ny - number of subdivisions along the local y axis

addQuadAnnularSector

public static void addQuadAnnularSector(PolygonalMesh mesh,
                                        double r0,
                                        double r1,
                                        double ang,
                                        int nr,
                                        int nang,
                                        RigidTransform3d XLM,
                                        maspack.geometry.MeshFactory.VertexMap vtxMap)
Adds an annular sector to an existing mesh. The sector is centered on the x-y plane of a local coordinate frame L, with the bisecting axis parallel to x and face normals directed along the z axis. It extends for +/-ang/2 on either side of the x axis, and from an inner radius r0 to an outer radius r1; if ang is 2 PI and r0 is 0 then the sector becomes a circle with radius r1. The mesh is made of quads except for those faces connected to the origin. A transform XLM is supplied to map L into the mesh coordinate frame M.

Parameters:
mesh - existing mesh to add the annular sector to
r0 - inner radius of the sector
r1 - outer radius of the sector
ang - total angular extent of the sector
nr - number of radial slices
nang - number of angular slices
XLM - transform from the local coordinate frame L to mesh coordinates M.
vtxMap - spatial hash map storing all existing vertices in the mesh. New vertices will be created as needed and added to both this map and to the mesh.

createQuadAnnularSector

public static PolygonalMesh createQuadAnnularSector(double r0,
                                                    double r1,
                                                    double ang,
                                                    int nr,
                                                    int nang)
Creates an annular sector. The sector is centered on the x-y plane of a local coordinate frame L, with the bisecting axis parallel to x and face normals directed along the z axis. For more details, see the documentation for addQuadAnnularSector(maspack.geometry.PolygonalMesh, double, double, double, int, int, maspack.matrix.RigidTransform3d, maspack.geometry.MeshFactory.VertexMap).

Parameters:
r0 - inner radius of the annular sector
r1 - outer radius of the annular sector
ang - total angular extent of the annular sector
nr - number of radial slices
nang - number of angular slices

addQuadCylindricalSection

public static void addQuadCylindricalSection(PolygonalMesh mesh,
                                             double r,
                                             double h,
                                             double ang,
                                             int nh,
                                             int nang,
                                             boolean outward,
                                             RigidTransform3d XLM,
                                             maspack.geometry.MeshFactory.VertexMap vtxMap)
Adds a cylindrical section to an existing mesh. The section is centered on the z axis of a local coordinate frame L, extending for a length +/-h/2 above and below the origin. The angular extent of the section is +/-ang/2 on either side of the x axis; if ang is 2 PI then the section will become a whole cylinder. Normals are oriented to face outwards. The sector is made of quads. A transform XLM is supplied to map L into the mesh coordinate frame M.

Parameters:
mesh - existing mesh to add the section to
r - radius of the cylinder
h - height of the cylinder
ang - total angular extent of the section
nh - number of height slices
nang - number of angular slices
outward - if true, the normals are facing outward
XLM - transform from the local coordinate frame L to mesh coordinates M.
vtxMap - spatial hash map storing all existing vertices in the mesh. New vertices will be created as needed and added to both this map and to the mesh.

createQuadCylindricalSection

public static PolygonalMesh createQuadCylindricalSection(double r,
                                                         double h,
                                                         double ang,
                                                         int nh,
                                                         int nang)
Creates a cylindrical section. The section is centered on the z axis of a local coordinate frame L, extending for a length +/-h/2 above and below the origin. The angular extent of the section is +/-ang/2 on either side of the x axis; if ang is 2 PI then the section will become a whole cylinder. Normals are oriented to face outwards. The sector is made of quads.

Parameters:
r - radius of the cylinder
h - height of the cylinder
ang - total angular extent of the section
nh - number of height slices
nang - number of angular slices

addQuadSphericalSection

public static void addQuadSphericalSection(PolygonalMesh mesh,
                                           double r,
                                           double maxthe,
                                           double maxphi,
                                           int nthe,
                                           int nphi,
                                           RigidTransform3d XLM,
                                           maspack.geometry.MeshFactory.VertexMap vtxMap)
Adds a spherical section to an existing mesh. The section is centered on the origin of a local coordinate frame L, with the poles located on the z axis. A point on the sphere is defined using spherical coordinates r, theta, and phi, with theta giving the azimuth angle with respect to the x axis and phi giving the elevation angle with respect to the z axis. The x, y, z and values are hence
 r sin(phi) cos(theta), r sin(phi) sin(theta), r cos(phi)
 
The extent of phi is given by [0, maxphi], while the extend of theta is given by [-maxthe, maxthe]. Specifying maxphi and maxthe as both PI results in a complete sphere. Normals are oriented to face outwards. The section is made of quads, except at the poles. A transform XLM is supplied to map L into the mesh coordinate frame M.

Note: to avoid degenarte quads near the south pole of the section, maxphi is rounded to PI if it is within 1e-4 of PI.

Parameters:
mesh - existing mesh to add the section to
r - radius of the section
maxthe - maximum azimuth angle about either side of the x axis
maxphi - maximum elevation angle with respect to the z axis
nthe - number of slices for the azimuth
nphi - number of slices for the elevation
XLM - transform from the local coordinate frame L to mesh coordinates M.
vtxMap - spatial hash map storing all existing vertices in the mesh. New vertices will be created as needed and added to both this map and to the mesh.

createQuadSphericalSection

public static PolygonalMesh createQuadSphericalSection(double r,
                                                       double maxthe,
                                                       double maxphi,
                                                       int nthe,
                                                       int nphi)
Creates a spherical section. The section is centered on the origin of a local coordinate frame L, with the poles located on the z axis. A point on the sphere is defined using spherical coordinates r, theta, and phi, with theta giving the azimuth angle with respect to the x axis and phi giving the elevation angle with respect to the z axis. For additional information, see the documentation for addQuadSphericalSection(maspack.geometry.PolygonalMesh, double, double, double, int, int, maspack.matrix.RigidTransform3d, maspack.geometry.MeshFactory.VertexMap).

Parameters:
r - radius of the section
maxthe - maximum azimuth angle about either side of the x axis
maxphi - maximum elevation angle with respect to the z axis
nthe - number of slices for the azimuth
nphi - number of slices for the elevation

addQuadToroidalSection

public static void addQuadToroidalSection(PolygonalMesh mesh,
                                          double rmajor,
                                          double rminor,
                                          double maxthe,
                                          int nmajor,
                                          int nminor,
                                          RigidTransform3d XLM,
                                          maspack.geometry.MeshFactory.VertexMap vtxMap)
Adds a toroidal section to an existing mesh. The section lies in the x-y plane and curves about the z-axis for an angular distance of maxthe, with the starting end aligned with the x-z plane. The major radius from the z axis to the center of the tube is given by rmajor, and the minor radius of the tube section itself is given by rminor.

The section made out of quads. It is closed into a torus if maxthe is equal to 2*Math.PI.

Parameters:
mesh - existing mesh to add the section to
rmajor - major radius of bending about the z axis
rminor - minor radius of the tube
maxthe - maximum bending angle about the z axis
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius
XLM - transform from the local coordinate frame L to mesh coordinates M.
vtxMap - spatial hash map storing all existing vertices in the mesh. New vertices will be created as needed and added to both this map and to the mesh.

createQuadToroidalSection

public static PolygonalMesh createQuadToroidalSection(double rmajor,
                                                      double rminor,
                                                      double maxthe,
                                                      int nmajor,
                                                      int nminor)
Creates a toroidal section. The section lies in the x-y plane and curves about the z-axis for an angular distance of maxthe, with the starting end aligned with the x-z plane. For additional information, see the documentation for addQuadToroidalSection(maspack.geometry.PolygonalMesh, double, double, double, int, int, maspack.matrix.RigidTransform3d, maspack.geometry.MeshFactory.VertexMap).

Parameters:
rmajor - major radius of bending about the z axis
rminor - minor radius of the tube
maxthe - maximum bending angle about the z axis
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius

createQuadTorus

public static PolygonalMesh createQuadTorus(double rmajor,
                                            double rminor,
                                            int nmajor,
                                            int nminor)
Creates a quad torus mesh in the x-y plane.

Parameters:
rmajor - major radius of the torus
rminor - minor radius of the torus
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius

createTorus

public static PolygonalMesh createTorus(double rmajor,
                                        double rminor,
                                        int nmajor,
                                        int nminor)
Creates a triangular torus mesh in the x-y plane.

Parameters:
rmajor - major radius of the torus
rminor - minor radius of the torus
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius

createQuadExtendedTorus

public static PolygonalMesh createQuadExtendedTorus(double rmajor,
                                                    double rminor,
                                                    double xlen,
                                                    int nmajor,
                                                    int nminor)
Creates a quad extended torus mesh in the x-y plane. An extended torus is a torus with straight sections added in the middle, giving a shape similar to a chain link. The straight sections are parallel to the x-axis.

Parameters:
rmajor - major radius of the torus
rminor - minor radius of the torus
xlen - length of the straight sections
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius

createExtendedTorus

public static PolygonalMesh createExtendedTorus(double rmajor,
                                                double rminor,
                                                double xlen,
                                                int nmajor,
                                                int nminor)
Creates a quad extended torus mesh in the x-y plane. An extended torus is a torus with straight sections added in the middle, giving a shape similar to a chain link. The straight sections are parallel to the x-axis.

Parameters:
rmajor - major radius of the torus
rminor - minor radius of the torus
xlen - length of the straight sections
nmajor - number of slices along the major radius
nminor - number of slices along the minor radius

createPlane

public static PolygonalMesh createPlane(double wx,
                                        double wy)
Create a open planar mesh, composed of two triangles, centered on the origin and with normals directed along the z axis. Texture coordinates are also created for each triangle.

Parameters:
wx - width in the x direction
wy - width in the y direction

createPlane

public static PolygonalMesh createPlane(double wx,
                                        double wy,
                                        int xdiv,
                                        int ydiv)
Create a open planar mesh, composed of triangles, centered on the origin and with normals directed along the z axis. Texture coordinates are also created for each triangle.

Parameters:
wx - width in the x direction
wy - width in the y direction
xdiv - number of divisions in x (>=1)
ydiv - number of divisions in y (>=1)

createQuadBox

public static PolygonalMesh createQuadBox(double wx,
                                          double wy,
                                          double wz)
Creates a quad-based box mesh, with one quad per side, centered on the origin.

Parameters:
wx - width in the x direction
wy - width in the y direction
wz - width in the z direction

createQuadBox

public static PolygonalMesh createQuadBox(double wx,
                                          double wy,
                                          double wz,
                                          double x,
                                          double y,
                                          double z)
Creates a quad-based box mesh, with one quad per side, centered at a prescribed location.

Parameters:
wx - width in the x direction
wy - width in the y direction
wz - width in the z direction
x - center location along the x axis
y - center location along the y axis
z - center location along the z axis

createBox

public static PolygonalMesh createBox(double wx,
                                      double wy,
                                      double wz)
Creates a triangle-based box mesh, with two triangles per side, centered on the origin.

Parameters:
wx - width in the x direction
wy - width in the y direction
wz - width in the z direction

createBox

public static PolygonalMesh createBox(double wx,
                                      double wy,
                                      double wz,
                                      double x,
                                      double y,
                                      double z)
Creates a triangle-based box mesh, with two triangles per side, centered at a prescribed location.

Parameters:
wx - width in the x direction
wy - width in the y direction
wz - width in the z direction
x - center location along the x axis
y - center location along the y axis
z - center location along the z axis

subdivide

public static PolygonalMesh subdivide(PolygonalMesh orig,
                                      int numIters)

subdivide

public static PolygonalMesh subdivide(PolygonalMesh orig)

createQuadBox

public static PolygonalMesh createQuadBox(double wx,
                                          double wy,
                                          double wz,
                                          Point3d center,
                                          int nx,
                                          int ny,
                                          int nz)
Creates a quad-based box mesh, with a specified mesh resolution in each direction, and centered at a defined center point.

Parameters:
wx - width in the x direction
wy - width in the y direction
wz - width in the z direction
center - center of the box
nx - number of subdivisions along x
ny - number of subdivisions along y
nz - number of subdivisions along z

createQuadBoxNew

public static PolygonalMesh createQuadBoxNew(double wx,
                                             double wy,
                                             double wz,
                                             Point3d center,
                                             int nx,
                                             int ny,
                                             int nz)

triangulateFaceCentroid

public static void triangulateFaceCentroid(PolygonalMesh mesh)

createCylinder

public static PolygonalMesh createCylinder(double r,
                                           double h,
                                           int nslices)
Creates a triangular cylindrical mesh centered on the origin with the main axis aligned with the z axis.

Parameters:
r - outer radius of the cylinder
h - height of the cylinder
nslices - number of segments about the z axis

createCylinder

public static PolygonalMesh createCylinder(double r,
                                           double h,
                                           int nslices,
                                           int nr,
                                           int nh)
Creates a triangular cylindrical mesh centered on the origin with the main axis aligned with the z axis.

Parameters:
r - outer radius of the cylinder
h - height of the cylinder
nslices - number of segments about the z axis
nr - number of radial segments on each end cap
nh - number of height segments along the z axis

triangulateFaceCentroid

public static void triangulateFaceCentroid(Face face)

createQuadCylinder

public static PolygonalMesh createQuadCylinder(double r,
                                               double h,
                                               int nslices,
                                               int nr,
                                               int nh)
Creates a quad cylindrical mesh centered on the origin with the main axis aligned with the z axis. All faces are quads except for those at the center of each end cap.

Parameters:
r - outer radius of the cylinder
h - height of the cylinder
nslices - number of segments about the z axis
nr - number of radial segments on each end cap
nh - number of height segments along the z axis

createQuadTube

public static PolygonalMesh createQuadTube(double r0,
                                           double r1,
                                           double h,
                                           int nslices,
                                           int nr,
                                           int nh)
Creates a quad tube mesh centered on the origin with the main axis aligned with the z axis.

Parameters:
r0 - inner radius of the tube
r1 - outer radius of the tube
h - height of the tube
nslices - number of segments about the z axis
nr - number of radial segments on each end
nh - number of height segments along the z axis

createTube

public static PolygonalMesh createTube(double r0,
                                       double r1,
                                       double h,
                                       int nslices,
                                       int nr,
                                       int nh)
Creates a triangular tube mesh centered on the origin with the main axis aligned with the z axis.

Parameters:
r0 - inner radius of the tube
r1 - outer radius of the tube
h - height of the tube
nslices - number of segments about the z axis
nr - number of radial segments on each end
nh - number of height segments along the z axis

createPointedCylinder

public static PolygonalMesh createPointedCylinder(double r,
                                                  double h,
                                                  double tiph,
                                                  int nsides)

createOctahedralSphere

public static PolygonalMesh createOctahedralSphere(double r,
                                                   int divisions)

createOctahedralSphere

public static PolygonalMesh createOctahedralSphere(double r,
                                                   Point3d c,
                                                   int divisions)

createIcosahedralSphere

public static PolygonalMesh createIcosahedralSphere(double r,
                                                    Point3d c,
                                                    int divisions)

createIcosahedralSphere

public static PolygonalMesh createIcosahedralSphere(double r,
                                                    int divisions)

createOctahedron

public static PolygonalMesh createOctahedron(double r)

createIcosahedron

public static PolygonalMesh createIcosahedron(double r)

createQuadSphere

public static PolygonalMesh createQuadSphere(double r,
                                             int nslices)

createSphere

public static PolygonalMesh createSphere(double r,
                                         int nslices)

createSphere

public static PolygonalMesh createSphere(double r,
                                         int nslices,
                                         int nlevels)

createQuadSphere

public static PolygonalMesh createQuadSphere(double r,
                                             int nslices,
                                             double x,
                                             double y,
                                             double z)

createQuadSphere

public static PolygonalMesh createQuadSphere(double r,
                                             int nslices,
                                             int nlevels,
                                             double x,
                                             double y,
                                             double z)

createSphere

public static PolygonalMesh createSphere(double r,
                                         int nslices,
                                         double x,
                                         double y,
                                         double z)

createQuadRoundedBox

public static PolygonalMesh createQuadRoundedBox(double wx,
                                                 double wy,
                                                 double wz,
                                                 int nslices)
Creates a box with rounded ends on the x-axis ends. The rounding is done circularly, in the x-y plane. The x width (specified by wx) gives the distance between the centers of each semi-circle which is used to create the rounding. The mesh is quad-based, except at the center of the semi-circles.

Parameters:
wx - width along the x axis
wy - width along the y axis
wz - width along the z axis
nslices - gives the number of sides used to approximate each semi-circlar end

createQuadRoundedBox

public static PolygonalMesh createQuadRoundedBox(double wx,
                                                 double wy,
                                                 double wz,
                                                 int nx,
                                                 int ny,
                                                 int nz,
                                                 int nslices)
Creates a box with rounded ends on the x-axis ends, and with a specified mesh resolution in the x, y, and z directions. The rounding is done circularly, in the x-y plane. The x width (specified by wx) gives the distance between the centers of each semi-circle which is used to create the rounding. The mesh is quad based, except at the center of the semi-circles.

Parameters:
wx - width along the x axis
wy - width along the y axis
wz - width along the z axis
nx - number of mesh divisions along x between the rounding centers
ny - number of mesh divisions along y between the rounding centers
nz - number of mesh divisions along z between the rounding centers
nslices - gives the number of sides used to approximate each semi-circlar end

createRoundedBox

public static PolygonalMesh createRoundedBox(double wx,
                                             double wy,
                                             double wz,
                                             int nx,
                                             int ny,
                                             int nz,
                                             int nslices)
Creates a triangule box mesh with rounded ends on the x-axis ends, and with a specified mesh resolution in the x, y, and z directions. The rounding is done circularly, in the x-y plane. The x width (specified by wx) gives the distance between the centers of each semi-circle which is used to create the rounding.

Parameters:
wx - width along the x axis
wy - width along the y axis
wz - width along the z axis
nx - number of mesh divisions along x between the rounding centers
ny - number of mesh divisions along y between the rounding centers
nz - number of mesh divisions along z between the rounding centers
nslices - gives the number of sides used to approximate each semi-circlar end

createRoundedBox

public static PolygonalMesh createRoundedBox(double wx,
                                             double wy,
                                             double wz,
                                             int nslices)
Creates a triangular box mesh with rounded ends on the z-axis ends. The rounding is done circularly, in the z-x plane. The z width (specified by wz) gives the distance between the centers of each semi-circle which is used to create the rounding.

Parameters:
wx - width along the x axis
wy - width along the y axis
wz - width along the z axis
nslices - gives the number of sides used to approximate each semi-circlar end

createQuadRoundedCylinder

public static PolygonalMesh createQuadRoundedCylinder(double r,
                                                      double h,
                                                      int nslices,
                                                      int nsegs,
                                                      boolean flatBottom)
Creates a cylinder with rounded (spherical) ends on the z-axis ends. This is really just a sphere with a cylinder inserted along the equator. The cylinder portion is divided into a prescribed number of segments (nsegs). The mesh is made of quads except at the poles of the rounded ends. An argument flatBottom can be used to request that the bottom of cylinder is flat instead of rounded.

Parameters:
r - radius of the cylinder
h - height of the cylinder along the z axis (measured as the distance between the centers of the rounded ends.
nslices - number of sides used to form the cylinder. This will be rounded up to a multiple of 4.
nsegs - number of segments along the length of the cylinder. This must be greater than 0.
flatBottom - if true, indicates that the bottom of the cylinder should be flat instead of rounded.

createRoundedCylinder

public static PolygonalMesh createRoundedCylinder(double r,
                                                  double h,
                                                  int nslices,
                                                  int nsegs,
                                                  boolean flatBottom)
Creates a triangular cylinder mesh with rounded (spherical) ends on the z-axis ends. This is really just a sphere with a cylinder inserted along the equator. The cylinder portion is divided into a prescribed number of segments (nsegs). The mesh is made of triangles. An argument flatBottom can be used to request that the bottom of cylinder is flat instead of rounded.

Parameters:
r - radius of the cylinder
h - height of the cylinder along the z axis (measured as the distance between the centers of the rounded ends.
nslices - number of sides used to form the cylinder. This will be rounded up to a multiple of 4.
nsegs - number of segments along the length of the cylinder. This must be greater than 0.
flatBottom - if true, indicates that the bottom of the cylinder should be flat instead of rounded.

createQuadCone

public static PolygonalMesh createQuadCone(double rtop,
                                           double rbot,
                                           double h,
                                           int nsides,
                                           int nh)

createQuadCone

public static PolygonalMesh createQuadCone(double rtop,
                                           double rbot,
                                           double h,
                                           int nsides)

createCone

public static PolygonalMesh createCone(double rtop,
                                       double rbot,
                                       double h,
                                       int nsides)

createQuadPrism

public static PolygonalMesh createQuadPrism(double[] xy,
                                            double h)

createPrism

public static PolygonalMesh createPrism(double[] xy,
                                        double h)

createQuadPrism

public static PolygonalMesh createQuadPrism(double[] xyTop,
                                            double[] xyBot,
                                            double h)

createQuadPrism

public static PolygonalMesh createQuadPrism(double[] xyTop,
                                            double[] xyBot,
                                            double h,
                                            int nH)

createPrism

public static PolygonalMesh createPrism(double[] xyTop,
                                        double[] xyBot,
                                        double h)

createHollowedBox

public static PolygonalMesh createHollowedBox(double wx,
                                              double wy,
                                              double wz,
                                              double r,
                                              int nsegs)
Creates a box with a cylindrical indentation in the top, parallel to the y axis, with a radius of r and approximated by nsegs segments.


createSphericalPolyline

public static PolylineMesh createSphericalPolyline(double r,
                                                   int nslices,
                                                   int nlevels)

createRandomPointMesh

public static PointMesh createRandomPointMesh(int numv,
                                              double width)
Creates a random point mesh, centered on the orgin, with a specified number of vertices and width.


createRefinedMesh

public static PolygonalMesh createRefinedMesh(PolygonalMesh orig,
                                              int res)
Creates a refined version of a polygonal mesh, based on Nagata patches applied with a given resolution. The supplied mesh must be triangular, and its normals will be computed automatically.


getIntersection

public static PolygonalMesh getIntersection(PolygonalMesh mesh1,
                                            PolygonalMesh mesh2)

getUnion

public static PolygonalMesh getUnion(PolygonalMesh mesh1,
                                     PolygonalMesh mesh2)

getSubtraction

public static PolygonalMesh getSubtraction(PolygonalMesh mesh1,
                                           PolygonalMesh mesh2)

main

public static void main(java.lang.String[] args)

findBorderEdges

public static java.util.ArrayList<HalfEdge> findBorderEdges(PolygonalMesh mesh)

fillHoles

public static boolean fillHoles(PolygonalMesh mesh)

closeSeams

public static void closeSeams(PolygonalMesh mesh)

mergeVertices

public static void mergeVertices(PolygonalMesh mesh,
                                 Vertex3d vtx1,
                                 Vertex3d vtx2)

getFlipped

public static PolygonalMesh getFlipped(PolygonalMesh mesh)