30 std::vector<int> added;
31 for (std::vector<int>::size_type i=0;i!=face.size();i++)
34 std::stack<FaceHandle> faceCollect;
36 for(
typename std::vector<FaceHandle >::iterator it(face.begin());it!=face.end();++it)
38 if (added[(**it).getId()]==0&&
39 *((**it).vertices[0])!=*((**it).vertices[1])&&
40 *((**it).vertices[2])!=*((**it).vertices[1])&&
41 *((**it).vertices[0])!=*((**it).vertices[2]))
44 faceCollect.push(*it);
45 while(!faceCollect.empty())
47 (*(faceCollect.top())).faceIdentity=numBigFaces;
48 added[(*(faceCollect.top())).getId()]=1;
49 tempFace=faceCollect.top();
52 for (
size_t i =0;i<(*tempFace).nFaces.size();i++)
54 if(added[tempFace->nFaces[i]->getId()]==0)
57 while((*(tempFace->nFaces[i])!=*(edge[tempFace->nEdges[k]->getId()].nFaces[0])&&
58 ((edge[tempFace->nEdges[k]->getId()].nFaces.size()==1)||
59 *(tempFace->nFaces[i])!=*(edge[tempFace->nEdges[k]->getId()].nFaces[1]))))
61 if (edge[tempFace->nEdges[k]->getId()].sharp==0)
62 faceCollect.push((*tempFace).nFaces[i]);
75 gsDebug<<
"Getting the features..."<<
"\n";
76 bWarnNonManifold=
false;
79 int fsize=face.size();
80 for(
int it=0;it<fsize;++it)
88 if ( Xless<T>(p0,p1) ) std::swap(p0,p1);
92 edge.push_sorted_unique( Edge(p0,p1) );
95 gsWarn<<
"face "<<it<<
" has 2 common vertices"<<
"\n"<<*p0<<*p1<<
"\n";
102 for(
typename std::vector<Edge>::iterator iter(edge.begin());iter!=edge.end();++iter)
108 for(
size_t it=0;it<face.size();++it)
110 if(*(face[it]->vertices[0])!=*(face[it]->vertices[1])&&
111 *(face[it]->vertices[2])!=*(face[it]->vertices[1])&&
112 *(face[it]->vertices[0])!=*(face[it]->vertices[2]))
118 if ( Xless<T>(p0,p1) ) std::swap(p0,p1);
122 Edge * eit = edge.find_ptr_or_fail( Edge(p0,p1) );
124 eit->nFaces.push_back(face[it]);
127 face[it]->nEdges.push_back(eit);
133 for(
typename std::vector<Edge>::iterator iter(edge.begin());iter!=edge.end();++iter)
135 std::vector<FaceHandle > vT;
136 for (
size_t i=0;i<iter->nFaces.size();i++)
138 vT.push_back(iter->nFaces[i]);
148 bWarnNonManifold=
true;
149 gsWarn<<
"non manifold edge"<<
"\n";
153 GISMO_ASSERT(vT.size()==2,
"Edge must belong to two triangles, got "<<vT.size() );
155 nv0 = nv0/(math::sqrt(nv0.squaredNorm()));
157 nv1 = nv1/(math::sqrt(nv1.squaredNorm()));
158 T cosPhi( nv0.dot(nv1) );
160 if(cosPhi > (T)(1.0)) cosPhi = (T)(1.0);
161 else if(cosPhi < (T)(-1.0)) cosPhi = (T)(-1.0);
163 const T PI_(3.14159);
164 T phiGrad(math::acos(cosPhi)/PI_*(T)(180));
165 if(phiGrad>=angleGrad)
170 (*face[(*vT[0]).getId()]).nFaces.push_back(face[(*vT[1]).getId()]);
171 (*face[(*vT[1]).getId()]).nFaces.push_back(face[(*vT[0]).getId()]);
176 gsDebug<<
"Attention: There were non-manifold edges. These are always features"<<
"\n";
180 gsDebug<<
"Attention: There were border edges. These are always features"<<
"\n";
187 if(useFeatures==1||useFeatures==2)
191 for(
size_t i=0;i<edge.size();i++)
196 for(
size_t i=0;i<featEdges.size();i++)
199 for(
size_t j=0;j<edge.size();j++)
201 if(approxEqual(featEdges[i],edge[j])==1)
208 gsWarn<<
"could not find the feature number"<<i<<
",review the input data"<<
"\n";
212 for(
typename std::vector<Edge>::iterator iter(edge.begin());iter!=edge.end();++iter)
217 gsDebug<<
"Feature lines: "<<i1<<
"\n";
225 for (
typename std::vector<Edge >::iterator it(edge.begin());it!=edge.end();++it)
227 if ((*it).nFaces[0]->faceIdentity==(*it).nFaces[1]->faceIdentity)
228 (*it).numPatches.push_back((*it).nFaces[0]->faceIdentity);
231 (*it).numPatches.push_back((*it).nFaces[0]->faceIdentity);
232 (*it).numPatches.push_back((*it).nFaces[1]->faceIdentity);
242 std::vector<T > areas;
243 for (
int i=0;i<numBigFaces;i++)
245 for (
size_t i=0;i<face.size();i++)
247 if(face[i]->faceIdentity>0&&face[i]->faceIdentity<=numBigFaces)
248 areas[face[i]->faceIdentity-1]+=calcArea(face[i]);
251 for(
size_t i=0;i<areas.size();i++)
256 T averageArea=totalArea/
static_cast<T
>(areas.size());
257 for(
size_t j=0;j<edge.size();j++)
259 if(edge[j].numPatches.size()==1)
262 if(areas[edge[j].numPatches[0]-1]>averageArea*patchAreaWeight)
266 nv0 = nv0/(math::sqrt(nv0.squaredNorm()));
268 nv1 = nv1/(math::sqrt(nv1.squaredNorm()));
269 T cosPhi( nv0.dot(nv1) );
271 if(cosPhi > (T)(1.0)) cosPhi = (T)(1.0);
272 else if(cosPhi < (T)(-1.0)) cosPhi = (T)(-1.0);
274 const T PI_(3.14159);
275 T phiGrad(math::acos(cosPhi)/PI_*(T)(180));
276 if(phiGrad>=innerAngle)
284 for(
typename std::vector<Edge>::iterator iter(edge.begin());iter!=edge.end();++iter)
289 gsDebug<<
"Feature lines after dividing patches: "<<i2<<
"\n";
290 if(mergeSmallPatches!=0)
292 for(
size_t j=0;j<edge.size();j++)
294 if(edge[j].numPatches.size()==2)
296 if(areas[edge[j].numPatches[0]-1]<averageArea*mergeSmallPatches&&areas[edge[j].numPatches[1]-1]<averageArea*mergeSmallPatches)
302 for(
typename std::vector<Edge>::iterator iter(edge.begin());iter!=edge.end();++iter)
307 gsDebug<<
"Feature lines after merging patches: "<<i3<<
"\n";
312 std::vector< std::vector<std::vector<VertexHandle> > > & innerBdrys, std::vector< std::vector<Vertex> > & innerBdrysMassP,
313 std::vector<std::vector<bool> > & oPointsConvexFlag)
315 gsDebug<<
"Getting the faces..."<<
"\n";
316 this->calcPatchNumbers();
319 for (
typename std::vector<Edge >::iterator it(edge.begin());it!=edge.end();++it)
321 if ((*it).sharp==1&&(*it).nFaces[0]->faceIdentity==(*it).nFaces[1]->faceIdentity)
325 for (
size_t i=0;i<edge.size();i++)
327 edge[i].source->nVertices.push_back(edge[i].target);
328 edge[i].target->nVertices.push_back(edge[i].source);
329 if (edge[i].sharp==1)
331 edge[i].source->sharp=1;
332 edge[i].target->sharp=1;
336 if(edge[i].source->sharp!=1)
337 edge[i].source->sharp=0;
338 if(edge[i].target->sharp!=1)
339 edge[i].target->sharp=0;
343 std::multimap<int,EdgeHandle> mmIE;
344 for (
typename std::vector<Edge >::iterator it(edge.begin());it!=edge.end();++it)
346 if ((*it).sharp==1&&(*it).nFaces[0]->faceIdentity!=(*it).nFaces[1]->faceIdentity)
348 if ((*it).nFaces.size()!=2)
349 gsDebug<<
"edge "<<*it<<
" has "<<(*it).nFaces.size()<<
" neighboring faces"<<
"\n";
350 mmIE.insert(std::make_pair((*it).nFaces[0]->faceIdentity,&(*it)));
351 mmIE.insert(std::make_pair((*it).nFaces[1]->faceIdentity,&(*it)));
354 for (std::vector<int>::size_type i=0;i!=vertex.size();i++)
355 vertex[i]->numEdges=0;
356 for(
typename std::vector<Edge >::iterator it(edge.begin());it!=edge.end();++it)
358 if((*it).nFaces.size()==2&&((*it).nFaces[0]->faceIdentity!=(*it).nFaces[1]->faceIdentity))
360 vertex[(*it).source->getId()]->numEdges++;
361 vertex[(*it).target->getId()]->numEdges++;
365 gsDebug<<
"Getting interior points..."<<
"\n";
367 std::vector< std::set< VertexHandle> > iPointsSet;
368 std::set< VertexHandle > vertexSet;
372 for (
int i=0;i<numBigFaces;i++)
374 iPointsSet.push_back(vertexSet);
376 for(
typename std::vector<FaceHandle >::iterator it(face.begin());it!=face.end();++it)
378 if ( *((**it).vertices[0])!=*((**it).vertices[1])&&
379 *((**it).vertices[2])!=*((**it).vertices[1])&&
380 *((**it).vertices[0])!=*((**it).vertices[2]))
382 for (
int i=0;i<3;i++)
384 iPointsSet[(**it).faceIdentity-1].insert((**it).vertices[i]);
391 for(
int i=0;i<numBigFaces;i++)
393 std::vector< VertexHandle > tempVec;
394 for (
typename std::set<VertexHandle> ::iterator it(iPointsSet[i].begin());it!=iPointsSet[i].end();++it)
397 tempVec.push_back(*it);
399 iPoints.push_back(tempVec);
403 gsDebug<<
"Getting boundary points..."<<
"\n";
408 for(
int i=1;i<numBigFaces+1;i++)
411 bool allEdgesCovered=
false;
412 std::vector<bool> edgeAdded;
413 for(
size_t j=0;j<mmIE.count(i);j++)
414 edgeAdded.push_back(
false);
417 std::vector< std::vector<VertexHandle> > innerBdryHelpVec;
418 std::vector<Vertex> innerBdryMassPHelpVec;
419 while (allEdgesCovered==
false)
421 std::vector< bool> isConvex;
422 std::vector< T> angle;
423 std::vector< VertexHandle> vertexVec;
426 EdgeHandle firstEdge=mmIE.find(i)->second;
428 while (edgeAdded[EdgeCount]==
true)
430 edgeAdded[EdgeCount]=
true;
432 for(
typename std::multimap<int,EdgeHandle>::iterator edgeIter = mmIE.find(i);helpCount<=EdgeCount;edgeIter++)
435 firstEdge=(*edgeIter).second;
439 FaceHandle firstFace=NULL;
440 if (firstEdge->nFaces[0]->faceIdentity==i)
441 firstFace=firstEdge->nFaces[0];
442 else if(firstEdge->nFaces[1]->faceIdentity==i)
443 firstFace=firstEdge->nFaces[1];
445 gsWarn<<
"edge has wrong neighboring faces"<<
"\n";
446 for (
int j=0;j<3;j++)
448 if (*(firstFace->vertices[j])==*(firstEdge->source))
450 if (*(firstFace->vertices[j])==*(firstEdge->target))
453 if ((sourcePos-targetPos)==1||sourcePos-targetPos==-2)
455 vertexVec.push_back((firstEdge->target));
456 vertexVec.push_back((firstEdge->source));
458 else if((sourcePos-targetPos)==2||sourcePos-targetPos==-1)
460 vertexVec.push_back((firstEdge->source));
461 vertexVec.push_back((firstEdge->target));
464 gsWarn<<
"Edge not found"<<
"\n";
466 EdgeHandle currentEdge=firstEdge;
468 while (k==0||(vertexVec[0])!=(vertexVec[vertexVec.size()-1]))
474 for (
typename std::multimap<int,EdgeHandle>::iterator it(mmIE.find(i));(*it).first==i;++it)
476 if (*(*it).second!=*currentEdge&&*(*it).second->target==*vertexVec[vertexVec.size()-1]&&edgeAdded[l]==
false)
478 vertexVec.push_back(((*it).second->source));
480 angle.push_back(calcAngle(currentEdge,(*it).second,i));
481 currentEdge=(*it).second;
486 else if (*(*it).second!=*currentEdge&&*(*it).second->source==*vertexVec[vertexVec.size()-1]&&edgeAdded[l]==
false)
488 vertexVec.push_back(((*it).second->target));
490 angle.push_back(calcAngle(currentEdge,(*it).second,i));
491 currentEdge=(*it).second;
500 if (*(vertexVec[0])==*(vertexVec[vertexVec.size()-1]))
502 typename std::vector<T>::iterator it=angle.begin();
503 angle.insert(it,calcAngle(currentEdge, firstEdge,i));
505 GISMO_ASSERT(edgeNotFound==0,
"edge not found, could not create a closed boundary of sharp edges to identify a face");
508 for (
size_t j=0;j<angle.size();j++)
510 isConvex.push_back(angle[j] < (T)(EIGEN_PI));
513 vertexVec.pop_back();
516 bdryLength=calcBdryLength(vertexVec);
519 oPoints.push_back(vertexVec);
520 maxLength=bdryLength;
521 oPointsConvexFlag.push_back(isConvex);
523 else if (bdryLength>maxLength)
525 innerBdryHelpVec.push_back(oPoints.back());
526 innerBdryMassPHelpVec.push_back(getMassP(oPoints.back()));
528 oPoints.push_back(vertexVec);
529 maxLength=bdryLength;
530 oPointsConvexFlag.pop_back();
531 oPointsConvexFlag.push_back(isConvex);
533 else if(bdryLength<=maxLength)
535 innerBdryHelpVec.push_back(vertexVec);
536 innerBdryMassPHelpVec.push_back(getMassP(vertexVec));
540 allEdgesCovered=
true;
541 for (
size_t j=0;j<mmIE.count(i);j++)
543 if (edgeAdded[j]==
false)
544 allEdgesCovered=
false;
547 innerBdrys.push_back(innerBdryHelpVec);
548 innerBdrysMassP.push_back(innerBdryMassPHelpVec);
551 for(
size_t i=0;i<innerBdrys.size();i++)
553 for(
size_t j=0;j<innerBdrys[i].size();j++)
555 for(
size_t k=0;k<innerBdrys[i][j].size();k++)
557 innerBdrys[i][j][k]->nVertices.push_back(&innerBdrysMassP[i][j]);
558 innerBdrysMassP[i][j].nVertices.push_back(innerBdrys[i][j][k]);
567 std::vector<std::vector<VertexHandle> > & oPoints,
568 std::vector< std::vector<std::vector<VertexHandle> > > & innerBdrys,
569 std::vector< std::vector<Vertex> > & innerBdrysMassP,
570 std::vector<std::vector<bool> > & oPointsConvexFlag,
574 int kvOuterPoints,
int kvAdditionalInnerPoints,
575 bool plot,
int meshPoints,
576 bool moreInner, T wE, T wI,
int closeBoundary,
bool noSmooth)
579 GISMO_ASSERT( (static_cast<int>(iPoints.size() ) == numBigFaces) &&
580 (
static_cast<int>(oPoints.size() ) == numBigFaces) &&
581 (
static_cast<int>(innerBdrys.size() ) == numBigFaces) &&
582 (
static_cast<int>(innerBdrysMassP.size() ) == numBigFaces) &&
583 (
static_cast<int>(oPointsConvexFlag.size() ) == numBigFaces),
584 "expecting the same number of big faces everywhere");
586 gsDebug<<
"mapping to plane..."<<
"\n";
587 std::vector<std::vector<Vertex> > iPoints2D;
588 std::vector<std::vector<Vertex> > oPoints2D;
589 std::vector< std::vector<std::vector<Vertex> > > innerBdrys2D;
593 for (
size_t i=0;i<oPoints.size();i++)
596 std::vector<gsVector3d<T>*> vertices;
597 std::vector<VertexHandle> vertexVec=oPoints[i];
599 std::vector<bool> isConvex=oPointsConvexFlag[i];
600 for (
size_t j=0;j<oPoints[i].size();j++)
602 vertices.push_back(&(*vertexVec[j]));
611 int nm = normalMult(faceNormal, face, (
int)(i + 1));
622 else if(nm == -1) loop.
flip1();
626 std::vector<gsVertex<T> > vector2D;
627 for(
size_t j=0;j<loop.curves().size();j++)
629 vector2D.push_back(
gsVertex<T>(loop.curve(j).coefs()(0,0),loop.curve(j).coefs()(0,1),0));
632 oPoints2D.push_back(vector2D);
634 gsDebug<<
"generated loops"<<
'\n';
636 std::vector<T > areas;
637 for (
int i=0;i<numBigFaces;i++)
639 for (
size_t i=0;i<face.size();i++)
641 if(face[i]->faceIdentity>0&&face[i]->faceIdentity<=numBigFaces)
642 areas[face[i]->faceIdentity-1]+=calcArea(face[i]);
646 for (
size_t i=0;i<areas.size();i++)
650 std::vector< std::vector< EdgeHandle > > faceEdges;
651 for (
int i=0;i<numBigFaces;i++)
653 std::vector< EdgeHandle > helpVec;
654 faceEdges.push_back(helpVec);
656 for(
size_t i=0;i<edge.size();i++)
659 if(edge[i].nFaces.size()==2 &&
660 ((edge[i].nFaces[0]->faceIdentity)==(edge[i].nFaces[1]->faceIdentity)))
662 faceEdges[(edge[i].nFaces[0]->faceIdentity)-1].push_back(&edge[i]);
666 faceEdges[(edge[i].nFaces[0]->faceIdentity)-1].push_back(&edge[i]);
667 if(edge[i].nFaces.size()==2)
669 faceEdges[(edge[i].nFaces[1]->faceIdentity)-1].push_back(&edge[i]);
673 std::vector<bool> isCylinder;
674 std::vector<T> improveCylinderParametrization;
675 for(
size_t i=0;i<oPoints.size();i++)
677 if(innerBdrys[i].size()!=1)
679 isCylinder.push_back(0);
680 improveCylinderParametrization.push_back(0);
685 for(
size_t j=0;j<oPoints[i].size()-1;j++)
687 for(
size_t k=j+1;k<oPoints[i].size();k++)
689 T tempDiameter=((oPoints[i][j]->x()-oPoints[i][k]->x())*(oPoints[i][j]->x()-oPoints[i][k]->x()))+
690 ((oPoints[i][j]->y()-oPoints[i][k]->y())*(oPoints[i][j]->y()-oPoints[i][k]->y()))+
691 ((oPoints[i][j]->z()-oPoints[i][k]->z())*(oPoints[i][j]->z()-oPoints[i][k]->z()));
692 if(tempDiameter>diameterOut)
693 diameterOut=tempDiameter;
697 for(
size_t j=0;j<innerBdrys[i][0].size()-1;j++)
699 for(
size_t k=j+1;k<innerBdrys[i][0].size();k++)
701 T tempDiameter=((innerBdrys[i][0][j]->x()-innerBdrys[i][0][k]->x())*(innerBdrys[i][0][j]->x()-innerBdrys[i][0][k]->x()))+
702 ((innerBdrys[i][0][j]->y()-innerBdrys[i][0][k]->y())*(innerBdrys[i][0][j]->y()-innerBdrys[i][0][k]->y()))+
703 ((innerBdrys[i][0][j]->z()-innerBdrys[i][0][k]->z())*(innerBdrys[i][0][j]->z()-innerBdrys[i][0][k]->z()));
704 if(tempDiameter>diameterIn)
705 diameterIn=tempDiameter;
709 for(
size_t j=0;j<oPoints[i].size()-1;j++)
711 for(
size_t k=0;k<innerBdrys[i][0].size();k++)
713 T tempDist=((oPoints[i][j]->x()-innerBdrys[i][0][k]->x())*(oPoints[i][j]->x()-innerBdrys[i][0][k]->x()))+
714 ((oPoints[i][j]->y()-innerBdrys[i][0][k]->y())*(oPoints[i][j]->y()-innerBdrys[i][0][k]->y()))+
715 ((oPoints[i][j]->z()-innerBdrys[i][0][k]->z())*(oPoints[i][j]->z()-innerBdrys[i][0][k]->z()));
716 if(tempDist<distance||distance==0)
720 if(diameterOut/(T)(4)<distance&&diameterIn/(T)(4)<distance)
722 isCylinder.push_back(1);
723 improveCylinderParametrization.push_back(0.1);
728 isCylinder.push_back(0);
729 improveCylinderParametrization.push_back(0);
738 gsDebug<<
"allocating surfaces"<<
'\n';
741 std::vector<gsTrimSurface<T> *> tSurfVec;
742 for (
size_t i=0;i<iPoints.size();i++)
744 size_t iPsize=iPoints[i].size();
748 size_t n = iPsize+innerBdrysMassP[i].size();
749 size_t innerBdrysSize=0;
750 for (
size_t m=0;m<innerBdrys[i].size();m++)
752 innerBdrysSize+=innerBdrys[i][m].size();
757 std::set<VertexHandle> vertexFaceSet;
758 std::set<VertexHandle> vertexFaceSetBdry;
759 std::set<VertexHandle> vertexFaceSetInner;
762 for (
size_t j=0;j<iPoints[i].size();j++)
764 vertexFaceSet.insert(iPoints[i][j]);
765 vertexFaceSetInner.insert(iPoints[i][j]);
767 for (
size_t j=0;j<innerBdrys[i].size();j++)
769 vertexFaceSet.insert(&innerBdrysMassP[i][j]);
770 vertexFaceSetInner.insert(&innerBdrysMassP[i][j]);
771 for (
size_t k=0;k<innerBdrys[i][j].size();k++)
773 vertexFaceSet.insert(innerBdrys[i][j][k]);
774 vertexFaceSetInner.insert(innerBdrys[i][j][k]);
777 for (
size_t j=0;j<oPoints[i].size();j++)
779 vertexFaceSet.insert(oPoints[i][j]);
780 vertexFaceSetBdry.insert(oPoints[i][j]);
793 gsEigen::SparseMatrix<T, ColMajor> A(n,n);
795 typename gsSparseSolver<T>::LU solver;
803 for (
size_t j=0;j<n;j++)
808 coefficients.add(j,j,1.0);
811 std::vector<T> rhsCoefs;
812 std::vector<VertexHandle> rhs;
813 std::vector<T> matCoefs;
814 std::vector<VertexHandle> mat;
821 for (
size_t k=0;k<iPoints[i][j]->nVertices.size();k++)
824 if(vertexFaceSetBdry.find(iPoints[i][j]->nVertices[k])!=vertexFaceSetBdry.end())
826 weight=calcWeight(iPoints[i][j],iPoints[i][j]->nVertices[k],vertexFaceSet);
827 rhsCoefs.push_back(weight);
828 rhs.push_back(iPoints[i][j]->nVertices[k]);
833 weight=calcWeight(iPoints[i][j],iPoints[i][j]->nVertices[k],vertexFaceSet);
834 matCoefs.push_back(weight);
835 mat.push_back(iPoints[i][j]->nVertices[k]);
840 else if(j<iPsize+innerBdrysMassP[i].size())
842 for (
size_t k=0;k<innerBdrys[i][j-iPsize].size();k++)
845 weight=calcWeight(&innerBdrysMassP[i][j-iPsize],innerBdrys[i][j-iPsize][k],vertexFaceSet);
846 matCoefs.push_back(weight);
847 mat.push_back(innerBdrys[i][j-iPsize][k]);
858 size_t innerIndex=j-iPsize-innerBdrysMassP[i].size();
862 while (innerIndex>=c)
864 c+=innerBdrys[i][k].size();
868 c-=innerBdrys[i][k].size();
871 for (
size_t i2=0;i2<innerBdrys[i][k][l]->nVertices.size();i2++)
874 if(vertexFaceSetBdry.find(innerBdrys[i][k][l]->nVertices[i2])!=vertexFaceSetBdry.end())
876 weight=calcWeight(innerBdrys[i][k][l],(innerBdrys[i][k][l]->nVertices[i2]),vertexFaceSet);
877 rhsCoefs.push_back(weight);
878 rhs.push_back(innerBdrys[i][k][l]->nVertices[i2]);
882 else if(vertexFaceSetInner.find(innerBdrys[i][k][l]->nVertices[i2])!=vertexFaceSetInner.end())
884 weight=calcWeight(innerBdrys[i][k][l],(innerBdrys[i][k][l]->nVertices[i2]),vertexFaceSet);
886 if(isCylinder[i]==1&&*(innerBdrys[i][k][l]->nVertices[i2])==innerBdrysMassP[i][0])
888 weight*=improveCylinderParametrization[i];
890 matCoefs.push_back(weight);
891 mat.push_back(innerBdrys[i][k][l]->nVertices[i2]);
897 GISMO_ASSERT(normCoef > 0,
"normCoef should be positive");
899 for (
size_t k=0;k<rhsCoefs.size();k++)
901 rhsCoefs[k]=rhsCoefs[k]/normCoef;
904 while (*oPoints[i][l]!=*rhs[k])
909 b1(j)+=(oPoints2D[i][l].operator[](0))*rhsCoefs[k];
910 b2(j)+=(oPoints2D[i][l].operator[](1))*rhsCoefs[k];
914 for (
size_t k=0;k<matCoefs.size();k++)
916 matCoefs[k]=matCoefs[k]/normCoef;
920 for (
size_t l=0;l<iPsize;l++)
922 if (*mat[k]==*iPoints[i][l])
923 coefficients.add(j,l,-matCoefs[k]);
926 for (
size_t l=0;l<innerBdrysMassP[i].size();l++)
928 if(*mat[k]==innerBdrysMassP[i][l])
929 coefficients.add(j,l+iPsize,-matCoefs[k]);
933 for (
size_t i2=0;i2<innerBdrys[i].size();i2++)
935 for(
size_t i3=0;i3<innerBdrys[i][i2].size();i3++)
937 if(*mat[k]==*innerBdrys[i][i2][i3])
938 coefficients.add(j,l+iPsize+innerBdrysMassP[i].size(),-matCoefs[k]);
945 if(check < (T)(1-0.001)||check > (T)(1+0.001))
946 gsWarn<<
"something might have gone wrong with norming: "<<check<<
"!=1\n";
949 A.setFromTriplets(coefficients.begin(), coefficients.end());
955 solver.analyzePattern(A);
959 u = solver.solve(b1);
960 v = solver.solve(b2);
966 std::vector<gsVertex<T> > helpvec;
967 for (
size_t j=0;j<iPsize;j++)
971 iPoints2D.push_back(helpvec);
972 std::vector<std::vector<gsVertex<T> > > holeVecFace;
973 int index=innerBdrys[i].size();
974 for(
size_t j=0;j<innerBdrys[i].size();j++)
976 std::vector<gsVertex<T> > holeVec;
977 for(
size_t k=0;k<innerBdrys[i][j].size();k++)
979 holeVec.push_back(
gsVertex<T>(u(iPsize+index),v(iPsize+index),0));
982 holeVecFace.push_back(holeVec);
984 innerBdrys2D.push_back(holeVecFace);
988 for (
size_t j=0;j<oPoints[i].size();j++)
990 if(oPoints[i][j]->numEdges>2)
995 for (
size_t j=0;j<innerBdrys[i].size();j++)
997 for(
size_t k=0;k<innerBdrys[i][j].size();k++)
999 if(innerBdrys[i][j][k]->numEdges>2)
1007 int nEdgePts=(oPoints[i].size()+innerBdrysSize)*(closeBoundary+1)-nCorners;
1013 for (
size_t j=0;j<oPoints[i].size();j++)
1016 if(oPoints[i][j]->numEdges>2)
1018 Corners2d(0,corNum)=oPoints2D[i][j].x();
1019 Corners2d(1,corNum)=oPoints2D[i][j].y();
1020 Corners3d(0,corNum)=oPoints[i][j]->x();
1021 Corners3d(1,corNum)=oPoints[i][j]->y();
1022 Corners3d(2,corNum)=oPoints[i][j]->z();
1027 EdgePts2d(0,edgNum)=oPoints2D[i][j].x();
1028 EdgePts2d(1,edgNum)=oPoints2D[i][j].y();
1029 EdgePts3d(0,edgNum)=oPoints[i][j]->x();
1030 EdgePts3d(1,edgNum)=oPoints[i][j]->y();
1031 EdgePts3d(2,edgNum)=oPoints[i][j]->z();
1035 for(
size_t j=0;j<oPoints[i].size()-1;j++)
1037 for(
int k=0;k<closeBoundary;k++)
1039 EdgePts2d(0,edgNum)=oPoints2D[i][j].x()*(T)(k+1)/(T)(closeBoundary+1)+oPoints2D[i][j+1].x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1040 EdgePts2d(1,edgNum)=oPoints2D[i][j].y()*(T)(k+1)/(T)(closeBoundary+1)+oPoints2D[i][j+1].y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1041 EdgePts3d(0,edgNum)=oPoints[i][j]->x()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i][j+1]->x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1042 EdgePts3d(1,edgNum)=oPoints[i][j]->y()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i][j+1]->y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1043 EdgePts3d(2,edgNum)=oPoints[i][j]->z()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i][j+1]->z()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1047 for(
int k=0;k<closeBoundary;k++)
1049 EdgePts2d(0,edgNum)=oPoints2D[i][0].x()*(T)(k+1)/(T)(closeBoundary+1)+oPoints2D[i].back().x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1050 EdgePts2d(1,edgNum)=oPoints2D[i][0].y()*(T)(k+1)/(T)(closeBoundary+1)+oPoints2D[i].back().y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1051 EdgePts3d(0,edgNum)=oPoints[i][0]->x()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i].back()->x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1052 EdgePts3d(1,edgNum)=oPoints[i][0]->y()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i].back()->y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1053 EdgePts3d(2,edgNum)=oPoints[i][0]->z()*(T)(k+1)/(T)(closeBoundary+1)+oPoints[i].back()->z()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1057 int nInteriorPts=iPsize;
1059 std::multiset<T> edgeLengths;
1060 std::vector<int> nAddIntPointsPerEdge;
1061 int nAddIntPoints=0;
1065 for(
size_t j=0;j<faceEdges[i].size();j++)
1067 edgeLengths.insert(calcDist(faceEdges[i][j]->source,faceEdges[i][j]->target));
1070 typename std::multiset<T >::iterator it=edgeLengths.begin();
1071 for(
size_t j=0;j<=edgeLengths.size()/10;j++)
1076 for(
size_t j=0;j<faceEdges[i].size();j++)
1078 T l=calcDist(faceEdges[i][j]->source,faceEdges[i][j]->target);
1079 int add= math::max( cast<T,int>(l/h)-1, 0 );
1080 nAddIntPointsPerEdge.push_back(add);
1084 gsMatrix<T> interiorPts2d(2,nInteriorPts+nAddIntPoints);
1085 gsMatrix<T> interiorPts3d(3,nInteriorPts+nAddIntPoints);
1086 for (
size_t j=0;j<iPoints2D[i].size();j++)
1089 interiorPts2d(0,j)=iPoints2D[i][j].x();
1090 interiorPts2d(1,j)=iPoints2D[i][j].y();
1091 interiorPts3d(0,j)=iPoints[i][j]->x();
1092 interiorPts3d(1,j)=iPoints[i][j]->y();
1093 interiorPts3d(2,j)=iPoints[i][j]->z();
1099 for(
size_t j=0;j<faceEdges[i].size();j++)
1101 if(nAddIntPointsPerEdge[j]>0)
1109 for(
size_t k=0;k<oPoints[i].size();k++)
1111 if(oPoints[i][k]==faceEdges[i][j]->source)
1114 v1_2d=&oPoints2D[i][k];
1116 else if(oPoints[i][k]==faceEdges[i][j]->target)
1119 v2_2d=&oPoints2D[i][k];
1122 for(
size_t k=0;k<iPoints[i].size();k++)
1124 if(iPoints[i][k]==faceEdges[i][j]->source)
1127 v1_2d=&iPoints2D[i][k];
1129 else if(iPoints[i][k]==faceEdges[i][j]->target)
1132 v2_2d=&iPoints2D[i][k];
1135 for(
size_t k=0;k<innerBdrys[i].size();k++)
1137 for(
size_t l=0;l<innerBdrys[i][k].size();l++)
1139 if(innerBdrys[i][k][l]==faceEdges[i][j]->source)
1141 v1=innerBdrys[i][k][l];
1142 v1_2d=&innerBdrys2D[i][k][l];
1144 else if(innerBdrys[i][k][l]==faceEdges[i][j]->target)
1146 v2=innerBdrys[i][k][l];
1147 v2_2d=&innerBdrys2D[i][k][l];
1151 GISMO_ASSERT(v1!=NULL&&v2!=NULL,
"could not find source or target of the edge in the face");
1152 for (
int k=0;k<nAddIntPointsPerEdge[j];k++)
1154 interiorPts2d(0,intNum)=v1_2d->
x()*(T)(k+1)/(T)(nAddIntPointsPerEdge[j]+1)+
1155 v2_2d->
x()*(T)(nAddIntPointsPerEdge[j]-k)/(T)(nAddIntPointsPerEdge[j]+1);
1156 interiorPts2d(1,intNum)=v1_2d->
y()*(T)(k+1)/(T)(nAddIntPointsPerEdge[j]+1)+
1157 v2_2d->
y()*(T)(nAddIntPointsPerEdge[j]-k)/(T)(nAddIntPointsPerEdge[j]+1);
1158 interiorPts3d(0,intNum)=v1->
x()*(T)(k+1)/(T)(nAddIntPointsPerEdge[j]+1)+
1159 v2->
x()*(T)(nAddIntPointsPerEdge[j]-k)/(T)(nAddIntPointsPerEdge[j]+1);
1160 interiorPts3d(1,intNum)=v1->
y()*(T)(k+1)/(T)(nAddIntPointsPerEdge[j]+1)+
1161 v2->
y()*(T)(nAddIntPointsPerEdge[j]-k)/(T)(nAddIntPointsPerEdge[j]+1);
1162 interiorPts3d(2,intNum)=v1->
z()*(T)(k+1)/(T)(nAddIntPointsPerEdge[j]+1)+
1163 v2->
z()*(T)(nAddIntPointsPerEdge[j]-k)/(T)(nAddIntPointsPerEdge[j]+1);
1170 for(
size_t j=0;j<innerBdrys[i].size();j++)
1172 for(
size_t k=0;k<innerBdrys[i][j].size();k++)
1174 if(innerBdrys[i][j][k]->numEdges>2)
1176 Corners2d(0,corNum)=innerBdrys2D[i][j][k].x();
1177 Corners2d(1,corNum)=innerBdrys2D[i][j][k].y();
1178 Corners3d(0,corNum)=innerBdrys[i][j][k]->x();
1179 Corners3d(1,corNum)=innerBdrys[i][j][k]->y();
1180 Corners3d(2,corNum)=innerBdrys[i][j][k]->z();
1185 EdgePts2d(0,edgNum)=innerBdrys2D[i][j][k].x();
1186 EdgePts2d(1,edgNum)=innerBdrys2D[i][j][k].y();
1187 EdgePts3d(0,edgNum)=innerBdrys[i][j][k]->x();
1188 EdgePts3d(1,edgNum)=innerBdrys[i][j][k]->y();
1189 EdgePts3d(2,edgNum)=innerBdrys[i][j][k]->z();
1194 for(
size_t it=0;it<innerBdrys[i].size();it++)
1196 for(
size_t j=0;j<innerBdrys[i][it].size()-1;j++)
1198 for(
int k=0;k<closeBoundary;k++)
1200 EdgePts2d(0,edgNum)=innerBdrys2D[i][it][j].x()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys2D[i][it][j+1].x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1201 EdgePts2d(1,edgNum)=innerBdrys2D[i][it][j].y()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys2D[i][it][j+1].y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1202 EdgePts3d(0,edgNum)=innerBdrys[i][it][j]->x()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it][j+1]->x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1203 EdgePts3d(1,edgNum)=innerBdrys[i][it][j]->y()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it][j+1]->y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1204 EdgePts3d(2,edgNum)=innerBdrys[i][it][j]->z()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it][j+1]->z()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1208 for(
int k=0;k<closeBoundary;k++)
1210 EdgePts2d(0,edgNum)=innerBdrys2D[i][it][0].x()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys2D[i][it].back().x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1211 EdgePts2d(1,edgNum)=innerBdrys2D[i][it][0].y()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys2D[i][it].back().y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1212 EdgePts3d(0,edgNum)=innerBdrys[i][it][0]->x()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it].back()->x()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1213 EdgePts3d(1,edgNum)=innerBdrys[i][it][0]->y()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it].back()->y()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1214 EdgePts3d(2,edgNum)=innerBdrys[i][it][0]->z()*(T)(k+1)/(T)(closeBoundary+1)+innerBdrys[i][it].back()->z()*(T)(closeBoundary-k)/(T)(closeBoundary+1);
1220 int innerPts=cast<T,int>(math::sqrt(cast<int,T>(nCorners+kvAdditionalInnerPoints)));
1227 Corners2d, Corners3d,
1228 EdgePts2d, EdgePts3d,
1229 interiorPts2d, interiorPts3d,
1230 appxNormalPoints, appxNormals,
1231 (T)(wE), (T)(wI), (T)(0), (T)(0.01),
1238 std::vector< gsCurveLoop<T> *> loops;
1239 gsCurveLoop<T> * loop = calculateLoop(oPoints2D[i], isCorner(oPoints[i]), noSmooth);
1241 loops.push_back(loop);
1242 for (
size_t j=0;j<innerBdrys2D[i].size();j++)
1244 gsCurveLoop<T> * innerloop = calculateLoop(innerBdrys2D[i][j], isCorner(innerBdrys[i][j]), noSmooth);
1245 loops.push_back(innerloop);
1249 tSurfVec.push_back(cface);
1253 typename gsMesh<T>::uPtr m;
1254 int nPoints=cast<T,int>(
1255 (T)(meshPoints)*math::sqrt(math::sqrt(areas[i]/maxArea)));
1258 m = cface->
toMesh(nPoints);
1259 fitMeshes.push_back(m.release());
1271 for (
size_t i=0;i<oPoints.size();i++)
1273 for (
size_t j=0;j<oPoints[i].size();j++)
1276 vertVec.push_sorted_unique(*oPoints[i][j]);
1279 for (
size_t i=0;i<innerBdrys.size();i++)
1281 for (
size_t j=0;j<innerBdrys[i].size();j++)
1283 for(
size_t k=0;k<innerBdrys[i][j].size();k++)
1285 vertVec.push_sorted_unique(*innerBdrys[i][j][k]);
1288 for (
size_t i=0;i<vertVec.size();i++)
1289 sl.
addHeVertex(vertVec[i][0],vertVec[i][1],vertVec[i][2]);
1290 for (
size_t i=0;i<oPoints.size();i++)
1292 std::vector<std::vector<gsSolidHeVertex<T>* > > faceConstruct;
1293 std::vector<gsSolidHeVertex<T>* > faceHelp;
1294 for (
size_t j=0;j<oPoints[i].size();j++)
1297 faceHelp.push_back( sl.vertex[ vertVec.getIndex(*oPoints[i][j])] );
1299 faceConstruct.push_back(faceHelp);
1300 for (
size_t j=0;j<innerBdrys[i].size();j++)
1303 for (
size_t k=0;k<innerBdrys[i][j].size();k++)
1305 faceHelp.push_back( sl.vertex[ vertVec.getIndex(*innerBdrys[i][j][k])] );
1306 faceConstruct.push_back(faceHelp);
1308 sl.
addFace( faceConstruct, tSurfVec[i]);
1321 for(
int facenumber=1;facenumber<=numBigFaces;facenumber++)
1325 for (
size_t it=0;it<this->face.size();it++)
1327 if(this->face[it]->faceIdentity==facenumber)
1330 mface->addVertex(this->face[it]->vertices[0]->
operator[](0),
1331 this->face[it]->vertices[0]->
operator[](1),
1332 this->face[it]->vertices[0]->
operator[](2));
1334 mface->addVertex(this->face[it]->vertices[1]->
operator[](0),
1335 this->face[it]->vertices[1]->
operator[](1),
1336 this->face[it]->vertices[1]->
operator[](2));
1338 mface->addVertex(this->face[it]->vertices[2]->
operator[](0),
1339 this->face[it]->vertices[2]->
operator[](1),
1340 this->face[it]->vertices[2]->
operator[](2));
1344 for (
size_t i=0;i!=mface->numVertices();i=i+3)
1346 (mface)->addFace(&mface->vertex(i), &mface->vertex(i+1), &mface->vertex(i+2));
1348 patchMeshes.push_back(mface);
1352 for(
size_t it=0;it<this->face.size();it++)
1354 if(this->face[it]->faceIdentity==facenumber)
1356 for(
size_t vertIt=0;vertIt<3;vertIt++)
1359 for(
size_t j=0;j<oPoints[facenumber-1].size();j++)
1361 if(*this->face[it]->vertices[vertIt]==*oPoints[facenumber-1][j]&&found==0)
1364 paraface->addVertex(oPoints2D[facenumber-1][j][0],oPoints2D[facenumber-1][j][1],0);
1368 for(
size_t j=0;j<iPoints[facenumber-1].size();j++)
1370 if(*this->face[it]->vertices[vertIt]==*iPoints[facenumber-1][j]&&found==0)
1373 paraface->addVertex(iPoints2D[facenumber-1][j][0],iPoints2D[facenumber-1][j][1],0);
1378 for(
size_t j=0;j<innerBdrys[facenumber-1].size();j++)
1380 for(
size_t k=0;k<innerBdrys[facenumber-1][j].size();k++)
1382 if(*this->face[it]->vertices[vertIt]==*innerBdrys[facenumber-1][j][k]&&found==0)
1385 paraface->addVertex(innerBdrys2D[facenumber-1][j][k][0],innerBdrys2D[facenumber-1][j][k][1],0);
1394 for (
size_t i=0; i!=paraface->numVertices(); i+=3)
1396 (paraface)->addFace(¶face->vertex(i), ¶face->vertex(i+1), ¶face->vertex(i+2));
1399 paraMeshes.push_back(paraface);
1406 std::vector<std::vector<VertexHandle> > & iPoints,
1407 std::vector<std::vector<VertexHandle> > & oPoints,
1408 std::vector< std::vector<std::vector<VertexHandle> > > & innerBdrys,
1409 std::vector< std::vector<Vertex> > & innerBdrysMassP,
1411 std::vector<std::vector<bool> > & oPointsConvexFlag,
1412 std::string filenameFeatures,
1416 bool non_manifold, warning_borders;
1419 this->getFeatures(angle, non_manifold, warning_borders);
1420 this->mesh->cleanMesh();
1423 std::vector<gsEdge<T> > featEdges;
1425 this->readEdges(filenameFeatures, featEdges);
1426 this->setSharpEdges(featEdges, useFeatures);
1429 this->calcPatchNumbers();
1432 storeNeighboringFaces();
1433 divideAndMergePatches(innerAngle, patchAreaWeight, mergeSmallPatches);
1436 this->calcPatchNumbers();
1438 this->getFaces(iPoints,oPoints,innerBdrys,innerBdrysMassP,oPointsConvexFlag);
1446 GISMO_ASSERT(outerPoints.size()==isCorner.size(),
"the vertices have to be defines as corners or edges by a vector of bools");
1449 if (noSmooth || isCorner.at(0)==1)
1451 if(noSmooth || isCorner.at(1)==1)
1453 gsBSpline<T> * tcurve = calcTCurve(outerPoints[0],outerPoints[1]);
1454 loop->insertCurve(tcurve);
1460 Vertex v2=outerPoints[0];
1462 if(isCorner.back()==1)
1463 v1=outerPoints.back();
1465 v1=giveMidpoint(outerPoints.back(),outerPoints[0]);
1466 if(isCorner.at(1)==1)
1469 v3=giveMidpoint(outerPoints[0],outerPoints[1]);
1471 loop->insertCurve(tcurve);
1474 for (
size_t i=1;i<outerPoints.size()-1;i++)
1476 if (noSmooth || isCorner.at(i)==1)
1478 if(noSmooth || isCorner.at(i+1)==1)
1480 gsBSpline<T> * tcurve = calcTCurve(outerPoints[i],outerPoints[i+1]);
1481 loop->insertCurve(tcurve);
1487 Vertex v2=outerPoints[i];
1489 if(isCorner.at(i-1)==1)
1490 v1=outerPoints[i-1];
1492 v1=giveMidpoint(outerPoints[i-1],outerPoints[i]);
1493 if(isCorner.at(i+1)==1)
1494 v3=outerPoints[i+1];
1496 v3=giveMidpoint(outerPoints[i],outerPoints[i+1]);
1498 loop->insertCurve(tcurve);
1502 if (noSmooth || isCorner.back()==1)
1504 if(noSmooth || isCorner.at(0)==1)
1506 gsBSpline<T> * tcurve = calcTCurve(outerPoints.back(),outerPoints[0]);
1507 loop->insertCurve(tcurve);
1513 Vertex v2=outerPoints.back();
1515 if(isCorner.at(isCorner.size()-2)==1)
1516 v1=outerPoints[isCorner.size()-2];
1518 v1=giveMidpoint(outerPoints[isCorner.size()-2],outerPoints.back());
1519 if(isCorner.at(0)==1)
1522 v3=giveMidpoint(outerPoints.back(),outerPoints[0]);
1524 loop->insertCurve(tcurve);
1532 std::set<VertexHandle>
1533 const & vertexFaceSet)
1538 for(
size_t i=0;i<v1->nVertices.size();i++)
1540 for(
size_t j=0;j<v2->nVertices.size();j++)
1543 if ( *(v1->nVertices[i])==*(v2->nVertices[j]) &&
1544 vertexFaceSet.find(v2->nVertices[j]) != vertexFaceSet.end()
1553 weight /= calcDist(v1,v2);
1563 std::vector<FaceHandle> & face,
1567 bool foundResult =
false;
1569 size_t nf = face.size();
1572 for(
size_t i = 0; i < nf; i++)
1575 GISMO_ASSERT(face[i]->vertices.size() == 3,
"Expected triangle mesh");
1577 if(face[i]->faceIdentity != bigFaceIdx)
continue;
1584 T thisResult = thisNormal.dot(globalNormal);
1585 if((foundResult && thisResult * static_cast<T>(result) <= 0) || thisResult == 0)
1589 else result = (thisResult > 0)?1:-1;
1592 GISMO_ASSERT(foundResult,
"Could not examine any triangles to get normal information");
1599 const T epsilon= calcDist(e1.source, e1.target ) * 0.01 ;
1601 return ( (*e1.source - *e2.source).norm() < epsilon &&
1602 (*e1.target - *e2.target).norm() < epsilon );
1620 if (e1->source==e2->source||e1->source==e2->target)
1621 anglePoint=e1->source;
1622 else if (e1->target==e2->target||e1->target==e2->source)
1623 anglePoint=e1->target;
1626 gsDebug<<
"Edges are not neighbors"<<
"\n";
1630 if (anglePoint==e1->source)
1632 gsVector3d<T> helpvec(e1->target->operator[](0)-e1->source->operator[](0),e1->target->operator[](1)-e1->source->operator[](1),e1->target->operator[](2)-e1->source->operator[](2));
1637 gsVector3d<T> helpvec(e1->source->operator[](0)-e1->target->operator[](0),e1->source->operator[](1)-e1->target->operator[](1),e1->source->operator[](2)-e1->target->operator[](2));
1641 if (anglePoint==e2->source)
1643 gsVector3d<T> helpvec(e2->target->operator[](0)-e2->source->operator[](0),e2->target->operator[](1)-e2->source->operator[](1),e2->target->operator[](2)-e2->source->operator[](2));
1648 gsVector3d<T> helpvec(e2->source->operator[](0)-e2->target->operator[](0),e2->source->operator[](1)-e2->target->operator[](1),e2->source->operator[](2)-e2->target->operator[](2));
1651 FaceHandle vec1Face=NULL;
1652 FaceHandle vec2Face=NULL;
1654 if (e1->nFaces[0]->faceIdentity==faceNum)
1655 vec1Face=e1->nFaces[0];
1656 else if (e1->nFaces[1]->faceIdentity==faceNum)
1657 vec1Face=e1->nFaces[1];
1659 gsDebug<<
"selected Edge has no valid neighboring face"<<
"\n";
1660 if (e2->nFaces[0]->faceIdentity==faceNum)
1661 vec2Face=e2->nFaces[0];
1662 else if (e2->nFaces[1]->faceIdentity==faceNum)
1663 vec2Face=e2->nFaces[1];
1665 gsDebug<<
"selected Edge has no valid neighboring face"<<
"\n";
1680 for (
size_t i=0;i<vec.size()-1;i++)
1681 length+=calcDist(vec[i],vec[i+1]);
1682 length+=calcDist(vec[0],vec.back());
1691 for (
size_t i=0;i<vec.size();i++)
1707 return (*v1 - *v2).norm();
1714 std::vector<bool> isCorner;
1715 for(
size_t i=0;i<vertexVec3d.size();i++)
1717 if(vertexVec3d[i]->numEdges>2)
1718 isCorner.push_back(1);
1720 isCorner.push_back(0);
1730 tcp << v1.
x(), v1.
y(), v2.
x(), v2.
y();
1740 tcp << v1.
x(), v1.
y(), v2.
x(), v2.
y(), v3.
x(), v3.
y();
1750 (v1[1]+v2[1])/(T)(2),
1751 (v1[2]+v2[2])/(T)(2));
1759 std::ifstream myfile (fn.c_str());
1760 if (myfile.is_open())
1763 T x1=0,x2=0,y1=0,y2=0,z1=0,z2=0;
1764 while(myfile >> line)
1768 x1 = atof(line.c_str());
1770 y1 = atof(line.c_str());
1772 z1 = atof(line.c_str());
1774 x2 = atof(line.c_str());
1776 y2 = atof(line.c_str());
1779 z2 = atof(line.c_str());
1783 if(Xless<T>(v1,v2))std::swap(v1,v2);
1784 gsEdge<T> featureEdge(v1,v2);
1785 edges.push_back(featureEdge);
1800 T d1=calcDist(f1->vertices[0],f1->vertices[1]);
1801 T d2=calcDist(f1->vertices[0],f1->vertices[2]);
1802 T d3=calcDist(f1->vertices[1],f1->vertices[2]);
1804 T p=(d1+d2+d3)/(T)(2);
1805 T area=math::sqrt(p*(p-d1)*(p-d2)*(p-d3));
static T calcBdryLength(std::vector< VertexHandle > vec)
Adds up the lengths between 2 neighboring vertices of a vector of vertices.
Definition: gsTriMeshToSolid.hpp:1677
Class that provides a container for triplets (i,j,value) to be filled in a sparse matrix...
Definition: gsSparseMatrix.h:33
A fixed-size, statically allocated 3D vector.
Definition: gsVector.h:218
Class for a trim surface.
Definition: gsTrimSurface.h:33
static T calcArea(FaceHandle f1)
using Heron's Formula for the area of a triangle.
Definition: gsTriMeshToSolid.hpp:1798
T distance(gsMatrix< T > const &A, gsMatrix< T > const &B, index_t i=0, index_t j=0, bool cols=false)
compute a distance between the point number in the set and the point number <j> in the set ; by def...
#define gsDebug
Definition: gsDebug.h:61
memory::unique_ptr< gsMesh< T > > toMesh(int npoints=50) const
Return a triangulation of the planar domain.
Definition: gsPlanarDomain.hpp:248
void setSharpEdges(std::vector< gsEdge< T > > &featEdges, int useFeatures)
Sets sharp edges according to the value of useFeatures.
Definition: gsTriMeshToSolid.hpp:185
Provides interface of gsTrimSurface class. Represents a trimmed surface (= spline "master surface" in...
S give(S &x)
Definition: gsMemory.h:266
This class is derived from std::vector, and adds sort tracking.
Definition: gsSortedVector.h:109
gsBSpline< T > * calcTCurve(Vertex v1, Vertex v2)
calculates a B-spline of degree one from 2 vertices.
Definition: gsTriMeshToSolid.hpp:1727
static bool approxEqual(const gsEdge< T > &e1, const gsEdge< T > &e2)
checks if two edges are very close to each other.
Definition: gsTriMeshToSolid.hpp:1597
void getPatchData(T angle, T innerAngle, T patchAreaWeight, T mergeSmallPatches, std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag, std::string filenameFeatures, int useFeatures)
Computes data describing the patch structure of the mesh. Combines getFeatures and getFaces...
Definition: gsTriMeshToSolid.hpp:1405
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
static T calcWeight(VertexHandle v1, VertexHandle v2, std::set< VertexHandle > const &vertexFaceSet)
calculates a weight between 2 vertices used in Floater's algorithm.
Definition: gsTriMeshToSolid.hpp:1531
A B-spline function of one argument, with arbitrary target dimension.
Definition: gsBSpline.h:50
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
void getFaces(std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag)
Computes data describing the patch structure of the mesh.
Definition: gsTriMeshToSolid.hpp:311
#define gsWarn
Definition: gsDebug.h:50
static Vertex giveMidpoint(Vertex v1, Vertex v2)
calculates the midpoint of two vertices.
Definition: gsTriMeshToSolid.hpp:1747
void flip1(T minu=0, T maxu=1)
flip a curve loop in the u direction
Definition: gsCurveLoop.hpp:608
void addHeVertex(scalar_t const &x, scalar_t const &y, scalar_t const &z=0)
add coords to gsHeVertex, not yet pointers to HEs
Definition: gsSolid.hpp:51
static std::vector< bool > isCorner(std::vector< VertexHandle > const &vertexVec3d)
checks whether vertices are corners.
Definition: gsTriMeshToSolid.hpp:1712
T x() const
Definition: gsVertex.h:108
void addVolume(gsVolumeHandle vol)
add a volume using its handle
Definition: gsSolid.h:167
T conditionedAngle(gsVector3d< T > vec1, gsVector3d< T > vec2)
Angle between two vector: 0 <= angle <= pi.
Definition: gsModelingUtils.hpp:165
void toSolid(gsSolid< T > &sl, std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag, std::vector< gsMesh< T > * > ¶Meshes, std::vector< gsMesh< T > * > &fitMeshes, std::vector< gsMesh< T > * > &patchMeshes, int kvOuterPoints, int kvAdditionalInnerPoints, bool plot, int meshPoints, bool moreInner=true, T wE=5, T wI=1, int closeBoundary=0, bool noSmooth=false)
Parametrized a number of patches given by iPoints, oPoints, innerBdrys, innerBdrysMassP and oPointsCo...
Definition: gsTriMeshToSolid.hpp:566
gsTensorBSpline< 2, T >::Ptr gsInterpolateSurface(const gsMatrix< T > &exactPoints, const gsMatrix< T > &exactValues, const gsMatrix< T > &appxPointsEdges, const gsMatrix< T > &appxValuesEdges, const gsMatrix< T > &appxPointsInt, const gsMatrix< T > &appxValuesInt, const gsMatrix< T > &appxNormalPoints, const gsMatrix< T > &appxNormals, T wEdge, T wInt, T wNormal, T wReg, const gsKnotVector< T > &kv1, const gsKnotVector< T > &kv2, bool force_normal)
Definition: gsModelingUtils.hpp:504
void setHeMate()
Assigning mates for each HE.
Definition: gsSolid.hpp:320
gsSolidHalfFaceHandle addFace(std::vector< gsSolidHeVertexHandle > V)
Definition: gsSolid.hpp:82
Represents a B-spline curve/function with one parameter.
Class representing a Planar domain with an outer boundary and a number of holes.
Definition: gsPlanarDomain.h:43
void readEdges(std::string const &fn, std::vector< gsEdge< T > > &edges)
reads a text file consisting of lines of 6 values, each line representing an edge.
Definition: gsTriMeshToSolid.hpp:1756
T y() const
Definition: gsVertex.h:110
bool initFrom3DByAngles(const std::vector< gsVector3d< T > * > points3D, const std::vector< bool > isConvex, T margin)
Definition: gsCurveLoop.hpp:483
Utility functions required by gsModeling classes.
void divideAndMergePatches(T innerAngle, T patchAreaWeight, T mergeSmallPatches)
Improve surface segmentation by using more complex rules.
Definition: gsTriMeshToSolid.hpp:239
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
static T calcDist(VertexHandle v1, VertexHandle v2)
calculates the distance between 2 vertices.
Definition: gsTriMeshToSolid.hpp:1705
Class for representing a solid made up of vertices, edges, faces, and volumes.
Definition: gsSolid.h:32
void initFromIsConvex(const std::vector< bool > isConvex, T margin)
Initialize a curve loop from a list of bools indicating whether the corners are convex or not...
Definition: gsCurveLoop.hpp:514
Class for representing a knot vector.
Definition: gsKnotVector.h:79
static gsVertex< T > getMassP(std::vector< VertexHandle > vec)
calculates the mass point of a vector of vertices.
Definition: gsTriMeshToSolid.hpp:1688
void storeNeighboringFaces()
Store each edge's neighboring faces.
Definition: gsTriMeshToSolid.hpp:222
A closed loop given by a collection of curves.
Definition: gsCurveLoop.h:36
static int normalMult(gsVector3d< T > globalNormal, std::vector< FaceHandle > &face, int bigFaceIdx)
Definition: gsTriMeshToSolid.hpp:1562
gsCurveLoop< T > * calculateLoop(std::vector< Vertex > outerPoints, std::vector< bool > const &isCorner, bool noSmooth=false)
calculates a curve loop consisting of B-spline curves of degree one and two from a vector of vertices...
Definition: gsTriMeshToSolid.hpp:1444
void getFeatures(T angleGrad, bool &bWarnNonManifold, bool &bWarnBorders)
generates edges for a mesh consisting of vertices and faces. Determines if these edges are sharp...
Definition: gsTriMeshToSolid.hpp:72
memory::shared_ptr< gsTensorBSpline > Ptr
Shared pointer for gsTensorBSpline.
Definition: gsTensorBSpline.h:59
Interface for gsCurveLoop class, representing a loop of curves, in anticlockwise order.
void calcPatchNumbers()
Each face obtains a patch number, faces of the same number belong to the same patch.
Definition: gsTriMeshToSolid.hpp:27
Provides declaration of gsPlanarDomain class. The outer boundary (m_loops[0]) is a loop of curves...
T z() const
Definition: gsVertex.h:112
gsVertex class that represents a 3D vertex for a gsMesh.
Definition: gsVertex.h:26
Provides declaration of gsSolid class, a boundary-represented solid.
static T calcAngle(EdgeHandle e1, EdgeHandle e2, int faceNum)
calculates the conditioned angle between 2 edges.
Definition: gsTriMeshToSolid.hpp:1617