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=0) 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...
 
virtual PyObjectgetPyObject (void)
 This method returns the Python wrapper for a C++ object. More...
 
virtual Type getTypeId (void) const
 
bool isDerivedFrom (const Type type) const
 
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 (void)
 
static Type getClassTypeId (void)
 
static void init (void)
 

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.

◆ 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

◆ getRefTypeByName()

◆ getRefTypeName()

◆ 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 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 Attacher::rtAnything, and Attacher::rtFlagHasPlacement.

Referenced by Attacher::AttachEnginePy::getRefTypeInfo().

◆ 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 Attacher::rtAnything, and Attacher::rtFlagHasPlacement.

Referenced by Attacher::AttachEnginePy::isFittingRefType().

◆ 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 = 0 
) 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 Part::TopoShape::convertToMatrix(), Base::Placement::getRotation(), Base::Rotation::multVec(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

◆ readLinks()

void AttachEngine::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 
)
staticprotected

◆ setUp() [1/2]

◆ 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 Attacher::mmDeactivated, and Attacher::mmDummy_NumberOfModes.

Referenced by SketcherGui::SuggestAutoMapMode(), and Attacher::AttachEnginePy::suggestModes().

◆ throwWrongMode()

void AttachEngine::throwWrongMode ( eMapMode  mmode)
staticprotected

◆ 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(), and App::PropertyLinkSubList::getValues().

Referenced by Attacher::AttachEnginePy::getReferences(), and Attacher::AttachEnginePy::writeParametersToFeature().

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",
NULL
}

◆ 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;

◆ 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:
  • Sources/FreeCAD/src/Mod/Part/App/Attacher.h
  • Sources/FreeCAD/src/Mod/Part/App/Attacher.cpp