AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
PolyMesh Subdivision Modeling

Building Basic Primitives

Basic primitives include planar rectangles, cubes, cylinders, cones, frustums, spheres, tori, etc.

Planar Rectangle

AMCAX::SubD::MeshMakeRectangle class is used to construct planar rectangles.

double dx = 3.;// The size in x direction
double dy = 3.;// The size in y direction
size_t useg = 3;// The number of segments in x direction
size_t vseg = 3;// The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(frame, dx, dy, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
Class of PolyMesh API for make a plane rectangle.
Definition MeshMakeRectangle.hpp:15
Class of PolyMesh structure The Low Level API functions are not exported for this version.
Definition PolyMesh.hpp:23
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:887

Cube

AMCAX::SubD::MeshMakeCube class is used to construct cubes.

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
Class of PolyMesh API for make a cube.
Definition MeshMakeCube.hpp:15

Cylinder

AMCAX::SubD::MeshMakeCylinder class is used to construct cylinders.

double radius = 2.;
double height = 5.;
bool isTop = true;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cylinder
AMCAX::SubD::MeshMakeCylinder mkCylinder(frame, radius, height, isTop, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCylinder.BuildMesh();
Class of PolyMesh API for make a cylinder.
Definition MeshMakeCylinder.hpp:15

Cone

AMCAX::SubD::MeshMakeCone class is used to construct cones.

double radius = 1.;
double height = 1.;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone
AMCAX::SubD::MeshMakeCone mkCone(radius, height, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();
Class of PolyMesh API for make a cone.
Definition MeshMakeCone.hpp:15

Frustum

AMCAX::SubD::MeshMakeCone class is used to construct frustums.

double radius1 = 2.;// The bottom radius
double radius2 = 1.;// The top radius
double height = 2.;
bool isTop = true;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone frustum
AMCAX::SubD::MeshMakeCone mkCone(frame, radius1, radius2, height, isTop, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();

Sphere

AMCAX::SubD::MeshMakeSphere class is used to construct spheres.

double radius = 2.;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a sphere
AMCAX::SubD::MeshMakeSphere mksphere(radius, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mksphere.BuildMesh();
Class of PolyMesh API for make a sphere.
Definition MeshMakeSphere.hpp:15

Torus

AMCAX::SubD::MeshMakeTorus class is used to construct tori.

double majorRadius = 2.;
double minorRadius = 0.5;
size_t majorSeg = 8;// The number of segments in major rotation
size_t minorSeg = 4;// The number of segments in minor rotation
// Construct a torus
AMCAX::SubD::MeshMakeTorus mktorus(majorRadius, minorRadius, majorSeg, minorSeg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mktorus.BuildMesh();
Class of PolyMesh API for make a Torus.
Definition MeshMakeTorus.hpp:15

Basic Editing Functions

Basic editing functions include traversal, face addition, refinement, deletion, separation, welding, etc.

Traversal

AMCAX::SubD::MeshTool class provides traversal functionality, as follows:

Get vertex indices of an edge in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the vertices of the edge
int edge = 0;// The index of edge
int vfirst, vlast;
AMCAX::SubD::MeshTool::EdgeVertexIndexs(mesh, edge, vfirst, vlast);
// Get the position of the vertex
static AMCAX_API const Point3 & Position(PolyMesh *mesh, int vert)
Return the position of vert in PolyMesh.
static AMCAX_API void EdgeVertexIndexs(PolyMesh *mesh, int edge, int &vfirst, int &vlast)
Get the vertices of the edge in PolyMesh.
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Get all vertex indices of a face in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the indices of vertices in face
int face = 0;// The index of face
std::vector< int > index_v = AMCAX::SubD::MeshTool::FaceVertexIndexs(mesh, face);
// Get the position of the vertex
static AMCAX_API std::vector< int > FaceVertexIndexs(PolyMesh *mesh, int face)
Return the vertices of the face in PolyMesh.

Get all edge indices of a face in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the edges of the face
int face = 0;// The index of face
std::vector< int > index_e = AMCAX::SubD::MeshTool::FaceEdgeIndexs(mesh, face);
static AMCAX_API std::vector< int > FaceEdgeIndexs(PolyMesh *mesh, int face)
Return the edges of the face in PolyMesh.

Get face indices adjacent to an input edge in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the faces adjacent to the edge
int edge = 0;// The index of edge
std::vector< int > index_f = AMCAX::SubD::MeshTool::EdgeFaceIndexs(mesh, edge);
static AMCAX_API std::vector< int > EdgeFaceIndexs(PolyMesh *mesh, int edge)
Return the faces adjacent to the input edge in PolyMesh.

Get edge indices adjacent to an input vertex in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the edges adjacent to the vertex
int vertex = 0;// The index of vertex
std::vector< int > index_e = AMCAX::SubD::MeshTool::VertEdgeIndexs(mesh, vertex);
static AMCAX_API std::vector< int > VertEdgeIndexs(PolyMesh *mesh, int vert)
Return the edges adjacent to the input vertex in PolyMesh.

Get face indices adjacent to an input vertex in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the faces adjacent to the vertex
int vertex = 0;// The index of vertex
std::vector< int > index_f = AMCAX::SubD::MeshTool::VertFaceIndexs(mesh, vertex);
static AMCAX_API std::vector< int > VertFaceIndexs(PolyMesh *mesh, int vert)
Return the faces adjacent to the input vertex in PolyMesh.

Get face indices adjacent to an input face in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Get the faces adjacent to the face
int face = 0;// The index of face
std::vector< int > index_f = AMCAX::SubD::MeshTool::FaceAdjacentFaces(mesh, face);
static AMCAX_API std::vector< int > FaceAdjacentFaces(PolyMesh *mesh, int face)
Return the faces adjacent to the input face in PolyMesh.

Adding Faces

AMCAX::SubD::MeshInsertFace class provides face addition functionality. Details are as follows:

Add a single face constructed from points to PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Add a single face constructed from points to PolyMesh
AMCAX::Point3 p1(10., 2., 1.);
AMCAX::Point3 p2(12., 5., 3.);
AMCAX::Point3 p3(15., 7., 6.);
std::vector< AMCAX::Point3 > points = { p1,p2,p3 };// The points for constructing face
static AMCAX_API MPolyFace * AddSingleFace(PolyMesh *mesh, const std::vector< Point3 > &points)
add a single face constructed from points to PolyMesh

Add a single face constructed from some PolyMesh vertices to PolyMesh

The vertices must be boundary vertices, meaning vertices that have boundary edges (edges belonging to fewer than 2 faces) or no edges around them.

double dx = 3.;// The size in x direction
double dy = 3.;// The size in y direction
size_t useg = 1;// The number of segments in x direction
size_t vseg = 1;// The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(frame, dx, dy, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Add a single face constructed from some PolyMesh vert
std::vector< int > vlist{ 0,1,2 };// The vert for constructing face
static AMCAX_API MPolyFace * EmbedSingleFace(PolyMesh *mesh, const std::vector< int > &vlist)
add a single face constructed from some PolyMesh vert

Add a single face constructed from two edges to PolyMesh

These two edges must be boundary edges.

double dx = 3.;// The size in x direction
double dy = 3.;// The size in y direction
size_t useg = 1;// The number of segments in x direction
size_t vseg = 1;// The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(frame, dx, dy, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Add a single face constructed from two edges
int face = 0;// The index of face
std::vector< int > index_e = AMCAX::SubD::MeshTool::FaceEdgeIndexs(mesh, face);
int edge1 = index_e[1];// The first edge
int edge2 = index_e[2];// The second edge
static AMCAX_API MPolyFace * AddFaceByEdge(PolyMesh *mesh, int edge1, int edge2)
add a single face constructed from two edges

Refinement

AMCAX::SubD::MeshSplit class provides refinement functionality.

Split loop faces

AMCAX::Point2 p0(1., 1.); // The min corner point
AMCAX::Point2 p1(10., 10.); // The max corner point
size_t useg = 3; // The number of segments in x direction
size_t vseg = 3; // The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(p0, p1, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Split a loop faces generated from edge
int eid = 4;
double t = 0.5;
split.SplitLoop(mesh, eid, t);
Class of PolyMesh API for split mesh.
Definition MeshSplit.hpp:14
static AMCAX_API bool SplitLoop(PolyMesh *mesh, const int eId, double t=0.5)
Split a loop faces generated from edge.
PointT< double, 2 > Point2
2D point
Definition PointT.hpp:456

Split faces along vertices

AMCAX::Point2 p0(1., 1.); // The min corner point
AMCAX::Point2 p1(10., 10.); // The max corner point
size_t useg = 3; // The number of segments in x direction
size_t vseg = 3; // The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(p0, p1, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Split faces by sequentially cross vertices in Mesh
std::vector<int> vlist = { 5, 10 };
split.SplitFaceWithVertex(mesh, vlist);
static AMCAX_API bool SplitFaceWithVertex(PolyMesh *mesh, const std::vector< int > &vlist)
Split faces by sequentially cross vertices in Mesh.

Deletion

AMCAX::SubD::MeshReduce class provides deletion functionality.

Delete faces

AMCAX::SubD::MeshReduce::DeleteFaces is used to delete faces in PolyMesh (can freely delete any number of faces and leave holes).

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Delete given faces
std::vector<int> face_id = { 1,3, 4 };// The faces to be delete
static AMCAX_API void DeleteFaces(PolyMesh *mesh, const std::vector< int > &flist)
Delete given faces in PolyMesh.

Separation and Welding

AMCAX::SubD::MeshSeparate class provides separation functionality.

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 3.;// The number of segments in x direction
size_t segY = 3.;// The number of segments in y direction
size_t segZ = 3.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Separate edges into each other
std::vector< int >elist = { 0, 3, 6 };
static AMCAX_API bool SeparateEdges(PolyMesh *mesh, const std::vector< int > &edges)
Separate edges into each other, the result edges will remain on top of each other until they are move...

Welding

AMCAX::SubD::MeshWeld class provides welding functionality.

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 3.;// The number of segments in x direction
size_t segY = 3.;// The number of segments in y direction
size_t segZ = 3.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Separate edges into each other
std::vector< int >elist = { 0, 3, 6 };
// Weld
{
// Weld them to inner edges
}
static AMCAX_API void MeshWeldEdges(PolyMesh *mesh, const std::vector< int > &elist, double tolerance=0.01)
find all edges in a PolyMesh by input edges with tolerance and Weld them to inner edges
static AMCAX_API bool FilterVoidWeldEdges(PolyMesh *mesh, std::vector< int > &elist)
filter input edges and remove edges which can not be weld

Topological Modeling Functions

Topological modeling functions include transformation, extrusion, thickening, hole filling, etc.

Transformation

AMCAX::SubD::MeshTransform class provides transformation functionality.

Apply transformation to vertex list in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Set the transformation as the translation
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsf.SetTransformation(trsfMove);
// Applying transformations to the vertex list
std::vector< int > index_v = { 5,7,9,11 };
trsf.TransformMeshVertices(mesh, index_v);
constexpr const CoordType & Coord() const noexcept
Get the intrinsic coordinate of the direction.
Definition DirectionT.hpp:186
constexpr const DirectionT< Scalar, DIM > & Direction() const noexcept
Get the main direction (z direction) in 3D.
Definition FrameT.hpp:443
Class of transforming a PolyMesh.
Definition MeshTransform.hpp:15
AMCAX_API void TransformMeshVertices(PolyMesh *mesh, const std::vector< int > &vlist)
Applying transformations to vert list in a PolyMesh.
AMCAX_API void SetTransformation(const Transformation3 &t)
Set the Transformation to be applied.
constexpr void SetTranslation(const VectorT< OtherScalar, DIM > &vec) noexcept
Set the transformation as the translation.
Definition TransformationT.hpp:311
TransformationT< double, 3 > Transformation3
3D transformation
Definition TransformationT.hpp:1115
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Apply transformation to edge list in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Set the transformation as the translation
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsf.SetTransformation(trsfMove);
// Applying transformations to the edge list
std::vector< int > index_e = { 0,1,2 };
trsf.TransformMeshEdges(mesh, index_e);
AMCAX_API void TransformMeshEdges(PolyMesh *mesh, const std::vector< int > &elist)
Applying transformations to edge list in a PolyMesh.

Apply transformation to face list in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Set the transformation as the translation
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsf.SetTransformation(trsfMove);
// Applying transformations to the face list
std::vector< int > index_f = { 50,70,90,100 };
trsf.TransformMeshFaces(mesh, index_f);
AMCAX_API void TransformMeshFaces(PolyMesh *mesh, const std::vector< int > &flist)
Applying transformations to face list in a PolyMesh.

Extrusion

AMCAX::SubD::MeshExtrude class provides extrusion functionality.

Extrude edges

AMCAX::SubD::MeshExtrude::ExtrudeEdge is used to extrude edges.

double dx = 3.;// The size in x direction
double dy = 3.;// The size in y direction
size_t useg = 1;// The number of segments in x direction
size_t vseg = 1;// The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(frame, dx, dy, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Extrude the edges in PolyMesh
std::vector<int> edgeid = { 0, 1, 2 };
std::vector<int> edgeid_new; // Indices of the edges after extrusion
extrude.ExtrudeEdge(mesh, edgeid, edgeid_new);
Class of PolyMesh API for extrude method only change the topology, the new result is coincide the old...
Definition MeshExtrude.hpp:15
static AMCAX_API bool ExtrudeEdge(PolyMesh *mesh, const std::vector< int > &edges, std::vector< int > &edgesNew)
extrude the edges in PolyMesh

Extrude faces

AMCAX::SubD::MeshExtrude::ExtrudeFace is used to extrude faces.

AMCAX::Point3 p0(0., 0., 0.);// The min corner point
AMCAX::Point3 p1(12., 12., 12.); // The max corner point
size_t segX = 3; // The number of segments in x direction
size_t segY = 3; // The number of segments in y direction
size_t segZ = 3; // The number of segments in z direction
// Construct a rectangle
AMCAX::SubD::MeshMakeCube mkCube(p0, p1, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Extrude the faces in PolyMesh
std::vector<int> faceid = { 0, 2, 5 };
std::vector<int> faceid_new; // Indices of the faces after extrusion
extrude.ExtrudeFace(mesh, faceid, faceid_new);
static AMCAX_API bool ExtrudeFace(PolyMesh *mesh, const std::vector< int > &faces, std::vector< int > &facesNew)
extrude the faces in PolyMesh

Thickening

AMCAX::SubD::MeshOffset class provides thickening functionality.

double dx = 3.;// The size in x direction
double dy = 3.;// The size in y direction
size_t useg = 3;// The number of segments in x direction
size_t vseg = 3;// The number of segments in y direction
// Construct a rectangle
AMCAX::SubD::MeshMakeRectangle mkRect(frame, dx, dy, useg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
// Thicken a mesh
double dist = 0.2;// The reference thickening distance
bool isConnect = true;
AMCAX::SubD::MeshOffset::ThickenMesh(mesh, dist, isConnect);
static AMCAX_API bool ThickenMesh(PolyMesh *mesh, double dist, bool isConnect=true)
Thicken a mesh to give a approximately shell or thickness.

Hole Filling

AMCAX::SubD::MeshFillHole class provides hole filling functionality.

Fill a single hole in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Delete given faces
std::vector<int> face_id = { 1,3, 4 };
// Get the edges of the face
int face = 0;
std::vector< int > index_e = AMCAX::SubD::MeshTool::FaceEdgeIndexs(mesh, face);
// Fill a hole with input edge
static AMCAX_API bool FillSingleHole(PolyMesh *mesh, int edge)
fill hole whit input edge by use a singel polygon face

Note: The input edge ID can be any edge ID of the hole.

Fill all holes in PolyMesh

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// Delete given faces
std::vector<int> face_id = { 1,3, 4 };
// Fill all holes in PolyMesh
static AMCAX_API bool FillAllHole(PolyMesh *mesh)
fill all holes in PolyMesh by use a singel polygon face

Mesh Subdivision

Mesh subdivision includes two types: Catmull-Clark subdivision and Loop subdivision. They will be introduced one by one below.

Catmull-Clark Subdivision

Catmull-Clark subdivision supports arbitrary meshes.

double radius = 1.;
double height = 1.;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone
AMCAX::SubD::MeshMakeCone mkCone(radius, height, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();
// Do Catmull-Clark Subdivision for input mesh
size_t sumTime = 3;
static AMCAX_API void CatmullClark(PolyMesh *mesh, size_t subTime)
Catmull-Clark Subdivision for input mesh.

To improve subdivision efficiency, the kernel provides AMCAX::SubD::MeshSubdivideRenderCC (for all-quad meshes). Its results are the same as Catmull-Clark subdivision results, with the same number of vertices/faces, but different order, so they cannot be compared. Note: An all-quad mesh can be obtained by one subdivision AMCAX::SubD::MeshSubdivideHE::CatmullClark(mesh, 1).

double radius = 1.;
double height = 1.;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone
AMCAX::SubD::MeshMakeCone mkCone(radius, height, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();
// Do Catmull-Clark subdivision for input mesh
size_t sumTime = 1;
// Do Catmull-Clark subdivision for input mesh
size_t sumTime2 = 3;
subdivide.DoCatmullClark(mesh, sumTime2);
Class of PolyMesh API for quadrilateral mesh Catmull-Clark subdivision.
Definition MeshSubdivideRender.hpp:17
AMCAX_API bool DoCatmullClark(PolyMesh *mesh, size_t subtime)
Do Catmull-Clark subdivision.

Loop Subdivision

Loop subdivision only supports triangle meshes (an all-triangle mesh can be obtained by triangulation AMCAX::SubD::MeshTool::MeshTriangles).

double radius = 1.;
double height = 1.;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone
AMCAX::SubD::MeshMakeCone mkCone(radius, height, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();
// Make a mesh to triangular mesh
// Do Loop subdivision for input mesh
size_t sumTime = 3;
static AMCAX_API void Loop(PolyMesh *mesh, size_t subTime)
Loop subdivision for input mesh, only for triangular mesh.
static AMCAX_API void MeshTriangles(PolyMesh *mesh)
Make a mesh to triangular mesh.

To improve subdivision efficiency, the kernel provides AMCAX::SubD::MeshSubdivideRenderLoop (for all-triangle meshes). Its results are the same as Loop subdivision results, with the same number of vertices/faces, but different order, so they cannot be compared.

double radius = 1.;
double height = 1.;
bool isBottom = true;
size_t rseg = 8;// The number of segments in rotation
size_t vseg = 4;// The number of segments in vertical
// Construct a cone
AMCAX::SubD::MeshMakeCone mkCone(radius, height, isBottom, rseg, vseg);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCone.BuildMesh();
// Make a mesh to triangular mesh
// Do Loop subdivision for input mesh
size_t sumTime = 3;
subloop.DoLoop(mesh, sumTime);
Class of PolyMesh API for triangle mesh Loop subdividion.
Definition MeshSubdivideRender.hpp:50
AMCAX_API bool DoLoop(PolyMesh *mesh, size_t subtime)
Do Loop subdivision.

Import and Export

Import

// OBJ
AMCAX::SubD::PolyMesh* mesh1 = nullptr;
std::string fileNameOBJ = "1.obj";
// OFF
AMCAX::SubD::PolyMesh* mesh2 = nullptr;
std::string fileNameOFF = "2.off";
static AMCAX_API bool LoadMesh(const std::string &filename, PolyMesh *&mesh)
load a PolyMesh from a file

Export

double dx = 10.;// The size in x direction
double dy = 10.; // The size in y direction
double dz = 10.;// The size in z direction
size_t segX = 10.;// The number of segments in x direction
size_t segY = 10.;// The number of segments in y direction
size_t segZ = 10.;// The number of segments in z direction
// Construct a cube
AMCAX::SubD::MeshMakeCube mkCube(frame, dx, dy, dz, segX, segY, segZ);
// Build and get the result PolyMesh
AMCAX::SubD::PolyMesh* mesh = mkCube.BuildMesh();
// OBJ
std::string fileNameOBJ = "sampleResult.obj";
// OFF
std::string fileNameOFF = "sampleResult.off";
static AMCAX_API bool WriteMesh(const std::string &filename, PolyMesh *mesh)
write a PolyMesh to a file