iksolver.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 *<
00003 FILE: IKSolver.h
00004 
00005 DESCRIPTION:  IK Solver Class definition
00006 
00007 CREATED BY: Jianmin Zhao
00008 
00009 HISTORY: created 16 March 2000
00010 
00011 *>  Copyright (c) 1994, All Rights Reserved.
00012 **********************************************************************/
00013 #pragma once
00014 
00015 #include "plugapi.h"
00016 #include "IKHierarchy.h"
00017 // forward declarations
00018 
00034 class IKSolver  : public BaseInterfaceServer {
00035 public:
00036     typedef unsigned    ReturnCondition;
00037     enum ConditionBit {
00038         bLimitReached =         0x00000001,
00039         bLimitClamped =         0x00000002,
00040         bMaxIterationReached =  0x00000004,
00041         // The first eight bits are reserved for mild condition.
00042         // They are still considered successful.
00043         bGoalTooCloseToEE =     0x00000100,
00044         bInvalidArgument =      0x00000200,
00045         bInvalidInitialValue =  0x00000400
00046     };
00047     // Plugins derived from this class are supposed to have this super class id.
00053     virtual SClass_ID SuperClassID() {return IK_SOLVER_CLASS_ID;}
00055     virtual Class_ID ClassID() =0;
00063     virtual void GetClassName(MSTR& s) { s= MSTR(_M("IKSolver")); }  
00065     virtual ~IKSolver(){}
00066 
00067     // History independent solver does need time input.
00078     virtual bool        IsHistoryDependent() const =0;
00086     virtual bool        DoesOneChainOnly() const =0;
00087     // Interactive solver does need initial pose. It needs current pose.
00098     virtual bool        IsInteractive() const =0;
00103     virtual bool        UseSlidingJoint() const =0;
00108     virtual bool        UseSwivelAngle() const =0;
00109     // Solutions of an analytic solver is not dependent on Pos/Rot threshold
00110     // or MaxInteration number.
00117     virtual bool        IsAnalytic() const { return false; }
00118     // The result will be simply clamped into joint limits by the ik system
00119     // if the solver does not do joint limits.
00126     virtual bool        DoesRootJointLimits() const { return false;}
00133     virtual bool        DoesJointLimitsButRoot() const { return false;}
00134 
00135     // The interface ID that this solver is equipped to solve.
00136     virtual Interface_ID ExpectGoal() const =0;
00137     // RotThreshold() is not relevant to solver that does not SolveEERotation().
00138     // UseSwivelAngle() and SolveEERotation() cannot both be true.
00144     virtual bool        SolveEERotation() const =0;
00145     // A solver may have its own zero map. If so, the IK system may want
00146     // to know through this method.
00165 #pragma warning(push)
00166 #pragma warning(disable:4100)
00167     virtual const IKSys::ZeroPlaneMap* GetZeroPlaneMap(const Point3& a0, const Point3& n0) const { return NULL; }
00168 #pragma warning(pop)
00169 
00170     virtual float       GetPosThreshold() const =0;
00172     virtual float       GetRotThreshold() const =0;
00175     virtual unsigned    GetMaxIteration() const =0;
00180     virtual void        SetPosThreshold(float) =0;
00185     virtual void        SetRotThreshold(float) =0;
00190     virtual void        SetMaxIteration(unsigned) =0;
00191     // The derived class should override this method if it answers true
00192     // to DoesOneChainOnly() and false to HistoryDependent().
00193     // The solver is not designed to be invoked recursively. The
00194     // recursion logic existing among the ik chains is taken care of by
00195     // the Max IK (sub-)System.
00223     virtual ReturnCondition Solve(IKSys::LinkChain&) =0;
00224 };