Difference between revisions of "NMG"

From BRL-CAD
(Created page with "category:tutorials {|align="right" |thumb|256px|Example NMG object created with "put" |} BRL-CAD contains a powerful Non-Mani...")
 
m
Line 25: Line 25:
 
create a ramp structure with another primitive and then convert it
 
create a ramp structure with another primitive and then convert it
 
with the "facetize" command:
 
with the "facetize" command:
 +
 +
<br clear=all />
  
 
  mged> make ramp_arb arb6
 
  mged> make ramp_arb arb6

Revision as of 19:15, 16 December 2014


Example NMG object created with "put"

BRL-CAD contains a powerful Non-Manifold Geometry (NMG) mesh primitive. NMG objects are usually created through geometry importers, or through commands like "facetize" that create NMG from other geometry. However, using the low-level database commands "get" and "put", it is possible to manually create and edit NMG objects.

BRL-CAD's internal representation is similar to the Radial Edge data structure described in http://www.scorec.rpi.edu/REPORTS/1986-1.pdf. However, the textual representations that can be created and viewed with "get" and "put" are somewhat simpler; this representation deals with vertices, faces, and loops. Loops, in effect, are closed curves that form boundaries for faces, and a face can have multiple loops. For example, a face with a hole in it might have two loops, with one defining each boundary: one for the outer "edge" and one for the inner.

To obtain a sample of the way that nmgs are created, these commands create a ramp structure with another primitive and then convert it with the "facetize" command:


mged> make ramp_arb arb6
mged> facetize -n ramp_nmg ramp_arb
mged> get ramp_nmg
nmg V { { 1.500499999999999944932938 -0.5003749999999999031885523 1.500375000000000014210855 } { 1.500499999999999944932938 1.500624999999999875655021 1.500375000000000014210855 } { -0.500499999999999944932938 0.5001250000000000417443857 1.500375000000000014210855 } { 1.500499999999999944932938 -0.5003749999999999031885523 -0.5006249999999998756550212 } { -0.500499999999999944932938 0.5001250000000000417443857 -0.5006249999999998756550212 } { 1.500499999999999944932938 1.500624999999999875655021 -0.5006249999999998756550212 } } F { { 3 5 1 0 } } F { { 3 0 2 4 } } F { { 5 4 2 1 } } F { { 3 4 5 } } F { { 0 1 2 } }

or, formatted, more nicely,

nmg
V {
  { 1.500499999999999944932938 -0.5003749999999999031885523 1.500375000000000014210855 }
  { 1.500499999999999944932938 1.500624999999999875655021 1.500375000000000014210855 }
  { -0.500499999999999944932938 0.5001250000000000417443857 1.500375000000000014210855 }
  { 1.500499999999999944932938 -0.5003749999999999031885523 -0.5006249999999998756550212 }
  { -0.500499999999999944932938 0.5001250000000000417443857 -0.5006249999999998756550212 }
  { 1.500499999999999944932938 1.500624999999999875655021 -0.5006249999999998756550212 }
}
F { { 3 5 1 0 } }
F { { 3 0 2 4 } }
F { { 5 4 2 1 } }
F { { 3 4 5 } }
F { { 0 1 2 } }

The "nmg" at the beginning is the type of what follows; the actual information is just a list of vertices and a number of face statements. Each face is represented by a list that contains any number of loops; each loop is a list of vertices. The vertices are referred to by their index into the V list.

To create a new nmg structure, use "put" instead of "get"; the first argument to "put" should be the name of the new object. For example, to create a similar ramp structure named "ramp_nmg2" but with different coordinates, you'd do this:

mged> put ramp_nmg2 nmg V { { 0 0 0 } { 1 0 0 } { 0 1 0 } { 1 1 0 } { 0 1 1 } { 1 1 1} } F { { 0 1 2 3 } } F { { 3 2 4 5 } } F { { 0 1 5 4 } } F { { 0 2 4 } } F { { 1 3 5 } }