20#define GISMO_BASIS_ACCESSORS \
21 Basis & basis() { return static_cast<Basis&>(*this->m_basis); } \
22 const Basis & basis() const { return static_cast<const Basis&>(*this->m_basis); }
97 typedef memory::shared_ptr< gsGeometry >
Ptr;
100 typedef memory::unique_ptr< gsGeometry >
uPtr;
123 "The coefficient matrix of the geometry (rows="<<
m_coefs.rows()
124 <<
") does not match the number of basis functions in its basis("
125 <<
basis.size() <<
").");
134 virtual ~gsGeometry();
137#if EIGEN_HAS_RVALUE_REFERENCES
142 other.m_basis = NULL;
146 m_coefs.swap(other.m_coefs); other.m_coefs.clear();
148 m_basis = other.m_basis; other.m_basis = NULL;
149 m_id = std::move(other.m_id);
176 void eval_into(
const gsMatrix<T>& u, gsMatrix<T>& result)
const;
222 virtual void deriv_into(
const gsMatrix<T>& u, gsMatrix<T>& result)
const;
244 virtual void deriv2_into(
const gsMatrix<T>& u, gsMatrix<T>& result)
const;
247 std::vector<gsMatrix<T> > & result,
248 bool sameElement =
false)
const;
251 virtual void compute(
const gsMatrix<T> & in, gsFuncData<T> & out)
const;
265 return (T(0) < val) - (val < (T)(0));
270 virtual void toggleOrientation();
355 "Coefficient or coordinate which is out of range requested.");
363 "Coefficient or coordinate which is out of range requested.");
397 gsEigen::Transform<T,3,gsEigen::Affine>
398 rot( gsEigen::AngleAxis<T> (angle,axis.normalized()) );
401 rot.matrix().transpose() ).leftCols(3) ;
408 gsEigen::Rotation2D<T> rot(angle);
409 this->
m_coefs *= rot.matrix().transpose();
417 else if ( coord <
geoDim() )
424 GISMO_ASSERT( v.rows() == this->m_coefs.cols(),
"Sizes do not agree." );
425 this->
m_coefs.array().rowwise() *= v.array().transpose();
431 this->
m_coefs.rowwise() += v.transpose();
462 void unrefineElements( std::vector<index_t>
const & boxes );
478 GISMO_ASSERT( N > 0,
"Embed dimension must be positive");
481 if ( nc == 0 )
return;
483 if (!pad_right && nc<0)
485 m_coefs.conservativeResize(gsEigen::NoChange, N);
490 m_coefs.rightCols(nc).setZero();
494 m_coefs.leftCols(nc).setZero();
498 else gsWarn<<
"Coefficients projected (deleted)..\n";
542 std::vector<gsGeometry *>
boundary()
const;
557 virtual std::ostream &
print(std::ostream &os)
const;
562 virtual void toMesh(
gsMesh<T> & msh,
int npoints)
const;
590 const T accuracy = 1e-6,
591 const bool useInitialPoint =
false)
const;
598 const T accuracy = 1e-6)
const;
603 const T accuracy = 1e-6,
604 const bool directed=
false)
const;
609 const T accuracy)
const;
643{
return b.
print(os); }
656template <
short_t d,
typename T>
659 typedef gsGeometry<T> GeometryBase;
664struct gsGeoTraits<1,T>
666 typedef gsCurve<T> GeometryBase;
671struct gsGeoTraits<2,T>
673 typedef gsSurface<T> GeometryBase;
678struct gsGeoTraits<3,T>
680 typedef gsVolume<T> GeometryBase;
685struct gsGeoTraits<4,T>
687 typedef gsBulk<T> GeometryBase;
690#ifdef GISMO_WITH_PYBIND11
695 void pybind11_init_gsGeometry(pybind11::module &m);
702#ifndef GISMO_BUILD_LIB
703#include GISMO_HPP_HEADER(gsGeometry.hpp)
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual gsMatrix< T > parameterCenter() const
Returns a "central" point inside inside the parameter domain.
Definition gsFunction.h:261
gsGeometrySlice is a class representing an iso parametric slice of a geometry object....
Definition gsGeometrySlice.h:28
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate second derivatives of the function at points u into result.
Definition gsGeometry.hpp:174
gsMatrix< T > & coefs()
Definition gsGeometry.h:340
T HausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6, const bool directed=false) const
Computes the Hausdorff distance between *this to other.
Definition gsGeometry.hpp:377
std::vector< gsGeometry * > boundary() const
Get boundary of this geometry as a vector of new gsGeometry instances.
Definition gsGeometry.hpp:437
virtual void uniformCoarsen(int numKnots=1)
Coarsen the geometry uniformly, removing numKnots new knots into each knot span.
Definition gsGeometry.hpp:312
void scale(gsVector< T > const &v)
Apply Scaling coord-wise by a vector v.
Definition gsGeometry.h:422
gsMatrix< T >::RowXpr coefAtCorner(boxCorner const &c)
Returns the control point at corner c.
Definition gsGeometry.hpp:293
virtual void degreeElevate(short_t const i=1, short_t const dir=-1)
Elevate the degree by the given amount i for the direction dir. If dir is -1 then degree elevation is...
Definition gsGeometry.hpp:450
virtual void degreeIncrease(short_t const i=1, short_t const dir=-1)
Elevate the degree by the given amount i for the direction dir. If dir is -1 then degree elevation is...
Definition gsGeometry.hpp:476
void setCoefs(gsMatrix< T > cc)
Set the coefficient matrix of the geometry, taking ownership of the matrix.
Definition gsGeometry.h:368
void setId(const size_t i)
Sets the patch index for this patch.
Definition gsGeometry.h:612
void scale(T s, int coord=-1)
Apply Scaling by factor s.
Definition gsGeometry.h:413
gsMatrix< T >::RowXpr coef(index_t i)
Returns the i-th coefficient of the geometry as a row expression.
Definition gsGeometry.h:346
void translate(gsVector< T > const &v)
Apply translation by vector v.
Definition gsGeometry.h:429
short_t degree(const short_t &i) const
Returns the degree wrt direction i.
Definition gsGeometry.hpp:333
void embed(index_t N, bool pad_right=true)
Embeds coefficients in N dimensions For the new dimensions zeros are added (or removed) on the right ...
Definition gsGeometry.h:476
size_t id() const
Returns the patch index for this patch.
Definition gsGeometry.h:615
short_t coDim() const
Co-dimension of the geometric object.
Definition gsGeometry.hpp:187
void rotate(T angle)
Apply 2D Rotation by angle radians.
Definition gsGeometry.h:405
void evaluateMesh(gsMesh< T > &mesh) const
Definition gsGeometry.hpp:255
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition gsGeometry.h:100
std::vector< boxSide > locateOn(const gsMatrix< T > &u, gsVector< bool > &onG2, gsMatrix< T > &preIm, bool lookForBoundary=false, real_t tol=1.e-6) const
Get back the side of point u.
Definition gsGeometry.hpp:620
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero functions and their derivatives up to order n at points u into result.
Definition gsGeometry.hpp:178
short_t targetDim() const
Dimension of the ambient physical space (overriding gsFunction::targetDim())
Definition gsGeometry.h:286
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsGeometry.hpp:166
virtual void merge(gsGeometry *other)
Merge the given other geometry into this one.
Definition gsGeometry.hpp:420
gsGeometry()
Default constructor. Note: Derived constructors (except for the default) should assign m_basis to a v...
Definition gsGeometry.h:111
virtual void hessian_into(const gsMatrix< T > &u, gsMatrix< T > &result, index_t coord) const
Definition gsGeometry.hpp:502
virtual void compute(const gsMatrix< T > &in, gsFuncData< T > &out) const
Computes function data.
Definition gsGeometry.hpp:553
virtual std::vector< gsGeometry< T > * > uniformSplit(index_t dir=-1) const
Definition gsGeometry.hpp:280
void outerNormal_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Computes the outer normals at parametric points u.
Definition gsGeometry.hpp:433
short_t geoDim() const
Dimension n of the absent physical space.
Definition gsGeometry.h:292
void recoverPoints(gsMatrix< T > &xyz, gsMatrix< T > &uv, index_t k, const T accuracy) const
Recovers the points of the geometry from the given points xyz and parameters uv.
Definition gsGeometry.hpp:393
virtual void degreeReduce(short_t const i=1, short_t const dir=-1)
Reduces the degree by the given amount i for the direction dir. If dir is -1 then degree reduction is...
Definition gsGeometry.hpp:463
short_t coefDim() const
Dimension n of the coefficients (control points)
Definition gsGeometry.h:289
T directedHausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6) const
Definition gsGeometry.hpp:360
int orientation() const
Evaluates if the geometry orientation coincide with the ambient orientation. This is computed in the ...
Definition gsGeometry.h:260
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition gsGeometry.hpp:184
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
virtual gsGeometry::uPtr iface(const boundaryInterface &bi, const gsGeometry &other) const
Computes and returns the interface with other as a new geometry.
Definition gsGeometry.hpp:232
gsGeometry::uPtr component(boxComponent const &bc) const
Get parametrization of box component bc as a new gsGeometry uPtr.
Definition gsGeometry.hpp:240
virtual void uniformRefine(int numKnots=1, int mul=1, short_t const dir=-1)
Refine the geometry uniformly, inserting numKnots new knots into each knot span.
Definition gsGeometry.hpp:306
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition gsGeometry.hpp:190
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition gsGeometry.hpp:170
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition gsGeometry.h:632
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition gsGeometry.hpp:193
void rotate(T angle, const gsVector< T, 3 > &axis)
Apply 3D Rotation by angle radians around axis axis.
Definition gsGeometry.h:394
T closestPointTo(const gsVector< T > &pt, gsVector< T > &result, const T accuracy=1e-6, const bool useInitialPoint=false) const
Definition gsGeometry.hpp:339
const gsMatrix< T > & coefs() const
Returns the coefficient matrix of the geometry.
Definition gsGeometry.h:343
memory::shared_ptr< gsGeometry > Ptr
Shared pointer for gsGeometry.
Definition gsGeometry.h:97
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition gsGeometry.h:629
size_t m_id
Definition gsGeometry.h:636
void linearTransform(const gsMatrix< T > &mat)
Apply the given square matrix to every control point.
Definition gsGeometry.h:388
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsGeometry.hpp:410
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition gsGeometry.hpp:538
gsGeometrySlice< T > getIsoParametricSlice(index_t dir_fixed, T par) const
Definition gsGeometry.hpp:286
index_t coefsSize() const
Return the number of coefficients (control points)
Definition gsGeometry.h:371
const T coef(index_t i, index_t j) const
Returns the j-th coordinate of the i-th coefficient of the geometry.
Definition gsGeometry.h:360
virtual gsBasis< T > & basis()=0
Returns a reference to the basis of the geometry.
T & coef(index_t i, index_t j)
Returns the j-th coordinate of the i-th coefficient of the geometry.
Definition gsGeometry.h:352
void refineElements(std::vector< index_t > const &boxes)
Refines the basis and adjusts the coefficients to keep the geometry the same.
Definition gsGeometry.hpp:318
virtual void insertKnot(T knot, index_t dir, index_t i=1)
Inserts knot knot at direction dir, i times.
Definition gsGeometry.hpp:444
gsMatrix< T >::ConstRowXpr coef(index_t i) const
Returns the i-th coefficient of the geometry as a row expression.
Definition gsGeometry.h:349
virtual void degreeDecrease(short_t const i=1, short_t const dir=-1)
Reduces the degree by the given amount i for the direction dir. If dir is -1 then degree reduction is...
Definition gsGeometry.hpp:489
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition gsGeometry.hpp:198
void embed3d()
Embeds coefficients in 3D.
Definition gsGeometry.h:467
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Provides structs and classes related to interfaces and boundaries.
Provides declaration of a 4D bulk.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
Provides declaration of Curve abstract interface.
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Function abstract interface.
Provides declaration of Surface abstract interface.
Provides declaration of Volume abstract interface.
The G+Smo namespace, containing all definitions for the library.
Struct which represents an interface between two patches.
Definition gsBoundary.h:650
Struct which represents a certain component (interior, face, egde, corner).
Definition gsBoundary.h:445
Struct which represents a certain corner of a hyper-cube.
Definition gsBoundary.h:292