Meshes#
Meshes are 3d shapes that are defined using points (“vertices”) with faces between them. The straight lines between vertices at the edge of a face is called an “edge”. Edges are straight and faces are flat. This means that curved surfaces are approximated by a (large) number of faces.
Meshes are heavily used in computer graphics and 3D printing. They and are easy to define and quick to work with.
DAVE uses meshes for tanks, buoyancy and contact. For these applications the meshes need to meet certain criteria. Besides for calculations, meshes can also be used as visual. For meshes used as visual there are no restrictions to the mesh as they are not used for calculations.
File format and tools#
DAVE can work with .stl
and .obj
files. STL is a pure mesh format while obj can also include texture files. The preferred format for meshes is .stl
There are many good tools for working with meshes, often free. All of them have a learning-curve, good points and bad points.
Rhino 3D: Well known commercial package. Good if you already have it. Although OpenCascade often performs better when converting STEP files to mesh.
Blender: Open source 3d modeler and renderer. Aimed at artists, great if you also plan to export and render your DAVE projects to Blender. There are CAD tools available via plugins. Modifiers can be used to refine or simplify existing meshes.
These are some quick tips for meshing with blender.
PyMeshUp: A python based mesh builder using boolean geometry based on meshlab. PyMeshUp is best for creating hull shapes from scratch using ordinates, frames or from GHS files. It can define tanks in hull shapes using the beforementioned boolean geometry. It has a version of capytaine build in so it can be used directly for diffraction analysis.
Note: PyMeshUp is from the same author as DAVE.
Meshlab: Great collection of filters for checking and repairing meshes. Used by PyMeshUp as well.
See these tips for fixing meshes using meshlab.
SketchUp: The 2017 version of Sketchup MAKE is still free
FreeCAD : OpenCascade based CAD program with good options for converting .stp to mesh. Free.
Note that many CAD drawing are not meshes. Converting a CAD model or drawing to a good mesh is possible if the CAD model is physically correct. If it isn’t then some manual labor is required.
What is a good mesh#
A good mesh is “clean”. Things that are considered bad are:
gaps between adjacent faces
overlapping faces
faces intersecting each other or, even worse, duplicate faces.
faces that are bent
internal faces. That is: faces that are inside a volume.
inconsistent normals. Faces in a mesh have an orientation which is define by the order in which the vertices are defined for a face. This defines what is inside and what is outside.
Many of these defects can be created when converting from CAD models to meshes. Using the right tool, a skilled person and a proper CAD model helps to minimize these. Some tips and methods on cleaning and repairing meshes with either blender or meshlab are given at the end of this section.
Tanks and buoyancy shapes#
Tanks and buoyancy shapes require a mesh that forms a closed volume. This makes sense as the physical tank or hull needs to be water-tight.
A “boundary edge” is an edge that is connected to only a single face. A mesh is closed when it does not have any boundary edges. DAVE will warn if you try to use a shape with boundary edges as tank or buoyancy shape.
Examples of good tank or buoyancy meshes are the cube, sphere and seal models. Here shown as partially filled tanks.
The fewer panels are used to describe the geometry, the faster the calculation and the more accurate the result. So it is better to describe a flat plate with one single panel than with 100 panels. DAVE will automatically cut the mesh at the waterline if needed (see left image).
For people familiar with diffraction meshes: A mesh for a tank or buoyancy is NOT A DIFFRACTION MESH. It does not need to have small “panels”. Also there are no restriction on aspect ratio or size changes for adjacent faces.
Conserving Volume#
When meshing a curved or round object you are literally cutting corners. When vertices are placed on the surface and faces are creating faces between those then volume is lost. This is illustrated on the left. This can be corrected for by calculating the resulting enclosed volume and scaling the the the created mesh up such that the original volume is maintained. The result is shown on the right.
Note that DAVE calculates and display the total volume of the mesh and has the option to provide a scaling factor as well.
Converting STEP (.STP) to Mesh (STL)#
For converting CAD formats such as .stp (STEP) to meshes the best option is OpenCascade. This is easiest used via cadquery or FreeCAD (use the mesh workbench). OpenCascade allows for defining both an angular and a linear tolerance which other programs (including commercial ones) often do not offer.
FreeCad#
Use the mesh workbench and the
button to convert a solid to a mesh.
CadQuery#
A pre-compiled and stand-alone version of cadquery is CadQuery Editor which can be found here: CadQuery Gui.
The python script on the left is copied below for convenience:
import cadquery as cq
from cadquery import exporters
result = cq.importers.importStep(r"hdgphm0150.stp")
exporters.export(result,
fname = r"exported.stl",
angularTolerance = 0.9,
tolerance =10)