corrected some interpolation numerical issue in InterpolateField3D
This commit is contained in:
parent
27a4ad3049
commit
89997b915f
|
|
@ -110,31 +110,35 @@ vcg::Point3<ScalarType> InterpolateNRosy3D(const std::vector<vcg::Point3<ScalarT
|
||||||
NF.Normalize();
|
NF.Normalize();
|
||||||
CoordType Vect=V[i];
|
CoordType Vect=V[i];
|
||||||
Vect.Normalize();
|
Vect.Normalize();
|
||||||
//ScalarType Dot=fabs(Vect*NF);
|
ScalarType Dot=(Norm[i]*TargetN);
|
||||||
//std::cout << "V[i] " << V[i].X() << " " << V[i].Y() << std::endl << std::flush;
|
CoordType rotV=V[i];
|
||||||
|
//std::cout << "Dot " <<Dot<<std::endl;
|
||||||
|
if (Dot>-0.99999)
|
||||||
|
{
|
||||||
|
//std::cout << "V[i] " << V[i].X() << " " << V[i].Y() << std::endl << std::flush;
|
||||||
|
|
||||||
///rotate the vector to become tangent to the reference plane
|
///rotate the vector to become tangent to the reference plane
|
||||||
vcg::Matrix33<ScalarType> RotNorm=vcg::RotationMatrix(Norm[i],TargetN);
|
vcg::Matrix33<ScalarType> RotNorm=vcg::RotationMatrix(Norm[i],TargetN);
|
||||||
//std::cout << "Norm[i] " << Norm[i].X() << " " << Norm[i].Y() << " " << Norm[i].Z()<< std::endl;
|
// std::cout << "Norm[i] " << Norm[i].X() << " " << Norm[i].Y() << " " << Norm[i].Z()<< std::endl;
|
||||||
//std::cout << "TargetN " << TargetN.X() << " " << TargetN.Y() << " " << TargetN.Z()<< std::endl<< std::flush;
|
// std::cout << "TargetN " << TargetN.X() << " " << TargetN.Y() << " " << TargetN.Z()<< std::endl<< std::flush;
|
||||||
|
|
||||||
CoordType rotV=RotNorm*V[i];
|
rotV=RotNorm*V[i];
|
||||||
//assert(fabs(rotV*TargetN)<0.000001);
|
//assert(fabs(rotV*TargetN)<0.000001);
|
||||||
rotV.Normalize();
|
rotV.Normalize();
|
||||||
//std::cout << "rotV " << rotV.X() << " " << rotV.Y() << " " << rotV.Z()<< std::endl<< std::flush;
|
//std::cout << "rotV " << rotV.X() << " " << rotV.Y() << " " << rotV.Z()<< std::endl<< std::flush;
|
||||||
|
|
||||||
///trassform to the reference frame
|
///trassform to the reference frame
|
||||||
rotV=RotFrame*rotV;
|
rotV=RotFrame*rotV;
|
||||||
// if (isnan(rotV.X())||isnan(rotV.Y()))
|
// if (isnan(rotV.X())||isnan(rotV.Y()))
|
||||||
// {
|
// {
|
||||||
// std::cout << "V[i] " << V[i].X() << " " << V[i].Y() << std::endl << std::flush;
|
// std::cout << "V[i] " << V[i].X() << " " << V[i].Y() << std::endl << std::flush;
|
||||||
// std::cout << "Norm[i] " << Norm[i].X() << " " << Norm[i].Y() << " " << Norm[i].Z()<< std::endl;
|
// std::cout << "Norm[i] " << Norm[i].X() << " " << Norm[i].Y() << " " << Norm[i].Z()<< std::endl;
|
||||||
// std::cout << "TargetN " << TargetN.X() << " " << TargetN.Y() << " " << TargetN.Z()<< std::endl<< std::flush;
|
// std::cout << "TargetN " << TargetN.X() << " " << TargetN.Y() << " " << TargetN.Z()<< std::endl<< std::flush;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
assert(!isnan(rotV.X()));
|
|
||||||
assert(!isnan(rotV.Y()));
|
|
||||||
|
|
||||||
|
assert(!isnan(rotV.X()));
|
||||||
|
assert(!isnan(rotV.Y()));
|
||||||
|
}
|
||||||
//it's 2D from now on
|
//it's 2D from now on
|
||||||
Cross2D.push_back(vcg::Point2<ScalarType>(rotV.X(),rotV.Y()));
|
Cross2D.push_back(vcg::Point2<ScalarType>(rotV.X(),rotV.Y()));
|
||||||
|
|
||||||
|
|
@ -534,9 +538,9 @@ public:
|
||||||
static void InitBorderField(MeshType & mesh)
|
static void InitBorderField(MeshType & mesh)
|
||||||
{
|
{
|
||||||
typedef typename MeshType::FaceType FaceType;
|
typedef typename MeshType::FaceType FaceType;
|
||||||
// typedef typename MeshType::VertexType VertexType;
|
// typedef typename MeshType::VertexType VertexType;
|
||||||
typedef typename MeshType::CoordType CoordType;
|
typedef typename MeshType::CoordType CoordType;
|
||||||
// typedef typename MeshType::ScalarType ScalarType;
|
// typedef typename MeshType::ScalarType ScalarType;
|
||||||
|
|
||||||
vcg::tri::UpdateTopology<MeshType>::FaceFace(mesh);
|
vcg::tri::UpdateTopology<MeshType>::FaceFace(mesh);
|
||||||
for (size_t i=0;i<mesh.face.size();i++)
|
for (size_t i=0;i<mesh.face.size();i++)
|
||||||
|
|
@ -641,7 +645,7 @@ public:
|
||||||
//restore selected flag
|
//restore selected flag
|
||||||
vcg::tri::UpdateFlags<MeshType>::FaceClearS(mesh);
|
vcg::tri::UpdateFlags<MeshType>::FaceClearS(mesh);
|
||||||
for (int i=0; i<(int)Sel0.size(); i++)
|
for (int i=0; i<(int)Sel0.size(); i++)
|
||||||
mesh.face[Sel0[i]].SetS();
|
mesh.face[Sel0[i]].SetS();
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t FindSeparatrices(const typename vcg::face::Pos<FaceType> &vPos,
|
static size_t FindSeparatrices(const typename vcg::face::Pos<FaceType> &vPos,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue