Combined model is not watertight

#4 · closed · 2 comments

View on GitHub ↗

MarcelHeu

Hey, first i have to say thank you for this library. I really missed these in python. Now my problem: After i combined two models with each other, i sometimes get a "not watertight" model as result. Attached you will find some example source code. ########################################################################## "Function to combine (union) two different trimesh files" def getUnion(model1, model2): ########################################################### # using pycork to combine to different models # Extra list of vertices and triangular faces from the meshes vertsA = model1.vertices trisA = model1.faces vertsB = model2.vertices trisB = model2.faces # Perform the boolean opertions directly with Cork library vertsC, trisC = pycork.union(vertsA, trisA, vertsB, trisB) # combined model combinedModel = trimesh.Trimesh(vertices=vertsC, faces=trisC, process=True) ########################################################### return combinedModel # end of function ########################################################################## # needed variables radius = 0.5 insertConeInMM = 0.001 cylinderHeight = 4 coneHeight = 1 # create cylinder cylinder = cylinder(radius,height=cylinderHeight, sections=36) # create cone1 cone1 = cone(radius,height=coneHeight, sections=36) cone1.apply_translation((0,0,cylinderHeight/2 - insertConeInMM)) # create cone2 cone2 = cone(radius,height=coneHeight, sections=36) alpha2, beta2, gamma2 = np.deg2rad((180,0,0)) R_e = trimesh.transformations.euler_matrix(alpha2, beta2, gamma2, 'rxyz') cone2.apply_transform(R_e) cone2.apply_translation((0,0,-(cylinderHeight/2 - insertConeInMM))) # combine everything part1 = getUnion(cylinder, cone1) combined = getUnion(part1, cone2) print(combined.is_watertight) # export as stl file_path = QtWidgets.QFileDialog.getSaveFileName(parent = None, caption = "Export Model", directory = os.environ['USERPROFILE'] + "/" + "Test", filter = "STL file (*.stl)") if file_path[0] != "": combined.export(file_path[0])

Comments

drlukeparry

Hi Marcel, I have tried the watertight check in the Cork Library even with a model that I know is considered a watertight or non-manifold mesh in other software. Unfortunately, I admit I do not know the inner-workings of the Cork Library to provide an opinion or recommendation, if the actual boolean operation is watertight. I would suggest validating the result in other software (in Windows 3D Print Builder) or via python libraries (trimesh) Generally, you'll need to evaluate if you need an exactly conforming water-tight model for your application. 3D printing for example is a little forgiving depending on the process and algorithms used. Hope that helps, Luke

MarcelHeu

Hey Luke, thanks for the answer! I will close the issue.