| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef ASSEMBLY_AssemblyObject_H |
| | #define ASSEMBLY_AssemblyObject_H |
| |
|
| | #include <boost/signals2.hpp> |
| |
|
| | #include <Mod/Assembly/AssemblyGlobal.h> |
| |
|
| | #include <App/FeaturePython.h> |
| | #include <App/Part.h> |
| | #include <App/PropertyLinks.h> |
| |
|
| | #include <OndselSolver/enum.h> |
| |
|
| | namespace MbD |
| | { |
| | class ASMTPart; |
| | class ASMTAssembly; |
| | class ASMTJoint; |
| | class ASMTMarker; |
| | class ASMTPart; |
| | } |
| |
|
| | namespace App |
| | { |
| | class PropertyXLinkSub; |
| | } |
| |
|
| | namespace Base |
| | { |
| | class Placement; |
| | class Rotation; |
| | } |
| |
|
| |
|
| | namespace Assembly |
| | { |
| |
|
| | class AssemblyLink; |
| | class JointGroup; |
| | class ViewGroup; |
| | enum class JointType; |
| |
|
| |
|
| | struct ObjRef |
| | { |
| | App::DocumentObject* obj; |
| | App::PropertyXLinkSub* ref; |
| | }; |
| |
|
| | class AssemblyExport AssemblyObject: public App::Part |
| | { |
| | PROPERTY_HEADER_WITH_OVERRIDE(Assembly::AssemblyObject); |
| |
|
| | public: |
| | AssemblyObject(); |
| | ~AssemblyObject() override; |
| |
|
| | PyObject* getPyObject() override; |
| |
|
| | |
| | const char* getViewProviderName() const override |
| | { |
| | return "AssemblyGui::ViewProviderAssembly"; |
| | } |
| |
|
| | App::DocumentObjectExecReturn* execute() override; |
| |
|
| | |
| | |
| | |
| | int solve(bool enableRedo = false, bool updateJCS = true); |
| | int generateSimulation(App::DocumentObject* sim); |
| | int updateForFrame(size_t index, bool updateJCS = true); |
| | size_t numberOfFrames(); |
| | void preDrag(std::vector<App::DocumentObject*> dragParts); |
| | void doDragStep(); |
| | void postDrag(); |
| | void savePlacementsForUndo(); |
| | void undoSolve(); |
| | void clearUndo(); |
| |
|
| | void exportAsASMT(std::string fileName); |
| |
|
| | Base::Placement getMbdPlacement(std::shared_ptr<MbD::ASMTPart> mbdPart); |
| | bool validateNewPlacements(); |
| | void setNewPlacements(); |
| | static void recomputeJointPlacements(std::vector<App::DocumentObject*> joints); |
| | static void redrawJointPlacements(std::vector<App::DocumentObject*> joints); |
| | static void redrawJointPlacement(App::DocumentObject* joint); |
| |
|
| | |
| | void ensureIdentityPlacements(); |
| |
|
| | |
| | std::shared_ptr<MbD::ASMTAssembly> makeMbdAssembly(); |
| | void create_mbdSimulationParameters(App::DocumentObject* sim); |
| | std::shared_ptr<MbD::ASMTPart> makeMbdPart( |
| | std::string& name, |
| | Base::Placement plc = Base::Placement(), |
| | double mass = 1.0 |
| | ); |
| | std::shared_ptr<MbD::ASMTPart> getMbDPart(App::DocumentObject* obj); |
| | |
| | |
| | |
| | |
| | struct MbDPartData |
| | { |
| | std::shared_ptr<MbD::ASMTPart> part; |
| | Base::Placement offsetPlc; |
| | }; |
| | MbDPartData getMbDData(App::DocumentObject* part); |
| | std::shared_ptr<MbD::ASMTMarker> makeMbdMarker(std::string& name, Base::Placement& plc); |
| | std::vector<std::shared_ptr<MbD::ASMTJoint>> makeMbdJoint(App::DocumentObject* joint); |
| | std::shared_ptr<MbD::ASMTJoint> makeMbdJointOfType(App::DocumentObject* joint, JointType jointType); |
| | std::shared_ptr<MbD::ASMTJoint> makeMbdJointDistance(App::DocumentObject* joint); |
| | std::string handleOneSideOfJoint( |
| | App::DocumentObject* joint, |
| | const char* propRefName, |
| | const char* propPlcName |
| | ); |
| | void getRackPinionMarkers( |
| | App::DocumentObject* joint, |
| | std::string& markerNameI, |
| | std::string& markerNameJ |
| | ); |
| | int slidingPartIndex(App::DocumentObject* joint); |
| |
|
| | void jointParts(std::vector<App::DocumentObject*> joints); |
| | JointGroup* getJointGroup() const; |
| | ViewGroup* getExplodedViewGroup() const; |
| | template<typename T> |
| | T* getGroup(); |
| |
|
| | std::vector<App::DocumentObject*> getJoints( |
| | bool updateJCS = true, |
| | bool delBadJoints = false, |
| | bool subJoints = true |
| | ); |
| | std::vector<App::DocumentObject*> getGroundedJoints(); |
| | std::vector<App::DocumentObject*> getJointsOfObj(App::DocumentObject* obj); |
| | std::vector<App::DocumentObject*> getJointsOfPart(App::DocumentObject* part); |
| | App::DocumentObject* getJointOfPartConnectingToGround( |
| | App::DocumentObject* part, |
| | std::string& name, |
| | const std::vector<App::DocumentObject*>& excludeJoints = {} |
| | ); |
| | std::unordered_set<App::DocumentObject*> getGroundedParts(); |
| | std::unordered_set<App::DocumentObject*> fixGroundedParts(); |
| | void fixGroundedPart(App::DocumentObject* obj, Base::Placement& plc, std::string& jointName); |
| |
|
| | bool isJointConnectingPartToGround(App::DocumentObject* joint, const char* partPropName); |
| | bool isJointTypeConnecting(App::DocumentObject* joint); |
| |
|
| | bool isObjInSetOfObjRefs(App::DocumentObject* obj, const std::vector<ObjRef>& pairs); |
| | void removeUnconnectedJoints( |
| | std::vector<App::DocumentObject*>& joints, |
| | std::unordered_set<App::DocumentObject*> groundedObjs |
| | ); |
| | void traverseAndMarkConnectedParts( |
| | App::DocumentObject* currentPart, |
| | std::vector<ObjRef>& connectedParts, |
| | const std::vector<App::DocumentObject*>& joints |
| | ); |
| | std::vector<ObjRef> getConnectedParts( |
| | App::DocumentObject* part, |
| | const std::vector<App::DocumentObject*>& joints |
| | ); |
| | bool isPartGrounded(App::DocumentObject* part); |
| | bool isPartConnected(App::DocumentObject* part); |
| |
|
| | std::vector<ObjRef> getDownstreamParts( |
| | App::DocumentObject* part, |
| | App::DocumentObject* joint = nullptr |
| | ); |
| | App::DocumentObject* getUpstreamMovingPart( |
| | App::DocumentObject* part, |
| | App::DocumentObject*& joint, |
| | std::string& name, |
| | std::vector<App::DocumentObject*> excludeJoints = {} |
| | ); |
| |
|
| | double getObjMass(App::DocumentObject* obj); |
| | void setObjMasses(std::vector<std::pair<App::DocumentObject*, double>> objectMasses); |
| |
|
| | std::vector<AssemblyLink*> getSubAssemblies(); |
| |
|
| | std::vector<App::DocumentObject*> getMotionsFromSimulation(App::DocumentObject* sim); |
| |
|
| | bool isMbDJointValid(App::DocumentObject* joint); |
| |
|
| | bool isEmpty() const; |
| | int numberOfComponents() const; |
| |
|
| | inline int getLastDoF() const |
| | { |
| | return lastDoF; |
| | } |
| | inline bool getLastHasConflicts() const |
| | { |
| | return lastHasConflict; |
| | } |
| | inline bool getLastHasRedundancies() const |
| | { |
| | return lastHasRedundancies; |
| | } |
| | inline bool getLastHasPartialRedundancies() const |
| | { |
| | return lastHasPartialRedundancies; |
| | } |
| | inline bool getLastHasMalformedConstraints() const |
| | { |
| | return lastHasMalformedConstraints; |
| | } |
| | inline int getLastSolverStatus() const |
| | { |
| | return lastSolverStatus; |
| | } |
| | inline const std::vector<int>& getLastConflicting() const |
| | { |
| | return lastConflicting; |
| | } |
| | inline const std::vector<int>& getLastRedundant() const |
| | { |
| | return lastRedundant; |
| | } |
| | inline const std::vector<int>& getLastPartiallyRedundant() const |
| | { |
| | return lastPartiallyRedundant; |
| | } |
| | inline const std::vector<int>& getLastMalformedConstraints() const |
| | { |
| | return lastMalformedConstraints; |
| | } |
| | fastsignals::signal<void()> signalSolverUpdate; |
| |
|
| | private: |
| | std::shared_ptr<MbD::ASMTAssembly> mbdAssembly; |
| |
|
| | std::unordered_map<App::DocumentObject*, MbDPartData> objectPartMap; |
| | std::vector<std::pair<App::DocumentObject*, double>> objMasses; |
| | std::vector<App::DocumentObject*> draggedParts; |
| | std::vector<App::DocumentObject*> motions; |
| |
|
| | std::vector<std::pair<App::DocumentObject*, Base::Placement>> previousPositions; |
| |
|
| | bool bundleFixed; |
| |
|
| | int lastDoF; |
| | bool lastHasConflict; |
| | bool lastHasRedundancies; |
| | bool lastHasPartialRedundancies; |
| | bool lastHasMalformedConstraints; |
| | int lastSolverStatus; |
| |
|
| | std::vector<int> lastConflicting; |
| | std::vector<int> lastRedundant; |
| | std::vector<int> lastPartiallyRedundant; |
| | std::vector<int> lastMalformedConstraints; |
| | }; |
| |
|
| | } |
| |
|
| |
|
| | #endif |
| |
|