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]);
- }
- }
+ if ((bbGetInputCloseSurface()==true) && (lstIndexs.size()>=2) )
+ {
+ //check if initial and end points are the same in all splines (splines are in line shape and not U shape)
+ //to not apply changes because clean polydata will take care of it.
+ int count = 0;
+ bool differentPoints = false;
+ for(i=0; i < lstIndexs.size() && !differentPoints;i++){
+ bool sameStart = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1];
+ bool sameEnd = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1];
+ if(!(sameStart && sameEnd)) differentPoints = true;
+ count += lstIndexs[i];
}
+ //Correct surface normals if needed
+ if(differentPoints)
+ {
+ 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);
+ } // for pIndex
+
+ 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]);
+ } // for i
+ } // for splineI
+ } // if dotNormalSurf
+ }// if differentPoints
}
//
int lastId1 = lstIndexs[0]-1;
int lastId2 = sizeLstX - 1;
int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1];
- bool face1open = std::fabs(lstX[0] - lstX[lastId1]) > 0.0001 && std::fabs(lstY[0] - lstY[lastId1]) > 0.0001 && std::fabs(lstZ[0] - lstZ[lastId1]) > 0.0001;
- bool face2open = std::fabs(lstX[firstId2] - lstX[lastId2]) > 0.0001 && std::fabs(lstY[firstId2] - lstY[lastId2]) > 0.0001 && std::fabs(lstZ[firstId2] - lstZ[lastId2]) > 0.0001;
+ bool face1open = std::fabs(lstX[0] - lstX[lastId1]) > 0.0001 || std::fabs(lstY[0] - lstY[lastId1]) > 0.0001 || std::fabs(lstZ[0] - lstZ[lastId1]) > 0.0001;
+ bool face2open = std::fabs(lstX[firstId2] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[firstId2] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[firstId2] - lstZ[lastId2]) > 0.0001;
- bool altFace1open = std::fabs(lstX[0] - lstX[firstId2]) > 0.0001 && std::fabs(lstY[0] - lstY[firstId2]) > 0.0001 && std::fabs(lstZ[0] - lstZ[firstId2]) > 0.0001;
- bool altFace2open = std::fabs(lstX[lastId1] - lstX[lastId2]) > 0.0001 && std::fabs(lstY[lastId1] - lstY[lastId2]) > 0.0001 && std::fabs(lstZ[lastId1] - lstZ[lastId2]) > 0.0001;
+ bool altFace1open = std::fabs(lstX[0] - lstX[firstId2]) > 0.0001 || std::fabs(lstY[0] - lstY[firstId2]) > 0.0001 || std::fabs(lstZ[0] - lstZ[firstId2]) > 0.0001;
+ bool altFace2open = std::fabs(lstX[lastId1] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[lastId1] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[lastId1] - lstZ[lastId2]) > 0.0001;
//false = Open Contour
//true = Closed Contour