From: Eduardo DAVILA Date: Mon, 12 Jun 2023 12:42:25 +0000 (+0200) Subject: #3513 ColorLayerImageView2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1ef848909c3dc4dfdbb781fa4d48aa57075aa59d;p=creaMaracasVisu.git #3513 ColorLayerImageView2 --- diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg index 61ca150..11f16fc 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg +++ b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBG BlackBox Diagram file -# - /home/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg +# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg # ---------------------------------- APP_START @@ -171,7 +171,7 @@ In7:"+> Insert group after" PORT In8:"- Delete group" PORT -In9:"Tool - 3 or 4 points to surface" +In9:"Tool - Create Volume Surface from 3 or 4 points (use Close Spline 2 - Close Surface Off)" FIN_BOX BOX creaMaracasVisu:ShowNPoints_Tools:Box60 @@ -527,7 +527,7 @@ ISEXEC:FALSE PORT 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 200 210" +In1:"1 5 10 20 30 40 50 0 100 110 205 210" PORT Type:"2" FIN_BOX diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs index 5b9ca89..5c2c681 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs +++ b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs +# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs # ---------------------------------- include std @@ -56,7 +56,7 @@ new std:AddStringToVector Box58 set Box58.In6 "----------------------" set Box58.In7 "+> Insert group after" set Box58.In8 "- Delete group" - set Box58.In9 "Tool - 3 or 4 points to surface" + set Box58.In9 "Tool - Create Volume Surface from 3 or 4 points (use Close Spline 2 - Close Surface Off)" new creaMaracasVisu:ShowNPoints_Tools Box60 @@ -187,7 +187,7 @@ new std:AddStringToVector Box99 new std:VectorFilterString Box100 set Box100.In0 "0 1 2 3 4 5 6 7 8 9 10 11" - set Box100.In1 "1 5 10 20 30 40 50 0 100 110 200 210" + set Box100.In1 "1 5 10 20 30 40 50 0 100 110 205 210" set Box100.Type "2" new std:ConcatStrings Box101 diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index edb3954..6910717 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -75,6 +75,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ColorLayerImageView,bbtk::WxBlackBox); //===== void ColorLayerImageView::Process() { + printf("EED ColorLayerImageView::Process Start %s\n", bbGetFullName().c_str()); if (bbGetInputIn()!=NULL) { if ( !( (bbGetInputWxVtkBaseView()==NULL) && (bbGetInputWxVtkBaseView1()==NULL) && (bbGetInputWxVtkBaseView2()==NULL)) ) { @@ -86,22 +87,25 @@ void ColorLayerImageView::Process() // firsttime=false; clivp->SetActive( bbGetInputActive() ); } + + std::vector range = bbGetInputlstRangeForColorBar(); + std::vector colorbarposition = bbGetInputColorBarPosition(); + std::vector base_color = bbGetInputlstBaseColor(); + std::vector grey_level_boundaries = bbGetInputlstGreyLevelBoundaries(); + std::vector transparence_level_boundaries = bbGetInputlstTransparenceBoundaries(); + clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() ); clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 1 , bbGetInputWxVtkBaseView1() ); clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 2 , bbGetInputWxVtkBaseView2() ); - std::vector range = bbGetInputlstRangeForColorBar(); clivp->GetColorLayerImageViewManager()->SetRangeForColorBar( range ); - std::vector colorbarposition = bbGetInputColorBarPosition(); clivp->GetColorLayerImageViewManager()->SetColorBarPosition( colorbarposition ); - std::vector base_color = bbGetInputlstBaseColor(); clivp->GetColorLayerImageViewManager()->SetBaseColors( base_color ); - std::vector grey_level_boundaries = bbGetInputlstGreyLevelBoundaries(); clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries ); - std::vector transparence_level_boundaries = bbGetInputlstTransparenceBoundaries(); clivp->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries ); clivp->GetColorLayerImageViewManager()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() ); clivp->SetFittingMode( bbGetInputFittingMode() ); clivp->SetImage( bbGetInputIn() ); + bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) ); bbSetOutputLookupTable( clivp->GetColorLayerImageViewManager()->GetLookupTable(0) ); bbSetOutputOutOpacity( clivp->GetOpacity() ); @@ -117,6 +121,9 @@ void ColorLayerImageView::Process() }// if xxVtkBaseView } // if In + + printf("EED ColorLayerImageView::Process End \n"); + } //===== // Don't edit this file. This file is generated from xml description.. diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h index 907323b..8af663f 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h @@ -34,10 +34,8 @@ #include "wxVtkBaseView.h" #include - #include - namespace bbcreaMaracasVisu { @@ -81,7 +79,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColorLayerImageView,bbtk::WxBlackBox); BBTK_NAME("ColorLayerImageView"); BBTK_AUTHOR("Eduardo DAVILA (Creatis)"); - BBTK_DESCRIPTION("Color Layer Image View"); + BBTK_DESCRIPTION("(wxWidget) Color Layer Image View"); BBTK_CATEGORY("__CategoryBlackBox__"); BBTK_INPUT(ColorLayerImageView,In,"Input Image",vtkImageData*,""); BBTK_INPUT(ColorLayerImageView,Active,"Active True/False (default True)",bool,""); diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.cxx new file mode 100644 index 0000000..aa0941f --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.cxx @@ -0,0 +1,162 @@ +//===== +// 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) +//===== +#include "bbcreaMaracasVisuColorLayerImageView2.h" +#include "bbcreaMaracasVisuPackage.h" +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ColorLayerImageView2) +BBTK_BLACK_BOX_IMPLEMENTATION(ColorLayerImageView2,bbtk::AtomicBlackBox); + + + + + +//===== +// 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 ColorLayerImageView2::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + // bbSetOutputOut( bbGetInputIn() ); + // std::cout << "Output value = " <SetActive( bbGetInputActive() ); + // } + + + std::vector range = bbGetInputlstRangeForColorBar(); + std::vector colorbarposition = bbGetInputColorBarPosition(); + std::vector base_color = bbGetInputlstBaseColor(); + std::vector grey_level_boundaries = bbGetInputlstGreyLevelBoundaries(); + std::vector transparence_level_boundaries = bbGetInputlstTransparenceBoundaries(); + + _colorLayerImageViewManager->SetwxVtkBaseView ( 0 , bbGetInputWxVtkBaseView() ); + _colorLayerImageViewManager->SetwxVtkBaseView ( 1 , bbGetInputWxVtkBaseView1() ); + _colorLayerImageViewManager->SetwxVtkBaseView ( 2 , bbGetInputWxVtkBaseView2() ); + _colorLayerImageViewManager->SetRangeForColorBar ( range ); + _colorLayerImageViewManager->SetColorBarPosition ( colorbarposition ); + _colorLayerImageViewManager->SetBaseColors ( base_color ); + _colorLayerImageViewManager->SetGreyLevelBoundaries ( grey_level_boundaries ); + _colorLayerImageViewManager->SetBaseTransparence ( transparence_level_boundaries ); + _colorLayerImageViewManager->SetPlainOrGradientColor ( bbGetInputPlainOrGradientColor() ); + _colorLayerImageViewManager->onThresholdChangeOpacity ( bbGetInputOpacity() ); + _colorLayerImageViewManager->SetActive ( bbGetInputActive() ); + + int fitting_mode=3; + // CM Sets the fitting mode if an appropriate value is provided. + if (bbGetInputFittingMode() == -1 || bbGetInputFittingMode() == 1 || bbGetInputFittingMode() == 2 || bbGetInputFittingMode() == 3) + { + fitting_mode = bbGetInputFittingMode(); + } + //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept). + else if (bbGetInputFittingMode() != 0) { + std::cout << "CM ERROR!!! The fitting mode provided has an inappropriate value. It should be an int between -1 ; 1 ; 2 ; 3, but its value is :" << bbGetInputFittingMode() << ". The default value will be set instead, i.e. Pixel transformation (3)." << std::endl; + //EO CM + fitting_mode=3; + } + +// clivp->SetFittingMode( bbGetInputFittingMode() ); +// clivp->SetImage( bbGetInputIn() ); + _colorLayerImageViewManager->SetFittingMode( fitting_mode ); + _colorLayerImageViewManager->SetImageStep1( bbGetInputIn() ); + _colorLayerImageViewManager->SetImageStep2( bbGetInputIn() ); + + bbSetOutputNewImage( _colorLayerImageViewManager->GetImageChangeInformation(0) ); + bbSetOutputLookupTable( _colorLayerImageViewManager->GetLookupTable(0) ); +// bbSetOutputOutOpacity( clivp->GetOpacity() ); + // if (firsttime==true) + // { + // firsttime=false; + // clivp->ChangeOpacity(); + // clivp->SetBox(this); + // } + // } // if clivp + } else { + printf("EED Error!!! ColorLayerImageView::Process (%s) Missing Inputs: WxVtkBaseView , WxVtkBaseView1 , WxVtkBaseView2 \n", bbGetFullName().c_str() ); + }// if xxVtkBaseView + + } // if In + + } // if Active + + + +} +//===== +// 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 ColorLayerImageView2::bbUserSetDefaultValues() +{ +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + firsttime=true; + bbSetInputIn(NULL); + bbSetInputActive(true); + bbSetInputOpacity(100); + bbSetInputPlainOrGradientColor(false); +// bbSetInputTypeControlsInterface(1); + bbSetInputWxVtkBaseView(NULL); + bbSetInputWxVtkBaseView1(NULL); + bbSetInputWxVtkBaseView2(NULL); + std::vector lstColorBarPosition; + lstColorBarPosition.push_back(10); + lstColorBarPosition.push_back(105); + bbSetInputColorBarPosition(lstColorBarPosition); +// bbSetOutputWidget(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 ColorLayerImageView2::bbUserInitializeProcessing() +{ + + _colorLayerImageViewManager = new ColorLayerImageViewManager(); + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// 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 ColorLayerImageView2::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.h b/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.h new file mode 100644 index 0000000..094833b --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView2.h @@ -0,0 +1,87 @@ +//===== +// 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) +//===== +#ifndef __bbcreaMaracasVisuColorLayerImageView2_h_INCLUDED__ +#define __bbcreaMaracasVisuColorLayerImageView2_h_INCLUDED__ + +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include + +#include "wxVtkBaseView.h" +#include "ColorLayerImageViewManager.h" + +namespace bbcreaMaracasVisu +{ + +class bbcreaMaracasVisu_EXPORT ColorLayerImageView2 + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ColorLayerImageView2,bbtk::AtomicBlackBox); +//===== +// 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) +//===== + + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_INPUT(Active,bool); + BBTK_DECLARE_INPUT(Opacity,int); +// BBTK_DECLARE_INPUT(TypeControlsInterface,int); + BBTK_DECLARE_INPUT(WxVtkBaseView,wxVtkBaseView *); + BBTK_DECLARE_INPUT(WxVtkBaseView1,wxVtkBaseView *); + BBTK_DECLARE_INPUT(WxVtkBaseView2,wxVtkBaseView *); + BBTK_DECLARE_INPUT(lstBaseColor,std::vector); + BBTK_DECLARE_INPUT(lstGreyLevelBoundaries,std::vector); + BBTK_DECLARE_INPUT(lstTransparenceBoundaries,std::vector); + BBTK_DECLARE_INPUT(lstRangeForColorBar,std::vector); + BBTK_DECLARE_INPUT(PlainOrGradientColor,bool); + BBTK_DECLARE_INPUT(FittingMode,int); + BBTK_DECLARE_INPUT(ColorBarPosition,std::vector); + BBTK_DECLARE_OUTPUT(NewImage,vtkImageData*); + BBTK_DECLARE_OUTPUT(LookupTable,vtkScalarsToColors*); +// BBTK_DECLARE_OUTPUT(OutOpacity,int); + BBTK_PROCESS(Process); + + void Process(); + bool firsttime; + ColorLayerImageViewManager *_colorLayerImageViewManager; + +//===== +// 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) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColorLayerImageView2,bbtk::AtomicBlackBox); + BBTK_NAME("ColorLayerImageView2"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("Color Layer Image View"); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ColorLayerImageView2,In,"Input Image",vtkImageData*,""); + BBTK_INPUT(ColorLayerImageView2,Active,"Active True/False (default True)",bool,""); + BBTK_INPUT(ColorLayerImageView2,Opacity,"(default 100) 0..100",int,""); +// BBTK_INPUT(ColorLayerImageView2,TypeControlsInterface,"1 (default) All controls, 2 just transparency",int,""); + BBTK_INPUT(ColorLayerImageView2,WxVtkBaseView," 0 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); + BBTK_INPUT(ColorLayerImageView2,WxVtkBaseView1," 1 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); + BBTK_INPUT(ColorLayerImageView2,WxVtkBaseView2," 2 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); + BBTK_INPUT(ColorLayerImageView2,lstBaseColor,"???EED List of Base Colors in RGB format to define the color map. Requirement: must be of a size being a multiple of 3, with values between 0 and 1. For example, for 2 colors: \"1 0 0 0 0 1\". If not provided as required, the histogram is equally split into three areas, blue, yellow and red.",std::vector,""); + BBTK_INPUT(ColorLayerImageView2,lstTransparenceBoundaries,"Transparence vector. (The same size of color lst).",std::vector,""); + BBTK_INPUT(ColorLayerImageView2,lstGreyLevelBoundaries,"???EED List of the Grey Level Boundaries to define the color map (grey level outside the color boundaries will not be disayed). Requirement: Must have one more element than the number of colours. For example, for 2 colors: \"50 150 250\". If not provided as required, the histogram is equally split into areas, which number corresponds to the number of colors provided (3 by default).",std::vector,""); + BBTK_INPUT(ColorLayerImageView2,lstRangeForColorBar,"??? EED ",std::vector,""); + BBTK_INPUT(ColorLayerImageView2,PlainOrGradientColor,"true=Plane false=Gradient (Default false)",bool,""); + BBTK_INPUT(ColorLayerImageView2,FittingMode,"Choose the fitting mode between the images, the transformation can be either by Dimension (1), by Spacing (2) or by Pixel (3). If you want to make the choice through a dialog box, choose (-1). Default is by Pixel (3).",int,""); + BBTK_INPUT(ColorLayerImageView2,ColorBarPosition,"default (10,105)",std::vector,""); + BBTK_OUTPUT(ColorLayerImageView2,NewImage,"Image with correct Spacing",vtkImageData*,""); + BBTK_OUTPUT(ColorLayerImageView2,LookupTable,"LookupTable",vtkScalarsToColors*,""); +// BBTK_OUTPUT(ColorLayerImageView2,OutOpacity,"Opacity",int,""); +BBTK_END_DESCRIBE_BLACK_BOX(ColorLayerImageView2); +//===== +// 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) +//===== +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuColorLayerImageView2_h_INCLUDED__ + diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx index 8571c5f..3fd8695 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -121,7 +121,8 @@ void ShowNPoints_Tools::InitCreatePatch_Points() WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); wsp->StopAutoAddPoints(); wsp->StopTrackPoint(); - if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL )){ + if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL )) + { if(wsp->GetModelShowNPoints()->GetLstPointsSize()==4){ CreatePatch_4points(); } @@ -134,9 +135,61 @@ void ShowNPoints_Tools::InitCreatePatch_Points() } 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"); - } + } // if wsp && mesh } +void ShowNPoints_Tools::InitCreateVolumeSurface_Points() +{ + InitCreatePatch_Points(); // 1 group -> 3 groups + + // 3 groups to 4 groups + WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); + wsp->StopAutoAddPoints(); + wsp->StopTrackPoint(); + if( wsp->GetLstModelShowNPointsSize()==3 ) + { + double spc[3]; + double pC1[3]; // fist point + double dx,dy,dz; + double pC2A[3]; // first middle point + double pC2B[3]; // second midle point + double pC3[3]; // last point + double pN[3]; // new over the surface + + vtkPoints *points = bbGetInputMesh()->GetPoints(); + vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New(); + pointLocator->SetDataSet( bbGetInputMesh() ); + pointLocator->BuildLocator(); + spc[0] = bbGetInputSpacing()[0]; + spc[1] = bbGetInputSpacing()[1]; + spc[2] = bbGetInputSpacing()[2]; + wsp->InsertCollectionAfter_(); + wsp->GetCollectionPoint(1,0, pC1); + wsp->GetCollectionPoint(1,2, pC3); + dx=pC3[0]-pC1[0]; + dy=pC3[1]-pC1[1]; + dz=pC3[2]-pC1[2]; + pC2A[0]=pC1[0]+dx*0.33333; pC2A[1]=pC1[1]+dy*0.3333; pC2A[2]=pC1[2]+dz*0.33333; + pC2B[0]=pC1[0]+dx*0.66666; pC2B[1]=pC1[1]+dy*0.6666; pC2B[2]=pC1[2]+dz*0.66666; + + wsp->InsertPoint(pC1[0] ,pC1[1], pC1[2],""); + + NearestPointToMesh(points, pointLocator, spc, pC2A,pN); + wsp->InsertPoint(pN[0] ,pN[1], pN[2],""); + + NearestPointToMesh(points, pointLocator, spc, pC2B,pN); + wsp->InsertPoint(pN[0] ,pN[1], pN[2],""); + + wsp->InsertPoint(pC3[0] ,pC3[1], pC3[2],""); + + // --- Finish --- + wsp->SetOutputBox(); + wsp->UndoRedo_SaveCollection(); + + } // if wsp && mesh +} + + void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector lstY, std::vector lstZ) { WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); @@ -182,7 +235,6 @@ void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector } NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0] ,pM[1], pM[2],""); - if(sect == 0 || sect == 4) lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(pM) ); } @@ -204,9 +256,7 @@ void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector wsp->InsertPoint(p[0] ,p[1], p[2],""); std::copy(std::begin(p), std::end(p), std::begin(centroid)); // --- Group 2 --- - wsp->InsertCollectionAfter_(); - dx = lstX[2]-lstX[3]; dy = lstY[2]-lstY[3]; dz = lstZ[2]-lstZ[3]; @@ -227,12 +277,9 @@ void ShowNPoints_Tools::CreatePatch_Points(std::vector lstX, std::vector } NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0] ,pM[1], pM[2],""); - if(sect == 0 || sect == 4) lstIdNormalSurface.push_back( pointLocator->FindClosestPoint(pM) ); } - pointLocator->Delete(); - // Check normals // 1. Recorrer las normales de lstIdNormals y calcular el promedio -> V1 double *nValue; @@ -730,10 +777,14 @@ void ShowNPoints_Tools::Process() { bbGetInputWidgetShowNPoints()->OnResetCollections_(); } // if Type - if (bbGetInputType()==200) + if (bbGetInputType()==200) // Create patch surface { InitCreatePatch_Points(); } // if Type + if (bbGetInputType()==205) // Create volume surface from points + { + InitCreateVolumeSurface_Points(); + } // if Type if (bbGetInputType()==210) { bbGetInputWidgetShowNPoints()->OnInvertLstPoints_(); diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h index ce3627c..55e1ebc 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h @@ -38,6 +38,7 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools void CreatePatch_3points(); void CreatePatch_4points(); void InitCreatePatch_Points(); + void InitCreateVolumeSurface_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(); @@ -60,7 +61,7 @@ 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 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 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch",int,""); + 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 patch surface - Create Mesh (based on 1 group and 3 or 4 points) 205:Tool 3 or 4 points to volume surface - Create Mesh (based on 1 group and 3 or 4 points) 210: Invert points 220: Move patch center 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch",int,""); BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: normal and direction, 320: centroid and direction, 330: normal and direction, 340: centroid and direction", std::vector,""); BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector, ""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx index 4bc83c8..631c11a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx @@ -40,6 +40,8 @@ //========================================================================= ColorLayerImageViewManager::ColorLayerImageViewManager( ) { + _active = true; + _fitting_mode = 3; _colorLayerImageViewLst.push_back(NULL); // 0 _colorLayerImageViewLst.push_back(NULL); // 1 _colorLayerImageViewLst.push_back(NULL); // 2 @@ -386,16 +388,110 @@ void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity) } //---------------------------------------------------------------------------- -void ColorLayerImageViewManager::SetImage( vtkImageData* img ) +void ColorLayerImageViewManager::SetImageStep1( vtkImageData* img ) { - int i, size=_colorLayerImageViewLst.size(); - for (i=0;iSetImage( img ); - } // if - } // for + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetImage( img ); + } // if + } // for i +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetImageStep2( vtkImageData* img ) +{ + if (img!=NULL) + { +// if (_histogramMinMaxLevel!=NULL) +// { +// _histogramMinMaxLevel->Configure( img ); +// } +// _colorLayerImageViewManager->SetImage( img ); + double spcOriginalLayer[3]; + int dimensionOriginalLayer[3]; + double spcBase[3]; + int dimensionBase[3]; + double newSpc[3]; + this->GetSpcOriginalLayer(0,spcOriginalLayer); + this->GetDimensionOriginalLayer(0,dimensionOriginalLayer); + this->GetSpcBase(0,spcBase); + this->GetDimensionBase(0,dimensionBase); +// if (_sl_SliceImageX!=NULL) +// { +// _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] ); +// _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] ); +// _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] ); +// } + + if ( (spcOriginalLayer[0]!=spcBase[0]) || + (spcOriginalLayer[1]!=spcBase[1]) || + (spcOriginalLayer[2]!=spcBase[2]) || + (dimensionOriginalLayer[0]!=dimensionBase[0]) || + (dimensionOriginalLayer[1]!=dimensionBase[1]) || + (dimensionOriginalLayer[2]!=dimensionBase[2]) + ) + { + // CM + int typeOfTransformation = _fitting_mode; +// // In case of the option is set to create a dialog box. +// if (_fitting_mode == -1) +// { +// bool transformOkDlg; +// wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? "); +// wxDlgTransformByDimensionBySpacingByPixel dlg; +// dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg); +// // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value. +// if (transformOkDlg == false) +// { +// typeOfTransformation = 3; +// } +// } else { +// typeOfTransformation = _fitting_mode; +// } // _fitting_mode -1 + + //EO CM + if (typeOfTransformation == 1) // Adapt spacing + { + newSpc[0] = spcBase[0] * dimensionBase[0] / dimensionOriginalLayer[0]; + newSpc[1] = spcBase[1] * dimensionBase[1] / dimensionOriginalLayer[1]; + newSpc[2] = spcBase[2] * dimensionBase[2] / dimensionOriginalLayer[2]; + } + + if (typeOfTransformation == 2) // keep spacing of the Layer Image + { + newSpc[0] = spcOriginalLayer[0]; + newSpc[1] = spcOriginalLayer[1]; + newSpc[2] = spcOriginalLayer[2]; + } + + if (typeOfTransformation == 3) // Use the spacing of the Base Image + { + newSpc[0] = spcBase[0]; + newSpc[1] = spcBase[1]; + newSpc[2] = spcBase[2]; + } + this->SetNewSpacingLayer(newSpc); + } else { + newSpc[0] = spcOriginalLayer[0]; + newSpc[1] = spcOriginalLayer[1]; + newSpc[2] = spcOriginalLayer[2]; + } // spc !_spcBase dim!__dimBase + this->SetNewSpacingLayer(newSpc); + } // img + + if (_active==true) + { + this->onThreshold(); + if (img==NULL) + { + this->onThresholdRemove( ); + } // img + this->Refresh(); + } // _active + } //---------------------------------------------------------------------------- @@ -467,6 +563,30 @@ void ColorLayerImageViewManager::SetNewSpacingLayer(double *spc) } // for } +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetActive(bool active) +{ + _active = active; +} + +//---------------------------------------------------------------------------- +bool ColorLayerImageViewManager::GetActive() +{ + return _active; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetFittingMode( int fitting_mode ) +{ + _fitting_mode = fitting_mode; +} + +//---------------------------------------------------------------------------- +int ColorLayerImageViewManager::GetFittingMode() +{ + return _fitting_mode; +} + // EOF diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h index 6a4f95f..eaf7e8d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h @@ -68,6 +68,8 @@ class ColorLayerImageViewManager void onThresholdInterpolation( bool interpolation ); void SetSliceFixDynamic( bool fixdin ); void onThresholdChangeOpacity( int opacity ); + void SetImageStep1( vtkImageData* img ); + void SetImageStep2( vtkImageData* img ); void SetImage( vtkImageData* img ); vtkImageData* GetImageChangeInformation(int id); @@ -76,12 +78,17 @@ class ColorLayerImageViewManager void GetDimensionOriginalLayer (int id,int *dim); void GetSpcOriginalLayer (int id,double *spc); void SetNewSpacingLayer (double *spc); + void SetActive (bool active); + bool GetActive(); + void SetFittingMode( int fitting_mode ); + int GetFittingMode(); vtkLookupTable* GetLookupTable(int id); private: std::vector< ColorLayerImageView* > _colorLayerImageViewLst; - + bool _active; + int _fitting_mode; protected: }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index 358817a..b5287a8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -238,6 +238,7 @@ ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewMana return _colorLayerImageViewManager; } +/* //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::SetImage(vtkImageData *img) { @@ -247,7 +248,9 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) { _histogramMinMaxLevel->Configure( img ); } + _colorLayerImageViewManager->SetImage( img ); + double spcOriginalLayer[3]; int dimensionOriginalLayer[3]; double spcBase[3]; @@ -317,7 +320,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) newSpc[1] = spcOriginalLayer[1]; newSpc[2] = spcOriginalLayer[2]; } // spc !_spcBase dim!__dimBase - GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc); } // img @@ -327,9 +329,63 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _colorLayerImageViewManager->onThreshold(); if (img==NULL) _colorLayerImageViewManager->onThresholdRemove( ); RefreshView(); - } // _ative + } // _active +} +*/ + +//---------------------------------------------------------------------------- +void ColorLayerImageViewPanel::SetImage(vtkImageData *img) +{ +// if (img!=NULL) +// { + if (_histogramMinMaxLevel!=NULL) + { + _histogramMinMaxLevel->Configure( img ); + } + + _colorLayerImageViewManager->SetImageStep1( img ); + + double spcBase[3]; + double spcOriginalLayer[3]; + int dimensionBase[3]; + int dimensionOriginalLayer[3]; + // double newSpc[3]; + GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer); + GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer); + GetColorLayerImageViewManager()->GetSpcBase(0,spcBase); + GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase); + GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer); + if (_sl_SliceImageX!=NULL) + { + _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] ); + _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] ); + _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] ); + } + + int typeOfTransformation; + if (_fitting_mode == -1) + { + bool transformOkDlg; + wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? "); + wxDlgTransformByDimensionBySpacingByPixel dlg; + dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg); + // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value. + if (transformOkDlg == false) + { + typeOfTransformation = 3; + } + } else { + typeOfTransformation = _fitting_mode; + } // _fitting_mode -1 + + _colorLayerImageViewManager->SetFittingMode( typeOfTransformation ); + _colorLayerImageViewManager->SetImageStep2( img ); + +// } // img + } +//---------------------------------------------------------------------------- void ColorLayerImageViewPanel::RefreshView() { //EED01 _colorLayerImageView->Refresh(); @@ -364,9 +420,9 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) // w.ShowModal(); printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n"); - int ext[6]; - double spc[6]; - double origin[3]; + int ext[6]; + double spc[6]; + double origin[3]; origin[0] = 0; origin[1] = 0; origin[2] = 0; @@ -383,7 +439,7 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) change -> Modified(); //important change -> Update(); //important SetImage( change->GetOutput() ); - _colorLayerImageViewManager->onThreshold(); + GetColorLayerImageViewManager()->onThreshold(); RefreshView(); } @@ -392,7 +448,7 @@ void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event) { if (_thresholdGo) { - _colorLayerImageViewManager->onThresholdChange(); + GetColorLayerImageViewManager()->onThresholdChange(); RefreshView(); //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; } // _thresholdGo @@ -405,9 +461,9 @@ void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event) _active = _thresholdGo; if (_thresholdGo) { - _colorLayerImageViewManager->onThreshold(); + GetColorLayerImageViewManager()->onThreshold(); }else{ - _colorLayerImageViewManager->onThresholdRemove( ); + GetColorLayerImageViewManager()->onThresholdRemove( ); } RefreshView(); } @@ -415,18 +471,18 @@ void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event) //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdStop() { - if (_thresholdGo) - { - _colorLayerImageViewManager->onThresholdRemove( ); - _thresholdGo=false; - } + if (_thresholdGo) + { + GetColorLayerImageViewManager()->onThresholdRemove( ); + _thresholdGo = false; + } } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) { - _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue()); - RefreshView(); + GetColorLayerImageViewManager()->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + RefreshView(); } //---------------------------------------------------------------------------- @@ -436,9 +492,9 @@ void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event) _colorLayerImageViewManager->SetSliceFixDynamic( fixdin ); if (fixdin==false) { - _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() ); - _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() ); - _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() ); + GetColorLayerImageViewManager()->SetX2( _sl_SliceImageX->GetValue() ); + GetColorLayerImageViewManager()->SetY2( _sl_SliceImageY->GetValue() ); + GetColorLayerImageViewManager()->SetZ2( _sl_SliceImageZ->GetValue() ); } _sl_SliceImageX->Enable(!fixdin); _sl_SliceImageY->Enable(!fixdin); @@ -450,10 +506,10 @@ void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event) //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event) { - _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() ); - _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() ); - _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() ); - _colorLayerImageViewManager->onThreshold(); + GetColorLayerImageViewManager()->SetX2( _sl_SliceImageX->GetValue() ); + GetColorLayerImageViewManager()->SetY2( _sl_SliceImageY->GetValue() ); + GetColorLayerImageViewManager()->SetZ2( _sl_SliceImageZ->GetValue() ); + GetColorLayerImageViewManager()->onThreshold(); RefreshView(); } @@ -467,7 +523,7 @@ int ColorLayerImageViewPanel::GetOpacity() void ColorLayerImageViewPanel::ChangeOpacity() { int opacity = _opacity->GetValue(); - _colorLayerImageViewManager->onThresholdChangeOpacity(opacity); + GetColorLayerImageViewManager()->onThresholdChangeOpacity(opacity); RefreshView(); } @@ -495,6 +551,7 @@ void ColorLayerImageViewPanel::SetActive(bool active) { _cb_ShowHide->SetValue( _active ); } + GetColorLayerImageViewManager()->SetActive( _active ); }