Caribou
MultiVecEqualVisitor.h
1 #include <sofa/simulation/MechanicalVisitor.h>
2 
3 namespace SofaCaribou::visitor {
9 class MultiVecEqualVisitor : public sofa::simulation::BaseMechanicalVisitor {
10 public:
11 
21  MultiVecEqualVisitor(const sofa::core::ExecParams *params,
22  sofa::core::TMultiVecId<sofa::core::V_ALL, sofa::core::V_WRITE> a,
23  sofa::core::TMultiVecId<sofa::core::V_ALL, sofa::core::V_READ> b,
24  bool mapped = false,
25  bool only_mapped = false)
26  : BaseMechanicalVisitor(params), p_a(a), p_b(b), p_mapped(mapped), p_only_mapped(only_mapped) {
27  }
28 
29  // If mapped or only_mapped is ste, this visitor must go through all mechanical mappings, even if isMechanical flag is disabled
30  bool stopAtMechanicalMapping(sofa::simulation::Node * /*node*/, sofa::core::BaseMapping *map) override {
31  if (p_mapped || p_only_mapped)
32  return false;
33  else
34  return !map->areForcesMapped();
35  }
36 
37  Result fwdMechanicalState(VisitorContext *ctx, sofa::core::behavior::BaseMechanicalState *mm) override;
38 
39  Result fwdMappedMechanicalState(VisitorContext *ctx, sofa::core::behavior::BaseMechanicalState *mm) override;
40 
41  void copy(sofa::core::behavior::BaseMechanicalState * state) const ;
42 
43  const char *getClassName() const override { return "MultiVecEqualVisitor"; }
44 
45  std::string getInfos() const override;
46 
47 private:
48  sofa::core::TMultiVecId<sofa::core::V_ALL, sofa::core::V_WRITE> p_a;
49  sofa::core::TMultiVecId<sofa::core::V_ALL, sofa::core::V_READ> p_b;
50  bool p_mapped;
51  bool p_only_mapped;
52 };
53 
54 } // namespace SofaCaribou::visitor
SofaCaribou::visitor::MultiVecEqualVisitor
This visitor is used to compute a = b, where a and b are multi-vectors (MultiVecDeriv or MultiVecCoor...
Definition: MultiVecEqualVisitor.h:9
SofaCaribou::visitor::MultiVecEqualVisitor::MultiVecEqualVisitor
MultiVecEqualVisitor(const sofa::core::ExecParams *params, sofa::core::TMultiVecId< sofa::core::V_ALL, sofa::core::V_WRITE > a, sofa::core::TMultiVecId< sofa::core::V_ALL, sofa::core::V_READ > b, bool mapped=false, bool only_mapped=false)
Assign the values of the multi-vector b to the values of a (ie, a := b), no mather the type of a and ...
Definition: MultiVecEqualVisitor.h:21