Medusa  1.1
Coordinate Free Mehless Method implementation
mm::NURBSShape< vec_t, param_vec_t > Class Template Reference

#include <NURBSShape_fwd.hpp>

Detailed Description

template<typename vec_t, typename param_vec_t>
class mm::NURBSShape< vec_t, param_vec_t >

Class representing a shape made out of NURBS patches in an arbitrary dimensional space.

Warning
Currently only supports NURBS surfaces (2D domain) and NURBS curves (1D domain).

Usage example:

int p = 3;
auto knots = Range<double>{0, 0, 0, 0, 1, 1, 1, 1};
Range<double> ws{1, 1, 1, 1};
Range<Vec2d> cps1{{1, 1}, {2, 3}, {4, 4}, {6, 1}};
Range<Vec2d> cps2{{1, 1}, {0, -3}, {8, -2}, {6, 1}};
NURBSPatch<Vec2d, Vec1d> p1(cps1, {ws}, {knots}, {p});
NURBSPatch<Vec2d, Vec1d> p2(cps2, {ws}, {knots}, {p});
Range<NURBSPatch<Vec2d, Vec1d>> patches{p1, p2};
NURBSShape<Vec2d, Vec1d> shape(patches);
shape.seed(1337);
double h = 0.01;
DomainDiscretization<Vec2d> domain = shape.discretizeBoundaryWithStep(h);
Template Parameters
vec_tVector type.

Definition at line 52 of file NURBSShape_fwd.hpp.

+ Inheritance diagram for mm::NURBSShape< vec_t, param_vec_t >:
+ Collaboration diagram for mm::NURBSShape< vec_t, param_vec_t >:

Public Member Functions

 NURBSShape (const Range< NURBSPatch< vec_t, param_vec_t >> &patches_in)
 Construct NURBSShape from a Range of patches. More...
 
 NURBSShape (Range< NURBSPatch< vec_t, param_vec_t >> &&patches_in)
 Move constructor for constructing NURBSShape from a Range of patches. More...
 
bool contains (const vec_t &) const override
 Return true if point is not more than margin() outside the domain. More...
 
bool hasContains () const override
 Return true if shape has contains() method implemented. More...
 
std::pair< vec_t, vec_t > bbox () const override
 Return the bounding box of the domain. More...
 
DomainDiscretization< vec_t > discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &, int) const override
 Discretizes boundary with given density and fill engine. More...
 
std::ostream & print (std::ostream &ostream) const override
 Output information about this shape to given output stream os. More...
 
NURBSShapeclone () const override
 Polymorphic clone pattern. More...
 
NURBSShapemaxPoints (int max_points)
 Maximal number of points generated in surface fill. More...
 
NURBSShapeseed (int seed)
 Set custom seed for the random number generator. More...
 
NURBSShapeproximityTolerance (scalar_t zeta)
 Set proximity tolerance in surface fill. More...
 
NURBSShapenumSamples (int n_samples)
 Controls the number of generated candidates from each point in surface fill. More...
 
NURBSShapeboundaryProximity (scalar_t epsilon)
 Calculate boundary normals epsilon times the size of domain away from the boundary. More...
 
scalar_t margin () const
 Returns current margin. More...
 
virtual void setMargin (scalar_t margin)
 Sets domain margin to margin. More...
 
void toggleMargin ()
 Toggles the margin from positive to negative. More...
 
ShapeUnion< vec_t > add (const DomainShape &other) const
 Returns a shape representing a union of *this and other. More...
 
ShapeUnion< vec_t > operator+ (const DomainShape &other) const
 Operator form of DomainShape::add. More...
 
ShapeDifference< vec_t > subtract (const DomainShape &other) const
 Returns a shape representing a difference of *this and other. More...
 
ShapeDifference< vec_t > operator- (const DomainShape &other) const
 Operator form of DomainShape::subtract. More...
 
virtual std::pair< bool, vec_t > projectPointToBoundary (const vec_t &point, const vec_t &unit_normal) const
 Project point to boundary using bisection along the line define by unit_normal. More...
 
virtual DomainDiscretization< vec_t > discretizeBoundaryWithStep (scalar_t step, int type) const
 Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More...
 
DomainDiscretization< vec_t > discretizeBoundaryWithStep (scalar_t step) const
 Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More...
 
virtual DomainDiscretization< vec_t > discretizeWithStep (scalar_t step, int internal_type, int boundary_type) const
 Returns a discretization of this shape with approximately uniform distance step between nodes. More...
 
DomainDiscretization< vec_t > discretizeWithStep (scalar_t step) const
 discretizeWithStep but with default types as assigned by the shape. More...
 
virtual DomainDiscretization< vec_t > discretizeWithDensity (const std::function< scalar_t(vec_t)> &dr, int internal_type, int boundary_type) const
 Returns a discretization of the domain with spatially variable step. More...
 
template<typename func_t , typename fill_t >
DomainDiscretization< vec_t > discretizeWithDensity (const func_t &dr, const fill_t &fill, int internal_type, int boundary_type) const
 Overload for fill engine. More...
 
DomainDiscretization< vec_t > discretizeWithDensity (const std::function< scalar_t(vec_t)> &dr) const
 Overload with default types. More...
 
template<typename func_t , typename fill_t >
DomainDiscretization< vec_t > discretizeWithDensity (const func_t &dr, const fill_t &fill) const
 Overload for fill engine with default types. More...
 
DomainDiscretization< vec_t > discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &dr) const
 Overload with default type. More...
 
TranslatedShape< vec_t > translate (const vec_t &a)
 Translate the shape by given vector a. More...
 
RotatedShape< vec_t > rotate (const Eigen::Matrix< scalar_t, dim, dim > &Q)
 Transform the shape by given orthogonal matrix Q. More...
 
RotatedShape< vec_t > rotate (scalar_t angle)
 2D version of rotate accepting an angle. More...
 

Public Types

enum  { dim = vec_t::dim, proj_dim = dim + 1, param_dim = param_vec_t::dim }
 Store dimensionality. More...
 
typedef vec_t::scalar_t scalar_t
 Scalar type. More...
 
typedef Vec< scalar_t, proj_dimproj_vec_t
 Vector type before projection. More...
 
enum  { dim = vec_t::dim }
 Store dimension of the domain. More...
 
typedef vec_t vector_t
 Vector data type used in computations. More...
 

Friends

struct nurbs_shape_internal::NURBSShapeHelper< vec_t, param_vec_t >
 

Protected Attributes

scalar_t margin_
 Tolerance for the geometric operation of the domain. More...
 

Private Attributes

Range< NURBSPatch< vec_t, param_vec_t > > patches
 Range of NURBS patches. More...
 
int max_points = 5000000
 Maximal number of points generated in surface fill. More...
 
int seed_
 Seed for the random number generator. More...
 
int n_samples = 15
 Number of samples in surface fill. More...
 
scalar_t zeta = 1 - 1e-10
 Proximity tolerance in surface fill. More...
 
scalar_t epsilon = 0
 Evaluate normals slightly away from the boundary. More...
 

Member Enumeration Documentation

◆ anonymous enum

template<typename vec_t >
anonymous enum
inherited

Store dimension of the domain.

Enumerator
dim 

Dimensionality of the domain.

Definition at line 57 of file DomainShape_fwd.hpp.

◆ anonymous enum

template<typename vec_t , typename param_vec_t >
anonymous enum

Store dimensionality.

Enumerator
dim 

Dimensionality of space after projection.

proj_dim 

Dimensionality of space before projection.

param_dim 

Dimensionality of parametric space.

Definition at line 58 of file NURBSShape_fwd.hpp.

Constructor & Destructor Documentation

◆ NURBSShape() [1/2]

template<typename vec_t , typename param_vec_t >
mm::NURBSShape< vec_t, param_vec_t >::NURBSShape ( const Range< NURBSPatch< vec_t, param_vec_t >> &  patches_in)

Construct NURBSShape from a Range of patches.

Definition at line 22 of file NURBSShape.hpp.

◆ NURBSShape() [2/2]

template<typename vec_t , typename param_vec_t >
mm::NURBSShape< vec_t, param_vec_t >::NURBSShape ( Range< NURBSPatch< vec_t, param_vec_t >> &&  patches_in)

Move constructor for constructing NURBSShape from a Range of patches.

Definition at line 33 of file NURBSShape.hpp.

Member Function Documentation

◆ add()

template<typename vec_t >
ShapeUnion< vec_t > mm::DomainShape< vec_t >::add ( const DomainShape< vec_t > &  other) const
inherited

Returns a shape representing a union of *this and other.

Definition at line 66 of file DomainShape.hpp.

◆ bbox()

template<typename vec_t , typename param_vec_t >
std::pair<vec_t, vec_t> mm::NURBSShape< vec_t, param_vec_t >::bbox ( ) const
inlineoverridevirtual

Return the bounding box of the domain.

Bounding box is returned in format bbox() == {{mx, my, ...}, {MX, MY, ...}}, such that mx <= Mx and my <= My etc.\ and that the whole domain is contained in the cuboid [mx, my, ...] x [Mx, My, ...].

Implements mm::DomainShape< vec_t >.

Definition at line 82 of file NURBSShape_fwd.hpp.

◆ boundaryProximity()

template<typename vec_t , typename param_vec_t >
NURBSShape< vec_t, param_vec_t > & mm::NURBSShape< vec_t, param_vec_t >::boundaryProximity ( scalar_t  epsilon)

Calculate boundary normals epsilon times the size of domain away from the boundary.

By default epsilon = 0. This can be useful if normals are undefined on the boundary. It should hold that 0 < epsilon < 1.

Definition at line 59 of file NURBSShape.hpp.

◆ clone()

template<typename vec_t , typename param_vec_t >
NURBSShape* mm::NURBSShape< vec_t, param_vec_t >::clone ( ) const
inlineoverridevirtual

Polymorphic clone pattern.

Implements mm::DomainShape< vec_t >.

Definition at line 95 of file NURBSShape_fwd.hpp.

◆ contains()

template<typename vec_t , typename param_vec_t >
bool mm::NURBSShape< vec_t, param_vec_t >::contains ( const vec_t &  point) const
inlineoverridevirtual

Return true if point is not more than margin() outside the domain.

Implements mm::DomainShape< vec_t >.

Definition at line 78 of file NURBSShape_fwd.hpp.

◆ discretizeBoundaryWithDensity() [1/2]

template<typename vec_t , typename param_vec_t >
DomainDiscretization< vec_t > mm::NURBSShape< vec_t, param_vec_t >::discretizeBoundaryWithDensity ( const std::function< scalar_t(vec_t)> &  dr,
int  type 
) const
overridevirtual

Discretizes boundary with given density and fill engine.

If type is 0, the underlying shape provides the default.

Implements mm::DomainShape< vec_t >.

Definition at line 44 of file NURBSShape.hpp.

◆ discretizeBoundaryWithDensity() [2/2]

template<typename vec_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeBoundaryWithDensity ( const std::function< scalar_t(vec_t)> &  dr) const
inlineinherited

Overload with default type.

Definition at line 189 of file DomainShape_fwd.hpp.

◆ discretizeBoundaryWithStep() [1/2]

template<typename vec_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeBoundaryWithStep ( scalar_t  step) const
inlineinherited

Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes.

Node type are decided by the underlying shape.

Definition at line 126 of file DomainShape_fwd.hpp.

◆ discretizeBoundaryWithStep() [2/2]

template<typename vec_t >
virtual DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeBoundaryWithStep ( scalar_t  step,
int  type 
) const
inlinevirtualinherited

Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes.

step must be positive. Added nodes are of type type, which must be non-positive. Value 0 indicates that types are dependant on the implementation of concrete shape.

Reimplemented in mm::PolygonShape< vec_t >, mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, mm::BoxShape< vec_t >, mm::ShapeDifference< vec_t >, and mm::BallShape< vec_t >.

Definition at line 118 of file DomainShape_fwd.hpp.

◆ discretizeWithDensity() [1/4]

template<typename vec_t >
template<typename func_t , typename fill_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeWithDensity ( const func_t &  dr,
const fill_t &  fill 
) const
inlineinherited

Overload for fill engine with default types.

Definition at line 177 of file DomainShape_fwd.hpp.

◆ discretizeWithDensity() [2/4]

template<typename vec_t >
template<typename func_t , typename fill_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeWithDensity ( const func_t &  dr,
const fill_t &  fill,
int  internal_type,
int  boundary_type 
) const
inlineinherited

Overload for fill engine.

Definition at line 162 of file DomainShape_fwd.hpp.

◆ discretizeWithDensity() [3/4]

template<typename vec_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeWithDensity ( const std::function< scalar_t(vec_t)> &  dr) const
inlineinherited

Overload with default types.

Definition at line 170 of file DomainShape_fwd.hpp.

◆ discretizeWithDensity() [4/4]

template<typename vec_t >
DomainDiscretization< vec_t > mm::DomainShape< vec_t >::discretizeWithDensity ( const std::function< scalar_t(vec_t)> &  dr,
int  internal_type,
int  boundary_type 
) const
virtualinherited

Returns a discretization of the domain with spatially variable step.

Parameters
drFunction giving desired internodal distance at each point.
internal_typeUser supplied type of internal nodes. Must be non-negative.
boundary_typeUser supplied type of boundary nodes. Must be non-positive. If any of the types is 0, the underlying shape provides the default.
Returns
Discretization with nodes distributed according to dr.

Reimplemented in mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, and mm::ShapeDifference< vec_t >.

Definition at line 77 of file DomainShape.hpp.

◆ discretizeWithStep() [1/2]

template<typename vec_t >
DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeWithStep ( scalar_t  step) const
inlineinherited

discretizeWithStep but with default types as assigned by the shape.

Definition at line 144 of file DomainShape_fwd.hpp.

◆ discretizeWithStep() [2/2]

template<typename vec_t >
virtual DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeWithStep ( scalar_t  step,
int  internal_type,
int  boundary_type 
) const
inlinevirtualinherited

Returns a discretization of this shape with approximately uniform distance step between nodes.

step must be positive.

Parameters
stepDesired internodal distance.
internal_typeUser supplied type of internal nodes. Must be non-negative.
boundary_typeUser supplied type of boundary nodes. Must be non-positive. If any of the types is 0, the underlying shape provides the default.

Reimplemented in mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, mm::BoxShape< vec_t >, mm::ShapeDifference< vec_t >, and mm::BallShape< vec_t >.

Definition at line 137 of file DomainShape_fwd.hpp.

◆ hasContains()

template<typename vec_t , typename param_vec_t >
bool mm::NURBSShape< vec_t, param_vec_t >::hasContains ( ) const
inlineoverridevirtual

Return true if shape has contains() method implemented.

Reimplemented from mm::DomainShape< vec_t >.

Definition at line 80 of file NURBSShape_fwd.hpp.

◆ margin()

template<typename vec_t >
scalar_t mm::DomainShape< vec_t >::margin ( ) const
inlineinherited

Returns current margin.

Definition at line 72 of file DomainShape_fwd.hpp.

◆ maxPoints()

template<typename vec_t , typename param_vec_t >
NURBSShape& mm::NURBSShape< vec_t, param_vec_t >::maxPoints ( int  max_points)
inline

Maximal number of points generated in surface fill.

Warning
The actual upper bound for number of points generated is maxPoints \(\pm\) numSamples.

Definition at line 103 of file NURBSShape_fwd.hpp.

◆ numSamples()

template<typename vec_t , typename param_vec_t >
NURBSShape& mm::NURBSShape< vec_t, param_vec_t >::numSamples ( int  n_samples)
inline

Controls the number of generated candidates from each point in surface fill.

For 2-D it is the actual number of candidates, for 3-D it is the number of candidates on the great circle. Its value is ignored in 1-D.

Definition at line 119 of file NURBSShape_fwd.hpp.

◆ operator+()

template<typename vec_t >
ShapeUnion<vec_t> mm::DomainShape< vec_t >::operator+ ( const DomainShape< vec_t > &  other) const
inlineinherited

Operator form of DomainShape::add.

See also
add

Definition at line 81 of file DomainShape_fwd.hpp.

◆ operator-()

template<typename vec_t >
ShapeDifference<vec_t> mm::DomainShape< vec_t >::operator- ( const DomainShape< vec_t > &  other) const
inlineinherited

Operator form of DomainShape::subtract.

See also
subtract

Definition at line 86 of file DomainShape_fwd.hpp.

◆ print()

template<typename vec_t , typename param_vec_t >
std::ostream& mm::NURBSShape< vec_t, param_vec_t >::print ( std::ostream &  os) const
inlineoverridevirtual

Output information about this shape to given output stream os.

Implements mm::DomainShape< vec_t >.

Definition at line 91 of file NURBSShape_fwd.hpp.

◆ projectPointToBoundary()

template<typename vec_t >
std::pair< bool, vec_t > mm::DomainShape< vec_t >::projectPointToBoundary ( const vec_t &  point,
const vec_t &  unit_normal 
) const
virtualinherited

Project point to boundary using bisection along the line define by unit_normal.

Definition at line 21 of file DomainShape.hpp.

◆ proximityTolerance()

template<typename vec_t , typename param_vec_t >
NURBSShape< vec_t, param_vec_t > & mm::NURBSShape< vec_t, param_vec_t >::proximityTolerance ( scalar_t  zeta)

Set proximity tolerance in surface fill.

A new candidate mush be at least zeta*h(p) away. It should hold that 0 < zeta < 1.

Definition at line 51 of file NURBSShape.hpp.

◆ rotate() [1/2]

template<typename vec_t >
RotatedShape< vec_t > mm::DomainShape< vec_t >::rotate ( const Eigen::Matrix< scalar_t, dim, dim > &  Q)
inherited

Transform the shape by given orthogonal matrix Q.

Note
It is usually faster to first discretize the domain and than transform the whole discretization using DomainDiscretization::rotate.

Definition at line 98 of file DomainShape.hpp.

◆ rotate() [2/2]

template<typename vec_t >
RotatedShape< vec_t > mm::DomainShape< vec_t >::rotate ( scalar_t  angle)
inherited

2D version of rotate accepting an angle.

Definition at line 89 of file DomainShape.hpp.

◆ seed()

template<typename vec_t , typename param_vec_t >
NURBSShape& mm::NURBSShape< vec_t, param_vec_t >::seed ( int  seed)
inline

Set custom seed for the random number generator.

Definition at line 106 of file NURBSShape_fwd.hpp.

◆ setMargin()

template<typename vec_t >
virtual void mm::DomainShape< vec_t >::setMargin ( scalar_t  margin)
inlinevirtualinherited

Sets domain margin to margin.

Reimplemented in mm::PolygonShape< vec_t >.

Definition at line 75 of file DomainShape_fwd.hpp.

◆ subtract()

template<typename vec_t >
ShapeDifference< vec_t > mm::DomainShape< vec_t >::subtract ( const DomainShape< vec_t > &  other) const
inherited

Returns a shape representing a difference of *this and other.

Definition at line 71 of file DomainShape.hpp.

◆ toggleMargin()

template<typename vec_t >
void mm::DomainShape< vec_t >::toggleMargin ( )
inlineinherited

Toggles the margin from positive to negative.

Definition at line 77 of file DomainShape_fwd.hpp.

◆ translate()

template<typename vec_t >
TranslatedShape< vec_t > mm::DomainShape< vec_t >::translate ( const vec_t &  a)
inherited

Translate the shape by given vector a.

Note
It is usually faster to first discretize the domain and than translate the whole discretization using DomainDiscretization::translate.

Definition at line 84 of file DomainShape.hpp.

Member Data Documentation

◆ epsilon

template<typename vec_t , typename param_vec_t >
scalar_t mm::NURBSShape< vec_t, param_vec_t >::epsilon = 0
private

Evaluate normals slightly away from the boundary.

Definition at line 69 of file NURBSShape_fwd.hpp.

◆ margin_

template<typename vec_t >
scalar_t mm::DomainShape< vec_t >::margin_
protectedinherited

Tolerance for the geometric operation of the domain.

The domain should behave as if it was margin_ thicker. Default margin is 1e-10.

Definition at line 64 of file DomainShape_fwd.hpp.

◆ max_points

template<typename vec_t , typename param_vec_t >
int mm::NURBSShape< vec_t, param_vec_t >::max_points = 5000000
private

Maximal number of points generated in surface fill.

Definition at line 65 of file NURBSShape_fwd.hpp.

◆ n_samples

template<typename vec_t , typename param_vec_t >
int mm::NURBSShape< vec_t, param_vec_t >::n_samples = 15
private

Number of samples in surface fill.

Definition at line 67 of file NURBSShape_fwd.hpp.

◆ patches

template<typename vec_t , typename param_vec_t >
Range<NURBSPatch<vec_t, param_vec_t> > mm::NURBSShape< vec_t, param_vec_t >::patches
private

Range of NURBS patches.

Definition at line 64 of file NURBSShape_fwd.hpp.

◆ seed_

template<typename vec_t , typename param_vec_t >
int mm::NURBSShape< vec_t, param_vec_t >::seed_
private

Seed for the random number generator.

Definition at line 66 of file NURBSShape_fwd.hpp.

◆ zeta

template<typename vec_t , typename param_vec_t >
scalar_t mm::NURBSShape< vec_t, param_vec_t >::zeta = 1 - 1e-10
private

Proximity tolerance in surface fill.

Definition at line 68 of file NURBSShape_fwd.hpp.


The documentation for this class was generated from the following files:
mm::NURBSShape::patches
Range< NURBSPatch< vec_t, param_vec_t > > patches
Range of NURBS patches.
Definition: NURBSShape_fwd.hpp:64