Open CASCADE notes- Topology and Geometry 下载本文

内容发布更新时间 : 2024/5/10 16:50:39星期一 下面是文章的全部内容请认真阅读。

how to convert them into Open CASCADE valid wire. As a result, Shape Healing's ShapeFix_Face has been extended with FixMissingSeam().

Orientation

Face orientation shows how face normal is aligned with its surface normal. If orientation is TopAbs_FORWARD then normals match, if TopAbs_REVERSED then they are opposite to each other.

Face normal shows where body material is – it lies ‘behind' the face. In a correct solid body all face normals go ‘outward' (see below):

Material on the face is defined by orientation of its edges. The side is defined by a cross product of a surface (not face!) normal and edge derivative. Edge derivative equals its 3D curve derivative if edge is forward and is opposite, if reversed. Perhaps easier understanding can be got if to consider edge pcurves: if an edge is forward then material is on the left, if reversed, material is on the right. This may sound complicated but once you get it, it will be simpler ;-). We'll speak more of orientation in a dedicated chapter.

11

Tolerance

Geometric meaning of a face tolerance is a thickness of a pie surrounding a surface.

A face tolerance is used by modeling algorithms significantly more rarely than edge's or vertex' and is often retained at default level (Precision::Confusion()).

12

By convention, Open CASCADE requires that the following condition is respected:

Face tolerance <= Edge tolerance <= Vertex tolerance, where an Edge lies on a Face, and a Vertex – on an Edge.

Triangulation

In addition to underlying surface, a face may contains a tessellated

representation (composed of triangles). It is computed, for example, when a face is displayed in shading mode. Visualization algorithms internally call BRepMesh::Mesh() which calculates and adds triangulation for every face.

Additional location

Unlike an edge or a vertex, a face has an additional location (TopLoc_Location) which is a member field of BRep_TFace. So, do not forget to take it into

account when using underlying surface or triangulation. Stephane has recently pointed this out on a forum.

Creating a face bottom-up and accessing its data

Like in the case of a vertex and an edge, BRep_Builder and BRep_Tool is what you need.

BRep_Builder aBuilder; TopoDS_Face aFace;

aBuilder.MakeFace (aFace, aSurface, Precision::Confusion()); ...

TopLoc_Location aLocation;

Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace, aLocation); gp_Pnt aPnt = aSurf->Value (aU, aV).Transformed (aLocation.Transformation()); //or to transform a surface at once

//Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace); //gp_Pnt aPnt = aSurf->Value (aU, aV);

Handle(Poly_Triangulation) aTri = BRep_Tool::Triangulation (aFace, aLocation);

aPnt = aTri->Nodes.Value (i).Transformed (aLocation.Transformation());

Hope this was not too boring ;-). Just bookmark it and get back when you need it!

To be continued...

Topology and Geometry in Open CASCADE. Part 5

13

Continued...

Other topology types

So far we considered vertex, edge, and face – those which have connection with geometry. The rest – wire, shell, solid, compsolid and compound – do not connect with geometry directly and are just containers for other topological entities:

- wire consists of edge(s); - shell – of face(s); - solid – of shell(s);

- compsolid – of solid(s) sharing common face(s);

- compound – of any arbitrary type (including compound).

A minor note on solids. A solid is expected to contain a single shell that

describes its external boundary. If there are two or more shells, it's considered to be a solid with voids but Open CASCADE can be not too robust to work with such bodies. So beware.

Iteration over children

The are two ways to iterate over child subshapes.

1. Direct children can be retrieved using TopoDS_Iterator.

The following function will traverse through entire shape structure: void TraverseShape (const TopoDS_Shape& theShape) {

TopoDS_Iterator anIt (theShape); for (; anIt.More(); anIt.Next()) {

const TopoDS_Shape& aChild = anIt.Value(); TraverseShape (aChild);

14

} }

TopoDS_Iterator has two flags specifying whether to take into account location and orientation of a parent shape when extracting a child. If the location flag is on then any child is returned as if it were a standalone shape and placed exactly at its location in 3D space (i.e. the user would see an

extracted edge right where it is displayed in the context of its parent wire). If the orientation flag is on, then returned child orientation will be a product of a parent and own child orientation (e.g. two reversed or forward will give forward, reversed and forward in any combination will give reversed). If flags are off, then a child shape is returned with its own location and

orientation as stored inside (recall diagram 2 in Part1). By default both flags are on.

2. Children of a particular subtype

If you want to retrieve all edges of your shape you can do the following: TopExp_Explorer anExp (theShape, TopAbs_EDGE); for (; anExp.More(); anExp.Next()) {

const TopoDS_Edge& anEdge = TopoDS::Edge (anExp.Current()); //do something with anEdge }

TopExp_Explorer has an additional parameter that specifies which parent type you want to skip. For example, if you want to retrieve only floating edges (i.e. not belonging to any face – refer to Part3), you can do the following: TopExp_Explorer aFloatingEdgeExp (theShape; TopAbs_EDGE, TopAbs_FACE);

More on location and orientation

As already described in the previous chapters, an individual location of a geometrically bounded entity (vertex, edge, face) defines a displacement

relative to its underlying geometry. Location of any topology entity (regardless if it has geometric binding or not) also defines a displacement relative to its children. For instance, if a wire has a location consisting of a translation part along the {0, 0, 10} vector then it just means that all its edges are actually translated along the Z axis by 10 units.

The same works for orientation. Parent orientation affects its children orientation when extracting them from inside the shape. There is one

important exception however – which is about edge orientation within a face. If you recall Part4 we discussed there that face material lies on the left of forward edge pcurves and on the right of the reversed edge pcurves. This reversed or forward orientation of an edge must be calculated *excluding*

15