Geometric Modeling

Yan Zhuang
Discrete Computation, Wolfram Research

Join the Conversation #WolframTechConf

Outlines of the Talk

Connection to 3D database

Curated 3D geometric models

Import & Export

GeometrySearch

Region Constructors

DiscretizeGraphics

ImageMesh

ArrayMesh

Region Operations

TransformedRegion

BooleanRegion

Connection to 3D database

The Wolfram Language provides direct access to a large volume of curated 3D geometric models such as polyhedra, knots, anatomical structures, and geometric features.

Code

showMeshGrid[f_,names_]:=Grid[{Framed[Show[ImagePad[Rasterize[If[f===GeoElevationData,f[#,Automatic,"Region"],f[#,"Region"]],"Image",ImageSize->{100,100},Background->None],10,RGBColor[1,1,1,0]],PlotLabel->format[#],Method->{"ShrinkWrap"->False},ImageSize->100],RoundingRadius->10,Background->Lighter[Gray,0.9],FrameStyle->GrayLevel[0.5]]&/@names}]
format[GeoDisk[s_,___]]:=format[s]
format[e_Entity]:=First[StringSplit[CommonName[e],","]]
format[s_List]:=format[Last[s]]
format[s_]:=s

PolyhedronData

showMeshGrid[PolyhedronData,{"Dodecahedron","SnubCube","Echidnahedron","CumulatedCube"}]

KnotData

showMeshGrid[KnotData,{"Trefoil","FigureEight","SolomonSeal","Stevedore"}]

ChemicalData

showMeshGrid[ChemicalData,{"Water","Caffeine","SulfuricAcid","DTyrosine"}]

AnatomyData

showMeshGrid[AnatomyData,{"Liver","Eye","LeftHand","Skull"}]

GeoElevationData

showMeshGrid[GeoElevationData,{(Entity["Mount Everest", Entity["Mountain","MountEverest"], "Entity[\"Mountain\", \"MountEverest\"]", "mountain"]),(Entity["Switzerland", Entity["Country","Switzerland"], "Entity[\"Country\", \"Switzerland\"]", "country"]),(Entity["Hawaii, United States", Entity["AdministrativeDivision",{"Hawaii","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Hawaii\", \"UnitedStates\"}]", "administrative division"]),GeoDisk[(Entity["Mariana Trench", Entity["UnderseaFeature","MarianaTrench"], "Entity[\"UnderseaFeature\", \"MarianaTrench\"]", "undersea feature"]),(Quantity[30, "mi", miles, "Miles"])]}]

ExampleData

showMeshGrid[ExampleData,{{"Geometry3D","Cow"},{"Geometry3D","Beethoven"},{"Geometry3D","Tree"},{"Geometry3D","Seashell"}}]

Connection to 3D database

Support variety of 3d data format:

Bust of Nefertiti at the Neues Museum from MyMiniFactory.

bust=Import[NotebookDirectory[]<>"bust.stl"]

Connection to 3D database

GeometrySearch searches for 2D and 3D geometric models in repositories such as Wolfram Data Repository and MakerBot Thingiverse:

GeometrySearch["skull", Method->"Thingiverse"]

model["Properties"]

skull=model["Region"]

Printout3D[skull, "Sculpteo"]

Constructors - Mesh from Image

Constructors - Mesh from Image

image = ;

DeleteSmallComponents[Binarize[image],500]

ImageMesh[ColorNegate[%]]

RegionProduct[%,Line[{{0.},{50.}}]]

Constructors - Mesh from Image

extrudeImage[image_]:=
Block[{res,img},
img=DeleteSmallComponents[Binarize[image],500];
res=ImageMesh[ColorNegate[img],Method->"MarchingSquares"];
RegionProduct[res,Line[{{0.},{50.}}]]
]

extrudeImage /@ {,,,}

img=;

timg=ImageTrim[img,First @ FindFaces[img]]

extrudeImage[timg]

Constructors - Mesh from Graphics3D

Constructors - Mesh from Graphics3D

RevolutionPlot3D ▪ ParametricPlot3D ▪ ContourPlot3D ▪ Plot3D ▪ SphericalPlot3D

SphericalPlot3D[{1,2,3},{θ,0,Pi},{ϕ,0,3Pi/2},Boxed-> False,Axes-> None,PlotTheme-> "ThickSurface"]

DiscretizeGraphics[%]

DiscretizeGraphics/@{,,}

Constructors - Mesh from Array

({{, , }, {, , }})

Constructors - Mesh from Array

arrays= {(({{1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}})),(({{1, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}})),(({{1, 1, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}})),(({{0, 1, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}})),
(({{1, 0, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}})),(({{1, 1, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}))};

amesh=Table[ArrayMesh[i],{i,arrays}]

Table[RegionProduct[i,Line[{{0.},{1.}}]],{i,amesh}]

Constructors - Mesh from Array

Constructors - Mesh from Array

Build a 3D chessboard

board=ArrayMesh[ConstantArray[1,{8,8,1}]]

m=Flatten[ConstantArray[{{0,1,0,1,0,1,0,1},{1,0,1,0,1,0,1,0}},4]];

p=First/@Position[Flatten[m],1];

style={Style[1, {Thick,Black}],Style[3, White],Style[{3,#}&/@p, Black]};

HighlightMesh[board,style]

Region Operations

Boolean operations over regions:

{a,b}={,};

Multicolumn[Table[BooleanRegion[op,{a,b},PlotLabel-> op,BaseStyle->Opacity[0.7]],{op, {Or, And,¬#2∧#1&,#1⊻#2&}}],2]

Region Operations

Region Operations

a=Ellipsoid[{0,0,0},{50,30,80}];

ellips=TransformedRegion[a,RotationTransform[#,{1,0,0}]]&/@{Pi/4,Pi/2,3Pi/4,Pi};

Region[RegionUnion@@ellips]

b=Ellipsoid[{0,0,0},{60,60,60}];

Region[RegionUnion@@Join[{b},ellips]]

Curvy Staircase - Region Operations

Curvy Staircase - Region Operations

Coordinate

n=10;h=1;w=5;d=1;

coords=Flatten[#,2]&@Table[
{k*w,i*d,(i+j)*h},
{i,0,n},{j,0,1},{k,0,1}];

Graphics3D[{PointSize[Large],Table[Tooltip[Point@coords[[i]],i],{i,Length[coords]}]}]

Regular Staircase

front=Table[2*i+{1,2,4,3},{i,0,2*n-1}];

mfront=MeshRegion[coords,Polygon[front]]

side=Partition[Table[2*i-1,{i,2n+2}],3,2];
side=Join[side,side+1];

mside=MeshRegion[coords,Polygon[side]]

stair=RegionUnion[mfront,mside]

Curvy Staircase

newcoords=Flatten[#,2]&@Table[
RotationMatrix[i/n,{0,0,1}].{k*w,i*d,(i+j)*h},
{i,0,n},{j,0,1},{k,0,1}];

MeshRegion[newcoords,MeshCells[stair,2]]

Chain - Region Operations

Chain - Region Operations

Tori Chain

LeftRightTorus[i_]:=ParametricRegion[{i+Sin[t] (3.9+Cos[r]),Cos[t] (3.9+Cos[r]),Sin[r]},{{t,0,2 π},{r,0,2 π}}]

TopBottomTorus[i_]:=ParametricRegion[{i+(3.9+Cos[r]) Cos[t],Sin[r],(3.9+Cos[r]) Sin[t]},{{t,0,2 π},{r,0,2 π}}]

{Region@LeftRightTorus[1],Region@TopBottomTorus[1]}

torusChain[n_]:=Table[If[OddQ[i],LeftRightTorus[i*5],TopBottomTorus[i*5]],{i,n}]

Region[RegionUnion@@torusChain[3]]

Region[RegionUnion@@torusChain[8]]

Turners - Region Operations

Turners - Region Operations

s=10;
cube=Cuboid[-(1/2){s,s,s},(1/2){s,s,s}];
Cylinder[{{0,0,-((s+2)/2)},{0,0,((s+2)/2)}},(s/2)-2];
cylinderx=TransformedRegion[cylinder,RotationTransform[Pi/2,{1,0,0}]];
cylindery=TransformedRegion[cylinder,RotationTransform[Pi/2,{0,1,0}]];

Region[cyls=RegionUnion@@{cylinder,cylinderx,cylindery}]

Region@RegionDifference[cube, cyls]

Turners[s_]:=
Module[{cube,cylinder,cylinderx,cylindery, cyls},
cube=Cuboid[-(1/2){s,s,s},(1/2){s,s,s}];
cylinder =  Cylinder[{{0,0,-((s+2)/2)},{0,0,((s+2)/2)}},(s/2)-2];
cylinderx=TransformedRegion[cylinder,RotationTransform[Pi/2,{1,0,0}]];
cylindery=TransformedRegion[cylinder,RotationTransform[Pi/2,{0,1,0}]];
cyls=RegionUnion@@{cylinder,cylinderx,cylindery};
RegionDifference[cube, cyls]
]

Table[Region[Turners[i]],{i,20,10,-2}]

Show[%]

Learn More

Marketing Pages

Symbolic Geometry (Overview) [web]

Basic & Formula Regions [web]

Data & Mesh Regions [web]

PDEs & Finite Elements [web]

Core Geometry [web]

3D Printing [web]

Guide Pages

Geometric Computation (General Overview) [product] [web]

Plane Geometry (Special Overview) [product] [web]

Solid Geometry (Special Overview) [product] [web]

Region Properties & Measures [product] [web]

Solvers over Regions [product] [web]

3D Printing [product] [web]

Basic Geometric Regions [product] [web]

Mesh-Based Geometric Regions [product] [web]

Derived Geometric Regions [product] [web]