OpenLexocad  27.1
OpenLxApp::FacetedBrep Class Reference

A faceted brep is a simple form of boundary representation model in which all faces are planar and all edges are straight lines. A faceted B-rep has to meet the same topological constraints as the manifold solid Brep. (Definition from ISO/CD 16739:2011) More...

#include <FacetedBrep.h>

Inheritance diagram for OpenLxApp::FacetedBrep:
OpenLxApp::Geometry OpenLxApp::DocObject

Public Member Functions

std::vector< int > getModel () const
 
void setModel (const std::vector< int > &aValue)
 
std::vector< Geom::PntgetPoints () const
 
void setPoints (const std::vector< Geom::Pnt > &aValue)
 
 ~FacetedBrep (void)
 
bool setShape (pShape aShape)
 
- Public Member Functions inherited from OpenLxApp::Geometry
virtual ~Geometry (void)
 
pShape computeShape (bool checkShape=false)
 
pConstShape getShape (void) const
 
double getPrecision () const
 
void setPrecision (double p)
 
Geom::Bnd_Box getBoundingBox () const
 
- Public Member Functions inherited from OpenLxApp::DocObject
std::shared_ptr< DocumentgetDocument () const
 
bool isNew () const
 
bool isUpdated () const
 
bool isValid () const
 
bool hasErrors () const
 
void touch ()
 
LxIfc4::LxIfc4EntityEnum getEntityType () const
 
std::string getEntityTypeAsString () const
 
std::shared_ptr< Core::DbgInfogetDbgInfo () const
 
 DocObject (Core::DocObject *aObject)
 
virtual ~DocObject (void)
 
Core::DocObject__getObj__ () const
 

Additional Inherited Members

- Protected Member Functions inherited from OpenLxApp::Geometry
 Geometry ()=default
 
- Protected Member Functions inherited from OpenLxApp::DocObject
 DocObject ()
 
- Protected Attributes inherited from OpenLxApp::DocObject
Core::DocObject_coreObj = nullptr
 

Detailed Description

A faceted brep is a simple form of boundary representation model in which all faces are planar and all edges are straight lines. A faceted B-rep has to meet the same topological constraints as the manifold solid Brep. (Definition from ISO/CD 16739:2011)

Introduction

A faceted brep can be used to create a polyhedron. Polyhedra are 3D objects only composed by planar faces. Each face again has to be limited by straight edges. An edge is - in this case - defined as a straight line between two points (respectively, vertices).

Creating a faceted brep via this hirachical (or topological) approach is totally valid. To do so, you have to:

  1. Define your set of Geom::Pnt.
  2. Form a Topo::Edge each of two different Geom::Pnt (Have a look at Topo::EdgeTool).
  3. Combine differend Topo::Edge to a set of Topo::Wire in a connected order (Have a look at Topo::WireTool)
  4. Create Topo::Face each of one outer Topo::Wire and multiple (including zero) inner Topo::Wire (Have a look at Topo::FaceTool).
  5. Merge the different Topo::Face into a Topo::Shape (Have a look at Topo::ShapeTool).
  6. If this Topo::Shape is a polyhedron (in the mathematical sense), you can use setShape to make it become a faceted brep.


Another way to create a faceted brep is to use the setPoints and setModel functions.
The approach is different here.

  1. Set up a list of Geom::Pnt and pass them to the faceted brep via setPoints
  2. Set up a list of indices, pointing into this pointist and pass them to the faceted brep via setModel

These indices have to follow a specific format and order:

The format:
Each index refers to a point in the pointlist. A sequence of indices represents a wire. Since faces are allowed to have voids (as long as the resulting shape is still a polyhedron), one face can be made of several wires. To indicate the end of a wire, the index -2 is used. To indicate the end of a face, the index -1 is used. If your face is only constructed by a single wire, you still have to use the -2 to indicate the end of the wire, before indicating the end of the face (by a -1).

The order:
The order of the indices is used to determine, which side of it is the "outside" and which one is the "inside".
Looking at the face from the outside, the indices representing the outer boundary of the face, have to follow a counter clockwise order. To cut voids into a face, the indices of this void-wire have to follow a clockwise order (again, looking from the outside of the face onto it).
The following image shows a face with a void from the "outside". The red arrows are indicating the winding (respectively order):

FacetedBrep_winding_of_face_with_void.png
The winding of a face with a void.

Examples

The following example shows, how you can create a simple box with a side length of 10 as a faceted brep. It is created by setting a list of points and indices (as described in the second approach).

import OpenLxApp as lx
import Geom, Base
app = lx.Application.getInstance()
doc = app.getActiveDocument()
# Define the eight points of a box.
points = Geom.vector_Pnt([Geom.Pnt(0, 0, 0), Geom.Pnt(10, 0, 0), Geom.Pnt(10, 10, 0), Geom.Pnt(0, 10, 0),
Geom.Pnt(0, 0, 10), Geom.Pnt(10, 0, 10), Geom.Pnt(10, 10, 10), Geom.Pnt(0, 10, 10)])
# Define the indices for each face.
# Note the -2 at the end of each wire and -1 at the end of each face definition.
indices = Base.vector_int([3, 2, 1, 0, -2, -1, # Bottom
4, 5, 6, 7, -2, -1, # Top
0, 1, 5, 4, -2, -1, # Side (Outside in direction: -y)
1, 2, 6, 5, -2, -1, # Side (Outside in direction: +x)
2, 3, 7, 6, -2, -1, # Side (Outside in direction: +y)
3, 0, 4, 7, -2, -1] # Side (Outside in direction: -x)
)
# Create the faceted brep.
fbr = lx.FacetedBrep.createIn(doc)
# Set the points for the brep.
fbr.setPoints(points)
# Set the faces.
fbr.setModel(indices)
# To draw the faceted brep, assign it to an Element and recompute the current document.
fbrElement = lx.Element.createIn(doc)
fbrElement.setDiffuseColor(Base.Color(32,192,0,255))
fbrElement.setGeometry(fbr)
doc.recompute()
The result:
FacetedBrep_box.png
A simple box, created as faceted brep.

This example extends the previous one, by carving a void into the top and bottom face. Again, the winding is important here. To cut out the voids, the inner points have to be accessed in clockwise order, where the outer bounds of each face have to be accessed in counterclockwise order. To make the object still be a polyhderon, additional faces have to be added inbetween the voids. The result is a box with a squared tunnel.

import OpenLxApp as lx
import Geom, Base
app = lx.Application.getInstance()
doc = app.getActiveDocument()
# Define the eight points of a box plus the 8 points for the two openings.
# These are the same points as in the first example, extended by 8 points on the bottom and top plane.
points = Geom.vector_Pnt([Geom.Pnt(0, 0, 0), Geom.Pnt(10, 0, 0), Geom.Pnt(10, 10, 0), Geom.Pnt(0, 10, 0),
Geom.Pnt(0, 0, 10), Geom.Pnt(10, 0, 10), Geom.Pnt(10, 10, 10), Geom.Pnt(0, 10, 10),
Geom.Pnt(3, 3, 0), Geom.Pnt(7, 3, 0), Geom.Pnt(7, 7, 0), Geom.Pnt(3, 7, 0),
Geom.Pnt(3, 3, 10), Geom.Pnt(7, 3, 10), Geom.Pnt(7, 7, 10), Geom.Pnt(3, 7, 10)])
# Define the indices for each face.
# Note the -2 at the end of each wire and -1 at the end of each face definition.
indices = Base.vector_int([ 3, 2, 1, 0, -2, 8, 9, 10, 11, -2, -1, # Bottom - First four indices indicate the outer boundary, second four (non negative) indices the inner one.
4, 5, 6, 7, -2, 15, 14, 13, 12, -2, -1, # Top - First four indices indicate the outer boundary, second four (non negative) indices the inner one.
0, 1, 5, 4, -2, -1, # Side (Outside in direction: -y)
1, 2, 6, 5, -2, -1, # Side (Outside in direction: +x)
2, 3, 7, 6, -2, -1, # Side (Outside in direction: +y)
3, 0, 4, 7, -2, -1, # Side (Outside in direction: -x)
9, 8, 12, 13, -2, -1, # Inner side (Outside in direction: +y)
10, 9, 13, 14, -2, -1, # Inner side (Outside in direction: -x)
11, 10, 14, 15, -2, -1, # Inner side (Outside in direction: -y)
8, 11, 15, 12, -2, -1] # Inner side (Outside in direction: +x)
)
# Create the faceted brep.
fbr = lx.FacetedBrep.createIn(doc)
# Set the points for the brep.
fbr.setPoints(points)
# Set the faces.
fbr.setModel(indices)
# To draw the faceted brep, assign it to an Element and recompute the current document.
fbrElement = lx.Element.createIn(doc)
fbrElement.setDiffuseColor(Base.Color(32,192,0,255))
fbrElement.setGeometry(fbr)
doc.recompute()
The result:
FacetedBrep_box_with_tunnel.png
A simple box with a tunnel, created as faceted brep.
See also
Documentation from IFC4: IfcFacetedBrep

Constructor & Destructor Documentation

◆ ~FacetedBrep()

OpenLxApp::FacetedBrep::~FacetedBrep ( void  )

Member Function Documentation

◆ getModel()

std::vector<int> OpenLxApp::FacetedBrep::getModel ( ) const

◆ getPoints()

std::vector<Geom::Pnt> OpenLxApp::FacetedBrep::getPoints ( ) const

◆ setModel()

void OpenLxApp::FacetedBrep::setModel ( const std::vector< int > &  aValue)

◆ setPoints()

void OpenLxApp::FacetedBrep::setPoints ( const std::vector< Geom::Pnt > &  aValue)

◆ setShape()

bool OpenLxApp::FacetedBrep::setShape ( pShape  aShape)

The documentation for this class was generated from the following file: