(wsp->GetModelShowNPoints()->GetLstPointsSize()==4) &&
(bbGetInputMesh()!=NULL ) )
{
- std::vector<long int> lstIdNormal;
+ std::vector<long int> lstIdNormalSurface;
double spc[3];
spc[0] = bbGetInputSpacing()[0];
spc[1] = bbGetInputSpacing()[1];
std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+ wsp->ErasePoint( 0 );
+ wsp->ErasePoint( 0 );
+ wsp->ErasePoint( 0 );
+ wsp->ErasePoint( 0 );
+
// --- Group 0 ---
- wsp->ErasePoint( 2 );
- wsp->ErasePoint( 2 );
dx = lstX[1]-lstX[0];
dy = lstY[1]-lstY[0];
dz = lstZ[1]-lstZ[0];
- s=0.33333;
+ s = 0;
p[0] = lstX[0] + dx*s;
p[1] = lstY[0] + dy*s;
p[2] = lstZ[0] + dz*s;
NearestPointToMesh(points, pointLocator, spc, p,pM);
wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) );
- s=s*2;
+ lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(pM) );
+ s = 0.33333;
+ p[0] = lstX[0] + dx*s;
+ p[1] = lstY[0] + dy*s;
+ p[2] = lstZ[0] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ s = 0.6666666;
+ p[0] = lstX[0] + dx*s;
+ p[1] = lstY[0] + dy*s;
+ p[2] = lstZ[0] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0],pM[1], pM[2],"");
+ s = 1;
p[0] = lstX[0] + dx*s;
p[1] = lstY[0] + dy*s;
p[2] = lstZ[0] + dz*s;
NearestPointToMesh(points, pointLocator, spc, p,pM);
wsp->InsertPoint(pM[0],pM[1], pM[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) );
+ lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(pM) );
// --- Group 1 ---
wsp->InsertCollectionAfter_();
p[2] = (lstZ[0]+lstZ[3])/2;
NearestPointToMesh(points, pointLocator, spc, p,pM);
wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) );
p[0] = (lstX[1]+lstX[2])/2;
p[1] = (lstY[1]+lstY[2])/2;
p[2] = (lstZ[1]+lstZ[2])/2;
NearestPointToMesh(points, pointLocator, spc, p,pM);
wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) );
p[0] = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4; p[1] = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4; p[2] = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
wsp->InsertPoint(p[0] ,p[1], p[2],"");
p[0] = lstX[3];
p[1] = lstY[3];
p[2] = lstZ[3];
- wsp->InsertPoint(p[0] ,p[1], p[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(p) );
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(p) );
p[0] = lstX[2];
p[1] = lstY[2];
p[2] = lstZ[2];
- wsp->InsertPoint(p[0] ,p[1], p[2],"");
- lstIdNormal.push_back( pointLocator->FindClosestPoint(p) );
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(p) );
dx = lstX[2]-lstX[3];
dy = lstY[2]-lstY[3];
dz = lstZ[2]-lstZ[3];
NearestPointToMesh(points, pointLocator, spc, p,pM);
wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
- wsp->SetOutputBox();
- pointLocator->Delete();
+ wsp->SetOutputBox();
+ pointLocator->Delete();
// Check normals
double n1[3];
vtkPointData *pointdata = bbGetInputMesh()->GetPointData();
vtkDataArray *dataarray = pointdata->GetNormals();
- int i,size = lstIdNormal.size();
+ int i,size = lstIdNormalSurface.size();
n1[0]=0;
n1[1]=0;
n1[2]=0;
for (i=0; i<size; i++)
{
- nValue = dataarray->GetTuple3( i );
- n1[0] = n1[0]+nValue[0];
- n1[1] = n1[1]+nValue[1];
- n1[2] = n1[2]+nValue[2];
+ nValue = dataarray->GetTuple3( lstIdNormalSurface[i] );
+ n1[0] = n1[0] + nValue[0];
+ n1[1] = n1[1] + nValue[1];
+ n1[2] = n1[2] + nValue[2];
} // for i
n1[0] = n1[0]/size;
n1[1] = n1[1]/size;
// 2. Calcular el promedio de 4 normales de la nueva superficie -> V2
-// 3. Calcular el angulo entre V1 y V2
-// 4. Si el angulo es major de 90 Invertir las normales de la superficie actual
+ double pC[3];
+ double pM1[3];
+ double pM2[3];
+ double n2[3];
+ n2[0] = 0;
+ n2[1] = 0;
+ n2[2] = 0;
+ // Collection 0 with 4 points
+ // Collection 1 with 3 points
+ // Collection 2 with 4 points
+ wsp->GetCollectionPoint(1,1, pC);
+ wsp->GetCollectionPoint(0,0, pM);
+ vtkMath::Subtract(pM,pC,pM1);
+ wsp->GetCollectionPoint(0,3, pM);
+ vtkMath::Subtract(pM,pC,pM2);
+ vtkMath::Cross(pM1,pM2,pM);
+ n2[0] = pM[0];
+ n2[1] = pM[1];
+ n2[2] = pM[2];
+
+ wsp->GetCollectionPoint(0,3, pM);
+ vtkMath::Subtract(pM,pC,pM1);
+ wsp->GetCollectionPoint(2,3, pM);
+ vtkMath::Subtract(pM,pC,pM2);
+ vtkMath::Cross(pM1,pM2,pM);
+ n2[0] = n2[0] + pM[0];
+ n2[1] = n2[1] + pM[1];
+ n2[2] = n2[2] + pM[2];
+
+ wsp->GetCollectionPoint(2,3, pM);
+ vtkMath::Subtract(pM,pC,pM1);
+ wsp->GetCollectionPoint(2,0, pM);
+ vtkMath::Subtract(pM,pC,pM2);
+ vtkMath::Cross(pM1,pM2,pM);
+ n2[0] = n2[0] + pM[0];
+ n2[1] = n2[1] + pM[1];
+ n2[2] = n2[2] + pM[2];
+
+ wsp->GetCollectionPoint(2,0, pM);
+ vtkMath::Subtract(pM,pC,pM1);
+ wsp->GetCollectionPoint(0,0, pM);
+ vtkMath::Subtract(pM,pC,pM2);
+ vtkMath::Cross(pM1,pM2,pM);
+ n2[0] = n2[0] + pM[0];
+ n2[1] = n2[1] + pM[1];
+ n2[2] = n2[2] + pM[2];
+
+ n2[0] = n2[0] / 4;
+ n2[1] = n2[1] / 4;
+ n2[2] = n2[2] / 4;
+
+
+// 3. Calcular el angulo entre V1 y V2
+ double angle = vtkMath::AngleBetweenVectors(n1,n2) * 180 / vtkMath::Pi();
+
+ printf("EED ShowNPoints_Tools::CreatePatch01 n1 %f %f %f\n", n1[0] , n1[1] , n1[2] );
+ printf("EED ShowNPoints_Tools::CreatePatch01 n2 %f %f %f\n", n2[0] , n2[1] , n2[2] );
+ printf("EED ShowNPoints_Tools::CreatePatch01 angle %f\n", angle);
+ // 4. Si el angulo es major de 90 Invertir las normales de la superficie actual
+ if (angle>90)
+ {
+ wsp->InvertLstPoints_();
+ } // if angle
// --- Finish ---
wsp->UndoRedo_SaveCollection();
} else {