MeshLib Documentation
Loading...
Searching...
No Matches
MRDipole.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector3.h"
4
5namespace MR
6{
7
10struct Dipole
11{
12 Vector3f pos;
13 float area = 0;
14 Vector3f dirArea;
15 float rr = 0; // maximum squared distance from pos to any corner of the bounding box
18 [[nodiscard]] bool addIfGoodApprox( const Vector3f& q, float betaSq, float& addTo ) const
19 {
20 const auto dp = pos - q;
21 const auto dd = dp.lengthSq();
22 if ( dd <= betaSq * rr )
23 return false;
24 if ( const auto d = std::sqrt( dd ); d > 0 )
25 addTo += dot( dp, dirArea ) / ( d * dd );
26 return true;
27 }
28};
29
30static_assert( sizeof( Dipole ) == 8 * sizeof( float ) );
31
33MRMESH_API void calcDipoles( Dipoles& dipoles, const AABBTree& tree, const Mesh& mesh );
34[[nodiscard]] MRMESH_API Dipoles calcDipoles( const AABBTree& tree, const Mesh& mesh );
35
40[[nodiscard]] MRMESH_API float calcFastWindingNumber( const Dipoles& dipoles, const AABBTree& tree, const Mesh& mesh,
41 const Vector3f & q, float beta, FaceId skipFace );
42
43} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRAABBTree.h:16
Definition MRCameraOrientationPlugin.h:8
MRMESH_API float calcFastWindingNumber(const Dipoles &dipoles, const AABBTree &tree, const Mesh &mesh, const Vector3f &q, float beta, FaceId skipFace)
MRMESH_API void calcDipoles(Dipoles &dipoles, const AABBTree &tree, const Mesh &mesh)
calculates dipoles for given mesh and AABB-tree
struct MRMESH_CLASS Dipole
Definition MRMesh/MRMeshFwd.h:385
Definition MRDipole.h:11
float rr
Definition MRDipole.h:15
Vector3f dirArea
Definition MRDipole.h:14
bool addIfGoodApprox(const Vector3f &q, float betaSq, float &addTo) const
Definition MRDipole.h:18
float area
Definition MRDipole.h:13
Vector3f pos
Definition MRDipole.h:12
Definition MRMesh/MRMesh.h:23