X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkPolyDataNormals.cxx;h=46bc24a56656d27a216545591e1f3005b3df1908;hb=refs%2Fheads%2Fvtk9itk5wx3-macos;hp=f9676e5a4b9a3d49f83203df7eb0f0478448ce0e;hpb=2ff30a2f6c323b37d5e38743e3875535ea2563f6;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx index f9676e5..46bc24a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx @@ -5,6 +5,7 @@ #include "bbcreaVtkPackage.h" #include +//#include #include #include @@ -34,9 +35,17 @@ void PolyDataNormals::Process() // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <SetAutoOrientNormals(true); + normal->SetConsistency(true); +// this force to not change the order of triangles, keep the original order +// normal->SetAutoOrientNormals(false); +// normal->SetConsistency(false); + normal->SetInputData( bbGetInputIn() ); if (bbGetInputComputeType()==0) { @@ -44,8 +53,14 @@ void PolyDataNormals::Process() } else { normal->ComputePointNormalsOn(); } - // normal->SetFeatureAngle(60.0); + normal->SetFeatureAngle(360); + normal->Update(); + + /* + vtkTriangleMeshPointNormals* normal = vtkTriangleMeshPointNormals::New(); + normal->SetInputData( bbGetInputIn() ); normal->Update(); + */ // >>>>>>>>>>>>>>>>>>>> Calculate the MeanNormal vtkPolyData *polydata = normal->GetOutput(); @@ -62,12 +77,11 @@ void PolyDataNormals::Process() */ dataarray = pointdata->GetNormals(); std::vector meanNormal; - meanNormal.push_back(1); + meanNormal.push_back(0); meanNormal.push_back(0); meanNormal.push_back(0); if (dataarray!=NULL) { - meanNormal[0]=0; int i , size=dataarray->GetNumberOfTuples(); for (i=0; iGetNumberOfTuples(); for (i=0; iGetTuple3( i ); ang = vtkMath::AngleBetweenVectors( pValue, meanN ); - vtkMath::Cross(meanN,pValue,crossResult); wxyz[0] = ang * bbGetInputParam(); wxyz[1] = crossResult[0]; wxyz[2] = crossResult[1]; wxyz[3] = crossResult[2]; vtkMath::RotateVectorByWXYZ(meanN, wxyz ,meanNormalresult); + magnitude = sqrt( meanNormalresult[0]*meanNormalresult[0] + meanNormalresult[1]*meanNormalresult[1] + meanNormalresult[2]* meanNormalresult[2] ); + meanNormalresult[0] = meanNormalresult[0] / magnitude; + meanNormalresult[1] = meanNormalresult[1] / magnitude; + meanNormalresult[2] = meanNormalresult[2] / magnitude; dataarray->SetTuple3( i , meanNormalresult[0], meanNormalresult[1], meanNormalresult[2] ); } // for - } // if Type==1 && dataarray bbSetOutputMeanNormal( meanNormal ); bbSetOutputOut( normal->GetOutput() ); - } // if In - + } else { + bbSetOutputOut( NULL ); + }// if In } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -128,34 +151,34 @@ void PolyDataNormals::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputIn(NULL); + bbSetInputType(0); + bbSetInputComputeType(0); + bbSetInputIn(NULL); + bbSetOutputOut( NULL ); } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void PolyDataNormals::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void PolyDataNormals::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk