32 real_t t = (u - u0) / (u1 - u0);
34 return ((T)(1) - t) * v0 + t * v1;
54 mesh.addFace(w0, w01, w12);
55 mesh.addFace(w0, w12, w2);
61 mesh.addFace(vvv01, v1copy, vvv12);
69 mesh.addFace(w0, w01, w12);
70 mesh.addFace(w0, w12, w2);
76 mesh.addFace(vvv01, v1copy, vvv12);
79 gsWarn <<
"This situation of addThreeFlatTriangles should not happen, v1->x() = "
80 << v1->
x() <<
"." << std::endl;
89 if(v0->
x() < 0 && v2->
x() < 0)
94 addThreeFlatTrianglesOneOut(mesh, w0, w1, w2);
96 else if(v0->
x() > 1 && v2->
x() > 1)
101 addThreeFlatTrianglesOneOut(mesh, w0, w1, w2);
104 gsWarn <<
"This situation of addThreeFlatTrianglesTwoOut should not happen, v1->x()="
105 << v1->
x() <<
"." << std::endl;
117 real_t v0x = v0->
x();
118 real_t v1x = v1->
x();
119 real_t v2x = v2->
x();
121 while(v0x > 1 && v1x > 1 && v2x > 1)
128 while(v0x < 0 && v1x < 0 && v2x < 0)
135 if(v0x >= 0 && v0x <= 1 &&
136 v1x >= 0 && v1x <= 1 &&
137 v2x >= 0 && v2x <= 1)
140 mesh.addVertex(v0x, v0->
y()),
141 mesh.addVertex(v1x, v1->
y()),
142 mesh.addVertex(v2x, v2->
y()));
146 gsWarn <<
"This triangle does intersect the boundary.";
147 gsWarn <<
"v0: " << v0x <<
", " << v0->
y() << std::endl;
148 gsWarn <<
"v1: " << v1x <<
", " << v1->
y() << std::endl;
149 gsWarn <<
"v2: " << v2x <<
", " << v2->
y() << std::endl;
158 for(
size_t i=0; i<m_unfolded.getNumberOfTriangles(); i++)
163 for(
size_t j=1; j<=3; ++j)
165 vh[j-1] = m_unfolded.getVertex(m_unfolded.getGlobalVertexIndex(j, i));
166 real_t u = vh[j-1]->
x();
173 if( !out[0] && !out[1] && !out[2] )
174 addOneFlatTriangleNotIntersectingBoundary(result, vh[0], vh[1], vh[2]);
176 else if( out[0] && !out[1] && out[2] )
177 addThreeFlatTrianglesTwoOut(result, vh[0], vh[1], vh[2]);
178 else if( out[0] && out[1] && !out[2] )
179 addThreeFlatTrianglesTwoOut(result, vh[1], vh[2], vh[0]);
180 else if( !out[0] && out[1] && out[2] )
181 addThreeFlatTrianglesTwoOut(result, vh[2], vh[0], vh[1]);
183 else if( !out[0] && !out[1] && out[2] )
184 addThreeFlatTrianglesOneOut(result, vh[1], vh[2], vh[0]);
185 else if( !out[0] && out[1] && !out[2] )
186 addThreeFlatTrianglesOneOut(result, vh[0], vh[1], vh[2]);
187 else if( out[0] && !out[1] && !out[2] )
188 addThreeFlatTrianglesOneOut(result, vh[2], vh[0], vh[1]);
191 addOneFlatTriangleNotIntersectingBoundary(result, vh[0], vh[1], vh[2]);
200 real_t uMin, real_t uMax)
const
202 real_t uLength = uMax - uMin;
203 for(
index_t j=0; j<uv.cols(); j++)
215 void gsPeriodicParametrization<T>::initParameterPoints()
217 typedef typename gsParametrization<T>::Point2D Point2D;
219 size_t n = this->m_mesh.getNumberOfInnerVertices();
220 size_t N = this->m_mesh.getNumberOfVertices();
222 this->m_parameterPoints.reserve(N);
223 for (
size_t i = 1; i <= n; i++)
224 this->m_parameterPoints.push_back(Point2D(0, 0, i));
227 size_t v0size = m_paramsV0.cols();
228 size_t v1size = m_paramsV1.cols();
229 GISMO_ASSERT(m_indicesV0.size() == v0size,
"Different sizes of u0.");
230 GISMO_ASSERT(m_indicesV1.size() == v1size,
"Different sizes of u1.");
231 GISMO_ASSERT(v0size + v1size == this->m_mesh.getNumberOfBoundaryVertices(),
232 "Not prescribing all boundary points.");
234 size_t numPtsSoFar = n;
235 this->m_parameterPoints.resize(n + v0size + v1size);
238 for(
size_t i=0; i<v0size; i++)
239 this->m_parameterPoints[m_indicesV0[i]-1] = Point2D(m_paramsV0(0, i), 0, numPtsSoFar++);
242 for(
size_t i=0; i<v1size; i++)
243 this->m_parameterPoints[m_indicesV1[i]-1] = Point2D(m_paramsV1(0, i), 1, numPtsSoFar++);
real_t correspondingV(const VertexHandle &v0, const VertexHandle &v1, real_t u) const
Definition: gsPeriodicParametrization.hpp:23
#define index_t
Definition: gsConfig.h:32
gsMesh< T > createRestrictedFlatMesh() const
Trims the mesh to [0, 1]^2.
Definition: gsPeriodicParametrization.hpp:154
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
gsMesh & cleanMesh()
reorders the vertices of all faces of an .stl mesh, such that only 1 vertex is used instead of #(adja...
Definition: gsMesh.hpp:250
#define gsWarn
Definition: gsDebug.h:50
void addOneFlatTriangleNotIntersectingBoundary(gsMesh< T > &mesh, const VertexHandle &v0, const VertexHandle &v1, const VertexHandle &v2) const
Adds a flat triangle and shifts it inside the domain if necessary.
Definition: gsPeriodicParametrization.hpp:109
T x() const
Definition: gsVertex.h:108
T y() const
Definition: gsVertex.h:110
void addThreeFlatTrianglesOneOut(gsMesh< T > &mesh, const VertexHandle &v0, const VertexHandle &v1, const VertexHandle &v2) const
Definition: gsPeriodicParametrization.hpp:38
Abstract class with the functionality common to gsPeriodicStitch and gsPeriodicOverlap.
void addThreeFlatTrianglesTwoOut(gsMesh< T > &mesh, const VertexHandle &v0, const VertexHandle &v1, const VertexHandle &v2) const
Definition: gsPeriodicParametrization.hpp:84
gsVertex class that represents a 3D vertex for a gsMesh.
Definition: gsVertex.h:26