Path::Area Class Reference

Base class for FreeCAD wrapping of libarea. More...

#include <Area.h>

Classes

struct  Shape
 

Public Member Functions

void add (const TopoDS_Shape &shape, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OPCODE))
 Add a child shape with given operation code. More...
 
 Area (const Area &other, bool deep_copy=true)
 
 Area (const AreaParams *params=nullptr)
 Declare all parameters defined in #AREA_PARAMS_ALL as member variable. More...
 
void clean (bool deleteShapes=false)
 Clean internal caches. More...
 
const std::list< ShapegetChildren () const
 
const AreaParamsgetParams () const
 Get the current configuration. More...
 
TopoDS_Shape getPlane (gp_Trsf *trsf=nullptr)
 Return the current active workplane. More...
 
std::size_t getSectionCount ()
 Return the number of sections. More...
 
TopoDS_Shape getShape (int index=-1)
 Get the combined shape. More...
 
bool isBuilt () const
 
TopoDS_Shape makeOffset (int index=-1, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OFFSET), int reoirent=0, bool from_center=false)
 Generate an offset of the combined shape. More...
 
TopoDS_Shape makePocket (int index=-1, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_POCKET))
 Make a pocket of the combined shape. More...
 
std::vector< std::shared_ptr< Area > > makeSections (PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_SECTION_EXTRA), const std::vector< double > &heights=std::vector< double >(), const TopoDS_Shape &plane=TopoDS_Shape())
 Make a pocket of the combined shape. More...
 
void setParams (const AreaParams &params)
 Config this Area object. More...
 
void setPlane (const TopoDS_Shape &shape)
 Set a working plane. More...
 
virtual ~Area ()
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction. More...
 
 BaseClass (const BaseClass &)=default
 
virtual PyObjectgetPyObject ()
 This method returns the Python wrapper for a C++ object. More...
 
virtual Type getTypeId () const
 
bool isDerivedFrom (const Type type) const
 
BaseClassoperator= (const BaseClass &)=default
 
virtual void setPyObject (PyObject *)
 
virtual ~BaseClass ()
 Destruction. More...
 

Static Public Member Functions

static void abort (bool aborting)
 
static bool aborting ()
 
static int addShape (CArea &area, const TopoDS_Shape &shape, const gp_Trsf *trsf=nullptr, double deflection=0.01, const TopoDS_Shape *plane=nullptr, bool force_coplanar=true, CArea *areaOpen=nullptr, bool to_edges=false, bool reorient=true)
 Add a OCC generic shape to CArea. More...
 
static void addWire (CArea &area, const TopoDS_Wire &wire, const gp_Trsf *trsf=nullptr, double deflection=0.01, bool to_edges=false)
 Add a OCC wire shape to CArea. More...
 
static const AreaStaticParamsgetDefaultParams ()
 
static bool isCoplanar (const TopoDS_Shape &s1, const TopoDS_Shape &s2)
 Check if two OCC shape is coplanar. More...
 
static int project (TopoDS_Shape &out, const TopoDS_Shape &in, const AreaParams *params=nullptr, const TopoDS_Shape *work_plane=nullptr)
 
static void setDefaultParams (const AreaStaticParams &params)
 
static void setWireOrientation (TopoDS_Wire &wire, const gp_Dir &dir, bool ccw)
 
static void showShape (const TopoDS_Shape &shape, const char *name, const char *fmt=nullptr,...)
 
static std::list< TopoDS_Shape > sortWires (const std::list< TopoDS_Shape > &shapes, bool has_start=false, gp_Pnt *pstart=nullptr, gp_Pnt *pend=nullptr, double *stepdown_hint=nullptr, short *arc_plane=nullptr, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_SORT))
 Group shapes by their plane, and return a list of sorted wires. More...
 
static void toPath (Toolpath &path, const std::list< TopoDS_Shape > &shapes, const gp_Pnt *pstart=nullptr, gp_Pnt *pend=nullptr, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_PATH))
 Convert a list of wires to gcode. More...
 
static TopoDS_Shape toShape (const CArea &area, bool fill, const gp_Trsf *trsf=nullptr, int reoirent=0)
 Convert curves in CArea into an OCC shape. More...
 
static TopoDS_Shape toShape (const CCurve &curve, const gp_Trsf *trsf=nullptr, int reorient=0)
 Convert a single curve into an OCC wire. More...
 
- Static Public Member Functions inherited from Base::BaseClass
static void * create ()
 
static Type getClassTypeId ()
 
static void init ()
 

Protected Member Functions

void addToBuild (CArea &area, const TopoDS_Shape &shape)
 Called by build() to add children shape. More...
 
void build ()
 Called internally to combine children shapes for further processing. More...
 
void explode (const TopoDS_Shape &shape)
 
TopoDS_Shape findPlane (const TopoDS_Shape &shape, gp_Trsf &trsf)
 
std::list< ShapegetProjectedShapes (const gp_Trsf &trsf, bool inverse=true) const
 
void makeOffset (std::list< std::shared_ptr< CArea > > &areas, PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OFFSET), bool from_center=false)
 Obtain a list of offset areas. More...
 
TopoDS_Shape makePocket ()
 Make a pocket of the combined shape. More...
 
TopoDS_Shape toShape (CArea &area, short fill, int reorient=0)
 Called internally to obtain the combined children shapes. More...
 

Protected Attributes

std::unique_ptr< CAreamyArea
 
std::unique_ptr< CAreamyAreaOpen
 
bool myHaveFace
 
bool myHaveSolid
 
AreaParams myParams
 
bool myProjecting
 
std::vector< std::shared_ptr< Area > > mySections
 
TopoDS_Shape myShape
 
bool myShapeDone
 
TopoDS_Shape myShapePlane
 
std::list< ShapemyShapes
 
int mySkippedShapes
 
gp_Trsf myTrsf
 
TopoDS_Shape myWorkPlane
 

Static Protected Attributes

static bool s_aborting
 
static AreaStaticParams s_params
 

Additional Inherited Members

- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=nullptr)
 

Detailed Description

Base class for FreeCAD wrapping of libarea.

Constructor & Destructor Documentation

◆ Area() [1/2]

Area::Area ( const AreaParams params = nullptr)

Declare all parameters defined in #AREA_PARAMS_ALL as member variable.

References setParams().

◆ Area() [2/2]

Area::Area ( const Area other,
bool  deep_copy = true 
)

◆ ~Area()

Area::~Area ( )
virtual

References clean().

Member Function Documentation

◆ abort()

void Area::abort ( bool  aborting)
static

◆ aborting()

bool Area::aborting ( )
static

References s_aborting.

Referenced by abort().

◆ add()

void Area::add ( const TopoDS_Shape &  shape,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OPCODE)   
)

Add a child shape with given operation code.

No validation is done at this point. Exception will be thrown when asking for output shape, if any of the children shapes is not valid or not coplanar

  • shape: the child shape
  • op: operation code, see #AREA_PARAMS_OPCODE

References clean(), myHaveSolid, and myShapes.

Referenced by build(), Path::FeatureArea::execute(), getShape(), and project().

◆ addShape()

int Area::addShape ( CArea area,
const TopoDS_Shape &  shape,
const gp_Trsf *  trsf = nullptr,
double  deflection = 0.01,
const TopoDS_Shape *  plane = nullptr,
bool  force_coplanar = true,
CArea areaOpen = nullptr,
bool  to_edges = false,
bool  reorient = true 
)
static

Add a OCC generic shape to CArea.

  • area: output converted curved object to here
  • shape: input shape object
  • trsf: optional transform matrix to transform the wire shape into XY0 plane.
  • deflection: for defecting non circular curves
  • plane: a shape for testing coplanar
  • force_coplaner: if true, discard non-coplanar shapes.
  • areaOpen: for collecting open curves. If not supplied, open curves are added to area
  • to_edges: separate open wires to individual edges
  • reorient: reorient closed wires for wire only shape
Returns
Returns the number of non coplaner. Planar testing only happens if plane is supplied

References addWire(), isCoplanar(), CArea::m_curves, and CArea::Reorder().

Referenced by addToBuild().

◆ addToBuild()

void Area::addToBuild ( CArea area,
const TopoDS_Shape &  shape 
)
protected

Called by build() to add children shape.

Mainly for checking if there is any faces for auto fill

References addShape(), getPlane(), CArea::m_curves, myArea, myAreaOpen, myHaveFace, myHaveSolid, myParams, myProjecting, mySkippedShapes, and myTrsf.

Referenced by build().

◆ addWire()

void Area::addWire ( CArea area,
const TopoDS_Wire &  wire,
const gp_Trsf *  trsf = nullptr,
double  deflection = 0.01,
bool  to_edges = false 
)
static

Add a OCC wire shape to CArea.

  • area: output converted curved object to here
  • wire: input wire object
  • trsf: optional transform matrix to transform the wire shape into XY0 plane.
  • deflection: for discretizing non circular curves
  • to_edges: if true, discretize all curves, and insert as open line segments

References CArea::append(), CCurve::append(), CCurve::IsClosed(), CCurve::m_vertices, CArea::move(), draftfunctions.move::move(), and CCurve::UnFitArcs().

Referenced by addShape(), and explode().

◆ build()

◆ clean()

void Area::clean ( bool  deleteShapes = false)

Clean internal caches.

The combined shapes is cached internally to make other operation more efficient, such as makeOffset() and makePocket()

  • deleteShapes: if true, delete all children shapes.

References myArea, myAreaOpen, myHaveFace, myHaveSolid, mySections, myShape, myShapeDone, myShapePlane, and myShapes.

Referenced by add(), build(), Path::FeatureArea::execute(), setParams(), setPlane(), and ~Area().

◆ explode()

void Area::explode ( const TopoDS_Shape &  shape)
protected

◆ findPlane()

TopoDS_Shape Area::findPlane ( const TopoDS_Shape &  shape,
gp_Trsf &  trsf 
)
protected

Referenced by makeSections(), and setPlane().

◆ getChildren()

const std::list< Shape > Path::Area::getChildren ( ) const

◆ getDefaultParams()

const AreaStaticParams & Area::getDefaultParams ( )
static

References s_params.

◆ getParams()

const AreaParams & Path::Area::getParams ( ) const

Get the current configuration.

◆ getPlane()

TopoDS_Shape Area::getPlane ( gp_Trsf *  trsf = nullptr)

Return the current active workplane.

  • trsf: optional return of a transformation matrix that will bring the found plane to XY0 plane.

If no workplane is set using setPlane(), the active workplane is derived from the added children shapes using the same algorithm empolyed by setPlane().

References myShapePlane, myShapes, myTrsf, and myWorkPlane.

Referenced by addToBuild(), build(), explode(), and makeSections().

◆ getProjectedShapes()

std::list< Area::Shape > Area::getProjectedShapes ( const gp_Trsf &  trsf,
bool  inverse = true 
) const
protected

References myParams, myShapes, mySkippedShapes, myWorkPlane, and project().

Referenced by build(), and makeSections().

◆ getSectionCount()

std::size_t Path::Area::getSectionCount ( )

Return the number of sections.

Referenced by Path::FeatureArea::execute().

◆ getShape()

TopoDS_Shape Area::getShape ( int  index = -1)

Get the combined shape.

  • index: index of the section, -1 for all sections. No effect on non-sectioned area.

References add(), build(), getShape(), makeOffset(), makePocket(), myArea, myParams, myShape, myShapeDone, PARAM_FIELDS, and toShape().

Referenced by Path::FeatureArea::execute(), getShape(), and project().

◆ isBuilt()

bool Area::isBuilt ( ) const

References myArea, and mySections.

Referenced by Area(), build(), and Path::FeatureArea::mustExecute().

◆ isCoplanar()

bool Area::isCoplanar ( const TopoDS_Shape &  s1,
const TopoDS_Shape &  s2 
)
static

Check if two OCC shape is coplanar.

Referenced by addShape(), and explode().

◆ makeOffset() [1/2]

TopoDS_Shape Path::Area::makeOffset ( int  index = -1,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OFFSET)  ,
int  reoirent = 0,
bool  from_center = false 
)

Generate an offset of the combined shape.

See #AREA_PARAMS_OFFSET for description of the arguments. If more than one offset is requested, a compound shape is return containing all offset shapes as wires regardless of Fill setting.

◆ makeOffset() [2/2]

void Path::Area::makeOffset ( std::list< std::shared_ptr< CArea > > &  areas,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_OFFSET)  ,
bool  from_center = false 
)
protected

Obtain a list of offset areas.

See #AREA_PARAMS_OFFSET for description of the arguments.

Referenced by getShape().

◆ makePocket() [1/2]

TopoDS_Shape Path::Area::makePocket ( )
protected

Make a pocket of the combined shape.

User #AREA_PARAMS_POCKET setting in myParams.

Referenced by getShape().

◆ makePocket() [2/2]

TopoDS_Shape Path::Area::makePocket ( int  index = -1,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_POCKET)   
)

Make a pocket of the combined shape.

See #AREA_PARAMS_POCKET for description of the arguments.

◆ makeSections()

std::vector< shared_ptr< Area > > Area::makeSections ( PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_SECTION_EXTRA)  ,
const std::vector< double > &  heights = std::vector<double>(),
const TopoDS_Shape &  plane = TopoDS_Shape() 
)

Make a pocket of the combined shape.

  • heights: optional customized heights of each section. The meaning of each height depends on section mode. If none is given, the section heights is determined by the section settings in this Area object (configured through setParams()).
  • plane: the section plane if the section mode is SectionModeWorkplane, otherwise ignored

See #AREA_PARAMS_EXTRA for description of the arguments. Currently, there is only one argument, namely mode for section mode.

References Part::FaceMaker::addWire(), Part::FaceMaker::Build(), findPlane(), getPlane(), getProjectedShapes(), myParams, myShapes, project(), Part::FaceMakerBullseye::setPlane(), showShape(), and draftutils.utils::tolerance().

Referenced by build().

◆ project()

◆ setDefaultParams()

void Area::setDefaultParams ( const AreaStaticParams params)
static

◆ setParams()

void Area::setParams ( const AreaParams params)

Config this Area object.

References clean(), and myParams.

Referenced by Area(), and Path::FeatureArea::execute().

◆ setPlane()

void Area::setPlane ( const TopoDS_Shape &  shape)

Set a working plane.

  • shape: a shape defining a working plane.

The supplied shape does not need to be planar. Area will try to find planar sub-shape (face, wire or edge). If more than one planar sub-shape is found, it will prefer the top plane parallel to XY0 plane.

If no working plane are set, Area will try to find a working plane from the added children shape using the same algorithm

References clean(), findPlane(), myTrsf, and myWorkPlane.

Referenced by Path::FeatureArea::execute().

◆ setWireOrientation()

void Area::setWireOrientation ( TopoDS_Wire &  wire,
const gp_Dir &  dir,
bool  ccw 
)
static

◆ showShape()

void Area::showShape ( const TopoDS_Shape &  shape,
const char *  name,
const char *  fmt = nullptr,
  ... 
)
static

◆ sortWires()

std::list< TopoDS_Shape > Area::sortWires ( const std::list< TopoDS_Shape > &  shapes,
bool  has_start = false,
gp_Pnt *  pstart = nullptr,
gp_Pnt *  pend = nullptr,
double *  stepdown_hint = nullptr,
short *  arc_plane = nullptr,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_SORT)   
)
static

Group shapes by their plane, and return a list of sorted wires.

The output wires is ordered by its occupied plane, and sorted to minimize traval distance

  • shapes: input list of shapes.
  • has_start: if false or pstart is 0, then a start point will be auto selected.
  • pstart: optional start point. If has_start is false, then the auto selected start point will be returned with this point if not NULL.
  • pend: optional output containing the ending point of the returned
  • stepdown_hint: optional output of a hint of step down as the max distance between two sections.
  • arc_plane: optional arc plane selection, if given the found plane will be returned. See #AREA_PARAMS_ARC_PLANE for more details.

See #AREA_PARAMS_SORT for other arguments

Returns
sorted wires

Referenced by toPath().

◆ toPath()

void Area::toPath ( Toolpath path,
const std::list< TopoDS_Shape > &  shapes,
const gp_Pnt *  pstart = nullptr,
gp_Pnt *  pend = nullptr,
PARAM_ARGS_DEF(PARAM_FARG, AREA_PARAMS_PATH)   
)
static

Convert a list of wires to gcode.

  • path: output toolpath
  • shapes: input list of shapes
  • pstart: output start point,
  • pend: optional output containing the ending point of the returned

See #AREA_PARAMS_PATH for other arguments

References PARAM_FARG, PARAM_FIELDS, PARAM_REF, and sortWires().

Referenced by Path::FeatureShape::execute().

◆ toShape() [1/3]

TopoDS_Shape Area::toShape ( CArea area,
short  fill,
int  reorient = 0 
)
protected

Called internally to obtain the combined children shapes.

References CArea::FitArcs(), myArea, myHaveFace, myParams, myTrsf, and toShape().

Referenced by build(), getShape(), and toShape().

◆ toShape() [2/3]

static TopoDS_Shape Path::Area::toShape ( const CArea area,
bool  fill,
const gp_Trsf *  trsf = nullptr,
int  reoirent = 0 
)
static

Convert curves in CArea into an OCC shape.

  • area: input area object
  • fill: if true, create a face object from the wires
  • trsf: optional transform matrix to transform the shape back into its original position.

◆ toShape() [3/3]

static TopoDS_Shape Path::Area::toShape ( const CCurve curve,
const gp_Trsf *  trsf = nullptr,
int  reorient = 0 
)
static

Convert a single curve into an OCC wire.

  • curve: input curve object
  • trsf: optional transform matrix to transform the shape back into its original position.

Member Data Documentation

◆ myArea

std::unique_ptr<CArea> Path::Area::myArea
protected

◆ myAreaOpen

std::unique_ptr<CArea> Path::Area::myAreaOpen
protected

Referenced by addToBuild(), build(), and clean().

◆ myHaveFace

bool Path::Area::myHaveFace
protected

Referenced by addToBuild(), clean(), and toShape().

◆ myHaveSolid

bool Path::Area::myHaveSolid
protected

Referenced by add(), addToBuild(), build(), and clean().

◆ myParams

◆ myProjecting

bool Path::Area::myProjecting
protected

Referenced by addToBuild(), build(), and project().

◆ mySections

std::vector<std::shared_ptr<Area> > Path::Area::mySections
protected

Referenced by Area(), build(), clean(), and isBuilt().

◆ myShape

TopoDS_Shape Path::Area::myShape
protected

Referenced by Area(), clean(), and getShape().

◆ myShapeDone

bool Path::Area::myShapeDone
protected

Referenced by Area(), clean(), and getShape().

◆ myShapePlane

TopoDS_Shape Path::Area::myShapePlane
protected

Referenced by Area(), clean(), and getPlane().

◆ myShapes

std::list<Shape> Path::Area::myShapes
protected

◆ mySkippedShapes

int Path::Area::mySkippedShapes
mutableprotected

◆ myTrsf

gp_Trsf Path::Area::myTrsf
protected

◆ myWorkPlane

TopoDS_Shape Path::Area::myWorkPlane
protected

◆ s_aborting

bool Area::s_aborting
staticprotected

Referenced by abort(), and aborting().

◆ s_params

AreaStaticParams Area::s_params
staticprotected

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