AGX Dynamics  2.37.3.2
WireNodeDensityController.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxWire/Node.h>
20 
22 
23 namespace agxWire
24 {
25  class WireDistanceCompositeConstraint;
26 
27  typedef agx::RangeReal WireNodeRange;
28 
29  struct AGXPHYSICS_EXPORT HighResData
30  {
31  HighResData() : range( agx::Real( 0 ), agx::Real( 0 ) ), resolutionPerUnitLength( agx::Real( 0 ) ) {}
32 
33  HighResData( agx::RangeReal rangeRelWire, agx::Real resPerUnitLength )
34  : range( rangeRelWire ), resolutionPerUnitLength( resPerUnitLength ) {}
35 
36  agx::Bool overlaps( agx::RangeReal otherRange ) const
37  {
38  return agx::leq(range.lower(), otherRange.upper() ) &&
39  agx::geq(range.upper(), otherRange.lower() );
40  }
41 
42  agx::Bool overlaps( agx::Real val, agx::Real epsilon )
43  {
44  return overlaps( agx::RangeReal( val - epsilon, val + epsilon ) );
45  }
46 
47  HighResData reversed() const
48  {
49  HighResData ret = *this;
50  ret.range.lower() *= agx::Real( -1 );
51  ret.range.upper() *= agx::Real( -1 );
52  std::swap( ret.range.lower(), ret.range.upper() );
53  return ret;
54  }
55 
56  agx::RangeReal range;
57  agx::Real resolutionPerUnitLength;
58  };
59  typedef agx::Vector< HighResData > HighResDataContainer;
60  typedef agx::List< HighResData > HighResDataList;
61 
62  class AGXPHYSICS_EXPORT WireNodeDensityController : public agx::Referenced
63  {
64  public:
65  WireNodeDensityController() {}
66 
67  void update( agxWire::WireDistanceCompositeConstraint* wire );
68 
69  void clear();
70 
76  const HighResDataContainer& getHighResolutionData() const;
77 
83  HighResDataList& getRangeExcessData();
84 
85  void addResolutionRange( agxWire::Node* node, agx::Real distanceAlongWire );
86  void addResolutionRange( agx::RangeReal range, agx::Real resolutionPerUnitLength );
87  void addResolutionRange( agxWire::HighResData hresData );
88 
89  void addExternalHighResolutionRange( Node* node, agx::Real distanceOnSegment );
90 
94  bool resolutionHighEnoughForPosition(const agx::Real restlengthToBfn,const agx::Real minDistanceToLump, const agx::Real eps = agx::Real(1E-6) ) const;
95 
101  void findLocalHighResolutionRanges( const agx::Real distanceOnWireToStart, const agx::Real localLength, agx::Vector< agxWire::WireNodeRange >& foundRanges );
102 
103  private:
104  HighResDataContainer m_highResolutionNodesDistanceOnWire;
105  HighResDataList m_rangeExcess;
106 
107  };
108 
109 }
110 
T & upper()
Definition: Range.h:298
AGXTERRAIN_EXPORT void clear()
bool Bool
Definition: Integer.h:48
#define AGXPHYSICS_EXPORT
bool geq(double a, double b, double eps=(double) AGX_EQUIVALENT_EPSILON)
Definition: Math.h:381
void swap(agx::String &lhs, agx::String &rhs)
Definition: String.h:914
Base class providing referencing counted objects.
Definition: Referenced.h:119
bool leq(double a, double b, double eps=(double) AGX_EQUIVALENT_EPSILON)
Definition: Math.h:369
Templated vector class.
Definition: Vector.h:52
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
T & lower()
Definition: Range.h:286
Class defining a node that is part of a wire.
Definition: agxWire/Node.h:511
double Real
Definition: Real.h:42
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97