From: Pablo Garzon Date: Tue, 4 Apr 2023 12:26:03 +0000 (+0200) Subject: #3504 Integer to double ShowNpoints X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=7a9fee153660293ce0ad7c381830a17efd40fced;p=creaMaracasVisu.git #3504 Integer to double ShowNpoints --- diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg b/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg index ddc0a77..b75e420 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg +++ b/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBG BlackBox Diagram file -# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg +# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg # ---------------------------------- APP_START @@ -179,7 +179,7 @@ In7:"+> Insert group after" PORT In8:"- Delete group" PORT -In9:"Tool - 3 points to surface" +In9:"Tool - 3 or 4 points to surface" FIN_BOX BOX creaMaracasVisu:ShowNPoints_Tools:Box60 @@ -623,9 +623,7 @@ ISEXEC:FALSE -301.046687:92.535608:-900.000000 -276.526687:90.035608:-900.000000 PORT -In0:"Tool - 4 points to surface" -PORT -In1:"Tool - Inverse Normals" +In0:"Tool - Inverse Normals" FIN_BOX BOX std:VectorFilterString:Box112 @@ -633,9 +631,9 @@ ISEXEC:FALSE -276.139970:71.814693:-900.000000 -248.099970:69.314693:-900.000000 PORT -In0:"0 1 2 3 4 5 6 7 8 9 10 11 12" +In0:"0 1 2 3 4 5 6 7 8 9 10 11" PORT -In1:"1 5 10 20 30 40 50 0 100 110 190 200 210" +In1:"1 5 10 20 30 40 50 0 100 110 200 210" PORT Type:"2" FIN_BOX @@ -1083,9 +1081,6 @@ CONNECTION Box100:Out:Box95:Param NumberOfControlPoints:0 CONNECTION -Box99:Widget:Box101:Widget4 -NumberOfControlPoints:0 -CONNECTION Box99:BoxChange:Box103:In4 NumberOfControlPoints:0 CONNECTION @@ -1206,9 +1201,6 @@ CONNECTION Box117:Widget:Box44:Widget3 NumberOfControlPoints:0 CONNECTION -Box118:Widget:Box101:Widget1 -NumberOfControlPoints:0 -CONNECTION Box118:Out:Box96:ScalarFactor NumberOfControlPoints:0 CONNECTION @@ -1269,9 +1261,15 @@ CONNECTION Box127:Widget:Box129:Widget4 NumberOfControlPoints:0 CONNECTION -Box129:Widget:Box101:Widget7 +Box121:Widget:Box129:Widget6 NumberOfControlPoints:0 CONNECTION -Box121:Widget:Box129:Widget6 +Box99:Widget:Box101:Widget7 +NumberOfControlPoints:0 +CONNECTION +Box118:Widget:Box101:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box129:Widget:Box101:Widget1 NumberOfControlPoints:0 APP_END diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs b/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs index 482b97c..1ca503f 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs +++ b/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box) -# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs +# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs # ---------------------------------- include std @@ -60,7 +60,7 @@ new std:AddStringToVector Box58 set Box58.In6 "----------------------" set Box58.In7 "+> Insert group after" set Box58.In8 "- Delete group" - set Box58.In9 "Tool - 3 points to surface" + set Box58.In9 "Tool - 3 or 4 points to surface" new creaMaracasVisu:ShowNPoints_Tools Box60 @@ -224,12 +224,11 @@ new creaVtk:MeshReduction_QuadricDecimation Box110 set Box110.TargetReduction "0.5" new std:AddStringToVector Box111 - set Box111.In0 "Tool - 4 points to surface" - set Box111.In1 "Tool - Inverse Normals" + set Box111.In0 "Tool - Inverse Normals" new std:VectorFilterString Box112 - set Box112.In0 "0 1 2 3 4 5 6 7 8 9 10 11 12" - set Box112.In1 "1 5 10 20 30 40 50 0 100 110 190 200 210" + set Box112.In0 "0 1 2 3 4 5 6 7 8 9 10 11" + set Box112.In1 "1 5 10 20 30 40 50 0 100 110 200 210" set Box112.Type "2" new std:ConcatStrings Box114 @@ -371,7 +370,6 @@ connect Box04.Out Box95.In connect Box95.Out Box96.In connect Box99.Out Box100.In1 connect Box100.Out Box95.Param -connect Box99.Widget Box101.Widget4 connect Box99.BoxChange Box103.In4 connect Box103.BoxChange Box98.boxexecute connect Box71.Out Box105.wxVtkBaseView @@ -412,7 +410,6 @@ connect Box43.Widget Box44.Widget1 connect Box78.Widget Box117.Widget2 connect Box80.Widget Box117.Widget4 connect Box117.Widget Box44.Widget3 -connect Box118.Widget Box101.Widget1 connect Box118.Out Box96.ScalarFactor connect Box118.BoxChange Box103.In3 connect Box119.Out Box58.StringVector @@ -433,8 +430,10 @@ connect Box128.BoxChange Box126.In2 connect Box120.BoxChange Box126.In1 connect Box126.BoxChange Box31.BoxExecute connect Box127.Widget Box129.Widget4 -connect Box129.Widget Box101.Widget7 connect Box121.Widget Box129.Widget6 +connect Box99.Widget Box101.Widget7 +connect Box118.Widget Box101.Widget4 +connect Box129.Widget Box101.Widget1 # Complex input ports input point showNpoints.In " " diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx index 84435b2..254ad79 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -32,107 +32,112 @@ void ShowNPoints_Tools::CreatePatch_3points() { //printf("PG ShowNPoints_Tools::CreatePatch_3points Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); - wsp->StopAutoAddPoints(); - wsp->StopTrackPoint(); - if ( (wsp->GetLstModelShowNPointsSize()==1) && - (wsp->GetModelShowNPoints()->GetLstPointsSize()==3) && - (bbGetInputMesh()!=NULL ) ) - { - std::vector lstX = wsp->GetModelShowNPoints()->GetLstPointsX(); - std::vector lstY = wsp->GetModelShowNPoints()->GetLstPointsY(); - std::vector lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ(); - - double pA[3]; - pA[0] = lstX[0]; - pA[1] = lstY[0]; - pA[2] = lstZ[0]; - double pB[3]; - pB[0] = lstX[1]; - pB[1] = lstY[1]; - pB[2] = lstZ[1]; - double pC[3]; - pC[0] = lstX[2]; - pC[1] = lstY[2]; - pC[2] = lstZ[2]; + + std::vector lstX = wsp->GetModelShowNPoints()->GetLstPointsX(); + std::vector lstY = wsp->GetModelShowNPoints()->GetLstPointsY(); + std::vector lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ(); + + double pA[3]; + pA[0] = lstX[0]; + pA[1] = lstY[0]; + pA[2] = lstZ[0]; + double pB[3]; + pB[0] = lstX[1]; + pB[1] = lstY[1]; + pB[2] = lstZ[1]; + double pC[3]; + pC[0] = lstX[2]; + pC[1] = lstY[2]; + pC[2] = lstZ[2]; - double v[3]; - double u[3]; - vtkMath::Subtract(pC,pA,v); - vtkMath::Subtract(pB,pA,u); - - /**point in AC closest to B. - *formula t=(V)dot(U)/(V)dot(V) - */ - double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v); - /**nP found point - *formula A+t(C-A) -> A+tV - */ - vtkMath::MultiplyScalar(v, t); - double nP[3]; - vtkMath::Add(pA, v, nP); - - //calculate direction vector from found point to B - double dirVector[3]; - vtkMath::Subtract(pB, nP, dirVector); - - double pointAdd[3]; - double pointSub[3]; - - //Add and subtract direction vector to A and C to find the 4 points to create the patch, - - std::vector resListX; - std::vector resListY; - std::vector resListZ; - - vtkMath::Add(pA, dirVector, pointAdd); - vtkMath::Subtract(pA, dirVector, pointSub); - - resListX.push_back(pointSub[0]); - resListY.push_back(pointSub[1]); - resListZ.push_back(pointSub[2]); + double v[3]; + double u[3]; + vtkMath::Subtract(pC,pA,v); + vtkMath::Subtract(pB,pA,u); + + /**point in AC closest to B. + *formula t=(V)dot(U)/(V)dot(V) + */ + double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v); + /**nP found point + *formula A+t(C-A) -> A+tV + */ + vtkMath::MultiplyScalar(v, t); + double nP[3]; + vtkMath::Add(pA, v, nP); + + //calculate direction vector from found point to B + double dirVector[3]; + vtkMath::Subtract(pB, nP, dirVector); + + double pointAdd[3]; + double pointSub[3]; + + //Add and subtract direction vector to A and C to find the 4 points to create the patch, + + std::vector resListX; + std::vector resListY; + std::vector resListZ; + + vtkMath::Add(pA, dirVector, pointAdd); + vtkMath::Subtract(pA, dirVector, pointSub); + + resListX.push_back(pointSub[0]); + resListY.push_back(pointSub[1]); + resListZ.push_back(pointSub[2]); - resListX.push_back(pointAdd[0]); - resListY.push_back(pointAdd[1]); - resListZ.push_back(pointAdd[2]); - - - vtkMath::Add(pC, dirVector, pointAdd); - vtkMath::Subtract(pC, dirVector, pointSub); - - resListX.push_back(pointAdd[0]); - resListY.push_back(pointAdd[1]); - resListZ.push_back(pointAdd[2]); - - resListX.push_back(pointSub[0]); - resListY.push_back(pointSub[1]); - resListZ.push_back(pointSub[2]); - //printf("PG ShowNPoints_Tools::CreatePatch_3points Calls CreatePatch_Points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - //Create patch given the previously calculated points (4 points) - CreatePatch_Points(resListX, resListY, resListZ); - }else{ - //printf("PG ShowNPoints_Tools::CreatePatch_3points Warning patch not apply. Need only one group of 3 points\n"); - } + resListX.push_back(pointAdd[0]); + resListY.push_back(pointAdd[1]); + resListZ.push_back(pointAdd[2]); + + + vtkMath::Add(pC, dirVector, pointAdd); + vtkMath::Subtract(pC, dirVector, pointSub); + + resListX.push_back(pointAdd[0]); + resListY.push_back(pointAdd[1]); + resListZ.push_back(pointAdd[2]); + + resListX.push_back(pointSub[0]); + resListY.push_back(pointSub[1]); + resListZ.push_back(pointSub[2]); + + //Create patch given the previously calculated points (4 points) + CreatePatch_Points(resListX, resListY, resListZ); } void ShowNPoints_Tools::CreatePatch_4points() +{ + WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); + + std::vector lstX = wsp->GetModelShowNPoints()->GetLstPointsX(); + std::vector lstY = wsp->GetModelShowNPoints()->GetLstPointsY(); + std::vector lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ(); + CreatePatch_Points(lstX, lstY, lstZ); +} + +void ShowNPoints_Tools::InitCreatePatch_Points() { WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); wsp->StopAutoAddPoints(); wsp->StopTrackPoint(); - if ( (wsp->GetLstModelShowNPointsSize()==1) && - (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) && - (bbGetInputMesh()!=NULL ) ) - { - std::vector lstX = wsp->GetModelShowNPoints()->GetLstPointsX(); - std::vector lstY = wsp->GetModelShowNPoints()->GetLstPointsY(); - std::vector lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ(); - CreatePatch_Points(lstX, lstY, lstZ); - }else{ - printf("PG ShowNPoints_Tools::CreatePatch_4points Warning patch not apply. Need only one group of 4 points\n"); + if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL )){ + if(wsp->GetModelShowNPoints()->GetLstPointsSize()==4){ + CreatePatch_4points(); + } + else if(wsp->GetModelShowNPoints()->GetLstPointsSize()==3){ + CreatePatch_3points(); + } + else{ + printf("PG ShowNPoints_Tools::CreatePatch_Npoints Warning patch not apply. Number of points is invalid. Group should have 3 or 4 points\n"); + } + } + else{ + printf("PG ShowNPoints_Tools::CreatePatch_Npoints Warning patch not apply. groups or mesh invalid. Need 1 group of 3 or 4 points, and a mesh\n"); } } -void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector lstY, std::vector lstZ) +void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector lstY, std::vector lstZ) { WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); std::vector lstIdNormalSurface; @@ -347,7 +352,6 @@ void ShowNPoints_Tools::MovePatchCenter() modPoint.push_back(centerPoint[2] + direction * normal[2]); wsp->SetCollectionPoint(1, 1, modPoint); - wsp->GetViewShowNPoints()->RefreshPoints(); // --- Finish --- wsp->SetOutputBox(); @@ -421,13 +425,9 @@ void ShowNPoints_Tools::Process() { bbGetInputWidgetShowNPoints()->OnResetCollections_(); } // if Type - if (bbGetInputType()==190) - { - CreatePatch_3points(); - } // if Type if (bbGetInputType()==200) { - CreatePatch_4points(); + InitCreatePatch_Points(); } // if Type if (bbGetInputType()==210) { diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h index d0abad8..2f510b4 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h @@ -37,7 +37,8 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools void CreatePatch_3points(); void CreatePatch_4points(); - void CreatePatch_Points(std::vector lstX, std::vector lstY, std::vector lstZ); + void InitCreatePatch_Points(); + void CreatePatch_Points(std::vector lstX, std::vector lstY, std::vector lstZ); void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator *pointLocator, double *spc , double *p , double *pM ); void MovePatchCenter(); @@ -54,8 +55,8 @@ BBTK_CATEGORY("empty"); BBTK_INPUT(ShowNPoints_Tools,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,""); BBTK_INPUT(ShowNPoints_Tools,Spacing,"(default [1,1,1] )Spacing",std::vector,""); BBTK_INPUT(ShowNPoints_Tools,Mesh,"Mesh en format vtkPolyData ",vtkPolyData*,""); - BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 190:Tool 3 points to surface - Create Mesh (based with one group and 3 points) 200:Tool 4 points to surface - Create Mesh (based with one group and 4 points) 210: Invert points 220: Move patch center",int,""); - BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: Normal and direction", std::vector,""); + BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 200:Tool 3 or 4 points to surface - Create Mesh (based on one group and 3 or 4 points) 210: Invert points 220: Move patch center",int,""); + BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required 200: Normal and direction", std::vector,""); BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector, ""); // BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,""); diff --git a/bbtk/src/bbmaracasvisuShowNPoints.h b/bbtk/src/bbmaracasvisuShowNPoints.h index 2312b2e..5c6a56a 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.h +++ b/bbtk/src/bbmaracasvisuShowNPoints.h @@ -64,22 +64,22 @@ class /*BBTK_EXPORT*/ ShowNPoints public bbtk::WxBlackBox { BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox); - BBTK_DECLARE_INPUT(In, std::vector ); + BBTK_DECLARE_INPUT(In, std::vector ); BBTK_DECLARE_INPUT(Renderer, vtkRenderer* ); BBTK_DECLARE_INPUT(Image, vtkImageData* ); BBTK_DECLARE_INPUT(Colour, std::vector ); BBTK_DECLARE_INPUT(Opacity, double ); BBTK_DECLARE_INPUT(Radio, double ); - BBTK_DECLARE_INPUT(InitLstPointsX , std::vector ); - BBTK_DECLARE_INPUT(InitLstPointsY , std::vector ); - BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector ); + BBTK_DECLARE_INPUT(InitLstPointsX , std::vector ); + BBTK_DECLARE_INPUT(InitLstPointsY , std::vector ); + BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector ); BBTK_DECLARE_INPUT(InitLstLabels , std::vector ); BBTK_DECLARE_INPUT(InitLstIndexs , std::vector ); BBTK_DECLARE_INPUT(Type, int ); - BBTK_DECLARE_OUTPUT( lstPointsX , std::vector ); - BBTK_DECLARE_OUTPUT( lstPointsY , std::vector ); - BBTK_DECLARE_OUTPUT( lstPointsZ , std::vector ); + BBTK_DECLARE_OUTPUT( lstPointsX , std::vector ); + BBTK_DECLARE_OUTPUT( lstPointsY , std::vector ); + BBTK_DECLARE_OUTPUT( lstPointsZ , std::vector ); BBTK_DECLARE_OUTPUT( lstLabels , std::vector ); BBTK_DECLARE_OUTPUT( WidgetShowNPoints, WidgetShowNPoints*); BBTK_DECLARE_OUTPUT( lstIndexs , std::vector ); @@ -98,22 +98,22 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox); BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)"); BBTK_CATEGORY("widgetVtk"); - BBTK_INPUT(ShowNPoints,In,"One Point",std::vector,""); + BBTK_INPUT(ShowNPoints,In,"One Point",std::vector,""); BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,""); BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,""); BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector,"colour"); BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor 0..1 (default 1)",double,""); BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres 1..50 (default 10)",double,""); - BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector,""); - BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector,""); - BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector,""); + BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector,""); + BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector,""); + BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector,""); BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector,""); BBTK_INPUT(ShowNPoints,InitLstIndexs,"Initial lst of indexs sizes",std::vector,""); BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point, 2:Add/DeleteAll points, 3:As 0 with out save/load option, 4 Multiple NPoints",int,""); - BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector ,""); - BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector ,""); - BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector ,""); + BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector ,""); + BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector ,""); + BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , lstIndexs , " list of index sizes ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , WidgetShowNPoints , " WidgetShowNPoints ", WidgetShowNPoints* ,""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx index ea3616a..a66c92d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx @@ -28,19 +28,19 @@ double ModelShowNPoints::GetRadio() } //------------------------------------------------------------------------ -std::vector ModelShowNPoints::GetLstPointsX() +std::vector ModelShowNPoints::GetLstPointsX() { return lstPointsX; } //------------------------------------------------------------------------ -std::vector ModelShowNPoints::GetLstPointsY() +std::vector ModelShowNPoints::GetLstPointsY() { return lstPointsY; } //------------------------------------------------------------------------ -std::vector ModelShowNPoints::GetLstPointsZ() +std::vector ModelShowNPoints::GetLstPointsZ() { return lstPointsZ; } @@ -65,13 +65,13 @@ std::vector ModelShowNPoints::GetLstLabels() } //------------------------------------------------------------------------ -void ModelShowNPoints::SetReferencePoint(std::vector ppoint) +void ModelShowNPoints::SetReferencePoint(std::vector ppoint) { mReferencePoint = ppoint; } //------------------------------------------------------------------------ -std::vector ModelShowNPoints::GetReferencePoint() +std::vector ModelShowNPoints::GetReferencePoint() { return mReferencePoint; } @@ -95,7 +95,7 @@ std::string ModelShowNPoints::CleanSpaces(std::string ss) } //------------------------------------------------------------------------ -void ModelShowNPoints::GetIdPoint(int id, int *x, int *y, int *z) +void ModelShowNPoints::GetIdPoint(int id, double *x, double *y, double *z) { *x = lstPointsX[id]; *y = lstPointsY[id]; @@ -115,7 +115,7 @@ vtkImageData *ModelShowNPoints::GetImage() } //------------------------------------------------------------------------ -void ModelShowNPoints::AddPoint(int x, int y, int z, std::string label) +void ModelShowNPoints::AddPoint(double x, double y, double z, std::string label) { lstPointsX.push_back( x ); lstPointsY.push_back( y ); @@ -132,11 +132,11 @@ double ModelShowNPoints::DistanceSQ(double dX0, double dY0, double dZ0, double d } //------------------------------------------------------------------------ -int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label) +int ModelShowNPoints::InsertPoint(double x, double y, double z, std::string label) { if(lstPointsX.size()>1) { - std::vector dTotal; + std::vector dTotal; int pos = 1; double a,b,c,res; int i,j; @@ -149,7 +149,7 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label) dTotal.push_back (res); } //Gets the smallest distance - int smallTMP = dTotal[0]; + double smallTMP = dTotal[0]; for (j = 0; j < (int) dTotal.size(); j++) { if(dTotal[j]::iterator it; + std::vector::iterator it; //Insert the point in the list of points it = lstPointsX.begin(); lstPointsX.insert( it+pos, x ); @@ -239,21 +239,21 @@ void ModelShowNPoints::SavePoints_(FILE* ff) int i , size = (int) (lstPointsX.size()); fprintf(ff,"NumberOfPoints %d \n",size); fprintf(ff," X\tY\tZ\tvalue\tLabel\n"); - int x, y, z; + double x, y, z; double value; for (i=0; iGetScalarComponentAsDouble(x,y,z,0); + value = mimage->GetScalarComponentAsDouble(std::round(x),std::round(y),std::round(z),0); if (lstLabels[i]!="") { tmpLabel=lstLabels[i]; } else{ tmpLabel="<_VOID_>"; } - fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str()); + fprintf(ff,"%f\t%f\t%f\t%f\t%s\n", x , y , z , value , tmpLabel.c_str()); } // for } @@ -279,11 +279,12 @@ int ModelShowNPoints::ReadPoints_(FILE* ff) fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp ); float value; - int x,y,z; + double x,y,z; for (i=0; i")==0) { strcpy(chartmp,""); } + cout << x << " " << y << " " << z << " " << value << endl; AddPoint(x,y,z, chartmp ); } return size; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h index fce6107..b809c2a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h @@ -13,47 +13,47 @@ class ModelShowNPoints public: ModelShowNPoints(); ~ModelShowNPoints(); - std::vector GetLstPointsX(); - std::vector GetLstPointsY(); - std::vector GetLstPointsZ(); - void GetIdPoint(int id, int *x, int *y, int *z); - std::string GetIdLabel(int id); - std::vector GetLstLabels(); - void AddPoint(int x, int y, int z, std::string label); - double DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1); - int InsertPoint(int x, int y, int z, std::string label); - void SavePoints(std::string filename); - void SavePoints_(FILE* ff); + std::vector GetLstPointsX(); + std::vector GetLstPointsY(); + std::vector GetLstPointsZ(); + void GetIdPoint(int id, double *x, double *y, double *z); + std::string GetIdLabel(int id); + std::vector GetLstLabels(); + void AddPoint(double x, double y, double z, std::string label); + double DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1); + int InsertPoint(double x, double y, double z, std::string label); + void SavePoints(std::string filename); + void SavePoints_(FILE* ff); - int ReadPoints(std::string filename); - int ReadPoints_(FILE* ff); - int GetNearestPoint(); + int ReadPoints(std::string filename); + int ReadPoints_(FILE* ff); + int GetNearestPoint(); - int GetLstPointsSize(); - void SetPointId_mReferencePoint(int id); - int IdInsidePoint(); + int GetLstPointsSize(); + void SetPointId_mReferencePoint(int id); + int IdInsidePoint(); - void SetPointById(int id, std::vector point); + void SetPointById(int id, std::vector point); - void SetReferencePoint(std::vector ppoint); - std::vector GetReferencePoint(); - void SetImage(vtkImageData *image); - std::string CleanSpaces(std::string ss); - vtkImageData* GetImage(); - void SetRadio(double radio); - double GetRadio(); - int RenamePoint(std::string label); - void ErasePoint(int id); - void SetFirstTime(bool value); - bool GetFirstTime(); - void InversLstPoints(); + void SetReferencePoint(std::vector ppoint); + std::vector GetReferencePoint(); + void SetImage(vtkImageData *image); + std::string CleanSpaces(std::string ss); + vtkImageData* GetImage(); + void SetRadio(double radio); + double GetRadio(); + int RenamePoint(std::string label); + void ErasePoint(int id); + void SetFirstTime(bool value); + bool GetFirstTime(); + void InversLstPoints(); private: - std::vector lstPointsX; - std::vector lstPointsY; - std::vector lstPointsZ; + std::vector lstPointsX; + std::vector lstPointsY; + std::vector lstPointsZ; std::vector lstLabels; - std::vector mReferencePoint; + std::vector mReferencePoint; double mradio; vtkImageData *mimage; bool firsttime; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx index 0af0e45..008f5cf 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx @@ -21,7 +21,7 @@ ViewShowNPoints::~ViewShowNPoints() void ViewShowNPoints::RefreshPoint(int id) { double spc[3]; - int x,y,z; + double x,y,z; GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z); GetModelShowNPoints()->GetImage()->GetSpacing(spc); std::string label = GetModelShowNPoints()->GetIdLabel(id); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index 7aba88a..1ae46a5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -506,7 +506,7 @@ void WidgetShowNPoints::AddVtkPoint() //------------------------------------------------------------------------ -void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label) +void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label) { GetModelShowNPoints()->AddPoint(x,y,z, label ); // EED 2022-05-19 @@ -516,7 +516,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label) } //------------------------------------------------------------------------ -void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT +void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT { // EED 2022-05-19 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 ) @@ -547,7 +547,7 @@ void WidgetShowNPoints::OnInsertPoint_() { return; } - std::vector point = GetModelShowNPoints()->GetReferencePoint(); + std::vector point = GetModelShowNPoints()->GetReferencePoint(); if (point.size()==3) { InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) ); @@ -573,7 +573,7 @@ void WidgetShowNPoints::OnAddPoint__() { return; } - std::vector point = GetModelShowNPoints()->GetReferencePoint(); + std::vector point = GetModelShowNPoints()->GetReferencePoint(); if (point.size()==3) { AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) ); @@ -954,7 +954,7 @@ void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event) } //------------------------------------------------------------------------ -void WidgetShowNPoints::SetReferencePoint(std::vector point) +void WidgetShowNPoints::SetReferencePoint(std::vector point) { GetModelShowNPoints()->SetReferencePoint(point); int i,size=lstModelShowNPoints.size(); @@ -965,7 +965,7 @@ void WidgetShowNPoints::SetReferencePoint(std::vector point) } //------------------------------------------------------------------------ -void WidgetShowNPoints::SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels ) +void WidgetShowNPoints::SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels ) { // EED 2022-05-19 //if (this->renderer==NULL) @@ -978,7 +978,7 @@ void WidgetShowNPoints::SetInitLstPoints( std::vector initLstPointsX, std sizeY = (int)initLstPointsY.size(); sizeZ = (int)initLstPointsZ.size(); sizeLabels = (int)initLstLabels.size(); - int x,y,z; + double x,y,z; std::string label; if ( (sizeX==sizeY) && (sizeX==sizeZ) ) { @@ -1363,7 +1363,7 @@ void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event) //------------------------------------------------------------------------ void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint) { - int x,y,z; + double x,y,z; lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z); pPoint[0] = x; pPoint[1] = y; @@ -1373,24 +1373,27 @@ void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector modPoint) { if(idCol >= 0 && idCol < lstModelShowNPoints.size()) + { lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint); + lstViewShowNPoints[idCol]->RefreshPoint(idPoint); + } else{ printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range"); } } //------------------------------------------------------------------------ -std::vector WidgetShowNPoints::GetLstPointsX() +std::vector WidgetShowNPoints::GetLstPointsX() { if (mtype!=4) { return GetModelShowNPoints()->GetLstPointsX(); } else { - std::vector lst; + std::vector lst; int iP,s; int iG,sG=lstModelShowNPoints.size(); for (iG=0 ; iG lstTmp = lstModelShowNPoints[iG]->GetLstPointsX(); + std::vector lstTmp = lstModelShowNPoints[iG]->GetLstPointsX(); s = lstTmp.size(); for (iP=0 ; iP WidgetShowNPoints::GetLstPointsX() } //------------------------------------------------------------------------ -std::vector WidgetShowNPoints::GetLstPointsY() +std::vector WidgetShowNPoints::GetLstPointsY() { if (mtype!=4) { return GetModelShowNPoints()->GetLstPointsY(); } else { - std::vector lst; + std::vector lst; int iP,s; int iG,sG=lstModelShowNPoints.size(); for (iG=0 ; iG lstTmp = lstModelShowNPoints[iG]->GetLstPointsY(); + std::vector lstTmp = lstModelShowNPoints[iG]->GetLstPointsY(); s = lstTmp.size(); for (iP=0 ; iP WidgetShowNPoints::GetLstPointsY() } //------------------------------------------------------------------------ -std::vector WidgetShowNPoints::GetLstPointsZ() +std::vector WidgetShowNPoints::GetLstPointsZ() { if (mtype!=4) { return GetModelShowNPoints()->GetLstPointsZ(); } else { - std::vector lst; + std::vector lst; int iP,s; int iG,sG=lstModelShowNPoints.size(); for (iG=0 ; iG lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ(); + std::vector lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ(); s = lstTmp.size(); for (iP=0 ; iP point); + void SetReferencePoint(std::vector point); - void AddPoint(int x, int y, int z, std::string label); + void AddPoint(double x, double y, double z, std::string label); void OnInsertPoint_(); - void InsertPoint(int x, int y, int z, std::string label);//CFT + void InsertPoint(double x, double y, double z, std::string label);//CFT int GetLstModelShowNPointsSize(); ModelShowNPoints* GetModelShowNPoints(); ViewShowNPoints* GetViewShowNPoints(); - void SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels ); + void SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels ); void SetType(int type); int GetType(); @@ -111,9 +111,9 @@ class WidgetShowNPoints : public wxPanel virtual void SetOutputBox(); void ErasePoint(int id); - std::vector GetLstPointsX(); - std::vector GetLstPointsY(); - std::vector GetLstPointsZ(); + std::vector GetLstPointsX(); + std::vector GetLstPointsY(); + std::vector GetLstPointsZ(); std::vector GetLstLabels(); std::vector GetLstIndexs();