This class is a Facade to handle geometry and sketcher geometry extensions with a single sketcher specific interface. More...
#include <GeometryFacade.h>
Public Member Functions | |
Part::Geometry * | clone (void) const |
Part::Geometry * | copy (void) const |
void | deleteExtension (Base::Type type) |
void | deleteExtension (const std::string &name) |
GeometryFacade (const GeometryFacade &)=delete | |
GeometryFacade (GeometryFacade &&)=default | |
bool | getBlocked () const |
bool | getConstruction (void) const |
std::weak_ptr< const Part::GeometryExtension > | getExtension (Base::Type type) const |
std::weak_ptr< const Part::GeometryExtension > | getExtension (std::string name) const |
const std::string & | getExtensionName () const |
std::vector< std::weak_ptr< const Part::GeometryExtension > > | getExtensions () const |
template<typename GeometryT = Part::Geometry, typename = typename std::enable_if< std::is_base_of<Part::Geometry, typename std::decay<GeometryT>::type>::value >::type> | |
GeometryT * | getGeometry () |
template<typename GeometryT = Part::Geometry, typename = typename std::enable_if< std::is_base_of<Part::Geometry, typename std::decay<GeometryT>::type>::value >::type> | |
const GeometryT * | getGeometry () const |
virtual int | getGeometryLayerId () const override |
virtual long | getId () const override |
virtual InternalType::InternalType | getInternalType () const override |
bool | getOwner () const |
virtual PyObject * | getPyObject (void) override |
This method returns the Python wrapper for a C++ object. More... | |
boost::uuids::uuid | getTag () const |
const | Handle (Geom_Geometry) &handle() const |
bool | hasExtension (Base::Type type) const |
bool | hasExtension (const std::string &name) const |
bool | isGeoType (const Base::Type &type) const |
bool | isInternalAligned () const |
void | mirror (const Base::Vector3d &point) |
void | mirror (const Base::Vector3d &point, Base::Vector3d dir) |
GeometryFacade & | operator= (const GeometryFacade &)=delete |
GeometryFacade & | operator= (GeometryFacade &&)=default |
void | rotate (const Base::Placement &plm) |
void | scale (const Base::Vector3d &vec, double scale) |
void | setBlocked (bool status=true) |
void | setConstruction (bool construction) |
void | setExtension (std::unique_ptr< Part::GeometryExtension > &&geo) |
void | setGeometry (Part::Geometry *geometry) |
virtual void | setGeometryLayerId (int geolayer) override |
virtual void | setGeometryMode (int flag, bool v=true) override |
virtual void | setId (long id) override |
virtual void | setInternalType (InternalType::InternalType type) override |
void | setOwner (bool owner) |
virtual bool | testGeometryMode (int flag) const override |
TopoDS_Shape | toShape () const |
void | transform (const Base::Matrix4D &mat) |
void | translate (const Base::Vector3d &vec) |
~GeometryFacade () | |
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 | copyId (const Part::Geometry *src, Part::Geometry *dst) |
static void | ensureSketchGeometryExtension (Part::Geometry *geometry) |
static bool | getBlocked (const Part::Geometry *geometry) |
static bool | getConstruction (const Part::Geometry *geometry) |
static std::unique_ptr< const GeometryFacade > | getFacade (const Part::Geometry *geometry) |
static std::unique_ptr< GeometryFacade > | getFacade (Part::Geometry *geometry, bool owner=false) |
static bool | isInternalType (const Part::Geometry *geometry, InternalType::InternalType type) |
static void | setConstruction (Part::Geometry *geometry, bool construction) |
Static Public Member Functions inherited from Base::BaseClass | |
static void * | create () |
static Type | getClassTypeId () |
static void | init () |
Protected Member Functions | |
GeometryFacade () | |
GeometryFacade (const Part::Geometry *geometry, bool owner=false) | |
Friends | |
class | GeometryFacadePy |
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) |
This class is a Facade to handle geometry and sketcher geometry extensions with a single sketcher specific interface.
The facade privately inherits from a common interface it shares with the extension thereby implementing a compiler enforced same interface as the extension. It does not inherit from Part::Geometry and thus is intended to provide, in part a convenience subset of the interface of Part::Geometry, in part a different interface.
GeometryFacade has private constructors and objects may only be created using the getFacade factory methods.
There is a version of getFacade taking a const Part::Geometry and producing a const GeometryFacade, and a non-const version producing a non-const GeometryFacade. So constness of the Part::Geometry object is preserved by the GeometryFacade container.
There are some static convenience utility functions to simplify common operations such as ID copy or to ensure that a geometry object has the extension (creating the extension if not existing).
A simple usage example:
const std::vector< Part::Geometry * > &vals = getInternalGeometry(); auto gf = GeometryFacade::getFacade(vals[GeoId]); id = gf->getId();
An example of static Id utility function
const Part::Geometry *geo = getGeometry(GeoId); ... std::unique_ptr<Part::GeomBSplineCurve> bspline(new Part::GeomBSplineCurve(curve)); ...
Part::GeomBSplineCurve * gbsc = bspline.release(); GeometryFacade::copyId(geo, gbsc);
Examples getting and setting the construction stations without creating a Facade:
if ((*geo) && GeometryFacade::getConstruction(*geo) && (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) count++;
Part::Geometry* copy = v->copy();
if(construction && copy->getTypeId() != Part::GeomPoint::getClassTypeId()) { GeometryFacade::setConstruction(copy, construction); }
Note: The standard GeometryFacade stores Part::Geometry derived classes as a Part::Geometry *, while it has the ability to return a dynamic_cast-ed version to a provided type as follows:
HLine->getGeometry<Part::GeomLineSegment>();
If for seamless operation it is convenient to have a given derived class of Part::Geometry, it is possible to use GeometryTypedFacade (see below).
|
protected |
|
protected |
Referenced by getFacade(), and getPyObject().
|
delete |
|
default |
GeometryFacade::~GeometryFacade | ( | ) |
Part::Geometry * Sketcher::GeometryFacade::clone | ( | void | ) | const |
References Part::Geometry::clone().
Referenced by ArchPanel.CommandPanelSheet::Activated(), ArchStructure.CommandStructuralSystem::Activated(), ArchComponent.Component::execute(), ArchCurtainWall.CurtainWall::execute(), ArchTruss.Truss::execute(), Mod.PartDesign.WizardShaft.SegmentFunction.SegmentFunction::integrated(), and PathTests.TestPathHelix.TestPathHelix::test04().
Part::Geometry * Sketcher::GeometryFacade::copy | ( | void | ) | const |
References Part::Geometry::copy().
|
static |
References getFacade().
void Sketcher::GeometryFacade::deleteExtension | ( | Base::Type | type | ) |
void Sketcher::GeometryFacade::deleteExtension | ( | const std::string & | name | ) |
|
static |
References Base::BaseClass::getClassTypeId().
bool Sketcher::GeometryFacade::getBlocked | ( | ) | const |
References Sketcher::GeometryMode::Blocked.
Referenced by Sketcher::SketchObject::fillet().
|
static |
References getFacade().
|
static |
References getFacade().
Referenced by SketcherGui::EditModeGeometryCoinManager::updateGeometryColor().
bool Sketcher::GeometryFacade::getConstruction | ( | void | ) | const |
std::weak_ptr< const Part::GeometryExtension > Sketcher::GeometryFacade::getExtension | ( | Base::Type | type | ) | const |
std::weak_ptr< const Part::GeometryExtension > Sketcher::GeometryFacade::getExtension | ( | std::string | name | ) | const |
const std::string & Sketcher::GeometryFacade::getExtensionName | ( | ) | const |
std::vector< std::weak_ptr< const Part::GeometryExtension > > Sketcher::GeometryFacade::getExtensions | ( | ) | const |
|
static |
References GeometryFacade().
|
static |
References GeometryFacade().
Referenced by Sketcher::SketchObject::addCopy(), Sketcher::Sketch::addGeometry(), Sketcher::SketchObject::addSymmetric(), copyId(), Sketcher::SketchAnalysis::detectDegeneratedGeometries(), Sketcher::SketchAnalysis::detectMissingPointOnPointConstraints(), Sketcher::Sketch::extractGeoListFacade(), Sketcher::Sketch::extractGeometry(), Sketcher::GeoListModel< T >::GeoListModel(), getBlocked(), getConstruction(), Sketcher::SketchObject::getGeoListFacade(), Sketcher::SketchObject::getGeometryFacade(), Sketcher::GeoListModel< T >::getGeometryFacadeFromGeoId(), Sketcher::SketchObject::getGeometryId(), isInternalType(), Sketcher::SketchObject::migrateSketch(), Sketcher::SketchAnalysis::removeDegeneratedGeometries(), setConstruction(), Sketcher::SketchObject::setGeometryId(), Sketcher::SketchObject::synchroniseGeometryState(), Sketcher::SketchObject::toggleConstruction(), and Sketcher::Sketch::toShape().
GeometryT * Sketcher::GeometryFacade::getGeometry | ( | ) |
const GeometryT * Sketcher::GeometryFacade::getGeometry | ( | ) | const |
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
bool Sketcher::GeometryFacade::getOwner | ( | ) | const |
|
overridevirtual |
This method returns the Python wrapper for a C++ object.
It's in the responsibility of the programmer to do the correct reference counting. Basically there are two ways how to implement that: Either always return a new Python object then reference counting is not a matter or return always the same Python object then the reference counter must be incremented by one. However, it's absolutely forbidden to return always the same Python object without incrementing the reference counter.
The default implementation returns 'None'.
Reimplemented from Base::BaseClass.
References GeometryFacade(), and GeometryFacadePy.
boost::uuids::uuid Sketcher::GeometryFacade::getTag | ( | ) | const |
const Sketcher::GeometryFacade::Handle | ( | Geom_Geometry | ) | const & |
bool Sketcher::GeometryFacade::hasExtension | ( | Base::Type | type | ) | const |
bool Sketcher::GeometryFacade::hasExtension | ( | const std::string & | name | ) | const |
bool Sketcher::GeometryFacade::isGeoType | ( | const Base::Type & | type | ) | const |
bool Sketcher::GeometryFacade::isInternalAligned | ( | ) | const |
|
static |
References getFacade().
Referenced by SketcherGui::TrimmingSelection::allow(), and Sketcher::SketchObject::trim().
void Sketcher::GeometryFacade::mirror | ( | const Base::Vector3d & | point | ) |
void Sketcher::GeometryFacade::mirror | ( | const Base::Vector3d & | point, |
Base::Vector3d | dir | ||
) |
|
delete |
|
default |
void Sketcher::GeometryFacade::rotate | ( | const Base::Placement & | plm | ) |
Referenced by PathScripts.PathDressupLeadInOut.ObjectDressup::getLeadEnd(), PathScripts.PathDressupLeadInOut.ObjectDressup::getLeadStart(), draftguitools.gui_rotate.Rotate::numericRadius(), ArchSectionPlane.SectionPlaneTaskPanel::rotateX(), ArchSectionPlane.SectionPlaneTaskPanel::rotateY(), and ArchSectionPlane.SectionPlaneTaskPanel::rotateZ().
void Sketcher::GeometryFacade::scale | ( | const Base::Vector3d & | vec, |
double | scale | ||
) |
void Sketcher::GeometryFacade::setBlocked | ( | bool | status = true | ) |
References Sketcher::GeometryMode::Blocked.
void Sketcher::GeometryFacade::setConstruction | ( | bool | construction | ) |
References Sketcher::GeometryMode::Construction.
|
static |
References getFacade().
Referenced by Sketcher::SketchObject::addCopy(), Sketcher::SketchObject::addGeometry(), Sketcher::SketchObject::carbonCopy(), Sketcher::SketchObject::exposeInternalGeometry(), Sketcher::SketchObject::migrateSketch(), Sketcher::SketchObject::rebuildExternalGeometry(), and Sketcher::SketchObject::setConstruction().
void Sketcher::GeometryFacade::setExtension | ( | std::unique_ptr< Part::GeometryExtension > && | geo | ) |
References draftfunctions.move::move().
void GeometryFacade::setGeometry | ( | Part::Geometry * | geometry | ) |
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
Implements Sketcher::ISketchGeometryExtension.
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
|
overridevirtual |
Implements Sketcher::ISketchGeometryExtension.
void Sketcher::GeometryFacade::setOwner | ( | bool | owner | ) |
Implements Sketcher::ISketchGeometryExtension.
TopoDS_Shape Sketcher::GeometryFacade::toShape | ( | ) | const |
void Sketcher::GeometryFacade::transform | ( | const Base::Matrix4D & | mat | ) |
void Sketcher::GeometryFacade::translate | ( | const Base::Vector3d & | vec | ) |
References draftgeoutils.general::vec().
|
friend |
Referenced by getPyObject().