Geometric kernel/UI separation in Eyeshot 2022

With Eyeshot 2022 we make a strong separation between geometric algorithms and object rendering. For this reason, we introduced a new hierarchy of objects under the namespace devDept.Geometry.Entities that can be used to perform geometric modeling without dealing with graphic attributes.

Most standard entities (hereafter, just entity) depend now on their geometric entities (hereafter, primitive). Entities still expose geometric methods and properties but only as wrappers to primitive's ones. Beware that If something is changed directly on the primitive, the related entity must be regenerated to be correctly rendered.

That said, now it's a good practice to work with the geometric kernel and create an entity only when needed for rendering, as shown in the below code:

GBrep box = GBrep.CreateBox(10, 10, 10);
GBrep cyl = GBrep.CreateCylinder(2, 14);
cyl.Translate(5, 5, -2);
GBrep diff = GBrep.Difference(box, cyl)[0];
Brep brep = new Brep(diff);
design1.Entities.Add(brep, Color.Beige);

The most relevant change affects the instance of “composite entities” such as CompositeCurve, Region, etc. that now are defined by a collection of primitives instead of entities.

v2021 v2022
Line ln1 = new Line(Plane.YZ, 50, 90, 50, 0);
Line ln2 = new Line(Plane.YZ, 50, 0, 0, 0);
Line ln3 = new Line(Plane.YZ, 0, 0, 0, 90);

Arc arc = new Arc(Plane.YZ, new Point2D(25, 60), 30, 0, Math.PI);

Point3D[] ps = Curve.Intersection(arc, ln1);
ln1.TrimBy(ps[0], true);
arc.TrimBy(ps[0], true);

ps = Curve.Intersection(arc, ln3);
ln3.TrimBy(ps[0], false);
arc.TrimBy(ps[0], false);

CompositeCurve cc1 = new CompositeCurve(ln1, arc, ln2, ln3);
GLine ln1 = new GLine(Plane.YZ, 50, 90, 50, 0);
GLine ln2 = new GLine(Plane.YZ, 50, 0, 0, 0);
GLine ln3 = new GLine(Plane.YZ, 0, 0, 0, 90);

GArc arc = new GArc(Plane.YZ, new Point2D(25, 60), 30, 0, Math.PI);

Point3D[] ps = GCurve.Intersection(arc, ln1);
ln1.TrimBy(ps[0], true);
arc.TrimBy(ps[0], true);

ps = GCurve.Intersection(arc, ln3);
ln3.TrimBy(ps[0], false);
arc.TrimBy(ps[0], false);

CompositeCurve cc1 = new CompositeCurve(ln1, arc, ln2, ln3);

These are two articles that show how to model using the geometric kernel: Modeling Practice Drawings 125, Modeling Practice Drawing 42.

To switch between entities and primitives is possible to use the static utility methods under the Entity class such as Entitiy.GetPrimitiveFromEntity() or Entity.CreateEntityFromPrimitive().

Why are GEntity.BoxMin/BoxMax properties not available?

Entity.BoxMin/BoxMax properties were computed on entity tessellation vertices. Tessellation is something we want to keep on the UI side. Following this principle, you can generate tessellation vertices from the geometric kernel (using IGEntity.ComputeTessellation() method) but not keep tessellation or bounding box data into its entities.

As a side note, IGCurve implementor classes can use the GetTightBBox() method that returns the exact curve bounding box.

For a rough estimation of entity size, e.g. for tolerances estimation, the GEntity.GetCoarseSampling() method can be a valid alternative.

Was this article helpful?
3 out of 3 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.