5
$\begingroup$

I want to make the Final use fewer mesh lines, the ideal version will look like the second image. Where the triangle shape is more clear and clean. Can anyone give me some advice on how to fix my code?

   ex1 = ParametricPlot3D[{(3 + Cos[v]) Cos[u], (3 + Cos[v]) Sin[u], 
       Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, Boxed -> False, Axes -> False]
    
    
   mesh = Import[Export[NotebookDirectory[] <> "ex1.stl", ex1]]
    
   edges = MeshPrimitives[mesh, 1]
    
   Final = Graphics3D[Map[Tube[#, .05] &, edges[[All, 1]]],Boxed -> False]

First image

Second image

$\endgroup$

2 Answers 2

8
$\begingroup$

The FEM package will tend to give you more isotropic triangles as shown in your spherical mesh than other discretization functions in Mathematica. Also, for a torus, an implicit region seems to give a cleaner mesh than a parametric region as can be seen by the FindMeshDefects function.

Below, you can see a comparison between ParametricRegionand ImplicitRegion:

Needs["NDSolve`FEM`"]
torus = ParametricRegion[{(3 + Cos[v]) Cos[u], (3 + Cos[v]) Sin[u], 
    Sin[v]}, {{u, 0, 2 π}, {v, 0, 2 π}}];
mrtorus = 
  MeshRegion@
   ToBoundaryMesh[torus, "MeshOrder" -> 1, MaxCellMeasure -> .1, 
    AccuracyGoal -> 1];
HighlightMesh[mrtorus, 1]
FindMeshDefects[mrtorus]
torus = SolidData["SolidTorus", "ImplicitRegion"][1, 3];
mrtorus = 
  MeshRegion@
   ToBoundaryMesh[torus, "MeshOrder" -> 1, MaxCellMeasure -> .1, 
    AccuracyGoal -> 1];
HighlightMesh[mrtorus, 1]
FindMeshDefects[mrtorus]

enter image description here

$\endgroup$
2
  • $\begingroup$ Is it possible to get edges less than 1616?torus = SolidData["SolidTorus", "ImplicitRegion"][1, 3]; mrtorus = MeshRegion@ ToBoundaryMesh[torus, "MeshOrder" -> 1, MaxCellMeasure -> 1, AccuracyGoal -> 1]; $\endgroup$ Commented Dec 14, 2020 at 7:18
  • $\begingroup$ @HyperGroups To have ultimate control over the number lines, you may have to resort to a structured mesh. The automatic mesh generators will probably add points to meet its internal requirements for a watertight mesh with triangles of sufficient quality. $\endgroup$
    – Tim Laska
    Commented Dec 15, 2020 at 1:50
4
$\begingroup$

Change the MeshFunctions and Mesh and PlotPoints

ex1 = ParametricPlot3D[{(3 + Cos[v]) Cos[u], (3 + Cos[v]) Sin[u], 
    Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, Boxed -> False, 
   Axes -> False, MeshFunctions -> Automatic, Mesh -> {{0}}, 
   PlotPoints -> {12, 8}];
reg = DiscretizeGraphics[ex1];
newedges = MeshPrimitives[reg, 1];
Graphics3D[Map[Tube[#, .05] &, newedges[[All, 1]]], Boxed -> False]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.