Sketcher::GeoListModel< T > Class Template Reference

Class for managing internal and external geometry as a single object. More...

#include <GeoList.h>

Public Member Functions

 GeoListModel (const GeoListModel &)=delete
 
 GeoListModel (GeoListModel &&)=default
 
std::vector< T > & geometryList ()
 return a reference to the internal geometry list vector. More...
 
int getExternalCount () const
 returns the amount of external geometry objects. More...
 
Sketcher::GeoElementId getGeoElementIdFromVertexId (int vertexId)
 Obtain a GeoElementId class {GeoId, Pos} given a VertexId. More...
 
int getGeoIdFromGeomListIndex (int index) const
 returns the GeoId index from the index in the geometry in geomlist format with which it was constructed. More...
 
const Sketcher::GeometryFacadegetGeometryFacadeFromGeoId (int geoId) const
 returns a geometryfacade More...
 
const Part::GeometrygetGeometryFromGeoId (int geoId) const
 returns the geometry given by the GeoId More...
 
int getInternalCount () const
 returns the amount of internal (normal, non-external) geometry objects. More...
 
Vector3d getPoint (const GeoElementId &geid) const
 Returns a point coordinates given GeoElementId {GeoId, Pos}. More...
 
Vector3d getPoint (int geoId, Sketcher::PointPos pos) const
 Returns a point coordinates given {GeoId, Pos}. More...
 
int getVertexIdFromGeoElementId (const Sketcher::GeoElementId &geoelementId) const
 Given an GeoElementId {GeoId, Pos}, it returns the index of the vertex in VertexId format. More...
 
GeoListModeloperator= (const GeoListModel &)=delete
 
GeoListModeloperator= (GeoListModel &&)=default
 
 ~GeoListModel ()
 
 ~GeoListModel ()
 Destructor having type dependent behaviour. More...
 

Static Public Member Functions

static const GeoListModel< T > getGeoListModel (const std::vector< T > &geometrylist, int intgeocount)
 
static GeoListModel< T > getGeoListModel (std::vector< T > &&geometrylist, int intgeocount, bool ownerT=false)
 GeoListModel manages the lifetime of its internal std::vector. More...
 
static const Sketcher::GeometryFacadegetGeometryFacadeFromGeoId (const std::vector< T > &geometrylist, int geoId)
 returns a geometry facade More...
 
static const Part::GeometrygetGeometryFromGeoId (const std::vector< T > &geometrylist, int geoId)
 returns the geometry given by the GeoId in the geometrylist in geomlist format provided as a parameter. More...
 

Public Attributes

std::vector< T > geomlist
 

Protected Member Functions

 GeoListModel (const std::vector< GeometryFacadeUniquePtr > &geometrylist, int intgeocount)
 
 GeoListModel (const std::vector< T > &geometrylist, int intgeocount)
 
 GeoListModel (std::vector< GeometryFacadeUniquePtr > &&geometrylist, int intgeocount, bool ownerT)
 
 GeoListModel (std::vector< T > &&geometrylist, int intgeocount, bool ownerT=false)
 Constructors are protected, use static methods getGeoListModel() to construct the objects instead. More...
 

Detailed Description

template<typename T>
class Sketcher::GeoListModel< T >

Class for managing internal and external geometry as a single object.

Internal and external geometries are present in a single geometry vector one after the other.

This class follows the format used by solver facade (sketch.cpp) in: getSolvedSketch().extractGeometry() and by SketchObject in getCompleteGeometry(). Care should be taken that the former may provide the list with a deep copy of the geometry pointers, whereas the second just provides a shallow copy of the pointers.

This class is templated to allow instantiations with list elements being legacy naked pointers (Part::Geometry *) and GeometryFacade smart pointer objects. Convenience typedefs are provided:

using GeoList = GeoListModel<GeometryPtr>; using GeoListFacade = GeoListModel<GeometryFacadeUniquePtr>;

with: using GeometryPtr = Part::Geometry *; using GeometryFacadeUniquePtr = std::unique_ptr<const Sketcher::GeometryFacade>;

N.B.: Note that the index of the geomlist (all layers) and the GeoId can be converted from each other as needed using the member functions (and sometimes the static functions).

Constructor & Destructor Documentation

◆ GeoListModel() [1/6]

template<typename T >
GeoListModel::GeoListModel ( std::vector< T > &&  geometrylist,
int  intgeocount,
bool  ownerT = false 
)
explicitprotected

Constructors are protected, use static methods getGeoListModel() to construct the objects instead.

Constructs the object from a list of geometry in geomlist format and the number of internal geometries (non external) present in the list.

Parameters
geometrylistthe geometry in geomlist format (external after internal in a single vector).
intgeocountthe number of internal geometries (non external) in the list.
ownerTindicates whether the GeoListModel takes ownership of the elements of the std::vector<T> (for pointers)

◆ GeoListModel() [2/6]

template<typename T >
GeoListModel::GeoListModel ( const std::vector< T > &  geometrylist,
int  intgeocount 
)
explicitprotected

◆ ~GeoListModel() [1/2]

template<typename T >
GeoListModel::~GeoListModel

Destructor having type dependent behaviour.

Warning
For GeoList, the destructor will destruct the Part::Geometry pointers * only * if it was constructed with ownerT = true.

For GeoListFacade, the smart pointers will be deleted. However, a GeometryFacade does * not * delete the underlying naked pointers by default (which is mostly the desired behaviour as the ownership of the pointers belongs to sketchObject). If GeometryFacade is to delete the underlying naked pointers (because it is a temporal deep copy), then the GeometryFacade needs to get ownership (see setOwner method).

◆ GeoListModel() [3/6]

template<typename T >
Sketcher::GeoListModel< T >::GeoListModel ( const GeoListModel< T > &  )
delete

◆ GeoListModel() [4/6]

template<typename T >
Sketcher::GeoListModel< T >::GeoListModel ( GeoListModel< T > &&  )
default

◆ GeoListModel() [5/6]

Sketcher::GeoListModel< GeometryFacadeUniquePtr >::GeoListModel ( std::vector< GeometryFacadeUniquePtr > &&  geometrylist,
int  intgeocount,
bool  ownerT 
)
protected

◆ GeoListModel() [6/6]

◆ ~GeoListModel() [2/2]

Sketcher::GeoListModel< std::unique_ptr< constSketcher::GeometryFacade > >::~GeoListModel ( )

Member Function Documentation

◆ geometryList()

template<typename T >
std::vector< T > & Sketcher::GeoListModel< T >::geometryList ( )

return a reference to the internal geometry list vector.

Warning
{ It returns a reference to the internal list vector. The validity of the reference depends on the lifetime of the GeoListModel object.}

References Sketcher::GeoListModel< T >::geomlist.

◆ getExternalCount()

template<typename T >
int Sketcher::GeoListModel< T >::getExternalCount ( ) const

returns the amount of external geometry objects.

References Sketcher::GeoListModel< T >::geomlist.

Referenced by SketcherGui::EditModeConstraintCoinManager::processConstraints().

◆ getGeoElementIdFromVertexId()

template<typename T >
Sketcher::GeoElementId GeoListModel::getGeoElementIdFromVertexId ( int  vertexId)

Obtain a GeoElementId class {GeoId, Pos} given a VertexId.

A vertexId is a positive index of the vertex, where indices of external geometry taken higher positive values than normal geometry. It is the same format of vertex numbering used in the Sketcher, Sketch.cpp, and ViewProviderSketch.

◆ getGeoIdFromGeomListIndex()

template<typename T >
int GeoListModel::getGeoIdFromGeomListIndex ( int  index) const

returns the GeoId index from the index in the geometry in geomlist format with which it was constructed.

Parameters
indexthe index of the list of geometry in geomlist format.

Referenced by SketcherGui::EditModeGeometryCoinConverter::convert().

◆ getGeoListModel() [1/2]

template<typename T >
const GeoListModel< T > GeoListModel::getGeoListModel ( const std::vector< T > &  geometrylist,
int  intgeocount 
)
static

◆ getGeoListModel() [2/2]

template<typename T >
GeoListModel< T > GeoListModel::getGeoListModel ( std::vector< T > &&  geometrylist,
int  intgeocount,
bool  ownerT = false 
)
static

GeoListModel manages the lifetime of its internal std::vector.

This means that while the actual ownership of the T parameter needs to be specified or separately handled. In the absence of that, a new vector will be created and the T elements shallow copied to the internal vector.

The constness of the GeoListModel is tied to the constness of the std::vector from which it is constructed.

Warning
For GeoListFacade ownership at GeoListModel level cannot be taken (ownerT cannot be true). An assertion is raised if this happens. The ownership needs to be specified on the GeoListFacade objects themselves (setOwner method).

References draftfunctions.move::move().

Referenced by Sketcher::Sketch::extractGeoListFacade(), and Sketcher::SketchObject::getGeoListFacade().

◆ getGeometryFacadeFromGeoId() [1/2]

template<typename T >
const Sketcher::GeometryFacade * GeoListModel::getGeometryFacadeFromGeoId ( const std::vector< T > &  geometrylist,
int  geoId 
)
static

returns a geometry facade

Warning
If the underlying model of the list is a naked pointed (Part::Geometry *), the client (the user) bears responsibility for releasing the GeometryFacade pointer!!

This is not a problem when the model of the list is a std::unique_ptr<Sketcher::GeometryFacade>, because the lifetime is tied to the model itself.

References Sketcher::GeometryFacade::getFacade().

◆ getGeometryFacadeFromGeoId() [2/2]

template<typename T >
const Sketcher::GeometryFacade * GeoListModel::getGeometryFacadeFromGeoId ( int  geoId) const

returns a geometryfacade

Warning
If the underlying model of the list is a naked pointed (Part::Geometry *), i.e. a GeoList instantiation, the client (the user) bears responsibility for releasing the GeometryFacade pointer!!

This is not a problem when the model of the list is a std::unique_ptr<Sketcher::GeometryFacade>, because the lifetime is tied to the GeometryFacade. It will destruct the pointer if it is the owner.

References Sketcher::GeoListModel< T >::getGeometryFacadeFromGeoId().

Referenced by SketcherGui::EditModeGeometryCoinConverter::convert(), Sketcher::GeoListModel< T >::getGeometryFacadeFromGeoId(), and SketcherGui::EditModeGeometryCoinManager::updateGeometryColor().

◆ getGeometryFromGeoId() [1/2]

template<typename T >
const Part::Geometry * GeoListModel::getGeometryFromGeoId ( const std::vector< T > &  geometrylist,
int  geoId 
)
static

returns the geometry given by the GeoId in the geometrylist in geomlist format provided as a parameter.

Parameters
geometrylistthe geometry in geomlist format (external after internal in a single vector).
indexthe index of the list of geometry in geomlist format.

◆ getGeometryFromGeoId() [2/2]

◆ getInternalCount()

template<typename T >
int Sketcher::GeoListModel< T >::getInternalCount ( ) const

returns the amount of internal (normal, non-external) geometry objects.

Referenced by Sketcher::getGeoListFacade(), and SketcherGui::EditModeConstraintCoinManager::processConstraints().

◆ getPoint() [1/2]

◆ getPoint() [2/2]

◆ getVertexIdFromGeoElementId()

template<typename T >
int GeoListModel::getVertexIdFromGeoElementId ( const Sketcher::GeoElementId geoelementId) const

Given an GeoElementId {GeoId, Pos}, it returns the index of the vertex in VertexId format.

A vertexId is a positive index of the vertex, where indices of external geometry taken higher positive values than normal geometry. It is the same format of vertex numbering used in the Sketcher, Sketch.cpp, and ViewProviderSketch.

References DraftVecUtils::find().

◆ operator=() [1/2]

template<typename T >
GeoListModel & Sketcher::GeoListModel< T >::operator= ( const GeoListModel< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
GeoListModel & Sketcher::GeoListModel< T >::operator= ( GeoListModel< T > &&  )
default

Member Data Documentation

◆ geomlist


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