[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...

Read more at http://opencascade.blogspot.com/2009/02/topology-and-geometry-in-open-ca...

Roman Lygin's picture
c-riddell's picture

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

Roman Lygin's picture

Thanks much Cory!

Here goes Part 3
http://opencascade.blogspot.com/2009/02/topology-and-geometry-in-open-ca...

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

Roman Lygin's picture
Roman Lygin's picture
Divya's picture

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

thanks!

Roman Lygin's picture

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
---
opencascade.blogspot.com - the Open CASCADE blog

Divya's picture

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!

Roman Lygin's picture

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 !

---
opencascade.blogspot.com - the Open CASCADE blog

Roman Lygin's picture
SINDHU's picture

Roman can you please help me finding the solution to this problem?
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.

SINDHU's picture

Hi Roman
Can you please help me finding the intersection points? I tried using the suggestions posted by vidhyan even then I have a problem. I posted my problem in this thread. Please help...

http://www.opencascade.org/org/forum/thread_15890/

Thanks & Regards
Sindhu

Divya's picture

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?

Divya's picture

continuation of earlier post:

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

Roman Lygin's picture

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;

//add your edges to aWD in the loop
for (...) {
aWD->Add (anEdge);
}
aShFW->Load (aWD);
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
---
opencascade.blogspot.com - the Open CASCADE blog

Divya's picture

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?

Pawel's picture

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.

http://www.tes-cax.de/index-de/download.html

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

Cheers
Pawel

tank's picture

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?
Thanks for your sharing!

Pawel's picture

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

tank's picture

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

Roman Lygin's picture

Hi Pawel,

Posted my thoughts here

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

---
opencascade.blogspot.com - the Open CASCADE blog
www.cadexchanger.com - CAD Exchanger, your 3D data translator

SINDHU's picture

Hi Roman,
Can u please go through this thread and help me..

http://www.opencascade.org/org/forum/thread_16529/

Thanks a lot
Sindhu

Divya's picture

Hi Roman!

what exactly does ShapeBuild_Edge::CopyReplaceVertices() do?
I mean how does it work?coz when I try building an edge from vertices it leaves a few edges unconnected inside the wire.