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< Shape > | getChildren () const |
const AreaParams & | getParams () 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 ¶ms) |
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 PyObject * | getPyObject () |
This method returns the Python wrapper for a C++ object. More... | |
virtual Type | getTypeId () const |
bool | isDerivedFrom (const Type type) const |
BaseClass & | operator= (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 AreaStaticParams & | getDefaultParams () |
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 ¶ms) |
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< Shape > | getProjectedShapes (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< CArea > | myArea |
std::unique_ptr< CArea > | myAreaOpen |
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< Shape > | myShapes |
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) |
Base class for FreeCAD wrapping of libarea.
Area::Area | ( | const AreaParams * | params = nullptr | ) |
Declare all parameters defined in #AREA_PARAMS_ALL as member variable.
References setParams().
References isBuilt(), myArea, mySections, myShape, myShapeDone, and myShapePlane.
|
virtual |
References clean().
|
static |
References aborting(), and s_aborting.
Referenced by PathPythonGui.simple_edit_panel.SimpleEditPanel::clicked(), and femsolver.run.Machine::run().
|
static |
References s_aborting.
Referenced by abort().
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().
|
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 shapeplane
is supplied References addWire(), isCoplanar(), CArea::m_curves, and CArea::Reorder().
Referenced by addToBuild().
|
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().
|
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().
|
protected |
Called internally to combine children shapes for further processing.
References add(), WireJoiner::add(), addToBuild(), build(), clean(), WireJoiner::comp, explode(), getPlane(), getProjectedShapes(), isBuilt(), WireJoiner::join(), CArea::m_curves, makeSections(), draftfunctions.move::move(), myArea, myAreaOpen, myHaveSolid, myParams, myProjecting, mySections, myShapes, mySkippedShapes, myTrsf, myWorkPlane, PARAM_FIELDS, PARAM_FNAME, and toShape().
Referenced by build(), and getShape().
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().
|
protected |
References addWire(), getPlane(), isCoplanar(), myArea, myParams, mySkippedShapes, and myTrsf.
Referenced by build().
|
protected |
Referenced by makeSections(), and setPlane().
const std::list< Shape > Path::Area::getChildren | ( | ) | const |
|
static |
References s_params.
const AreaParams & Path::Area::getParams | ( | ) | const |
Get the current configuration.
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().
|
protected |
References myParams, myShapes, mySkippedShapes, myWorkPlane, and project().
Referenced by build(), and makeSections().
std::size_t Path::Area::getSectionCount | ( | ) |
Return the number of sections.
Referenced by Path::FeatureArea::execute().
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().
bool Area::isBuilt | ( | ) | const |
References myArea, and mySections.
Referenced by Area(), build(), and Path::FeatureArea::mustExecute().
|
static |
Check if two OCC shape is coplanar.
Referenced by addShape(), and explode().
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.
|
protected |
Obtain a list of offset areas.
See #AREA_PARAMS_OFFSET for description of the arguments.
Referenced by getShape().
|
protected |
Make a pocket of the combined shape.
User #AREA_PARAMS_POCKET setting in myParams.
Referenced by getShape().
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.
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 ignoredSee #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().
|
static |
References add(), WireJoiner::comp, Path::AreaParams::dump(), WireJoiner::edges, WireJoiner::findClosedWires(), getShape(), myParams, myProjecting, myWorkPlane, showShape(), WireJoiner::splitEdges(), and draftutils.utils::tolerance().
Referenced by getProjectedShapes(), makeSections(), importIFCHelper.ProjectImporter::setAttributes(), and importIFCHelper.ProjectImporter::setComplexAttributes().
|
static |
References s_params.
Referenced by PathScripts.PathPreferencesPathJob.JobPreferencesPage::saveSettings().
void Area::setParams | ( | const AreaParams & | params | ) |
Config this Area object.
References clean(), and myParams.
Referenced by Area(), and Path::FeatureArea::execute().
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().
|
static |
|
static |
|
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
Referenced by toPath().
|
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 returnedSee #AREA_PARAMS_PATH for other arguments
References PARAM_FARG, PARAM_FIELDS, PARAM_REF, and sortWires().
Referenced by Path::FeatureShape::execute().
Called internally to obtain the combined children shapes.
References CArea::FitArcs(), myArea, myHaveFace, myParams, myTrsf, and toShape().
Referenced by build(), getShape(), and toShape().
|
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.
|
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.
|
protected |
Referenced by addToBuild(), Area(), build(), clean(), explode(), getShape(), isBuilt(), and toShape().
|
protected |
Referenced by addToBuild(), build(), and clean().
|
protected |
Referenced by addToBuild(), clean(), and toShape().
|
protected |
Referenced by add(), addToBuild(), build(), and clean().
|
protected |
Referenced by addToBuild(), build(), explode(), getProjectedShapes(), getShape(), makeSections(), project(), setParams(), and toShape().
|
protected |
Referenced by addToBuild(), build(), and project().
|
protected |
|
protected |
Referenced by Area(), clean(), and getShape().
|
protected |
Referenced by Area(), clean(), and getShape().
|
protected |
Referenced by Area(), clean(), and getPlane().
|
protected |
Referenced by add(), build(), clean(), getPlane(), getProjectedShapes(), and makeSections().
|
mutableprotected |
Referenced by addToBuild(), build(), explode(), and getProjectedShapes().
|
protected |
Referenced by addToBuild(), build(), explode(), getPlane(), setPlane(), and toShape().
|
protected |
Referenced by build(), getPlane(), getProjectedShapes(), project(), and setPlane().
|
staticprotected |
Referenced by abort(), and aborting().
|
staticprotected |
Referenced by getDefaultParams(), and setDefaultParams().