]> Creatis software - creaMaracasVisu.git/commitdiff
#3493 ShowNPoints_UndoRedo
authorEduardo Enrique Davila Serrano <davila@creatis.insa-lyon.fr>
Mon, 17 Oct 2022 10:43:27 +0000 (12:43 +0200)
committerEduardo Enrique Davila Serrano <davila@creatis.insa-lyon.fr>
Mon, 17 Oct 2022 10:43:27 +0000 (12:43 +0200)
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx

index 5585788034e4379fe32dcd506e67e188dfe5b7e3..5b98808d6fdc87df40001d2546a046da84d1ebcf 100644 (file)
@@ -4,6 +4,10 @@
 #include "bbcreaMaracasVisuShowNPoints_Tools.h"
 #include "bbcreaMaracasVisuPackage.h"
 
+#include <vtkPointData.h>
+#include <vtkDataArray.h>
+#include <vtkMath.h>
+
 
 namespace bbcreaMaracasVisu
 {
@@ -120,10 +124,30 @@ void ShowNPoints_Tools::CreatePatch01()
         
         
         // Check normals
-        1. Recorrer las normales de lstIdNormals y calcular el promedio  -> V1
-        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
+//        1. Recorrer las normales de lstIdNormals y calcular el promedio  -> V1
+        double          *nValue;
+               double                  n1[3];
+        vtkPointData    *pointdata  =  bbGetInputMesh()->GetPointData();
+        vtkDataArray    *dataarray  = pointdata->GetNormals();
+               int i,size = lstIdNormal.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];
+               } // for i
+               n1[0] = n1[0]/size;
+               n1[1] = n1[1]/size;
+               n1[2] = n1[2]/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
         
         
         // --- Finish ---
index ff7e6236bb7e63b093050d7705a38396fdeec159..8cbb9c53d68e1504e3ccc9388f2d73d5382cc849 100644 (file)
        // EED 2022-05-19
     //  mmodelShowNPoints                                  = new ModelShowNPoints();
                         idUndoRedo          = 0;
-                        maxUndoRedo         = 0;
-      UndoRedoDir                           = "/tmp";
-      
+                        maxUndoRedo         = 0;       
+#if defined(_WIN32)
+                                               char * val = getenv( "TEMP" );
+                                               if (val == NULL) 
+                                               { 
+                                                       UndoRedoDir = std::string("");  
+                                               } else { 
+                                                       UndoRedoDir = std::string(val)+"\\creatools"; 
+                                                       printf("WidgetShowNPoints::WidgetShowNPoints  UndoRedoDir = %s   %p \n", UndoRedoDir.c_str() , this );
+                                                       std::string cmd1 = "mkdir "+ UndoRedoDir;
+                                                       system( cmd1.c_str() );
+                                                       // Erasing files of more than 1 day old  ( -1 )
+                                                       std::string cmd2 = "ForFiles /p \"" + UndoRedoDir + "\" /s /d -1 /c \"cmd /c del @file \"";
+                                                       system( cmd2.c_str() );
+                                               }
+#elif defined(__GNUC__)
+
+
+    #if defined(MACOSX)
+                                               UndoRedoDir         = "/tmp";
+    #else  // Linux
+                                               UndoRedoDir         = "/tmp";
+    #endif
+       
+       printf("WidgetShowNPoints::WidgetShowNPoints  UndoRedoDir = %s   %p \n", UndoRedoDir.c_str() , this );
+       // Erasing files of more than 1 day old  ( +1 ) 
+       str::string cmd= "find "+UndoRedoDir+" -name \"UndoRedo_collection_*.undoredo\" -type f -mtime +1 -delete";
+       system( cmd.c_str() );
+
+#else
+                                               UndoRedoDir         = "./";
+#endif
+   
+   
                         mActualCollection   = 0;
     ModelShowNPoints*   modelShowNPoints    = new ModelShowNPoints();
     lstModelShowNPoints.push_back( modelShowNPoints );