added displacement of polygonal template position considering the fixed vertices

This commit is contained in:
nico 2020-10-31 22:10:05 +01:00
parent 36e8d80854
commit 0488a0242a
1 changed files with 27 additions and 1 deletions

View File

@ -387,6 +387,30 @@ private:
F.N()=PlF.Direction(); F.N()=PlF.Direction();
} }
static void DisplaceBySelected(FaceType &f,std::vector<CoordType> &TemplatePos,
bool FixS,bool FixB)
{
CoordType AvPosF(0,0,0);
CoordType AvPosT(0,0,0);
size_t Num=0;
for (size_t i=0;i<f.VN();i++)
{
bool AddVal=false;
AddVal|=((FixS)&&(f.V(i)->IsS()));
AddVal|=((FixB)&&(f.V(i)->IsB()));
if (!AddVal)continue;
Num++;
AvPosF+=f.V(i)->P();
AvPosT+=TemplatePos[i];
}
if (Num==0)return;
AvPosF/=(ScalarType)Num;
AvPosT/=(ScalarType)Num;
CoordType Displ=AvPosF-AvPosT;
for (size_t i=0;i<TemplatePos.size();i++)
TemplatePos[i]+=Displ;
}
public: public:
static void SelectIrregularInternal(PolyMeshType &poly_m) static void SelectIrregularInternal(PolyMeshType &poly_m)
@ -548,6 +572,9 @@ public:
if ((IgnoreF!=NULL)&&((*IgnoreF)[i]))continue; if ((IgnoreF!=NULL)&&((*IgnoreF)[i]))continue;
std::vector<typename PolygonType::CoordType> TemplatePos; std::vector<typename PolygonType::CoordType> TemplatePos;
GetRotatedTemplatePos(poly_m.face[i],TemplatePos); GetRotatedTemplatePos(poly_m.face[i],TemplatePos);
if ((FixS)||(fixB))
DisplaceBySelected(poly_m.face[i],TemplatePos,FixS,fixB);
//then cumulate the position per vertex //then cumulate the position per vertex
ScalarType val=vcg::PolyArea(poly_m.face[i]); ScalarType val=vcg::PolyArea(poly_m.face[i]);
if (val<(AvgArea*0.00001)) if (val<(AvgArea*0.00001))
@ -564,7 +591,6 @@ public:
//sum up contributes //sum up contributes
avgPos[IndexV]+=Pos*W; avgPos[IndexV]+=Pos*W;
weightSum[IndexV]+=W; weightSum[IndexV]+=W;
} }
} }