Forum Replies Created
-
AuthorPosts
-
4 February 2018 at 05:32 in reply to: [SOLVED] Translating mechanical objects (not working c++) #10413WengBlocked
Have you tried the MechanicalStateController in SofaUserInteraction Project? The mechanical state could be modified in the following steps:
(1) get the MechanicalState
using core::behavior::MechanicalState;
mState = dynamic_cast<MechanicalState<DataTypes> *> (this->getContext()->getMechanicalState());(2) get the WriteAccessor of position
helper::WriteAccessor<Data<VecCoord> > x = *this->mState->write(core::VecCoordId::position());
helper::WriteAccessor<Data<VecCoord> > xfree = *this->mState->write(core::VecCoordId::freePosition());(3) modify the center or orientation
x[i].getCenter() = position;
xfree[i].getOrientation() = orientation;Best Regards,
Weng BinWengBlockedPrecomputedConstraintCorrection will take a few minutes to compute the .comp file and store it in its default path. The second time you run your scene file, PrecomputedConstraintCorrection will try to load the previous .comp file. To solve your problem, I suggest to find the .comp file and put it in the share folder.
WengBlockedHi, Erik
Thanks for your reply.
This is really helpful for anyone working on cutting.Best regards,
Weng BinWengBlockedDear Hugo,
Your reply does help.
Also, I found a component called MechanicalStateController in project SofaUserInteraction quite suitable for my purpose. And some examples in Controller folder are very useful.
In Qt GUI, to use mouse or keyboard, ‘Ctrl’ need to be pressed at the same time. Otherwise, the interaction defined by Qt viewer will be called.
Best regards,
Weng BinWengBlockedDear Hugo,
I checked the topics you suggested. And my problem is solved now.
Thanks!Best regards,
Weng BinWengBlockedDear Alison,
Dynamic topological change involves most parts of simulation. I am not an expert, here is what I think:
(1) First check if your forcefield support dynamic topological change. Is there a function “handleTopologicalChange” ? If not, you need to implement it.
(2) Need to call functions (e.g. removeTriangles, addTriangles…) in Modifier (e.g. TriangleSetTopologyModifier). These functions will call all handleTopologicalChange going down your scene graph. It will also change the mechanical state of your MechanicalObject.
(3) Some components did not handleTopologicalChange well by now, you need to check or modify them. For examples, adding points in OglModel troubles me a lot.regards,
Weng BinWengBlockedI think the most relevant plugins are: Sensable , SofaCarving. Try all examples in them.
You should handle the HapticDeviceEvent
(1) in OnAnimateBeginEvent of OmniDriver, send out HapticDeviceEvent (already implemented). If you are using NewOmniDriver, you may need to add codes to send out HapticDeviceEvent.
(2) in your plugin/component/class, add function handleEvent, and catch the HapticDeviceEvent. Refer to CarvingManager.cpp for example.Hope this could help.
regards,
Weng BinWengBlockedIt has been 6 days… no one answer…
Currently, what I know:
(1) TopologyEngine and handleTopologyChange() are both used in SOFA.
(2) TopologyEngine supports: PointData, EdgeData, …, HexahedronData (see TopologyData.h), all these data (variable) will be automatically updated according to the topology changes, no need to handleTopologyChange for them.
for example:
in BarycentricMapping.h : in BarycentricMapperHexahedronSetTopology
topology::PointData< sofa::helper::vector<MappingData> > map;in the init()
if (this->toTopology)
{
map.createTopologicalEngine(this->toTopology);
map.registerTopologicalData();
}indicates that map is using TopologyEngine,
(3) All the other situations rely one handleTopologyChange
for example, in TriangleModel.inl: void TTriangleModel<DataTypes>::handleTopologyChange()If I misunderstood anything, please reply
regards,
Weng Bin3 November 2015 at 10:11 in reply to: [SOLVED] Internal nodes’ displacements from surface displacement #3915WengBlockedTo the best of my knowledge, SOFA has two position,
(1) rest position, which is loaded or generated before the animation.
(2) free position, which is driven by forcefield,solver, etc.. in the animation.for your “initial position”, does it mean the rest position ?
for your “rest position”, does it mean the balance position in the animation when the object is undergone some forces (gravity for example)?Are you actually asking about the volume mesh generation from surface mesh ? If this is what you want, please search tetgen or netgen …
3 November 2015 at 09:41 in reply to: [SOLVED] Internal nodes’ displacements from surface displacement #3912WengBlockedWhat is initial position ? What is the difference between the rest position and initial position?
2 October 2015 at 02:00 in reply to: [SOLVED] How to develop collision model that support different proximity? #3724WengBlockedThank you, Romain.
Finally, I add my collision model successfully, although I have not implemented the different proximity yet.To summarize,
For the collision detection:
(1) Define MyTriangleModel derived from CollisionModel
(2) Add intersection method for MyTriangleModel to intersection class to allow it to intersect with the other collision models. For example, I add into LocalMinDistance with the following:
int computeIntersection(MyTriangle&, Point&, OutputVector*);
int computeIntersection(MyTriangle&, Sphere&, OutputVector*);
int computeIntersection(Ray&, MyTriangle&, OutputVector*);For the collision response:
(1) Add ContactMapper for MyTriangleModel. What I did is to add to BarycentricContactMapper with the following:template<class DataTypes>
class ContactMapper<MyTriangleModel, DataTypes> : public BarycentricContactMapper<MyTriangleModel, DataTypes>Since, in my scene I use BarycentricMapping. I think if other mapping was used, ContactMapper should be added respectively. The ContactMapper will be used in FrictionContact.
(2) Add Contact for MyTriangleModel. What I did is to add to FrictionContact.cpp with the following:
Creator<sofa::core::collision::Contact::Factory, FrictionContact<MyTriangleModel, PointModel> > MyTrianglePointFrictionContactClass(“FrictionContact”,true);
this should register the new type FrictionContact in the Contact::Factory
For different collision models and different ContactMapper and Contact, I think the steps should be similar.
regards,
Weng Bin30 September 2015 at 07:29 in reply to: [SOLVED] How to develop collision model that support different proximity? #3707WengBlockedHello Romain,
Thank you for answering my question so quickly!
I tried your advice.
But there are still some errors:[WARNING] [DefaultContactManager “response”] Contact FrictionContact between Wen
gTTriangleModel and TPointModel creation failed
[WARNING] [DefaultContactManager “response”] Supported models for contact Fricti
onContact:
[WARNING] [DefaultContactManager “response”] FrictionContact<TPointModel<StdV
ectorTypes<Vec<3,double>,Vec<3,double>,double> >,TPointModel<StdVectorTypes<Vec<
3,double>,Vec<3,double>,double> >,StdVectorTypes<Vec<3,double>,Vec<3,double>,dou
ble> >My collision model seems not supported by the contact FrictionContact. How to make it supported?
Best regards,
Weng BinWengBlockedDid you try this example with current stable version of SOFA?
examples\Components\forcefield\HexahedralFEMForceField.scn can be run successfully in my SOFA.
And how did you know the crash was due to QuadSetTopology?regards,
weng binWengBlockedMaybe you should try SofaCaving plugin.
Also try some examples in sofa\examples\Components\topology , try to use right button of mouse to remove tetrahedron.
I did not find any incision of tetrahedron in SOFA.
Some researchers in SOFA team have done the incision for sure, but I could not find it.
good luck!regards,
Weng Bin21 August 2015 at 03:43 in reply to: [SOLVED] Running examples in sensible folder (Sensible Plugin) #3486WengBlockedMy personal opinion.
The NewOmniDriver does not send out HapticDeviceEvent while OmniDriver does (tell me if I am wrong).
In the handleEvent() of CarvingManager, it needs to catch the HapticDeviceEvent to start doCarve().
So, to use the carving example, you need to either use OmniDriver or add codes in onAnimateBeginEvent() of NewOmniDriver to send out HapticDeviceEvent when the button is pressed.regards,
Weng Bin -
AuthorPosts