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()));
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);