41 typedef memory::shared_ptr< gsMultiPatch >
Ptr;
43 typedef memory::unique_ptr< gsMultiPatch >
uPtr;
45 typedef std::vector<gsGeometry<T> *> PatchContainer;
46 typedef std::map<boundaryInterface,typename gsGeometry<T>::uPtr> InterfaceRep;
47 typedef std::map<patchSide,typename gsGeometry<T>::uPtr> BoundaryRep;
49 typedef typename PatchContainer::iterator iterator;
50 typedef typename PatchContainer::const_iterator const_iterator;
60 #if ! EIGEN_HAS_RVALUE_REFERENCES
72 : BaseA(
give(other) ), m_patches(
give(other.m_patches) )
91 const std::vector<patchSide>& boundary,
92 const std::vector<boundaryInterface>&
interfaces );
104 {
return m_patches.begin(); }
108 const_iterator
end()
const
109 {
return m_patches.end(); }
114 {
return m_patches.begin(); }
119 {
return m_patches.end(); }
135 for (
typename PatchContainer::const_iterator it =
136 m_patches.begin(); it != m_patches.end(); ++it )
137 sz += (*it)->coefsSize();
147 for (
typename PatchContainer::const_iterator it =
148 m_patches.begin(); it != m_patches.end(); ++it )
150 result.block(offset,0,(*it)->coefsSize(),(*it)->geoDim()) = (*it)->coefs();
151 offset += (*it)->coefsSize();
173 m_patches.swap( other.m_patches );
177 std::ostream&
print( std::ostream& os )
const;
180 std::string
detail()
const;
202 bool empty()
const {
return m_patches.empty(); }
208 size_t nPatches()
const {
return m_patches.size(); }
211 PatchContainer
const&
patches()
const {
return m_patches; }
213 const BaseA & topology()
const {
return *
this; }
223 std::vector<gsBasis<T> *>
basesCopy(
bool numeratorOnly =
false)
const;
228 GISMO_ASSERT( i < m_patches.size(),
"Invalid patch index "<<i<<
" requested from gsMultiPatch" );
229 return *m_patches[i];
233 void permute(
const std::vector<short_t> & perm);
289 for (
typename PatchContainer::const_iterator it = m_patches.begin();
290 it != m_patches.end(); ++it )
302 bool computeTopology( T tol = 1e-4,
bool cornersOnly =
false,
bool tjunctions =
false);
316 gsSurfMesh
toMesh()
const;
346 std::vector< boundaryInterface > bivec =
interfaces();
347 size_t kmax = 2*bivec.size();
349 bool sthChanged =
false;
354 for(
size_t i = 0; i < bivec.size(); i++ )
357 sthChanged = sthChanged || change;
361 while( sthChanged && k <= kmax );
390 const T accuracy = 1e-6)
const;
392 std::pair<index_t,gsVector<T> > closestPointTo(
const gsVector<T> & pt,
393 const T accuracy = 1e-6)
const;
398 const T accuracy = 1e-6,
399 const bool directed=
false);
403 const T accuracy = 1e-6,
404 const bool directed=
false);
406 void constructInterfaceRep();
409 void constructSides();
412 void constructInterfaceRep(
const std::string l);
416 const InterfaceRep & interfaceRep()
const {
return m_ifaces; }
417 const BoundaryRep & boundaryRep()
const {
return m_bdr; }
418 const BoundaryRep & sides()
const {
return m_sides; }
427 PatchContainer m_patches;
429 InterfaceRep m_ifaces;
430 BoundaryRep m_bdr, m_sides;
445 static bool matchVerticesOnSide (
446 const gsMatrix<T> &cc1,
const std::vector<boxCorner> &ci1,
index_t start,
447 const gsMatrix<T> &cc2,
const std::vector<boxCorner> &ci2,
448 const gsVector<bool> &matched,
449 gsVector<index_t> &dirMap, gsVector<bool> &dirO,
457 std::ostream& operator<<( std::ostream& os, const gsMultiPatch<T>& b )
459 return b.print( os );
462 #ifdef GISMO_WITH_PYBIND11
467 void pybind11_init_gsMultiPatch(pybind11::module &m);
469 #endif // GISMO_WITH_PYBIND11
475 #ifndef GISMO_BUILD_LIB
476 #include GISMO_HPP_HEADER(gsMultiPatch.hpp)
memory::shared_ptr< gsMultiPatch > Ptr
Shared pointer for gsMultiPatch.
Definition: gsMultiPatch.h:41
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry<T>::uPtr.
Definition: gsMultiPatch.hpp:210
void addBoundary(index_t p, boxSide s, std::string l="")
Set side s of box p to a boundary.
Definition: gsBoxTopology.h:208
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
gsMultiPatch & operator=(gsMultiPatch other)
Assignment operator (uses copy-and-swap idiom)
Definition: gsMultiPatch.h:63
void clear()
Clear (delete) all patches.
Definition: gsMultiPatch.h:319
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
Provides declaration of the BoxTopology class.
short_t m_dim
Dimension of the boxes held.
Definition: gsBoxTopology.h:377
short_t geoDim() const
Dimension of the geometry (must match for all patches).
Definition: gsMultiPatch.hpp:149
#define short_t
Definition: gsConfig.h:35
index_t nPieces() const
Number of pieces in the domain of definition.
Definition: gsMultiPatch.h:127
gsBasis< T > & basis(const size_t i) const
Return the basis of the i-th patch.
Definition: gsMultiPatch.hpp:171
Provides declaration of MultiBasis class.
bool repairInterface(const boundaryInterface &bi)
Checks if the interface is fully matching, and if not, repairs it.
Definition: gsMultiPatch.hpp:737
short_t parDim() const
Dimension of the parameter domain (must match for all patches).
Definition: gsMultiPatch.h:183
gsSurfMesh toMesh() const
Creates a surface mesh out of this multipatch.
Definition: gsMultiPatch.hpp:641
S give(S &x)
Definition: gsMemory.h:266
Provides declaration of Geometry abstract interface.
iterator begin()
Definition: gsMultiPatch.h:113
void addInterface(index_t p1, boxSide s1, index_t p2, boxSide s2, std::string l="")
Add an interface between side s1 of box p1 and side s2 of box p2.
Definition: gsBoxTopology.h:184
#define index_t
Definition: gsConfig.h:32
void fixOrientation()
Provides positive orientation for all patches.
Definition: gsMultiPatch.hpp:485
void uniformRefine(int numKnots=1, int mul=1)
Refine uniformly all patches by inserting numKnots in each knot-span with multipliplicity mul...
Definition: gsMultiPatch.hpp:270
void locatePoints(const gsMatrix< T > &points, gsVector< index_t > &pids, gsMatrix< T > &preim, const T accuracy=1e-6) const
For each point in points, locates the parametric coordinates of the point.
Definition: gsMultiPatch.hpp:779
Struct which represents a certain corner of a patch.
Definition: gsBoundary.h:392
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void boundingBox(gsMatrix< T > &result) const
Returns a bounding box for the multipatch domain. The output result is a matrix with two columns...
Definition: gsMultiPatch.hpp:321
gsMatrix< T > coefs() const
Returns the coefficient matrix of the multi-patch geometry.
Definition: gsMultiPatch.h:142
const gsGeometry< T > & operator[](size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:216
void uniformCoarsen(int numKnots=1)
Coarsen uniformly all patches by removing numKnots in each knot-span.
Definition: gsMultiPatch.hpp:311
gsMatrix< T > parameterRange(int i=0) const
Returns the range of parameter.
Definition: gsMultiPatch.hpp:164
index_t size() const
size
Definition: gsMultiPatch.h:129
gsMultiPatch< T > approximateLinearly(index_t nsamples) const
Computes linear approximation of the patches using nsamples per direction.
Definition: gsMultiPatch.hpp:722
Representation of an affine function.
Definition: gsAffineFunction.h:29
short_t targetDim() const
Dimension of the target space.
Definition: gsMultiPatch.h:192
memory::unique_ptr< gsMultiPatch > uPtr
Unique pointer for gsMultiPatch.
Definition: gsMultiPatch.h:43
void swap(gsMultiPatch &other)
Swap with another gsMultiPatch.
Definition: gsMultiPatch.h:170
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsMultiPatch.h:188
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
size_t nPatches() const
Number of patches.
Definition: gsMultiPatch.h:208
void permute(const std::vector< short_t > &perm)
Permutes the patches according to perm.
Definition: gsMultiPatch.hpp:203
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsMultiPatch.hpp:124
void repairInterfaces()
Checks if all patch-interfaces are fully matching, and if not, repairs them, i.e., makes them fully matching.
Definition: gsMultiPatch.h:344
const gsGeometry< T > & piece(const index_t i) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsMultiPatch.h:123
size_t findPatchIndex(gsGeometry< T > *g) const
Search for the given geometry and return its patch index.
Definition: gsMultiPatch.hpp:234
const_iterator end() const
Definition: gsMultiPatch.h:108
void addPatchBoundary(gsGeometry< T > *g, boxSide s)
Add side s of patch g to the outer boundary of the domain.
Definition: gsMultiPatch.h:257
void degreeReduce(int elevationSteps=1)
Reduce the degree of all patches by elevationSteps.
Definition: gsMultiPatch.hpp:301
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
std::vector< gsBasis< T > * > basesCopy(bool numeratorOnly=false) const
Makes a deep copy of all bases and puts them in a vector.
Definition: gsMultiPatch.hpp:178
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
void constructBoundaryRep()
Construct the boundary representation.
Definition: gsMultiPatch.hpp:944
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition: gsGeometry.h:100
gsAffineFunction< T > getMapForInterface(const boundaryInterface &bi, T scaling=0) const
construct the affine map that places bi.first() next to bi.second() and identifies the two matching s...
Definition: gsMultiPatch.hpp:697
bool isClosed()
Returns true if the multipatch object is a closed manifold (ie. it has no boundaries) ...
Definition: gsMultiPatch.h:199
size_t nBoundary() const
Number of boundaries.
Definition: gsBoxTopology.h:111
void swap(gsBoxTopology &other)
Swap with another gsBoxTopology.
Definition: gsBoxTopology.h:174
void closeGaps(T tol=1e-4)
Attempt to close gaps between the interfaces. Assumes that the topology is computed, ie. computeTopology() has been called.
Definition: gsMultiPatch.hpp:566
index_t coefsSize() const
Return the number of coefficients (control points)
Definition: gsMultiPatch.h:132
gsMatrix< T > pointOn(const patchCorner &pc)
Get coordinates of the patchCorner pc in the physical domain.
Definition: gsMultiPatch.hpp:253
void clearAll()
Clear all boxes, boundary and interface data.
Definition: gsBoxTopology.h:165
std::string detail() const
Prints the object as a string with extended details.
Definition: gsMultiPatch.hpp:137
iterator end()
Definition: gsMultiPatch.h:118
std::vector< T > HausdorffDistance(const gsMultiPatch< T > &other, const index_t nsamples=1000, const T accuracy=1e-6, const bool directed=false)
Construct the interface representation.
Definition: gsMultiPatch.hpp:895
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
const_iterator begin() const
Definition: gsMultiPatch.h:103
~gsMultiPatch()
Destructor.
Definition: gsMultiPatch.hpp:108
gsMultiPatch()
Default empty constructor.
Definition: gsMultiPatch.h:55
const ifContainer & interfaces() const
Return the vector of interfaces.
Definition: gsBoxTopology.h:252
Defines a topological arrangement of a collection of "boxes" (e.g., parameter domains that map to phy...
Definition: gsBoxTopology.h:38
short_t coDim() const
Co-dimension of the geometry (must match for all patches).
Definition: gsMultiPatch.hpp:156
PatchContainer const & patches() const
Returns a vector of patches // to do : replace by copies.
Definition: gsMultiPatch.h:211
GISMO_DEPRECATED void addInterface(gsGeometry< T > *g1, boxSide s1, gsGeometry< T > *g2, boxSide s2)
Add an interface joint between side s1 of geometry g1 side s2 of geometry g2.
Definition: gsMultiPatch.hpp:244
void degreeIncrease(short_t const elevationSteps=1, short_t const dir=-1)
Increase the degree of all patches by elevationSteps, preserves multiplicity.
Definition: gsMultiPatch.hpp:291
bool empty() const
Returns true if gsMultiPatch is empty.
Definition: gsMultiPatch.h:202
gsDofMapper getMapper(T tol) const
Used to get a mapper with unique vertices.
Definition: gsMultiPatch.hpp:593
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
bool computeTopology(T tol=1e-4, bool cornersOnly=false, bool tjunctions=false)
Attempt to compute interfaces and boundaries automatically.
Definition: gsMultiPatch.hpp:366
void degreeElevate(short_t const elevationSteps=1, short_t const dir=-1)
Elevate the degree of all patches by elevationSteps, preserves smoothness.
Definition: gsMultiPatch.hpp:281
gsMultiPatch< T > uniformSplit(index_t dir=-1) const
Splits each patch uniformly in each direction (if dir = -1) into two new patches, giving a total numb...
Definition: gsMultiPatch.hpp:340