7
$\begingroup$

How do I read in an obj file as a MeshRegion so I can e.g. compute its area?

If I just import the object and try Area[O] it tells me it is not a correctly specified region, even for e.g. the StanfordBunny.

Also, how do I turn Geometry3D into a MeshRegion? For example

Area[ExampleData[{"Geometry3D", "SpaceShuttle"}]]

does not work either.

It seems that geometry has more than one representation in different parts of Mathematica - bad.

$\endgroup$
10
$\begingroup$

Well, you have to first convert it to a MeshRegion. Let's take the space shuttle for example:

shuttle = ExampleData[{"Geometry3D", "SpaceShuttle"}]

Mathematica graphics

Now, we discretize it, since it's a Graphics3D object, we use DiscretizeGraphics:

ds = DiscretizeGraphics[shuttle]

Mathematica graphics

Now, we can find the Area easily:

Area[ds]

177.301907

Similarly for the horse:

horse = ExampleData[{"Geometry3D", "Horse"}]

Mathematica graphics

dh = DiscretizeGraphics[horse]

Mathematica graphics

We compute the surface area:

Area[dh]

0.0358690432

$\endgroup$
  • $\begingroup$ Does not always work. Area[DiscretizeGraphics[Import["somefile.obj"]]] still give a not correctly specified region error. $\endgroup$ – Ralph Aug 18 '14 at 10:51
  • $\begingroup$ Retried it and it did work. Apologies. I must have typed something wrong. $\endgroup$ – Ralph Aug 19 '14 at 7:44
  • $\begingroup$ I have some cases where Mathematica computes the volume of a closed surface mesh as zero, even though FindMeshDefects doesn't find any defects and all the MeshCoordinates are points in 3D. I might formulate an MVE and another SE question, but this one seems very closely related. $\endgroup$ – Reb.Cabin Jul 16 '17 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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