Sketcher::GeometryFacade Class Reference

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::Geometryclone (void) const
 
Part::Geometrycopy (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::GeometryExtensiongetExtension (Base::Type type) const
 
std::weak_ptr< const Part::GeometryExtensiongetExtension (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 PyObjectgetPyObject (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)
 
GeometryFacadeoperator= (const GeometryFacade &)=delete
 
GeometryFacadeoperator= (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 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 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 GeometryFacadegetFacade (const Part::Geometry *geometry)
 
static std::unique_ptr< GeometryFacadegetFacade (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)
 

Detailed Description

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).

Warning
The const factory method will throw if the geometry does not have a SketchGeometryExtension (being const, it commits not to create one and modify the const Part::Geometry object). The non-const factory method will create the extension if not existing.
If the Geometry Pointer fed into the factory method is a nullptr, a nullptr GeometryFacade is created. It should not be possible to create a GeometryFacade having a Part::Geometry * being a nullptr.

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).

Remarks
Summary Remarks: It is intended to have a separate type (not being a Geometry type). it is intended to have the relevant interface in full for the sketcher extension only It is intended to work on borrowed memory allocation. But the getFacade has an owner parameter to take ownership of the geometry pointer if that is intended (this can also be achieved via the setOwner method once created).

Constructor & Destructor Documentation

◆ GeometryFacade() [1/4]

GeometryFacade::GeometryFacade ( const Part::Geometry geometry,
bool  owner = false 
)
protected

◆ GeometryFacade() [2/4]

GeometryFacade::GeometryFacade ( )
protected

Referenced by getFacade(), and getPyObject().

◆ GeometryFacade() [3/4]

Sketcher::GeometryFacade::GeometryFacade ( const GeometryFacade )
delete

◆ GeometryFacade() [4/4]

Sketcher::GeometryFacade::GeometryFacade ( GeometryFacade &&  )
default

◆ ~GeometryFacade()

GeometryFacade::~GeometryFacade ( )

Member Function Documentation

◆ clone()

◆ copy()

Part::Geometry * Sketcher::GeometryFacade::copy ( void  ) const

◆ copyId()

void GeometryFacade::copyId ( const Part::Geometry src,
Part::Geometry dst 
)
static

References getFacade().

◆ deleteExtension() [1/2]

void Sketcher::GeometryFacade::deleteExtension ( Base::Type  type)

◆ deleteExtension() [2/2]

void Sketcher::GeometryFacade::deleteExtension ( const std::string &  name)

◆ ensureSketchGeometryExtension()

void GeometryFacade::ensureSketchGeometryExtension ( Part::Geometry geometry)
static

◆ getBlocked() [1/2]

bool Sketcher::GeometryFacade::getBlocked ( ) const

◆ getBlocked() [2/2]

bool GeometryFacade::getBlocked ( const Part::Geometry geometry)
static

References getFacade().

◆ getConstruction() [1/2]

bool GeometryFacade::getConstruction ( const Part::Geometry geometry)
static

◆ getConstruction() [2/2]

◆ getExtension() [1/2]

std::weak_ptr< const Part::GeometryExtension > Sketcher::GeometryFacade::getExtension ( Base::Type  type) const

◆ getExtension() [2/2]

std::weak_ptr< const Part::GeometryExtension > Sketcher::GeometryFacade::getExtension ( std::string  name) const

◆ getExtensionName()

const std::string & Sketcher::GeometryFacade::getExtensionName ( ) const

◆ getExtensions()

std::vector< std::weak_ptr< const Part::GeometryExtension > > Sketcher::GeometryFacade::getExtensions ( ) const

◆ getFacade() [1/2]

std::unique_ptr< const GeometryFacade > GeometryFacade::getFacade ( const Part::Geometry geometry)
static

References GeometryFacade().

◆ getFacade() [2/2]

◆ getGeometry() [1/2]

template<typename GeometryT = Part::Geometry, typename = typename std::enable_if< std::is_base_of<Part::Geometry, typename std::decay<GeometryT>::type>::value >::type>
GeometryT * Sketcher::GeometryFacade::getGeometry ( )

◆ getGeometry() [2/2]

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 * Sketcher::GeometryFacade::getGeometry ( ) const

◆ getGeometryLayerId()

virtual int Sketcher::GeometryFacade::getGeometryLayerId ( ) const
overridevirtual

◆ getId()

virtual long Sketcher::GeometryFacade::getId ( ) const
overridevirtual

◆ getInternalType()

virtual InternalType::InternalType Sketcher::GeometryFacade::getInternalType ( ) const
overridevirtual

◆ getOwner()

bool Sketcher::GeometryFacade::getOwner ( ) const

◆ getPyObject()

PyObject * GeometryFacade::getPyObject ( void  )
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.

◆ getTag()

boost::uuids::uuid Sketcher::GeometryFacade::getTag ( ) const

◆ Handle()

const Sketcher::GeometryFacade::Handle ( Geom_Geometry  ) const &

◆ hasExtension() [1/2]

bool Sketcher::GeometryFacade::hasExtension ( Base::Type  type) const

◆ hasExtension() [2/2]

bool Sketcher::GeometryFacade::hasExtension ( const std::string &  name) const

◆ isGeoType()

bool Sketcher::GeometryFacade::isGeoType ( const Base::Type type) const

◆ isInternalAligned()

bool Sketcher::GeometryFacade::isInternalAligned ( ) const

◆ isInternalType()

bool GeometryFacade::isInternalType ( const Part::Geometry geometry,
InternalType::InternalType  type 
)
static

◆ mirror() [1/2]

void Sketcher::GeometryFacade::mirror ( const Base::Vector3d point)

◆ mirror() [2/2]

void Sketcher::GeometryFacade::mirror ( const Base::Vector3d point,
Base::Vector3d  dir 
)

◆ operator=() [1/2]

GeometryFacade & Sketcher::GeometryFacade::operator= ( const GeometryFacade )
delete

◆ operator=() [2/2]

GeometryFacade & Sketcher::GeometryFacade::operator= ( GeometryFacade &&  )
default

◆ rotate()

◆ scale()

◆ setBlocked()

void Sketcher::GeometryFacade::setBlocked ( bool  status = true)

◆ setConstruction() [1/2]

void Sketcher::GeometryFacade::setConstruction ( bool  construction)

◆ setConstruction() [2/2]

◆ setExtension()

void Sketcher::GeometryFacade::setExtension ( std::unique_ptr< Part::GeometryExtension > &&  geo)

◆ setGeometry()

void GeometryFacade::setGeometry ( Part::Geometry geometry)

◆ setGeometryLayerId()

virtual void Sketcher::GeometryFacade::setGeometryLayerId ( int  geolayer)
overridevirtual

◆ setGeometryMode()

virtual void Sketcher::GeometryFacade::setGeometryMode ( int  flag,
bool  v = true 
)
overridevirtual

◆ setId()

virtual void Sketcher::GeometryFacade::setId ( long  id)
overridevirtual

◆ setInternalType()

virtual void Sketcher::GeometryFacade::setInternalType ( InternalType::InternalType  type)
overridevirtual

◆ setOwner()

void Sketcher::GeometryFacade::setOwner ( bool  owner)

◆ testGeometryMode()

virtual bool Sketcher::GeometryFacade::testGeometryMode ( int  flag) const
overridevirtual

◆ toShape()

TopoDS_Shape Sketcher::GeometryFacade::toShape ( ) const

◆ transform()

◆ translate()

void Sketcher::GeometryFacade::translate ( const Base::Vector3d vec)

Friends And Related Function Documentation

◆ GeometryFacadePy

friend class GeometryFacadePy
friend

Referenced by getPyObject().


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