Ngon rules?

I’m trying to understand the “rules” for what Ngons are like. Here’s my rough attempt at it:

  1. Ngons are edge-connected collections of mesh faces, which are either triangles or quadrangles. They do not have to be planar.
  2. Ngons have a closed, connected outer boundary. (I’ve been scratching my head trying to figure out when a collection that matches rule 1 wouldn’t have this property, and the only thing I’ve been able to think of are cases like cylinders that have two “outer” boundaries?)
  3. Ngons can have inner boundaries. (This was a earlier topic on here.)

Is there anything else I’m missing?


Hi Sol,

With regard to Rhino/OpenNurbs I don’t think there’s a requirement that ngons be planar but most of the SDK tools work best, or only work, if they are planar. You would not, for instance, be able to make a single ngon from a cylinder. At least with any SDK functions that I’m aware of. They can have inner boundaries but some downstream applications don’t allow for them. Obj is an example. SketchUp does allow them. Also, if you have non-manifold edges that will cause you lots of grief. Like if you have a duplicate face in the ngon.


1 Like

Ngons are 3 sided or 5+ sided, never “quadrangles”.

Why doesn’t creating a single quad face and then making an Ngon whose only face is that one work to get a 4 sided Ngon?

Hi @colomon,

Doing this:

// Create a mesh
ON_Mesh mesh(4, 1, true, false);

// Add vertices
mesh.SetVertex(0, ON_3dPoint(0.0, 0.0, 0.0));
mesh.SetVertex(1, ON_3dPoint(10.0, 0.0, 0.0));
mesh.SetVertex(2, ON_3dPoint(10.0, 10.0, 0.0));
mesh.SetVertex(3, ON_3dPoint(0.0, 10.0, 0.0));

// Add face
mesh.SetQuad(0, 0, 1, 2, 3);

// Add ngon
ON_SimpleArray<unsigned int> ngon_fi;

// ComputeNormals

// Finish up

// Dump
ON_wString str;
ON_TextLog log(str);

produces this:

ON_Mesh: vertex count = 4  facet count = 1
double precision: true
vertex normals:   true
face normals:     true
n-gons:           true
srf parameters:   false
tex coords:       false
vertex kappa:     false
vertex colors:    false
	Texture/color mapping tag:
m_packed_tex_rotate: false
m_packed_tex_domain: (-1.23432e+308,-1.23432e+308)x(-1.23432e+308,-1.23432e+308)
m_srf_domain: (-1.23432e+308,-1.23432e+308)x(-1.23432e+308,-1.23432e+308)
m_srf_scale: 0,0
	Texture/color mapping tag:
Memory used: 140 bytes
	4 mesh vertices:
		m_V array hash ON_SHA1_Hash::3316F6091AF9DEFE54A4BC516B436DE9CA737231
		m_dV array hash ON_SHA1_Hash::226D90143CB58B959A39997CAE484DF115E36E28
		m_V[0] = (0,0,0) D = (0,0,0)
		m_V[1] = (10,0,0) D = (10,0,0)
		m_V[2] = (10,10,0) D = (10,10,0)
		m_V[3] = (0,10,0) D = (0,10,0)
	4 mesh vertex normals:
		m_N array hash ON_SHA1_Hash::77E4AD5D3847C25F99C7BBC7CF07E5571A16F7DC
		m_N[0] = (0,0,1)
		m_N[1] = (0,0,1)
		m_N[2] = (0,0,1)
		m_N[3] = (0,0,1)
	1 mesh faces:
		m_F array hash ON_SHA1_Hash::02E4414E7DFA0F3AA2387EE8EA7AB31431CB406A
		m_F[0].vi = (0,1,2,3)
	1 mesh face normals:
		m_FN[0] = (0,-0,1)
	1 mesh n-gons:
		Ngon(0): m_vi[4]=(0,1,2,3) m_fi[1]=(0) capacity=7 boundary counts outer = 4, inner = 0

What are we missing?

– Dale