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.;
double dy = 3.;
size_t useg = 3;
size_t vseg = 3;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
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;
size_t vseg = 4;
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;
size_t vseg = 4;
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.;
double radius2 = 1.;
double height = 2.;
bool isTop = true;
bool isBottom = true;
size_t rseg = 8;
size_t vseg = 4;
Sphere
AMCAX::SubD::MeshMakeSphere class is used to construct spheres.
double radius = 2.;
size_t rseg = 8;
size_t vseg = 4;
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;
size_t minorSeg = 4;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int edge = 0;
int vfirst, vlast;
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459
Get all vertex indices of a face in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int face = 0;
Get all edge indices of a face in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int face = 0;
Get face indices adjacent to an input edge in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int edge = 0;
Get edge indices adjacent to an input vertex in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int vertex = 0;
Get face indices adjacent to an input vertex in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int vertex = 0;
Get face indices adjacent to an input face in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
int face = 0;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
std::vector< AMCAX::Point3 > points = { p1,p2,p3 };
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.;
double dy = 3.;
size_t useg = 1;
size_t vseg = 1;
std::vector< int > vlist{ 0,1,2 };
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.;
double dy = 3.;
size_t useg = 1;
size_t vseg = 1;
int face = 0;
int edge1 = index_e[1];
int edge2 = index_e[2];
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
size_t useg = 3;
size_t vseg = 3;
int eid = 4;
double t = 0.5;
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
size_t useg = 3;
size_t vseg = 3;
std::vector<int> vlist = { 5, 10 };
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
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 Welding
AMCAX::SubD::MeshSeparate class provides separation functionality.
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 3.;
size_t segY = 3.;
size_t segZ = 3.;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 3.;
size_t segY = 3.;
size_t segZ = 3.;
std::vector< int >elist = { 0, 3, 6 };
{
}
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
double h = 2.;
std::vector< int > index_v = { 5,7,9,11 };
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
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
double h = 2.;
std::vector< int > index_e = { 0,1,2 };
Apply transformation to face list in PolyMesh
double dx = 10.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
double h = 2.;
std::vector< int > index_f = { 50,70,90,100 };
Extrusion
AMCAX::SubD::MeshExtrude class provides extrusion functionality.
Extrude edges
AMCAX::SubD::MeshExtrude::ExtrudeEdge is used to extrude edges.
double dx = 3.;
double dy = 3.;
size_t useg = 1;
size_t vseg = 1;
std::vector<int> edgeid = { 0, 1, 2 };
std::vector<int> 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.
size_t segX = 3;
size_t segY = 3;
size_t segZ = 3;
std::vector<int> faceid = { 0, 2, 5 };
std::vector<int> 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.;
double dy = 3.;
size_t useg = 3;
size_t vseg = 3;
double dist = 0.2;
bool isConnect = true;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
std::vector<int> face_id = { 1,3, 4 };
int face = 0;
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
std::vector<int> face_id = { 1,3, 4 };
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;
size_t vseg = 4;
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;
size_t vseg = 4;
size_t sumTime = 1;
size_t sumTime2 = 3;
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;
size_t vseg = 4;
size_t sumTime = 3;
static AMCAX_API void Loop(PolyMesh *mesh, size_t subTime)
Loop subdivision for input mesh, only for 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;
size_t vseg = 4;
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
std::string fileNameOBJ = "1.obj";
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.;
double dy = 10.;
double dz = 10.;
size_t segX = 10.;
size_t segY = 10.;
size_t segZ = 10.;
std::string fileNameOBJ = "sampleResult.obj";
std::string fileNameOFF = "sampleResult.off";
static AMCAX_API bool WriteMesh(const std::string &filename, PolyMesh *mesh)
write a PolyMesh to a file