Hide menu
No Matches

Defines a topological face. More...

#include <cadex/ModelData_Face.hxx>

Inheritance diagram for cadex::ModelData_Face:

Public Member Functions

 ModelData_Face (const ModelData_Surface &theSurface, bool theMakeWire=false)
 ModelData_Face (const ModelData_Surface &theSurface, const ModelData_Wire &theWire)
 ModelData_Face (const ModelData_Surface &theSurface, double theUMin, double theUMax, double theVMin, double theVMax)
 ModelData_Face (const TopoDS_Face &)
 operator const TopoDS_Face & () const
 Cast operator.
 operator TopoDS_Face & ()
 Cast operator.
bool Append (const ModelData_Wire &theWire)
 Adds a wire to the face.
ModelData_Surface Surface () const
 Returns underlying surface.
ModelData_Wire OuterWire () const
 Returns outer wire.
- Public Member Functions inherited from cadex::ModelData_Shape
 ModelData_Shape ()
 ModelData_Shape (const ModelData_Shape &theOther)
 ModelData_Shape (ModelData_Shape &&theOther)
 Move constructor.
 ~ModelData_Shape ()
ModelData_Shapeoperator= (const ModelData_Shape &theOther)
 Assignment operator.
ModelData_Shapeoperator= (ModelData_Shape &&theOther)
 Move assignment operator.
 operator const TopoDS_Shape & () const
 Casts this object to TopoDS_Shape.
ModelData_ShapeType Type () const
 Returns a shape type.
ModelData_ShapeOrientation Orientation () const
 Returns orientation flag.
ModelData_Shape Reversed () const
 Returns a shape that shares the same geometry and subshape graph but has opposite orientation.
ModelData_Shape Oriented (ModelData_ShapeOrientation theOrientation) const
 Returns a shape that shares the same geometry and subshape graph and has specified orientation.
void Nullify ()
 Nullifies the object.
bool IsNull () const
 Returns true if the object has not been initialized yet.
 operator bool () const
 Returns true if the object is not null.
bool IsEqual (const ModelData_Shape &theOther) const
 Returns true if the shape shares the same geometry and subshape graph, and has equal orientation.
bool IsSame (const ModelData_Shape &theOther) const
 Returns true if the shape shares the same geometry and subshape graph.
internal::ModelData_ShapeImpl * Impl () const
 Returns internal implementation object.

Static Public Member Functions

static const ModelData_FaceCast (const ModelData_Shape &theShape)
 Cast operator.
static ModelData_FaceCast (ModelData_Shape &theShape)
 Cast operator.

Additional Inherited Members

- Protected Member Functions inherited from cadex::ModelData_Shape
 ModelData_Shape (const TopoDS_Shape &theOther, bool)
 ModelData_Shape (internal::ModelData_ShapeImpl *theImpl)
- Protected Attributes inherited from cadex::ModelData_Shape
internal::Base_Handle myImpl
 Internal implementation object.

Detailed Description

Defines a topological face.

The following image depicts an example of a face:


Face resides on a geometrical surface (returned by Surface()) and is bounded by one or several wires. A face must always have at least one explicit outer wire even if it corresponds to a naturally bounded surface (e.g. torus or a sphere).

Orientation() defines whether face normal matches the normal of the underlying surface, or is opposite to it.

Face Boundaries

Face wires must always be closed, both in 3D and in 2D (i.e. parametric space of the underlying surface). Therefore a face lying on a periodical surface on its full period must have an explicit seam-edge (an edge corresponding to surface boundaries).

A face outer wire can be distinguished using the OuterWire() method.

Face wires must be oriented such that they define a closed portion of material. If to look in the direction opposite to a surface normal, p-curves of an outer wire (taking into account edge orientations) must be oriented counter-clockwise, and p-curve of inner wires (if present) - clockwise. This ensures that the face has a finite area.

The following image depicts an example of face with two wires and p-curves in parametric space of the face surface. P-curves of edges with forward orientation are displayed in green, p-curves of edges with reversed orientation are displayed in red:

Face with two wires
P-curves in surface parametric space
Own face orientation must be ignored when defining correct contour orientation (unlike, for instance, ACIS or Parasolid kernels which do take face orientation into account).

The following code snippet demonstrates how to iterate over face edges p-curves:

ModelData_Face aFace = ...;
//always use forward orientation when analyzing pcurves orientation
ModelData_Face aFwdFace = ModelData_Face::Cast (aFace.Oriented (ModelData_SO_Forward));
ModelData_Wire anOuterWire = aFwdFace.OuterWire();
while (i.HasNext()) {
const ModelData_Shape& aWire = i.Next(); //wire
assert (aWire.Type() == ModelData_ST_Wire);
if (aWire.IsSame (anOuterWire)) {
//we are exploring an outer wire
} else {
//we are exploring a hole
ModelData_Shape::Iterator j (aWire);
while (j.HasNext()) {
const ModelData_Shape& aShape = j.Next(); //edge
const ModelData_Edge& anEdge = ModelData_Edge::Cast (aShape);
double aF, aL;
ModelData_Curve2d aPCurve = anEdge.PCurve (aFwdFace, aF, aL);
if (anEdge.Orientation() == ModelData_SO_Forward) {
//face material is on the left from the pcurve
} else {
//face material is on the right from the pcurve
static const ModelData_Edge & Cast(const ModelData_Shape &theShape)
Casts a base class object to ModelData_Edge.
Definition: ModelData_Edge.cxx:688
Defines a topological face.
Definition: ModelData_Face.hxx:32
static const ModelData_Face & Cast(const ModelData_Shape &theShape)
Cast operator.
Definition: ModelData_Face.cxx:282
ModelData_Wire OuterWire() const
Returns outer wire.
Definition: ModelData_Face.cxx:266
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
ModelData_Shape Oriented(ModelData_ShapeOrientation theOrientation) const
Returns a shape that shares the same geometry and subshape graph and has specified orientation.
Definition: ModelData_Shape.cxx:414
Definition: ModelData_Shape.cxx:283
bool IsSame(const ModelData_Shape &theOther) const
Returns true if the shape shares the same geometry and subshape graph.
Definition: ModelData_Shape.cxx:436
ModelData_ShapeType Type() const
Returns a shape type.
Definition: ModelData_Shape.cxx:358
Defines a connected set of edges.
Definition: ModelData_Wire.hxx:31

2D Bounding Box

Face p-curves define a closed contour (or a set of contours in the case of face with holes) in surface parametric space. A 2D bounding box in this surface parametric space can be returned using the ModelAlgo_BoundingBox::Compute() method (its overload accepting ModelData_Face). The following images demonstrate a face lying on a cylindrical surface and its 2D contour and bounding box:

Face on cylindrical surface
2D bounding box

The following example demonstrates how to retrieve this bounding box. Note aHeight below would designate a 3D length of this cylindrical face and if it occupied entire U-range of the cylindrical surface (ModelData_CylindricalSurface) then it would correspond to a cylinder's height:

ModelData_Face aFace = ...
ModelData_Box2d aBox;
double aHeight = aBox.YRange(); //cylindrical surface is parametrized by length in V-range
static void Compute(const ModelData_Model &theSG, ModelData_Box &theBox, bool theForcedFlush=true)
Returns a bounding box of a scene graph.
Definition: ModelAlgo_BoundingBox.cxx:346
exploring/brepgeometry/Program.cs, exploring/brepgeometry/main.cxx, exploring/breprepresentation/Program.cs, exploring/breprepresentation/main.cxx, meshing/visualizationmesher/Program.cs, meshing/visualizationmesher/main.cxx, modeling/assembly/Program.cs, modeling/assembly/main.cxx, modeling/brep/Program.cs, and modeling/brep/main.cxx.

Constructor & Destructor Documentation

◆ ModelData_Face() [1/3]

cadex::ModelData_Face::ModelData_Face ( const ModelData_Surface theSurface,
bool  theMakeWire = false 


Creates a face on entire surface's definition domain:

Constructing face from surface

The surface must have bounded definition domain (see ModelData_Surface::Domain()). This is the case for instance for ModelData_BSplineSurface.

theMakeWire specifies whether the wire must be automatically constructed and added to the face.

◆ ModelData_Face() [2/3]

cadex::ModelData_Face::ModelData_Face ( const ModelData_Surface theSurface,
const ModelData_Wire theWire 


Creates a face from a surface and explicitly defined wire:

Constructing face from surface and wire

The wire's edge must lie on a surface (within proximity of their tolerances).

◆ ModelData_Face() [3/3]

cadex::ModelData_Face::ModelData_Face ( const ModelData_Surface theSurface,
double  theUMin,
double  theUMax,
double  theVMin,
double  theVMax 


Creates a face from a surface and its parametric definition domain:

Input surface
Surface definition domain

The parameters must be within surface's definition domain (see ModelData_Surface::Domain()) unless it is periodic. theUMax must be greater than theUMin by at least 1e-9.

Member Function Documentation

◆ Append()

bool cadex::ModelData_Face::Append ( const ModelData_Wire theWire)

Adds a wire to the face.

There must be single outer wire and zero, one or more inner wires (i.e. holes). It is strongly recommended (although not required) that the first wire being added is an outer wire.

Returns false if theEdge is null and true otherwise.

modeling/assembly/Program.cs, and modeling/brep/Program.cs.

◆ Cast() [1/2]

const ModelData_Face & cadex::ModelData_Face::Cast ( const ModelData_Shape theShape)

Cast operator.

Casts theShape to a face. If theShape is not a face then behavior is undefined (assert will be thrown in debug mode).

exploring/brepgeometry/Program.cs, exploring/breprepresentation/Program.cs, and meshing/visualizationmesher/Program.cs.

◆ Cast() [2/2]

ModelData_Face & cadex::ModelData_Face::Cast ( ModelData_Shape theShape)

Cast operator.

Casts theShape to a face. If theShape is not a face then behavior is undefined (assert will be thrown in debug mode).

◆ OuterWire()

ModelData_Wire cadex::ModelData_Face::OuterWire ( ) const

Returns outer wire.

Outer wire is not necessarily the first one in the list of wires even if this is often the case. If the face has single wire then returns that wire.

Recognizing the outer wire can be relatively compute-intensive operation in the case of multiple wires.