AMCAX Kernel
Geometry kernel for CAD/CAE/CAM
AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
PolyMesh Subdivision Modeling

Basic Shape Construction

Basic shape include plane rectangle, cube, cylinder, cone, truncated cone, sphere, torus, etc.

MeshMakeRectangle(Plane Rectangle)

AMCAX::SubD::MeshMakeRectangle mkRect(frame, 3, 3, 3, 3);
AMCAX::SubD::PolyMesh* mesh1 = mkRect.BuildMesh();
Class of PolyMesh API for make a plane rectangle.
Definition MeshMakeRectangle.hpp:15
Class of TMSpline 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:885

MeshMakeCube(Cube)

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh2 = makeCube.BuildMesh();
Class of PolyMesh API for make a cube.
Definition MeshMakeCube.hpp:15

MeshMakeCylinder(Cylinder)

AMCAX::SubD::MeshMakeCylinder makeCylinder(frame, 2.0, 5.0);
AMCAX::SubD::PolyMesh* mesh3 = makeCylinder.BuildMesh();
Class of PolyMesh API for make a cylinder.
Definition MeshMakeCylinder.hpp:15

MeshMakeCone(Cone)

AMCAX::SubD::MeshMakeCone meshmakeCone1(1., 1.);
AMCAX::SubD::PolyMesh* mesh4 = meshmakeCone1.BuildMesh();
Class of PolyMesh API for make a cone.
Definition MeshMakeCone.hpp:15

MeshMakeCone(Truncated Cone)

AMCAX::SubD::MeshMakeCone meshmakeCone2(frame, 2., 1., 2.);
AMCAX::SubD::PolyMesh* mesh5 = meshmakeCone2.BuildMesh();

MeshMakeSphere(Sphere)

double r = 2.1;
AMCAX::SubD::PolyMesh* mesh6 = sphere.BuildMesh();
Class of PolyMesh API for make a sphere.
Definition MeshMakeSphere.hpp:15

MeshMakeTorus(Torus)

AMCAX::SubD::MeshMakeTorus maketorus(2.0, 0.5, 8, 4);
AMCAX::SubD::PolyMesh* mesh7 = maketorus.BuildMesh();
Class of PolyMesh API for make a Torus.
Definition MeshMakeTorus.hpp:15

Basic Edit Feature

Basic edit feature include traversal, face addition, split, deletion, separation, and weld.

Traversal

AMCAX::SubD::MeshTool class provides traversal features, such as the following:
AMCAX::SubD::MeshTool::EdgeVertexIndexs is used to get the indices of the vertices of a specific edge in the PolyMesh;
AMCAX::SubD::MeshTool::FaceVertexIndexs is used to get the indices of all vertices of a specific face in the PolyMesh;
AMCAX::SubD::MeshTool::FaceEdgeIndexs is used to get the indices of all edges of a specific face in the PolyMesh;
AMCAX::SubD::MeshTool::EdgeFaceIndexs is used to get the indices of the faces adjacent to a given edge in the PolyMesh;
AMCAX::SubD::MeshTool::VertEdgeIndexs is used to get the indices of edges adjacent to a given vertex in the PolyMesh;
AMCAX::SubD::MeshTool::VertFaceIndexs is used to get the indices of faces adjacent to a given vertex in the PolyMesh;
AMCAX::SubD::MeshTool::FaceAdjacentFaces is used to get the indices of faces adjacent to a given face in the PolyMesh.

Get the indices of the vertices of a specific edge in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int edge = 0;
int vfirst, vlast;
AMCAX::SubD::MeshTool::EdgeVertexIndexs(mesh, edge, vfirst, vlast);
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. @detail If the edge is boundary, return the order of vertic...
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Get the indices of all vertices of a specific face in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
std::vector< int > index = AMCAX::SubD::MeshTool::FaceVertexIndexs(mesh, face);
static AMCAX_API std::vector< int > FaceVertexIndexs(PolyMesh *mesh, int face)
Return the vertices of the face in PolyMesh.

Get the indices of all edges of a specific face in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int face = 0;
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 the indices of the faces adjacent to a given edge in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int edge = 0;
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 the indices of edges adjacent to a given vertex in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int vertex = 0;
std::vector< int > index_e1 = 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 the indices of faces adjacent to a given vertex in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int vertex = 0;
std::vector< int > index_f1 = 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 the indices of faces adjacent to a given face in the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
int face = 0;
std::vector< int > index_f2 = 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.

Add Face

AMCAX::SubD::MeshInsertFace class provides functionality for adding face. Specifically:
AMCAX::SubD::MeshInsertFace::AddSingleFace is used to add a single face constructed from points to the PolyMesh;
AMCAX::SubD::MeshInsertFace::EmbedSingleFace is used to add a single face constructed from certain PolyMesh vertices;
AMCAX::SubD::MeshInsertFace::AddFaceByEdge is used to add a single face constructed from two edges.

Add a single face constructed from points to the PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
AMCAX::Point3 p1(10., 2., 1.);
AMCAX::Point3 p2(12., 5., 3.);
AMCAX::Point3 p3(15., 7., 6.);
std::vector< AMCAX::Point3 > p = { p1,p2,p3 };
static AMCAX_API MPolyFace * AddSingleFace(PolyMesh *mesh, std::vector< Point3 > &points)
add a single face constructed from points to PolyMesh

Add a single face constructed from certain PolyMesh vertices to the PolyMesh

The vertices must be boundary vertices, meaning that they are surrounded by boundary edges (edges whose associated faces are less than 2) or have no edges.

AMCAX::SubD::MeshMakeRectangle mkRect(frame, 15, 15, 1, 1);
AMCAX::SubD::PolyMesh* mesh3 = mkRect.BuildMesh();
int face = 0;
std::vector< int > index_v = AMCAX::SubD::MeshTool::FaceVertexIndexs(mesh3, face);
std::vector< int > vlist{ 0,1,2 };
static AMCAX_API MPolyFace * EmbedSingleFace(PolyMesh *mesh, std::vector< int > &vlist)
add a single face constructed from some PolyMesh vert

Add a single face constructed from two edges to the PolyMesh

These two edges must be boundary edges.

AMCAX::SubD::MeshMakeRectangle mkRect(frame, 15, 15, 1, 1);
AMCAX::SubD::PolyMesh* mesh3 = mkRect.BuildMesh();
int face = 0;
std::vector< int > index_e = AMCAX::SubD::MeshTool::FaceEdgeIndexs(mesh3, face);
AMCAX::SubD::MeshInsertFace::AddFaceByEdge(mesh3, index_e[1], index_e[2]);
static AMCAX_API MPolyFace * AddFaceByEdge(PolyMesh *mesh, int edge1, int edge2)
add a single face constructed from two edges

Split

AMCAX::SubD::MeshSplit class provides split functionality.
To be down.

Deletion

AMCAX::SubD::MeshReduce class provides deletion functionality. AMCAX::SubD::MeshReduce::DeleteFaces is used to delete faces from the PolyMesh (it allows you to delete any number of faces while leaving holes);AMCAX::SubD::MeshReduce::DeleteIsolatedVertices is used to delete all isolated vertices in the PolyMesh.

Delete Face

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
std::vector<int> face_id = { 1,3, 4 };
static AMCAX_API void DeleteFaces(PolyMesh *mesh, const std::vector< int > &flist)
Delete given faces in PolyMesh.

Separation and Weld

AMCAX::SubD::MeshSeparate class provides separation functionality, while the AMCAX::SubD::MeshWeld class provides weld functionality.

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
std::vector< int >edge = { 1,2,3 };
//MeshSeparate
std::cout << r << std::endl;
//MeshWeld
static AMCAX_API bool SeparateEdges(PolyMesh *mesh, std::vector< int > &edges)
Separate edges into each other, the result edges will remain on top of each other until they are move...
static AMCAX_API void MeshWeldEdges(PolyMesh *mesh, 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

Topological Modeling Function

Topological modeling function include transformation, extrusion, thicken, hole fill, etc.

Transformation

AMCAX::SubD::MeshTransform class provides transformation functionality. Transformation include:
AMCAX::SubD::MeshTransform::TransformMeshEdges Applies transformations to a list of edges in a PolyMesh;
AMCAX::SubD::MeshTransform::TransformMeshFaces;
AMCAX::SubD::MeshTransform::TransformMeshVertices Applies transformations to a list of vertices in a PolyMesh.

Apply Transformation to a List of Edges in PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsfF.SetTransformation(trsfMove);
std::vector< int > index_e = { 0,1,2 };
trsfF.TransformMeshEdges(mesh, index_e);
constexpr const CoordType & Coord() const noexcept
Get the intrinsic coordinate of the direction.
Definition DirectionT.hpp:213
constexpr const DirectionT< Scalar, DIM > & Direction() const noexcept
Get the main direction (z direction) in 3D.
Definition FrameT.hpp:441
Class of transforming a PolyMesh.
Definition MeshTransform.hpp:15
AMCAX_API void TransformMeshEdges(PolyMesh *mesh, const std::vector< int > &elist)
Applying transformations to edge 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:1102
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Apply Transformation to a List of Faces in PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsfF.SetTransformation(trsfMove);
std::vector< int > index_f = { 50,70,90,100 };
trsfF.TransformMeshFaces(mesh, index_f);
AMCAX_API void TransformMeshFaces(PolyMesh *mesh, const std::vector< int > &flist)
Applying transformations to face list in a PolyMesh.

Apply Transformation to a List of Vertices in PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
double h = 2.;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
trsfMove.SetTranslation(vh);
trsfF.SetTransformation(trsfMove);
std::vector< int > index_v = { 5,7,9,11 };
trsfF.TransformMeshVertices(mesh, index_v);
AMCAX_API void TransformMeshVertices(PolyMesh *mesh, const std::vector< int > &vlist)
Applying transformations to vert list in a PolyMesh.

Extrusion

AMCAX::SubD::MeshExtrude class provides extrusion functionality. Among which, AMCAX::SubD::MeshExtrude::ExtrudeEdge is used to extrude edges, and AMCAX::SubD::MeshExtrude::ExtrudeFace is used to extrude faces.
To be down.

Thicken

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

double h = 2;
AMCAX::SubD::MeshMakeRectangle mkRect(frame, 3, 3, 3, 3);
AMCAX::SubD::PolyMesh* mesh = mkRect.BuildMesh();
static AMCAX_API bool ThickenMesh(PolyMesh *mesh, double dist, bool isConnect=true)
Thicken a mesh to give a approximately shell or thickness.

Hole Fill

AMCAX::SubD::MeshFillHole class provides hole filling functionality. Among which, AMCAX::SubD::MeshFillHole::FillAllHole fills all holes in a PolyMesh, and AMCAX::SubD::MeshFillHole::FillSingleHole fills a specific hole in a PolyMesh (by inputting the edge ID of any edge of the hole).

Fill All Holes in PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
std::vector<int> face_id = { 1,3, 4 };
int face = 0;
std::vector< int > index_e = AMCAX::SubD::MeshTool::FaceEdgeIndexs(mesh, face);
bool r = AMCAX::SubD::MeshFillHole::FillSingleHole(mesh, index_e[1]);
std::cout << r << std::endl;
static AMCAX_API bool FillSingleHole(PolyMesh *mesh, int edge)
fill hole whit input edge by use a singel polygon face

Fill a Specific Hole in PolyMesh

AMCAX::SubD::MeshMakeCube makeCube(frame, 10, 10, 10, 10, 10, 10);
AMCAX::SubD::PolyMesh* mesh = makeCube.BuildMesh();
std::vector<int> face_id = { 1,3, 4 };
std::cout << r2 << std::endl;
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. Catmull-Clark subdivision supports any mesh, while Loop subdivision only supports triangular meshes (which can be obtained through triangulation using AMCAX::SubD::MeshTool::MeshTriangles).

Catmull-Clark Subdivision

double r = 1;
double h = 1;
AMCAX::SubD::MeshMakeCone meshmakeCone(r, h);
AMCAX::SubD::PolyMesh* mesh = meshmakeCone.BuildMesh();
static AMCAX_API void CatmullClark(PolyMesh *mesh, size_t subTime)
Catmull-Clark Subdivision for input mesh.

Additionally, to improve the subdivision efficiency, the kernel also provides AMCAX::SubD::MeshSubdivideRenderCC (for full quadrilateral meshes). The result is the same as Catmull-Clark subdivision, with the same number of vertices, but the sequence is different, so it cannot be compared. Additionally, full quadrilateral meshes can be obtained after one subdivision using AMCAX::MeshSubdivideHE::CatmullClark(mesh, 1).

double r = 1;
double h = 1;
AMCAX::SubD::MeshMakeCone meshmakeCone(r, h);
AMCAX::SubD::PolyMesh* mesh = meshmakeCone.BuildMesh();
bool r1 = subdivide.DoCatmullClark(mesh, 1);
std::cout << r1 << std::endl;
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

double r = 1;
double h = 1;
AMCAX::SubD::MeshMakeCone meshmakeCone3(r, h);
AMCAX::SubD::PolyMesh* mesh3 = meshmakeCone.BuildMesh();
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.

Additionally, to improve the subdivision efficiency, the kernel also provides AMCAX::SubD::MeshSubdivideRenderLoop (for full triangular meshes). The result is the same as Loop subdivision, with the same number of vertices, but the sequence is different, so it cannot be compared.

Import and Export of OBJ and OFF File

Import

//OBJ
std::string fileNameOBJ5 = "MeshSubdivideRenderLoop.obj";
AMCAX::SubD::PolyMeshIO::LoadMesh(fileNameOBJ5, mesh4);
static AMCAX_API bool LoadMesh(const std::string &filename, PolyMesh *&mesh)
load a PolyMesh from a file

Export

//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