MeshCheck
Package: Libraries.Fabrication.Geometry · Inherits from: Libraries.Language.Object
The MeshCheck class looks at each part (mesh) of a loaded model and says whether it is a closed solid, which a 3D printer needs. A part is closed when every edge of every triangle is shared by exactly two triangles. An edge with only one triangle is open: it borders a hole, or the part is a single surface, such as a window pane or a sheet of cloth. The slicer can't tell the inside of an open part from the outside, so it may print with gaps or missing walls. Corners at the same spot count as one, so a part whose triangles were split apart only for their textures or normals is still closed. Parts that pass through each other aren't checked, and nothing is repaired.
Example Code
use Libraries.Game.Graphics.Models.Data.ModelLoader
use Libraries.Game.Graphics.Models.Data.ModelData
use Libraries.Fabrication.Geometry.MeshCheck
ModelLoader loader
ModelData model = loader:Load("Car/ToyCarCentered.gltf")
MeshCheck meshCheck
meshCheck:Check(model)
integer i = 0
repeat while i < meshCheck:GetPartCount()
if meshCheck:IsClosed(i)
output meshCheck:GetPartName(i) + " is a closed solid."
else
output meshCheck:GetPartName(i) + " has " + meshCheck:GetOpenEdgeCount(i) + " open edges."
end
i = i + 1
end
Actions
Check(Libraries.Game.Graphics.Models.Data.ModelData data)
This action checks every part of the model, replacing what an earlier Check found.
Parameters
dataLibraries.Game.Graphics.Models.Data.ModelData: The loaded model.
Example
use Libraries.Game.Graphics.Models.Data.ModelLoader
use Libraries.Game.Graphics.Models.Data.ModelData
use Libraries.Fabrication.Geometry.MeshCheck
ModelLoader loader
ModelData model = loader:Load("Car/ToyCarCentered.gltf")
MeshCheck meshCheck
meshCheck:Check(model)
GetOpenEdgeCount(integer index)
This action returns how many of a part's edges belong to only one triangle. A closed solid has none.
Parameters
indexinteger: Which part, counting from 0.
Returns
integer: The number of open edges.
Example
use Libraries.Fabrication.Geometry.MeshCheck
MeshCheck meshCheck
// meshCheck:Check(model)
output meshCheck:GetOpenEdgeCount(0) + " open edges"
GetPartCount()
This action returns how many parts the last Check looked at.
Returns
integer: The number of parts.
Example
use Libraries.Fabrication.Geometry.MeshCheck
MeshCheck meshCheck
// meshCheck:Check(model)
output meshCheck:GetPartCount() + " parts"
GetPartName(integer index)
This action returns a part's name: the name the model file gives it, else its material's name, else "Part" and its number, counting from 1.
Parameters
indexinteger: Which part, counting from 0.
Returns
text: The part's name.
Example
use Libraries.Fabrication.Geometry.MeshCheck
MeshCheck meshCheck
// meshCheck:Check(model)
output meshCheck:GetPartName(0)
GetTriangleCount(integer index)
This action returns how many triangles a part has.
Parameters
indexinteger: Which part, counting from 0.
Returns
integer: The number of triangles.
Example
use Libraries.Fabrication.Geometry.MeshCheck
MeshCheck meshCheck
// meshCheck:Check(model)
output meshCheck:GetTriangleCount(0) + " triangles"
IsClosed(integer index)
This action returns true if a part is a closed solid: it has triangles, and none of its edges are open.
Parameters
indexinteger: Which part, counting from 0.
Returns
boolean: True if the part is closed.
Example
use Libraries.Fabrication.Geometry.MeshCheck
MeshCheck meshCheck
// meshCheck:Check(model)
if not meshCheck:IsClosed(0)
output "The first part has holes."
end