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() <<
").");
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() )
425 this->
m_coefs.array().rowwise() *= v.array().transpose();
431 this->
m_coefs.rowwise() += v.transpose();
450 virtual void uniformRefine(
int numKnots = 1,
int mul=1,
int dir=-1);
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;
637 std::ostream &operator<<(std::ostream &os, const gsGeometry<T>& b)
638 {
return b.print(os); }
651 template <
short_t d,
typename T>
654 typedef gsGeometry<T> GeometryBase;
658 template <
typename T>
659 struct gsGeoTraits<1,T>
661 typedef gsCurve<T> GeometryBase;
665 template <
typename T>
666 struct gsGeoTraits<2,T>
668 typedef gsSurface<T> GeometryBase;
672 template <
typename T>
673 struct gsGeoTraits<3,T>
675 typedef gsVolume<T> GeometryBase;
679 template <
typename T>
680 struct gsGeoTraits<4,T>
682 typedef gsBulk<T> GeometryBase;
685 #ifdef GISMO_WITH_PYBIND11
690 void pybind11_init_gsGeometry(pybind11::module &m);
692 #endif // GISMO_WITH_PYBIND11
697 #ifndef GISMO_BUILD_LIB
698 #include GISMO_HPP_HEADER(gsGeometry.hpp)
virtual void compute(const gsMatrix< T > &in, gsFuncData< T > &out) const
Computes function data.
Definition: gsGeometry.hpp:539
void linearTransform(const gsMatrix< T > &mat)
Apply the given square matrix to every control point.
Definition: gsGeometry.h:388
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:606
virtual std::vector< gsGeometry< T > * > uniformSplit(index_t dir=-1) const
Definition: gsGeometry.hpp:280
gsGeometry()
Default constructor. Note: Derived constructors (except for the default) should assign m_basis to a v...
Definition: gsGeometry.h:111
void evaluateMesh(gsMesh< T > &mesh) const
Definition: gsGeometry.hpp:255
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition: gsGeometry.h:624
gsMatrix< T >::RowXpr coef(index_t i)
Returns the i-th coefficient of the geometry as a row expression.
Definition: gsGeometry.h:346
std::vector< T * > release(std::vector< unique_ptr< T > > &cont)
Takes a vector of smart pointers, releases them and returns the corresponding raw pointers...
Definition: gsMemory.h:228
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition: gsGeometry.hpp:524
Provides declaration of a 4D bulk.
short_t coefDim() const
Dimension n of the coefficients (control points)
Definition: gsGeometry.h:289
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
memory::shared_ptr< gsGeometry > Ptr
Shared pointer for gsGeometry.
Definition: gsGeometry.h:97
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition: gsGeometry.hpp:198
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition: gsGeometry.h:627
virtual gsMatrix< T > parameterCenter() const
Returns a "central" point inside inside the parameter domain.
Definition: gsFunction.h:261
#define short_t
Definition: gsConfig.h:35
void outerNormal_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Computes the outer normals at parametric points u.
Definition: gsGeometry.hpp:419
void embed3d()
Embeds coefficients in 3D.
Definition: gsGeometry.h:467
Provides structs and classes related to interfaces and boundaries.
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
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:436
Provides declaration of Surface abstract interface.
void scale(gsVector< T > const &v)
Apply Scaling coord-wise by a vector v.
Definition: gsGeometry.h:422
short_t degree(const short_t &i) const
Returns the degree wrt direction i.
Definition: gsGeometry.hpp:333
Provides declaration of Volume abstract interface.
size_t id() const
Returns the patch index for this patch.
Definition: gsGeometry.h:610
virtual index_t size() const
size
Definition: gsFunctionSet.h:578
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:449
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
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
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
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:462
index_t coefsSize() const
Return the number of coefficients (control points)
Definition: gsGeometry.h:371
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsMatrix< T >::ConstRowXpr coef(index_t i) const
Returns the i-th coefficient of the geometry as a row expression.
Definition: gsGeometry.h:349
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
virtual void insertKnot(T knot, index_t dir, index_t i=1)
Inserts knot knot at direction dir, i times.
Definition: gsGeometry.hpp:430
virtual void merge(gsGeometry *other)
Merge the given other geometry into this one.
Definition: gsGeometry.hpp:406
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
void scale(T s, int coord=-1)
Apply Scaling by factor s.
Definition: gsGeometry.h:413
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsGeometry.hpp:396
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
void rotate(T angle)
Apply 2D Rotation by angle radians.
Definition: gsGeometry.h:405
int orientation() const
Evaluates if the geometry orientation coincide with the ambient orientation. This is computed in the ...
Definition: gsGeometry.h:260
#define gsWarn
Definition: gsDebug.h:50
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
short_t coDim() const
Co-dimension of the geometric object.
Definition: gsGeometry.hpp:187
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition: gsGeometry.hpp:184
const gsMatrix< T > & coefs() const
Returns the coefficient matrix of the geometry.
Definition: gsGeometry.h:343
std::vector< gsGeometry * > boundary() const
Get boundary of this geometry as a vector of new gsGeometry instances.
Definition: gsGeometry.hpp:423
gsGeometrySlice is a class representing an iso parametric slice of a geometry object. It stores a pointer to the geometry object, which is only valid as long as this object is alive. Methods for printing to paraview are available in gsWriteToParaview.h
Definition: gsGeometrySlice.h:27
virtual void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine the geometry uniformly, inserting numKnots new knots into each knot span.
Definition: gsGeometry.hpp:306
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
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
void setId(const size_t i)
Sets the patch index for this patch.
Definition: gsGeometry.h:607
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition: gsGeometry.hpp:190
gsGeometry & operator=(const gsGeometry &o)
Definition: gsGeometry.hpp:202
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition: gsGeometry.h:100
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
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
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition: gsGeometry.hpp:193
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 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:475
void setCoefs(gsMatrix< T > cc)
Set the coefficient matrix of the geometry, taking ownership of the matrix.
Definition: gsGeometry.h:368
Provides declaration of Curve abstract interface.
gsGeometry::uPtr component(boxComponent const &bc) const
Get parametrization of box component bc as a new gsGeometry uPtr.
Definition: gsGeometry.hpp:240
gsGeometrySlice< T > getIsoParametricSlice(index_t dir_fixed, T par) const
Definition: gsGeometry.hpp:286
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
virtual void hessian_into(const gsMatrix< T > &u, gsMatrix< T > &result, index_t coord) const
Definition: gsGeometry.hpp:488
short_t targetDim() const
Dimension of the ambient physical space (overriding gsFunction::targetDim())
Definition: gsGeometry.h:286
Provides declaration of Function abstract interface.
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
size_t m_id
Definition: gsGeometry.h:631
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
T directedHausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6) const
Definition: gsGeometry.hpp:360
void translate(gsVector< T > const &v)
Apply translation by vector v.
Definition: gsGeometry.h:429
short_t geoDim() const
Dimension n of the absent physical space.
Definition: gsGeometry.h:292
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
virtual void uniformCoarsen(int numKnots=1)
Coarsen the geometry uniformly, removing numKnots new knots into each knot span.
Definition: gsGeometry.hpp:312
gsMatrix< T > & coefs()
Definition: gsGeometry.h:340
Struct which represents a certain component (interior, face, egde, corner).
Definition: gsBoundary.h:445