[SOLVED] Is it possible to get the surface area of a 'NURBSSurface' object in GroIMP?

In GroIMP, can the surface area of a NURBSSurface object be determined? Previous versions of GroIMP have included ‘getSurfaceArea’ and ‘getVolume’ functions for primitive objects, but it’s unclear if a similar approach can be used to obtain the area of a NURBSSurface in the latest release? When I tried to implement this function, it always returned 0, so I am unsure if it is not yet available in GroIMP or if I implemented it incorrectly.

If determining the surface area of a NURBSSurface object is not possible, are there any workarounds? For example, could triangulation points be used to estimate the surface area?

1 Like

Hi, the getSurfaceArea of a NURBSSurface is not implemented (it will return 0). There is currently no way of getting the surface area of a NURBSSurface. I guess it could be approximated using the polygons used for the rendering.

For a given nurbssurface node, you can get the PolygonArray with (in a rgg file):

PolygonizationCache polyCache = new PolygonizationCache (graphState (), 0, 100, false);
PolygonArray polys = polyCache.get (nurbs, true, nurbs);

I know the PolygonArray (PolygonArray) is used for the rendering, but I don’t know how this data-structure works.

2 Likes

Thank you very much! Your suggestion was really helpful. :slight_smile:
By following, your suggested method and adding the following steps below, I to obtain the area (I’m not sure if it’s the best way to do it though! but it’s here if anyone is curious)
Since I am using a detailed NURBSurface, the approximation seems to be accurate enough for my purposes.

Point3d Tuple_p0 = new Point3d();
Point3d Tuple_p1 = new Point3d();
Point3d Tuple_p2 = new Point3d();
Point3d Tuple_p3 = new Point3d();

for (int i = 0; i<polys.getPolygonCount(); i++){
polys.getPolygon(i, indicesOut, normalsOut);

polys.getVertex(indicesOut[0], Tuple_p0);
polys.getVertex(indicesOut[1], Tuple_p1);
polys.getVertex(indicesOut[2], Tuple_p2);
polys.getVertex(indicesOut[3], Tuple_p3);
float pointlist = {Tuple_p0.x,Tuple_p0.y,Tuple_p0.z, Tuple_p1.x,Tuple_p1.y,Tuple_p1.z, Tuple_p2.x,Tuple_p2.y,Tuple_p2.z, Tuple_p3.x,Tuple_p3.y,Tuple_p3.z};
SurfaceArea = SurfaceArea+ getAreaOfTriangulation(pointlist)*2;
}

Here’s an example that demonstrates a comparison between the NURBSurface and a duplicate created using captured polygons:

2 Likes