std::vector<double> lstY = bbGetInputLstY();
std::vector<double> lstZ = bbGetInputLstZ();
std::vector<int> lstIndexs = bbGetInputLstIndexs();
+ double pointsCentroid[3];
if ( (lstIndexs.size()<1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) )
{
printf("Warning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n");
for (i=0;i<sizeLstX;i++)
{
points->InsertNextPoint(lstX[i],lstY[i],lstZ[i]);
+ pointsCentroid[0] += lstX[i];
+ pointsCentroid[1] += lstY[i];
+ pointsCentroid[2] += lstZ[i];
} // for i
+ pointsCentroid[0] /= sizeLstX;
+ pointsCentroid[1] /= sizeLstX;
+ pointsCentroid[2] /= sizeLstX;
+
+ if(bbGetInputCloseSurface())
+ {
+ //Correct surface normals if needed
+ double pointSurf1[3], pointSurf2[3], pointSurf3[3];
+ double vect1[3], vect2[3];
+ double surfNormal[3], vectorCenter[3];
+ double dotNormalSurf = 0;
+
+ for(int pIndex = 0; pIndex < lstIndexs[0]-1; pIndex++){
+ pointSurf1[0] = lstX[pIndex];
+ pointSurf1[1] = lstY[pIndex];
+ pointSurf1[2] = lstZ[pIndex];
+ vtkMath::Subtract(pointsCentroid, pointSurf1, vectorCenter);
+
+ pointSurf2[0] = lstX[pIndex+lstIndexs[1]];
+ pointSurf2[1] = lstY[pIndex+lstIndexs[1]];
+ pointSurf2[2] = lstZ[pIndex+lstIndexs[1]];
+ pointSurf3[0] = lstX[pIndex+1];
+ pointSurf3[1] = lstY[pIndex+1];
+ pointSurf3[2] = lstZ[pIndex+1];
+ vtkMath::Subtract(pointSurf2, pointSurf1, vect1);
+ vtkMath::Subtract(pointSurf3, pointSurf1, vect2);
+ vtkMath::Cross(vect1, vect2, surfNormal);
+ dotNormalSurf += vtkMath::Dot(surfNormal, vectorCenter);
+ }
+ if(dotNormalSurf > 0){
+ points->Delete();
+ points = vtkPoints::New();
+ for(int splineI = 0; splineI < lstIndexs.size(); splineI++){
+ for (i=lstIndexs[splineI]-1; i >= 0;i--)
+ {
+ points->InsertNextPoint(lstX[splineI*lstIndexs[0]+i],lstY[splineI*lstIndexs[0]+i],lstZ[splineI*lstIndexs[0]+i]);
+ }
+ }
+ }
+ }
+ //
+
// vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
if (cells!=NULL) cells->Delete();
cells = vtkCellArray::New();
iGeneral=iGeneral+sizeSegment1;
cells->InsertNextCell(triangleStrip);
} //for LstIndexs
-
+
+
if(bbGetInputCloseSurface())
{
int lastId1 = lstIndexs[0]-1;
triangle->GetPointIds()->SetId(2, centroidId);
cells->InsertNextCell(triangle);
}
- /**triangleStrip->GetPointIds()->SetId(triangleIndex,index);
- triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);
- if(index-increment <= initial && !isClosedCont){
- triangleStrip->GetPointIds()->SetId(triangleIndex+2,triangleStripStart);
- triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);
- }
- triangleIndex+=2;
- */
}
- //cells->InsertNextCell(triangleStrip);
}//if normalOrder
}//if validCentroid
}//if numPointsFace
vtkSmartPointer<vtkTriangleStrip> triangleStripBottom = vtkSmartPointer<vtkTriangleStrip>::New();
triangleStripBottom->GetPointIds()->SetNumberOfIds(sizeLstIdexes*2);
+
+ double originPoint[3];
+ points->GetPoint(0, originPoint);
+ int middleMeshPoint = uPointOrder?lstIndexs[0]/2:lstIndexs[0]*sizeLstIdexes/2;
+
+ bool normalOrder = isPointingCorrectly(uPointOrder?lstIndexs[0]-1:sizeLstX-lstIndexs[0], uPointOrder?lstIndexs[0]:1, originPoint, middleMeshPoint);
+
int triangleIndex = 0, currentId = 0, nextId = 0;
for(int splineIndex = 0; splineIndex < sizeLstIdexes;splineIndex++){
- triangleStripBottom->GetPointIds()->SetId(triangleIndex, currentId);
nextId = uPointOrder?currentId + lstIndexs[splineIndex] - 1:sizeLstX - sizeLstIdexes + splineIndex;
- triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, nextId);
- triangleIndex+=2;
+ if(normalOrder)
+ {
+ triangleStripBottom->GetPointIds()->SetId(triangleIndex, currentId);
+ triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, nextId);
+ }
+ else{
+ triangleStripBottom->GetPointIds()->SetId(triangleIndex, nextId);
+ triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, currentId);
+ }
currentId = uPointOrder?nextId + 1: splineIndex+1;
+ triangleIndex+=2;
}
cells->InsertNextCell(triangleStripBottom);
}