almatea Posted October 30, 2010 Share Posted October 30, 2010 (edited) [solved] Edited October 30, 2010 by almatea Quote Link to comment Share on other sites More sharing options...
rdg Posted October 30, 2010 Share Posted October 30, 2010 [solved] What and How? I remember roughly you having issues reading parms from a custom solver. Please send file so we can learn from it. Thanks. Quote Link to comment Share on other sites More sharing options...
almatea Posted October 31, 2010 Author Share Posted October 31, 2010 okay, I'll try to prepare example in soon time - there already is another troubles, now I try to solve it : ) Quote Link to comment Share on other sites More sharing options...
almatea Posted October 31, 2010 Author Share Posted October 31, 2010 (edited) a header file: // // // #ifndef __my_solver_h__ #define __my_solver_h__ #include <UT/UT_DSOVersion.h> #include <SIM/SIM_OptionsUser.h> #include <SIM/SIM_Solver.h> #define SIM_NAME_MY_PARM "myParm" class SIM_MyOwnSolver : public SIM_Solver, public SIM_OptionsUser { public: GETSET_DATA_FUNCS_F(SIM_NAME_MY_PARM, myParm); protected: explicit SIM_MyOwnSolver(const SIM_DataFactory *factory); virtual ~SIM_MyOwnSolver(); // This implements your own solver step virtual SIM_Solver::SIM_Result solveObjectsSubclass( SIM_Engine &engine, SIM_ObjectArray &objects, SIM_ObjectArray &newobjects, SIM_ObjectArray &feedbacktoobjects, const SIM_Time &timestep); private: static const SIM_DopDescription* getMyOwnSolverDescription(); DECLARE_STANDARD_GETCASTTOTYPE(); DECLARE_DATAFACTORY(SIM_MyOwnSolver, SIM_Solver, "SIM_MyOwnSolver", getMyOwnSolverDescription()); }; #endif cpp file: //my solver #include "my_solver.h" #include <UT/UT_DSOVersion.h> #include <UT/UT_XformOrder.h> #include <PRM/PRM_Include.h> #include <SIM/SIM_DopDescription.h> #include <SIM/SIM_DataFilter.h> #include <SIM/SIM_Object.h> #include <SIM/SIM_SDF.h> #include <SIM/SIM_ObjectArray.h> #include <SIM/SIM_OptionsUser.h> #include <SIM/SIM_Options.h> #include <SIM/SIM_Data.h> #include <SIM/SIM_Query.h> #include <RBD/RBD_State.h> #include <SIM/SIM_Engine.h> #include <SIM/SIM_Force.h> #include <SIM/SIM_ForcePoint.h> #include <SIM/SIM_ForceUniform.h> #include <SIM/SIM_ForceGravity.h> #include <SIM/SIM_Constraint.h> #include <SIM/SIM_ConAnchorObjSpacePos.h> #include <SIM/SIM_ConAnchorWorldSpacePos.h> #include <SIM/SIM_ConAnchor.h> #include <SIM/SIM_ConRel.h> #include <SIMZ/SIM_PopGeometry.h> #include <GEO/GEO_Detail.h> #include <UT/UT_Quaternion.h> //Constructor SIM_MyOwnSolver::SIM_MyOwnSolver(const SIM_DataFactory *factory) : BaseClass(factory), SIM_OptionsUser(this) { } //Destructor SIM_MyOwnSolver::~SIM_MyOwnSolver() { } const SIM_DopDescription * SIM_MyOwnSolver::getMyOwnSolverDescription() { static PRM_Name themyParm(SIM_NAME_MY_PARM, "myParm"); static PRM_Default defmyParm(155.55f); static PRM_Template theTemplates[] = { PRM_Template(PRM_FLT_J, 1, &themyParm, &defmyParm), PRM_Template() }; static SIM_DopDescription theDopDescription(true, "SIM_MyOwnSolver", "SIM_MyOwnSolver", "Solver", classname(), theTemplates); return &theDopDescription; } SIM_Solver::SIM_Result SIM_MyOwnSolver::solveObjectsSubclass( SIM_Engine &engine, SIM_ObjectArray &objects, SIM_ObjectArray &newobjects, SIM_ObjectArray &feedbacktoobjects, const SIM_Time &timestep) { //it can be even //float aaa=getmyParm(); int i; int totalDopObjects = engine.getNumSimulationObjects(); for(i = 0; i < totalDopObjects; i++) { //Get current dop sim object SIM_Object *currObject = (SIM_Object *)engine.getSimulationObject(i); SIM_MyOwnSolver *state = SIM_DATA_GET(*currObject, "Solver", SIM_MyOwnSolver); float aaa=state->getmyParm(); float bbb=currObject->getObjectId(); cout<< "myParm: " << aaa /*<< "; time: " << currTime*/ <<endl; cout<< "ObjectId: " << bbb /*<< "; time: " << currTime*/ <<endl; } cout <<endl; return SIM_SOLVER_SUCCESS; }; void initializeSIM(void *) { IMPLEMENT_DATAFACTORY(SIM_MyOwnSolver); } this simple solver with one parameter do cast this parameter to DOP property and print eval of this property to stdout Edited October 31, 2010 by almatea Quote Link to comment Share on other sites More sharing options...
rdg Posted October 31, 2010 Share Posted October 31, 2010 thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.