# Topology and Geometry in Open CASCADE. Part 3

*Continued...*

OK, let's continue to eat our elephant bit by bit. The next bit is edge. Hope you won't get difficulties with it.**Edge**

Edge is a topological entity that corresponds to 1D object – a curve. It may designate a face boundary (e.g. one of the twelve edges of a box) or just a ‘floating' edge not belonging to a face (imagine an initial contour before constructing a prism or a sweep). Face edges can be shared by two (or more) faces (e.g. in a stamp model they represent connection lines between faces) or can only belong to one face (in a stamp model these are boundary edges). I'm sure you saw all of these types – in default viewer, in wireframe mode, they are displayed in red, yellow and green respectively.

Edge contains several geometric representations (refer to the diagram in Part1):

- Curve C(t) in 3D space, encoded as Geom_Curve. This is considered as a primary representation;

- Curve(s) P(t) in parametric 2D space of a surface underlying each face the edge belongs to. These are often called pcurves and are encoded as Geom2d_Curve;

- Polygonal representation as an array of points in 3D, encoded as Poly_Polygon3D;

- Polygonal representation as an array of indexes in array of points of face triangulation, encoded as Poly_PlygonOnTriangulation.

The latter two are tessellation analogues of exact representations with the help of former two.

These representations can be retrieved using already mentioned BRep_Tool, for instance:

Standard_Real aFirst, aLast, aPFirst, aPLast;

Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (anEdge, aFirst, aLast);

Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface (anEdge, aFace, aPFirst, aPLast);

The edge must have pcurves on all surfaces, the only exception is planes where pcurves can be computed on the fly.

The edge curves must be coherent, i.e. go in one direction. Thus, a point on the edge can be computed using any representation - as C(t), t from [first, last]; S1 (P1x (u), P1y(u)), u from [first1, last1], where Pi – pcurve in parametric space of surface Si **Edge flags**

Edge has two special flags:

- "same range" (BRep_Tool::SameRange()), which is true when first = first_i and last = last_i, i.e. all geometric representations are within the same range;

- "same parameter" (BRep_Tool::SameParameter()), which is true when C(t) = S1(P1x(t), P1y(t)), i.e. any point along the edge corresponds to the same parameter on any of its curves.

Many algorithms assume that they are both set, therefore it is recommended that you ensure that these conditions are respected and flags are set.**Tolerance**

Edge's tolerance is a maximum deviation between its 3D curve and any other representation. Thus, its geometric meaning is a radius of a pipe that goes along its 3D curve and encompass curves restored from all representations.**Special edge types**

There are two kinds of edges that are distinct from others. These are:

- seam edge – one which is shared by the same face twice (i.e. has 2 pcurves on the same surface)

- degenerated edge – one which lies on a surface singularity that corresponds to a single point in 3D space.

The sphere contains both of these types. Seam-edge lies on pcurves corresponding to surface U iso-lines with parameters 0 and 2*PI. Degenerated edges lies on North and South poles and correspond to V iso-lines with parameters –PI/2 and PI/2.

Other examples - torus, cylinder, and cone. Torus has two seam-edges – corresponding to its parametric space boundaries; cylinder has a seam-edge. Degenerated edge represents on a cone apex.

To check if the edge is either seam or degenerated, use BRep_Tool::IsClosed(), and BRep_Tool::Degenerated().**Edge orientation**

Forward edge orientation means that its logical direction matches direction of its curve(s). Reversed orientation means that logical direction is opposite to curve's direction. Therefore, seam-edge always has 2 orientations within a face – one reversed and one forward.*To be continued...*

P.S. As usual, many thanks to those who voted and sent comments. Is this series helpful ?

## 16 comments

Very useful article even for non-beginners. Roman, keep going and go deeper into the geometry/topology stuff.

ReplyDeleteBeside this, the rate buttons don't work on Opera. I voted in IE.

Are you kidding me?

ReplyDeleteDon't doubt more if it is useful or not. This is ESSENTIAL.

I am very faithful to your blog.

Come on, let's go through the faces because I am getting several issues to solve!

As far as possible, you are getting my project alive!

Thank you Roman

OK, folks, thanks for continued support. Yes, face is a next target. Stay tuned ;-)

ReplyDeleteGreat and interesting articles! With such background theory get easier to read throught the OCC code!

ReplyDeleteRoman, thanks for all of this. I've understood OCC for years, but now I start to really understand it.

ReplyDeleteRob

Ever thought about writing "Open CASCADE for Dummies" :)

ReplyDeletePete

Great article Roman, much enjoying the topology series.

ReplyDeleteA little surprised that the face is the following article, I thought Wire was the node up the topology graph? Thanks for your efforts!

Great blog, thanks for posting all this fun stuff.

ReplyDeleteIt would be great if you could elaborate on orientation. It seems to me, that sometimes, the orientation attribute of a TopoDS_Edge refers the orientation of the TopoDS_Edge with respect to the underlying TopoDS_TEdge (or BRepCurve) and other times the orientation of the TopoDS_Edge refers to the orientation of the TopoDS_Edge with respect to the TopoDS_Face that it bounds. I am always confused as to which one I actually have at any given moment.

Thanks for continuous feedback, guys, and high ratings. Appreciate your interest and support.

ReplyDeleteOK to include more details on wires and orientation.

We are working hard here at Intel to release new Beta Update for Parallel Amplifier and Inspector (www.intel.com/go/parallel, fighting with remaining bugs and polishing GUI. In addition to other personal projects, this makes it more challenging to quickly issue posts. But I will keep on, I promise...

Thanks again.

As productive as you are, how the heck did you manage to escape OpenCascade? It's a wonder that they didn't break out handcuffs when you announced you were leaving! :)

ReplyDeleteA Dummies book is not a bad idea. If not, could you at least take your blog posts and put them in a PDF some time? A PDF would be easier if someone wants to print it out.

Hi Roman,

ReplyDeletefirst of all thanks for the series - it's really essential!

However, there's an issues I didn't get. It's about orientation of seam-edges. Why do these always have two different orientations? If there are two separate pcurves for each seam-edge it is possible to decide how those are parameterized, isn't it? Additionally the rule you introduced in part 4 (material on the left for forward edges or on the right for reversed edges) will not be violated if the edges are all forward (or reversed).

If the solution comes in one of the next articles you mentioned in part 4 don't bother answering this post.

Pawel

Mark, I left the company quite gracefully and continue to maintain relationships with many folks there. This is a great team.

ReplyDeletePawel, remember that curve representations (3D and all pcurves) must be consistent – see Part3. Thus, in 2D parametric space they will be parallel and co-directional (see sphere pcurves in figures in Parts 3 and 4). Thus, to keep material on the left on the one and on the right of the other, one must be forward and the other – reversed.

Ok I finally got it! For some reason I misinterpreted the arrows as the edge orientation (not the parameterization direction!).

ReplyDeleteGood Article

ReplyDeleteHi Roman,

ReplyDeleteSay you have a TopoDS_Compound that contains multiple TopoDS_Edge - how would you pick each individual edge through IVtkTools_ShapePicker? For example, say I've constructed a box out of 12 TopoDS_Edge, and combined them using BRep_Builder into a single TopoDS_Compound. I then want to, using the picker, select an edge of the box. How would this be done?

Hi Mark,

ReplyDeleteI've never used the OCC-VTK bundle so cannot say for the ShapePicker. I would start with IVtkDraw which demonstrates the bundle in action (though perhaps on X11 only).

Good luck!

Roman