# [Blog] Topology and Geometry in Open CASCADE

Let us consider these fundamental concepts of Open CASCADE. From time to time questions about them pop up on the forum, so I hope this post will be useful for many readers...

Roman- thanks for taking the time to write this up. It's very helpful to someone like me who is new to the project and doesn't know the history behind everything.

Cory

Thanks much Cory!

This seems to be the longest series so far...

Hi Roman,
thats really helpful!can u please tell me where can i find information about converting edges to wires.

thanks!

Hi Divya,

Hmm, edges are not *converted* to wires; a wire is a container of edges (see Part 5).
If you need a wire of 1 to 4 edges, the simplest way is to use BRepBuilderAPI_MakeWire. Otherwise, just use BRep_Builder to iteratively add edges into a wire.
Of course, keep in mind that edges must share connecting vertices.

Hope this helps.
Roman
---

Hi Roman!
Ya I need to group edges into their respective wires,but when I use ConnectEdgestoWires() function it gives wrong results! It is about not being able to group all the edges into wires as they(edges) are not reacheable in a few cases!how do i group them in such case!please do reply!

void ShapeAnalysis_FreeBounds::ConnectEdgesToWires(
Handle(TopTools_HSequenceOfShape)& edges,
const Standard_Real toler,
const Standard_Boolean shared,
Handle(TopTools_HSequenceOfShape)& wires)

---Purpose: Builds sequnce of out of sequence of not sorted
-- .
-- Tries to build wires of maximum length. Building a wire is
-- stopped when no edges can be connected to it at its head or
-- at its tail.
--
-- Orientation of the edge can change when connecting.
-- If is True connection is performed only when
-- adjacent edges share the same vertex.
-- If is False connection is performed only when
-- ends of adjacent edges are at distance less than .

The best is when you use shared=True to use topological connectivity, in this case the tolerance is simply ignored. For each edge in a sequence the method unwinds a wire of maximum possible length. Used edges are removed from the sequence. It repeats this for any unused edge until all are used. As a result you get a sequence of wires. There must be no edges left orphan.

If your edges do not share vertices you might want to use shared=false and specify a tolerance but the principle remains.

Hope this helps.
Roman
P.S. God, I wrote this method 10+ years ago. How the time flies !

---

I have used a Geom_Curve to build a curve and used Geom_OffsetCurve and found the offset of the Basis curve. But the problem is that the offset curve obtained is self-intersecting at different locations. So,I want to trim the unnecessary curve and want to display only the exact offset curve (in which every point on the offset curve should be D distance away from the Basis curve) and also the resultant offset curve obtained should be C0 continuous.

Hi Roman

Thanks & Regards
Sindhu

Hi Roman!
I ordered edges using ShapeAnalysis_WireOrder. everything is fine.But,the edges are not connected as last vertex of edge1-to-first vertex of edge2.So,when i try to categorise them into loops using ConnectEdgesToWires it happens to check only the first and last vertex of next edge. therefore they result is wrong.

Can you please tell me any other way to put these ordered edges in last vertex of edge1 to First vertex edge2 order as in.( LV1-FV2,LV2-FV3,LV3-FV4)or Do I have to do it manually?

continuation of earlier post:

the checking of next edge in a wire is done only at the tail and not head.

Sorry to hear you are still struggling :-(.
Why wouldn't you just try ShapeFix_Wire to get your wire reordered, connected and closed ?

Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire;
Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData;

for (...) {
}
aShFW->ClosedWireMode() = Standard_True; //or False - as needed
aShFW->FixReorder();
aShFW->FixConnected();

TopoDS_Wire aNewWire = aShFW->Wire();

Maybe this is just what you need ?
Of course, this only makes sense for a case of a single wire.

Good luck.
Roman
---

Hi Roman!
i have to group edges into their loops.
I used connectedgestowires function. It is highly inconsistent when tried for multiple levels.
as it gives different results for same topology when called multiple no of times?

Hi everyone,

inspired by Roman's blog I started implementing kind of a topology browser as a part of Total Engineer. Those of you who try to build topological structures bottom-up might find it useful.

This is an initial release of the browser so it's neither perfect nor complete. Any feedback is - as always - appreciated.

Cheers
Pawel

Hi,Pawel
Thanks for your Total Engineer, i have intalled it and can't find related material,so it is difficult for me to use it. Could you please give me some more materials related TE and tell me how to use it?

Hi Tank,

there are a couple of documents accompanying the software. First of all, pressing F1 will show a reference help. Besides, in windows start menu you will find a 'Documentation' directory containing a manual. I would suggest having a look at it.

If you want to use the TopologyExplorer you can either generate some basic shapes like boxes or spheres using scripts (description in the manual) or import external models from STEP, IGES, BREp etc. After that, you can use the browser to traverse through the topological structure of the shape and query its properties using the PropertiesExplorer.

Pawel

Hi,Pawel
Thanks for your suggestions.i will try our best to study it

Hi Pawel,

Posted my thoughts here

Overall I think this will be very valuable.
Good luck.
Roman

---