Attacher::AttachEngine Class Referenceabstract

The AttachEngine class is the placement calculation routine, modes, hints and so on. More...

#include <Attacher.h>

Public Member Functions

 AttachEngine ()
 
virtual Base::Placement calculateAttachedPlacement (const Base::Placement &origPlacement) const =0
 
virtual AttachEnginecopy () const =0
 
void EnableAllSupportedModes (void)
 EnableAllModes enables all modes that have shape type lists filled. More...
 
Base::Placement placementFactory (const gp_Dir &ZAxis, gp_Vec XAxis, gp_Pnt Origin, gp_Pnt refOrg=gp_Pnt(), bool useRefOrg_Line=false, bool useRefOrg_Plane=false, bool makeYVertical=false, bool makeLegacyFlatFaceOrientation=false, Base::Placement *placeOfRef=nullptr) const
 placementFactory calculates placement from Z axis direction, optional X axis direction, and origin point. More...
 
virtual void setUp (const App::PropertyLinkSubList &references, eMapMode mapMode=mmDeactivated, bool mapReverse=false, double attachParameter=0.0, double surfU=0.0, double surfV=0.0, const Base::Placement &attachmentOffset=Base::Placement())
 
virtual void setUp (const AttachEngine &another)
 
virtual void suggestMapModes (SuggestResult &result) const
 suggestMapModes is the procedure that knows everything about mapping modes. More...
 
virtual ~AttachEngine ()
 
- 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 eRefType downgradeType (eRefType type)
 downgradeType converts a more-specific type into a less-specific type (e.g. More...
 
static GProp_GProps getInertialPropsOfShape (const std::vector< const TopoDS_Shape * > &shapes)
 
static eMapMode getModeByName (const std::string &modeName)
 
static std::string getModeName (eMapMode mmode)
 getModeName More...
 
static eRefType getRefTypeByName (const std::string &typeName)
 
static std::string getRefTypeName (eRefType shapeType)
 
static eRefType getShapeType (const App::DocumentObject *obj, const std::string &subshape)
 getShapeType by link content. More...
 
static eRefType getShapeType (const TopoDS_Shape &sh)
 getShapeType by shape. More...
 
static int getTypeRank (eRefType type)
 getTypeRank determines, how specific is the supplied shape type. More...
 
static int isShapeOfType (eRefType shapeType, eRefType requirement)
 isShapeOfType tests if a shape fulfills the requirement of a mode, and returns a score of how spot on was the requirement. More...
 
static void verifyReferencesAreSafe (const App::PropertyLinkSubList &references)
 verifyReferencesAreSafe: checks if pointers in references still point to objects contained in open documents. More...
 
- Static Public Member Functions inherited from Base::BaseClass
static void * create ()
 
static Type getClassTypeId ()
 
static void init ()
 

Public Attributes

Base::Placement attachmentOffset
 
double attachParameter
 
eMapMode mapMode
 
bool mapReverse
 
std::vector< boolmodeEnabled
 modeEnabled is an indicator, whether some mode is ever suggested or not. More...
 
std::vector< refTypeStringListmodeRefTypes
 
App::PropertyLinkSubList references
 
double surfU
 
double surfV
 

Static Public Attributes

static const char * eMapModeStrings []
 
static const char * eRefTypeStrings []
 

Protected Member Functions

refTypeString cat (eRefType rt1)
 
refTypeString cat (eRefType rt1, eRefType rt2)
 
refTypeString cat (eRefType rt1, eRefType rt2, eRefType rt3)
 
refTypeString cat (eRefType rt1, eRefType rt2, eRefType rt3, eRefType rt4)
 

Static Protected Member Functions

static void readLinks (const App::PropertyLinkSubList &references, std::vector< App::GeoFeature * > &geofs, std::vector< const TopoDS_Shape * > &shapes, std::vector< TopoDS_Shape > &storage, std::vector< eRefType > &types)
 AttachEngine3D::readLinks. More...
 
static void throwWrongMode (eMapMode mmode)
 
- 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

The AttachEngine class is the placement calculation routine, modes, hints and so on.

It can be used separately, without deriving from AttachableObject.

Constructor & Destructor Documentation

◆ AttachEngine()

AttachEngine::AttachEngine ( )

◆ ~AttachEngine()

virtual Attacher::AttachEngine::~AttachEngine ( )
virtual

Member Function Documentation

◆ calculateAttachedPlacement()

virtual Base::Placement Attacher::AttachEngine::calculateAttachedPlacement ( const Base::Placement origPlacement) const
pure virtual

◆ cat() [1/4]

refTypeString Attacher::AttachEngine::cat ( eRefType  rt1)
protected

◆ cat() [2/4]

refTypeString Attacher::AttachEngine::cat ( eRefType  rt1,
eRefType  rt2 
)
protected

◆ cat() [3/4]

refTypeString Attacher::AttachEngine::cat ( eRefType  rt1,
eRefType  rt2,
eRefType  rt3 
)
protected

◆ cat() [4/4]

refTypeString Attacher::AttachEngine::cat ( eRefType  rt1,
eRefType  rt2,
eRefType  rt3,
eRefType  rt4 
)
protected

◆ copy()

virtual AttachEngine * Attacher::AttachEngine::copy ( ) const
pure virtual

◆ downgradeType()

◆ EnableAllSupportedModes()

void AttachEngine::EnableAllSupportedModes ( void  )

EnableAllModes enables all modes that have shape type lists filled.

The function acts on modeEnabled array.

References Attacher::mmDummy_NumberOfModes, modeEnabled, and modeRefTypes.

◆ getInertialPropsOfShape()

GProp_GProps AttachEngine::getInertialPropsOfShape ( const std::vector< const TopoDS_Shape * > &  shapes)
static

◆ getModeByName()

eMapMode AttachEngine::getModeByName ( const std::string &  modeName)
static

◆ getModeName()

std::string AttachEngine::getModeName ( eMapMode  mmode)
static

getModeName

Parameters
mmode
Returns
returns a string that identifies the attachment mode in enum property.

References eMapModeStrings, and Attacher::mmDummy_NumberOfModes.

Referenced by PartDesignGui::fixSketchSupport().

◆ getRefTypeByName()

eRefType AttachEngine::getRefTypeByName ( const std::string &  typeName)
static

◆ getRefTypeName()

std::string AttachEngine::getRefTypeName ( eRefType  shapeType)
static

◆ getShapeType() [1/2]

eRefType AttachEngine::getShapeType ( const App::DocumentObject obj,
const std::string &  subshape 
)
static

getShapeType by link content.

Will include rtFlagHasPlacement, if applies.

Parameters
obj
subshape(input). Can be empty string (then, whole object will be used for shape type testing)
Returns

References readLinks(), and App::PropertyLinkSubList::setValue().

◆ getShapeType() [2/2]

◆ getTypeRank()

int AttachEngine::getTypeRank ( eRefType  type)
static

getTypeRank determines, how specific is the supplied shape type.

The ranks are outlined in definition of eRefType. The ranks are defined by implementation of downgradeType().

Parameters
type
Returns
number of times the type can be downgradeType() before it becomes rtAnything

References downgradeType(), Attacher::rtAnything, and Attacher::rtFlagHasPlacement.

Referenced by isShapeOfType().

◆ isShapeOfType()

int AttachEngine::isShapeOfType ( eRefType  shapeType,
eRefType  requirement 
)
static

isShapeOfType tests if a shape fulfills the requirement of a mode, and returns a score of how spot on was the requirement.

Parameters
shapeType(use return value of AttachEngine::getShapeType)
requirement
Returns
: -1 - doesn't fulfill, 0 - compatible topology, but incompatible specific (e.g. rtLine, rtCircle); 1 - valid by generic type (e.g. rtCircle is rtEdge), 2 and up - more and more specific match (according to rank of requirement)

References downgradeType(), getTypeRank(), Attacher::rtAnything, and Attacher::rtFlagHasPlacement.

Referenced by Attacher::AttachEngine3D::calculateAttachedPlacement(), and suggestMapModes().

◆ placementFactory()

Base::Placement AttachEngine::placementFactory ( const gp_Dir &  ZAxis,
gp_Vec  XAxis,
gp_Pnt  Origin,
gp_Pnt  refOrg = gp_Pnt(),
bool  useRefOrg_Line = false,
bool  useRefOrg_Plane = false,
bool  makeYVertical = false,
bool  makeLegacyFlatFaceOrientation = false,
Base::Placement placeOfRef = nullptr 
) const

placementFactory calculates placement from Z axis direction, optional X axis direction, and origin point.

Parameters
ZAxis(input) mandatory. Z axis of the returned placement will strictly coincide with ZAxis.
XAxis(input) optional (i.e., can be zero). Sets the preferred X axis orientation. If it is not perpendicular to ZAxis, it will be forced to be. If XAxis is zero, the effect is equivalent to setting makeYVertical to true.
Origin(input) mandatory.
refOrg(input). The point that will be used in case any of useRefOrg_XX parameters is true.
useRefOrg_Line(input). If true, Origin will be moved along ZAxis to be as close as possible to refOrg.
useRefOrg_Plane(input). If true, Origin will be moved in XAxis-YAxis plane to be as close as possible to refOrg.
makeYVertical(input). If true, XAxis is ignored, and X and Y axes are defined in order to make Y axis go as upwards as possible. If ZAxis is strictly upwards, XY will match global XY. If ZAxis is strictly downwards, XAxis will be the reversed global X axis.
makeLegacyFlatFaceOrientation(input). Modifies the behavior of makeYVertical to match the logic that was used in mapping of sketches to flat faces in FreeCAD prior to introduction of Attacher. Set makeYVertical to true if using this.
Returns
the resulting placement. ReverseXY property of Attacher will be automatically applied.

References Base::Placement::getRotation(), mapReverse, Base::Rotation::multVec(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

Referenced by Attacher::AttachEngine3D::calculateAttachedPlacement(), Attacher::AttachEngineLine::calculateAttachedPlacement(), and Attacher::AttachEnginePoint::calculateAttachedPlacement().

◆ readLinks()

◆ setUp() [1/2]

void AttachEngine::setUp ( const App::PropertyLinkSubList references,
eMapMode  mapMode = mmDeactivated,
bool  mapReverse = false,
double  attachParameter = 0.0,
double  surfU = 0.0,
double  surfV = 0.0,
const Base::Placement attachmentOffset = Base::Placement() 
)
virtual

◆ setUp() [2/2]

void AttachEngine::setUp ( const AttachEngine another)
virtual

◆ suggestMapModes()

void AttachEngine::suggestMapModes ( SuggestResult result) const
virtual

suggestMapModes is the procedure that knows everything about mapping modes.

It returns the most appropriate mapping mode, as well as list of all modes that will accept the set of references. In case no modes apply, extra information regarding reasons is returned in msg.

Parameters
result(output). Returns results of suggestion, such as best fit mode, list of all modes that apply, hints, etc.

References isShapeOfType(), Attacher::mmDeactivated, Attacher::mmDummy_NumberOfModes, modeEnabled, modeRefTypes, readLinks(), references, Attacher::SuggestResult::srIncompatibleGeometry, Attacher::SuggestResult::srLinkBroken, Attacher::SuggestResult::srNoModesFit, and Attacher::SuggestResult::srOK.

Referenced by SketcherGui::SuggestAutoMapMode().

◆ throwWrongMode()

◆ verifyReferencesAreSafe()

void AttachEngine::verifyReferencesAreSafe ( const App::PropertyLinkSubList references)
static

verifyReferencesAreSafe: checks if pointers in references still point to objects contained in open documents.

This guarantees the links are valid. Throws Base::Exception if invalid links are found.

References App::GetApplication(), App::Application::getDocuments(), App::PropertyLinkSubList::getValues(), and references.

Referenced by readLinks().

Member Data Documentation

◆ attachmentOffset

◆ attachParameter

double Attacher::AttachEngine::attachParameter

◆ eMapModeStrings

const char * AttachEngine::eMapModeStrings
static

◆ eRefTypeStrings

const char * AttachEngine::eRefTypeStrings
static
Initial value:
= {
"Any",
"Vertex",
"Edge",
"Face",
"Line",
"Curve",
"Circle",
"Conic",
"Ellipse",
"Parabola",
"Hyperbola",
"Plane",
"Sphere",
"Revolve",
"Cylinder",
"Torus",
"Cone",
"Object",
"Solid",
"Wire",
nullptr
}

Referenced by getRefTypeByName(), and getRefTypeName().

◆ mapMode

◆ mapReverse

bool Attacher::AttachEngine::mapReverse

◆ modeEnabled

std::vector<bool> Attacher::AttachEngine::modeEnabled

modeEnabled is an indicator, whether some mode is ever suggested or not.

Set to false to suppress suggesting some mode, like so: modeEnabled[mmModeIDontLike] = false;

Referenced by EnableAllSupportedModes(), and suggestMapModes().

◆ modeRefTypes

◆ references

◆ surfU

double Attacher::AttachEngine::surfU

Referenced by setUp().

◆ surfV

double Attacher::AttachEngine::surfV

Referenced by setUp().


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