38 Vector3f
normal = Vector3f( 1, 0, 0 );
111 using Variant = std::variant<Sphere, ConeSegment, Plane>;
119[[nodiscard]]
inline Primitives::ConeSegment toPrimitive(
const Line3f& line ) {
return { .referencePoint = line.p, .dir = line.d.normalized(), .positiveLength = INFINITY, .negativeLength = INFINITY }; }
120[[nodiscard]]
inline Primitives::ConeSegment toPrimitive(
const LineSegm3f& segm ) {
return { .referencePoint = segm.a, .dir = segm.dir().normalized(), .positiveLength = segm.length() }; }
124 float halfLen = cyl.length / 2;
126 .referencePoint = cyl.
center(),
127 .dir = cyl.direction().normalized(),
128 .positiveSideRadius = cyl.radius, .negativeSideRadius = cyl.radius,
129 .positiveLength = halfLen, .negativeLength = halfLen,
135 .referencePoint = cone.
center(),
136 .dir = cone.direction().normalized(),
137 .positiveSideRadius = std::tan( cone.angle ) * cone.height, .negativeSideRadius = 0,
138 .positiveLength = cone.height, .negativeLength = 0,
236struct Unary<Primitives::ConeSegment>
246template <
typename A,
typename B>
251template <
typename A,
typename B>
254 { t.measure( a, b ) } -> std::same_as<MeasureResult>;
297[[nodiscard]] std::string
name(
const T& primitive )
305template <
typename A,
typename B>
309template <
typename A,
typename B>
320 if ( *dist && ( !std::isfinite( dist->distance ) || !dist->closestPointA.isFinite() || !dist->closestPointB.isFinite() ) )
325 assert( *dist <= ( std::abs( ( dist->closestPointB - dist->closestPointA ).length() - std::abs( dist->distance ) ) < 0.0001f ) );
333 assert( ret.
angle <= ( std::abs( 1 - ret.
angle.
dirA.length() ) < 0.0001f ) );
334 assert( ret.
angle <= ( std::abs( 1 - ret.
angle.
dirB.length() ) < 0.0001f ) );
350 return std::visit( [&](
const auto& elem ){
return (
measure)( elem, b ); }, a );
356 return std::visit( [&](
const auto& elem ){
return (
measure)( a, elem ); }, b );
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
named object in the data model
Definition MRObject.h:60
Definition MRFeatures.h:306
Definition MRFeatures.h:252
std::variant< Sphere, ConeSegment, Plane > Variant
Definition MRFeatures.h:111
Definition MRFeatures.h:21
std::string name(const T &primitive)
Definition MRFeatures.h:297
MRMESH_API Primitives::ConeSegment primitiveCylinder(const Vector3f &a, const Vector3f &b, float rad)
a and b are centers of the sides.
MeasureResult measure(const A &a, const B &b)
Definition MRFeatures.h:311
MRMESH_API std::shared_ptr< FeatureObject > primitiveToObject(const Primitives::Variant &primitive, float infiniteExtent)
MRMESH_API Primitives::ConeSegment primitiveCircle(const Vector3f &point, const Vector3f &normal, float rad)
normal doesn't need to be normalized.
MRMESH_API std::string_view toString(MeasureResult::Status status)
MRMESH_API Primitives::ConeSegment primitiveCone(const Vector3f &a, const Vector3f &b, float rad)
a is the center of the base, b is the pointy end.
Primitives::Sphere toPrimitive(const Vector3f &point)
Definition MRFeatures.h:116
MRMESH_API std::optional< Primitives::Variant > primitiveFromObject(const Object &object)
Definition MRCameraOrientationPlugin.h:8
Cylinder3f
Definition MRMesh/MRMeshFwd.h:261
Cone3f
Definition MRMesh/MRMeshFwd.h:266
Definition MRFeatures.h:196
Vector3f pointA
Definition MRFeatures.h:197
Vector3f dirFor(bool b) const
Definition MRFeatures.h:203
MRMESH_API float computeAngleInRadians() const
Vector3f pointB
Definition MRFeatures.h:198
Vector3f dirA
Definition MRFeatures.h:201
bool isSurfaceNormalA
Whether dir{A,B} is a surface normal or a line direction.
Definition MRFeatures.h:206
Vector3f pointFor(bool b) const
Definition MRFeatures.h:199
bool isSurfaceNormalFor(bool b) const
Definition MRFeatures.h:209
Vector3f dirB
Definition MRFeatures.h:202
bool isSurfaceNormalB
Definition MRFeatures.h:207
Definition MRFeatures.h:173
Status status
Definition MRFeatures.h:174
Definition MRFeatures.h:179
Vector3f closestPointA
Definition MRFeatures.h:183
Vector3f closestPointFor(bool b) const
Definition MRFeatures.h:186
Vector3f closestPointB
Definition MRFeatures.h:184
float distance
Definition MRFeatures.h:181
Stores the results of measuring two objects relative to one another.
Definition MRFeatures.h:157
MRMESH_API void swapObjects()
Distance centerDistance
Definition MRFeatures.h:193
Angle angle
Definition MRFeatures.h:213
Distance distance
Definition MRFeatures.h:189
Status
Definition MRFeatures.h:159
@ badRelativeLocation
Can't be computed because of how the objects are located relative to each other.
@ notImplemented
Algorithms set this if this when something isn't yet implemented.
@ notFinite
The result was not finite. This is set automatically if you return non-finite values,...
std::vector< Primitives::Variant > intersections
Definition MRFeatures.h:216
Definition MRFeatures.h:55
friend bool operator==(const ConeSegment &, const ConeSegment &)=default
float length() const
Definition MRFeatures.h:85
MRMESH_API Sphere basePoint(bool negative) const
MRMESH_API ConeSegment extendToInfinity() const
Vector3f referencePoint
Definition MRFeatures.h:63
MRMESH_API ConeSegment baseCircle(bool negative) const
MRMESH_API ConeSegment untruncateCone() const
float positiveSideRadius
Cap radius in the dir direction.
Definition MRFeatures.h:67
Vector3f dir
Definition MRFeatures.h:64
MRMESH_API Sphere centerPoint() const
float negativeLength
Distance from the center to the cap in the direction opposite to dir.
Definition MRFeatures.h:74
MRMESH_API Plane basePlane(bool negative) const
float negativeSideRadius
Cap radius in the direction opposite to dir.
Definition MRFeatures.h:69
MRMESH_API ConeSegment axis() const
float positiveLength
Distance from the center to the cap in the dir direction.
Definition MRFeatures.h:72
bool isZeroRadius() const
Definition MRFeatures.h:81
bool hollow
Definition MRFeatures.h:77
MRMESH_API ConeSegment extendToInfinity(bool negative) const
bool isCircle() const
Definition MRFeatures.h:82
Definition MRFeatures.h:34
Vector3f center
Definition MRFeatures.h:35
MRMESH_API Sphere intersectWithLine(const ConeSegment &line) const
MRMESH_API ConeSegment intersectWithPlane(const Plane &other) const
friend bool operator==(const Plane &, const Plane &)=default
Vector3f normal
Definition MRFeatures.h:38
MRMESH_API MeasureResult measure(const Primitives::ConeSegment &a, const Primitives::ConeSegment &b) const
MRMESH_API MeasureResult measure(const Primitives::ConeSegment &a, const Primitives::Sphere &b) const
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::ConeSegment &b) const
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::Plane &b) const
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::Sphere &b) const
MRMESH_API MeasureResult measure(const Primitives::Sphere &a, const Primitives::Sphere &b) const
Definition MRFeatures.h:247
MRMESH_API std::string name(const Primitives::ConeSegment &prim) const
MRMESH_API std::string name(const Primitives::Plane &prim) const
MRMESH_API std::string name(const Primitives::Sphere &prim) const
Definition MRFeatures.h:229
V center
Definition MRSphere.h:12