AMCAX Kernel
Geometry kernel for CAD/CAE/CAM
AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
T Mesh Spline Modeling

Basic Geometry Construction

Basic geometries include planar rectangle, cube, cylinder, cone, truncated cone, sphere, torus, and others.

TMSplineMakeRectangle(Planar Rectangle)

AMCAX::TMS::TMSplineMakeRectangle mkRect(frame, 3, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp1 = mkRect.BuildSpline();
Class of TMSpline structure The Low Level API functions are not exported for this version.
Definition TMSpline.hpp:30
Class of TMSpline API for make a plane rectangle.
Definition TMSplineMakeRectangle.hpp:15
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:885

TMSplineMakeCube(Cube)

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp2 = mkCube.BuildSpline();
Class of TMSpline API for make a cube.
Definition TMSplineMakeCube.hpp:15
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

TMSplineMakeCylinder(Cylinder)

AMCAX::TMS::TMSplineMakeCylinder mkCylinder(frame, 1.0, 4.0, true, true, 8, 4);
AMCAX::TMS::TMSpline* tsp3 = mkCylinder.BuildSpline();
Class of TMSpline API for make a cylinder.
Definition TMSplineMakeCylinder.hpp:15

TMSplineMakeCone(Cone)

AMCAX::TMS::TMSplineMakeCone mkCone(1.0, 2.0, true, 8, 4);
AMCAX::TMS::TMSpline* tsp4 = mkCone.BuildSpline();
Class of TMSpline API for make a cone.
Definition TMSplineMakeCone.hpp:16

TMSplineMakeCone(Truncated Cone)

AMCAX::TMS::TMSplineMakeCone mkCone2(frame, 2.0, 1.0, 2.0, true, true, 8, 4);
AMCAX::TMS::TMSpline* tsp5 = mkCone2.BuildSpline();

TMSplineMakeSphere(Sphere)

AMCAX::TMS::TMSplineMakeSphere mkSphere(10.0, 8, 8);
AMCAX::TMS::TMSpline* tsp6 = mkSphere.BuildSpline();
Class of TMSpline API for make a sphere.
Definition TMSplineMakeSphere.hpp:15

TMSplineMakeTorus(Torus)

AMCAX::TMS::TMSplineMakeTorus mkTorus(20.0, 10.0, 8, 16);
AMCAX::TMS::TMSpline* tsp7 = mkTorus.BuildSpline();
Class of TMSpline API for make a Torus.
Definition TMSplineMakeTorus.hpp:15

Basic Edit Function

Basic edit function include traversal, add faces, split, deletion, separation, and weld.

Traversal

The AMCAX::TMS::TMSplineTool class provides traversal functions, as detailed below:
AMCAX::TMS::TMSplineTool::FaceVertexIndexs get all vertex indices of a specific face in the TMSpline;
AMCAX::TMS::TMSplineTool::EdgeVertexIndexs get vertex indices of a specific edge in the TMSpline;
AMCAX::TMS::TMSplineTool::FaceEdgeIndexs get all edge indices of a specific face in the TMSpline;
AMCAX::TMS::TMSplineTool::EdgeFaceIndexs get indices of faces adjacent to the specified edge in the TMSpline.

Get all vertex indices of a specific face in the TMSpline

AMCAX::Point3 bb_min(0.00, 0.00, 0.00), bb_max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(bb_min, bb_max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
int face = 0;
std::vector< int > index_v = AMCAX::TMS::TMSplineTool::FaceVertexIndexs(tsp, face);
static AMCAX_API std::vector< int > FaceVertexIndexs(TMSpline *tsp, int face)
Return the vertices of the face in TMSpline.

Get vertex indices of a specific edge in the TMSpline

AMCAX::Point3 bb_min(0.00, 0.00, 0.00), bb_max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(bb_min, bb_max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
int edge = 0;
int vfirst, vlast;
static AMCAX_API void EdgeVertexIndexs(TMSpline *tsp, int edge, int &vfirst, int &vlast)
Get the vertices of the edge in TMSpline.

Get all edge indices of a specific face in the TMSpline

AMCAX::Point3 bb_min(0.00, 0.00, 0.00), bb_max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(bb_min, bb_max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
int face = 0;
std::vector< int > index_e = AMCAX::TMS::TMSplineTool::FaceEdgeIndexs(tsp, face);
static AMCAX_API std::vector< int > FaceEdgeIndexs(TMSpline *tsp, int face)
Return the edge of the face in TMSpline.

Get indices of faces adjacent to a specified edge in the TMSpline

AMCAX::Point3 bb_min(0.00, 0.00, 0.00), bb_max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(bb_min, bb_max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
int edge = 0;
std::vector< int >index_f = AMCAX::TMS::TMSplineTool::EdgeFaceIndexs(tsp, edge);
static AMCAX_API std::vector< int > EdgeFaceIndexs(TMSpline *tsp, int edge)
Return the faces adjacent to edge in TMSpline.

Add Face

The AMCAX::TMS::TMSplineAddFace class provides add functionality. AMCAX::TMS::TMSplineAddFace::AddSingleFace adds a single face composed of a set of points to a TMSpline; AMCAX::TMS::TMSplineAddFace::AddFaceByEdge adds a single face composed of two edges to a TMSpline. In addition, AMCAX::TMS::TMSplineAddFace::CanAddSingleFace or AMCAX::TMS::TMSplineAddFace::CanAddFaceByEdge can be used to determine whether a face can be added successfully or not before adding.

Add a single face defined by a set of points to the TMSpline

AMCAX::TMS::TMSplineMakeRectangle mkRect(frame, 10., 10., 2, 2);
AMCAX::TMS::TMSpline* tsp1 = mkRect.BuildSpline();
AMCAX::Point3 p1(12., 15., 15.);
AMCAX::Point3 p2(16., 13., 11.);
AMCAX::Point3 p3(20., 18., 13.);
std::vector< AMCAX::Point3 > vlist = { p1,p2,p3 };
bool r1 = af1.CanAddSingleFace(tsp1, vlist);
std::cout << r1 << std::endl;
af1.AddSingleFace(tsp1, vlist);
AMCAX::TMS::TMSplineMeshing tspMesh1(tsp1, 4);
tspMesh1.UpdateDrawMesh();
std::string fileNameOBJ1 = "AddSingleFace.obj";
meshIO1.ExportToOBJ(fileNameOBJ1, tspMesh1.GetDrawMesh());
Class of TMSpline API for Adding faces.
Definition TMSplineAddFace.hpp:15
AMCAX_API TFace * AddSingleFace(TMSpline *tsp, const std::vector< Point3 > &vplist)
add a single face constructed from points to a TMSpline
AMCAX_API bool CanAddSingleFace(TMSpline *tsp, const std::vector< Point3 > &vplist)
return true if it can add a single face constructed from points to a TMSpline
Class of meshing a TMSpline to a Triangle mesh.
Definition TMSplineMeshing.hpp:19
Class of export TMSpline triangle mesh to STL or OBJ format.
Definition TMSplineMeshingIO.hpp:16
AMCAX_API bool ExportToOBJ(const std::string &filename, const TMSTriangleMesh *tmsMesh) const
export a TMSpline triangle mesh to a obj file

Add a single face defined by two edges to the TMSpline

To be down.

Split

AMCAX::TMS::TMSplineSplit class provides split functions.
To be down.

Deletion

AMCAX::TMS::TMSplineReduce class provides deletion functions. The specific functions are:
AMCAX::TMS::TMSplineReduce::RemoveVertices removes vertices from the TMSpline (edges connected to those vertices are also deleted);
AMCAX::TMS::TMSplineReduce::RemoveEdges removes edges from the TMSpline;
AMCAX::TMS::TMSplineReduce::DeleteFaces removes faces from the TMSpline.
Before deletion, you can check if it's possible to remove vertices/edges/faces using AMCAX::TMS::TMSplineReduce::CanRemoveVertices, AMCAX::TMS::TMSplineReduce::CanRemoveEdges, or AMCAX::TMS::TMSplineReduce::CanDeleteFaces.

Remove vertices from the TMSpline

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 2, 2, 2);
AMCAX::TMS::TMSpline* tsp1 = mkCube.BuildSpline();
std::vector< int >vlist = { 0,1};
std::cout << rv.CanRemoveVertices(tsp1, vlist) << std::endl;
rv.RemoveVertices(tsp1, vlist);
Class of TMSpline API for delete and remove element Deleting an element will leave a hole,...
Definition TMSplineReduce.hpp:15
AMCAX_API void RemoveVertices(TMSpline *tsp, const std::vector< int > &vlist)
Remove vertices in a TMSpline, it will also remove edges which connect to vertices.
AMCAX_API bool CanRemoveVertices(TMSpline *tsp, const std::vector< int > &vlist)
return true if it can remove vertices in a TMSpline

Remove edges from the TMSpline

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 2, 2, 2);
AMCAX::TMS::TMSpline* tsp1 = mkCube.BuildSpline();
const std::vector< int > elist = { 10,15};
std::cout << rv2.CanRemoveEdges(tsp1, elist) << std::endl;
rv2.RemoveEdges(tsp1, elist);
AMCAX_API bool CanRemoveEdges(TMSpline *tsp, const std::vector< int > &elist)
return true if it can remove edges in a TMSpline
AMCAX_API void RemoveEdges(TMSpline *tsp, const std::vector< int > &elist)
Remove edges in a TMSpline.

Remove faces from the TMSpline

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 2, 2, 2);
AMCAX::TMS::TMSpline* tsp1 = mkCube.BuildSpline();
const std::vector< int > flist = { 2,6};
std::cout << rv3.CanDeleteFaces(tsp1, flist) << std::endl;
rv3.DeleteFaces(tsp1, flist);
AMCAX_API bool CanDeleteFaces(TMSpline *tsp, const std::vector< int > &flist)
return true if it can delete faces in a TMSpline
AMCAX_API void DeleteFaces(TMSpline *tsp, const std::vector< int > &flist)
Delete faces in a TMSpline.

Separation and Weld

AMCAX::TMS::TMSplineSeparate class provides separation functions, and the AMCAX::TMS::TMSplineWeld class provides weld functions.

AMCAX::TMS::TMSplineMakeRectangle mkRect(frame, 3, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp1 = mkRect.BuildSpline();
//SeparateEdges
std::vector< int >elist = { 0 };
std::cout << se.SeparateEdges(tsp1, elist) << std::endl;
//WeldEdges
std::cout << we.CanWeldEdges(tsp1, elist) << std::endl;
we.WeldEdges(tsp1, elist);
Class of TMSpline API for separate edge, obtain new boundaries in the separated edges.
Definition TMSplineSeparate.hpp:14
AMCAX_API bool SeparateEdges(TMSpline *tsp, const std::vector< int > &elist)
Separate edges into each other, the result edges will remain on top of each other until they are move...
Class of TMSpline API for weld edges.
Definition TMSplineWeld.hpp:14
AMCAX_API bool CanWeldEdges(TMSpline *tsp, const std::vector< int > &elist)
return true if edges in a TMSpline can be weld

Topological Modeling Function

Topological modeling functions include transformation, extrusion, thicken, hole fill, and others.

Transformation

The AMCAX::TMS::TMSplineTransform class provides transformation functions. AMCAX::TMS::TMSplineTransform::TransformTMSplineVertices transforms the list of vertices in the TMSpline; AMCAX::TMS::TMSplineTransform::TransformTMSplineEdges transforms the list of edges in the TMSpline; AMCAX::TMS::TMSplineTransform::TransformTMSplineFaces transforms the list of faces in the TMSpline.

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
double h = 30;
AMCAX::Vector3 vh(frame.Direction().Coord() * h);
//TransformTMSplineVertices
std::vector< int > vlist = { 0,1,2 };
trsfV.TransformTMSplineVertices(tsp, vlist);
//TransformTMSplineEdges
std::vector< int > elist = { 14,15,16 };
trsfV.TransformTMSplineEdges(tsp, elist);
//TransformTMSplineFaces
std::vector< int > flist = { 27,28,29 };
trsfV.TransformTMSplineEdges(tsp, flist);
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 TMSpline, change the input and post processing required after transforming th...
Definition TMSplineTransform.hpp:15
AMCAX_API void TransformTMSplineEdges(TMSpline *tsp, const std::vector< int > &elist)
Applying transformations to edge list in a TMSpline.
AMCAX_API void TransformTMSplineVertices(TMSpline *tsp, const std::vector< int > &vlist)
Applying transformations to vert list in a TMSpline.
TransformationT< double, 3 > Transformation3
3D transformation
Definition TransformationT.hpp:1102
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Extrusion

The AMCAX::TMS::TMSplineExtrude class provides extrusion functions. AMCAX::TMS::TMSplineExtrude::ExtrudeEdges is used to extrude edges; AMCAX::TMS::TMSplineExtrude::ExtrudeFaces is used to extrude faces.

Extrude Edge

Note that the edges to be extruded must be boundary edges.

AMCAX::TMS::TMSplineMakeRectangle mkRect(frame, 3, 3, 1, 1);
AMCAX::TMS::TMSpline* tsp = mkRect.BuildSpline();
std::vector<int> edgeid = { 0,1,2 };
std::vector<int> edge_id_new;
std::cout << AMCAX::TMS::TMSplineCheck::IsEdgeBoundary(tsp, edgeid[0]) << std::endl;
std::cout << AMCAX::TMS::TMSplineCheck::IsEdgeBoundary(tsp, edgeid[1]) << std::endl;
std::cout << AMCAX::TMS::TMSplineCheck::IsEdgeBoundary(tsp, edgeid[2]) << std::endl;
std::cout << ex.CanExtrudeEdges(tsp, edgeid) << std::endl;
ex.ExtrudeEdges(tsp, edgeid, edge_id_new);
static AMCAX_API bool IsEdgeBoundary(TMSpline *tsp, int eid)
check if the edge is boundary edge
Class of TMSpline API for extrude method only change the topology, the new result is coincide the old...
Definition TMSplineExtrude.hpp:15
AMCAX_API bool CanExtrudeEdges(TMSpline *tsp, const std::vector< int > &edges)
check if it can extrude input edges in TMSpline
AMCAX_API bool ExtrudeEdges(TMSpline *tsp, const std::vector< int > &edges, std::vector< int > &edgesNew)
extrude the edges in TMSpline

Extrude Face

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp2 = mkCube.BuildSpline();
std::vector<int> faceid = { 0,2,5};
std::vector<int> face_id_new;
std::cout << ex.CanExtrudeFaces(tsp2, faceid) << std::endl;
ex.ExtrudeFaces(tsp2, faceid, face_id_new);
AMCAX_API bool CanExtrudeFaces(TMSpline *tsp, const std::vector< int > &faces)
check if it can extrude input faces in TMSpline
AMCAX_API bool ExtrudeFaces(TMSpline *tsp, const std::vector< int > &faces, std::vector< int > &facesNew)
extrude the faces in TMSpline

Thicken

AMCAX::TMS::TMSplineMakeRectangle mkRect(frame, 3, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkRect.BuildSpline();
mkThick.ThickenTMSpline(tsp, 1);
Class of TMSpline API for Thicken a TMSpline.
Definition TMSplineThicken.hpp:14
AMCAX_API bool ThickenTMSpline(TMSpline *tsp, double dist)
Thicken a TMSpline to obtain a new TMSpline.

Hole Fill

The AMCAX::TMS::TMSplineFillHole class provides hole filling functions. AMCAX::TMS::TMSplineFillHole::FillAllHoles is used to fill a specific hole in a TMSpline; before filling hole, AMCAX::TMS::TMSplineFillHole::CanFillSingleHole can be used to check if a hole can be filled; AMCAX::TMS::TMSplineFillHole::FillAllHoles is used to fill all holes in the TMSpline. Note that for an open mesh, during hole filling, the boundary will also be considered a hole and filled with a polygon.

AMCAX::Point2 p0(1.0, 1.0), p1(10.0, 10.0);
AMCAX::TMS::TMSplineMakeRectangle mkRect(p0, p1, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkRect.BuildSpline();
std::vector<int> face_id = { 4 };
std::vector<int> edge_id = { 6, 10, 13, 14 };
reduce.DeleteFaces(tsp, face_id);
//FillSingleHole
std::cout << fillhole.CanFillSingleHole(tsp, 6) << std::endl;
fillhole.FillSingleHole(tsp, 6);
//FillAllHoles
std::vector<int> face_id2 = { 0,6 };
reduce2.DeleteFaces(tsp, face_id2);
fillhole2.FillAllHoles(tsp);
Class of TMSpline API for fill hole.
Definition TMSplineFillHole.hpp:15
AMCAX_API bool FillAllHoles(TMSpline *tsp)
fill all holes in TMSpline by use a singel polygon face
AMCAX_API void FillSingleHole(TMSpline *tsp, size_t edgeIndex)
fill hole whit input edge by use a singel polygon face
AMCAX_API bool CanFillSingleHole(TMSpline *tsp, size_t edgeIndex)
check if there are hole with input edge in TMSpline
PointT< double, 2 > Point2
2D point
Definition PointT.hpp:456

Meshing

AMCAX::TMS::TMSplineMeshing class divides the TMSpline into triangular meshes.

AMCAX::Point3 bb_min(0.00, 0.00, 0.00), bb_max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(bb_min, bb_max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp = mkCube.BuildSpline();
tspMesh.UpdateDrawMesh();

Export OBJ/STL File

AMCAX::TMS::TMSplineMeshingIO::ExportToOBJ provides the function to export to OBJ files; AMCAX::TMS::TMSplineMeshingIO::ExportToSTL provides the function to export to STL files.

AMCAX::Point3 min(0.00, 0.00, 0.00), max(12.00, 12.00, 12.00);
AMCAX::TMS::TMSplineMakeCube mkCube(min, max, 3, 3, 3);
AMCAX::TMS::TMSpline* tsp4 = mkCube.BuildSpline();
AMCAX::TMS::TMSplineMeshing tspMesh4(tsp4, 4);
tspMesh4.UpdateDrawMesh();
std::string fileNameOBJ4 = "cube.obj";
std::string fileNameOBJ5 = "cube.stl";
meshIO4.ExportToOBJ(fileNameOBJ4, tspMesh4.GetDrawMesh());
meshIO4.ExportToSTL(fileNameOBJ5, tspMesh4.GetDrawMesh());
AMCAX_API bool ExportToSTL(const std::string &filename, const TMSTriangleMesh *tmsMesh) const
export a TMSpline triangle mesh to a stl file